예제 #1
0
 /**
  * Clears the user's password, sets an empty e-mail and marks as disabled
  *
  * @param  User    $user         User account to close
  * @param  string  $changeReason Reason for change
  * @param  string  $mStatusMsg   Main error message
  * @param  string  $mStatusMsg2  Secondary (non-critical) error message
  * @param  boolean $keepEmail    Optionally keep the email address in a
  *                               user option
  * @return boolean               true on success, false on failure
  */
 public static function closeAccount($user = '', $changeReason = '', &$mStatusMsg = '', &$mStatusMsg2 = '', $keepEmail = true)
 {
     if (empty($user)) {
         throw new Exception('User object is invalid.');
     }
     $id = $user->getId();
     # Set flag for Special:Contributions
     # NOTE: requires FlagClosedAccounts.php to be included separately
     if (defined('CLOSED_ACCOUNT_FLAG')) {
         $user->setRealName(CLOSED_ACCOUNT_FLAG);
     } else {
         # magic value not found, so lets at least blank it
         $user->setRealName('');
     }
     // remove users avatar
     if (class_exists('Masthead')) {
         $avatar = Masthead::newFromUser($user);
         if (!$avatar->isDefault()) {
             if (!$avatar->removeFile(false)) {
                 # dont quit here, since the avatar is a non-critical part of closing, but flag for later
                 $mStatusMsg2 = wfMessage('editaccount-remove-avatar-fail')->plain();
             }
         }
     }
     // close account and invalidate cache + cluster data
     Wikia::invalidateUser($user, true, $keepEmail, true);
     // if they are connected from facebook, disconnect them
     self::disconnectFromFacebook($user);
     if ($user->getEmail() == '') {
         $title = Title::newFromText('EditAccount', NS_SPECIAL);
         // Log what was done
         $log = new LogPage('editaccnt');
         $log->addEntry('closeaccnt', $title, $changeReason, array($user->getUserPage()));
         // All clear!
         $mStatusMsg = wfMessage('editaccount-success-close', $user->mName)->plain();
         wfRunHooks('EditAccountClosed', array($user));
         return true;
     } else {
         // There were errors...inform the user about those
         $mStatusMsg = wfMessage('editaccount-error-close', $user->mName)->plain();
         return false;
     }
 }
예제 #2
0
 /**
  * Blanks user profile data
  * @author grunny
  */
 public function resetUserProfile()
 {
     global $wgMemc;
     foreach ($this->optionsArray as $option) {
         if ($option === 'gender' || $option === 'birthday') {
             $option = self::USER_PROPERTIES_PREFIX . $option;
         }
         $this->user->setGlobalAttribute($option, null);
         $this->user->saveSettings();
         $wgMemc->delete($this->getMemcUserIdentityDataKey());
         Wikia::invalidateUser($this->user);
     }
 }