function simplePageMove($old_title, $new_subject, $reason) { if ($this->user->pingLimiter('move')) { throw new ThrottledError(); } # Variables beginning with 'o' for old article 'n' for new article $ot = $old_title; $nt = $this->incrementedTitle($new_subject, $old_title->getNamespace()); self::$occupied_titles[] = $nt->getPrefixedDBkey(); $error = $ot->moveTo($nt, true, "Changed thread subject: {$reason}"); if ($error !== true) { throw new Exception("Got error {$error} trying to move pages."); } # Move the talk page if relevant, if it exists, and if we've been told to // TODO we need to implement correct moving of talk pages everywhere later. // Snipped. }
/** * Returns true if the user has surpassed the upload rate limit, false otherwise. * * @param User $user * @return bool */ public static function isThrottled($user) { return $user->pingLimiter('upload'); }
/** * Check whether a user is allowed to send email * * @param User $user * @param string $editToken Edit token * @param Config $config optional for backwards compatibility * @return string|null Null on success or string on error */ public static function getPermissionsError($user, $editToken, Config $config = null) { if ($config === null) { wfDebug(__METHOD__ . ' called without a Config instance passed to it'); $config = ConfigFactory::getDefaultInstance()->makeConfig('main'); } if (!$config->get('EnableEmail') || !$config->get('EnableUserEmail')) { return 'usermaildisabled'; } if (!$user->isAllowed('sendemail')) { return 'badaccess'; } if (!$user->isEmailConfirmed()) { return 'mailnologin'; } if ($user->isBlockedFromEmailuser()) { wfDebug("User is blocked from sending e-mail.\n"); return "blockedemailuser"; } if ($user->pingLimiter('emailuser')) { wfDebug("Ping limiter triggered.\n"); return 'actionthrottledtext'; } $hookErr = false; Hooks::run('UserCanSendEmail', array(&$user, &$hookErr)); Hooks::run('EmailUserPermissionsErrors', array($user, $editToken, &$hookErr)); if ($hookErr) { return $hookErr; } return null; }
/** * Check whether a user is allowed to send email * * @param User $user * @param string $editToken Edit token * @return string|null Null on success or string on error */ public static function getPermissionsError($user, $editToken) { global $wgEnableEmail, $wgEnableUserEmail; if (!$wgEnableEmail || !$wgEnableUserEmail) { return 'usermaildisabled'; } if (!$user->isAllowed('sendemail')) { return 'badaccess'; } if (!$user->isEmailConfirmed()) { return 'mailnologin'; } if ($user->isBlockedFromEmailuser()) { wfDebug("User is blocked from sending e-mail.\n"); return "blockedemailuser"; } if ($user->pingLimiter('emailuser')) { wfDebug("Ping limiter triggered.\n"); return 'actionthrottledtext'; } $hookErr = false; wfRunHooks('UserCanSendEmail', array(&$user, &$hookErr)); wfRunHooks('EmailUserPermissionsErrors', array($user, $editToken, &$hookErr)); if ($hookErr) { return $hookErr; } return null; }