/** * gets an array of Agent objects related to a user * * @return Agent */ public static function getAgentsForCurrentUser() { $isAdmin = sfContext::getInstance()->getUser()->hasCredential(array(0 => 'administrator')); $c = new Criteria(); if (!$isAdmin) { $userId = sfContext::getInstance()->getUser()->getSubscriberId(); $c->addJoin(AgentHasUserPeer::AGENT_ID, AgentPeer::ID); $c->add(AgentHasUserPeer::USER_ID, $userId); } $c->addAscendingOrderByColumn(AgentPeer::ORG_NAME); $result = AgentPeer::doSelect($c); return $result; }
/** * gets a list of all agents related to all schemas * * @return array Agents * @param var_type $var */ public static function getSchemaAgents() { $results = array(); $c = new Criteria(); $c->clearSelectColumns(); $c->addSelectColumn(self::AGENT_ID); $c->addJoin(self::AGENT_ID, AgentPeer::ID); $c->addAscendingOrderByColumn(AgentPeer::ORG_NAME); $c->setDistinct(); $rs = self::doSelectRS($c); while ($rs->next()) { $results[] = AgentPeer::retrieveByPK($rs->getInt(1)); } return $results; }
/** * 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(AgentPeer::ID, $pks, Criteria::IN); $objs = AgentPeer::doSelect($criteria, $con); } return $objs; }
/** * Selects a collection of Profile objects pre-filled with all related objects except Status. * * @return array Array of Profile objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptStatus(Criteria $c, $con = null) { $c = clone $c; // Set the correct dbName if it has not been overridden // $c->getDbName() will return the same object if not set to another value // so == check is okay and faster if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } ProfilePeer::addSelectColumns($c); $startcol2 = ProfilePeer::NUM_COLUMNS - ProfilePeer::NUM_LAZY_LOAD_COLUMNS + 1; AgentPeer::addSelectColumns($c); $startcol3 = $startcol2 + AgentPeer::NUM_COLUMNS; UserPeer::addSelectColumns($c); $startcol4 = $startcol3 + UserPeer::NUM_COLUMNS; UserPeer::addSelectColumns($c); $startcol5 = $startcol4 + UserPeer::NUM_COLUMNS; UserPeer::addSelectColumns($c); $startcol6 = $startcol5 + UserPeer::NUM_COLUMNS; UserPeer::addSelectColumns($c); $startcol7 = $startcol6 + UserPeer::NUM_COLUMNS; $c->addJoin(ProfilePeer::AGENT_ID, AgentPeer::ID); $c->addJoin(ProfilePeer::CREATED_BY, UserPeer::ID); $c->addJoin(ProfilePeer::UPDATED_BY, UserPeer::ID); $c->addJoin(ProfilePeer::DELETED_BY, UserPeer::ID); $c->addJoin(ProfilePeer::CHILD_UPDATED_BY, UserPeer::ID); $rs = BasePeer::doSelect($c, $con); $results = array(); while ($rs->next()) { $omClass = ProfilePeer::getOMClass(); $cls = Propel::import($omClass); $obj1 = new $cls(); $obj1->hydrate($rs); $omClass = AgentPeer::getOMClass(); $cls = Propel::import($omClass); $obj2 = new $cls(); $obj2->hydrate($rs, $startcol2); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj2 = $temp_obj1->getAgent(); //CHECKME if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { $newObject = false; $temp_obj2->addProfile($obj1); break; } } if ($newObject) { $obj2->initProfiles(); $obj2->addProfile($obj1); } $omClass = UserPeer::getOMClass(); $cls = Propel::import($omClass); $obj3 = new $cls(); $obj3->hydrate($rs, $startcol3); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj3 = $temp_obj1->getUserRelatedByCreatedBy(); //CHECKME if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) { $newObject = false; $temp_obj3->addProfileRelatedByCreatedBy($obj1); break; } } if ($newObject) { $obj3->initProfilesRelatedByCreatedBy(); $obj3->addProfileRelatedByCreatedBy($obj1); } $omClass = UserPeer::getOMClass(); $cls = Propel::import($omClass); $obj4 = new $cls(); $obj4->hydrate($rs, $startcol4); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj4 = $temp_obj1->getUserRelatedByUpdatedBy(); //CHECKME if ($temp_obj4->getPrimaryKey() === $obj4->getPrimaryKey()) { $newObject = false; $temp_obj4->addProfileRelatedByUpdatedBy($obj1); break; } } if ($newObject) { $obj4->initProfilesRelatedByUpdatedBy(); $obj4->addProfileRelatedByUpdatedBy($obj1); } $omClass = UserPeer::getOMClass(); $cls = Propel::import($omClass); $obj5 = new $cls(); $obj5->hydrate($rs, $startcol5); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj5 = $temp_obj1->getUserRelatedByDeletedBy(); //CHECKME if ($temp_obj5->getPrimaryKey() === $obj5->getPrimaryKey()) { $newObject = false; $temp_obj5->addProfileRelatedByDeletedBy($obj1); break; } } if ($newObject) { $obj5->initProfilesRelatedByDeletedBy(); $obj5->addProfileRelatedByDeletedBy($obj1); } $omClass = UserPeer::getOMClass(); $cls = Propel::import($omClass); $obj6 = new $cls(); $obj6->hydrate($rs, $startcol6); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj6 = $temp_obj1->getUserRelatedByChildUpdatedBy(); //CHECKME if ($temp_obj6->getPrimaryKey() === $obj6->getPrimaryKey()) { $newObject = false; $temp_obj6->addProfileRelatedByChildUpdatedBy($obj1); break; } } if ($newObject) { $obj6->initProfilesRelatedByChildUpdatedBy(); $obj6->addProfileRelatedByChildUpdatedBy($obj1); } $results[] = $obj1; } return $results; }
$showHistoryBc = true; } } */ //this section determines which breadcrumbs to show with which tab //it also retrieves the necessary objects for each breadcrumb //it also sets the object id to use in each tab link when displaying the tabs switch ($buildBc) { case 'agent': $showBc = true; $showAgentBc = true; 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();
/** * 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 = AgentPeer::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->setLastUpdated($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setDeletedAt($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setOrgEmail($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setOrgName($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setIndAffiliation($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setIndRole($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setAddress1($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setAddress2($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { $this->setCity($arr[$keys[10]]); } if (array_key_exists($keys[11], $arr)) { $this->setState($arr[$keys[11]]); } if (array_key_exists($keys[12], $arr)) { $this->setPostalCode($arr[$keys[12]]); } if (array_key_exists($keys[13], $arr)) { $this->setCountry($arr[$keys[13]]); } if (array_key_exists($keys[14], $arr)) { $this->setPhone($arr[$keys[14]]); } if (array_key_exists($keys[15], $arr)) { $this->setWebAddress($arr[$keys[15]]); } if (array_key_exists($keys[16], $arr)) { $this->setType($arr[$keys[16]]); } }
/** * Get the associated Agent object * * @param Connection Optional Connection object. * @return Agent The associated Agent object. * @throws PropelException */ public function getAgent($con = null) { if ($this->aAgent === null && $this->agent_id !== null) { // include the related Peer class include_once 'lib/model/om/BaseAgentPeer.php'; $this->aAgent = AgentPeer::retrieveByPK($this->agent_id, $con); /* The following can be used instead of the line above to guarantee the related object contains a reference to this object, but this level of coupling may be undesirable in many circumstances. As it can lead to a db query with many results that may never be used. $obj = AgentPeer::retrieveByPK($this->agent_id, $con); $obj->addAgents($this); */ } return $this->aAgent; }
/** * description * * @return agent Current agent object * @param integer $agentId */ public static function setLatestagent($agentId) { $agentObj = AgentPeer::retrieveByPK($agentId); if ($agentObj) { sfContext::getInstance()->getUser()->setCurrentagent($agentObj); } return $agentObj; }
/** * Selects a collection of AgentHasUser objects pre-filled with all related objects except User. * * @return array Array of AgentHasUser objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptUser(Criteria $c, $con = null) { $c = clone $c; // Set the correct dbName if it has not been overridden // $c->getDbName() will return the same object if not set to another value // so == check is okay and faster if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } AgentHasUserPeer::addSelectColumns($c); $startcol2 = AgentHasUserPeer::NUM_COLUMNS - AgentHasUserPeer::NUM_LAZY_LOAD_COLUMNS + 1; AgentPeer::addSelectColumns($c); $startcol3 = $startcol2 + AgentPeer::NUM_COLUMNS; $c->addJoin(AgentHasUserPeer::AGENT_ID, AgentPeer::ID); $rs = BasePeer::doSelect($c, $con); $results = array(); while ($rs->next()) { $omClass = AgentHasUserPeer::getOMClass(); $cls = Propel::import($omClass); $obj1 = new $cls(); $obj1->hydrate($rs); $omClass = AgentPeer::getOMClass(); $cls = Propel::import($omClass); $obj2 = new $cls(); $obj2->hydrate($rs, $startcol2); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj2 = $temp_obj1->getAgent(); //CHECKME if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { $newObject = false; $temp_obj2->addAgentHasUser($obj1); break; } } if ($newObject) { $obj2->initAgentHasUsers(); $obj2->addAgentHasUser($obj1); } $results[] = $obj1; } return $results; }