public static function onLogLine($logType, $logaction, $title, $paramArray, &$comment, &$revert, $logTimestamp) { global $wgUser, $wgCityId; if (strpos($logaction, 'chatban') === 0) { $user = User::newFromId($paramArray[1]); if (!empty($user) && Chat::getBanInformation($wgCityId, $user) !== false && $wgUser->isAllowed('chatmoderator')) { $revert = "(" . "<a class='chat-change-ban' data-user-id='{$paramArray[1]}' href='#'>" . wfMsg('chat-ban-log-change-ban-link') . "</a>" . ")"; } } elseif ($logaction === 'chatconnect' && !empty($paramArray)) { $ipLinks = array(); if ($wgUser->isAllowed('multilookup')) { $mlTitle = GlobalTitle::newFromText('MultiLookup', NS_SPECIAL, 177); // Need to make the link manually for this as Linker's normaliseSpecialPage // makes the link local if the special page exists locally, rather than // keeping the global title $ipLinks[] = Xml::tags('a', array('href' => $mlTitle->getFullURL('target=' . urlencode($paramArray[0]))), wfMessage('multilookup')->escaped()); $ipLinks[] = Linker::makeKnownLinkObj(GlobalTitle::newFromText('Phalanx', NS_SPECIAL, 177), wfMessage('phalanx')->escaped(), wfArrayToCGI(array('type' => '8', 'target' => $paramArray[0], 'wpPhalanxCheckBlocker' => $paramArray[0]))); $ipLinks[] = Linker::blockLink(0, $paramArray[0]); $revert = '(' . implode(wfMessage('pipe-separator')->plain(), $ipLinks) . ')'; } } return true; }
function BanModal() { ChatHelper::info(__METHOD__ . ': Method called'); global $wgRequest, $wgCityId, $wgLang; wfProfileIn(__METHOD__); $tmpl = new EasyTemplate(dirname(__FILE__) . '/templates/'); $userId = $wgRequest->getVal('userId', 0); $isChangeBan = false; $isoTime = ""; $fmtTime = ""; if (!empty($userId) && ($user = User::newFromID($userId))) { $ban = Chat::getBanInformation($wgCityId, $user); if ($ban !== false) { $isChangeBan = true; $isoTime = wfTimestamp(TS_ISO_8601, $ban->end_date); $fmtTime = $wgLang->timeanddate(wfTimestamp(TS_MW, $ban->end_date), true); } } $tmpl->set_vars(array('options' => Chat::GetBanOptions(), 'isChangeBan' => $isChangeBan, 'isoTime' => $isoTime, 'fmtTime' => $fmtTime)); $retVal = array(); $retVal['template'] = $tmpl->render("banModal"); $retVal['isChangeBan'] = $isChangeBan; wfProfileOut(__METHOD__); return $retVal; }
/** * Since the permission essentially has to be implemented as an anti-permission, this function removes the * need for confusing double-negatives in the code. * * @param userObject - an object of class User (such as wgUser). */ public static function canChat($userObject) { global $wgCityId; if ($userObject->isBlocked()) { return false; } if (Chat::getBanInformation($wgCityId, $userObject) !== false) { return false; } return $userObject->isLoggedin() && $userObject->isAllowed('chat'); }
/** * @return string */ protected function getTagFromGroups() { $this->app->wf->ProfileIn(__METHOD__); $result = ''; $group = $this->getUsersHighestGroup($this->user); if ($group) { $result = $this->app->wf->Msg('user-identity-box-group-' . $group); } /* See if user is banned from chat */ if (!empty($this->app->wg->EnableChat) && Chat::getBanInformation($this->app->wg->CityId, $this->user) !== false) { $result = wfMsg('user-identity-box-banned-from-chat'); } $this->app->wf->ProfileOut(__METHOD__); return $result; }
/** * Since the permission essentially has to be implemented as an anti-permission, this function removes the * need for confusing double-negatives in the code. * * @param User $userObject - an object of class User (such as wgUser). * * @return bool */ public static function canChat(User $userObject) { if ($userObject->isAnon()) { return false; } if ($userObject->isBlocked()) { return false; } if (Chat::getBanInformation(F::app()->wg->CityId, $userObject) !== false) { return false; } return $userObject->isAllowed('chat'); }