Пример #1
0
 public function save($con = null)
 {
     $con = Propel::getConnection();
     try {
         $con->begin();
         $ret = parent::save($con);
         // update agent_has_user table
         $userId = sfContext::getInstance()->getUser()->getSubscriberId();
         $agentId = $this->getId();
         $mode = sfContext::getInstance()->getRequest()->getParameter('action');
         //see if there's already an entry in the table and if not, add it
         $criteria = new Criteria();
         $criteria->add(AgentHasUserPeer::USER_ID, $userId);
         $AgentHasUsersColl = $this->getAgentHasUsers($criteria, $con);
         if (!count($AgentHasUsersColl)) {
             $agentUser = new AgentHasUser();
             $agentUser->setAgentId($agentId);
             $agentUser->setUserId($userId);
             $agentUser->save($con);
         }
         $con->commit();
         sfContext::getInstance()->getUser()->setHasAgents();
         return $ret;
     } catch (Exception $e) {
         $con->rollback();
         throw $e;
     }
 }
Пример #2
0
 /**
  * Returns a peer instance associated with this om.
  *
  * Since Peer classes are not to have any instance attributes, this method returns the
  * same instance for all member of this class. The method could therefore
  * be static, but this would prevent one from overriding the behavior.
  *
  * @return     AgentPeer
  */
 public function getPeer()
 {
     if (self::$peer === null) {
         self::$peer = new AgentPeer();
     }
     return self::$peer;
 }