Пример #1
0
 public function executeEdit(sfWebRequest $request)
 {
     $staging = Doctrine::getTable('Staging')->findOneById($request->getParameter('id'));
     $this->import = Doctrine::getTable('Imports')->find($staging->getImportRef());
     if (!Doctrine::getTable('collectionsRights')->hasEditRightsFor($this->getUser(), $this->import->getCollectionRef())) {
         $this->forwardToSecureAction();
     }
     $this->fields = $staging->getFields();
     $form_fields = array();
     if ($this->fields) {
         foreach ($this->fields as $key => $values) {
             $form_fields[] = $values['fields'];
         }
     }
     if (in_array('taxon_ref', $form_fields)) {
         $parent = new Hstore();
         $parent->import($staging->getTaxonParents());
         $taxon_parent = $parent->getArrayCopy();
         $taxon_parent[$staging->getTaxonLevelName()] = $staging->getTaxonName();
         $this->taxon_level_name = $staging->getTaxonLevelName();
         $this->catalogues_taxon = Doctrine::getTable('Taxonomy')->getLevelParents('Taxonomy', $taxon_parent);
     }
     if (in_array('litho_ref', $form_fields)) {
         $parent = new Hstore();
         $parent->import($staging->getLithoParents());
         $parents = $parent->getArrayCopy();
         $parents[$staging->getLithoLevelName()] = $staging->getLithoName();
         $this->litho_level_name = $staging->getLithoLevelName();
         $this->catalogues_litho = Doctrine::getTable('Lithostratigraphy')->getLevelParents('Lithostratigraphy', $parents);
     }
     if (in_array('lithology_ref', $form_fields)) {
         $parent = new Hstore();
         $parent->import($staging->getLithologyParents());
         $parents = $parent->getArrayCopy();
         $parents[$staging->getLithologyLevelName()] = $staging->getLithologyName();
         $this->lithology_level_name = $staging->getLithologyLevelName();
         $this->catalogues_lithology = Doctrine::getTable('Lithology')->getLevelParents('Lithology', $parents);
     }
     if (in_array('chrono_ref', $form_fields)) {
         $parent = new Hstore();
         $parent->import($staging->getChronoParents());
         $parents = $parent->getArrayCopy();
         $parents[$staging->getChronoLevelName()] = $staging->getChronoName();
         $this->chrono_level_name = $staging->getChronoLevelName();
         $this->catalogues_chrono = Doctrine::getTable('Chronostratigraphy')->getLevelParents('Chronostratigraphy', $parents);
     }
     if (in_array('mineral_ref', $form_fields)) {
         $parent = new Hstore();
         $parent->import($staging->getMineralParents());
         $parents = $parent->getArrayCopy();
         $parents[$staging->getMineralLevelName()] = $staging->getMineralName();
         $this->mineral_level_name = $staging->getMineralLevelName();
         $this->catalogues_mineral = Doctrine::getTable('Mineralogy')->getLevelParents('Mineralogy', $parents);
     }
     $this->form = new StagingForm($staging, array('fields' => $form_fields));
 }