function Notify(AbstractPaymentModule $PaymentModule, $status) { global $PaymentModuleFactory; if ($status == PAYMENT_STATUS::SUCCESS) { UI::Redirect("payment_success.php?op=".$_SESSION['wizard']['whois']["operation"]); } else { $smarty = Core::GetSmartyInstance("SmartyExt"); $PaymentForm = $PaymentModule->GetPaymentForm(); $payment_module = $PaymentModuleFactory->GetModuleObjectByName($_SESSION['wizard']['checkout']["gate"]); $fields = $PaymentForm->ListFields(); $smarty_fields = array(); foreach($fields as $field) { $smarty_fields[$field->Title] = array("name" => $field->Name, "required" => $field->IsRequired, "type" => $field->FieldType, "values" => $field->Options); if ($_REQUEST[$field->Name]) $attr[$field->Title] = $_REQUEST[$field->Name]; } $display["errors"] = explode("\n", $PaymentModule->GetFailureReason()); $display["fields"] = $smarty_fields; $display["post"] = $attr; $display['phone_widget'] = Phone::GetInstance()->GetWidget(); $template_name = "paymentgate.tpl"; $smarty->assign($GLOBALS["display"]); $smarty->assign($display); $smarty->display($template_name); } }
/** * Returns array of error messages. * * @param array $data * @return array Empty when form passes validation */ private function ValidateOverXML ($data) { $err = array(); foreach ($this->XMLValidator->field as $field) { settype($field, "array"); $field = $field["@attributes"]; $field_name = $field["name"]; if ($field_name) { $description = ucfirst($field['description']); if ($field['iseditable'] == 0) { if ($field['iseditable'] == 0 && isset($data[$field_name]) && isset($this->Fields[$field_name]->Value)) { $err[$field_name] = sprintf(_("'%s' is uneditable"), $description); continue; } } if ($field['required'] && (!strlen($data[$field_name]) && ($field['iseditable'] || (!$field['iseditable'] && !array_key_exists($field_name, $this->Fields))))) { $err[$field_name] = sprintf(_("'%s' is required"), $description); } elseif (strlen($data[$field_name])) { if ($field["minlength"]) if (strlen($data[$field_name]) < (int)$field["minlength"]) { $err[$field_name] = sprintf(_("'%s' must contain at least %d chars"), $description, (int)$field["minlength"]); } if ((int)$field["maxlength"]) if (strlen($data[$field_name]) > (int)$field["maxlength"]) { $err[$field_name] = sprintf(_("'%s' cannot be longer than %d chars"), $description, (int)$field["maxlength"]); } if ($field["pattern"] && !preg_match("{$field['pattern']}msi", $data[$field_name])) { $err[$field_name] = sprintf(_("'%s' is not valid"), $description); } } if ($field['type'] == FORM_FIELD_TYPE::PHONE && $data[$field_name]) { $Phone = Phone::GetInstance(); if ($Phone->IsE164($data[$field_name]) || $Phone->IsPhone($data[$field_name])) continue; else $err[$field_name] = sprintf(_('%s must be in %s format'), $description, CONFIG::$PHONE_FORMAT); } } } return $err; }
public function ConvertUsers() { $this->Log('Convert users'); $skip_fields = array('opt_canMtech', 'opt_canMbill', 'opt_canbulkregister', 'isres', 'tax', 'idnumber', 'mobile'); $phone_fields = array('phone', 'fax'); $Phone = Phone::GetInstance(); $user_data = $this->DbOld->GetAll('SELECT * FROM users'); foreach ($user_data as &$row) { // Process skipped fields foreach ($skip_fields as $f) { unset($row[$f]); } // Convert phone and fax foreach ($phone_fields as $f) { if ($row[$f]) { $chunks = str_split(preg_replace("/[^0-9]+/", "", $row[$f]), 3); $e164 = trim("+" . array_shift($chunks) . "." . implode("", $chunks)); $row[$f] = $Phone->E164ToPhone($e164); } } } $this->TruncateTable('users', 'client_fields', 'client_info'); $this->BulkInsert('users', $user_data); if ($this->OldTableExists('cliend_fields', 'client_info')) { $this->CopyTable('client_fields'); $this->CopyTable('client_info'); } }
if (!$Validator->IsNotEmpty($_POST["zipcode"])) $err[] = _("Postal code required"); if ($Validator->IsNotEmpty($_POST['phone'])) { if (!Phone::GetInstance()->IsPhone($_POST["phone"])) $err[] = _("Phone invalid"); } else $err[] = _('Phone required'); if ($Validator->IsNotEmpty($_POST['fax'])) { if (!Phone::GetInstance()->IsPhone($_POST['fax'])) $err[] = _('Fax invalid'); } $DBEmailCheck = $db->GetOne("SELECT COUNT(*) FROM users WHERE email=?", array($post_email)); if ($DBEmailCheck > 0) $err[] = _("E-mail already exists in database"); $DBLoginCheck = $db->GetOne("SELECT COUNT(*) FROM users WHERE login=?", array($post_login)); if ($DBLoginCheck > 0) $err[] = _("Login already exists in database"); if (count($err) != 0) $step = "newclient"; }
} } else { $fields = $PaymentForm->ListFields(); $smarty_fields = array(); foreach($fields as $field) { $smarty_fields[$field->Title] = array("name" => $field->Name, "required" => $field->IsRequired, "type" => $field->FieldType, "values" => $field->Options); if ($_REQUEST[$field->Name]) $attr[$field->Title] = $_REQUEST[$field->Name]; } $display["post"] = $attr; $display['phone_widget'] = Phone::GetInstance()->GetWidget(); $display["fields"] = $smarty_fields; $template_name = "paymentgate.tpl"; } } } } $display["errors"] = $err; if (!$template_name) { $template_name = "placeorder.tpl"; include('order/calculate_placeorder.php'); }
private function AcceptFieldList ($xml_fields, $data, &$buf, $ErrList, $strict=true) { foreach ($xml_fields as $f_obj) { settype($f_obj, "array"); $field = $f_obj["@attributes"]; $field_name = (string)$field["name"]; $err = false; if ($field_name) { $description = ucfirst($field['description']); if ($strict && (int)$field['iseditable'] == 0) { if ((int)$field['iseditable'] == 0 && isset($data[$field_name]) && isset($this->Fields[$field_name])) $err = sprintf(_("'%s' is uneditable"), $description); else if (isset($this->Fields[$field_name])) { $buf[$field_name] = $this->Fields[$field_name]; continue; } } // �������� �� ������������ ���� if ($strict && (bool)$field['required'] && (strlen($data[$field_name]) == 0 && ($field['iseditable'] || (!$field['iseditable'] && !array_key_exists($field_name, $this->Fields))))) { $err = sprintf(_("'%s' is required"), $description); } elseif ($strict && strlen($data[$field_name])) { if ((int)$field["minlength"]) { if (strlen($data[$field_name]) < (int)$field["minlength"]) $err = sprintf(_("'%s' must contain at least %d chars"), $description, (int)$field["minlength"]); } if ((int)$field["maxlength"]) { if (strlen($data[$field_name]) > (int)$field["maxlength"]) $err = sprintf(_("'%s' cannot be longer than %d chars"), $description, (int)$field["maxlength"]); } if ($field["pattern"] && !preg_match("{$field['pattern']}msi", $data[$field_name])) $err = sprintf(_("'%s' is not valid"), $description); } if ($field['type'] == 'phone' && $data[$field_name]) { $Phone = Phone::GetInstance(); if ($Phone->IsE164($data[$field_name])) { // E164 phone $buf[$field_name] = $data[$field_name]; if (isset($data[$field_name . '_display'])) $buf[$field_name . '_display'] = $data[$field_name . '_display']; else $buf[$field_name . '_display'] = $Phone->E164ToPhone($data[$field_name]); continue; } else if ($Phone->IsPhone($data[$field_name])) { // Display phone $buf[$field_name] = $Phone->PhoneToE164($data[$field_name]); $buf[$field_name . '_display'] = $data[$field_name]; continue; } else if ($strict) { $err = sprintf(_('%s must be in %s format'), $description, CONFIG::$PHONE_FORMAT); } } if (!$err) { $buf[$field_name] = $data[$field_name]; } else { $ErrList->AddMessage($err); } } } }
function _testPhoneField() { $e164_phone = '+380.507243484'; $phone = '+380-50-7243484'; $Phone = Phone::GetInstance(); $this->assertTrue($Phone->PhoneToE164($phone) == $e164_phone, 'phone to e164'); $this->assertTrue($Phone->IsPhone($phone), 'phone is phone.. la lay lalala'); $this->assertTrue($Phone->IsE164($e164_phone), 'phone is e164'); $Contact = $this->Registry->NewContactInstance(CONTACT_TYPE::TECH); $field_list = $this->ContactFields; $field_list['voice'] = $phone; $field_list['fax'] = ''; $Contact->SetFieldList($field_list); try { } catch (ErrorList $e) { var_dump($e->GetAllMessages()); } $this->DBContact->Save($Contact); /* $this->assertTrue( $Contact->GetField('voice') == $phone_e164 && $Contact->GetField('voice_display') == $phone, 'Set phone' ); */ }
public function MakePhoneField($attrs = array()) { return Phone::GetInstance()->GetWidget($attrs); }