本文整理汇总了PHP中UserRights::isCentralWiki方法的典型用法代码示例。如果您正苦于以下问题:PHP UserRights::isCentralWiki方法的具体用法?PHP UserRights::isCentralWiki怎么用?PHP UserRights::isCentralWiki使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserRights
的用法示例。
在下文中一共展示了UserRights::isCentralWiki方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateUserGroups
public function updateUserGroups($user, $addgroup = array(), $removegroup = array())
{
wfProfileIn(__METHOD__);
if (!$user instanceof User) {
wfProfileOut(__METHOD__);
return true;
}
$user_id = $user->getID();
$dbr = wfGetDB(DB_SLAVE, array(), $this->mDBh);
$where = array("user_id" => $user_id, "wiki_id" => $this->mCityId);
$oRow = $dbr->selectRow(array($this->mTable), array("all_groups"), $where, __METHOD__);
$groups = array();
if ($oRow !== false) {
$tmp = explode(";", $oRow->all_groups);
if (!empty($tmp)) {
foreach ($tmp as $g) {
if (!empty($g)) {
$groups[] = $g;
}
}
}
}
$central_groups = array();
if (class_exists('UserRights')) {
if (!UserRights::isCentralWiki()) {
$central_groups = UserRights::getGlobalGroups($user);
}
}
# add groups
if (!empty($addgroup)) {
$groups = array_unique(array_merge($groups, $addgroup));
}
# remove groups
if (!empty($removegroup)) {
$groups = array_unique(array_diff($groups, $removegroup));
}
#central groups
if (!empty($central_groups)) {
$groups = array_unique(array_merge($groups, $central_groups));
}
if (!empty($groups)) {
sort($groups);
}
$elements = count($groups);
$singlegroup = $elements > 0 ? $groups[$elements - 1] : "";
$allgroups = $elements > 0 ? implode(";", $groups) : "";
$dbw = wfGetDB(DB_MASTER, array(), $this->mDBh);
if (empty($oRow)) {
$edits = User::edits($user_id);
$dbr = wfGetDB(DB_SLAVE);
$revRow = $dbr->selectRow('revision', array('rev_id', 'rev_timestamp'), array('rev_user' => $user_id), __METHOD__, array('ORDER BY' => 'rev_timestamp DESC'));
if (empty($revRow)) {
$editdate = '0000-00-00 00:00:00';
$lastrev = 0;
} else {
$editdate = wfTimestamp(TS_DB, $revRow->rev_timestamp);
$lastrev = $revRow->rev_id;
}
$dbw->replace($this->mTable, array('wiki_id', 'user_id', 'user_name'), array("wiki_id" => $this->mCityId, "user_id" => $user_id, "user_name" => $user->getName(), "last_ip" => 0, "edits" => $edits, "editdate" => $editdate, "last_revision" => intval($lastrev), "cnt_groups" => $elements, "single_group" => $singlegroup, "all_groups" => $allgroups), __METHOD__);
} else {
$dbw->update($this->mTable, array("cnt_groups" => $elements, "single_group" => $singlegroup, "all_groups" => $allgroups), $where, __METHOD__);
}
wfProfileOut(__METHOD__);
return true;
}