コード例 #1
0
 function validation_errors_array()
 {
     if (FALSE === ($OBJ =& _get_validation_object())) {
         return array();
     }
     return $OBJ->error_array();
 }
コード例 #2
0
ファイル: ABN_Controller.php プロジェクト: silvranz/ovs
 public function setCustomError($field_name = false, $error = false)
 {
     if (!empty($field_name) && !empty($error)) {
         $validator =& _get_validation_object();
         $validator->_field_data[$field_name] = array('field' => $field_name, 'rules' => false, 'postdata' => false, 'is_array' => false, 'error' => $error);
     }
 }
コード例 #3
0
ファイル: form_helper.php プロジェクト: PoppyLi/PCMS
function form_errors()
{
    if (FALSE === ($OBJ =& _get_validation_object())) {
        return '';
    }
    return $OBJ->get_errors();
}
コード例 #4
0
 function validation_errors($prefix = '', $suffix = '')
 {
     if (FALSE === ($OBJ =& _get_validation_object())) {
         return '';
     }
     return $OBJ->error_string($prefix, $suffix);
 }
コード例 #5
0
ファイル: MY_form_helper.php プロジェクト: navruzm/navruz.net
function set_value($field = '', $default = '')
{
    if (!isset($_POST[$field])) {
        return $default;
    }
    if (FALSE === ($OBJ =& _get_validation_object())) {
        return form_prep($_POST[$field], $field);
    }
    return form_prep($OBJ->set_value($field, $_POST[$field]), $field);
}
コード例 #6
0
 function keepValidationErrors()
 {
     if (FALSE === ($OBJ =& _get_validation_object())) {
         // No action
     } else {
         $errors = $OBJ->error_array();
         foreach ($errors as $error) {
             set_message_error($error);
         }
     }
 }
コード例 #7
0
 function validation_errors($prefix = '', $suffix = '')
 {
     if (FALSE === ($OBJ =& _get_validation_object())) {
         return '';
     }
     if ($prefix == '' && $suffix == '') {
         $prefix = '<p class="error">';
         $suffix = '</p>';
     }
     return $OBJ->error_string($prefix, $suffix);
 }
コード例 #8
0
/**
 * Apply Bootstrap Styling to error summary.
 */
function validation_errors($prefix = '', $suffix = '')
{
    if (FALSE === ($OBJ =& _get_validation_object())) {
        return '';
    }
    $error_string = $OBJ->error_string($prefix, $suffix);
    if (strlen(trim($error_string) > 0)) {
        return alert($error_string);
    } else {
        return '';
    }
}
コード例 #9
0
ファイル: MY_form_helper.php プロジェクト: mandress64/cordova
 function set_value($field = '', $default = '')
 {
     $OBJ =& _get_validation_object();
     if ($OBJ === TRUE && isset($OBJ->_field_data[$field])) {
         return form_prep($OBJ->set_value($field, $default));
     } else {
         if (!isset($_POST[$field])) {
             return $default;
         }
         return form_prep($_POST[$field]);
     }
 }
コード例 #10
0
function set_checkbox($field = '', $value = '', $default = '')
{
    $OBJ =& _get_validation_object();
    if ($OBJ === TRUE && isset($OBJ->_field_data[$field])) {
        return form_prep($OBJ->set_checkbox($field, $value, $default));
    } else {
        if (!isset($_POST[$field])) {
            if (isset($default) && $default == TRUE) {
                return 'checked=\'checked\'';
            } else {
                return '';
            }
        } else {
            if ($_POST[$field] == $value) {
                return 'checked=\'checked\'';
            }
        }
    }
}
コード例 #11
0
 /**
  * Login
  *
  * @access public
  */
 function do_login()
 {
     $this->form_validation->set_rules('login', lang("E-mail", 'admin'), 'trim|required|min_length[3]|max_length[50]|valid_email');
     $this->form_validation->set_rules('password', lang("Password", "admin"), 'trim|required|min_length[5]|max_length[32]');
     if ($_POST['remember'] == 1) {
         $remember = true;
     } else {
         $remember = false;
         //				$remember = true;
     }
     if ($this->dx_auth->is_max_login_attempts_exceeded()) {
         $this->form_validation->set_rules('captcha', lang("Protection code", "admin"), 'trim|required|xss_clean|callback_captcha_check');
     }
     if ($this->form_validation->run($this) == FALSE) {
         //			    if ($this->form_validation->run($this) == TRUE)
         $err_object =& _get_validation_object();
         foreach ($_POST as $k => $v) {
             $err_text = $err_object->error($k, $prefix, $suffix);
             $this->template->assign($k . '_error', $err_text);
         }
     } else {
         if ($this->check_permissions($this->input->post('login'))) {
             $rezult = $this->dx_auth->login($this->input->post('login'), $this->input->post('password'), $remember);
             if ($rezult == TRUE) {
                 $this->lib_admin->log(lang("Entered the IP control panel", "admin") . " " . $this->input->ip_address());
                 redirect('admin/admin/init', 'refresh');
             } else {
                 $this->template->assign('login_failed', lang("Username and password have not been found", "admin"));
             }
         } else {
             $this->template->assign('login_failed', lang("Not enough access rights", "admin"));
         }
     }
     $this->template->display('login_page');
     //			$this->template->show('login', TRUE);
 }
コード例 #12
0
ファイル: contact.php プロジェクト: roxio/MyClientBase-SB
 public function form()
 {
     //let's see with which kind of object we are dealing with
     $obj = $this->getContactById();
     if (!$obj) {
         if ($add_value = uri_assoc('add')) {
             //retrieving uid from GET
             if ($add_value) {
                 $obj = $add_value;
             }
         }
     }
     if ($obj) {
         $this->{$obj}->setFormRules();
     }
     if (!empty($obj) && $this->{$obj}->validateForm()) {
         //it's a submit and the form has been validated. Let's check if there is any binary file uploaded
         $upload_info = saveUploadedFile();
         //TODO error handling
         if (is_array($upload_info['data'])) {
             $this->load->helper('file');
             foreach ($upload_info['data'] as $element => $element_status) {
                 //reads the file and converts it in base64 and stores it in $obj
                 if ($element_status['full_path']) {
                     $binary_file = base64_encode(read_file($element_status['full_path']));
                     if ($binary_file) {
                         $this->{$obj}->{$element} = $binary_file;
                     }
                     unlink($element_status['full_path']);
                 }
             }
         }
         //ready to save in ldap
         if ($this->{$obj}->save()) {
             if (isset($this->{$obj}->uid)) {
                 redirect(site_url() . "/contact/details/uid/" . $this->{$obj}->uid);
             }
             if (isset($this->{$obj}->oid)) {
                 redirect(site_url() . "/contact/details/oid/" . $this->{$obj}->oid);
             }
             //this brings back to the previous page
             //redirect($this->session->userdata('last_index'));
         }
     }
     //it's not a form submit
     if ($obj) {
         //unset the errors found during the validation step, otherwise when a new contact is being created it gets errors
         $form_validation_obj =& _get_validation_object();
         $form_validation_obj->reset_errors();
         //the contact is set so it's an early stage update and it needs to fill the form with the contact's data
         $contact_id = $this->{$obj}->uid ? $this->{$obj}->uid : $this->{$obj}->oid;
         if (!$contact_id) {
             //it's not an update but a new contact creation
             $form = $this->input->post('form');
             switch ($this->{$obj}->objName) {
                 case 'person':
                     if (empty($form)) {
                         //this means that the form has been submitted automatically by js => no contacts found in the search
                         $first_name = $this->input->post('first_name');
                         $last_name = $this->input->post('last_name');
                     } else {
                         foreach ($form as $item) {
                             if ($item['field'] == 'first_name') {
                                 $first_name = $item['value'];
                             }
                             if ($item['field'] == 'last_name') {
                                 $last_name = $item['value'];
                             }
                         }
                     }
                     if (isset($first_name) && $first_name) {
                         $this->{$obj}->givenName = $first_name;
                     }
                     if (isset($last_name) && $last_name) {
                         $this->{$obj}->sn = $last_name;
                     }
                     break;
                 case 'organization':
                     if (empty($form)) {
                         $organization_name = $this->input->post('organization_name');
                     }
                     if (isset($organization_name) && $organization_name) {
                         $this->{$obj}->o = $organization_name;
                     }
                     break;
             }
         }
         //preparing the form
         foreach ($this->{$obj}->properties as $key => $property) {
             $this->mdl_contacts->form_values[$key] = $this->{$obj}->{$key};
         }
         //for test purposes
         //$o = $this->$obj;
         //sets form submit url
         if (isset($this->{$obj}->uid) && !empty($this->{$obj}->uid)) {
             $form_url = site_url() . "/contact/form/uid/" . $this->{$obj}->uid;
         }
         if (isset($this->{$obj}->oid) && !empty($this->{$obj}->oid)) {
             $form_url = site_url() . "/contact/form/oid/" . $this->{$obj}->oid;
         }
         if (!isset($form_url)) {
             $form_url = site_url() . "/contact/form/add/" . $obj;
         }
     } else {
         //the contact is not set. So it provides an empty form to add a new contact
         if ($add_value = uri_assoc('add')) {
             //retrieving uid from GET
             if ($add_value) {
                 $obj = $add_value;
             }
         }
         $this->{$obj}->setFormRules();
         $form_url = site_url() . "/contact/form/add/" . $obj;
     }
     //TODO what is this?
     //     	$client_settings = $this->input->post('client_settings');
     //this retrieves other info about the contact that have nothing to do with the contact itself
     //TODO later. MCB stuff
     //         $this->load->model(
     //             array(
     //             'mcb_data/mdl_mcb_client_data',
     //             'invoices/mdl_invoice_groups'
     //             )
     //         );
     //it's not a submit so let's fill the form with customer's data
     //TODO later. MCB stuff
     //$this->load->model('templates/mdl_templates');
     //$this->mdl_contacts->prep_validation($contact_id);
     $data = array('contact' => $this->{$obj}, 'form_url' => $form_url);
     $data['form'] = $this->plenty_parser->parse('form.tpl', $data, true, 'smarty', 'contact');
     $data['actions_panel'] = $this->plenty_parser->parse('actions_panel.tpl', $data, true, 'smarty', 'contact');
     $this->load->view('form', $data);
 }
コード例 #13
0
 /**
  * Check whether the form has an error
  *
  * @deprecated since 0.7.1 use form_error() in the main form library
  *
  * @param string $field Name of the field
  *
  * @return bool
  */
 function form_has_error($field = null)
 {
     if (false === ($OBJ =& _get_validation_object())) {
         return false;
     }
     return $OBJ->has_error($field);
 }
コード例 #14
0
ファイル: form_helper.php プロジェクト: puncoz/ingnepal.org
 function set_checkbox($field = '', $value = '', $default = FALSE)
 {
     $OBJ =& _get_validation_object();
     if ($OBJ === FALSE) {
         if (!isset($_POST[$field])) {
             if (count($_POST) === 0 and $default == TRUE) {
                 return ' checked="checked"';
             }
             return '';
         }
         $field = $_POST[$field];
         if (is_array($field)) {
             if (!in_array($value, $field)) {
                 return '';
             }
         } else {
             if ($field == '' or $value == '' or $field != $value) {
                 return '';
             }
         }
         return ' checked="checked"';
     }
     return $OBJ->set_checkbox($field, $value, $default);
 }
コード例 #15
0
/**
 * Check if the form has an error
 *
 * @access public
 *
 * @param string $field Name of the field
 *
 * @return bool
 */
function form_has_error($field = null)
{
    if (FALSE === ($OBJ =& _get_validation_object())) {
        return FALSE;
    }
    $return = $OBJ->has_error($field);
    return $return;
}
コード例 #16
0
 function form_error($field = '')
 {
     if (FALSE === ($OBJ =& _get_validation_object())) {
         return '';
     }
     return $OBJ->error($field, '<label for="' . $field . '" class="error">', '</label>');
 }
コード例 #17
0
function validation_errors($prefix = '', $suffix = '', $limit = 5)
{
    if (FALSE === ($OBJ =& _get_validation_object()) || $OBJ->error_string() == '') {
        return '';
    }
    return '<ul class="error">' . $OBJ->error_string($prefix, $suffix, $limit) . '</ul>';
}
コード例 #18
0
 /**
  * Form Value
  *
  * Upgraded from Codeigniter Form Helper
  *
  * Grabs a value from the POST or GET array for the specified field so you can
  * re-populate an input field or textarea.  If Form Validation
  * is active it retrieves the info from the validation class
  *
  * @access  public
  * @param string
  * @return  mixed
  * @author ExpressionEngine Dev Team
  * @author Tyler Wall <*****@*****.**>
  */
 function adv_set_value($field = '', $default = '')
 {
     if (FALSE === ($OBJ =& _get_validation_object())) {
         if (isset($_POST[$field])) {
             return html_escape($_POST[$field]);
         } elseif (isset($_GET[$field])) {
             return html_escape($_GET[$field]);
         }
         return $default;
     }
     return html_escape($OBJ->set_value($field, $default));
 }
コード例 #19
0
ファイル: Messages.php プロジェクト: singgihsap/elearning
 public function resolveValidationErrors()
 {
     if (FALSE === ($OBJ =& _get_validation_object())) {
         // No action
     } else {
         $errors = $OBJ->error_array();
         foreach ($errors as $error) {
             $this->add($error, 'error');
         }
     }
 }
コード例 #20
0
 function _cms_get_error_array()
 {
     $CI =& get_instance();
     if (isset($CI->session)) {
         $error_array = $CI->session->flashdata('validation_error_messages');
     }
     // if not in flashdata, then try directly from validation object (no redirect on failure)
     if (!isset($error_array) || $error_array === FALSE) {
         if (FALSE === ($OBJ =& _get_validation_object())) {
             $error_array = array();
         } else {
             $error_array = $OBJ->get_errors();
         }
     }
     return $error_array;
 }
コード例 #21
0
ファイル: EF_form_helper.php プロジェクト: rgochee/eForms
 function set_values($fieldname)
 {
     $OBJ =& _get_validation_object();
     return $OBJ->set_values($fieldname);
 }
コード例 #22
0
 function ajax_validation_on_edit_errors($prefix = '', $suffix = '', $editKey = '', $camelcase = TRUE)
 {
     if (FALSE === ($OBJ =& _get_validation_object())) {
         return '';
     }
     return $OBJ->ajax_error_on_edit_string($prefix, $suffix, $editKey, $camelcase);
 }