/**
  * Called from maintenance script only.  Send Digest emails for any founders with that preference enabled
  *
  * @param array $events Events is empty for this type
  */
 public function process(array $events)
 {
     global $wgTitle;
     wfProfileIn(__METHOD__);
     $founderEmailObj = FounderEmails::getInstance();
     $wgTitle = Title::newMainPage();
     // Get list of founders with digest mode turned on
     $cityList = $founderEmailObj->getFoundersWithPreference('founderemails-views-digest');
     $wikiService = new WikiService();
     // Gather daily page view stats for each wiki requesting views digest
     foreach ($cityList as $cityID) {
         $user_ids = $wikiService->getWikiAdminIds($cityID);
         $foundingWiki = WikiFactory::getWikiById($cityID);
         $page_url = GlobalTitle::newFromText('Createpage', NS_SPECIAL, $cityID)->getFullUrl(array('modal' => 'AddPage'));
         $emailParams = array('$WIKINAME' => $foundingWiki->city_title, '$WIKIURL' => $foundingWiki->city_url, '$PAGEURL' => $page_url, '$UNIQUEVIEWS' => $founderEmailObj->getPageViews($cityID));
         foreach ($user_ids as $user_id) {
             $user = User::newFromId($user_id);
             // skip if not enable
             if (!$this->enabled($user, $cityID)) {
                 continue;
             }
             self::addParamsUser($cityID, $user->getName(), $emailParams);
             $langCode = $user->getGlobalPreference('language');
             $links = array('$WIKINAME' => $emailParams['$WIKIURL']);
             $mailSubject = strtr(wfMsgExt('founderemails-email-views-digest-subject', array('content')), $emailParams);
             $mailBody = strtr(wfMsgExt('founderemails-email-views-digest-body', array('content', 'parsemag'), $emailParams['$UNIQUEVIEWS']), $emailParams);
             $mailBodyHTML = F::app()->renderView('FounderEmails', 'GeneralUpdate', array_merge($emailParams, array('language' => 'en', 'type' => 'views-digest')));
             $mailBodyHTML = strtr($mailBodyHTML, FounderEmails::addLink($emailParams, $links));
             $mailCategory = FounderEmailsEvent::CATEGORY_VIEWS_DIGEST . (!empty($langCode) && $langCode == 'en' ? 'EN' : 'INT');
             $founderEmailObj->notifyFounder($user, $this, $mailSubject, $mailBody, $mailBodyHTML, $cityID, $mailCategory);
         }
     }
     wfProfileOut(__METHOD__);
 }
Example #2
0
 /**
  * get list of wiki founder/admin/bureaucrat id
  * Note: also called from maintenance script.
  * @return array of $userIds
  */
 public function getWikiAdminIds($wikiId = 0, $useMaster = false)
 {
     $this->wf->ProfileIn(__METHOD__);
     $userIds = array();
     if (empty($this->wg->FounderEmailsDebugUserId)) {
         // get founder
         $wikiId = empty($wikiId) ? $this->wg->CityId : $wikiId;
         $wiki = WikiFactory::getWikiById($wikiId);
         if (!empty($wiki) && $wiki->city_public == 1) {
             $userIds[] = $wiki->city_founding_user;
             // get admin and bureaucrat
             if (empty($this->wg->EnableAnswers)) {
                 $memKey = $this->getMemKeyAdminIds($wikiId);
                 $adminIds = $this->wg->Memc->get($memKey);
                 if (!is_array($adminIds)) {
                     $dbname = $wiki->city_dbname;
                     $dbType = $useMaster ? DB_MASTER : DB_SLAVE;
                     $db = $this->wf->GetDB($dbType, array(), $dbname);
                     $result = $db->select('user_groups', 'distinct ug_user', array("ug_group in ('sysop','bureaucrat')"), __METHOD__);
                     $adminIds = array();
                     while ($row = $db->fetchObject($result)) {
                         $adminIds[] = $row->ug_user;
                     }
                     $db->freeResult($result);
                     $this->wg->Memc->set($memKey, $adminIds, 60 * 60 * 24);
                 }
                 $userIds = array_unique(array_merge($userIds, $adminIds));
             }
         }
     } else {
         $userIds[] = $this->wg->FounderEmailsDebugUserId;
     }
     $this->wf->ProfileOut(__METHOD__);
     return $userIds;
 }
function WidgetFounderBadge($id, $params)
{
    $output = "";
    wfProfileIn(__METHOD__);
    global $wgMemc;
    $key = wfMemcKey("WidgetFounderBadge", "user");
    $user = $wgMemc->get($key);
    if (is_null($user)) {
        global $wgCityId;
        $user = WikiFactory::getWikiById($wgCityId)->city_founding_user;
        $wgMemc->set($key, $user, 3600);
    }
    if (0 == $user) {
        return wfMsgForContent("widget-founderbadge-notavailable");
    }
    $key = wfMemcKey("WidgetFounderBadge", "edits");
    $edits = $wgMemc->get($key);
    if (empty($edits)) {
        $edits = AttributionCache::getInstance()->getUserEditPoints($user);
        $wgMemc->set($key, $edits, 300);
    }
    $author = array("user_id" => $user, "user_name" => User::newFromId($user)->getName(), "edits" => $edits);
    $output = Answer::getUserBadge($author);
    wfProfileOut(__METHOD__);
    return $output;
}
 /**
  * Returns array with fields values from city_list for provided city_id that are required for ExactTarget updates
  * @param int $iCityId
  * @return array
  */
 public function getWikiDataArray($iCityId)
 {
     /* Get wikidata from master */
     $oWiki = \WikiFactory::getWikiById($iCityId, true);
     $aWikiData = ['city_path' => $oWiki->city_path, 'city_dbname' => $oWiki->city_dbname, 'city_sitename' => $oWiki->city_sitename, 'city_url' => $oWiki->city_url, 'city_created' => $oWiki->city_created, 'city_founding_user' => $oWiki->city_founding_user, 'city_adult' => $oWiki->city_adult, 'city_public' => $oWiki->city_public, 'city_title' => $oWiki->city_title, 'city_founding_email' => $oWiki->city_founding_email, 'city_lang' => $oWiki->city_lang, 'city_special' => $oWiki->city_special, 'city_umbrella' => $oWiki->city_umbrella, 'city_ip' => $oWiki->city_ip, 'city_google_analytics' => $oWiki->city_google_analytics, 'city_google_search' => $oWiki->city_google_search, 'city_google_maps' => $oWiki->city_google_maps, 'city_indexed_rev' => $oWiki->city_indexed_rev, 'city_lastdump_timestamp' => $oWiki->city_lastdump_timestamp, 'city_factory_timestamp' => $oWiki->city_factory_timestamp, 'city_useshared' => $oWiki->city_useshared, 'ad_cat' => $oWiki->ad_cat, 'city_flags' => $oWiki->city_flags, 'city_cluster' => $oWiki->city_cluster, 'city_last_timestamp' => $oWiki->city_last_timestamp, 'city_founding_ip' => $oWiki->city_founding_ip, 'city_vertical' => $oWiki->city_vertical];
     return $aWikiData;
 }
Example #5
0
 /**
  * get wiki founder
  * @return User
  */
 public function getWikiFounder($wikiId = 0)
 {
     global $wgCityId, $wgFounderEmailsDebugUserId;
     $wikiId = !empty($wikiId) ? $wikiId : $wgCityId;
     if (empty($wgFounderEmailsDebugUserId)) {
         $wikiFounder = User::newFromId(WikiFactory::getWikiById($wikiId)->city_founding_user);
     } else {
         $wikiFounder = User::newFromId($wgFounderEmailsDebugUserId);
     }
     return $wikiFounder;
 }
 /**
  * Checks if user is the founder
  *
  * @return boolean
  *
  * @author Andrzej 'nAndy' Łukaszewski
  */
 protected function isFounder()
 {
     wfProfileIn(__METHOD__);
     $wiki = WikiFactory::getWikiById($this->app->wg->CityId);
     if (intval($wiki->city_founding_user) === $this->user->GetId()) {
         // mech: BugId 18248
         $founder = $this->isUserInGroup(self::WIKIA_GROUP_SYSOP_NAME) || $this->isUserInGroup(self::WIKIA_GROUP_BUREAUCRAT_NAME);
         wfProfileOut(__METHOD__);
         return $founder;
     }
     wfProfileOut(__METHOD__);
     return false;
 }
 function formatRow($row)
 {
     $type = implode(", ", Phalanx::getTypeNames(isset($row->ps_blocker_hit) ? $row->ps_blocker_hit : $row->ps_blocker_type));
     $username = $row->ps_blocked_user;
     $timestamp = $this->app->wg->Lang->timeanddate($row->ps_timestamp);
     $oWiki = WikiFactory::getWikiById($row->ps_wiki_id);
     $url = isset($row->ps_referrer) ? $row->ps_referrer : "";
     $url = empty($url) && isset($oWiki) ? $oWiki->city_url : $url;
     $html = Html::openElement('li');
     $html .= wfMsgExt('phalanx-stats-row', array('parseinline'), $type, $username, $url, $timestamp);
     $html .= Html::closeElement('li');
     return $html;
 }
 public static function achievements($cv_name, $city_id, $value)
 {
     wfProfileIn(__METHOD__);
     if ($cv_name == 'wgEnableAchievementsExt' && $value == true) {
         $wiki = WikiFactory::getWikiById($city_id);
         // Force WikiFactory::getWikiById() to query DB_MASTER if needed.
         if (!is_object($wiki)) {
             $wiki = WikiFactory::getWikiById($city_id, true);
         }
         $user = User::newFromId($wiki->city_founding_user);
         $user->load();
         $achService = new AchAwardingService($city_id);
         $achService->awardCustomNotInTrackBadge($user, BADGE_CREATOR);
     }
     wfProfileOut(__METHOD__);
     return true;
 }
 public function process(array $events)
 {
     global $wgEnableAnswers, $wgCityId;
     wfProfileIn(__METHOD__);
     if ($this->isThresholdMet(count($events))) {
         // get just one event when we have more... for now, just randomly
         $eventData = $events[rand(0, count($events) - 1)];
         $founderEmailObj = FounderEmails::getInstance();
         $wikiService = F::build('WikiService');
         $user_ids = $wikiService->getWikiAdminIds();
         $foundingWiki = WikiFactory::getWikiById($wgCityId);
         $emailParams = array('$EDITORNAME' => $eventData['data']['userName'], '$EDITORPAGEURL' => $eventData['data']['userPageUrl'], '$EDITORTALKPAGEURL' => $eventData['data']['userTalkPageUrl'], '$WIKINAME' => $foundingWiki->city_title, '$WIKIURL' => $foundingWiki->city_url);
         $wikiType = !empty($wgEnableAnswers) ? '-answers' : '';
         foreach ($user_ids as $user_id) {
             $user = User::newFromId($user_id);
             // skip if not enable
             if (!$this->enabled($wgCityId, $user)) {
                 continue;
             }
             self::addParamsUser($wgCityId, $user->getName(), $emailParams);
             $langCode = $user->getOption('language');
             $mailSubject = strtr(wfMsgExt('founderemails' . $wikiType . '-email-user-registered-subject', array('content')), $emailParams);
             $mailBody = strtr(wfMsgExt('founderemails' . $wikiType . '-email-user-registered-body', array('content')), $emailParams);
             if (empty($wgEnableAnswers)) {
                 // FounderEmailv2.1
                 $links = array('$EDITORNAME' => $emailParams['$EDITORPAGEURL'], '$WIKINAME' => $emailParams['$WIKIURL']);
                 $mailBodyHTML = F::app()->renderView("FounderEmails", "GeneralUpdate", array_merge($emailParams, array('language' => 'en', 'type' => 'user-registered')));
                 $mailBodyHTML = strtr($mailBodyHTML, FounderEmails::addLink($emailParams, $links));
             } else {
                 $mailBodyHTML = $this->getLocalizedMsg('founderemails' . $wikiType . '-email-user-registered-body-HTML', $emailParams);
             }
             $mailCategory = FounderEmailsEvent::CATEGORY_REGISTERED . (!empty($langCode) && $langCode == 'en' ? 'EN' : 'INT');
             wfProfileOut(__METHOD__);
             $founderEmailObj->notifyFounder($user, $this, $mailSubject, $mailBody, $mailBodyHTML, $wgCityId, $mailCategory);
         }
         return true;
     }
     wfProfileOut(__METHOD__);
     return false;
 }
Example #10
0
 /**
  * get list of wiki founder/admin/bureaucrat id
  * Note: also called from maintenance script.
  *
  * @param integer $wikiId - wiki Id (default: current wiki Id)
  * @param bool    $useMaster - flag that describes if we should use masted DB (default: false)
  * @param bool    $excludeBots - flag that describes if bots should be excluded from admins list (default: false)
  * @param integer $limit - admins limit
  * @param bool    $includeFounder - flag that describes if founder user should be added to admins list (default: true)
  *
  * @return array of $userIds
  */
 public function getWikiAdminIds($wikiId = 0, $useMaster = false, $excludeBots = false, $limit = null, $includeFounder = true)
 {
     wfProfileIn(__METHOD__);
     $userIds = array();
     if (empty($this->wg->FounderEmailsDebugUserId)) {
         // get founder
         $wikiId = empty($wikiId) ? $this->wg->CityId : $wikiId;
         $wiki = WikiFactory::getWikiById($wikiId);
         if (!empty($wiki) && $wiki->city_public == 1) {
             if ($includeFounder) {
                 $userIds[] = $wiki->city_founding_user;
             }
             // get admin and bureaucrat
             if (empty($this->wg->EnableAnswers)) {
                 $memKey = $this->getMemKeyAdminIds($wikiId, $excludeBots, $limit);
                 $adminIds = WikiaDataAccess::cache($memKey, 60 * 60 * 3, function () use($wiki, $useMaster, $excludeBots, $limit) {
                     $dbname = $wiki->city_dbname;
                     $dbType = $useMaster ? DB_MASTER : DB_SLAVE;
                     $db = wfGetDB($dbType, array(), $dbname);
                     $conditions = array("ug_group in ('sysop','bureaucrat')");
                     if ($excludeBots) {
                         $conditions[] = "ug_user not in (select distinct ug_user from user_groups where ug_group in (" . $db->makeList(self::$botGroups) . "))";
                     }
                     $result = $db->select('user_groups', 'distinct ug_user', $conditions, __METHOD__, !empty($limit) ? array('LIMIT' => $limit) : array());
                     $adminIds = array();
                     while ($row = $db->fetchObject($result)) {
                         $adminIds[] = $row->ug_user;
                     }
                     $db->freeResult($result);
                     return $adminIds;
                 });
                 $userIds = array_unique(array_merge($userIds, $adminIds));
             }
         }
     } else {
         $userIds[] = $this->wg->FounderEmailsDebugUserId;
     }
     wfProfileOut(__METHOD__);
     return $userIds;
 }
 /**
  * Called from maintenance script only.  Send Digest emails for any founders with that preference enabled
  * @param array $events
  */
 public function process(array $events)
 {
     global $wgTitle;
     wfProfileIn(__METHOD__);
     $wgTitle = Title::newMainPage();
     $founderEmailObj = FounderEmails::getInstance();
     // Get list of founders with digest mode turned on (defined in FounderEmailsEvent
     $cityList = $founderEmailObj->getFoundersWithPreference('founderemails-complete-digest');
     $wikiService = F::build('WikiService');
     foreach ($cityList as $cityID) {
         $user_ids = $wikiService->getWikiAdminIds($cityID);
         $foundingWiki = WikiFactory::getWikiById($cityID);
         $page_url = GlobalTitle::newFromText('WikiActivity', NS_SPECIAL, $cityID)->getFullUrl();
         $emailParams = array('$WIKINAME' => $foundingWiki->city_title, '$WIKIURL' => $foundingWiki->city_url, '$PAGEURL' => $page_url, '$UNIQUEVIEWS' => $founderEmailObj->getPageViews($cityID), '$USERJOINS' => $founderEmailObj->getNewUsers($cityID), '$USEREDITS' => $founderEmailObj->getDailyEdits($cityID));
         foreach ($user_ids as $user_id) {
             $user = User::newFromId($user_id);
             // skip if not enable
             if (!$this->enabled($cityID, $user)) {
                 continue;
             }
             self::addParamsUser($cityID, $user->getName(), $emailParams);
             $langCode = $user->getOption('language');
             // Only send digest emails for English users until translation is done
             if ($langCode == 'en') {
                 $links = array('$WIKINAME' => $emailParams['$WIKIURL']);
                 $mailSubject = strtr(wfMsgExt('founderemails-email-complete-digest-subject', array('content')), $emailParams);
                 $mailBody = strtr(wfMsgExt('founderemails-email-complete-digest-body', array('content', 'parsemag'), $emailParams['$UNIQUEVIEWS'], $emailParams['$USEREDITS'], $emailParams['$USERJOINS']), $emailParams);
                 $mailBodyHTML = F::app()->renderView("FounderEmails", "GeneralUpdate", array_merge($emailParams, array('language' => 'en', 'type' => 'complete-digest')));
                 $mailBodyHTML = strtr($mailBodyHTML, FounderEmails::addLink($emailParams, $links));
                 $mailCategory = FounderEmailsEvent::CATEGORY_COMPLETE_DIGEST . (!empty($langCode) && $langCode == 'en' ? 'EN' : 'INT');
                 // Only send email if there is some kind of activity to report
                 if ($emailParams['$UNIQUEVIEWS'] > 0 || $emailParams['$USERJOINS'] > 0 || $emailParams['$USEREDITS'] > 0) {
                     $founderEmailObj->notifyFounder($user, $this, $mailSubject, $mailBody, $mailBodyHTML, $cityID, $mailCategory);
                 }
             }
         }
     }
     wfProfileOut(__METHOD__);
 }
 /**
  * get users with avatar who sign up on the wiki (include founder)
  * @param integer $wikiId
  * @param integer $limit (number of users)
  * @return array $wikiUsers
  */
 protected function getWikiUsers($wikiId = null, $limit = 30)
 {
     $this->wf->ProfileIn(__METHOD__);
     $wikiId = empty($wikiId) ? $this->wg->CityId : $wikiId;
     $memKey = $this->wf->SharedMemcKey('userlogin', 'users_with_avatar', $wikiId);
     $wikiUsers = $this->wg->Memc->get($memKey);
     if (!is_array($wikiUsers)) {
         $wikiUsers = array();
         $db = $this->wf->GetDB(DB_SLAVE, array(), $this->wg->StatsDB);
         $result = $db->select(array('user_login_history'), array('distinct user_id'), array('city_id' => $wikiId), __METHOD__, array('LIMIT' => $limit));
         while ($row = $db->fetchObject($result)) {
             $this->addUserToUserList($row->user_id, $wikiUsers);
         }
         $db->freeResult($result);
         // add founder if not exist
         $founder = WikiFactory::getWikiById($wikiId)->city_founding_user;
         if (!array_key_exists($founder, $wikiUsers)) {
             $this->addUserToUserList($founder, $wikiUsers);
         }
         $this->wg->Memc->set($memKey, $wikiUsers, 60 * 60 * 24);
     }
     $this->wf->ProfileOut(__METHOD__);
     return $wikiUsers;
 }
		die( "Usage: php maintenance.php [--help] [--dry-run] [--quiet]
		--dry-run                      dry run
		--quiet                        show summary result only
		--help                         you are reading it right now\n\n" );
	}

	$dryRun = ( isset($options['dry-run']) );
	$quiet = ( isset($options['quiet']) );

	if ( empty($wgCityId) ) {
		die( "Error: Invalid wiki id." );
	}

	echo "Wiki: ".$wgCityId;

	$wiki = WikiFactory::getWikiById( $wgCityId );
	if ( !empty($wiki) && $wiki->city_public == 1 ) {
		$dbname = $wiki->city_dbname;

		echo " ($dbname): \n";

		$total = 0;
		$add = 0;
		$dup = 0;

		$user = User::newFromName('WikiaBot');
		$markers = array( RelatedVideosNamespaceData::WHITELIST_MARKER, RelatedVideosNamespaceData::BLACKLIST_MARKER );

		echo "GlobalList: \n";
		$globalList = RelatedVideosNamespaceData::newFromGeneralMessage();
 /**
  * get wiki info ( wikiname, description, url, status, images )
  * @param integer $wikiId
  * @param string $langCode
  * @param WikiDataGetter $dataGetter
  * @return array wikiInfo
  */
 public function getWikiInfo($wikiId, $langCode, WikiDataGetter $dataGetter)
 {
     wfProfileIn(__METHOD__);
     $wikiInfo = array('name' => '', 'headline' => '', 'description' => '', 'url' => '', 'official' => 0, 'promoted' => 0, 'blocked' => 0, 'images' => array());
     if (!empty($wikiId)) {
         $wiki = WikiFactory::getWikiById($wikiId);
         if (!empty($wiki)) {
             $wikiInfo['url'] = $wiki->city_url . '?redirect=no';
         }
         $wikiData = $dataGetter->getWikiData($wikiId, $langCode);
         if (!empty($wikiData)) {
             $wikiInfo['name'] = $wikiData['name'];
             $wikiInfo['headline'] = $wikiData['headline'];
             $wikiInfo['description'] = $wikiData['description'];
             // wiki status
             $wikiInfo['official'] = intval(CityVisualization::isOfficialWiki($wikiData['flags']));
             $wikiInfo['promoted'] = intval(CityVisualization::isPromotedWiki($wikiData['flags']));
             $wikiInfo['blocked'] = intval(CityVisualization::isBlockedWiki($wikiData['flags']));
             $wikiInfo['images'] = array();
             if (!empty($wikiData['main_image'])) {
                 $wikiInfo['images'][] = $wikiData['main_image'];
             }
             $wikiData['images'] = !empty($wikiData['images']) ? (array) $wikiData['images'] : array();
             // wiki images
             if (!empty($wikiData['images'])) {
                 $wikiInfo['images'] = array_merge($wikiInfo['images'], $wikiData['images']);
             }
         }
     }
     wfProfileOut(__METHOD__);
     return $wikiInfo;
 }
 private function blockWikia($wikiId)
 {
     $oWiki = WikiFactory::getWikiById($wikiId);
     if (!is_object($oWiki)) {
         return false;
     }
     // process block data for display
     $data = array('wiki_id' => $oWiki->city_id, 'sitename' => WikiFactory::getVarValueByName("wgSitename", $oWiki->city_id), 'url' => WikiFactory::getVarValueByName("wgServer", $oWiki->city_id), 'last_timestamp' => $this->wg->Lang->timeanddate($oWiki->city_last_timestamp));
     // we have a valid id, change title to use it
     $this->wg->Out->setPageTitle(wfMsg('phalanx-stats-title') . ': ' . $data['url']);
     $headers = array(wfMsg('phalanx-stats-table-wiki-id'), wfMsg('phalanx-stats-table-wiki-name'), wfMsg('phalanx-stats-table-wiki-url'), wfMsg('phalanx-stats-table-wiki-last-edited'));
     $tableAttribs = array('border' => 1, 'class' => 'wikitable', 'style' => "font-family:monospace;");
     $table = Xml::buildTable(array($data), $tableAttribs, $headers);
     $this->setVal('table', $table);
     $pager = new PhalanxStatsWikiaPager($wikiId);
     $this->setVal('statsPager', $pager->getNavigationBar() . $pager->getBody() . $pager->getNavigationBar());
 }
 protected function getWiki()
 {
     return WikiFactory::getWikiById($this->cityId);
 }
 public function fetchContributionsDataTables()
 {
     wfProfileIn(__METHOD__);
     //error_log( "start" );
     $aColumns = array('rev_timestamp', 'user_id', 'event_type', 'wiki_id', 'page_id', 'page_ns', 'rev_size', 'rev_id', 'ip');
     $dbr = $this->getDb(DB_SLAVE);
     $users = explode(",", $_GET['users']);
     $users = array_map("intval", $users);
     $limitS = 0;
     $limitL = 10;
     if (isset($_GET['iDisplayStart']) && $_GET['iDisplayLength'] != '-1') {
         $limitS = mysql_real_escape_string($_GET['iDisplayStart']);
         $limitL = mysql_real_escape_string($_GET['iDisplayLength']);
     }
     $orderBy = array();
     if (isset($_GET['iSortCol_0'])) {
         for ($i = 0; $i < intval($_GET['iSortingCols']); $i++) {
             if ($_GET['bSortable_' . intval($_GET['iSortCol_' . $i])] == "true") {
                 $orderBy[] = $aColumns[intval($_GET['iSortCol_' . $i])] . " " . mysql_real_escape_string($_GET['sSortDir_' . $i]);
             }
         }
     }
     $results = array();
     $table = array('events');
     $vars = $aColumns;
     $conds = array('user_id' => $users);
     if (!empty($orderBy)) {
         $options = array('LIMIT' => $limitL, 'OFFSET' => $limitS, 'ORDER BY' => implode(",", $orderBy));
     } else {
         $options = array('LIMIT' => $limitL, 'OFFSET' => $limitS);
     }
     $res = $dbr->select($table, 'COUNT(1) as c', $conds, __METHOD__);
     $row = $dbr->fetchRow($res);
     $iTotal = $row['c'];
     //error_log( $iTotal );
     $iFilteredTotal = $iTotal;
     $output = array("sEcho" => intval($_GET['sEcho']), "iTotalRecords" => $iTotal, "iTotalDisplayRecords" => $iFilteredTotal, "aaData" => array());
     $res = $dbr->select($table, $vars, $conds, __METHOD__, $options);
     while ($row = $dbr->fetchRow($res)) {
         $wiki = WikiFactory::getWikiById($row['wiki_id']);
         if (is_object($wiki) && $wiki->city_public != 0) {
             $wikiSitename = WikiFactory::getVarValueByName('wgSitename', $row['wiki_id']);
             $url = WikiFactory::getLocalEnvURL($wiki->city_url);
             $wikiLink = Xml::element('a', array('class' => 'wiki_name', 'href' => $url), $wikiSitename);
             $row['wiki_id'] = $wikiLink . Xml::element('span', array('class' => 'wiki_id'), $row['wiki_id']);
             if (!empty($row['user_id'])) {
                 $name = User::newFromId($row['user_id'])->getName();
             } else {
                 $name = long2ip($row['ip']);
             }
             $nameLink = Xml::element('a', array('class' => 'user_name', 'href' => GlobalTitle::newFromText($name, NS_USER, $wiki->city_id)->getFullURL()), $name);
             $row['user_id'] = $nameLink . Xml::element('span', array('class' => 'user_id'), $row['user_id']);
             global $wgDevelEnvironment;
             $pageId = $row['page_id'];
             $row['page_id'] = 'db not found' . Xml::element('span', array('class' => 'page_id'), $row['page_id']);
             if (!$wgDevelEnvironment) {
                 $title = GlobalTitle::newFromId($row['page_id'], $wiki->city_id);
                 if (is_object($title)) {
                     $pageLink = Xml::element('a', array('class' => 'page_name', 'href' => $title->getFullURL()), $title->getPrefixedText());
                     $row['page_id'] = $pageLink . Xml::element('span', array('class' => 'page_id'), $row['page_id']);
                 }
             }
         }
         $row['ip'] = long2ip($row['ip']);
         $rawtimestamp = wfTimestamp(TS_ISO_8601, $row['rev_timestamp']);
         $reltimestamp = Xml::element('div', array('class' => "timeago", 'title' => $rawtimestamp), '.');
         $row['rev_timestamp'] .= " " . $reltimestamp;
         $namespaceName = MWNamespace::getCanonicalName($row['page_ns']);
         if ($namespaceName) {
             $row['page_ns'] = $namespaceName;
         } elseif ($row['page_ns'] == NS_MAIN) {
             $row['page_ns'] = 'main';
         }
         switch ($row['event_type']) {
             case ScribeEventProducer::EDIT_CATEGORY_INT:
                 $row['event_type'] = 'edit';
                 break;
             case ScribeEventProducer::CREATEPAGE_CATEGORY_INT:
                 $row['event_type'] = 'create';
                 break;
             case ScribeEventProducer::DELETE_CATEGORY_INT:
                 $row['event_type'] = 'delete';
                 break;
             case ScribeEventProducer::UNDELETE_CATEGORY_INT:
                 $row['event_type'] = 'undelete';
         }
         $output_row = array();
         for ($i = 0; $i < count($aColumns); $i++) {
             $output_row[] = $row[$aColumns[$i]];
         }
         $output['aaData'][] = $output_row;
     }
     echo json_encode($output);
     $this->skipRendering();
     wfProfileOut(__METHOD__);
     return false;
 }
 /**
  * Retrieves a wikia's ID from a database using its domain
  * @param  string $sWikiDomain  A domain (host) (e.g. ja.community.wikia.com)
  * @return ResultWrapper|bool A wikia's object or false if not found.
  */
 private function getNativeWikiByDomain($sWikiDomain)
 {
     $oDB = wfGetDB(DB_SLAVE, array(), $this->wg->ExternalSharedDB);
     $oRow = $oDB->selectRow('`city_domains`', ['`city_id`'], ['city_domain' => $sWikiDomain], __METHOD__);
     if ($oRow !== false) {
         $iNativeWikiId = $oRow->city_id;
         $oNativeWiki = WikiFactory::getWikiById($iNativeWikiId);
         if (is_object($oNativeWiki)) {
             return $oNativeWiki;
         } else {
             $this->response->setVal('error', "A native wikia with id={$iNativeWikiId} not found.");
             return false;
         }
     } else {
         $this->response->setVal('error', "A native wikia not found.");
         return false;
     }
 }
Example #19
0
 /**
  * Enqueues a job based on a few simple preliminary checks.
  *
  * Called once an article has been saved.
  *
  * @param $oArticle Object The WikiPage object for the contribution.
  * @param $oUser Object The User object for the contribution.
  * @param $sText String The contributed text.
  * @param $sSummary String The summary for the contribution.
  * @param $iMinorEdit Integer Indicates whether a contribution has been marked as a minor one.
  * @param $nWatchThis Null Not used as of MW 1.8
  * @param $nSectionAnchor Null Not used as of MW 1.8
  * @param $iFlags Integer Bitmask flags for the edit.
  * @param $oRevision Object The Revision object.
  * @param $oStatus Object The Status object returned by Article::doEdit().
  * @param $iBaseRevId Integer The ID of the revision, the current edit is based on (or Boolean False).
  * @return Boolean True so the calling method would continue.
  * @see http://www.mediawiki.org/wiki/Manual:$wgHooks
  * @see http://www.mediawiki.org/wiki/Manual:Hooks/ArticleSaveComplete
  * @since MediaWiki 1.19.4
  * @internal
  */
 public static function onArticleSaveComplete(&$oArticle, &$oUser, $sText, $sSummary, $iMinorEdit, $nWatchThis, $nSectionAnchor, &$iFlags, $oRevision, $oStatus, $iBaseRevId)
 {
     /**
      *
      * Deprecated: Use HAWelcomeTaskHooks::onArticleSaveComplete.
      * Remove once this HAWelcomeTask has been tested in production.
      *
      */
     wfProfileIn(__METHOD__);
     if (is_null($oRevision)) {
         // if oRevision is null, that means we're dealing with a null edit (no content change)
         // and therefore we don't have to welcome anybody
         wfProfileOut(__METHOD__);
         return true;
     }
     /** @global Boolean Show PHP Notices. Set via WikiFactory. */
     global $wgHAWelcomeNotices, $wgCityId;
     /** @type Interget Store the original error reporting level. */
     $iErrorReporting = error_reporting();
     error_reporting(E_ALL);
     // Abort if the feature has been disabled by the admin of the wiki.
     if (in_array(trim(wfMessage('welcome-user')->inContentLanguage()->text()), array('@disabled', '-'))) {
         if (!empty($wgHAWelcomeNotices)) {
             trigger_error(sprintf('%s Terminated. The feature has been disabled.', __METHOD__), E_USER_NOTICE);
         }
         // Restore the original error reporting level.
         error_reporting($iErrorReporting);
         wfProfileOut(__METHOD__);
         return true;
     }
     /**
      * @global Boolean True in scripts that may be run from the command line.
      * @see http://www.mediawiki.org/wiki/Manual:$wgCommandLineMode
      */
     global $wgCommandLineMode;
     // Ignore revisions created in the command-line mode. Otherwise HAWelcome::run() could
     // invoke HAWelcome::onRevisionInsertComplete(), too which may cause an infinite loop
     // and serious performance problems.
     if (!$wgCommandLineMode) {
         /**
          * @global Object MemcachedPhpBagOStuff A pure-PHP memcached client instance.
          * @see https://doc.wikimedia.org/mediawiki-core/master/php/html/classMemcachedPhpBagOStuff.html
          */
         global $wgMemc;
         // Abort if the contributor has been welcomed recently.
         if ($wgMemc->get(wfMemcKey('HAWelcome-isPosted', $oRevision->getRawUserText()))) {
             if (!empty($wgHAWelcomeNotices)) {
                 trigger_error(sprintf('%s Done. The contributor has been welcomed recently.', __METHOD__), E_USER_NOTICE);
             }
             // Restore the original error reporting level.
             error_reporting($iErrorReporting);
             wfProfileOut(__METHOD__);
             return true;
         }
         // Handle an edit made by an anonymous contributor.
         if (!$oRevision->getRawUser()) {
             if (!empty($wgHAWelcomeNotices)) {
                 trigger_error(sprintf('%s An edit made by an anonymous contributor.', __METHOD__), E_USER_NOTICE);
             }
             // Handle an edit made by a registered contributor.
         } else {
             if (!empty($wgHAWelcomeNotices)) {
                 trigger_error(sprintf('%s An edit made by a registered contributor.', __METHOD__), E_USER_NOTICE);
             }
             /**
              * @global Object User The state of the user viewing/using the site
              * @see http://www.mediawiki.org/wiki/Manual:$wgUser
              */
             global $wgUser;
             $wiki = WikiFactory::getWikiById($wgCityId);
             $founderId = isset($wiki->city_founding_user) ? intval($wiki->city_founding_user) : false;
             // Abort if the contributor is a member of a group that should not be welcomed or the default welcomer
             // Also, don't welcome founders as they are welcomed separately
             if ($wgUser->isAllowed('welcomeexempt') || $wgUser->getName() == HAWelcomeTask::DEFAULT_WELCOMER || $founderId === intval($oRevision->getRawUser())) {
                 if (!empty($wgHAWelcomeNotices)) {
                     trigger_error(sprintf('%s Done. The registered contributor is a bot, a staff member, the wiki founder or the default welcomer.', __METHOD__), E_USER_NOTICE);
                 }
                 // Restore the original error reporting level.
                 error_reporting($iErrorReporting);
                 wfProfileOut(__METHOD__);
                 return true;
             }
             // Abort if the registered contributor has made edits before this one.
             if (1 < $wgUser->getEditCountLocal()) {
                 // Check the extension settings...
                 /** @type String The user to become the welcomer. */
                 $sSender = trim(wfMessage('welcome-user')->inContentLanguage()->text());
                 if (in_array($sSender, array('@latest', '@sysop'))) {
                     if (!empty($wgHAWelcomeNotices)) {
                         trigger_error(sprintf('%s Taking the chance to update admin activity.', __METHOD__), E_USER_NOTICE);
                     }
                     // ... and take the opportunity to update admin activity variable.
                     /** @type Array Implicit group memberships the user has. */
                     $aGroups = $wgUser->getEffectiveGroups();
                     if (in_array('sysop', $aGroups) && !in_array('bot', $aGroups)) {
                         if (!empty($wgHAWelcomeNotices)) {
                             trigger_error(sprintf('%s Updating admin activity.', __METHOD__), E_USER_NOTICE);
                         }
                         $wgMemc->set(wfMemcKey('last-sysop-id'), $wgUser->getId());
                     }
                 }
                 if (!empty($wgHAWelcomeNotices)) {
                     trigger_error(sprintf('%s Done. The registered contributor has already made edits.', __METHOD__), E_USER_NOTICE);
                 }
                 // Restore the original error reporting level.
                 error_reporting($iErrorReporting);
                 wfProfileOut(__METHOD__);
                 return true;
             }
         }
         // Mark that we have handled this particular contributor to prevent
         // creating more jobs. Improves performance if the contributor is editing massively.
         $wgMemc->set(wfMemcKey('HAWelcome-isPosted', $oRevision->getRawUserText()), true);
         /** @type Object Title Title associated with the revision */
         $oTitle = $oRevision->getTitle();
         // Sometimes, for some reason or other, the Revision object
         // does not contain the associated Title object. It has to be
         // recreated based on the associated Page object.
         if (!$oTitle) {
             $oTitle = Title::newFromId($oRevision->getPage(), Title::GAID_FOR_UPDATE);
             if (!empty($wgHAWelcomeNotices)) {
                 trigger_error(sprintf('%s Recreated Title for page %d, revision %d, URL %s', __METHOD__, $oRevision->getPage(), $oRevision->getId(), $oTitle->getFullURL()), E_USER_NOTICE);
             }
         }
         /** @type Array Parameters for the job */
         $aParams = array('iUserId' => $oRevision->getRawUser(), 'sUserName' => $oRevision->getRawUserText(), 'iTimestamp' => time());
         if (!empty($wgHAWelcomeNotices)) {
             trigger_error(sprintf('%s Scheduling a job.', __METHOD__), E_USER_NOTICE);
         }
         self::queueHAWelcomeTask($wgCityId, $oTitle, $aParams);
     }
     if (!empty($wgHAWelcomeNotices)) {
         trigger_error(sprintf('%s Done.', __METHOD__), E_USER_NOTICE);
     }
     // Restore the original error reporting level.
     error_reporting($iErrorReporting);
     wfProfileOut(__METHOD__);
     return true;
 }
Example #20
0
include '../../../maintenance/commandLine.inc';
//
// Michał Roszka (Mix) <*****@*****.**>
//
// IMPORTANT: The script might look too verbose.
// The point of the extra verbosity is to investigate the BugId:10474.
//
//
// Step 1 of 3: load a wiki based on SERVER_ID
//
echo "Step 1 of 3: trying to load a wiki based on SERVER_ID.\n";
$wiki = WikiFactory::getWikiById($wgCityId);
// Force WikiFactory::getWikiById() to query DB_MASTER if needed.
if (!is_object($wiki)) {
    echo "Step 1 of 3: first attempt to load a wiki failed, querying DB_MASTER.\n";
    $wiki = WikiFactory::getWikiById($wgCityId, true);
}
if (!is_object($wiki)) {
    echo "Not a valid wiki. Aborting.\n";
    exit(1);
}
echo "Step 1 of 3: wiki has been loaded.\n";
//
// Step 2 of 3: load a User object corresponding to the founder of the wiki
//
echo "Step 2 of 3: trying to load a User object corresponding to the founder of the wiki.\n";
$user = User::newFromId($wiki->city_founding_user);
// User::newFromId always returns an instance of User class so the load() call without any checks is safe.
$user->load();
if (0 == $user->getId()) {
    echo "Not a valid user. Aborting.\n";
	// get var id
	$var = WikiFactory::getVarByName( 'wgRelatedVideosPartialRelease', $wgCityId );
	echo "wgRelatedVideosPartialRelease ID: ".$var->cv_id."\n";

	// get list of wikis with wgRelatedVideosPartialRelease = false
	$wikis = WikiFactory::getListOfWikisWithVar( $var->cv_id, 'bool', '=' , false, true );
	$total = count( $wikis );
	echo "Total wikis (wgRelatedVideosPartialRelease = false): ".$total."\n";

	$counter = 0;
	$failed = 0;

	foreach( $wikis as $wikiId => $detail ) {
		$counter++;
		echo "[$counter of $total] Wiki $wikiId ";
		$wiki = WikiFactory::getWikiById( $wikiId );
		if ( !empty($wiki) && $wiki->city_public == 1 ) {
			$dbname = $wiki->city_dbname;

			echo "($dbname): \n";

			// get number of RelatedVideos articles on the wiki
			if ( $getTotalRV ) {
				getTotalRV( $dbname );
			}

			// set up video info
			if ( $setupVideoInfo ) {
				setupVideoInfo( $wikiId );
			}
 function formatRow($row)
 {
     global $wgLang;
     $type = implode(Phalanx::getTypeNames($row->ps_blocker_type));
     $username = $row->ps_blocked_user;
     $timestamp = $wgLang->timeanddate($row->ps_timestamp);
     $oWiki = WikiFactory::getWikiById($row->ps_wiki_id);
     $url = $oWiki->city_url;
     $html = '<li>';
     $html .= wfMsgExt('phalanx-stats-row', array('parseinline'), $type, $username, $url, $timestamp);
     $html .= '</li>';
     return $html;
 }
Example #23
0
}
if (!Sanitizer::validateEmail($params['email'])) {
    die("Invalid email address.\n");
}
// set variables
global $wgTitle, $wgCityId, $wgPasswordSender, $wgContLang, $wgEnableAnswers;
$params['name'] = strstr($params['email'], '@', TRUE);
if (!array_key_exists('lang', $params) || empty($params['lang'])) {
    $params['language'] = 'en';
} else {
    $params['language'] = $params['lang'];
}
$wgTitle = Title::newMainPage();
$wgContLang = wfGetLangObj($params['language']);
$city_id = $wgCityId ? $wgCityId : 177;
$foundingWiki = WikiFactory::getWikiById($city_id);
$wikiType = !empty($wgEnableAnswers) ? '-answers' : '';
$emailParams = array('$USERNAME' => $params['name'], '$WIKINAME' => $foundingWiki->city_title, '$WIKIURL' => $foundingWiki->city_url, '$UNIQUEVIEWS' => 789, '$USERJOINS' => 456, '$USEREDITS' => 123, '$EDITORNAME' => 'Someone', '$EDITORURL' => 'http://www.wikia.com', '$PAGETITLE' => 'Main Page', '$PAGEURL' => 'http://www.wikia.com', '$EDITORTALKPAGEURL' => 'http://www.wikia.com', '$MYHOMEURL' => 'http://www.wikia.com', '$ADDAPAGEURL' => 'http://www.wikia.com', '$ADDAPHOTOURL' => 'http://www.wikia.com', '$CUSTOMIZETHEMEURL' => 'http://www.wikia.com', '$EDITMAINPAGEURL' => 'http://www.wikia.com', '$EXPLOREURL' => 'http://www.wikia.com', '$WIKIMAINPAGEURL' => 'http://www.wikia.com', '$USERPAGEEDITURL' => 'http://www.wikia.com');
$content_types = array('html', 'text');
$types = array('user-registered', 'anon-edit', 'general-edit', 'first-edit', 'lot-happening', 'views-digest', 'complete-digest', 'DayZero', 'DayThree', 'DayTen');
$days_passed_events = array('DayZero', 'DayThree', 'DayTen');
$to = new MailAddress($params['email'], $params['name'], $params['name']);
$sender = new MailAddress($wgPasswordSender);
foreach ($content_types as $content_type) {
    foreach ($types as $type) {
        // get messages
        $params['type'] = $type;
        $html_template = 'GeneralUpdate';
        switch ($params['type']) {
            case 'user-registered':
                $msg_key_subj = 'founderemails' . $wikiType . '-email-user-registered-subject';
 /**
  * execute
  *
  * entry point for TaskExecutor
  *
  * @access public
  * @author Andrzej 'nAndy' Łukaszewski
  *
  * @param mixed $params default null - task data from wikia_tasks table
  *
  * @return boolean - status of operation
  */
 public function execute($params = null)
 {
     global $wgCityId;
     $noErrors = true;
     $params = unserialize($params->task_arguments);
     if (isset($params['wiki_id'])) {
         $wikiId = intval($params['wiki_id']);
     } else {
         $this->log('No wiki id given.');
         $noErrors = false;
     }
     if ($noErrors && $wikiId > 0) {
         $wiki = WikiFactory::getWikiById($wikiId);
         if (!is_object($wiki)) {
             $wiki = WikiFactory::getWikiById($wgCityId, true);
         }
         if (!is_object($wiki)) {
             $this->log('Not a valid wiki. (wiki id: ' . $wikiId . ')');
             $noErrors = false;
         }
         if (empty($wiki->city_dbname)) {
             $this->log('Not a valid wiki db (' . $wiki->city_dbname . '). (wiki id: ' . $wikiId . ')');
             $noErrors = false;
         }
         if ($noErrors) {
             if (defined('NS_USER_WALL') && defined('NS_USER_WALL_MESSAGE')) {
                 $wikiDb = $wiki->city_dbname;
                 $dbw = wfGetDB(DB_SLAVE, array(), $wikiDb);
                 //checking followed users
                 $results = $dbw->select('watchlist', array('wl_user', 'wl_title'), array('wl_namespace' => NS_USER_TALK, 'wl_user > 0', 'locate(wl_title, \'/\') = 0'), __METHOD__);
                 if ($results !== false) {
                     while ($row = $dbw->fetchObject($results)) {
                         if (isset($row->wl_user) && isset($row->wl_title)) {
                             $users[] = array('user_id' => $row->wl_user, 'title' => $row->wl_title);
                         } else {
                             $this->log('WALL_TASK_NOTICE: No wl_user or wl_title from database. wl_user: '******'not set') . ' wl_title: ' . (isset($row->wl_title) ? $row->wl_title : 'not set'));
                         }
                     }
                     $dbw->freeResult($results);
                     //creating data of followed walls
                     foreach ($users as $user) {
                         $data[] = array('wl_user' => $user['user_id'], 'wl_namespace' => NS_USER_WALL, 'wl_title' => $user['title']);
                         $data[] = array('wl_user' => $user['user_id'], 'wl_namespace' => NS_USER_WALL_MESSAGE, 'wl_title' => $user['title']);
                     }
                     if (!empty($data)) {
                         $dbw = wfGetDB(DB_MASTER, array(), $wikiDb);
                         return $dbw->insert('watchlist', $data, __METHOD__, 'IGNORE');
                     } else {
                         $this->log('WALL_TASK_NOTICE: No data to add to database');
                     }
                 } else {
                     $this->log('WALL_TASK_NOTICE: No results from database query');
                 }
             } else {
                 $this->log('No NS_USER_WALL and/or NS_USER_WALL_MESSAGE defined when copy follows action run');
                 $noErrors = false;
             }
         }
     }
     return $noErrors;
 }
Example #25
0
 /**
  * @brief Returns true if a user is founder of a wiki
  *
  * @param integer $userId user's id
  * @param integer $wikiId wiki's id
  *
  * @return boolean
  *
  * @author Andrzej 'nAndy' Łukaszewski
  */
 public static function isUserFounder($userName, $wikiId)
 {
     global $wgMemc;
     wfProfileIn(__METHOD__);
     $memcKey = 'lookupUser' . 'user' . 'isUserFounder' . $userName . 'on' . $wikiId;
     $result = $cachedData = $wgMemc->get($memcKey);
     if ($result !== true && $result !== false) {
         $result = false;
         $user = User::newFromName($userName);
         $wiki = WikiFactory::getWikiById($wikiId);
         if (intval($wiki->city_founding_user) === intval($user->getId())) {
             $result = true;
         }
         $wgMemc->set($memcKey, $result, 3600);
         //1h
     }
     wfProfileOut(__METHOD__);
     return $result;
 }
 public function process(array $events)
 {
     global $wgCityId, $wgEnableAnswers, $wgMemc;
     wfProfileIn(__METHOD__);
     if ($this->isThresholdMet(count($events))) {
         // get just one event when we have more... for now, just randomly
         $eventData = $events[rand(0, count($events) - 1)];
         // quit if this particular user has generated an edit email in the last hour
         $memcKey = wfMemcKey("FounderEmail", "EditEvent", $eventData['data']['editorName']);
         if ($wgMemc->get($memcKey) == "1") {
             return true;
         }
         $foundingWiki = WikiFactory::getWikiById($wgCityId);
         $founderEmailObj = FounderEmails::getInstance();
         $wikiService = F::build('WikiService');
         $user_ids = $wikiService->getWikiAdminIds();
         $emailParams = array('$EDITORNAME' => $eventData['data']['editorName'], '$EDITORPAGEURL' => $eventData['data']['editorPageUrl'], '$EDITORTALKPAGEURL' => $eventData['data']['editorTalkPageUrl'], '$MYHOMEURL' => $eventData['data']['myHomeUrl'], '$WIKINAME' => $foundingWiki->city_title, '$PAGETITLE' => $eventData['data']['titleText'], '$PAGEURL' => $eventData['data']['titleUrl'], '$WIKIURL' => $foundingWiki->city_url);
         $msgKeys = array();
         $today = date('Y-m-d');
         $wikiType = !empty($wgEnableAnswers) ? '-answers' : '';
         foreach ($user_ids as $user_id) {
             $user = User::newFromId($user_id);
             // skip if not enable
             if (!$this->enabled($wgCityId, $user)) {
                 continue;
             }
             // skip if reciever is the editor
             if ($user->getName() == $eventData['data']['editorName']) {
                 continue;
             }
             // BugID: 1961 Quit if the founder email is not confirmed
             if (!$user->isEmailConfirmed()) {
                 return true;
             }
             $aAllCounter = unserialize($user->getOption('founderemails-counter'));
             if (empty($aAllCounter)) {
                 $aAllCounter = array();
             }
             // quit if the Founder has recieved enough emails today
             $aWikiCounter = empty($aAllCounter[$wgCityId]) ? array() : $aAllCounter[$wgCityId];
             if (!empty($aWikiCounter[0]) && $aWikiCounter[0] == $today && $aWikiCounter[1] === 'full') {
                 return true;
             }
             // initialize or reset counter for today
             if (empty($aWikiCounter[0]) || $aWikiCounter[0] !== $today) {
                 $aWikiCounter[0] = $today;
                 $aWikiCounter[1] = 0;
             }
             self::addParamsUser($wgCityId, $user->getName(), $emailParams);
             $mailCategory = FounderEmailsEvent::CATEGORY_DEFAULT;
             // @FIXME magic number, move to config
             if ($aWikiCounter[1] === 15) {
                 $msgKeys['subject'] = 'founderemails-lot-happening-subject';
                 $msgKeys['body'] = 'founderemails-lot-happening-body';
                 $msgKeys['body-html'] = 'founderemails-lot-happening-body-HTML';
                 $mailCategory = FounderEmailsEvent::CATEGORY_EDIT_HIGH_ACTIVITY;
                 $mailKey = 'lot-happening';
             } elseif ($eventData['data']['registeredUserFirstEdit']) {
                 $msgKeys['subject'] = 'founderemails' . $wikiType . '-email-page-edited-reg-user-first-edit-subject';
                 $msgKeys['body'] = 'founderemails' . $wikiType . '-email-page-edited-reg-user-first-edit-body';
                 $msgKeys['body-html'] = 'founderemails' . $wikiType . '-email-page-edited-reg-user-first-edit-body-HTML';
                 $mailCategory = FounderEmailsEvent::CATEGORY_FIRST_EDIT_USER;
                 $mailKey = 'first-edit';
             } elseif ($eventData['data']['registeredUser']) {
                 $msgKeys['subject'] = 'founderemails' . $wikiType . '-email-page-edited-reg-user-subject';
                 $msgKeys['body'] = 'founderemails' . $wikiType . '-email-page-edited-reg-user-body';
                 $msgKeys['body-html'] = 'founderemails' . $wikiType . '-email-page-edited-reg-user-body-HTML';
                 $mailCategory = FounderEmailsEvent::CATEGORY_EDIT_USER;
                 $mailKey = 'general-edit';
             } else {
                 $msgKeys['subject'] = 'founderemails' . $wikiType . '-email-page-edited-anon-subject';
                 $msgKeys['body'] = 'founderemails' . $wikiType . '-email-page-edited-anon-body';
                 $msgKeys['body-html'] = 'founderemails' . $wikiType . '-email-page-edited-anon-body-HTML';
                 $mailCategory = FounderEmailsEvent::CATEGORY_EDIT_ANON;
                 $mailKey = 'anon-edit';
             }
             // Set flag so this user won't generate edit notifications for 1 hour
             $wgMemc->set($memcKey, "1", 3600);
             // Increment counter for daily notification limit
             $aWikiCounter[1] = $aWikiCounter[1] === 15 ? 'full' : $aWikiCounter[1] + 1;
             $aAllCounter[$wgCityId] = $aWikiCounter;
             $user->setOption('founderemails-counter', serialize($aAllCounter));
             $user->saveSettings();
             $langCode = $user->getOption('language');
             $mailCategory .= !empty($langCode) && $langCode == 'en' ? 'EN' : 'INT';
             $mailSubject = strtr(wfMsgExt($msgKeys['subject'], array('content')), $emailParams);
             $mailBody = strtr(wfMsgExt($msgKeys['body'], array('content')), $emailParams);
             if (empty($wgEnableAnswers)) {
                 // FounderEmailv2.1
                 $links = array('$EDITORNAME' => $emailParams['$EDITORPAGEURL'], '$PAGETITLE' => $emailParams['$PAGEURL'], '$WIKINAME' => $emailParams['$WIKIURL']);
                 $mailBodyHTML = F::app()->renderView("FounderEmails", "GeneralUpdate", array_merge($emailParams, array('language' => 'en', 'type' => $mailKey)));
                 $mailBodyHTML = strtr($mailBodyHTML, FounderEmails::addLink($emailParams, $links));
             } else {
                 // old emails
                 $mailBodyHTML = $this->getLocalizedMsg($msgKeys['body-html'], $emailParams);
             }
             wfProfileOut(__METHOD__);
             $founderEmailObj->notifyFounder($user, $this, $mailSubject, $mailBody, $mailBodyHTML, $wgCityId, $mailCategory);
         }
         return true;
     }
     wfProfileOut(__METHOD__);
     return false;
 }