public function executeDeletechapter() { $chapter = ChapterPeer::retrieveByPK($this->getRequestParameter('id')); $cr = $chapter->getChapterregion(); $c = new Criteria(); $c->add(UserchapterregionPeer::CHAPTERREGION_ID, $cr->getId()); $ucount = UserchapterregionPeer::doCount($c); $ucr = UserchapterregionPeer::doSelectOne($c); if ($ucr) { $this->setFlash('notice', 'Cannot delete chapter. <b>' . $ucount . '</b> user(s) are subscribed to this chapter.'); } else { $chapter->delete(); $cr->delete(); $this->setFlash('notice', 'Chapter Deleted Successfully'); } $this->redirect('admin/chapters'); }
public function executeUnjoinchapter() { $userid = $this->getUser()->getAttribute('userid'); $crid = $this->getRequestParameter('crid'); $c = new Criteria(); $c->add(UserchapterregionPeer::USER_ID, $userid); $c->add(UserchapterregionPeer::CHAPTERREGION_ID, $crid); $ucr = UserchapterregionPeer::doSelectOne($c); if ($ucr) { $ucr->delete(); } $this->redirect('/address/show'); }