public function executeList() { $idType = $this->getRequestParameter('IdType', null); $id = $this->getRequestParameter('id', null); if (!$idType) { //a current vocabulary is required to be in the request URL myActionTools::requireVocabularyFilter(); } else { $this->getRequest()->getParameterHolder()->set($idType, $id); } if ($idType !== 'import_id') { $vocabulary = myActionTools::findCurrentVocabulary(); $this->vocabulary = $vocabulary; if (in_array($idType, array('concept_id', 'property_id'))) { $this->concept = myActionTools::findCurrentConcept(); $this->setFlash('hasConcept', true); } } else { $import = FileImportHistoryPeer::retrieveByPK($id); if ($import) { $vocabulary = $import->getVocabulary(); $this->vocabulary = $vocabulary; } } //get the versions array $c = new Criteria(); $c->add(VocabularyHasVersionPeer::VOCABULARY_ID, $vocabulary->getId()); $versions = VocabularyHasVersionPeer::doSelect($c); $this->setFlash('versions', $versions); parent::executeList(); }
/** * setDefaults * * @param VocabularyHasUser $VocabularyHasUser */ public function setDefaults($VocabularyHasUser) { if (!isset($this->vocabulary)) { $this->vocabulary = myActionTools::findCurrentVocabulary(); } if ($this->vocabulary) { $VocabularyHasUser->setVocabularyId($this->vocabulary->getId()); } $VocabularyHasUser->setIsRegistrarFor(false); parent::setDefaults($VocabularyHasUser); }
/** * gets the current vocabulary object * * @return vocabulary current vocabulary object */ public function getCurrentVocabulary() { $vocabulary = myActionTools::findCurrentVocabulary(); if (!$vocabulary) { $this->concept = ConceptPeer::retrieveByPk($this->getRequestParameter('id')); if (isset($this->concept)) { $vocabulary = $this->concept->getVocabulary(); } } $this->forward404Unless($vocabulary, 'No vocabulary has been selected.'); $this->vocabulary = $vocabulary; $this->vocabularyID = $vocabulary->getId(); sfContext::getInstance()->getUser()->setCurrentVocabulary($vocabulary); return $vocabulary; }
/** * Set the defaults * * @param ConceptProperty $concept_property */ public function setDefaults($vocabulary_has_version) { //set the user id $userId = sfContext::getInstance()->getUser()->getAttribute('subscriber_id', '', 'subscriber'); $vocabulary_has_version->setCreatedUserId($userId); //set the vocabulary id $vocabulary = myActionTools::findCurrentVocabulary(); $this->forward404Unless($vocabulary, 'No vocabulary has been selected.'); $vocabulary_has_version->setVocabularyId($vocabulary->getId()); //set the timeslice $ts = $this->getRequestParameter('ts'); if ($ts) { $vocabulary_has_version->setTimeslice($ts); } parent::setDefaults($vocabulary_has_version); }
/** * Set the defaults * * @param ConceptProperty $concept_property */ public function setDefaults($discuss) { $action = $this->getRequest()->getParameter('action'); if ('create' == strtolower($action)) { $filter = $this->getUser()->getAttributeHolder()->getAll('sf_admin/discuss/filters'); //we need to get all the numbers if ($filter && is_array($filter)) { $filterKey = array_keys($filter); try { switch ($filterKey[0]) { case "property": $property = ConceptPropertyPeer::retrieveByPK($filter[$filterKey[0]]); $concept = $property->getConceptRelatedByConceptId(); $vocabId = $concept->getVocabularyId(); $vocabulary = myActionTools::findCurrentVocabulary(); /** @var Discuss **/ $discuss->setConceptProperty($property); $discuss->setConcept($concept); $discuss->setVocabularyId($vocabId); break; case "concept_id": $concept = ConceptPeer::retrieveByPK($filter[$filterKey[0]]); $vocabId = $concept->getVocabularyId(); /** @var Discuss **/ $discuss->setConcept($concept); $discuss->setVocabularyId($vocabId); case "vocabulary_id": $vocabId = VocabularyPeer::retrieveByPK($filter[$filterKey[0]]); /** @var Discuss **/ $discuss->setVocabularyId($vocabId); break; default: } } catch (Exception $e) { } } } else { } parent::setDefaults($discuss); }
public function execute($filterChain) { // get the cool stuff /** @var sfContext **/ $context = $this->getContext(); /** @var sfController **/ $controller = $context->getController(); /** @var sfUser **/ $user = $context->getUser(); /** @var sfRequest **/ $request = $context->getRequest(); if ($request->getCookie('MyWebSite')) { // sign in $user->setAuthenticated(true); } if (!$user->isAuthenticated()) { //this will make sure we are really signed out $user->signOut(); // we bail $filterChain->execute(); } $key = false; // get the current action instance /** @var sfActionStackEntry **/ $actionEntry = $controller->getActionStack()->getLastEntry(); $actionInstance = $actionEntry->getActionInstance(); $action = $request->getParameter('action'); //get the object security information $securityArray = $actionInstance->getSecurityConfiguration(); $objectCredArray = myUser::parseSecurity($securityArray, $action); //The module is either the current module or the parent module. if (isset($objectCredArray['module'])) { $module = $objectCredArray['module']; } else { $module = $context->getModuleName(); } //object credentials are stored in // $user->getAttribute($module,'','object_credentials') //the key for the object credentials comes from: // request param // the key of a stored parent object (need to know the parent object) //so next we need to know the key... //big hack because I'm frustrated: if ('import' == $module) { if ($request->getParameter('vocabulary_id')) { $key = $request->getParameter('vocabulary_id'); $module = 'vocabulary'; } if ($request->getParameter('schema_id')) { $key = $request->getParameter('schema_id'); $module = 'schema'; } } //Does the request parameter exist? if (isset($objectCredArray['request_param'])) { $key = $request->getParameter($objectCredArray['request_param'],''); //get the correct id to check against, but only if we haven't already checked it in this request } //use the default only if we're using the current request elseif ($module == $context->getModuleName()) { //we do the default $key = $request->getParameter('id'); } //still no key? //ok, so this is definitely a hack... if (!$key && (('edit' == $action || 'show' == $action || 'list' == $action) || $module != $context->getModuleName())) { if ('schema' == $module) { $schema = myActionTools::findCurrentSchema(); if ($schema) { $key = $schema->getId(); } } if ('vocabulary' == $module) { $vocabulary = myActionTools::findCurrentVocabulary(); if ($vocabulary) { $key = $vocabulary->getId(); } } if ('agent' == $module) { $agent = myActionTools::findCurrentAgent(); if ($agent) { $key = $agent->getId(); } } } if ($key) { $user->buildModCredentials($key, $module); if ('vocabulary' == $module) { $vocabulary = myActionTools::findCurrentVocabulary(); if ($vocabulary) { $agentId = $vocabulary->getAgentId(); $user->buildModCredentials($agentId, 'agent', true); } } } //skip re-setting the modcredentials if the action == create else { $this->setdefaultCred($user); } // Execute next filter $filterChain->execute(); }
/** * 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; }