/** * Get the associated sfGuardGroup object * * @param PropelPDO Optional Connection object. * @return sfGuardGroup The associated sfGuardGroup object. * @throws PropelException */ public function getsfGuardGroup(PropelPDO $con = null) { if ($this->asfGuardGroup === null && $this->group_id !== null) { $c = new Criteria(sfGuardGroupPeer::DATABASE_NAME); $c->add(sfGuardGroupPeer::ID, $this->group_id); $this->asfGuardGroup = sfGuardGroupPeer::doSelectOne($c, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->asfGuardGroup->addsfGuardUserGroups($this); */ } return $this->asfGuardGroup; }
/** * Chooses a role from the groups the user is in, right after the last one logs in. * */ public function loginRole() { $c = new Criteria(); $c->add(sfGuardUserGroupPeer::USER_ID, $this->getGuardUser()->getId(), Criteria::EQUAL); $c->addJoin(sfGuardGroupPeer::ID, sfGuardUserGroupPeer::GROUP_ID); $role = sfGuardGroupPeer::doSelectOne($c); if ($role) { if ($this->isPreceptor()) { $this->setLoginRole('Preceptor'); } else { $this->setLoginRole($role->getName()); } } }