/**
  * Update a chapter
  * @param $args array
  * @param $request PKPRequest
  * @return JSONMessage JSON object
  */
 function updateChapter($args, $request)
 {
     // Identify the chapter to be updated
     $chapter = $this->_getChapterFromRequest($request);
     // Form initialization
     import('controllers.grid.users.chapter.form.ChapterForm');
     $chapterForm = new ChapterForm($this->getMonograph(), $chapter);
     $chapterForm->readInputData();
     // Form validation
     if ($chapterForm->validate()) {
         $chapterForm->execute($request);
         $newChapter = $chapterForm->getChapter();
         return DAO::getDataChangedEvent($newChapter->getId());
     } else {
         // Return an error
         return new JSONMessage(false);
     }
 }
Esempio n. 2
0
 /**
  * Update a chapter
  * @param $args array
  * @param $request PKPRequest
  * @return string Serialized JSON object
  */
 function updateChapter($args, &$request)
 {
     // Identify the chapter to be updated
     $chapterId = $request->getUserVar('chapterId');
     // Form initialization
     import('controllers.grid.users.chapter.form.ChapterForm');
     $chapterForm = new ChapterForm($this->getMonograph(), $chapterId);
     $chapterForm->readInputData();
     // Form validation
     if ($chapterForm->validate()) {
         $chapterForm->execute();
         $chapter =& $chapterForm->getChapter();
         // Prepare the grid row data
         $categoryRow =& $this->getCategoryRowInstance();
         $categoryRow->setGridId($this->getId());
         $categoryRow->setId($chapter->getId());
         $categoryRow->setData($chapter);
         $categoryRow->initialize($request);
         // Render the row into a JSON response
         $chapterAuthorDao =& DAORegistry::getDAO('ChapterAuthorDAO');
         $monograph =& $this->getMonograph();
         $authors =& $chapterAuthorDao->getAuthors($monograph->getId(), $chapter->getId());
         $groupIterator = $chapter->getId() % 5;
         $json = new JSON(true, $this->_renderCategoryInternally($request, $categoryRow, $groupIterator));
     } else {
         // Return an error
         $json = new JSON(false);
     }
     // Return the serialized JSON response
     return $json->getString();
 }