Esempio n. 1
0
 public function insert($data)
 {
     $data['password'] = $this->_generatePassword($data['password']);
     if (isset($data['id'])) {
         unset($data['id']);
     }
     return parent::insert($data);
 }
Esempio 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'];
 }
Esempio n. 3
0
 /**
  * Inserts a new row.
  *
  * @param  array  $data  Column-value pairs.
  * @return mixed         The primary key of the row inserted.
  */
 public function insert(array $data)
 {
     if (isset($data['id']) == false) {
         $data['id'] = RM_Reservations::createReservationID();
     }
     return parent::insert($data);
 }