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


PHP add_error函数代码示例

本文整理汇总了PHP中add_error函数的典型用法代码示例。如果您正苦于以下问题:PHP add_error函数的具体用法?PHP add_error怎么用?PHP add_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: display

 function display($template)
 {
     $template_path = $this->template_dir . $template;
     if (!file_exists($template_path)) {
         add_error(_("Template error: No such template file:") . $template_path);
         return false;
     }
     $cache_id = md5(realpath($template_path));
     $cache_path = $this->cache_dir . basename($template) . '.' . $cache_id . '.inc';
     if (!file_exists($cache_path) || filemtime($cache_path) <= filemtime($template_path)) {
         require 'tags.inc';
         $compiled = preg_replace($find, $replace, file_get_contents($template_path));
         $compiled = preg_replace($empty_blocks, "\n", $compiled);
         if (empty($compiled) || !$compiled) {
             add_error(_("Template error: Error caching template file:") . $template);
             return false;
         } else {
             if (!($h = @fopen($cache_path, 'w'))) {
                 add_error(_("Template error: could not write to template cache directory."));
                 return false;
             }
             fwrite($h, $compiled);
             fclose($h);
         }
     }
     extract($this->vars);
     include $cache_path;
     return true;
 }
开发者ID:hasshy,项目名称:sahana-tw,代码行数:29,代码来源:Whiz.php

示例2: modules

 function modules($id = '')
 {
     if (empty($id)) {
         redirect($this->uri->rsegments[1] . '/listing');
     }
     if ($_POST) {
         $sql = "\n                SELECT da.*, a.name, a.action\n                FROM disposition_action da\n                JOIN action a ON da.action_id = a.id\n                WHERE da.status < 3 AND parent = (\n                    SELECT id FROM disposition_action WHERE action_id = ? AND ref = ?\n                )\n            ";
         $param = array($this->_action['id'], $id);
         $modules = $this->db->query($sql, $param)->result_array();
         if (!empty($modules)) {
             add_error(l('Modules have not been finished yet'));
         } else {
             if (empty($this->workflow['pages'])) {
                 redirect($this->_name . '/summary/' . $id);
             } else {
                 // redirect($this->_name . '/' . $this->workflow['pages'][0] . '/' . $id);
                 redirect($this->action_uri . '/' . $id);
             }
         }
     }
     $user = $this->auth->get_user();
     $sql = "\n            SELECT da.*, a.name, a.action\n            FROM disposition_action da\n            JOIN action a ON da.action_id = a.id\n            JOIN disposition d ON da.disposition_id = d.id\n            WHERE parent = (\n                SELECT id FROM disposition_action WHERE action_id = ? AND ref = ?\n            )\n        ";
     $param = array($this->_action['id'], $id);
     $this->_data['modules'] = $this->db->query($sql, $param)->result_array();
     $config = array('fields' => array('name', 'status'), 'names' => array('Action'), 'formats' => array('callback__act', 'param_short(disposition_status)'), 'show_checkbox' => false, 'actions' => array());
     $this->load->library('xgrid', $config, 'module_list');
 }
开发者ID:rip-projects,项目名称:ark-php,代码行数:27,代码来源:workflow_controller.php

示例3: save

 public function save()
 {
     $post = $this->input->post();
     if (!$post || !$this->input->post('translate')) {
         add_error(translate('Une erreur est survenue'));
         redirect('traductions/index');
     }
     $issetLang = isset($post['lang']);
     $lang = $issetLang ? $post['lang'] : 'fr';
     if ($issetLang) {
         unset($post['lang']);
     }
     unset($post['translate']);
     $fullTrads = $this->traductor->getFull();
     foreach ($fullTrads as $file => $trads) {
         foreach ($trads as $id => $trad) {
             if (isset($post['exclude-' . $id]) && $post['exclude-' . $id]) {
                 $fullTrads[$file][$id]['excluded'][$lang] = '1';
             } else {
                 $fullTrads[$file][$id]['excluded'][$lang] = '0';
             }
             if (isset($post['ignore-' . $id]) && $post['ignore-' . $id]) {
                 $fullTrads[$file][$id]['ignored'][$lang] = '1';
             } else {
                 $fullTrads[$file][$id]['ignored'][$lang] = '0';
             }
         }
     }
     $this->traductor->setFull($fullTrads);
     $this->traductor->complete($post, $lang);
     $this->traductor->translation($lang);
     add_success(translate('La traduction a bien été effectuée'));
     redirect('traductions/index');
 }
开发者ID:Cevantime,项目名称:site-core-modules,代码行数:34,代码来源:Index.php

示例4: save

 public function save($id = null)
 {
     $this->load->helper('memberspace/authorization');
     $this->load->helper('flashmessages/flashmessages');
     $this->load->model('memberspace/user');
     $this->load->helper('form');
     $datas = array();
     if (isset($_POST) && isset($_POST['save-user'])) {
         $datas = $_POST;
         unset($_POST['save-user']);
         if (isset($_POST['id']) && $_POST['id']) {
             if (!user_can('update', 'user', $_POST['id'])) {
                 add_error(translate('Vous ne pouvez pas modifier cet utilisateur'));
             }
         } else {
             if (!user_can('add', 'user', $_POST['id'])) {
                 add_error(translate('Vous ne pouvez pas ajouter d\'utilisateur'));
             }
         }
         if ($this->user->fromPost() !== false) {
             add_success(translate('L\'utilisateur a bien été ajouté'));
             redirect('bo/users/all');
         } else {
             add_error($this->form_validation->error_string());
         }
     } else {
         if ($id) {
             $datas = $this->user->getId($id, 'array');
         }
     }
     return $datas;
 }
开发者ID:Cevantime,项目名称:site-core-modules,代码行数:32,代码来源:Users.php

示例5: _save

 function _save($id = null)
 {
     $this->_view = $this->_name . '/show';
     $model = $this->_model();
     if ($_POST) {
         if ($this->_validate()) {
             $_POST['id'] = $id;
             try {
                 $tags = $_POST['tags'];
                 unset($_POST['tags']);
                 $id = $model->save($_POST, $id);
                 $model->update_tag($tags, $id);
                 if (!$this->input->is_ajax_request()) {
                     redirect($this->_get_uri('listing'));
                 }
                 add_info($id ? l('Record updated') : l('Record added'));
             } catch (Exception $e) {
                 add_error(l($e->getMessage()));
             }
         }
     } else {
         if ($id !== null) {
             $this->_data['id'] = $id;
             $_POST = $model->get($id);
             $_POST['tags'] = $model->get_tag($id);
         }
     }
 }
开发者ID:rip-projects,项目名称:ark-php,代码行数:28,代码来源:base_post_controller.php

示例6: form_fields

 function form_fields($values = array())
 {
     $fields = parent::form_fields();
     $CI =& get_instance();
     $CI->load->module_model(BLOG_FOLDER, 'blog_users_model');
     $CI->load->module_model(BLOG_FOLDER, 'blog_posts_model');
     $post_title = '';
     $post_options = $CI->blog_posts_model->options_list('id', 'title', array(), 'date_added desc');
     if (empty($post_options)) {
         return lang('blog_error_no_posts_to_comment');
     }
     $fields['post_id'] = array('type' => 'select', 'options' => $post_options, 'label' => 'Post');
     if (!empty($values['id'])) {
         $post = $CI->blog_posts_model->find_by_key($values['post_id']);
         $post_title = $post->title;
         if (!$post->is_published()) {
             add_error(lang('blog_post_is_not_published'));
         }
         $fields['post_id'] = array('type' => 'hidden', 'value' => $post_title, 'displayonly' => TRUE);
         $fields['post_title'] = array('label' => 'Post', 'value' => $post_title, 'order' => 1);
         $fields['post_title']['displayonly'] = TRUE;
         $fields['post_published']['displayonly'] = TRUE;
         $fields['author_email']['displayonly'] = TRUE;
         $fields['author_name']['displayonly'] = TRUE;
         $fields['post_title']['displayonly'] = TRUE;
         $fields['author_website']['displayonly'] = TRUE;
         $fields['ip_host']['displayonly'] = TRUE;
         $fields['date_submitted'] = array('displayonly' => TRUE, 'value' => english_date($values['date_added'], TRUE));
         $ip_host = !empty($values['author_ip']) ? gethostbyaddr($values['author_ip']) . ' (' . $values['author_ip'] . ')' : '';
         $fields['ip_host'] = array('label' => 'IP/Host', 'value' => $ip_host, 'order' => 5, 'displayonly' => TRUE);
         $fields['Reply to this Comment'] = array('type' => 'section');
         $replies = $this->find_all_array(array('parent_id' => $values['id']));
         $reply_arr = array();
         foreach ($replies as $r) {
             $reply_arr[] = $r['content'];
         }
         $fields['replies'] = array('label' => 'Replies', 'displayonly' => TRUE, 'value' => implode('<br /><br />', $reply_arr));
         if ($values['author_id'] == $CI->fuel_auth->user_data('id') or $CI->fuel_auth->is_super_admin()) {
             $fields['reply'] = array('label' => 'Reply', 'type' => 'textarea');
             $notify_options = array('Commentor' => lang('blog_comment_notify_option2'), 'All' => lang('blog_comment_notify_option1'), 'None' => lang('blog_comment_notify_option3'));
             $fields['reply_notify'] = array('label' => 'Notfiy', 'type' => 'enum', 'options' => $notify_options);
         }
         // hidden
         $fields['author_ip'] = array('type' => 'hidden');
     } else {
         $fields['author_ip'] = array('type' => 'hidden', 'value' => $_SERVER['REMOTE_ADDR'], 'label' => 'Author IP Address');
         $fields['is_spam'] = array('type' => 'hidden');
         $fields['date_added']['type'] = 'hidden';
         // so it will auto add
         $fields['last_modified']['type'] = 'hidden';
         // so it will auto add
     }
     // set author to current fuel user
     if (empty($fields['author_id']) and $CI->fuel_auth->user_data('id')) {
         $fields['author_id'] = array('value' => $CI->fuel_auth->user_data('id'));
     }
     $fields['author_id'] = array('type' => 'hidden');
     return $fields;
 }
开发者ID:kieranklaassen,项目名称:FUEL-CMS,代码行数:59,代码来源:blog_comments_model.php

示例7: spam_receive

function spam_receive()
{
    //`spam_id``user``IP``type`
    if (isset($_POST['this_is_spam'])) {
        //KOlla om det är admin som säger
        if (isset($_SESSION[PREFIX . 'user_id']) && user_get_admin($_SESSION[PREFIX . 'user_id']) > 1) {
            foreach ($_POST['id'] as $s_id) {
                $sql = "UPDATE " . PREFIX . sql_safe($_POST['type']) . " SET is_spam=2 WHERE id=" . sql_safe($s_id) . ";";
                echo "<br />DEBUG1827: {$sql}";
                if (mysql_query($sql)) {
                    add_message($_POST['type'] . " " . $s_id . " marked as spam.");
                } else {
                    add_error("There was some kind of error... (errorcode 1726)");
                }
            }
        } else {
            $sql = "INSERT INTO " . PREFIX . "spam SET type='" . sql_safe($_POST['type']) . "', spam_id=" . sql_safe($_POST['id']) . ", ";
            //Om man är inloggad
            if (isset($_SESSION[PREFIX . 'user_id'])) {
                $sql .= "user=" . sql_safe($_SESSION[PREFIX . 'user_id']) . ";";
            } else {
                $sql .= "IP='" . sql_safe($_SERVER['REMOTE_ADDR']) . "';";
            }
            // echo "<br />DEBUG1012: $sql";
            if (mysql_query($sql)) {
                add_message("Thank you for helping us keep the site spam-free!");
            } else {
                add_error("There was some kind of error... (errorcode 1727)");
            }
        }
    }
    if (isset($_POST['this_is_not_spam'])) {
        //KOlla om det är admin som säger
        if (isset($_SESSION[PREFIX . 'user_id']) && user_get_admin($_SESSION[PREFIX . 'user_id']) > 1) {
            foreach ($_POST['id'] as $s_id) {
                $sql = "UPDATE " . PREFIX . sql_safe($_POST['type']) . " SET is_spam=-2 WHERE id=" . sql_safe($s_id) . ";";
                echo "<br />DEBUG1827: {$sql}";
                if (mysql_query($sql)) {
                    add_message($_POST['type'] . " " . $s_id . " marked as not spam.");
                } else {
                    add_error("There was some kind of error... (errorcode 1728)");
                }
            }
        } else {
            $sql = "DELETE FROM " . PREFIX . "spam WHERE type='" . sql_safe($_POST['type']) . "' AND spam_id=" . sql_safe($_POST['id']) . " AND ";
            //Om man är inloggad
            if (isset($_SESSION[PREFIX . 'user_id'])) {
                $sql .= "user=" . sql_safe($_SESSION[PREFIX . 'user_id']) . ";";
            } else {
                $sql .= "IP='" . sql_safe($_SERVER['REMOTE_ADDR']) . "';";
            }
            if (mysql_query($sql)) {
                add_message("Thank you for helping us keep the site spam-free!");
            } else {
                add_error("There was some kind of error... (errorcode 1729)");
            }
        }
    }
}
开发者ID:carriercomm,项目名称:shell-2,代码行数:59,代码来源:spam.php

示例8: upload

 public function upload()
 {
     $this->load->library('form_builder');
     $this->load->module_model(FUEL_FOLDER, 'fuel_navigation_groups_model');
     $this->load->module_model(FUEL_FOLDER, 'fuel_navigation_model');
     $this->js_controller_params['method'] = 'upload';
     if (!empty($_POST)) {
         $params = $this->input->post();
         if (!empty($_FILES['file']['name'])) {
             $error = FALSE;
             $file_info = $_FILES['file'];
             $params['file_path'] = $file_info['tmp_name'];
             $params['var'] = $this->input->post('variable') ? $this->input->post('variable', TRUE) : 'nav';
             $params['language'] = $this->input->post('language', TRUE);
             if (!$this->fuel->navigation->upload($params)) {
                 $error = TRUE;
             }
             if ($error) {
                 add_error(lang('error_upload'));
             } else {
                 // change list view page state to show the selected group id
                 $this->fuel->admin->set_notification(lang('navigation_success_upload'), Fuel_admin::NOTIFICATION_SUCCESS);
                 redirect(fuel_url('navigation?group_id=' . $params['group_id']));
             }
         } else {
             add_error(lang('error_upload'));
         }
     }
     $fields = array();
     $nav_groups = $this->fuel_navigation_groups_model->options_list('id', 'name', array('published' => 'yes'), 'id asc');
     if (empty($nav_groups)) {
         $nav_groups = array('1' => 'main');
     }
     // load custom fields
     $this->form_builder->load_custom_fields(APPPATH . 'config/custom_fields.php');
     $fields['group_id'] = array('type' => 'select', 'options' => $nav_groups, 'module' => 'navigation_group');
     $fields['file'] = array('type' => 'file', 'accept' => '');
     $fields['variable'] = array('label' => 'Variable', 'value' => $this->input->post('variable') ? $this->input->post('variable', TRUE) : 'nav', 'size' => 10);
     $fields['language'] = array('type' => 'select', 'options' => $this->fuel->language->options(), 'first_option' => lang('label_select_one'));
     $fields['clear_first'] = array('type' => 'enum', 'options' => array('yes' => 'yes', 'no' => 'no'));
     $fields['__fuel_module__'] = array('type' => 'hidden');
     $fields['__fuel_module__']['value'] = $this->module;
     $fields['__fuel_module__']['class'] = '__fuel_module__';
     $fields['__fuel_module_uri__'] = array('type' => 'hidden');
     $fields['__fuel_module_uri__']['value'] = $this->module_uri;
     $fields['__fuel_module_uri__']['class'] = '__fuel_module_uri__';
     $this->form_builder->set_fields($fields);
     $this->form_builder->submit_value = '';
     $this->form_builder->use_form_tag = FALSE;
     $this->form_builder->set_field_values($_POST);
     $vars['instructions'] = lang('navigation_import_instructions');
     $vars['form'] = $this->form_builder->render();
     $vars['back_action'] = ($this->fuel->admin->last_page() and $this->fuel->admin->is_inline()) ? $this->fuel->admin->last_page() : fuel_uri($this->module_uri);
     $crumbs = array($this->module_uri => $this->module_name, lang('action_upload'));
     $this->fuel->admin->set_titlebar($crumbs);
     $this->fuel->admin->render('upload', $vars, Fuel_admin::DISPLAY_NO_ACTION);
 }
开发者ID:ressphere,项目名称:cb_iloveproperty,代码行数:57,代码来源:navigation.php

示例9: add_organization

 function add_organization($id)
 {
     if (!empty($_POST['org_id'])) {
         $this->_model()->add_organization($id, $_POST['org_id']);
         add_info(l('Group data added.'));
     } else {
         add_error(l('No data to add.'));
     }
     redirect($_SERVER['HTTP_REFERER']);
 }
开发者ID:rip-projects,项目名称:ark-php,代码行数:10,代码来源:group.php

示例10: __construct

 function __construct()
 {
     parent::__construct();
     $this->config->load('seo');
     $this->js_controller_params['module'] = 'seo';
     $this->load->module_language(SEO_FOLDER, 'seo', $this->config->item('language'));
     if ($this->config->item('dev_password', 'fuel')) {
         add_error(lang('error_seo_dev_password'));
     }
 }
开发者ID:kieranklaassen,项目名称:FUEL-CMS,代码行数:10,代码来源:Seo_base_controller.php

示例11: delete

 public function delete()
 {
     global $db;
     $query = "DELETE FROM `student_leaves_of_absence` where `id`=" . $db->qstr($this->id);
     if (!$db->Execute($query)) {
         add_error("Failed to remove leave of absence from database.");
         application_log("error", "Unable to delete a student_leaves_of_absence record. Database said: " . $db->ErrorMsg());
     } else {
         add_success("Successfully removed Leave of Absence.");
     }
 }
开发者ID:nadeemshafique,项目名称:entrada-1x,代码行数:11,代码来源:LeaveOfAbsence.class.php

示例12: ensure_authenticated

function ensure_authenticated()
{
    if ($_SESSION['authenticated'] != true) {
        add_error("You must be authenticated to view this page");
        header("Location: index.php");
        exit(0);
        /* return would just return from this function... not good enough */
    } else {
        debug("passed authentication check ok!\n");
    }
}
开发者ID:ahiliation,项目名称:beautifulwork,代码行数:11,代码来源:dvd-util.php

示例13: add_privilege

 function add_privilege($id)
 {
     if (!empty($_POST['uri'])) {
         $this->_model()->add_privilege($id, $_POST['uri']);
         $this->cache->context_delete($this->_model()->CACHE_KEY_PRIVILEGE);
         add_info(l('Privilege added.'));
     } else {
         add_error(l('No privilege to add.'));
     }
     redirect($_SERVER['HTTP_REFERER']);
 }
开发者ID:rip-projects,项目名称:ark-php,代码行数:11,代码来源:base_role_controller.php

示例14: setSequence

 /**
  * User is included to prevent tampering with another user's sequence.
  * @param User $user
  * @param array $ids
  */
 public function setSequence($user_id, array $ids)
 {
     global $db;
     $stmt = $db->Prepare('update `student_research` set `priority`=? where `user_id`=? and `id`=?');
     foreach ($ids as $priority => $id) {
         if (!$db->Execute($stmt, array($priority, $user_id, $id))) {
             add_error("Failed to re-sequence Research Citations.");
             application_log("error", "Unable to modify a student_research record. Database said: " . $db->ErrorMsg());
             break;
         }
     }
 }
开发者ID:nadeemshafique,项目名称:entrada-1x,代码行数:17,代码来源:ResearchCitations.class.php

示例15: notice_receive

function notice_receive()
{
    if (isset($_POST['notice_close'])) {
        //Check that logged in user owns the notice
        if (login_check_logged_in_mini() > 0) {
            $sql = "UPDATE " . PREFIX . "notice \r\n\t\t\tSET closed=NOW()\r\n\t\t\tWHERE user=" . sql_safe($_SESSION[PREFIX . 'user_id']) . " AND id=" . sql_safe($_POST['notice_id']) . ";";
            if (!mysql_query($sql)) {
                add_error(sprintf(_("Notice could not be closed.<br />SQL: %s<br />Error: %s"), $sql, mysql_error()));
            }
        }
    }
}
开发者ID:carriercomm,项目名称:shell-2,代码行数:12,代码来源:notice.php


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