本文整理汇总了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));
}
}