/**
  * Check if the the user account is scheduled to be closed
  *
  * @param  User    $user The user account to check
  * @return boolean       True if the account is scheduled for closure,
  *                       False otherwise
  */
 public function isScheduledForClosure(User $user)
 {
     return (bool) $user->getGlobalFlag('requested-closure', false) && $user->getGlobalAttribute('requested-closure-date', false) !== false;
 }
 /**
  * Keeps a per request cache of the 'founderemails-counter' user option
  *
  * @param User $admin
  *
  * @return mixed
  */
 private function getNotificationCounter(User $admin)
 {
     static $counter = null;
     if (empty($counter[$admin->getId()])) {
         $allCounter = unserialize($admin->getGlobalAttribute('founderemails-counter'));
         $allCounter = is_array($allCounter) ? $allCounter : [];
         if ($this->userCounterNeedsReset($allCounter)) {
             $allCounter[F::app()->wg->CityId] = ['date' => date('Y-m-d'), 'count' => 0];
         }
         $counter[$admin->getId()] = $allCounter;
     }
     return $counter[$admin->getId()];
 }
 /**
  * Check if account is unconfirmed. User confirms via an email we sent them.
  * @param  User $user User account
  * @return boolean true if the account is unconfirmed, false otherwise
  */
 private function isAccountUnconfirmed(User $user)
 {
     return $user->getGlobalAttribute(UserLoginSpecialController::NOT_CONFIRMED_SIGNUP_OPTION_NAME);
 }
 public static function onSetUserEmail(User $user, $newEmail, &$result, &$info)
 {
     $app = F::app();
     $oldEmail = $user->getEmail();
     $optionNewEmail = $user->getGlobalAttribute('new_email');
     if (empty($optionNewEmail) && $newEmail != $oldEmail || !empty($optionNewEmail) && $newEmail != $optionNewEmail) {
         $user->setGlobalAttribute('new_email', $newEmail);
         $user->invalidateEmail();
         if ($app->wg->EmailAuthentication) {
             $userLoginHelper = new UserLoginHelper();
             $result = $userLoginHelper->sendReconfirmationEmail($user, $newEmail);
             if ($result->isGood()) {
                 $info = 'eauth';
             }
         }
     } elseif ($newEmail != $oldEmail) {
         // if the address is the same, don't change it
         $user->setEmail($newEmail);
     }
     return true;
 }
 /**
  * Register the user viewed the watchlist,
  * so we know that following chnages should
  * result into notification emails is desired.
  * 
  * @since 0.1
  * 
  * @param User $user
  */
 protected function registerUserView(User $user)
 {
     $this->lastViewed = $user->getGlobalAttribute('swl_last_view');
     if (is_null($this->lastViewed)) {
         $this->lastViewed = wfTimestampNow();
     }
     $user->setGlobalAttribute('swl_last_view', wfTimestampNow());
     $user->setGlobalAttribute('swl_mail_count', 0);
     $user->saveSettings();
 }