Esempio n. 1
0
 public function getAgentCount($userID)
 {
     $criteria = new Criteria();
     $criteria->add(AgentHasUserPeer::USER_ID, $userID);
     $AgentCount = AgentHasUserPeer::doCount($criteria);
     return $AgentCount;
 }
Esempio n. 2
0
 public function getMyAgentId()
 {
     //
     $userId = sfContext::getInstance()->getUser()->getSubscriberId();
     $criteria = new Criteria();
     $criteria->add(VocabularyHasUserPeer::USER_ID, $userId);
     $userAgents = AgentHasUserPeer::doSelectJoinAgent($criteria);
     foreach ($userAgents as $agent) {
         $agents[] = $agent->getAgent();
     }
     return $agents;
 }
Esempio n. 3
0
     if (!isset($agent)) {
         $id = 'show' == $action ? $sf_params->get('id') : $paramId;
         if ($id) {
             $agent = AgentPeer::retrieveByPK($id);
         }
     }
     $objectId = $agent ? $agent->getID() : "";
     break;
 case 'agentuser':
     $showBc = true;
     $showAgentBc = true;
     $showAgentUserBc = true;
     if (!isset($agent_has_user)) {
         $id = 'show' == $action ? $sf_params->get('id') : $paramId;
         if ($id) {
             $agent_has_user = AgentHasUserPeer::retrieveByPK($id);
         }
     }
     $objectId = $agent_has_user->getID();
     if (!isset($agent)) {
         $agent = $agent_has_user->getAgent();
     }
     $tab = false;
     break;
 case 'vocabulary':
     $showBc = true;
     $showVocabularyBc = true;
     if ('import' == $filter) {
         $import = FileImportHistoryPeer::retrieveByPK($paramId);
         if ($import) {
             $id = $import->getSchemaId();
Esempio n. 4
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this Agent is new, it will return
  * an empty collection; or if this Agent has previously
  * been saved, it will retrieve related AgentHasUsers from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in Agent.
  */
 public function getAgentHasUsersJoinUser($criteria = null, $con = null)
 {
     // include the Peer class
     include_once 'lib/model/om/BaseAgentHasUserPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collAgentHasUsers === null) {
         if ($this->isNew()) {
             $this->collAgentHasUsers = array();
         } else {
             $criteria->add(AgentHasUserPeer::AGENT_ID, $this->getId());
             $this->collAgentHasUsers = AgentHasUserPeer::doSelectJoinUser($criteria, $con);
         }
     } else {
         // the following code is to determine if a new query is
         // called for.  If the criteria is the same as the last
         // one, just return the collection.
         $criteria->add(AgentHasUserPeer::AGENT_ID, $this->getId());
         if (!isset($this->lastAgentHasUserCriteria) || !$this->lastAgentHasUserCriteria->equals($criteria)) {
             $this->collAgentHasUsers = AgentHasUserPeer::doSelectJoinUser($criteria, $con);
         }
     }
     $this->lastAgentHasUserCriteria = $criteria;
     return $this->collAgentHasUsers;
 }
 public function getAgentCredentials($agentId = false)
 {
     //$agentId = sfContext::getInstance()->getRequest()->getParameter('id');
     if ($this->isAuthenticated()) {
         if ($agentId) {
             //make sure we've revoked the credentials -- we revoke, then set them every time the agent is accessed
             $this->removeCredential('agentcontact');
             $this->removeCredential('agentregistrar');
             $this->removeCredential('agentadmin');
             $agentContact = AgentHasUserPeer::retrieveByPK($agentId, $this->getSubscriberId());
             if (isset($agentContact)) {
                 $this->addCredential('agentcontact');
                 if ($agentContact->getIsRegistrarFor()) {
                     $this->addCredential('agentregistrar');
                 }
                 if ($agentContact->getIsAdminFor()) {
                     $this->addCredential('agentadmin');
                 }
             }
         } elseif ('create' == sfContext::getInstance()->getRequest()->getParameter('action')) {
             $this->addCredential('agentcontact');
             $this->addCredential('agentregistrar');
             $this->addCredential('agentadmin');
         }
     }
     return;
 }
Esempio n. 6
0
 /**
  * gets an array of User objects NOT related to the current agent
  *
  * The user group is defined by removing users already related to the supplied agentId
  *
  * @param Agent $agent The current agent
  * @return array An array of User objects
  */
 public static function getNewUsersForAgent($criteria)
 {
     $con = Propel::getConnection(self::DATABASE_NAME);
     $agent = sfContext::getInstance()->getUser()->getAttribute('agent', '');
     if ($agent) {
         $agentId = $agent->getId();
     }
     /**
     * @todo speed this up by making an array of current users and passing that to the query a 'not in array[]'
     **/
     //get the current user list for this agent
     $c = new Criteria();
     $c->add(AgentHasUserPeer::AGENT_ID, $agent->getId());
     $curUsers = AgentHasUserPeer::doSelect($c);
     $c = new Criteria();
     $c->addAscendingOrderByColumn(self::NICKNAME);
     $newUsers = UserPeer::doSelect($c);
     foreach ($curUsers as $curUser) {
         $curId = $curUser->getUserId();
         foreach ($newUsers as $key => $newUser) {
             if ($newUser->getId() == $curId) {
                 unset($newUsers[$key]);
                 break;
             }
         }
     }
     //make sure the array is contiguous
     $newUsers = array_merge($newUsers);
     return $newUsers;
 }
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      Connection $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(AgentHasUserPeer::ID, $pks, Criteria::IN);
         $objs = AgentHasUserPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
  * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = AgentHasUserPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setCreatedAt($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setUpdatedAt($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setDeletedAt($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setUserId($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setAgentId($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setIsRegistrarFor($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setIsAdminFor($arr[$keys[7]]);
     }
 }