public function executeDeleteregion()
 {
     $regionid = $this->getRequestParameter('id');
     $c = new Criteria();
     $c->add(ChapterregionPeer::REGION_ID, $regionid);
     $chcount = ChapterregionPeer::doCount($c);
     $chapterregion = ChapterregionPeer::doSelectOne($c);
     if ($chapterregion) {
         $this->setFlash('notice', 'Region cannot be deleted. <b>' . $chcount . '</b> chapters belong to this region.');
     } else {
         $region = RegionPeer::retrieveByPK($regionid);
         $region->delete();
         $this->setFlash('notice', 'Region deleted Successfully.');
     }
     $this->redirect('admin/regions');
 }
Beispiel #2
0
 public function getChapterregion()
 {
     $c = new Criteria();
     $c->add(ChapterregionPeer::CHAPTER_ID, $this->id);
     return ChapterregionPeer::doSelectOne($c);
 }
	<?php 
foreach ($chapters as $chapter) {
    $i++;
    ?>
	<div class="<?php 
    if ($i % 2 == 0) {
        echo 'evenRow';
    } else {
        echo 'oddRow';
    }
    ?>
">
		<?php 
    $c = new Criteria();
    $c->add(ChapterregionPeer::CHAPTER_ID, $chapter->getId());
    $cr = ChapterregionPeer::doSelectOne($c);
    $c->clear();
    $c->add(UserchapterregionPeer::CHAPTERREGION_ID, $cr->getId());
    $ucount = UserchapterregionPeer::doCount($c);
    ?>
		<div class="statColC1"><?php 
    echo $chapter->getName();
    ?>
</div>
		<div class="statColC2"><?php 
    echo $cr->getRegion()->getName();
    ?>
</div>
		<div class="statColC3"><?php 
    echo link_to($ucount, 'search/result?usertype=1&chapter=' . $chapter->getId(), array('title' => 'Click here to see a list of users from ' . $chapter->getName()));
    ?>
 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');
 }