/** * Returns the error_list if it exists or an empty_error_list if not * * @return object * @access public */ function &get_error_dataset() { $error_list =& error_list :: instance(); $errors = $error_list->export(); if (!sizeof($errors)) return new empty_dataset(); $array = array(); foreach($errors as $field_name => $errors_array) { foreach($errors_array as $error) { if($child =& $this->find_child($field_name)) { if(!$label = $child->get_attribute('label')) $label = $child->get_server_id(); $array[] = array('label' => $label, 'error_message' => $error['error']); } } } return new array_dataset($array); }
function _valid_perform() { $user_object =& site_object_factory::instance('user_object'); $data = $this->dataspace->export(); if (!$user_object->validate_password($data['old_password'])) { $error_list =& error_list::instance(); $error_list->add_error('old_password', 'WRONG_PASSWORD'); $this->valid = false; return $this->valid; } return $user_object->change_own_password($data['password']); }
function test_add_error() { $e =& error_list::instance(); $e->add_error('test', 'error'); $errors = $e->get_errors('test'); $this->assertEqual(sizeof($errors), 1); $this->assertEqual($errors[0]['error'], 'error'); $e->add_error('test', 'error2', array('param' => 1)); $errors = $e->get_errors('test'); $this->assertEqual(sizeof($errors), 2); $this->assertEqual($errors[1]['error'], 'error2'); $this->assertEqual($errors[1]['params']['param'], 1); $errors = $e->get_errors('no_errors'); $this->assertNull($errors); }
function &_get_error_list() { return error_list::instance(); }
function render_errors() { $error_list =& error_list :: instance(); if($errors = $error_list->get_errors($this->id)) { echo '<script language="javascript">'; foreach($errors as $error_data) { echo "set_error('{$this->id}', '" . addslashes($error_data['error']) . "');"; } echo '</script>'; } }