コード例 #1
0
 /**
  * @brief this is default method, which in this example just redirects to Hello method
  * @details No parameters
  *
  */
 public function index()
 {
     if (!$this->wg->User->isAllowed('chatfailover')) {
         $this->skipRendering();
         throw new PermissionsError('chatfailover');
     }
     $mode = (bool) ChatHelper::getMode();
     $this->wg->Out->setPageTitle(wfMsg('Chatfailover'));
     if ($this->request->wasPosted()) {
         $reason = $this->request->getVal('reason');
         if (!empty($reason) && $mode == ChatHelper::getMode()) {
             //the mode didn't change
             $mode = !$mode;
             StaffLogger::log("chatfo", "switch", $this->wg->User->getID(), $this->wg->User->getName(), $mode, $mode ? 'regular' : 'failover', $reason);
             ChatHelper::changeMode($mode);
         }
     }
     $this->response->setVal("serversList", ChatHelper::getServersList());
     $this->response->setVal("mode", $mode ? 'regular' : 'failover');
     $this->response->setVal("modeBool", $mode);
 }
コード例 #2
0
 /**
  * Logs the message to main user-visible log
  *
  * @param $text string Log message
  * @param $arg1 mixed Multiple format parameters
  */
 public function addMainLog($action, $text, $arg1 = null)
 {
     /*
     * BugId:1030
     * Michał Roszka (Mix) <*****@*****.**>
     *
     * $text is HTML and may contain % which are not vsptintf's conversion specification marks,
     * e.g. username f"oo"bar results with <a href="http://community.wikia.com/wiki/User:F%22oo%22baz">F&quot;oo&quot;baz</a>
     * which breaks vsprintf.
     *
     * There are 4 calls of this method, none of them passing any vsprintf's conversion specification marks.
     * vsprintf seems unnecessary, let's just pass $text to StaffLogger::log()
     
     		if (func_num_args() > 1) {
     			$args = func_get_args();
     			$args = array_slice($args,1);
     			$text = vsprintf($text,$args);
     		}
     */
     StaffLogger::log("renameuser", $action, $this->mRequestorId, $this->mRequestorName, $this->mUserId, $this->mNewUsername, $text);
 }
コード例 #3
0
 /**
  * Curry the StaffLogger function
  *
  * @param string $action Which action to log ('start', 'complete', 'fail', 'log')
  * @param array $params The params given to `#renameUser`
  * @param string $text The text to log
  */
 protected function staffLog($action, array $params, $text)
 {
     \StaffLogger::log('renameuser', $action, $params['requestor_id'], $params['requestor_name'], $params['rename_user_id'], $params['rename_new_name'], $text);
 }
 /**
  * The main method handling the Special:SpamWikis behaviour.
  */
 public function index()
 {
     // access control
     if (!$this->wg->User->isAllowed('specialspamwikis')) {
         $this->displayRestrictionError();
         return false;
     }
     // init some basic data
     $this->wg->Out->setPageTitle(wfMsg('specialspamwikis-pagetitle'));
     $this->mTitle = Title::makeTitle(NS_SPECIAL, $this->getName());
     $this->mAction = htmlspecialchars($this->mTitle->getLocalURL());
     // placeholder for the actual data
     $this->mData = new StdClass();
     // required for HTML links
     $link = new Linker();
     // the code below implements the behaviour of the stats subpage
     // TODO: find a better method to check for subpages
     if ("{$this->mTitle->getPrefixedText()}/stats" == $this->wg->request->getVal('title')) {
         // fetch the data
         $data = new SpecialSpamWikisData();
         $this->mData->stats = $data->getStats();
         // render the output
         $this->response->getView()->setTemplate('SpecialSpamWikisSpecialPageController', 'stats');
         return null;
     }
     // the code below implements the behaviour after form submission
     if (F::app()->wg->request->wasPosted()) {
         // which wikis to close?
         $this->mData->close = array();
         $this->mData->summary = array();
         $data = $this->request->getVal('close');
         if (!empty($data)) {
             // DB handle
             $tmpDb = F::app()->wf->getDb(DB_MASTER, array(), 'stats');
             foreach ($data as $k => $v) {
                 // get some info about the wiki
                 $city = WikiFactory::getWikiByID($k);
                 // set the public status to "spam"
                 $status = WikiFactory::setPublicStatus(-2, $k, 'SpecialSpamWikis');
                 // clear the cached settings for the wiki
                 WikiFactory::clearCache($k);
                 // prepare the output data
                 $this->mData->close[] = array('city' => $link->makeExternalLink($city->city_url, $city->city_title), 'status' => -2 == $status);
                 // update the summary
                 if (-2 == $status) {
                     if (!isset($this->mData->summary[$city->city_founding_user])) {
                         $this->mData->summary[$city->city_founding_user] = 1;
                     } else {
                         $this->mData->summary[$city->city_founding_user]++;
                     }
                 }
                 // remove from the noreptemp.spamwikis
                 $tmpDb->delete('noreptemp.spamwikis', array('city_id' => $k), __METHOD__);
             }
             // clear the interwiki links for ALL languages in memcached.
             WikiFactory::clearInterwikiCache();
             unset($tmpDb);
         }
         // calculate and pre-format data for StaffLog entry
         $summary = array('sum' => array_sum($this->mData->summary), 'count' => count($this->mData->summary), 'avg' => 0);
         if (0 != $summary['count']) {
             $summary['avg'] = sprintf('%1.2f', $summary['sum'] / $summary['count']);
         }
         // pass the calculated summary to the output (yes, overwrite the previous value)
         $this->mData->summary = $summary;
         // make a StaffLog entry
         StaffLogger::log('spamwiki', 'mark', $this->wg->User->getID(), $this->wg->User->getName(), 0, '', wfMsgExt('specialspamwikis-stafflog-summary', array('parsemag'), $summary['sum'], $summary['count'], $summary['avg']));
         // render the output
         $this->response->getView()->setTemplate('SpecialSpamWikisSpecialPageController', 'close');
         return null;
     }
     // the code below handles the default behaviour: displays the form
     $this->response->addAsset('resources/wikia/libraries/jquery/datatables/jquery.dataTables.min.js');
     $this->response->addAsset('extensions/wikia/SpecialSpamWikis/css/table.scss');
     $data = new SpecialSpamWikisData();
     $this->mData->criteria = $data->getCriteria();
 }
コード例 #5
0
     * @param User $user
     * @param User $userdst
     * @return bool
     */
    public static function eventlogPiggybackLogOut($user, $userdst)
    {
        self::log("piggyback", "logout", $user->getID(), $user->getName(), $userdst->getID(), $userdst->getName());
        return true;
    }
    /**
     * @static
     * @param Block $block instance of Block class includes/Block.php
     * @param User $user instance of User class includes/User.php
     * @return bool true 'cause it's a hook
     */
    public static function eventlogBlockIp($block, $user)
    {
        self::log("block", "block", $user->getID(), $user->getName(), $block->getBlocker(), $block->getTarget(), $block->mReason);
        return true;
    }
    public static function eventlogWFPublicStatusChange($cityStatus, $cityId, $reason)
    {
        global $wgUser;
        $comment = wfMsgForContent('stafflog-wiki-status-change', RenameUserLogFormatter::getCommunityUser($wgUser->getName()), RenameUserLogFormatter::getCityLink($cityId), $cityStatus, $reason);
        // sadly, $type and $action have 10-character limit, hence 'wikifactor' and 'pubstatus'.
        self::log('wikifactor', 'pubstatus', $wgUser->getID(), $wgUser->getName(), '', '', $comment);
        return true;
    }
}
StaffLogger::setupStafflog();