Esempio n. 1
0
 public function executeAddchapter()
 {
     $c = new Criteria();
     $c->add(ChapterPeer::NAME, $this->getRequestParameter('chapter'));
     $exchapter = ChapterPeer::doSelectOne($c);
     if ($exchapter) {
         $this->setFlash('notice', 'Chapter could not be added. A chapter with this name already exists.');
     } else {
         $chapter = new Chapter();
         $chapter->setName($this->getRequestParameter('chapter'));
         $chapter->save();
         $cr = new Chapterregion();
         $cr->setChapterId($chapter->getId());
         $cr->setRegionId($this->getRequestParameter('region'));
         $cr->save();
         $this->setFlash('notice', 'Chapter <b>' . $chapter->getName() . '</b> has been created successfully.');
     }
     $this->redirect('admin/chapters');
 }