/**
  * Save a single model item.
  *
  * @param array $newValues The values to store for a single model item.
  * @param array $filter If the filter contains old key values these are used
  * to decide on update versus insert.
  * @return array The values as they are after saving (they may change).
  */
 public function save(array $newValues, array $filter = null)
 {
     // When appointment id is not set, then check for existing instances of
     // this appointment using the source information
     if (!isset($newValues['gap_id_appointment']) && isset($newValues['gap_id_in_source'], $newValues['gap_id_organization'], $newValues['gap_source'])) {
         $sql = "SELECT gap_id_appointment\n                FROM gems__appointments\n                WHERE gap_id_in_source = ? AND gap_id_organization = ? AND gap_source = ?";
         $id = $this->db->fetchOne($sql, array($newValues['gap_id_in_source'], $newValues['gap_id_organization'], $newValues['gap_source']));
         if ($id) {
             $newValues['gap_id_appointment'] = $id;
         }
     }
     $oldChanged = $this->getChanged();
     $returnValues = parent::save($newValues, $filter);
     if ($this->getChanged() && $this->getChanged() !== $oldChanged) {
         if ($this->isAutoTrackUpdate()) {
             $appointment = $this->loader->getAgenda()->getAppointment($returnValues);
             $this->_changedTokenCount += $appointment->updateTracks();
         }
     }
     // \MUtil_Echo::track($this->_changedTokenCount);
     return $returnValues;
 }
 /**
  * Save a single model item.
  *
  * Makes sure the password is saved too using the userclass
  *
  * @param array $newValues The values to store for a single model item.
  * @param array $filter If the filter contains old key values these are used
  * to decide on update versus insert.
  * @param array $saveTables Optional array containing the table names to save,
  * otherwise the tables set to save at model level will be saved.
  * @return array The values as they are after saving (they may change).
  */
 public function save(array $newValues, array $filter = null, array $saveTables = null)
 {
     //First perform a save
     $savedValues = parent::save($newValues, $filter, $saveTables);
     //Now check if we need to save config values
     if (isset($newValues['gor_user_class']) && !empty($newValues['gor_user_class'])) {
         $definition = $this->loader->getUserLoader()->getUserDefinition($newValues['gor_user_class']);
         if ($definition instanceof \Gems_User_UserDefinitionConfigurableInterface && $definition->hasConfig()) {
             $savedValues = $definition->saveConfig($savedValues, $newValues);
             if ($definition->getConfigChanged() > 0 && $this->getChanged() < 1) {
                 $this->setChanged(1);
             }
         }
     }
     return $savedValues;
 }
Ejemplo n.º 3
0
 /**
  * Save a single model item.
  *
  * Makes sure the password is saved too using the userclass
  *
  * @param array $newValues The values to store for a single model item.
  * @param array $filter If the filter contains old key values these are used
  * to decide on update versus insert.
  * @param array $saveTables Optional array containing the table names to save,
  * otherwise the tables set to save at model level will be saved.
  * @return array The values as they are after saving (they may change).
  */
 public function save(array $newValues, array $filter = null, array $saveTables = null)
 {
     //First perform a save
     $savedValues = parent::save($newValues, $filter, $saveTables);
     //Now check if we need to set the password
     if (isset($newValues['fld_password']) && !empty($newValues['fld_password'])) {
         if ($this->getChanged() < 1) {
             $this->setChanged(1);
         }
         //Now load the userclass and save the password use the $savedValues as for a new
         //user we might not have the id in the $newValues
         $user = $this->loader->getUserLoader()->getUserByStaffId($savedValues['gsf_id_user']);
         if ($user->canSetPassword()) {
             $user->setPassword($newValues['fld_password']);
         }
     }
     return $savedValues;
 }