当前位置: 首页>>代码示例>>PHP>>正文


PHP Backend::addError方法代码示例

本文整理汇总了PHP中Backend::addError方法的典型用法代码示例。如果您正苦于以下问题:PHP Backend::addError方法的具体用法?PHP Backend::addError怎么用?PHP Backend::addError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Backend的用法示例。


在下文中一共展示了Backend::addError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: install_check

 public static function install_check()
 {
     //Check the cache folder
     if (!Backend::checkConfigFile()) {
         if (function_exists('posix_getgrgid') && function_exists('posix_getegid')) {
             if ($group = posix_getgrgid(posix_getegid())) {
                 $group = $group['name'];
             }
         }
         $values = array('file' => Backend::getConfigFileLocation(), 'group' => isset($group) ? $group : false);
         Backend::addContent(Render::file('config_value.fix_config.tpl.php', $values));
         return false;
     }
     if (self::get('settings.ConfigValueSet')) {
         return true;
     }
     if (is_post()) {
         $result = true;
         foreach ($_POST as $name => $value) {
             $name = str_replace('_', '.', $name);
             if (in_array($name, array('application.Title', 'application.Moto', 'application.HelpBoxContent', 'application.Description', 'author.Name', 'author.Email', 'author.Website'))) {
                 if (!self::set($name, $value)) {
                     Backend::addError('Could not set ' . $name);
                     $result = false;
                 }
             } else {
                 var_dump('Rejected:', $name);
             }
         }
         self::set('settings.ConfigValueSet', $result);
         Controller::redirect();
     }
     Backend::addContent(Render::file('config_value.values.tpl.php'));
     return false;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:35,代码来源:ConfigValue.obj.php

示例2: action_test

 public function action_test()
 {
     /*$lock = BackendLock::get('testing', BackendLock::LOCK_CUSTOM);
     		if (!$lock) {
     			Backend::addError('Could not aquire lock');
     		} else {
     			Backend::addSuccess('Testing is ' . ($lock->check() ? 'Available' : 'Not Available'));
     		}
     		$lock = BackendLock::release('testing');
     		Backend::addSuccess('Testing is ' . ($lock->check() ? 'Available' : 'Not Available'));
     		if ($lock = BackendLock::get('testing_expiry', BackendLock::LOCK_CUSTOM, '2010-01-01')) {
     			Backend::addSuccess('Testing Expiry is ' . ($lock->check() ? 'Available' : 'Not Available'));
     		}
     		if ($lock = BackendLock::get('testing_type', 5)) {
     			Backend::addSuccess('Testing Type is ' . ($lock->check() ? 'Available' : 'Not Available'));
     		}*/
     if ($lock = BackendLock::get('testing_system', BackendLock::LOCK_SYSTEM)) {
         Backend::addSuccess('Testing Type is ' . ($lock->check() ? 'Available' : 'Not Available'));
     } else {
         Backend::addSuccess('Should not get System lock (no expiry or password)');
     }
     if ($lock = BackendLock::get('testing_system', BackendLock::LOCK_SYSTEM, 'now + 1 minutes', 'Abc123')) {
         Backend::addSuccess('Testing Type is ' . ($lock->check() ? 'Available' : 'Not Available'));
     } else {
         Backend::addError('Could not get System lock');
     }
     return false;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:28,代码来源:BackendLock.obj.php

示例3: add

 public static function add($hook, $type, $class, array $options = array())
 {
     if (!Backend::getDB('default')) {
         return false;
     }
     $mode = array_key_exists('mode', $options) ? $options['mode'] : '*';
     $name = array_key_exists('name', $options) ? $options['name'] : ucwords($class . ' ' . $type . ' ' . $hook);
     $description = array_key_exists('description', $options) ? $options['description'] : '';
     $method = array_key_exists('method', $options) ? $options['method'] : 'hook_' . ($type == 'post' ? 'post_' : '') . strtolower($hook);
     $global = array_key_exists('global', $options) ? $options['global'] : 0;
     $sequence = array_key_exists('sequence', $options) ? $options['sequence'] : 0;
     //Certain hooks should be global
     if (in_array($hook, array('init'))) {
         $global = 1;
     }
     $data = array('class' => $class, 'hook' => $hook, 'type' => $type, 'mode' => $mode, 'name' => $name, 'description' => $description, 'method' => $method, 'global' => $global, 'sequence' => $sequence);
     $hook = new HookObj();
     if ($hook->replace($data)) {
         Backend::addSuccess('Added hook ' . $name . '(' . $class . '::' . $method . ')');
         $toret = true;
     } else {
         Backend::addError('Could not add hook ' . $name . '(' . $class . '::' . $method . ')');
         $toret = false;
     }
     return $toret;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:26,代码来源:Hook.obj.php

示例4: checkAliases

 private static function checkAliases($query)
 {
     if (file_exists(APP_FOLDER . '/configs/queries.php')) {
         $aliases = (include APP_FOLDER . '/configs/queries.php');
     }
     if (empty($aliases)) {
         if (Controller::$debug) {
             Backend::addError('Invalid query aliases');
         }
         return $query;
     }
     if (array_key_exists($query, $aliases)) {
         return $aliases[$query];
     }
     foreach ($aliases as $test => $new_query) {
         if ($test == $query) {
             return $new_query;
         } else {
             $search = array('/', ':any', ':num', ':controller', ':area_ctl', ':table_ctl');
             //TODO Get the controllers from the Component table, remove area and table
             $replace = array('\\/', '([^\\/]+)', '([0-9]+)', '(home)', '(admin)', '(content|comment|content_revision|tag|image|backend_user|hook)');
             $pattern = '/^' . str_replace($search, $replace, $test) . '\\/?$/';
             preg_match_all($pattern, $query, $matches);
             if (count($matches[0])) {
                 foreach ($matches as $key => $match) {
                     $new_query = str_replace('$' . $key, current($match), $new_query);
                 }
                 return $new_query;
             }
         }
     }
     return $query;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:33,代码来源:Request.obj.php

示例5: action_authorized

 public function action_authorized()
 {
     $auth_t = array_key_exists('OAuthAuthToken', $_SESSION) ? $_SESSION['OAuthAuthToken'] : false;
     if ($auth_t) {
         $access_t = $this->oauth->getAccessToken($auth_t);
         if ($access_t) {
             Backend::addSuccess('Sucessfully logged into Twitter');
             $data = array('screen_name' => $access_t['screen_name'], 'twitter_id' => $access_t['user_id'], 'oauth_token' => $access_t['oauth_token'], 'oauth_secret' => $access_t['oauth_token_secret'], 'active' => 1);
             $twit = new TwitterObj();
             if ($twit->replace($data)) {
             } else {
                 Backend::addError('Could not record Twitter Auth information');
             }
             if (!empty($_SESSION['TwitterRedirect'])) {
                 $url = $_SESSION['TwitterRedirect'];
                 unset($_SESSION['TwitterRedirect']);
                 Controller::redirect($url);
             }
         } else {
             Backend::addError('Could not get Access Token');
         }
     } else {
         Backend::addError('No Authentication Token');
     }
     return true;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:26,代码来源:Twitter.obj.php

示例6: execute

 private static function execute($search_string)
 {
     self::$error_msg = false;
     if (Controller::$debug) {
         var_dump(self::$url . '?' . $search_string);
     }
     $returned = curl_request(self::$url . '?' . $search_string);
     if (!$returned) {
         self::$error_msg = 'Invalid Twitter API request';
         if (Controller::$debug) {
             var_dump(self::$url . '?' . $search_string);
         }
         return false;
     } else {
         if (!($result = json_decode($returned))) {
             self::$error_msg = 'Invalid JSON returned: ' . $returned;
             return false;
         }
     }
     if (array_key_exists('error', $result)) {
         self::$error_msg = $result->error;
     } else {
         return is_object($result) && isset($result->results) ? $result->results : false;
     }
     if (!empty(self::$error_msg) && Controller::$debug) {
         Backend::addError('TwitterSearch: ' . self::$error_msg);
     }
     return false;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:29,代码来源:TwitterSearch.obj.php

示例7: check

 public static function check()
 {
     if (!empty($_COOKIE['remembered'])) {
         $query = new SelectQuery('PersistUser');
         $persist = $query->filter('MD5(CONCAT(`id`, `user_id`, `random`)) = :hash')->fetchAssoc(array(':hash' => $_COOKIE['remembered']));
         if ($persist) {
             //Get User
             $User = self::getObject('BackendUser');
             if (!$User instanceof DBObject) {
                 return false;
             }
             $query = BackendUser::getQuery();
             $query->filter('`backend_users`.`id` = :id');
             $params = array(':id' => $persist['user_id']);
             $User->read(array('query' => $query, 'parameters' => $params, 'mode' => 'object'));
             if ($User->object) {
                 $_SESSION['BackendUser'] = $User->object;
                 //Remove, and reremember
                 if (self::remember($User->object)) {
                     $query = new DeleteQuery('PersistUser');
                     $query->filter('`id` = :id')->limit(1);
                     $query->execute(array(':id' => $persist['id']));
                 } else {
                     Backend::addError('Could not reremember');
                 }
                 return $User->object;
             } else {
                 //Backend::addError('Invalid remembered user');
             }
         }
     }
     return false;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:33,代码来源:PersistUser.obj.php

示例8: hook_post_update

 public static function hook_post_update($data, $object)
 {
     if ($object instanceof ContentObj && !$object->array['from_file']) {
         if (!self::createNewRevision($object->array['id'], $object->array['markdown'], array_key_exists('revision_summary', $data) ? $data['revision_summary'] : false)) {
             Backend::addError('Could not add Content Revision');
         }
     }
     return true;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:9,代码来源:ContentRevision.obj.php

示例9: hook_output

 public static function hook_output($to_print)
 {
     if (empty($to_print['values']) || empty($to_print['options'])) {
         Backend::addError('Values and options are required');
         return false;
     } else {
         $to_print = self::make_bandwidth_chart($to_print['values'], $to_print['options']);
     }
     return $to_print;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:10,代码来源:OfcView.obj.php

示例10: action_toggle

 /**
  * @todo Make this a POST only
  */
 public function action_toggle($id, $field)
 {
     $result = parent::action_toggle($id, $field, false);
     if ($result && $result->array['active']) {
         if (call_user_func(array($result->array['name'], 'install'))) {
         } else {
             Backend::addError('Could not install component');
         }
     }
     return $result;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:14,代码来源:Component.obj.php

示例11: validate

 function validate($data, $action, $options = array())
 {
     $toret = true;
     $data = parent::validate($data, $action, $options);
     if ($data) {
         if (empty($data['expire'])) {
             Backend::addError('System Locks must expire');
             $toret = false;
         }
     }
     return $toret ? $data : false;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:12,代码来源:BackendSystemLockObj.obj.php

示例12: hook_output

 public static function hook_output($to_print)
 {
     Backend::add('BackendErrors', Backend::getError());
     Backend::add('BackendSuccess', Backend::getSuccess());
     Backend::add('BackendNotices', Backend::getNotice());
     Backend::add('BackendInfo', Backend::getInfo());
     Backend::setError();
     Backend::setSuccess();
     Backend::setNotice();
     Backend::setInfo();
     $content = Backend::getContent();
     if (empty($content)) {
         ob_start();
         var_dump($to_print);
         $content = ob_get_clean();
         if (substr($content, 0, 4) != '<pre') {
             $content = '<pre>' . $content . '</pre>';
         }
         Backend::addContent($content);
     }
     $layout = Backend::get('HTMLLayout', 'index');
     if (!Render::checkTemplateFile($layout . '.tpl.php')) {
         if (SITE_STATE != 'production') {
             Backend::addError('Missing Layout ' . $layout);
         }
         $layout = 'index';
     }
     $to_print = Render::file($layout . '.tpl.php');
     $to_print = self::addLastContent($to_print);
     $to_print = self::replace($to_print);
     $to_print = self::rewriteLinks($to_print);
     $to_print = self::addLinks($to_print);
     $to_print = self::formsAcceptCharset($to_print);
     //TODO fix this
     if (Component::isActive('BackendFilter')) {
         $BEFilter = new BEFilterObj();
         $BEFilter->read();
         $filters = $BEFilter->list ? $BEFilter->list : array();
         foreach ($filters as $row) {
             if (class_exists($row['class'], true) && is_callable(array($row['class'], $row['function']))) {
                 $to_print = call_user_func(array($row['class'], $row['function']), $to_print);
             }
         }
     }
     //TODO Make this configurable
     if (ConfigValue::get('html_view.TidyHTML') && function_exists('tidy_repair_string')) {
         $to_print = tidy_repair_string($to_print);
     }
     return $to_print;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:50,代码来源:HtmlView.obj.php

示例13: add

 /**
  * Perhaps subject can be omitted, and defaults to a value that will allow the an action
  * for all subjects? Eg, display.
  */
 public static function add($role, $action, $subject, $subject_id = 0, array $options = array())
 {
     if (!Backend::getDB('default')) {
         return false;
     }
     //Loop through arrays
     if (is_array($role)) {
         $result = 0;
         foreach ($role as $one_role) {
             if (self::add($one_role, $action, $subject, $subject_id, $options)) {
                 $result++;
             }
         }
         return $result;
     }
     if (is_array($action)) {
         $result = 0;
         foreach ($action as $one_action) {
             if (self::add($role, $one_action, $subject, $subject_id, $options)) {
                 $result++;
             }
         }
         return $result;
     }
     if (is_array($subject)) {
         $result = 0;
         foreach ($subject as $one_subject) {
             if (self::add($role, $role, $one_subject, $subject_id, $options)) {
                 $result++;
             }
         }
         return $result;
     }
     if (is_array($subject_id)) {
         $options = $subject_id;
         $subject_id = 0;
     }
     $control = array_key_exists('control', $options) ? $options['control'] : '100';
     $system = array_key_exists('system', $options) ? $options['system'] : 0;
     $data = array('role' => $role, 'action' => $action, 'subject' => class_for_url($subject), 'subject_id' => $subject_id, 'control' => $control, 'system' => $system, 'active' => 1);
     $permission = new PermissionObj();
     if ($permission->replace($data) !== false) {
         Backend::addSuccess('Added permission to ' . $action . ' for ' . $role);
         $result = true;
     } else {
         Backend::addError('Could not add permission to ' . $action . ' for ' . $role);
         $result = false;
     }
     return $result;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:54,代码来源:Permission.obj.php

示例14: install

 public static function install(array $options = array())
 {
     $options['drop_table'] = array_key_exists('drop_table', $options) ? $options['drop_table'] : true;
     $toret = parent::install($options);
     foreach (self::getDefaults() as $assignment) {
         if (GateKeeper::assign($assignment['role'], $assignment['access_type'], $assignment['access_id'])) {
             Backend::addSuccess('Added assignment to ' . $assignment['role']);
             $toret = $toret && true;
         } else {
             Backend::addError('Could not add assignment to ' . $assignment['role']);
             $toret = false;
         }
     }
     return $toret;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:15,代码来源:Assignment.obj.php

示例15: validate

 function validate($data, $action, $options = array())
 {
     $data = parent::validate($data, $action, $options);
     if (!$data) {
         return $data;
     }
     switch ($action) {
         case 'create':
             $data['active'] = array_key_exists('active', $data) ? $data['active'] : true;
             //We need either an email, mobile number or username to register a user
             //Lower ASCII only
             if (!empty($data['username'])) {
                 $data['username'] = filter_var(trim($data['username']), FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
                 //TODO Make the banned usernames configurable
                 $banned_usernames = array('root', 'admin', 'superadmin', 'superuser', 'webadmin', 'postmaster', 'webdeveloper', 'webmaster', 'administrator', 'sysadmin');
                 if (in_array($data['username'], $banned_usernames) && BackendUser::hasSuperUser()) {
                     Backend::addError('Please choose a valid username');
                     return false;
                 }
             }
             if (empty($data['username']) && empty($data['email']) && empty($data['mobile'])) {
                 Backend::addError('Please provide a username');
             }
             //If the username is an email address, make it the email address
             if (!empty($data['username']) && filter_var($data['username'], FILTER_VALIDATE_EMAIL)) {
                 if (!empty($data['email'])) {
                     list($data['username'], $data['email']) = array($data['email'], $data['username']);
                 } else {
                     $data['email'] = $data['username'];
                     unset($data['username']);
                 }
             }
             $data['salt'] = get_random('numeric');
             $data['password'] = md5($data['salt'] . $data['password'] . Controller::$salt);
             if (ConfigValue::get('application.confirmUser')) {
                 $data['confirmed'] = false;
             } else {
                 $data['confirmed'] = array_key_exists('confirmed', $data) ? $data['confirmed'] : true;
             }
             break;
         case 'update':
             if (!empty($data['password'])) {
                 $data['password'] = md5($this->array['salt'] . $data['password'] . Controller::$salt);
             }
             break;
     }
     return $data;
 }
开发者ID:jrgns,项目名称:backend-php,代码行数:48,代码来源:BackendUserObj.obj.php


注:本文中的Backend::addError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。