/** *Returns all roles (groups) $user_id has, excepting current one $current_role * */ public static function retrieveForUserWithoutCurrentRole($current_role, $user_id) { $c = new Criteria(); $c->add(self::USER_ID, $user_id); $c->addJoin(self::GROUP_ID, sfGuardGroupPeer::ID); $c->add(sfGuardGroupPeer::NAME, $current_role, Criteria::NOT_EQUAL); return sfGuardGroupPeer::doSelect($c); }
public function executeJsonList(sfWebRequest $request) { $c = new Criteria(); $groups = sfGuardGroupPeer::doSelect($c); $elements = array(); foreach ($groups as $group) { $elements[] = $group->toArray(); } $return = array('data' => $elements); $result = json_encode($return); $this->getResponse()->setHttpHeader('Content-type', 'application/json'); return $this->renderText($result); }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(sfGuardGroupPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(sfGuardGroupPeer::DATABASE_NAME); $criteria->add(sfGuardGroupPeer::ID, $pks, Criteria::IN); $objs = sfGuardGroupPeer::doSelect($criteria, $con); } return $objs; }
<?php // TBB (tom@punkave.com): filters by group. $groups = sfGuardGroupPeer::doSelect(new Criteria()); $fgroups = isset($filters['groups']) ? $filters['groups'] : array(); ?> <span class="groups_filter"> <?php foreach ($groups as $group) { ?> <div class="groups_filter_group"> <?php echo checkbox_tag('filters[groups][]', $group->getId(), in_array($group->getId(), $fgroups)); ?> <span class="groups_filter_group_label"> <?php echo $group->getName(); ?> </span> </div> <?php } ?> </span>