Example #1
0
 /**
  * @group UsingDB
  * @dataProvider getAvatarUrlDataProvider
  */
 public function testGetAvatarUrl($url, $userName, $userId, $avatarSize)
 {
     $user = new User();
     $user->setId($userId);
     $user->setName($userName);
     if ($userId > 0) {
         $user->setGlobalAttribute(AVATAR_USER_OPTION_NAME, $userId);
     }
     $this->assertStringEndsWith($url, AvatarService::getAvatarUrl($user, $avatarSize));
 }
 /**
  * @param User $user
  * @param $options
  */
 protected static function setUserAttributeByNameAndValue($user, $options)
 {
     foreach ($options as $optionName => $optionValue) {
         if (!is_array($optionValue)) {
             $user->setGlobalAttribute($optionName, $optionValue);
         }
     }
 }
 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();
 }
 /**
  * Save a user's gender from facebook if one is available. Facebook will return the
  * following values for a user's gender: 'male', 'female', null.
  * @param User $user
  */
 private function saveUserGender(User $user)
 {
     $fbUserInfo = FacebookClient::getInstance()->getUserInfo();
     $gender = $fbUserInfo->getProperty('gender');
     if (!is_null($gender)) {
         $user->setGlobalAttribute('gender', $gender);
         $user->saveSettings();
     }
 }