public function run()
 {
     if ($this->Environment->method == 'GET') {
         return new colesoControllerExecResult($this->renderForm());
     }
     $errStatus = false;
     if ($this->Environment->method == 'POST') {
         if (!colesoToken::checkValid()) {
             throw new Exception('Invalid token');
         }
         try {
             $bookshelfData = $this->loadData($this->bookshelfFields);
             $bookData = $this->loadData($this->bookFields, array('title' => 'book_title'));
             if (!$bookshelfData['key']) {
                 throw new bookCreationException('You should assign keyword value');
             }
             $this->saveBookshelfPosition($bookshelfData);
             if ($bookshelfData['separator'] == '') {
                 $this->saveBook($bookData, $bookshelfData['key']);
             }
         } catch (bookCreationException $e) {
             $data = array('errMessage' => $e->getMessage());
             $data = array_merge($data, $bookshelfData);
             $bookData['book_title'] = $bookData['title'];
             unset($bookData['title']);
             $data = array_merge($data, $bookData);
             return new colesoControllerExecResult($this->renderForm($data));
         }
         return new colesoControllerRedirect('./');
     }
     throw new Exception('Invalid HTTP method');
 }
 public function tearDown()
 {
     colesoApplication::setEnvironment($this->savedEnvironment);
     colesoToken::testReset();
     if ($this->cachePath) {
         colesoApplication::setConfigVal('/system/cacheDir', $this->savedSystemCachePath);
     }
 }
 function executeSave()
 {
     if ($this->useToken) {
         if (!colesoToken::checkValid()) {
             throw new Exception('Invalid token');
         }
     }
     $content = $this->Environment->getPostVar('content');
     $this->savePageContent($content);
     return new colesoControllerRedirect($this->buildRedirectAfterSaveURL());
 }
Example #4
0
 function token()
 {
     $tokenFieldName = colesoToken::getTokenKey();
     $tokenValue = colesoToken::getToken();
     $out = "<input name='{$tokenFieldName}' type='hidden' value='{$tokenValue}'  />";
     return $out;
 }
Example #5
0
 static function testReset()
 {
     $myVoid =& colesoToken::getInstance('reset');
 }