本文整理匯總了PHP中UserStatus::error_messages方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserStatus::error_messages方法的具體用法?PHP UserStatus::error_messages怎麽用?PHP UserStatus::error_messages使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UserStatus
的用法示例。
在下文中一共展示了UserStatus::error_messages方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: do_tags
function do_tags()
{
global $Conf, $Me, $papersel;
// check tags
$tagger = new Tagger($Me);
$t1 = array();
$errors = array();
foreach (preg_split('/[\\s,]+/', (string) @$_REQUEST["tag"]) as $t) {
if ($t === "") {
/* nada */
} else {
if (!($t = $tagger->check($t, Tagger::NOPRIVATE))) {
$errors[] = $tagger->error_html;
} else {
if (TagInfo::base($t) === "pc") {
$errors[] = "The “pc” user tag is set automatically for all PC members.";
} else {
$t1[] = $t;
}
}
}
}
if (count($errors)) {
return Conf::msg_error(join("<br>", $errors));
} else {
if (!count($t1)) {
return $Conf->warnMsg("Nothing to do.");
}
}
// modify database
Dbl::qe("lock tables ContactInfo write");
Conf::$no_invalidate_caches = true;
$users = array();
if ($_REQUEST["tagtype"] === "s") {
// erase existing tags
$likes = array();
$removes = array();
foreach ($t1 as $t) {
list($tag, $index) = TagInfo::split_index($t);
$removes[] = $t;
$likes[] = "contactTags like " . Dbl::utf8ci("'% " . sqlq_for_like($tag) . "#%'");
}
foreach (Dbl::fetch_first_columns(Dbl::qe("select contactId from ContactInfo where " . join(" or ", $likes))) as $cid) {
$users[(int) $cid] = (object) array("id" => (int) $cid, "add_tags" => [], "remove_tags" => $removes);
}
}
// account for request
$key = $_REQUEST["tagtype"] === "d" ? "remove_tags" : "add_tags";
foreach ($papersel as $cid) {
if (!isset($users[(int) $cid])) {
$users[(int) $cid] = (object) array("id" => (int) $cid, "add_tags" => [], "remove_tags" => []);
}
$users[(int) $cid]->{$key} = array_merge($users[(int) $cid]->{$key}, $t1);
}
// apply modifications
foreach ($users as $cid => $cj) {
$us = new UserStatus(array("send_email" => false));
if (!$us->save($cj)) {
$errors = array_merge($errors, $us->error_messages());
}
}
Dbl::qe("unlock tables");
Conf::$no_invalidate_caches = false;
$Conf->invalidateCaches(["pc" => true]);
// report
if (!count($errors)) {
$Conf->confirmMsg("Tags saved.");
redirectSelf(array("tagact" => null, "tag" => null));
} else {
Conf::msg_error(join("<br>", $errors));
}
}