function execute()
 {
     $dbw = wfGetDB(DB_MASTER);
     $table = 'user_properties';
     $oldPropName = 'narayamDisable';
     $newPropName = 'narayamEnable';
     $this->output("Changing {$oldPropName} to {$newPropName}\n");
     $allIds = array();
     while (true) {
         $dbw->begin();
         $res = $dbw->select($table, array('up_user'), array('up_property' => $oldPropName, 'up_value' => 1), __METHOD__, array('LIMIT' => $this->mBatchSize, 'FOR UPDATE'));
         if (!$res->numRows()) {
             break;
         }
         $ids = array();
         foreach ($res as $row) {
             $ids[] = $row->up_user;
         }
         $dbw->update($table, array('up_property' => $newPropName, 'up_value' => 0), array('up_property' => $oldPropName, 'up_user' => $ids), __METHOD__);
         $dbw->commit();
         foreach ($ids as $id) {
             $user = User::newFromID($id);
             if ($user) {
                 $user->invalidateCache();
             }
         }
         wfWaitForSlaves(10);
     }
     $this->output("Old preference {$oldPropName} was migrated to {$newPropName}\n");
 }
 function execute($par)
 {
     global $wgRequest, $wgOut, $wgUser, $wgLang;
     $target = isset($par) ? $par : $wgRequest->getVal('target');
     $sk = $wgUser->getSkin();
     $dbr =& wfGetDB(DB_SLAVE);
     $wgOut->setHTMLTitle('Edits Patrol Count - wikiHow');
     $wgOut->addHTML('  <style type="text/css" media="all">/*<![CDATA[*/ @import "/extensions/wikihow/Patrolcount.css"; /*]]>*/</style>');
     $me = Title::makeTitle(NS_SPECIAL, "Patrolcount");
     // allow the user to grab the local patrol count relative to their own timezone
     if ($wgRequest->getVal('patrolcountview', null)) {
         $wgUser->setOption('patrolcountlocal', $wgRequest->getVal('patrolcountview'));
         $wgUser->saveSettings();
     }
     if ($wgUser->getOption('patrolcountlocal', "GMT") != "GMT") {
         $links = "[" . $sk->makeLinkObj($me, wfMsg('patrolcount_viewGMT'), "patrolcountview=GMT") . "] [" . wfMsg('patrolcount_viewlocal') . "]";
         $result = Patrolcount::getPatrolcountWindow();
         $date1 = $result[0];
         $date2 = $result[1];
         //echo "$date1 , $date2";
     } else {
         $links = "[" . wfMsg('patrolcount_viewGMT') . "] [" . $sk->makeLinkObj($me, wfMsg('patrolcount_viewlocal'), "patrolcountview=local") . "]";
         $now = wfTimestamp(TS_UNIX);
         $date1 = substr(wfTimestamp(TS_MW), 0, 8) . "000000";
         $date2 = substr(wfTimestamp(TS_MW, $now + 24 * 3600), 0, 8) . "000000";
     }
     //echo "<h3>date1 $date1 to $date2</h3>";
     //grab the total
     $total = $dbr->selectField('logging', 'count(*)', array('log_type' => 'patrol', "log_timestamp>'{$date1}'", "log_timestamp<'{$date2}'"));
     $wgOut->addHTML("<div id='Patrolcount'>");
     $wgOut->addHTML(wfMsg('patrolcount_summary') . "<br/><br/>" . wfMsg('patrolcount_total', number_format($total, 0, '', ',')) . "<br/><br/><center>");
     $wgOut->addHTML($links);
     $wgOut->addHTML("<br/><br/><table width='500px' align='center' class='status'>");
     $sql = "SELECT log_user, count(*) as C FROM logging FORCE INDEX (times) WHERE log_type='patrol' AND log_timestamp > '{$date1}' AND log_timestamp < '{$date2}' GROUP BY log_user ORDER BY C DESC LIMIT 20";
     $res = $dbr->query($sql, __METHOD__);
     $index = 1;
     $wgOut->addHTML("<tr>\n\t                       <td></td>\n\t                        <td>User</td>\n\t                        <td  align='right'>" . wfMsg('patrolcount_numberofeditspatrolled') . "</td>\n\t                        <td align='right'>" . wfMsg('patrolcount_percentangeheader') . "</td>\n\t                        </tr>\n\t        ");
     while (($row = $dbr->fetchObject($res)) != null) {
         $u = User::newFromID($row->log_user);
         //skip auto-patrolled patrols
         if (in_array('bot', $u->getGroups()) || $u->getOption('autopatrol')) {
             continue;
         }
         $percent = $total == 0 ? "0" : number_format($row->C / $total * 100, 2);
         $count = number_format($row->C, 0, "", ',');
         $class = "";
         if ($index % 2 == 1) {
             $class = 'class="odd"';
         }
         $log = $sk->makeLinkObj(Title::makeTitle(NS_SPECIAL, 'Log'), $count, 'type=patrol&user='******'right'>{$log}</td>\n\t\t\t\t<td align='right'> {$percent} % </td>\n\t\t\t\t</tr>\n\t\t\t");
         $index++;
     }
     $wgOut->addHTML("</table></center>");
     if ($wgUser->getOption('patrolcountlocal', "GMT") != "GMT") {
         $wgOut->addHTML("<br/><br/><i><font size='-2'>" . wfMsgWikiHtml('patrolcount_viewlocal_info') . "</font></i>");
     }
     $wgOut->addHTML("</div>");
 }
 function formatResult($skin, $result)
 {
     global $wgLang, $wgContLang;
     $user = User::newFromID($result->rev_user);
     $ulinks = Linker::userLink($result->rev_user, $user->getName());
     $ulinks .= Linker::userToolLinks($result->rev_user, $user->getName());
     $date = date('h:i, d F Y', wfTimestamp(TS_UNIX, $result->rev_timestamp));
     return $ulinks . " " . $result->numedits . " edits | {$date}";
 }
 /**
  * Render file data
  */
 public static function renderData($data)
 {
     global $wgContLang, $wgUser;
     $user = User::newFromID($data[0]);
     $name = $user->getRealName();
     if (empty($name)) {
         $name = $user->getName();
     }
     $d = $wgContLang->userDate($data[1], $wgUser);
     $t = $wgContLang->userTime($data[1], $wgUser);
     return wfMsg('jqueryupload-uploadinfo', $name, $d, $t);
 }
Example #5
0
 /**
  * main entry point
  *
  * @access public
  */
 public function run()
 {
     global $wgUseEnotif;
     wfProfileIn(__METHOD__);
     if (!$wgUseEnotif) {
         wfProfileOut(__METHOD__);
         return true;
     }
     if ($this->mParams['user_id']) {
         /* registered User */
         $editor = User::newFromID($this->mParams['user_id']);
     } elseif ($this->mParams['user_name']) {
         /* anons */
         $editor = User::newFromName($this->mParams['user_name'], false);
     } else {
         /* invalid user */
         wfProfileOut(__METHOD__);
         return true;
     }
     /**
      * get title of page, take main part from this title which will be
      * main page for user blogs (listing)
      */
     $ownerTitle = BlogArticle::getOwnerTitle($this->title);
     /**
      * check who watches this page
      */
     $dbr = wfGetDB(DB_SLAVE);
     $res = $dbr->select(array("watchlist"), array("wl_user"), array("wl_namespace" => $ownerTitle->getNamespace(), "wl_title" => $ownerTitle->getDBKey()), __METHOD__);
     while ($row = $dbr->fetchObject($res)) {
         $watchers[] = intval($row->wl_user);
     }
     if (!empty($watchers)) {
         $enotif = new EmailNotification();
         $title = Title::makeTitle($ownerTitle->getNamespace(), $ownerTitle->getDBKey());
         $enotif->actuallyNotifyOnPageChange($editor, $title, $this->params['timestamp'], $this->params['comment'], $this->params['minor'], 0, $watchers, $this->params['log_action']);
         /* Update wl_notificationtimestamp for all watching users except the editor */
         $dbw = wfGetDB(DB_MASTER);
         $dbw->begin();
         $dbw->update('watchlist', array('wl_notificationtimestamp' => $dbw->timestamp(wfTimestampNow())), array('wl_title' => $ownerTitle->getDBkey(), 'wl_namespace' => $ownerTitle->getNamespace(), 'wl_user' => $watchers), __METHOD__);
         $dbw->commit();
     }
     wfProfileOut(__METHOD__);
     return true;
 }
Example #6
0
 function followCat($title, $cat, $user = null)
 {
     if (!$user) {
         // who first edited this article?
         $dbr = wfGetDB(DB_SLAVE);
         $row = $dbr->selectRow('firstedit', array('fe_user', 'fe_user_text'), array('fe_page' => $title->getArticleID()));
         if ($row->fe_user == 0) {
             return true;
         }
         // if the were a registered user, that user is now interestd in article in this category
         // at least by a little bit
         $user = User::newFromID($row->fe_user);
     }
     $dbw = wfGetDB(DB_MASTER);
     $cat = preg_replace("@\\[\\[Category:|\\]\\]@i", "", $cat);
     $t = Title::makeTitle(NS_CATEGORY, $cat);
     $sql = "INSERT INTO follow (fo_user, fo_user_text, fo_type, fo_target_id, fo_target_name, fo_weight, fo_timestamp) " . " VALUES ({$user->getID()}, " . $dbw->addQuotes($user->getName()) . ", 'category', {$t->getArticleID()}, " . $dbw->addQuotes($t->getText()) . ", 1, " . $dbw->addQuotes(wfTimestampNow()) . ") " . self::duplicateCheck();
     $dbw->query($sql);
 }
Example #7
0
 function setWgUser()
 {
     global $wgUser;
     $dbw = wfGetDB(DB_MASTER);
     $wh_userid = $dbw->selectField('facebook_connect', array('wh_user'), array('fb_user' => $this->userid));
     // Never here before?  create a new user and log them in
     if ($wh_userid == null) {
         $u = User::createNew('FB_' . $this->userid);
         if (!$u) {
             $u = User::newFromName('FB_' . $this->userid);
         }
         $dbw->insert('facebook_connect', array('wh_user' => $u->getID(), 'fb_user' => $this->userid));
     } else {
         $u = User::newFromID($wh_userid);
         $dbw->update('facebook_connect', array('num_login = num_login + 1'), array('wh_user' => $wh_userid));
     }
     $wgUser = $u;
     $wgUser->setCookies();
 }
Example #8
0
 public function userBlock($type = 'exact')
 {
     wfProfileIn(__METHOD__);
     $this->user->mBlockedby = $this->block->authorId;
     $this->user->mBlockedGlobally = true;
     $this->user->mBlockreason = UserBlock::getBlockReasonMessage($this->block->reason, $type == 'exact', $type == 'ip');
     // set expiry information
     $this->user->mBlock = new Block();
     // protected
     $this->user->mBlock->setId($this->block->id);
     $this->user->mBlock->setBlockEmail(true);
     $this->user->mBlock->setBlocker(User::newFromID($this->block->authorId));
     // public
     $this->user->mBlock->mExpiry = isset($this->block->expires) && !empty($this->block->expires) ? $this->block->expires : 'infinity';
     $this->user->mBlock->mTimestamp = wfTimestampNow();
     $this->user->mBlock->mAddress = $this->block->text;
     if ($type == 'ip') {
         $this->user->mBlock->setCreateAccount(1);
     }
     wfProfileOut(__METHOD__);
     return $this;
 }
 function setWgUser()
 {
     global $wgUser, $wgOut, $wgDBname;
     LoginForm::renewSessionId();
     $bNew = true;
     $dbw = wfGetDB(DB_MASTER);
     $dbw->selectDB(WH_DATABASE_NAME_SHARED);
     $wh_userid = $dbw->selectField('gplus_connect', array('wh_user'), array('gplus_user' => $this->userid));
     $dbw->selectDB($wgDBname);
     // Never here before?  create a new user and log them in
     if ($wh_userid == null) {
         $u = User::createNew('GP_' . $this->userid);
         if (!$u) {
             $u = User::newFromName('GP_' . $this->userid);
         }
         $dbw->selectDB(WH_DATABASE_NAME_SHARED);
         $dbw->insert('gplus_connect', array('wh_user' => $u->getID(), 'gplus_user' => $this->userid));
         $dbw->selectDB($wgDBname);
     } else {
         $u = User::newFromID($wh_userid);
         $dbw->selectDB(WH_DATABASE_NAME_SHARED);
         $dbw->update('gplus_connect', array('num_login = num_login + 1'), array('wh_user' => $wh_userid));
         $dbw->selectDB($wgDBname);
         $bNew = false;
     }
     $wgUser = $u;
     $wgUser->setCookies();
     if (!$bNew) {
         $dbw->selectDB(WH_DATABASE_NAME_SHARED);
         $registered = $dbw->selectField('user', array('user_email'), array('user_id' => $wh_userid));
         $dbw->selectDB($wgDBname);
         //pass them to our start page if they're logging in again...
         if ($registered) {
             $wgOut->redirect($this->returnto);
         }
     }
 }
 public function execute($par)
 {
     global $wgTitle, $wgOut, $wgRequest, $wgUser;
     $target = isset($par) ? $par : $wgRequest->getVal('target');
     $wgOut->setHTMLTitle('New Article Boost Status - wikiHow');
     $sk = $wgUser->getSkin();
     $dbr = wfGetDB(DB_SLAVE);
     $wgOut->addHTML('<style type="text/css" media="all">/*<![CDATA[*/ @import "' . wfGetPad('/extensions/min/f/extensions/wikihow/nab/newarticleboost.css&' . Newarticleboost::REVISION) . '"; /*]]>*/</style>');
     $wgOut->addHTML(wfMsg('nap_statusinfo'));
     $wgOut->addHTML("<br/><center>");
     $days = $wgRequest->getVal('days', 1);
     if ($days == 1) {
         $wgOut->addHTML(" [" . wfMsg('nap_last1day') . "] ");
         $wgOut->addHTML(" [" . $sk->makeLinkObj($wgTitle, wfMsg('nap_last7day'), "days=7") . "] ");
         $wgOut->addHTML(" [" . $sk->makeLinkObj($wgTitle, wfMsg('nap_last30day'), "days=30") . "] ");
     } else {
         if ($days == 7) {
             $wgOut->addHTML(" [" . $sk->makeLinkObj($wgTitle, wfMsg('nap_last1day'), "days=1") . "] ");
             $wgOut->addHTML(" [" . wfMsg('nap_last7day') . "] ");
             $wgOut->addHTML(" [" . $sk->makeLinkObj($wgTitle, wfMsg('nap_last30day'), "days=30") . "] ");
         } else {
             if ($days == 30) {
                 $wgOut->addHTML(" [" . $sk->makeLinkObj($wgTitle, wfMsg('nap_last1day'), "days=1") . "] ");
                 $wgOut->addHTML(" [" . $sk->makeLinkObj($wgTitle, wfMsg('nap_last7day'), "days=7") . "] ");
                 $wgOut->addHTML(" [" . wfMsg('nap_last30day') . "] ");
             }
         }
     }
     $days_ago = wfTimestamp(TS_MW, time() - 60 * 60 * 24 * $days);
     $boosted = $dbr->selectField(array('newarticlepatrol', 'page'), array('count(*)'), array('page_id=nap_page', 'page_is_redirect=0', 'nap_patrolled=1', "nap_timestamp_ci > '{$days_ago}'"), __METHOD__);
     $newarticles = $dbr->selectField(array('newarticlepatrol'), array('count(*)'), array("nap_timestamp > '{$days_ago}'"), __METHOD__);
     $na_boosted = $dbr->selectField(array('newarticlepatrol'), array('count(*)'), array("nap_timestamp > '{$days_ago}'", "nap_patrolled" => 1), __METHOD__);
     $boosted = number_format($boosted, 0, "", ",");
     $newarticles = number_format($newarticles, 0, "", ",");
     $na_boosted = number_format($na_boosted, 0, "", ",");
     $per_boosted = $newarticles > 0 ? number_format($na_boosted / $newarticles * 100, 2) : 0;
     $wgOut->addHTML("<br/><br/><div>\n\t\t\t\t<table width='50%' align='center' class='status'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>" . wfMsg('nap_totalboosted') . "</td>\n\t\t\t\t\t\t<td>{$boosted}</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>" . wfMsg('nap_numnewboosted') . "</td>\n\t\t\t\t\t\t<td>{$na_boosted}</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t <tr>\n\t\t\t\t\t\t<td>" . wfMsg('nap_numarticles') . "</td>\n\t\t\t\t\t\t<td>{$newarticles}</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>" . wfMsg('nap_perofnewbosted') . "</td>\n\t\t\t\t\t\t<td>{$per_boosted}%</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t\t</div>");
     $wgOut->addHTML("</center>");
     $wgOut->addHTML("<br/>" . wfMsg('nap_userswhoboosted') . "<br/><br/><center>\n\t\t\t<table width='500px' align='center' class='status'>");
     $total = $dbr->selectField('logging', 'count(*)', array('log_type' => 'nap', "log_timestamp>'{$days_ago}'"), __METHOD__);
     $sql = "SELECT log_user, count(*) AS C\n\t\t\t\t  FROM logging WHERE log_type = 'nap'\n\t\t\t\t    AND log_timestamp > '{$days_ago}'\n\t\t\t\t  GROUP BY log_user\n\t\t\t\t  ORDER BY C DESC\n\t\t\t\t  LIMIT 20";
     $res = $dbr->query($sql, __METHOD__);
     $index = 1;
     $wgOut->addHTML("<tr>\n\t\t\t<td></td>\n\t\t\t\t<td>User</td>\n\t\t\t\t<td  align='right'>" . wfMsg('nap_numboosted') . "</td>\n\t\t\t\t<td align='right'>" . wfMsg('nap_perboosted') . "</td>\n\t\t\t\t</tr>");
     while (($row = $dbr->fetchObject($res)) != null) {
         $user = User::newFromID($row->log_user);
         $percent = $total == 0 ? "0" : number_format($row->C / $total * 100, 0);
         $count = number_format($row->C, 0, "", ',');
         $log = $sk->makeLinkObj(Title::makeTitle(NS_SPECIAL, 'Log'), $count, 'type=nap&user='******'right'>{$log}</td>\n\t\t\t\t<td align='right'> {$percent} % </td>\n\t\t\t\t</tr>\n\t\t\t");
         $index++;
     }
     $dbr->freeResult($res);
     $wgOut->addHTML("</table></center>");
 }
Example #11
0
 public function purgeUsers($userIDs)
 {
     $userNames = array();
     foreach ($userIDs as $user_id) {
         $user = User::newFromID($user_id);
         $userNames[] = "'" . $user->getName() . "'";
     }
     $this->doPurgeUsers($userIDs, $userNames);
 }
$cutoff1 = wfTimestamp(TS_MW, time() - $argv[0] * 24 * 3600 * 30);
$cutoff2 = wfTimestamp(TS_MW, time() - $argv[1] * 24 * 3600 * 30);
$users = array();
$dbr = wfGetDB(DB_SLAVE);
$res = $dbr->select('user', array('user_id', 'user_email', 'user_name', 'user_editcount'), array("user_registration > '{$cutoff1}'", "user_registration < '{$cutoff2}'", 'user_editcount > 5'));
while ($row = $dbr->fetchObject($res)) {
    // did this user make an edit since the cutoff?
    $edits = $dbr->selectField(array('page', 'revision'), array('count(*)'), array('page_id=rev_page', 'rev_user' => $row->user_id, 'page_namespace' => NS_MAIN, "rev_timestamp>'{$cutoff2}'"));
    if ($edits > 0 && $row->user_email) {
        $users[$row->user_id] = $row->user_email;
    }
}
echo "got " . sizeof($users) . "\n";
$newusers = array();
foreach ($users as $id => $email) {
    $u = User::newFromID($id);
    if (!$u) {
        echo "can'tmake user from id {$id}\n";
        continue;
    }
    if ($u->getOption('disablemarketingemail', 0) != 1) {
        $newusers[] = $u;
    }
}
echo "got " . sizeof($newusers) . "\n";
shuffle($newusers);
$size = sizeof($newusers);
$control = array_splice($newusers, 0, $size / 2);
$batch1 = array_splice($newusers, 0, $size / 12);
$batch2 = array_splice($newusers, 0, $size / 12);
$batch3 = array_splice($newusers, 0, $size / 12);
Example #13
0
 /**
  * Create a new block with specified parameters on a user, IP or IP range.
  *
  * @param array $options Parameters of the block:
  *     address string|User  Target user name, User object, IP address or IP range
  *     user int             Override target user ID (for foreign users)
  *     by int               User ID of the blocker
  *     reason string        Reason of the block
  *     timestamp string     The time at which the block comes into effect
  *     auto bool            Is this an automatic block?
  *     expiry string        Timestamp of expiration of the block or 'infinity'
  *     anonOnly bool        Only disallow anonymous actions
  *     createAccount bool   Disallow creation of new accounts
  *     enableAutoblock bool Enable automatic blocking
  *     hideName bool        Hide the target user name
  *     blockEmail bool      Disallow sending emails
  *     allowUsertalk bool   Allow the target to edit its own talk page
  *     byText string        Username of the blocker (for foreign users)
  *
  * @since 1.26 accepts $options array instead of individual parameters; order
  * of parameters above reflects the original order
  */
 function __construct($options = array())
 {
     $defaults = array('address' => '', 'user' => null, 'by' => null, 'reason' => '', 'timestamp' => '', 'auto' => false, 'expiry' => '', 'anonOnly' => false, 'createAccount' => false, 'enableAutoblock' => false, 'hideName' => false, 'blockEmail' => false, 'allowUsertalk' => false, 'byText' => '');
     if (func_num_args() > 1 || !is_array($options)) {
         $options = array_combine(array_slice(array_keys($defaults), 0, func_num_args()), func_get_args());
         wfDeprecated(__METHOD__ . ' with multiple arguments', '1.26');
     }
     $options += $defaults;
     $this->setTarget($options['address']);
     if ($this->target instanceof User && $options['user']) {
         # Needed for foreign users
         $this->forcedTargetID = $options['user'];
     }
     if ($options['by']) {
         # Local user
         $this->setBlocker(User::newFromID($options['by']));
     } else {
         # Foreign user
         $this->setBlocker($options['byText']);
     }
     $this->mReason = $options['reason'];
     $this->mTimestamp = wfTimestamp(TS_MW, $options['timestamp']);
     $this->mExpiry = wfGetDB(DB_SLAVE)->decodeExpiry($options['expiry']);
     # Boolean settings
     $this->mAuto = (bool) $options['auto'];
     $this->mHideName = (bool) $options['hideName'];
     $this->isHardblock(!$options['anonOnly']);
     $this->isAutoblocking((bool) $options['enableAutoblock']);
     # Prevention measures
     $this->prevents('sendemail', (bool) $options['blockEmail']);
     $this->prevents('editownusertalk', !$options['allowUsertalk']);
     $this->prevents('createaccount', (bool) $options['createAccount']);
     $this->mFromMaster = false;
 }
Example #14
0
 /**
  * @author Wikia
  *
  * if user_name is empty - use User class to get his name
  * @param DatabaseRow $row
  */
 public function fixUserName(&$row)
 {
     wfProfileIn(__METHOD__);
     if (empty($row->user_name)) {
         $user = User::newFromID($row->log_user);
         if (!is_null($user)) {
             $row->user_name = $user->getName();
         }
     }
     wfProfileOut(__METHOD__);
 }
Example #15
0
 /**
  * Get the User object of the person who performed this change.
  *
  * @return User
  */
 public function getPerformer()
 {
     if ($this->mPerformer === false) {
         if ($this->mAttribs['rc_user']) {
             $this->mPerformer = User::newFromID($this->mAttribs['rc_user']);
         } else {
             $this->mPerformer = User::newFromName($this->mAttribs['rc_user_text'], false);
         }
     }
     return $this->mPerformer;
 }
Example #16
0
 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;
 }
Example #17
0
 protected function formatData($row)
 {
     $user = null;
     if ($row['post_user_id'] > 0) {
         $user = User::newFromID($row['post_user_id']);
     } else {
         $user = User::newFromName($this->long2ip($row['post_user_ip']), false);
     }
     $message = WallMessage::newFromId($row['page_id']);
     if (empty($message)) {
         return;
     }
     $title = $message->getTitle();
     if ($title instanceof Title && $message instanceof WallMessage) {
         return array('user' => $user, 'event_date' => $row['event_date'], 'event_iso' => wfTimestamp(TS_ISO_8601, $row['event_date']), 'event_mw' => wfTimestamp(TS_MW, $row['event_date']), 'display_username' => $user->getId() == 0 ? wfMsg('oasis-anon-user') : $user->getName(), 'metatitle' => $row['metatitle'], 'page_id' => $row['page_id'], 'title' => $title, 'is_reply' => $row['is_reply'], 'action' => $row['action'], 'reason' => $row['reason'], 'revision_id' => $row['revision_id'], 'wall_message' => $message);
     } else {
         //it happened once on devbox when master&slave weren't sync'ed
         wfDebug(__METHOD__ . ": Seems like master&slave are not sync'ed\n");
     }
 }
<?php

require_once 'commandLine.inc';
$db = DatabaseBase::factory('mysql');
$db->open($wgVanillaDB['host'], $wgVanillaDB['user'], $wgVanillaDB['password'], $wgVanillaDB['dbname']);
$oldignore = $db->ignoreErrors(true);
$res = $db->select('GDN_UserAuthentication', array('UserID', 'ForeignUserKey'));
$updates = array();
while ($row = $db->fetchObject($res)) {
    $u = User::newFromID($row->ForeignUserKey);
    $url = Avatar::getAvatarURL($u->getName());
    $updates[$row->UserID] = $url;
}
foreach ($updates as $userid => $url) {
    echo "Updating {$userid} with avatar {$url}\n";
    $db->update("GDN_User", array("Photo" => $url), array("UserID" => $userid));
}
 function processViewership()
 {
     $thresholds = array(25, 100, 500, 1000, 5000);
     $thresh2 = 10000;
     $dbr = wfGetDB(DB_SLAVE);
     $res = $dbr->select(array('email_notifications'), array('en_viewership_email', 'en_viewership', 'en_user', 'en_page'), array('en_watch' => 1), __METHOD__);
     while ($row = $dbr->fetchObject($res)) {
         $sendflag = 0;
         $viewership = 0;
         $milestone = 0;
         $title = Title::newFromID($row->en_page);
         $user = User::newFromID($row->en_user);
         if (isset($title)) {
             $viewership = $dbr->selectField('page', 'page_counter', array('page_id' => $title->getArticleID()), __METHOD__);
             $prev = $row->en_viewership;
             if ($viewership > $thresh2) {
                 $a = floor($prev / $thresh2);
                 $b = floor($viewership / $thresh2);
                 if ($b > $a) {
                     $milestone = $b * $thresh2;
                     $sendflag = 1;
                 }
             } else {
                 foreach ($thresholds as $level) {
                     if ($prev < $level && $level < $viewership) {
                         $milestone = $level;
                         $sendflag = 1;
                     }
                 }
             }
             if ($sendflag) {
                 echo "Processing: [TITLE] " . $title->getText() . "(" . $title->getArticleID() . ") [USER] " . $user->getName() . ", [VIEWS]" . $row->en_viewership . " - " . $viewership . " [MILESTONE] {$milestone} \n";
                 AuthorEmailNotification::notifyViewership($title, $user, $milestone, $viewership, $row->en_viewership_email);
             } else {
                 echo "Skipping: [TITLE] " . $title->getText() . "(" . $title->getArticleID() . ") [USER] " . $user->getName() . ", [VIEWS]" . $row->en_viewership . " - " . $viewership . " [MILESTONE] {$milestone} \n";
             }
         } else {
             echo "Article Removed: [PAGE] " . $row->en_page . " [USER] " . $row->en_user . "\n";
         }
     }
 }
Example #20
0
 /**
  * Given a database row from the ipblocks table, initialize
  * member variables
  * @param stdClass $row A row from the ipblocks table
  */
 protected function initFromRow($row)
 {
     $this->setTarget($row->ipb_address);
     if ($row->ipb_by) {
         // local user
         $this->setBlocker(User::newFromID($row->ipb_by));
     } else {
         // foreign user
         $this->setBlocker($row->ipb_by_text);
     }
     $this->mReason = $row->ipb_reason;
     $this->mTimestamp = wfTimestamp(TS_MW, $row->ipb_timestamp);
     $this->mAuto = $row->ipb_auto;
     $this->mHideName = $row->ipb_deleted;
     $this->mId = $row->ipb_id;
     $this->mParentBlockId = $row->ipb_parent_block_id;
     // I wish I didn't have to do this
     $db = wfGetDB(DB_SLAVE);
     if ($row->ipb_expiry == $db->getInfinity()) {
         $this->mExpiry = 'infinity';
     } else {
         $this->mExpiry = wfTimestamp(TS_MW, $row->ipb_expiry);
     }
     $this->isHardblock(!$row->ipb_anon_only);
     $this->isAutoblocking($row->ipb_enable_autoblock);
     $this->prevents('createaccount', $row->ipb_create_account);
     $this->prevents('sendemail', $row->ipb_block_email);
     $this->prevents('editownusertalk', !$row->ipb_allow_usertalk);
 }
	/**
	 * Renders the special page
	*/
	function execute( $par ) {
		global $wgOut, $wgRequest, $wgUser, $wgWatchersLimit;

		$this->setHeaders();

		$page = $wgRequest->getVal( 'page', $par );
		if ( $page !== null ) {
			$title = Title::newFromText( $page );
			if ( !$title instanceof Title ) {
				$wgOut->addWikiMsg( 'watchers-error-invalid-page', $page );
				return;
			}
		} else {
			# b/c
			$id = $wgRequest->getInt( 'article', 0 );
			$title = Title::newFromID( $id );

			# Check for valid title
			if ( $id == 0 || $title->getArticleID() <= 0 ) {
				$wgOut->addWikiMsg( 'watchers_error_article' );
				return;
			}
		}

		$dbr = wfGetDB( DB_SLAVE );
		$conds = array(
			'wl_namespace' => $title->getNamespace(),
			'wl_title' => $title->getDBkey(),
		);

		$watcherscount = $dbr->selectField(
			/* FROM   */ 'watchlist',
			/* SELECT */ 'count(wl_user) AS num',
			/* WHERE  */ $conds,
			__METHOD__
		);

		if ( $wgUser->isAllowed( 'watchers-list' ) ) {
			if ( $watcherscount == 0 ) {
				$wgOut->addWikiMsg( 'watchers_noone_watches', $title->getPrefixedText() );
			} else {
				$wgOut->wrapWikiMsg( '<h2>$1</h2>', array( 'watchers_header', $title->getPrefixedText(), $watcherscount ) );

				$res = $dbr->select(
					/* FROM   */ 'watchlist',
					/* SELECT */ 'wl_user',
					/* WHERE  */ $conds,
					__METHOD__
				);

				$sk = $wgUser->getSkin();

				$wgOut->addHTML( "<ol>\n" );
				foreach ( $res AS $row ) {
					$u = User::newFromID( $row->wl_user );
					$link = $sk->link( $u->getUserPage(), htmlspecialchars( $u->getName() ) );
					$wgOut->addHTML( "<li>" . $link . "</li>\n" );
				}
				$wgOut->addHTML( "</ol>\n" );
			}
		} else {
			if ( $wgWatchersLimit === null ) {
				if ( $watcherscount == 0 ) {
					$wgOut->addWikiMsg( 'watchers_noone_watches', $title->getPrefixedText() );
				} else {
					$wgOut->addWikiMsg( 'watchers-num', $watcherscount, $title->getPrefixedText() );
				}
			} else {
				if ( $watcherscount >= $wgWatchersLimit ) {
					$wgOut->addWikiMsg( 'watchers_x_or_more', $wgWatchersLimit, $title->getPrefixedText() );
				} else {
					$wgOut->addWikiMsg( 'watchers_less_than_x', $wgWatchersLimit, $title->getPrefixedText() );
				}
			}
		}
	}
Example #22
0
 public static function removePicture($uid = '')
 {
     global $wgUser;
     if ($uid == '') {
         $u = $wgUser->getID();
     } else {
         $u = $uid;
     }
     $fileext = array('jpg', 'png', 'gif', 'jpeg');
     $filename = $u . ".jpg";
     $crop_out = self::getAvatarOutFilePath($filename) . $filename;
     if (file_exists($crop_out)) {
         if (unlink($crop_out)) {
             foreach ($fileext as $ext) {
                 $filename = "{$u}.{$ext}";
                 $crop_in = self::getAvatarInFilePath($filename) . $filename;
                 if (file_exists($crop_in)) {
                     if (!unlink($crop_in)) {
                         wfDebug("can't delete {$crop_in}\n");
                     }
                 }
                 $filename = "tmp_{$u}.{$ext}";
                 $crop_in2 = self::getAvatarInFilePath($filename) . $filename;
                 if (file_exists($crop_in2)) {
                     if (!unlink($crop_in2)) {
                         wfDebug("can't delete {$crop_in2}\n");
                     }
                 }
             }
             $dbw = wfGetDB(DB_MASTER);
             $sql = "UPDATE avatar SET av_patrol=2, av_patrolledBy=" . $dbw->addQuotes($wgUser->getId()) . ", av_patrolledDate='" . wfTimestampNow() . "' WHERE av_user="******"SUCCESS: files removed {$crop_out} and {$crop_in}";
         } else {
             wfDebug("FAILED: files exists could not be removed. {$crop_out}");
             return "FAILED: files exists could not be removed. {$crop_out}";
         }
     }
     // files don't have to exist if we use av_image
     $dbw = wfGetDB(DB_MASTER);
     $sql = "UPDATE avatar SET av_patrol=2, av_patrolledBy=" . $dbw->addQuotes($wgUser->getId()) . ", av_patrolledDate='" . wfTimestampNow() . "' WHERE av_user="******"UPDATE avatar set av_image='' where av_user="******"SUCCESS: Facebook avatar removed";
     }
     // Remove avatar url (av_image) for G+ users
     if ($user && $user->isGPlusUser()) {
         $sql = "UPDATE avatar set av_image='' where av_user="******"SUCCESS: Google+ avatar removed";
     }
     return "FAILED: files do not exist. {$crop_out}";
 }
echo "\n\n<!-- " . date("r") . " user stats ... --->\n";
// get the group of "very active users", they are the ones with 500+ edits
$users = array();
wfDebug("Dashboard getting users with > 500 edits: {$sql}\n");
$res = $dbw->query("select rev_user, count(*) as C from {$table} {$join} {$where} group by rev_user having C > 500 order by C desc", __FILE__);
while ($row = $dbw->fetchObject($res)) {
    $users[$row->rev_user] = $row->C;
}
echo "<a href='https://" . REPORTS_HOST . REPORTS_DIR . "/" . date("Ymd") . ".html'>Full report</a>";
echo "<h1> User stats </h1>\n";
echo "<table class='dashboard' style='font-family: Arial; margin-left:auto; margin-right:auto; width: 90%;'><tr><td {$tdstyle} colspan='2'>";
echo "<h2>Very active users who have 10+ edits in the past week </h2><ol>";
foreach ($users as $u => $c) {
    $count = selectField($dbw, "select count(*) from {$table} {$join} where rev_timestamp > '" . $w_cutoff . "' and rev_user="******"<li>" . getUserLink($x) . " - " . nf($c) . " - {$count} " . getUserToolLinks($x) . "</li>\n";
    }
}
echo "</ol></td></tr><tr><td {$tdstyle}>";
echo "<h2>Users who have 100+ edits in the past month </h2><ol>";
$sql = "select rev_user_text, count(*) as C from {$table} {$join} where rev_timestamp > '{$m_cutoff} ' and rev_timestamp <  '{$start}' {$andcond} group by rev_user_text having C >= 100 order by C desc";
wfDebug("Dashboard 100+ edits in past month: {$sql}\n");
$res = $dbw->query($sql, __FILE__);
while ($row = $dbw->fetchObject($res)) {
    $x = User::newFromName($row->rev_user_text);
    echo "<li> " . getUserLink($x) . " - " . nf($row->C) . getUserToolLinks($x) . "</li>\n";
}
echo "</ol></td><td {$tdstyle}>";
echo "<h2>Users who have 25+ edits in the past week</h2><ol>";
 /**
  * Query for NFDs Reviewed
  **/
 function getNfdsReviewed($starttimestamp, $lb_user = '', $getArticles = false)
 {
     global $wgMemc;
     if ($getArticles) {
         $key = "leaderboard:nfd:{$starttimestamp}:{$lb_user}";
     } else {
         $key = "leaderboard:nfd:{$starttimestamp}";
     }
     $cachekey = wfMemcKey($key);
     $val = $wgMemc->get($cachekey);
     if (is_array($val)) {
         return $val;
     }
     $dbr = wfGetDB(DB_SLAVE);
     $data = array();
     $bots = WikihowUser::getBotIDs();
     $bot = "";
     if (sizeof($bots) > 0) {
         $bot = " AND log_user NOT IN (" . $dbr->makeList($bots) . ") ";
     }
     $sql = "SELECT log_user, count(*) as C " . "FROM logging " . "WHERE log_type='nfd' and log_action='vote' and log_timestamp >= '{$starttimestamp}' " . $bot . "GROUP BY log_user ORDER BY C DESC LIMIT 30";
     $res = $dbr->query($sql, __METHOD__);
     foreach ($res as $row) {
         if ($row->log_user > 0) {
             $u = User::newFromID($row->log_user);
             if ($getArticles) {
                 if ($lb_user == $u->getName()) {
                     $t = Title::newFromText($row->log_title);
                     if (isset($t)) {
                         $data[$t->getPartialURL()] = $t->getPrefixedText();
                     }
                 }
             } else {
                 if (!preg_match('/\\d+\\.\\d+\\.\\d+\\.\\d+/', $u->getName())) {
                     //$data[$u->getName()]++;
                     $data[$u->getName()] = number_format($row->C, 0, "", ',');
                 }
             }
         }
     }
     $wgMemc->set($cachekey, $data, 3600);
     return $data;
 }
Example #25
0
ini_set( "include_path", dirname(__FILE__)."/../" );
require( "commandLine.inc" );

if (isset($options['help'])) {
	die( "migrating the ban status from old system to new system" );
}


if ( WikiFactory::getVarValueByName("wgChatBanMigrated", $wgCityId ) ) {
//	die( "migrating the ban status from old system to new system" );	 
}
$db = wfGetDB(DB_SLAVE, array());

/*
 * first time it run only count on pages and then it run this script with param -do and list 
 * it is hack for problem with memory leak from parser 
 */

$res = $db->query("select ug_user, ug_group from user_groups where ug_group = 'bannedfromchat'");

$admin = User::newFromName("WikiaBot");

while ($row = $db->fetchRow($res)) {
	$userToBan = User::newFromID($row['ug_user']);
	Chat::banUser($userToBan->getName(), $admin, 60*60*24*30*6, "Auto migration script for new version of chat");
	$userToBan->removeGroup('chatmoderator');
}

WikiFactory::setVarByName("wgChatBanMigrated", $wgCityId, true );

echo "List of pages\n";
 function execute($par)
 {
     global $wgRequest, $wgOut, $wgUser, $wgLang;
     $target = isset($par) ? $par : $wgRequest->getVal('target');
     $sk = $wgUser->getSkin();
     $dbr =& wfGetDB(DB_SLAVE);
     $this->setHeaders();
     $wgOut->addCSScode('pcc');
     $me = Title::makeTitle(NS_SPECIAL, "Newvideoboard");
     $now = wfTimestamp(TS_UNIX);
     // allow the user to grab the local patrol count relative to their own timezone
     if ($wgRequest->getVal('window', 'day') == 'day') {
         $links = "[" . $sk->makeLinkObj($me, wfMsg('videoboard_week'), "window=week") . "] [" . wfMsg('videoboard_day') . "]";
         $date1 = substr(wfTimestamp(TS_MW, $now - 24 * 3600 * 7), 0, 8) . "000000";
         $date2 = substr(wfTimestamp(TS_MW, $now + 24 * 3600), 0, 8) . "000000";
     } else {
         $links = "[" . wfMsg('videoboard_week') . "] [" . $sk->makeLinkObj($me, wfMsg('videoboard_day'), "window=day") . "]";
         $date1 = substr(wfTimestamp(TS_MW), 0, 8) . "000000";
         $date2 = substr(wfTimestamp(TS_MW, $now + 24 * 3600), 0, 8) . "000000";
     }
     $wgOut->addHTML($links);
     $wgOut->addHTML("<br/><br/><table width='500px' align='center' class='status'>");
     $sql = "select log_user, count(*) as C\n\t\t\t\tfrom logging where log_type='vidsfornew' and log_timestamp > '{$date1}' and log_timestamp < '{$date2}'\n\t\t\t\tgroup by log_user order by C desc limit 20;";
     $res = $dbr->query($sql);
     $index = 1;
     $wgOut->addHTML("<tr>\n\t\t\t\t\t\t   <td></td>\n\t\t\t\t\t\t\t<td>User</td>\n\t\t\t\t\t\t\t<td  align='right'>" . wfMsg('videoboard_numberofvidsadded') . "</td>\n\t\t\t\t\t\t\t</tr>");
     while (($row = $dbr->fetchObject($res)) != null) {
         $u = User::newFromID($row->log_user);
         $count = number_format($row->C, 0, "", ',');
         $class = "";
         if ($index % 2 == 1) {
             $class = 'class="odd"';
         }
         $log = $sk->makeLinkObj(Title::makeTitle(NS_SPECIAL, 'Log'), $count, 'type=vidsfornew&user='******'right'>{$log}</td>\n\t\t\t\t</tr>\n\t\t\t");
         $index++;
     }
     $wgOut->addHTML("</table></center>");
     if ($wgUser->getOption('patrolcountlocal', "GMT") != "GMT") {
         $wgOut->addHTML("<br/><br/><i><font size='-2'>" . wfMsgWikiHtml('patrolcount_viewlocal_info') . "</font></i>");
     }
 }
Example #27
0
 /**
  * Writes the data in this object to the database
  * @param $noudp bool
  */
 public function save($noudp = false)
 {
     global $wgLocalInterwiki, $wgPutIPinRC, $wgContLang;
     $dbw = wfGetDB(DB_MASTER);
     if (!is_array($this->mExtra)) {
         $this->mExtra = array();
     }
     $this->mExtra['lang'] = $wgLocalInterwiki;
     if (!$wgPutIPinRC) {
         $this->mAttribs['rc_ip'] = '';
     }
     # If our database is strict about IP addresses, use NULL instead of an empty string
     if ($dbw->strictIPs() and $this->mAttribs['rc_ip'] == '') {
         unset($this->mAttribs['rc_ip']);
     }
     # Make sure summary is truncated (whole multibyte characters)
     $this->mAttribs['rc_comment'] = $wgContLang->truncate($this->mAttribs['rc_comment'], 255);
     # Fixup database timestamps
     $this->mAttribs['rc_timestamp'] = $dbw->timestamp($this->mAttribs['rc_timestamp']);
     $this->mAttribs['rc_cur_time'] = $dbw->timestamp($this->mAttribs['rc_cur_time']);
     $this->mAttribs['rc_id'] = $dbw->nextSequenceValue('recentchanges_rc_id_seq');
     ## If we are using foreign keys, an entry of 0 for the page_id will fail, so use NULL
     if ($dbw->cascadingDeletes() and $this->mAttribs['rc_cur_id'] == 0) {
         unset($this->mAttribs['rc_cur_id']);
     }
     /* Wikia change begin - @author: Macbre */
     /* Wysiwyg: add extra data before row is added */
     wfRunHooks('RecentChange_beforeSave', array(&$this));
     /* Wikia change end */
     # Insert new row
     $dbw->insert('recentchanges', $this->mAttribs, __METHOD__);
     # Set the ID
     $this->mAttribs['rc_id'] = $dbw->insertId();
     # Notify extensions
     wfRunHooks('RecentChange_save', array(&$this));
     # Notify external application via UDP
     if (!$noudp) {
         $this->notifyRC2UDP();
     }
     # E-mail notifications
     global $wgUseEnotif, $wgShowUpdatedMarker, $wgUser;
     if ($wgUseEnotif || $wgShowUpdatedMarker) {
         // Users
         if ($this->mAttribs['rc_user']) {
             $editor = $wgUser->getId() == $this->mAttribs['rc_user'] ? $wgUser : User::newFromID($this->mAttribs['rc_user']);
             // Anons
         } else {
             $editor = $wgUser->getName() == $this->mAttribs['rc_user_text'] ? $wgUser : User::newFromName($this->mAttribs['rc_user_text'], false);
         }
         $title = Title::makeTitle($this->mAttribs['rc_namespace'], $this->mAttribs['rc_title']);
         # @todo FIXME: This would be better as an extension hook
         $enotif = new EmailNotification($editor, $title, $this->mAttribs['rc_timestamp'], $this->mAttribs['rc_comment'], $this->mAttribs['rc_minor'], $this->mAttribs['rc_this_oldid'], $this->mAttribs['rc_last_oldid'], $this->mAttribs['rc_log_action']);
         $enotif->notifyOnPageChange();
     }
     // temporary code begin /Inez
     if ($this->mAttribs['rc_type'] == RC_NEW) {
         $eventType = 'new';
     } else {
         if ($this->mAttribs['rc_type'] == RC_EDIT) {
             $eventType = 'edit';
         } else {
             if ($this->mAttribs['rc_type'] == RC_LOG && $this->mAttribs['rc_namespace'] == NS_IMAGE) {
                 $eventType = 'upload';
             }
         }
     }
     if (!empty($eventType)) {
         global $wgMemc;
         $key = $eventType . gmdate('Ymd_Hi00');
         $ret = $wgMemc->incr($key);
         if (empty($ret)) {
             $wgMemc->set($key, 1, 60 * 5);
         }
     }
     // temporary code end
 }
 /**
  * @param RecentChange|null $oRecentChange This is allowed to be null to stay compatible
  *                                         with FounderEmailsEvent::register()
  *
  * @return bool
  *
  * @throws Exception
  */
 public static function register($oRecentChange = null)
 {
     $currentUser = F::app()->wg->User;
     if (is_null($oRecentChange)) {
         throw new \Exception('Invalid $oRecentChange value.');
     }
     if (FounderEmails::getInstance()->getLastEventType() == 'register') {
         // special case: creating user page after user registration, ignore event
         return true;
     }
     $isRegisteredUser = false;
     $isRegisteredUserFirstEdit = false;
     if ($oRecentChange->getAttribute('rc_user')) {
         $editorId = $oRecentChange->getAttribute('rc_user');
         $editor = $currentUser->getId() == $editorId ? $currentUser : User::newFromID($editorId);
         $isRegisteredUser = true;
         // if first edit email was already sent this is an additional edit
         $wasNotificationSent = static::getFirstEmailSentFlag($editor->getName()) === '1';
         if (!$wasNotificationSent) {
             $userEditStatus = static::getUserEditsStatus($editor, true);
             /*
             					If there is at least one edit, flag that we should not send this email anymore;
             					either first email is sent out as a result of this request,
             					or there was more than 1 edit so we will never need to send it again
             */
             switch ($userEditStatus) {
                 case self::NO_EDITS:
                     return true;
                     break;
                 case self::FIRST_EDIT:
                     $isRegisteredUserFirstEdit = true;
                     static::setFirstEmailSentFlag($editor->getName());
                     break;
                 case self::MULTIPLE_EDITS:
                     static::setFirstEmailSentFlag($editor->getName());
             }
         }
     } else {
         // Anon user
         $editorName = $oRecentChange->getAttribute('rc_user_text');
         $editor = $currentUser->getName() == $editorName ? $currentUser : User::newFromName($editorName, false);
     }
     $config = FounderEmailsEvent::getConfig('edit');
     if (in_array('staff', $editor->getGroups()) || in_array($editor->getId(), $config['skipUsers'])) {
         // page edited by founder, staff member or excluded user, skipping..
         return true;
     }
     if ($editor->isAllowed('bot')) {
         // skip bots
         return true;
     }
     $eventData = static::getEventData($editor, $oRecentChange, $isRegisteredUser, $isRegisteredUserFirstEdit);
     FounderEmails::getInstance()->registerEvent(new FounderEmailsEditEvent($eventData));
     return true;
 }
Example #29
0
 public function save()
 {
     global $wgLocalInterwiki, $wgPutIPinRC, $wgRC2UDPAddress, $wgRC2UDPOmitBots;
     $fname = 'RecentChange::save';
     $dbw = wfGetDB(DB_MASTER);
     if (!is_array($this->mExtra)) {
         $this->mExtra = array();
     }
     $this->mExtra['lang'] = $wgLocalInterwiki;
     if (!$wgPutIPinRC) {
         $this->mAttribs['rc_ip'] = '';
     }
     # If our database is strict about IP addresses, use NULL instead of an empty string
     if ($dbw->strictIPs() and $this->mAttribs['rc_ip'] == '') {
         unset($this->mAttribs['rc_ip']);
     }
     # Fixup database timestamps
     $this->mAttribs['rc_timestamp'] = $dbw->timestamp($this->mAttribs['rc_timestamp']);
     $this->mAttribs['rc_cur_time'] = $dbw->timestamp($this->mAttribs['rc_cur_time']);
     $this->mAttribs['rc_id'] = $dbw->nextSequenceValue('recentchanges_rc_id_seq');
     ## If we are using foreign keys, an entry of 0 for the page_id will fail, so use NULL
     if ($dbw->cascadingDeletes() and $this->mAttribs['rc_cur_id'] == 0) {
         unset($this->mAttribs['rc_cur_id']);
     }
     # Insert new row
     $dbw->insert('recentchanges', $this->mAttribs, $fname);
     # Set the ID
     $this->mAttribs['rc_id'] = $dbw->insertId();
     # Notify extensions
     wfRunHooks('RecentChange_save', array(&$this));
     # Notify external application via UDP
     if ($wgRC2UDPAddress && (!$this->mAttribs['rc_bot'] || !$wgRC2UDPOmitBots)) {
         self::sendToUDP($this->getIRCLine());
     }
     # E-mail notifications
     global $wgUseEnotif, $wgShowUpdatedMarker, $wgUser;
     if ($wgUseEnotif || $wgShowUpdatedMarker) {
         // Users
         if ($this->mAttribs['rc_user']) {
             $editor = $wgUser->getId() == $this->mAttribs['rc_user'] ? $wgUser : User::newFromID($this->mAttribs['rc_user']);
             // Anons
         } else {
             $editor = $wgUser->getName() == $this->mAttribs['rc_user_text'] ? $wgUser : User::newFromName($this->mAttribs['rc_user_text'], false);
         }
         # FIXME: this would be better as an extension hook
         $enotif = new EmailNotification();
         $title = Title::makeTitle($this->mAttribs['rc_namespace'], $this->mAttribs['rc_title']);
         $enotif->notifyOnPageChange($editor, $title, $this->mAttribs['rc_timestamp'], $this->mAttribs['rc_comment'], $this->mAttribs['rc_minor'], $this->mAttribs['rc_last_oldid']);
     }
 }
    AuthorEmailNotification::notifyFeatured($t);
}
// PROCESS VIEWERSHIP EMAILS
$ts = wfTimestamp(TS_MW, time() - 86400);
$sql = "SELECT page_namespace, page_title, page_counter, en_viewership, en_user\n\t\tFROM email_notifications \n\t\tLEFT JOIN page ON en_page=page_id\n\t\tWHERE en_viewership_email IS NULL\n\t\t\tOR en_viewership_email < '{$ts}'";
$res = $dbr->query($sql, __FILE__);
$milestones = array(10000, 5000, 1000, 500, 100);
while ($row = $dbr->fetchObject($res)) {
    $send = false;
    if (!$row->page_title) {
        continue;
    }
    if ($row->page_counter >= 10000 && $row->page_counter - $row->en_viewership >= 10000) {
        $milestone = floor($row->page_counter / 10000) * 10000;
        $send = true;
    } else {
        foreach ($milestones as $m) {
            if ($row->page_counter >= $m && $row->en_viewership < $m) {
                $milestone = $m;
                $send = true;
                break;
            }
        }
    }
    if ($send) {
        $title = Title::makeTitle($row->page_namespace, $row->page_title);
        $user = User::newFromID($row->en_user);
        $user->load();
        AuthorEmailNotification::notifyViewership($title, $user, $milestone, $milestone, null);
    }
}