/** * @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; }
/** * @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)))->escaped()); $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 ($config->get('RCWatchCategoryMembership')) { $defaultPreferences['hidecategorization'] = array('type' => 'toggle', 'label-message' => 'tog-hidecategorization', 'section' => 'rc/advancedrc'); } if ($user->useRCPatrol()) { $defaultPreferences['hidepatrolled'] = array('type' => 'toggle', 'section' => 'rc/advancedrc', 'label-message' => 'tog-hidepatrolled'); } if ($user->useNPPatrol()) { $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'); } }
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; }