/**
  * Get the count of admins
  *
  * @return int
  */
 public function GetAdminCount()
 {
     $c = new Criteria();
     $c->add(VocabularyHasUserPeer::IS_ADMIN_FOR, TRUE);
     $c->add(VocabularyHasUserPeer::VOCABULARY_ID, $this->getVocabularyId());
     return VocabularyHasUserPeer::doCount($c);
 }
 public function executeVocabularyUserList()
 {
     $c = new Criteria();
     $c->add(VocabularyHasUserPeer::VOCABULARY_ID, $this->vocabularyId);
     $c->addAscendingOrderByColumn(UserPeer::LAST_NAME);
     $this->users = VocabularyHasUserPeer::doSelectJoinUser($c);
 }
Example #3
0
     }
     $title = '';
     break;
 case 'vocabularyimportlist':
     $showBc = true;
     $showVocabularyBc = true;
     $tab = true;
     break;
 case 'vocabuser':
     $showBc = true;
     $showVocabularyBc = true;
     $showVocabUserBc = true;
     if (!isset($vocabulary_has_user)) {
         $id = 'show' == $action ? $sf_params->get('id') : $paramId;
         if ($id) {
             $vocabulary_has_user = VocabularyHasUserPeer::retrieveByPK($id);
         }
     }
     $objectId = $vocabulary_has_user->getID();
     if (!isset($vocabulary)) {
         $vocabulary = $vocabulary_has_user->getVocabulary();
     }
     $tab = false;
     break;
 case 'concept':
     $showBc = true;
     $showVocabularyBc = true;
     $showConceptBc = true;
     if (!isset($concept)) {
         $id = 'show' == $action ? $sf_params->get('id') : $paramId;
         if ($id) {
 public function getVocabularyCredentials($vocabularyId = false)
 {
     //$vocabularyId = sfContext::getInstance()->getRequest()->getParameter('id');
     if ($this->isAuthenticated()) {
         if (!$this->hasCredential(array(0 => 'hasAgents'))) {
             $this->setHasAgents();
         }
         if ($vocabularyId) {
             //make sure we've revoked the credentials -- we revoke, then set them every time the vocabulary is accessed
             $this->removeCredential('vocabularycontact');
             $this->removeCredential('vocabularyregistrar');
             $this->removeCredential('vocabularymaintainer');
             $this->removeCredential('vocabularyadmin');
             /* @var VocabularyHasUserPeer */
             $vocabularyContact = VocabularyHasUserPeer::retrieveByPK($vocabularyId, $this->getSubscriberId());
             if (isset($vocabularyContact)) {
                 $this->addCredential('vocabularycontact');
                 if ($vocabularyContact->getIsRegistrarFor()) {
                     $this->addCredential('vocabularyregistrar');
                 }
                 if ($vocabularyContact->getIsMaintainerFor()) {
                     $this->addCredential('vocabularymaintainer');
                 }
                 if ($vocabularyContact->getIsAdminFor()) {
                     $this->addCredential('vocabularyadmin');
                 }
             }
         } elseif ('create' == sfContext::getInstance()->getRequest()->getParameter('action')) {
             $this->addCredential('vocabularycontact');
             $this->addCredential('vocabularyregistrar');
             $this->addCredential('vocabularyadmin');
         }
     }
     return;
 }
    public function setUserId($userId = null)
    {
        if ($userId) {
            $this->userId = $userId;
        } else {
            $criteria = new \Criteria();
            if ('schema' == $this->type) {
                $criteria->add(\SchemaHasUserPeer::SCHEMA_ID, $this->vocabId);
                $criteria->add(\SchemaHasUserPeer::IS_ADMIN_FOR, true);
                $users = \SchemaHasUserPeer::doSelectJoinUser($criteria);
            } else {
                $criteria->add(\VocabularyHasUserPeer::VOCABULARY_ID, $this->vocabId);
                $criteria->add(\VocabularyHasUserPeer::IS_ADMIN_FOR, true);
                $users = \VocabularyHasUserPeer::doSelectJoinUser($criteria);
            }
            if ( ! $users) {
                //TODO: turn this into a real error message and exit gracefully
                exit( "No user ID found!!!!!" );
            }

            /** @var $schemaUser \SchemaHasUser */
            $schemaUser   = $users[0];
            $this->userId = $schemaUser->getUser()->getId();
        }
    }
Example #6
0
 /**
  * gets a list of users for the selected agent that have not been assigned to the current vocabulary
  *
  * @return array an array for select
  */
 public static function getNewUsersForVocabulary()
 {
     $results = array();
     $vocabulary = myActionTools::findCurrentVocabulary();
     if ($vocabulary) {
         //get the users for the agent
         $c = new Criteria();
         $c->addJoin(self::ID, AgentHasUserPeer::USER_ID, Criteria::LEFT_JOIN);
         $c->add(AgentHasUserPeer::AGENT_ID, $vocabulary->getAgentId(), Criteria::EQUAL);
         $c->addAscendingOrderByColumn(self::NICKNAME);
         $results = self::doSelect($c);
         //remove the current maintainers of the vocabulary
         $c = new Criteria();
         $c->add(VocabularyHasUserPeer::VOCABULARY_ID, $vocabulary->getId(), Criteria::EQUAL);
         $vocabUsers = VocabularyHasUserPeer::doSelect($c);
         /** @var $vocabUser VocabularyHasUser */
         foreach ($vocabUsers as $vocabUser) {
             $curId = $vocabUser->getUserId();
             /** @var $result User */
             foreach ($results as $key => $result) {
                 if ($result->getId() == $curId) {
                     unset($results[$key]);
                     break;
                 }
             }
         }
         $results = array_merge($results);
     }
     return $results;
 }
Example #7
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this User is new, it will return
  * an empty collection; or if this User has previously
  * been saved, it will retrieve related VocabularyHasUsers 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 User.
  */
 public function getVocabularyHasUsersJoinVocabulary($criteria = null, $con = null)
 {
     // include the Peer class
     include_once 'lib/model/om/BaseVocabularyHasUserPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collVocabularyHasUsers === null) {
         if ($this->isNew()) {
             $this->collVocabularyHasUsers = array();
         } else {
             $criteria->add(VocabularyHasUserPeer::USER_ID, $this->getId());
             $this->collVocabularyHasUsers = VocabularyHasUserPeer::doSelectJoinVocabulary($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(VocabularyHasUserPeer::USER_ID, $this->getId());
         if (!isset($this->lastVocabularyHasUserCriteria) || !$this->lastVocabularyHasUserCriteria->equals($criteria)) {
             $this->collVocabularyHasUsers = VocabularyHasUserPeer::doSelectJoinVocabulary($criteria, $con);
         }
     }
     $this->lastVocabularyHasUserCriteria = $criteria;
     return $this->collVocabularyHasUsers;
 }
 /**
  * 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(VocabularyHasUserPeer::ID, $pks, Criteria::IN);
         $objs = VocabularyHasUserPeer::doSelect($criteria, $con);
     }
     return $objs;
 }