/** * setDefaults * * @param SchemaHasUser $SchemaHasUser */ public function setDefaults($SchemaHasUser) { if (!isset($this->schema)) { $this->schema = myActionTools::findCurrentSchema(); } if ($this->schema) { $SchemaHasUser->setSchemaId($this->schema->getId()); } $SchemaHasUser->setIsRegistrarFor(false); parent::setDefaults($SchemaHasUser); }
public function executeList() { $idType = $this->getRequestParameter('IdType', null); $id = $this->getRequestParameter('id', null); if (!$idType) { //a current schema is required to be in the request URL myActionTools::requireSchemaFilter(); } else { $this->getRequest()->getParameterHolder()->set($idType, $id); } $schema = myActionTools::findCurrentSchema(); if ($schema) { $this->schema = $schema; $schemaId = $schema->getId(); } else { $import = FileImportHistoryPeer::retrieveByPK($id); if ($import) { $this->schema = $import->getSchema(); $schemaId = $this->schema->getId(); } } if (in_array($idType, array('schema_property_id', 'schema_property_element_id'))) { $property = myActionTools::findCurrentSchemaProperty(); if ($property) { $this->property = $property; $this->setFlash('hasProperty', true); $schemaId = $this->property->getSchemaId(); } } //get the versions array $c = new Criteria(); $c->add(SchemaHasVersionPeer::SCHEMA_ID, $schemaId); $versions = SchemaHasVersionPeer::doSelect($c); $this->setFlash('versions', $versions); parent::executeList(); }
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 the current schema object * * @return schema current schema object */ public function getCurrentSchema() { $schema = myActionTools::findCurrentSchema(); if (!$schema) { $this->schemaprop = SchemaPropertyPeer::retrieveByPk($this->getRequestParameter('id')); if (isset($this->schemaprop)) { $schema = $this->schemaprop->getSchema(); if ($schema) { myActionTools::setLatestSchema($schema->getId()); } } } $this->forward404Unless($schema, 'No Element Set has been selected.'); $this->schema = $schema; $this->schemaID = $schema->getId(); return $schema; }
/** * 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; }