Exemplo n.º 1
0
 public function allpanelsAction()
 {
     $unitModel = new RM_Units();
     $unitTypeID = $this->_getParam('unitTypeID');
     $unitTypeModel = new RM_UnitTypes();
     $unitType = $unitTypeModel->find($unitTypeID)->current();
     $unit = $unitModel->getAll(new RM_Unit_Search_Criteria(array('type' => $unitType, 'includeOptionUnits' => true, 'includeExcursionUnits' => true)))->current();
     if ($unitTypeID == RM_UnitTypes::DEFAULT_TYPE && $unit == null) {
         $unit = $unitModel->getAll(new RM_Unit_Search_Criteria())->current();
     }
     if ($unit == null) {
         $unit = $unitModel->createRow();
     }
     $this->view->unit = $unit;
     $this->view->admin = true;
     // this is required by captcha
     $panelModel = new RM_FormPanels();
     $panels = $panelModel->fetchAll();
     $this->view->panels = $panels;
 }
Exemplo n.º 2
0
 /**
  * Insert a unit by its primary key
  *
  * @param array $unit Array with all unit information
  * @param string $iso ISO language code ('cause we got all unit info with language dependent fields)
  * @param boolean $fromGUI This parameter told us was that data from GUI or it's internal usage.
  * @return mixed The primary key of the row inserted.
  */
 public function insert($unit, $iso, $fromGUI = false)
 {
     $unitTypeDAO = new RM_UnitTypes();
     $type = $unitTypeDAO->find($unit['type_id'])->current();
     list($fields, $languageFields) = $this->_getFieldsByType($type);
     $unitArray = array();
     $languageArray = array();
     foreach ($fields as $field) {
         $unitArray[$field->column_name] = $unit[$field->column_name];
     }
     foreach ($languageFields as $field) {
         $languageArray[$field->column_name] = $unit[$field->column_name];
     }
     //TODO: this code need to be more flexible to do not use UnitTypeManager module
     $manager = new RM_Module_UnitTypeManager();
     $unitArray['type_id'] = $manager->getDefaultUnitType()->id;
     if ($fromGUI) {
         $languageArray['unit_id'] = $this->insertFromGUI($unitArray);
     } else {
         $languageArray['unit_id'] = parent::insert($unitArray);
     }
     $unitModel = new RM_Units();
     $newUnit = $unitModel->createRow(array('id' => $languageArray['unit_id']));
     $mediaManager = new RM_Media_Unit_Manager($newUnit);
     $mediaManager->createFolder();
     //we need to create a unit detail row for every language installed in the system
     $languageModel = new RM_Languages();
     $languages = $languageModel->fetchAll();
     $unitLanguageModel = new RM_UnitLanguageDetails();
     foreach ($languages as $language) {
         $languageArray['iso'] = $language->iso;
         $unitLanguageModel->insert($languageArray);
     }
     return $languageArray['unit_id'];
 }