本文整理汇总了PHP中Domain::singleton方法的典型用法代码示例。如果您正苦于以下问题:PHP Domain::singleton方法的具体用法?PHP Domain::singleton怎么用?PHP Domain::singleton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Domain
的用法示例。
在下文中一共展示了Domain::singleton方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate_form
/**
* validate html form
*
* @param array $errors array with error messages
* @return bool TRUE if given values of form are OK, FALSE otherwise
*/
function validate_form(&$errors)
{
global $lang_str, $data, $config;
if ($this->action['action'] == "insert") {
if (!$this->validate_number_of_entries($errors)) {
return false;
}
return true;
}
if ($this->action['action'] == 'create') {
if (!$this->validate_number_of_entries($errors)) {
return false;
}
}
if ($this->action['action'] == 'edit' or $this->action['action'] == 'update' or $this->action['action'] == 'delete') {
if (!$this->is_edit_allowed($this->edit['un'], $this->edit['did'])) {
$errors[] = $lang_str['err_uri_modify_not_permited'];
return false;
}
}
if ($this->action['action'] == 'edit' or $this->action['action'] == 'delete') {
return true;
}
$form_ok = true;
if (false === parent::validate_form($errors)) {
$form_ok = false;
}
if (!isset($_POST['uri_is_canon'])) {
$_POST['uri_is_canon'] = 0;
}
if (!$this->check_did($_POST['uri_did'])) {
$d =& Domain::singleton();
$errors[] = "Operation failed: You haven't access to domain: " . $d->get_domain_name($did);
return false;
}
if ($_POST['uri_is_canon']) {
if (!$this->check_canon_flag()) {
return false;
}
}
/* Check wheteher URI is unique */
$opt = array();
$opt['filter']['username'] = new Filter("username", $_POST['uri_un'], "=", false, false);
$opt['filter']['did'] = new Filter("did", $_POST['uri_did'], "=", false, false);
$opt['filter']['scheme'] = new Filter("scheme", "sip", "=", false, false);
if (false === ($dups = $data->get_uris(null, $opt))) {
return false;
}
if ($dups) {
$dup = reset($dups);
if ($this->action['action'] == "update" and count($dups) == 1 and $dup->username == $this->edit_uri->username and $dup->did == $this->edit_uri->did and $dup->scheme == $this->edit_uri->scheme and $dup->uid == $this->edit_uri->uid) {
} else {
$errors[] = $lang_str['err_ri_dup'];
$form_ok = false;
}
}
return $form_ok;
}
示例2: validate_form
function validate_form(&$errors)
{
global $lang_str, $data;
if (false === parent::validate_form($errors)) {
return false;
}
$did = $_POST['al_domain'];
if (!$this->check_did($did)) {
$d =& Domain::singleton();
$errors[] = "You haven't access to domain which you selected: " . $d->get_domain_name($did);
return false;
}
// check if admin has parmission to changed URI and if has not, return flase
if ($_POST['al_id_d'] != "" and !$this->check_did($_POST['al_id_d'])) {
$errors[] = "Can not update, you have not access to this URI";
return false;
}
if (!empty($_POST['al_is_canon'])) {
// chenck if cannonical flag in other URI may be cleared
$uri_handler =& URIs::singleton($this->user_id->get_uid());
if (false === ($uris = $uri_handler->get_URIs())) {
return false;
}
foreach ($uris as $k => $v) {
if ($v->is_canonical() and !$this->check_did($v->get_did())) {
$errors[] = $lang_str['err_canon_uri_exists'];
return false;
}
}
}
return true;
}