public function setDefaultGroup() { $con = Propel::getConnection(sfGuardGroupPeer::DATABASE_NAME); $criteria = new Criteria(); $criteria->add(self::NAME, 'Admin'); $group = self::doSelectOne($criteria); $new = false; if (!$group) { $group = new sfGuardGroup(); $new = true; } $group->setName('Admin'); $group->setDescription('Admin Group'); if ($new) { $group->save(); } $selectCriteria = $group->buildPkeyCriteria(); // update values are also stored in Criteria object $group->setId(self::DEFAULT_GROUP_ID); $updateValues = $group->buildCriteria(); BasePeer::doUpdate($selectCriteria, $updateValues, $con); return $group; }
/** * Создать sfGuardGroupPermission */ public function makeGuardGroupPermission(sfGuardGroup $group, sfGuardPermission $permission, $save = false, array $props = array()) { $defaultProps = array('group_id' => $group->getId(), 'permission_id' => $permission->getId()); $props = array_merge($defaultProps, $props); return $this->makeModel('sfGuardGroupPermission', $props, $save); }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param sfGuardGroup $value A sfGuardGroup object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(sfGuardGroup $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
/** * Declares an association between this object and a sfGuardGroup object. * * @param sfGuardGroup $v * @return sfGuardUserGroup The current object (for fluent API support) * @throws PropelException */ public function setsfGuardGroup(sfGuardGroup $v = null) { if ($v === null) { $this->setGroupId(NULL); } else { $this->setGroupId($v->getId()); } $this->asfGuardGroup = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the sfGuardGroup object, it will not be re-added. if ($v !== null) { $v->addsfGuardUserGroup($this); } return $this; }
/** * Exclude object from result * * @param sfGuardGroup $sfGuardGroup Object to remove from the list of results * * @return sfGuardGroupQuery The current query, for fluid interface */ public function prune($sfGuardGroup = null) { if ($sfGuardGroup) { $this->addUsingAlias(sfGuardGroupPeer::ID, $sfGuardGroup->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * Filter the query by a related sfGuardGroup object * * @param sfGuardGroup|PropelObjectCollection $sfGuardGroup The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return sfGuardUserGroupQuery The current query, for fluid interface * @throws PropelException - if the provided filter is invalid. */ public function filterBysfGuardGroup($sfGuardGroup, $comparison = null) { if ($sfGuardGroup instanceof sfGuardGroup) { return $this->addUsingAlias(sfGuardUserGroupPeer::GROUP_ID, $sfGuardGroup->getId(), $comparison); } elseif ($sfGuardGroup instanceof PropelObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(sfGuardUserGroupPeer::GROUP_ID, $sfGuardGroup->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterBysfGuardGroup() only accepts arguments of type sfGuardGroup or PropelCollection'); } }
public function createProjectGroup($name, $description) { // TODO: make sure group name does not already exist if (sfGuardGroupPeer::retrieveByName($this->getUuid() . '-' . $name) != null) { return true; } $group = new sfGuardGroup(); $group->setName($this->getUuid() . '-' . $name); $group->setDescription($description); //$group->setDescription(); $group->save(); }
<?php $app = 'sympal'; require_once dirname(__FILE__) . '/../bootstrap/unit.php'; $t = new lime_test(9, new lime_output_color()); $user = sfContext::getInstance()->getUser(); $content = Doctrine_Core::getTable('sfSympalContent')->getTypeQuery('sfSympalPage')->andWhere('c.slug = ?', 'home')->fetchOne(); $t->is($user->hasAccessToViewContent($content), true); $group = new sfGuardGroup(); $group->name = 'SpecialGroup'; $group->save(); $content->Groups[] = $group; $content->save(); $admin = Doctrine_Core::getTable(sfSympalConfig::get('user_model'))->findOneByIsSuperAdmin(1); $user->signIn($admin); $t->is($user->hasAccessToViewContent($content), true); $t->is($user->isEditMode(), true); $t->is($user->isSuperAdmin(), true); $t->is($user->isAnonymous(), false); $t->is($user->hasCredential('BlahSomethingFake'), true); $t->is($user->getGuardUser()->id, $admin->id); $t->is((string) $user, 'Sympal Admin (admin)'); $t->is($user->checkPassword('admin'), true);
/** * Filter the query by a related sfGuardGroup object * * @param sfGuardGroup $sfGuardGroup the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return sfGuardGroupPermissionQuery The current query, for fluid interface */ public function filterBysfGuardGroup($sfGuardGroup, $comparison = null) { return $this->addUsingAlias(sfGuardGroupPermissionPeer::GROUP_ID, $sfGuardGroup->getId(), $comparison); }