Example #1
0
 /**
  * @return array
  */
 public function getMaintainerIds()
 {
     $ca = new Criteria();
     $ca->add(SchemaHasUserPeer::SCHEMA_ID, $this->getId());
     $ca->add(SchemaHasUserPeer::IS_MAINTAINER_FOR, true);
     $maintainers = SchemaHasUserPeer::doSelect($ca);
     $maintainerArray = [];
     /** @var SchemaHasUser $maintainer */
     foreach ($maintainers as $maintainer) {
         $maintainerArray[] = $maintainer->getUserId();
     }
     return $maintainerArray;
 }
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this Schema has previously
  * been saved, it will retrieve related SchemaHasUsers from storage.
  * If this Schema is new, it will return
  * an empty collection or the current collection, the criteria
  * is ignored on a new object.
  *
  * @param      Connection $con
  * @param      Criteria $criteria
  * @throws     PropelException
  */
 public function getSchemaHasUsers($criteria = null, $con = null)
 {
     // include the Peer class
     include_once 'lib/model/om/BaseSchemaHasUserPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collSchemaHasUsers === null) {
         if ($this->isNew()) {
             $this->collSchemaHasUsers = array();
         } else {
             $criteria->add(SchemaHasUserPeer::SCHEMA_ID, $this->getId());
             SchemaHasUserPeer::addSelectColumns($criteria);
             $this->collSchemaHasUsers = SchemaHasUserPeer::doSelect($criteria, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // 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(SchemaHasUserPeer::SCHEMA_ID, $this->getId());
             SchemaHasUserPeer::addSelectColumns($criteria);
             if (!isset($this->lastSchemaHasUserCriteria) || !$this->lastSchemaHasUserCriteria->equals($criteria)) {
                 $this->collSchemaHasUsers = SchemaHasUserPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastSchemaHasUserCriteria = $criteria;
     return $this->collSchemaHasUsers;
 }
 /**
  * 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(SchemaHasUserPeer::ID, $pks, Criteria::IN);
         $objs = SchemaHasUserPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Example #4
0
 /**
  * gets a list of users for the selected agent that have not been assigned to the current schema
  *
  * @return array an array for select
  * @param  var_type $var
  */
 public static function getNewUsersForSchema()
 {
     $schema = myActionTools::findCurrentSchema();
     $results = array();
     if ($schema) {
         //get the users for the agent
         $c = new Criteria();
         $c->addJoin(self::ID, AgentHasUserPeer::USER_ID, Criteria::LEFT_JOIN);
         $c->add(AgentHasUserPeer::AGENT_ID, $schema->getAgentId(), Criteria::EQUAL);
         $c->addAscendingOrderByColumn(self::NICKNAME);
         $results = self::doSelect($c);
         //remove the current maintainers of the vocabulary
         $c = new Criteria();
         $c->add(SchemaHasUserPeer::SCHEMA_ID, $schema->getId(), Criteria::EQUAL);
         $schemaUsers = SchemaHasUserPeer::doSelect($c);
         foreach ($schemaUsers as $schemaUser) {
             $curId = $schemaUser->getUserId();
             foreach ($results as $key => $result) {
                 if ($result->getId() == $curId) {
                     unset($results[$key]);
                     break;
                 }
             }
         }
         $results = array_merge($results);
     }
     return $results;
 }