Beispiel #1
0
 /**
  * Check a MODX return result for a success flag
  *
  * @param modProcessorResponse $result The result response
  * @return boolean
  */
 public function checkForSuccess(&$result)
 {
     if (empty($result) || !$result instanceof modProcessorResponse) {
         return false;
     }
     return !$result->isError();
 }
Beispiel #2
0
 /**
  * More convenient error messages
  *
  * @param modProcessorResponse $response
  * @param string $glue
  *
  * @return string
  */
 public function formatProcessorErrors(modProcessorResponse $response, $glue = 'br')
 {
     $errormsgs = array();
     if ($response->hasMessage()) {
         $errormsgs[] = $response->getMessage();
     }
     if ($response->hasFieldErrors()) {
         if ($errors = $response->getFieldErrors()) {
             foreach ($errors as $error) {
                 $errormsgs[] = $error->message;
             }
         }
     }
     return implode($glue, $errormsgs);
 }
Beispiel #3
0
 /**
  * Redirect the user after they logout
  * 
  * @param modProcessorResponse $response
  * @return void
  */
 public function redirectAfterLogout(modProcessorResponse $response)
 {
     $responseArray = $response->getObject();
     /* redirect */
     $logoutResourceId = $this->getProperty('logoutResourceId', 0);
     if (!empty($responseArray) && !empty($responseArray['url'])) {
         $this->modx->sendRedirect($responseArray['url']);
     } elseif (!empty($logoutResourceId)) {
         $logoutResourceParams = $this->getProperty('logoutResourceParams', '');
         if (!empty($logoutResourceParams)) {
             $logoutResourceParams = $this->modx->fromJSON($logoutResourceParams);
         }
         $url = $this->modx->makeUrl($logoutResourceId, '', $logoutResourceParams, 'full');
         $this->modx->sendRedirect($url);
     } else {
         $this->modx->sendRedirect($_SERVER['REQUEST_URI']);
     }
 }