Example #1
0
 /**
  * @param User $user
  * @param IContextSource $context
  * @param array $defaultPreferences
  */
 static function watchlistPreferences($user, IContextSource $context, &$defaultPreferences)
 {
     $config = $context->getConfig();
     $watchlistdaysMax = ceil($config->get('RCMaxAge') / (3600 * 24));
     # # Watchlist #####################################
     if ($user->isAllowed('editmywatchlist')) {
         $editWatchlistLinks = array();
         $editWatchlistModes = array('edit' => array('EditWatchlist', false), 'raw' => array('EditWatchlist', 'raw'), 'clear' => array('EditWatchlist', 'clear'));
         foreach ($editWatchlistModes as $editWatchlistMode => $mode) {
             // Messages: prefs-editwatchlist-edit, prefs-editwatchlist-raw, prefs-editwatchlist-clear
             $editWatchlistLinks[] = Linker::linkKnown(SpecialPage::getTitleFor($mode[0], $mode[1]), $context->msg("prefs-editwatchlist-{$editWatchlistMode}")->parse());
         }
         $defaultPreferences['editwatchlist'] = array('type' => 'info', 'raw' => true, 'default' => $context->getLanguage()->pipeList($editWatchlistLinks), 'label-message' => 'prefs-editwatchlist-label', 'section' => 'watchlist/editwatchlist');
     }
     $defaultPreferences['watchlistdays'] = array('type' => 'float', 'min' => 0, 'max' => $watchlistdaysMax, 'section' => 'watchlist/displaywatchlist', 'help' => $context->msg('prefs-watchlist-days-max')->numParams($watchlistdaysMax)->escaped(), 'label-message' => 'prefs-watchlist-days');
     $defaultPreferences['wllimit'] = array('type' => 'int', 'min' => 0, 'max' => 1000, 'label-message' => 'prefs-watchlist-edits', 'help' => $context->msg('prefs-watchlist-edits-max')->escaped(), 'section' => 'watchlist/displaywatchlist');
     $defaultPreferences['extendwatchlist'] = array('type' => 'toggle', 'section' => 'watchlist/advancedwatchlist', 'label-message' => 'tog-extendwatchlist');
     $defaultPreferences['watchlisthideminor'] = array('type' => 'toggle', 'section' => 'watchlist/advancedwatchlist', 'label-message' => 'tog-watchlisthideminor');
     $defaultPreferences['watchlisthidebots'] = array('type' => 'toggle', 'section' => 'watchlist/advancedwatchlist', 'label-message' => 'tog-watchlisthidebots');
     $defaultPreferences['watchlisthideown'] = array('type' => 'toggle', 'section' => 'watchlist/advancedwatchlist', 'label-message' => 'tog-watchlisthideown');
     $defaultPreferences['watchlisthideanons'] = array('type' => 'toggle', 'section' => 'watchlist/advancedwatchlist', 'label-message' => 'tog-watchlisthideanons');
     $defaultPreferences['watchlisthideliu'] = array('type' => 'toggle', 'section' => 'watchlist/advancedwatchlist', 'label-message' => 'tog-watchlisthideliu');
     $defaultPreferences['watchlistreloadautomatically'] = array('type' => 'toggle', 'section' => 'watchlist/advancedwatchlist', 'label-message' => 'tog-watchlistreloadautomatically');
     if ($config->get('RCWatchCategoryMembership')) {
         $defaultPreferences['watchlisthidecategorization'] = array('type' => 'toggle', 'section' => 'watchlist/advancedwatchlist', 'label-message' => 'tog-watchlisthidecategorization');
     }
     if ($user->useRCPatrol()) {
         $defaultPreferences['watchlisthidepatrolled'] = array('type' => 'toggle', 'section' => 'watchlist/advancedwatchlist', 'label-message' => 'tog-watchlisthidepatrolled');
     }
     $watchTypes = array('edit' => 'watchdefault', 'move' => 'watchmoves', 'delete' => 'watchdeletion');
     // Kinda hacky
     if ($user->isAllowed('createpage') || $user->isAllowed('createtalk')) {
         $watchTypes['read'] = 'watchcreations';
     }
     if ($user->isAllowed('rollback')) {
         $watchTypes['rollback'] = 'watchrollback';
     }
     foreach ($watchTypes as $action => $pref) {
         if ($user->isAllowed($action)) {
             // Messages:
             // tog-watchdefault, tog-watchmoves, tog-watchdeletion, tog-watchcreations
             // tog-watchrollback
             $defaultPreferences[$pref] = array('type' => 'toggle', 'section' => 'watchlist/advancedwatchlist', 'label-message' => "tog-{$pref}");
         }
     }
     if ($config->get('EnableAPI')) {
         $defaultPreferences['watchlisttoken'] = array('type' => 'api');
         $defaultPreferences['watchlisttoken-info'] = array('type' => 'info', 'section' => 'watchlist/tokenwatchlist', 'label-message' => 'prefs-watchlist-token', 'default' => $user->getTokenFromOption('watchlisttoken'), 'help-message' => 'prefs-help-watchlist-token2');
     }
 }
 /**
  * @param User $user
  * @param IContextSource $context
  * @param array $defaultPreferences
  */
 static function rcPreferences($user, IContextSource $context, &$defaultPreferences)
 {
     $config = $context->getConfig();
     $rcMaxAge = $config->get('RCMaxAge');
     ## RecentChanges #####################################
     $defaultPreferences['rcdays'] = array('type' => 'float', 'label-message' => 'recentchangesdays', 'section' => 'rc/displayrc', 'min' => 1, 'max' => ceil($rcMaxAge / (3600 * 24)), 'help' => $context->msg('recentchangesdays-max')->numParams(ceil($rcMaxAge / (3600 * 24)))->text());
     $defaultPreferences['rclimit'] = array('type' => 'int', 'label-message' => 'recentchangescount', 'help-message' => 'prefs-help-recentchangescount', 'section' => 'rc/displayrc');
     $defaultPreferences['usenewrc'] = array('type' => 'toggle', 'label-message' => 'tog-usenewrc', 'section' => 'rc/advancedrc');
     $defaultPreferences['hideminor'] = array('type' => 'toggle', 'label-message' => 'tog-hideminor', 'section' => 'rc/advancedrc');
     if ($user->useRCPatrol()) {
         $defaultPreferences['hidepatrolled'] = array('type' => 'toggle', 'section' => 'rc/advancedrc', 'label-message' => 'tog-hidepatrolled');
         $defaultPreferences['newpageshidepatrolled'] = array('type' => 'toggle', 'section' => 'rc/advancedrc', 'label-message' => 'tog-newpageshidepatrolled');
     }
     if ($config->get('RCShowWatchingUsers')) {
         $defaultPreferences['shownumberswatching'] = array('type' => 'toggle', 'section' => 'rc/advancedrc', 'label-message' => 'tog-shownumberswatching');
     }
 }
Example #3
0
 /**
  * @param object|RecentChange $rc Database row from recentchanges or a RecentChange object
  * @param User $user
  * @return bool
  */
 public static function isUnpatrolled($rc, User $user)
 {
     if ($rc instanceof RecentChange) {
         $isPatrolled = $rc->mAttribs['rc_patrolled'];
         $rcType = $rc->mAttribs['rc_type'];
     } else {
         $isPatrolled = $rc->rc_patrolled;
         $rcType = $rc->rc_type;
     }
     if (!$isPatrolled) {
         if ($user->useRCPatrol()) {
             return true;
         }
         if ($user->useNPPatrol() && $rcType == RC_NEW) {
             return true;
         }
     }
     return false;
 }
 private function getWatchedItemsWithRCInfoQueryFilterConds(User $user, array $options)
 {
     $conds = [];
     if (in_array(self::FILTER_MINOR, $options['filters'])) {
         $conds[] = 'rc_minor != 0';
     } elseif (in_array(self::FILTER_NOT_MINOR, $options['filters'])) {
         $conds[] = 'rc_minor = 0';
     }
     if (in_array(self::FILTER_BOT, $options['filters'])) {
         $conds[] = 'rc_bot != 0';
     } elseif (in_array(self::FILTER_NOT_BOT, $options['filters'])) {
         $conds[] = 'rc_bot = 0';
     }
     if (in_array(self::FILTER_ANON, $options['filters'])) {
         $conds[] = 'rc_user = 0';
     } elseif (in_array(self::FILTER_NOT_ANON, $options['filters'])) {
         $conds[] = 'rc_user != 0';
     }
     if ($user->useRCPatrol() || $user->useNPPatrol()) {
         // TODO: not sure if this should simply ignore patrolled filters if user does not have the patrol
         // right, or maybe rather fail loud at this point, same as e.g. ApiQueryWatchlist does?
         if (in_array(self::FILTER_PATROLLED, $options['filters'])) {
             $conds[] = 'rc_patrolled != 0';
         } elseif (in_array(self::FILTER_NOT_PATROLLED, $options['filters'])) {
             $conds[] = 'rc_patrolled = 0';
         }
     }
     if (in_array(self::FILTER_UNREAD, $options['filters'])) {
         $conds[] = 'rc_timestamp >= wl_notificationtimestamp';
     } elseif (in_array(self::FILTER_NOT_UNREAD, $options['filters'])) {
         // TODO: should this be changed to use Database::makeList?
         $conds[] = 'wl_notificationtimestamp IS NULL OR rc_timestamp < wl_notificationtimestamp';
     }
     return $conds;
 }