static public function instance() { if (!self :: $instance) self :: $instance = new ErrorList(); return self :: $instance; }
public function execute(MailMessage $mail) { if ($this->errorMode === self::ERRORLIST_NEW) { unset($this->errorList); $this->errorList = new ErrorList(); } $keys = array_keys($this->filters); foreach ($keys as $key) { try { $this->filters[$key]->execute($mail); } catch (ErrorException $e) { $this->errorList->addError($e->getMessage()); } } return $this->errorList->count() > 0 ? false : true; }
function testAddError() { $e =& ErrorList :: instance(); $e->addError('test', 'error'); $errors = $e->getErrors('test'); $this->assertEqual(sizeof($errors), 1); $this->assertEqual($errors[0]['error'], 'error'); $e->addError('test', 'error2', array('param' => 1)); $errors = $e->getErrors('test'); $this->assertEqual(sizeof($errors), 2); $this->assertEqual($errors[1]['error'], 'error2'); $this->assertEqual($errors[1]['params']['param'], 1); $errors = $e->getErrors('no_errors'); $this->assertNull($errors); }
$template_name = "client/domain_reg_step_4"; } else { $template_name = "client/domain_reg_step_1"; } } } // Validate contacts and show form with nameservers and additional fields elseif ($post_step == 4) { try { $exception = new ErrorList(); $Registry = $RegistryModuleFactory->GetRegistryByExtension($_SESSION["domaininfo"]["extension"]); $registry_config = $Registry->GetManifest()->GetSectionConfig(); $RegistryContacts = UI::GetContactsListForSmarty($registry_config); $display["TLD"] = $_SESSION["domaininfo"]["extension"]; foreach ($RegistryContacts as $k=>$v) { if (!$_POST[$v["type"]] && $v["isrequired"] == 1) { $message = sprintf(_("%s contact not specified"), $v["name"]); $exception->AddMessage(sprintf(_("%s contact not specified"), $v["name"])); }
public function init($map = null, $prefix = '') { if ($map != null) { if (PPUtils::array_match_key($map, $prefix . "receiver.")) { $newPrefix = $prefix . "receiver."; $this->receiver = new Receiver(); $this->receiver->init($map, $newPrefix); } $mapKeyName = $prefix . 'refundStatus'; if ($map != null && array_key_exists($mapKeyName, $map)) { $this->refundStatus = $map[$mapKeyName]; } $mapKeyName = $prefix . 'refundNetAmount'; if ($map != null && array_key_exists($mapKeyName, $map)) { $this->refundNetAmount = $map[$mapKeyName]; } $mapKeyName = $prefix . 'refundFeeAmount'; if ($map != null && array_key_exists($mapKeyName, $map)) { $this->refundFeeAmount = $map[$mapKeyName]; } $mapKeyName = $prefix . 'refundGrossAmount'; if ($map != null && array_key_exists($mapKeyName, $map)) { $this->refundGrossAmount = $map[$mapKeyName]; } $mapKeyName = $prefix . 'totalOfAllRefunds'; if ($map != null && array_key_exists($mapKeyName, $map)) { $this->totalOfAllRefunds = $map[$mapKeyName]; } $mapKeyName = $prefix . 'refundHasBecomeFull'; if ($map != null && array_key_exists($mapKeyName, $map)) { $this->refundHasBecomeFull = $map[$mapKeyName]; } $mapKeyName = $prefix . 'encryptedRefundTransactionId'; if ($map != null && array_key_exists($mapKeyName, $map)) { $this->encryptedRefundTransactionId = $map[$mapKeyName]; } $mapKeyName = $prefix . 'refundTransactionStatus'; if ($map != null && array_key_exists($mapKeyName, $map)) { $this->refundTransactionStatus = $map[$mapKeyName]; } if (PPUtils::array_match_key($map, $prefix . "errorList.")) { $newPrefix = $prefix . "errorList."; $this->errorList = new ErrorList(); $this->errorList->init($map, $newPrefix); } } }
public function renderErrors() { $error_list = ErrorList :: instance(); if($errors = $error_list->getErrors($this->id)) { echo '<script language="javascript">'; foreach($errors as $error_data) { echo "set_error('{$this->id}', '" . addslashes($error_data['error']) . "');"; } echo '</script>'; } }
protected function _getErrorList() { return ErrorList :: instance(); }
/** * Set contact data fields * * @param array(key=>value) $data * @throws ErrorList */ public function SetFieldList ($data, $strict=true) { $data = array_map("trim", $data); $ErrList = new ErrorList(); if (($callback = $this->Config->attributes()->validation_callback) != null) { list($class, $method) = explode('::', $callback); $func = array($class, $method); if (is_callable($func)) { $err = array(); try { $err = call_user_func($func, $data); } catch (Exception $e) { Log::Log(sprintf("Contact validation user-defined handler failed. %s", $e->getMessage())); } if ($err) { foreach ((array)$err as $errmsg) { $ErrList->AddMessage($errmsg); } } } } $buf = array(); $this->AcceptFieldList($this->Config->fields->field, $data, $buf, $ErrList, $strict); if ($this->Config->extra_fields) { foreach ($this->Config->extra_fields->children() as $n => $if) { $n = (string)$if->attributes()->field; $v = (string)$if->attributes()->value; if ($buf[$n] == $v) { $this->AcceptFieldList($if->children(), $data, $buf, $ErrList, $strict); } } } if ($ErrList->HasMessages() && $strict) { // remove duplicate messages $errors = array_unique($ErrList->GetAllMessages()); $ErrList = new ErrorList(); foreach ($errors as $err) $ErrList->AddMessage($err); throw $ErrList; } $this->StrictlyValidated = $strict; $this->Fields = $buf; }
private function ExceptionOnErrors(ErrorList $ErrList, $message = null, $code = null) { if ($ErrList->HasMessages()) { if (!$message) { $message = _("Cannot register domain"); } $e = new RegisterDomainAction_Exception($message); $e->ErrorList = $ErrList; throw $e; } }
function _testErrorList() { $ErrList = new ErrorList(); $ErrList->AddMessage('Invalid parameter value: 3'); $ErrList->AddMessage('Access denied for user piska'); throw $ErrList; }
protected function PostNS() { $ErrList = new ErrorList(); $Validator = Core::GetValidatorInstance(); if (!$attr["enable_managed_dns"]) { foreach (array("ns1", "ns2") as $k) { if (!$Validator->IsDomain($this->attr[$k])) { $ErrList->AddMessage(sprintf(_("%s is not a valid host"), $this->attr[$k])); } } if ($attr["ns1"] && $attr["ns1"] == $attr["ns2"]) { $ErrList->AddMessage(_("You cannot use the same nameserver twice.")); } if ($ErrList->HasMessages()) { throw $ErrList; } $this->ns = array($this->attr["ns1"], $this->attr["ns2"]); } else { $this->ns = array(CONFIG::$NS1, CONFIG::$NS2); } }
<?php require_once 'src/prepend.inc.php'; @set_time_limit(999999); if (Client::Load($_SESSION['userid'])->GetSettingValue('domain_preorder') != 1) { CoreUtils::Redirect("index.php"); } if ($_POST) { $Validator = new Validator(); $lines = explode("\n", $post_domains); $err = array(); foreach ($lines as $k => $line) { try { $ErrorList = new ErrorList(); $chunks = explode(",", $line); $domainname = trim($chunks[0]); $expiredate = trim($chunks[1]); if (!preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}\$/", $expiredate) || !strtotime($expiredate)) { $ErrorList->AddMessage(sprintf(_("Incorrect expiration date (%s) for domain %s."), $expiredate, $domainname)); throw $ErrorList; } if (!$Validator->IsDomain($domainname)) { $ErrorList->AddMessage(sprintf(_("Incorrect domain name %s"), $domainname)); throw $ErrorList; } $dmn_chunks = explode(".", $domainname); $domain_name = array_shift($dmn_chunks); $extension = implode(".", $dmn_chunks); if (!$Registries[$extension]) { try { $Registries[$extension] = RegistryModuleFactory::GetInstance()->GetRegistryByExtension($extension);