本文整理汇总了PHP中Chat::makeGroupNameListForLog方法的典型用法代码示例。如果您正苦于以下问题:PHP Chat::makeGroupNameListForLog方法的具体用法?PHP Chat::makeGroupNameListForLog怎么用?PHP Chat::makeGroupNameListForLog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chat
的用法示例。
在下文中一共展示了Chat::makeGroupNameListForLog方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: promoteChatModerator
/**
* Attempts to add the 'chatmoderator' group to the user whose name is provided
* in 'userNameToPromote'.
*
* Returns true on success, returns an error message as a string on failure.
*/
public static function promoteChatModerator($userNameToPromote, $promottingUser)
{
wfProfileIn(__METHOD__);
$CHAT_MOD_GROUP = 'chatmoderator';
$userToPromote = User::newFromName($userNameToPromote);
if (!$userToPromote instanceof User) {
$errorMsg = wfMsg('chat-err-invalid-username-chatmod', $userNameToPromote);
wfProfileOut(__METHOD__);
return $errorMsg;
}
// Check if the userToPromote is already in the chatmoderator group.
$errorMsg = '';
if (in_array($CHAT_MOD_GROUP, $userToPromote->getEffectiveGroups())) {
$errorMsg = wfMsg("chat-err-already-chatmod", $userNameToPromote, $CHAT_MOD_GROUP);
} else {
$changeableGroups = $promottingUser->changeableGroups();
$promottingUserName = $promottingUser->getName();
$isSelf = $userToPromote->getName() == $promottingUserName;
$addableGroups = array_merge($changeableGroups['add'], $isSelf ? $changeableGroups['add-self'] : array());
if (in_array($CHAT_MOD_GROUP, $addableGroups)) {
// Adding the group is allowed. Add the group, clear the cache, run necessary hooks, and log the change.
$oldGroups = $userToPromote->getGroups();
$userToPromote->addGroup($CHAT_MOD_GROUP);
$userToPromote->invalidateCache();
if ($userToPromote instanceof User) {
$removegroups = array();
$addgroups = array($CHAT_MOD_GROUP);
wfRunHooks('UserRights', array(&$userToPromote, $addgroups, $removegroups));
}
// Update user-rights log.
$newGroups = array_merge($oldGroups, array($CHAT_MOD_GROUP));
// Log the rights-change.
Chat::addLogEntry($userToPromote, $promottingUser, array(Chat::makeGroupNameListForLog($oldGroups), Chat::makeGroupNameListForLog($newGroups)), 'chatmoderator');
} else {
$errorMsg = wfMsg("chat-err-no-permission-to-add-chatmod", $CHAT_MOD_GROUP);
}
}
wfProfileOut(__METHOD__);
return $errorMsg == "" ? true : $errorMsg;
}