Example #1
0
 /**
  * Adds the user a new group from its name.
  *
  * @param string $name The group name
  * @param Doctrine_Connection $con A Doctrine_Connection object
  * @throws sfException
  */
 public function addGroupByName($name, $con = null)
 {
     $group = Doctrine_Core::getTable('sfGuardGroup')->findOneByName($name);
     if (!$group) {
         throw new sfException(sprintf('The group "%s" does not exist.', $name));
     }
     $ug = new sfGuardUserGroup();
     $ug->setUser($this);
     $ug->setGroup($group);
     $ug->save($con);
 }
 /**
  * Adds the user a new group from its name.
  *
  * @param string $name The group name
  * @param Doctrine_Connection $con A Doctrine_Connection object
  * @throws sfException
  */
 public function addGroupByName($name, $con = null)
 {
     $group = Doctrine_Core::getTable('sfGuardGroup')->findOneByName($name);
     if (!$group) {
         throw new sfException(sprintf('The group "%s" does not exist.', $name));
     }
     $ug = new sfGuardUserGroup();
     $ug->setUser($this);
     $ug->setGroup($group);
     $ug->save($con);
     // add group and permissions to local vars
     $this->_groups[$group->getName()] = $group;
     foreach ($group->getPermissions() as $permission) {
         $this->_allPermissions[$permission->getName()] = $permission;
     }
 }