当前位置: 首页>>代码示例>>PHP>>正文


PHP Chat::makeGroupNameListForLog方法代码示例

本文整理汇总了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;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:46,代码来源:Chat.class.php


注:本文中的Chat::makeGroupNameListForLog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。