/**
  * Show the special page
  *
  * @param $par Mixed: parameter passed to the page or null
  */
 public function execute($par)
 {
     global $wgUser, $wgOut, $wgRequest, $wgScriptPath, $wgUserGiftsScripts;
     $wgOut->setPageTitle(wfMsg('giftmanager'));
     if ($wgUser->isAnon() || !$this->canUserManage()) {
         throw new ErrorPageError('error', 'badaccess');
     }
     $wgOut->addStyle($wgUserGiftsScripts . '/UserGifts.css');
     if (count($_POST)) {
         if (!$_POST['id']) {
             $gift_id = Gifts::addGift($_POST['gift_name'], $_POST['gift_description'], $_POST['access']);
             $wgOut->addHTML('<span class="view-status">' . wfMsg('giftmanager-giftcreated') . '</span><br /><br />');
         } else {
             $gift_id = $_POST['id'];
             Gifts::updateGift($gift_id, $_POST['gift_name'], $_POST['gift_description'], $_POST['access']);
             $wgOut->addHTML('<span class="view-status">' . wfMsg('giftmanager-giftsaved') . '</span><br /><br />');
         }
         $wgOut->addHTML($this->displayForm($gift_id));
     } else {
         $gift_id = $wgRequest->getVal('id');
         if ($gift_id || $wgRequest->getVal('method') == 'edit') {
             $wgOut->addHTML($this->displayForm($gift_id));
         } else {
             if ($this->canUserCreateGift()) {
                 $wgOut->addHTML('<div><b><a href="' . $wgScriptPath . '/index.php?title=Special:GiftManager&amp;method=edit">' . wfMsg('giftmanager-addgift') . '</a></b></div>');
             }
             $wgOut->addHTML($this->displayGiftList());
         }
     }
 }
Пример #2
0
 /**
  * Show the special page
  *
  * @param $par Mixed: parameter passed to the page or null
  */
 public function execute($par)
 {
     $out = $this->getOutput();
     $request = $this->getRequest();
     $user = $this->getUser();
     // Set the page title, robot policies, etc.
     $this->setHeaders();
     $out->setPageTitle($this->msg('giftmanager')->plain());
     // Make sure that the user is logged in and that they can use this
     // special page
     if ($user->isAnon() || !$this->canUserManage()) {
         throw new ErrorPageError('error', 'badaccess');
     }
     // Show a message if the database is in read-only mode
     if (wfReadOnly()) {
         $out->readOnlyPage();
         return;
     }
     // Add CSS
     $out->addModuleStyles('ext.socialprofile.usergifts.css');
     if ($request->wasPosted()) {
         if (!$request->getInt('id')) {
             $giftId = Gifts::addGift($request->getVal('gift_name'), $request->getVal('gift_description'), $request->getInt('access'));
             $out->addHTML('<span class="view-status">' . $this->msg('giftmanager-giftcreated')->plain() . '</span><br /><br />');
         } else {
             $giftId = $request->getInt('id');
             Gifts::updateGift($giftId, $request->getVal('gift_name'), $request->getVal('gift_description'), $request->getInt('access'));
             $out->addHTML('<span class="view-status">' . $this->msg('giftmanager-giftsaved')->plain() . '</span><br /><br />');
         }
         $out->addHTML($this->displayForm($giftId));
     } else {
         $giftId = $request->getInt('id');
         if ($giftId || $request->getVal('method') == 'edit') {
             $out->addHTML($this->displayForm($giftId));
         } else {
             // If the user is allowed to create new gifts, show the
             // "add a gift" link to them
             if ($this->canUserCreateGift()) {
                 $out->addHTML('<div><b><a href="' . htmlspecialchars($this->getPageTitle()->getFullURL('method=edit')) . '">' . $this->msg('giftmanager-addgift')->plain() . '</a></b></div>');
             }
             $out->addHTML($this->displayGiftList());
         }
     }
 }
	/**
	 * Show the special page
	 *
	 * @param $par Mixed: parameter passed to the page or null
	 */
	public function execute( $par ) {
		global $wgUser, $wgOut, $wgRequest, $wgUserGiftsScripts;

		$wgOut->setPageTitle( wfMsg( 'giftmanager' ) );

		// Make sure that the user is logged in and that they can use this
		// special page
		if ( $wgUser->isAnon() || !$this->canUserManage() ) {
			throw new ErrorPageError( 'error', 'badaccess' );
		}

		// Show a message if the database is in read-only mode
		if ( wfReadOnly() ) {
			$wgOut->readOnlyPage();
			return;
		}

		// Add CSS
		$wgOut->addExtensionStyle( $wgUserGiftsScripts . '/UserGifts.css' );

		if ( $wgRequest->wasPosted() ) {
			if ( !$wgRequest->getInt( 'id' ) ) {
				$giftId = Gifts::addGift(
					$wgRequest->getVal( 'gift_name' ),
					$wgRequest->getVal( 'gift_description' ),
					$wgRequest->getInt( 'access' )
				);
				$wgOut->addHTML(
					'<span class="view-status">' .
					wfMsg( 'giftmanager-giftcreated' ) .
					'</span><br /><br />'
				);
			} else {
				$giftId = $wgRequest->getInt( 'id' );
				Gifts::updateGift(
					$giftId,
					$wgRequest->getVal( 'gift_name' ),
					$wgRequest->getVal( 'gift_description' ),
					$wgRequest->getInt( 'access' )
				);
				$wgOut->addHTML(
					'<span class="view-status">' .
					wfMsg( 'giftmanager-giftsaved' ) .
					'</span><br /><br />'
				);
			}

			$wgOut->addHTML( $this->displayForm( $giftId ) );
		} else {
			$giftId = $wgRequest->getInt( 'id' );
			if ( $giftId || $wgRequest->getVal( 'method' ) == 'edit' ) {
				$wgOut->addHTML( $this->displayForm( $giftId ) );
			} else {
				// If the user is allowed to create new gifts, show the
				// "add a gift" link to them
				if ( $this->canUserCreateGift() ) {
					$wgOut->addHTML(
						'<div><b><a href="' .
						$this->getTitle()->escapeFullURL( 'method=edit' ) .
						'">' . wfMsg( 'giftmanager-addgift' ) .
						'</a></b></div>'
					);
				}
				$wgOut->addHTML( $this->displayGiftList() );
			}
		}
	}