Exemplo n.º 1
0
 public function execute($par)
 {
     $this->setHeaders();
     // sets robotPolicy = "noindex,nofollow" + set page title
     $user = $this->getUser();
     $output = $this->getOutput();
     $request = $this->getRequest();
     // Check rights and block if necessary
     if (!$this->userCanExecute($user)) {
         // If anon, redirect to login
         if ($user->isAnon()) {
             $output->redirect($this->getTitleFor('UserLogin')->getLocalURL(array('returnto' => $this->getFullTitle())), '401');
             return;
         }
         // Else display an error page.
         $this->displayRestrictionError();
         return;
     }
     if (isset($par) && $par != '') {
         $explosion = explode(':', $par);
         if (count($explosion) == 1) {
             $this->action = $explosion[0];
             $this->category_id = $this->getRequest()->getText('category', null);
         } else {
             if (count($explosion) == 2) {
                 $this->action = $explosion[0];
                 $this->category_id = $explosion[1];
             }
         }
     } else {
         $this->action = $this->getRequest()->getText('action', null);
         $this->category_id = $this->getRequest()->getText('category', null);
     }
     if ($user->isAllowed(WP_ADMIN_RIGHT)) {
         $this->userIsAdmin = true;
         $this->userInvitationsCategories = WpInvitationCategory::factoryAllAvailable(true);
         // with admin categories
     } else {
         $this->userIsAdmin = false;
         $this->userActiveSubscription = WpSubscription::newActiveByUserId($user->getId());
         $this->userInvitationsCategories = WpInvitationCategory::factoryAllAvailable(false);
         // without admin categories
         $this->setUsageThisMonth();
         $this->setUsageLeftThisMonth();
     }
     $this->msgType = $request->getText('msgtype', null);
     $msgKey = $request->getText('msgkey', null);
     if ($msgKey != null) {
         $msg = wfMessage($msgKey);
         if ($msg->exists()) {
             $this->msg = $msg;
         }
     }
     $this->display();
 }
Exemplo n.º 2
0
 /**
  * For title in wikiplace namespace, checks if the current user can move it
  * @param Title $title Title in a wikiplace namespace
  * @param User $user Logged in user
  * @return array Empty array = can, array containing i18n key + args = cannot 
  */
 private static function wikiplaceUserCanMove(&$title, &$user)
 {
     $back = array();
     if (WpPage::isHomepage($title)) {
         $back[] = 'badarticleerror';
     } elseif ($user->isAllowed(WP_ADMIN_RIGHT)) {
         // ok
     } elseif (WpSubscription::newActiveByUserId($user->getId()) == null) {
         $back[] = 'wp-no-active-sub';
     } elseif (!WpPage::isOwner($title->getArticleID(), $user)) {
         $back[] = 'wp-not-owner';
     }
     return $back;
 }
Exemplo n.º 3
0
 public function processRenew($formData)
 {
     if (!isset($formData['Plan'])) {
         //check the key exists and value is not NULL
         throw new MWException('Cannot set next plan, no data.');
     }
     $sub = WpSubscription::newActiveByUserId($this->getUser()->getId());
     if ($sub == null) {
         throw new MWException('Cannot set next plan, no active subscription.');
     }
     $sub->setRenewalPlanId(intval($formData['Plan']));
     return true;
 }
Exemplo n.º 4
0
 private function displayOffers()
 {
     # block_join
     $html = Xml::openElement('div', array('class' => 'block block_join'));
     if (is_null(WpSubscription::newActiveByUserId($this->getUser()->getId()))) {
         $blockjoin = array('sz-blockjoin0', 'sz-blockjoin1', 'sz-blockjoin2');
     } else {
         $blockjoin = array('sz-blockjoin0b', 'sz-blockjoin1', 'sz-blockjoin2');
     }
     foreach ($blockjoin as $box) {
         $html .= Xml::openElement('a', array('class' => 'fade', 'href' => wfMessage($box . '-href')->text()));
         $html .= Xml::element('span', array(), wfMessage($box)->text());
         $html .= Html::rawElement('small', array(), wfMessage($box . '-catch')->parse());
         $html .= Xml::closeElement('a');
     }
     # /block_join
     $html .= Xml::closeElement('div');
     return $html;
 }