コード例 #1
0
 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();
 }
コード例 #2
0
 /**
  * overrides the parent executeList function
  *
  */
 public function executeList()
 {
     if (!$this->hasRequestParameter('user_id')) {
         //a current vocabulary is required
         $vocabulary = myActionTools::requireVocabularyFilter();
     }
     parent::executeList();
 }
コード例 #3
0
 /**
  * overrides the parent executeList function
  *
  */
 public function executeList()
 {
     if (!$this->hasRequestParameter('user_id')) {
         //a current schema is required
         $schema = myActionTools::requireSchemaFilter();
     }
     parent::executeList();
 }
コード例 #4
0
 public function setDefaults($AgentHasUser)
 {
     $agent = myActionTools::findCurrentAgent();
     if ($agent) {
         $AgentHasUser->setAgentId($agent->getId());
     }
     $AgentHasUser->setIsRegistrarFor(false);
     parent::setDefaults($AgentHasUser);
 }
コード例 #5
0
 /**
  * description
  *
  * @return return_type
  * @param  var_type $var
  */
 public static function getConceptsByCurrentVocabID()
 {
     $conceptProperty = sfContext::getInstance()->getActionStack()->getLastEntry()->getActionInstance()->concept_property;
     if ($conceptProperty) {
         $vocabId = $conceptProperty->getSchemeId();
     } else {
         $vocabId = sfContext::getInstance()->getUser()->getAttribute('vocabulary')->getId();
     }
     $concept = myActionTools::findCurrentConcept();
     if ($concept) {
         $conceptId = $concept->getId();
     }
     return self::getConceptsByVocabID($vocabId, $conceptId);
 }
コード例 #6
0
 /**
  * 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;
 }
コード例 #7
0
 /**
 * 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);
 }
コード例 #8
0
 /**
  * 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);
 }
コード例 #9
0
  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();
  }
コード例 #10
0
$tabMap['import']['show'] = array('tab' => 'import', 'title' => 'Show Import Detail');
//get the current module/action
/** @var sfParameterHolder $sf_params */
$module = $sf_params->get('module');
$action = $sf_params->get('action');
//add the truncate helper if it's a list
if ('list' == $action) {
    use_helper('TruncateUri');
}
//retrieve the map
$tab = $tabMap[$module][$action]['tab'];
$buildBc = $tab;
$metaAction = ' :: ' . __($tabMap[$module][$action]['title']);
//set the filter
/** @var myUser $sf_user * */
myActionTools::updateAdminFilters($sf_user->getAttributeHolder(), $value, $paramId, $module);
//setup the variables determining which breadcrumb to display
$showVocabularyBc = false;
$showVocabUserBc = false;
$showSchemaBc = false;
$showSchemaUserBc = false;
$showSchemaPropBc = false;
$showSchemaPropelBc = false;
$showSchemaHistoryBc = false;
$showConceptBc = false;
$showconceptpropBc = false;
$showAgentBc = false;
$showAgentUserBc = false;
$showUserBc = false;
$showHistoryBc = false;
$showDiscussBc = false;
コード例 #11
0
 /**
  * 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;
 }
コード例 #12
0
 /**
  * @param SchemaProperty $schema_property
  * @param int            $userId
  * @param Connection     $con
  *
  * @returns array Affected statements
  */
 public static function updateElementsFromForm(SchemaProperty $schema_property, $userId, $con = null)
 {
     $language = myActionTools::getEditLanguage();
     $fields = Schema::getProfileFields();
     //add parent_uri to fields
     $fields[] = "parent_uri";
     $affected = [];
     //iterate through the fields
     foreach ($fields as $key => $value) {
         //lookup each field in the array
         //if it's a match compare the values
         if ($key) {
             //if the new value is empty and the old value is not, delete the old value
             if ($key) {
             } else {
                 if ($key) {
                 }
             }
         } else {
         }
     }
     return $affected;
 }
コード例 #13
0
 /**
  * gets the current vocabulary object
  *
  * @return vocabulary current vocabulary object
  */
 public function getCurrentConcept()
 {
     //TODO: Redo this temporary fix to retrieving the current concept and vocabulary
     //$concept = myActionTools::findCurrentConcept();
     //if (!$concept) //we have to do it the hard way
     //{
     $this->conceptProperty = ConceptPropertyPeer::retrieveByPk($this->getRequestParameter('id'));
     /* @var Concept */
     if (isset($this->conceptProperty)) {
         $concept = $this->conceptProperty->getConceptRelatedByConceptId();
     } else {
         $concept = myActionTools::findCurrentConcept();
     }
     //}
     //and let's just do the vocabulary while we're at it
     //if ($concept && !isset($this->vocabulary))
     if ($concept) {
         $vocabulary = $concept->getVocabulary();
         $this->vocabulary = $vocabulary;
     }
     $this->forward404Unless($concept, 'No concept has been selected.');
     $this->forward404Unless($vocabulary, 'No vocabulary has been selected.');
     $this->concept = $concept;
     $this->conceptID = $concept->getId();
     return $concept;
 }
コード例 #14
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;
 }
コード例 #15
0
 /**
  * gets the current schema object
  *
  * @return schema current schema object
  */
 public function getCurrentSchema()
 {
     $schema = false;
     if ($this->getRequestParameter('id')) {
         $this->file_import_history = FileImportHistoryPeer::retrieveByPk($this->getRequestParameter('id'));
         if (isset($this->file_import_history)) {
             $schema = $this->file_import_history->getSchema();
             if ($this->file_import_history->getSchemaId()) {
                 $schema = $this->file_import_history->getSchema();
             }
             if ($this->file_import_history->getVocabularyId()) {
                 $schema = $this->file_import_history->getVocabulary();
             }
         }
     }
     if ($this->getRequestParameter('schema_id')) {
         $schema = SchemaPeer::retrieveByPk($this->getRequestParameter('schema_id'));
         $this->type = 'schema';
     }
     if ($this->getRequestParameter('vocabulary_id')) {
         $schema = VocabularyPeer::retrieveByPk($this->getRequestParameter('vocabulary_id'));
         $this->type = 'vocabulary';
     }
     if ($schema) {
         myActionTools::setLatestSchema($schema->getId());
     }
     $this->forward404Unless($schema, 'No filter has been selected.');
     $this->schema = $schema;
     $this->schemaID = $schema->getId();
     return $schema;
 }
コード例 #16
0
 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();
 }
コード例 #17
0
 public function executeCreate()
 {
     //make sure we have the id in the URL
     myActionTools::requireSchemaPropertyFilter();
     parent::executeCreate();
 }