public function addUserchapterregion(Userchapterregion $l) { $this->collUserchapterregions[] = $l; $l->setChapterregion($this); }
public function executeJoinchapter() { $userid = $this->getUser()->getAttribute('userid'); $rid = $this->getRequestParameter('region'); $cid = $this->getRequestParameter('chapter'); $c = new Criteria(); $c->add(ChapterregionPeer::REGION_ID, $rid); $c->add(ChapterregionPeer::CHAPTER_ID, $cid); $cr = ChapterregionPeer::doSelectOne($c); $c->clear(); $c->add(UserchapterregionPeer::CHAPTERREGION_ID, $cr->getId()); $c->add(UserchapterregionPeer::USER_ID, $userid); $ucr = UserchapterregionPeer::doSelectOne($c); if ($ucr) { $this->setFlash('notice', 'You are already a member of this chapter.'); } else { $ucr = new Userchapterregion(); $ucr->setUserId($userid); $ucr->setChapterregion($cr); $ucr->save(); $this->setFlash('notice', 'Chapter joined successfully.'); } $this->redirect('/address/show'); }