예제 #1
0
 /**
  * @see	\wcf\action\IAction::readParameters()
  */
 public function readParameters()
 {
     if (!MODULE_POLL) {
         throw new IllegalLinkException();
     }
     AbstractSecureAction::readParameters();
     if (isset($_POST['actionName'])) {
         $this->actionName = StringUtil::trim($_POST['actionName']);
     }
     if (isset($_POST['pollID'])) {
         $this->pollID = intval($_POST['pollID']);
     }
     $polls = PollManager::getInstance()->getPolls(array($this->pollID));
     if (!isset($polls[$this->pollID])) {
         throw new UserInputException('pollID');
     }
     $this->poll = $polls[$this->pollID];
     // load related object
     $this->relatedObject = PollManager::getInstance()->getRelatedObject($this->poll);
     if ($this->relatedObject === null) {
         if ($this->poll->objectID) {
             throw new SystemException("Missing related object for poll id '" . $this->poll->pollID . "'");
         }
     } else {
         $this->poll->setRelatedObject($this->relatedObject);
     }
     // validate action
     switch ($this->actionName) {
         case 'getResult':
             if (!$this->poll->canSeeResult()) {
                 throw new PermissionDeniedException();
             }
             break;
         case 'getVote':
         case 'vote':
             if (!$this->poll->canVote()) {
                 throw new PermissionDeniedException();
             }
             break;
         default:
             throw new SystemException("Unknown action '" . $this->actionName . "'");
             break;
     }
     if (isset($_POST['optionIDs']) && is_array($_POST['optionIDs'])) {
         $this->optionIDs = ArrayUtil::toIntegerArray($_POST['optionIDs']);
         if (count($this->optionIDs) > $this->poll->maxVotes) {
             throw new PermissionDeniedException();
         }
         $optionIDs = array();
         foreach ($this->poll->getOptions() as $option) {
             $optionIDs[] = $option->optionID;
         }
         foreach ($this->optionIDs as $optionID) {
             if (!in_array($optionID, $optionIDs)) {
                 throw new PermissionDeniedException();
             }
         }
     }
 }
예제 #2
0
 /**
  * @see	\wcf\action\IAction::execute()
  */
 public function execute()
 {
     parent::execute();
     // do logout
     WCF::getSession()->delete();
     $this->executed();
     // forward to index page
     // warning: if doLogout() writes a cookie this is buggy in MS IIS
     HeaderUtil::redirect(LinkHandler::getInstance()->getLink('Login'));
     exit;
 }
예제 #3
0
	/**
	 * @see	wcf\action\Action::execute()
	 */
	public function execute() {
		AbstractSecureAction::execute();
		
		// execute clipboard action
		$this->executeAction();
		
		// get editor items
		$returnValues = $this->getEditorItems();
		// send JSON response
		header('Content-type: application/json');
		echo JSON::encode($returnValues);
		exit;
	}
 /**
  * @see	\wcf\action\IAction::execute()
  */
 public final function execute()
 {
     parent::execute();
     $methodName = 'step' . StringUtil::firstCharToUpperCase($this->step);
     if (!method_exists($this, $methodName)) {
         throw new AJAXException("Class '" . get_class($this) . "' does not implement the required method '" . $methodName . "'");
     }
     // execute step
     $this->{$methodName}();
     $this->executed();
     // send JSON-encoded response
     header('Content-type: application/json');
     echo JSON::encode($this->data);
     exit;
 }
예제 #5
0
 /**
  * @see wcf\action\IAction::execute()
  */
 public function execute()
 {
     parent::execute();
     // validate
     if (!WCF::getUser()->userID) {
         throw new IllegalLinkException();
     }
     // do logout
     WCF::getSession()->delete();
     $this->executed();
     // forward to index page
     // warning: if doLogout() writes a cookie this is buggy in MS IIS
     HeaderUtil::redirect('index.php' . SID_ARG_1ST);
     exit;
 }
예제 #6
0
 /**
  * @see	\wcf\action\IAction::execute()
  */
 public function execute()
 {
     AbstractSecureAction::execute();
     // do logout
     WCF::getSession()->delete();
     // remove cookies
     if (isset($_COOKIE[COOKIE_PREFIX . 'userID'])) {
         HeaderUtil::setCookie('userID', 0);
     }
     if (isset($_COOKIE[COOKIE_PREFIX . 'password'])) {
         HeaderUtil::setCookie('password', '');
     }
     $this->executed();
     // forward to index page
     HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink(), WCF::getLanguage()->get('wcf.user.logout.redirect'));
     exit;
 }
예제 #7
0
 /**
  * @see	\wcf\action\IAction::execute()
  */
 public function execute()
 {
     AbstractSecureAction::execute();
     if ($this->loopCount == -1) {
         $this->sendResponse();
     }
     // init worker
     $this->worker = new $this->className($this->parameters);
     $this->worker->setLoopCount($this->loopCount);
     // validate worker parameters
     $this->worker->validate();
     // calculate progress, triggers countObjects()
     $progress = $this->worker->getProgress();
     // execute worker
     $this->worker->execute();
     $this->worker->finalize();
     // send current state
     $this->sendResponse($progress, $this->worker->getParameters(), $this->worker->getProceedURL());
 }
예제 #8
0
 /**
  * @see	\wcf\action\IAction::readParameters()
  */
 public function readParameters()
 {
     AbstractSecureAction::readParameters();
     if (isset($_POST['actionName'])) {
         $this->actionName = StringUtil::trim($_POST['actionName']);
     }
     if (isset($_POST['getFullQuoteObjectIDs'])) {
         $this->_getFullQuoteObjectIDs = intval($_POST['getFullQuoteObjectIDs']);
     }
     if (isset($_POST['objectTypes']) && is_array($_POST['objectTypes'])) {
         $this->objectTypes = ArrayUtil::trim($_POST['objectTypes']);
     }
     if (isset($_POST['quoteIDs'])) {
         $this->quoteIDs = ArrayUtil::trim($_POST['quoteIDs']);
         // validate quote ids
         foreach ($this->quoteIDs as $key => $quoteID) {
             if (MessageQuoteManager::getInstance()->getQuote($quoteID) === null) {
                 unset($this->quoteIDs[$key]);
             }
         }
     }
 }
예제 #9
0
 /**
  * @see	wcf\action\IAction::execute()
  */
 public function execute()
 {
     parent::execute();
     // validate class name
     if (!class_exists($this->className)) {
         throw new SystemException("unknown class '" . $this->className . "'");
     }
     if (!ClassUtil::isInstanceOf($this->className, 'wcf\\data\\IDatabaseObjectAction')) {
         throw new SystemException("'" . $this->className . "' should implement wcf\\system\\IDatabaseObjectAction");
     }
     // create object action instance
     $this->objectAction = new $this->className($this->objectIDs, $this->actionName, $this->parameters);
     // validate action
     try {
         $this->objectAction->validateAction();
     } catch (UserInputException $e) {
         $this->throwException($e);
     } catch (ValidateActionException $e) {
         $this->throwException($e);
     }
     // execute action
     try {
         $this->response = $this->objectAction->executeAction();
     } catch (\Exception $e) {
         $this->throwException($e);
     }
     $this->executed();
     // send JSON-encoded response
     header('Content-type: application/json');
     echo JSON::encode($this->response);
     exit;
 }
예제 #10
0
	/**
	 * @see	wcf\action\IAction::execute()
	 */
	public function execute() {
		parent::execute();
		
		// execute action
		try {
			$this->invoke();
		}
		catch (\Exception $e) {
			$this->throwException($e);
		}
		$this->executed();
		
		// send JSON-encoded response
		if (!$this->inDebugMode) {
			$this->sendResponse();
		}
	}
예제 #11
0
 /**
  * @see	wcf\action\IAction::execute()
  */
 public function execute()
 {
     parent::execute();
     // get object ids
     $objectIDs = $this->getObjectIDs();
     // create object action instance
     $this->objectAction = new $this->parameters['className']($objectIDs, $this->parameters['actionName']);
     // validate action
     try {
         $this->objectAction->validateAction();
     } catch (ValidateActionException $e) {
         throw new AJAXException("validation failed: " . $e->getMessage());
     }
     // execute action
     try {
         $this->response = $this->objectAction->executeAction();
     } catch (\Exception $e) {
         throw new AJAXException('unknown exception caught: ' . $e->getMessage());
     }
     $this->executed();
     // send JSON-encoded response
     header('Content-type: application/json');
     echo JSON::encode($this->response);
     exit;
 }