/**
  * Don't send 404 status for user pages with filled in masthead (bugid:44602)
  * @brief hook handler
  *
  * @param Article $article
  *
  * @return Boolean
  */
 public static function onBeforeDisplayNoArticleText($article)
 {
     global $UPPNamespaces;
     $wg = F::app()->wg;
     $title = $article->getTitle();
     if ($title instanceof Title && in_array($title->getNamespace(), $UPPNamespaces)) {
         $user = UserProfilePageHelper::getUserFromTitle($title);
         if ($user instanceof User && $user->getId() > 0) {
             $userIdentityBox = new UserIdentityBox($user);
             $userData = $userIdentityBox->getFullData();
             if (is_array($userData) && array_key_exists('showZeroStates', $userData)) {
                 if (!$userData['showZeroStates']) {
                     $wg->Out->setStatusCode(200);
                 }
             }
         }
     }
     return true;
 }
 /**
  * @brief Passes more data to the template to render about modal box
  *
  * @param int $userId
  *
  * @author Andrzej 'nAndy' Łukaszewski
  */
 private function renderAboutLightbox($userId)
 {
     wfProfileIn(__METHOD__);
     $user = User::newFromId($userId);
     /**
      * @var $userIdentityBox UserIdentityBox
      */
     $userIdentityBox = new UserIdentityBox($user);
     $userData = $userIdentityBox->getFullData();
     if (!empty($userData['fbPage'])) {
         $userData['fbPage'] = str_replace(self::FBPAGE_BASE_URL, '', $userData['fbPage']);
     }
     $this->setVal('user', $userData);
     $this->setVal('charLimits', ['name' => UserIdentityBox::USER_NAME_CHAR_LIMIT, 'location' => UserIdentityBox::USER_LOCATION_CHAR_LIMIT, 'occupation' => UserIdentityBox::USER_OCCUPATION_CHAR_LIMIT, 'gender' => UserIdentityBox::USER_GENDER_CHAR_LIMIT]);
     if (!empty($userData['birthday']['month'])) {
         $this->setVal('days', cal_days_in_month(CAL_GREGORIAN, $userData['birthday']['month'], 2000));
     }
     wfProfileOut(__METHOD__);
 }
Ejemplo n.º 3
0
 /**
  * Before resetting the options, save the masthead info so we can restore it in onSpecialPreferencesAfterResetUserOptions
  *
  * @param $storage - storage in which we can save some options, it will be passed in onSpecialPreferencesAfterResetUserOptions hook call
  * @param User $user
  */
 public static function onSpecialPreferencesBeforeResetUserOptions($preferences, &$user, &$storage)
 {
     // user identity box/masthead
     $userIdentityObject = new UserIdentityBox($user);
     $mastheadOptions = $userIdentityObject->getFullData();
     $masthead = new Masthead($user);
     if (!empty($masthead->mUser->mOptionOverrides['avatar'])) {
         $mastheadOptions['avatar'] = $masthead->mUser->mOptionOverrides['avatar'];
     }
     $storage[self::MASTHEAD_OPTIONS_STORAGE_ARRAY_KEY_NAME] = $mastheadOptions;
     // customize toolbar/myToolbar
     $oasisToolbarService = new SharedToolbarService();
     $toolbarNameInUserOptions = $oasisToolbarService->getToolbarOptionName();
     $toolbarCurrentList = $user->getGlobalPreference($oasisToolbarService->getToolbarOptionName());
     $storage[self::MY_TOOLBAR_OPTIONS_STORAGE_ARRAY_KEY_NAME] = array($toolbarNameInUserOptions => $toolbarCurrentList);
     return true;
 }
Ejemplo n.º 4
0
 /**
  * Before resetting the options, save the masthead info so we can restore it in onSpecialPreferencesAfterResetUserOptions
  *
  * @param $storage - storage in which we can save some options, it will be passed in onSpecialPreferencesAfterResetUserOptions hook call
  * @param User $user
  */
 public function onSpecialPreferencesBeforeResetUserOptions($preferences, &$user, &$storage)
 {
     //user identity box/masthead
     $userIdentityObject = new UserIdentityBox(F::app(), $user, 0);
     $mastheadOptions = $userIdentityObject->getFullData();
     $masthead = F::build('Masthead', array($user));
     if (!empty($masthead->mUser->mOptionOverrides['avatar'])) {
         $mastheadOptions['avatar'] = $masthead->mUser->mOptionOverrides['avatar'];
     }
     $storage[self::MASTHEAD_OPTIONS_STORAGE_ARRAY_KEY_NAME] = $mastheadOptions;
     //customize toolbar/myToolbar
     $skinName = RequestContext::getMain()->getSkin()->getSkinName();
     $oasisToolbarService = new OasisToolbarService($skinName);
     $toolbarNameInUserOptions = $oasisToolbarService->getToolbarOptionName();
     $toolbarCurrentList = $user->getOption($oasisToolbarService->getToolbarOptionName());
     $storage[self::MY_TOOLBAR_OPTIONS_STORAGE_ARRAY_KEY_NAME] = array($toolbarNameInUserOptions => $toolbarCurrentList);
     return true;
 }