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'); }
public static function doSelectJoinAllExceptUser(Criteria $c, $con = null) { $c = clone $c; if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } UserchapterregionPeer::addSelectColumns($c); $startcol2 = UserchapterregionPeer::NUM_COLUMNS - UserchapterregionPeer::NUM_LAZY_LOAD_COLUMNS + 1; ChapterregionPeer::addSelectColumns($c); $startcol3 = $startcol2 + ChapterregionPeer::NUM_COLUMNS; $c->addJoin(UserchapterregionPeer::CHAPTERREGION_ID, ChapterregionPeer::ID); $rs = BasePeer::doSelect($c, $con); $results = array(); while ($rs->next()) { $omClass = UserchapterregionPeer::getOMClass(); $cls = Propel::import($omClass); $obj1 = new $cls(); $obj1->hydrate($rs); $omClass = ChapterregionPeer::getOMClass(); $cls = Propel::import($omClass); $obj2 = new $cls(); $obj2->hydrate($rs, $startcol2); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj2 = $temp_obj1->getChapterregion(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { $newObject = false; $temp_obj2->addUserchapterregion($obj1); break; } } if ($newObject) { $obj2->initUserchapterregions(); $obj2->addUserchapterregion($obj1); } $results[] = $obj1; } return $results; }
public static function retrieveByPKs($pks, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(); $criteria->add(ChapterregionPeer::ID, $pks, Criteria::IN); $objs = ChapterregionPeer::doSelect($criteria, $con); } return $objs; }
<?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 fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = ChapterregionPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setChapterId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setRegionId($arr[$keys[2]]); } }
public function getChapterregionsJoinRegion($criteria = null, $con = null) { include_once 'lib/model/om/BaseChapterregionPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collChapterregions === null) { if ($this->isNew()) { $this->collChapterregions = array(); } else { $criteria->add(ChapterregionPeer::CHAPTER_ID, $this->getId()); $this->collChapterregions = ChapterregionPeer::doSelectJoinRegion($criteria, $con); } } else { $criteria->add(ChapterregionPeer::CHAPTER_ID, $this->getId()); if (!isset($this->lastChapterregionCriteria) || !$this->lastChapterregionCriteria->equals($criteria)) { $this->collChapterregions = ChapterregionPeer::doSelectJoinRegion($criteria, $con); } } $this->lastChapterregionCriteria = $criteria; return $this->collChapterregions; }
public function getChapterregion() { $c = new Criteria(); $c->add(ChapterregionPeer::CHAPTER_ID, $this->id); return ChapterregionPeer::doSelectOne($c); }
public function getChapterregion($con = null) { include_once 'lib/model/om/BaseChapterregionPeer.php'; if ($this->aChapterregion === null && $this->chapterregion_id !== null) { $this->aChapterregion = ChapterregionPeer::retrieveByPK($this->chapterregion_id, $con); } return $this->aChapterregion; }
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'); }