Beispiel #1
0
 /** Save all changed columns of the recordset in table of database. Therefore the class remembers if it's
  *  a new record or if only an update is necessary. The update statement will only update
  *  the changed columns. If the table has columns for creator or editor than these column
  *  with their timestamp will be updated.
  *  The current organization will be set per default.
  *  @param $updateFingerPrint Default @b true. Will update the creator or editor of the recordset if table has columns like @b usr_id_create or @b usr_id_changed
  */
 public function save($updateFingerPrint = true)
 {
     global $gCurrentOrganization;
     if ($this->new_record) {
         $this->setValue('ann_org_shortname', $gCurrentOrganization->getValue('org_shortname'));
     }
     parent::save($updateFingerPrint);
 }
Beispiel #2
0
 /**
  * Save all changed columns of the recordset in table of database. Therefore the class remembers if it's
  * a new record or if only an update is necessary. The update statement will only update
  * the changed columns. If the table has columns for creator or editor than these column
  * with their timestamp will be updated.
  * For new records the organization will be set per default.
  * @param bool $updateFingerPrint Default @b true. Will update the creator or editor of the recordset if table has columns like @b usr_id_create or @b usr_id_changed
  * @return bool If an update or insert into the database was done then return true, otherwise false.
  */
 public function save($updateFingerPrint = true)
 {
     if ($this->new_record && $this->getValue('txt_org_id') === '') {
         // Insert
         global $gCurrentOrganization;
         $this->setValue('txt_org_id', $gCurrentOrganization->getValue('org_id'));
     }
     return parent::save($updateFingerPrint);
 }
 /**
  * Save all changed columns of the recordset in table of database. Therefore the class remembers if it's
  * a new record or if only an update is necessary. The update statement will only update
  * the changed columns. If the table has columns for creator or editor than these column
  * with their timestamp will be updated.
  * For new records the organization and ip address will be set per default.
  * @param bool $updateFingerPrint Default @b true. Will update the creator or editor of the recordset if table has columns like @b usr_id_create or @b usr_id_changed
  */
 public function save($updateFingerPrint = true)
 {
     global $gCurrentOrganization;
     if ($this->new_record) {
         $this->setValue('gbc_org_id', $gCurrentOrganization->getValue('org_id'));
         $this->setValue('gbc_ip_address', $_SERVER['REMOTE_ADDR']);
     }
     parent::save($updateFingerPrint);
 }
Beispiel #4
0
 /**
  * Save all changed columns of the recordset in table of database. Therefore the class remembers if it's
  * a new record or if only an update is necessary. The update statement will only update
  * the changed columns. If the table has columns for creator or editor than these column
  * with their timestamp will be updated.
  * @param bool $updateFingerPrint Default @b true. Will update the creator or editor of the recordset if table has columns like @b usr_id_create or @b usr_id_changed
  * @return bool If an update or insert into the database was done then return true, otherwise false.
  */
 public function save($updateFingerPrint = true)
 {
     global $gCurrentSession;
     $returnStatus = parent::save($updateFingerPrint);
     if ($returnStatus && is_object($gCurrentSession)) {
         // renew user object of the affected user because of edited role assignment
         $gCurrentSession->renewUserObject($this->getValue('mem_usr_id'));
     }
     return $returnStatus;
 }
Beispiel #5
0
 /**
  * Save all changed columns of the recordset in table of database. Therefore the class remembers if it's
  * a new record or if only an update is necessary. The update statement will only update the changed columns.
  * If the table has columns for creator or editor than these column with their timestamp will be updated.
  * The current organization, last login and ip adress will be set per default.
  * @param bool $updateFingerPrint Default @b true. Will update the creator or editor of the recordset
  *                                if table has columns like @b usr_id_create or @b usr_id_changed
  */
 public function save($updateFingerPrint = true)
 {
     if ($this->new_record) {
         // Insert
         global $gCurrentOrganization;
         $this->setValue('atl_org_id', $gCurrentOrganization->getValue('org_id'));
         $this->setValue('atl_last_login', DATETIME_NOW);
         $this->setValue('atl_ip_address', $_SERVER['REMOTE_ADDR']);
         // Tabelle aufraeumen, wenn ein neuer Datensatz geschrieben wird
         $this->tableCleanup();
     } else {
         // Update
         $this->setValue('atl_last_login', DATETIME_NOW);
         $this->setValue('atl_ip_address', $_SERVER['REMOTE_ADDR']);
     }
     parent::save($updateFingerPrint);
 }
Beispiel #6
0
 /**
  * Save all changed columns of the recordset in table of database. Therefore the class remembers if it's
  * a new record or if only an update is necessary. The update statement will only update
  * the changed columns. If the table has columns for creator or editor than these column
  * with their timestamp will be updated.
  * Per default the organization, user and timestamp will be set.
  * @param bool $updateFingerPrint Default @b true. Will update the creator or editor of the recordset if table has columns like @b usr_id_create or @b usr_id_changed
  */
 public function save($updateFingerPrint = true)
 {
     global $gCurrentOrganization, $gCurrentUser;
     // Standardfelder fuellen
     if ($this->new_record) {
         $this->setValue('lst_timestamp', DATETIME_NOW);
         $this->setValue('lst_usr_id', $gCurrentUser->getValue('usr_id'));
         if (strlen($this->getValue('lst_org_id')) === 0) {
             $this->setValue('lst_org_id', $gCurrentOrganization->getValue('org_id'));
         }
     } else {
         $this->setValue('lst_timestamp', DATETIME_NOW);
         $this->setValue('lst_usr_id', $gCurrentUser->getValue('usr_id'));
     }
     // falls nicht explizit auf global = 1 gesetzt wurde, immer auf 0 setzen
     if ($this->getValue('lst_global') != 1) {
         $this->setValue('lst_global', 0);
     }
     parent::save($updateFingerPrint);
 }
 /**
  * Save all changed columns of the recordset in table of database. Therefore the class remembers if it's
  * a new record or if only an update is necessary. The update statement will only update
  * the changed columns. If the table has columns for creator or editor than these column
  * with their timestamp will be updated.
  * If a new record is inserted than the next free sequence will be determined.
  * @param bool $updateFingerPrint Default @b true. Will update the creator or editor of the recordset if table has columns like @b usr_id_create or @b usr_id_changed
  * @return bool If an update or insert into the database was done then return true, otherwise false.
  */
 public function save($updateFingerPrint = true)
 {
     global $gCurrentOrganization, $gCurrentSession;
     $fields_changed = $this->columnsValueChanged;
     $this->db->startTransaction();
     if ($this->new_record) {
         if ($this->getValue('cat_org_id') > 0) {
             $org_condition = ' AND (  cat_org_id  = ' . $gCurrentOrganization->getValue('org_id') . '
                                    OR cat_org_id IS NULL ) ';
         } else {
             $org_condition = ' AND cat_org_id IS NULL ';
         }
         // beim Insert die hoechste Reihenfolgennummer der Kategorie ermitteln
         $sql = 'SELECT COUNT(*) as count
                   FROM ' . TBL_CATEGORIES . '
                  WHERE cat_type = \'' . $this->getValue('cat_type') . '\'
                        ' . $org_condition;
         $countCategoriesStatement = $this->db->query($sql);
         $row = $countCategoriesStatement->fetch();
         $this->setValue('cat_sequence', $row['count'] + 1);
         if ($this->getValue('cat_org_id') == 0) {
             // eine Orga-uebergreifende Kategorie ist immer am Anfang, also Kategorien anderer Orgas nach hinten schieben
             $sql = 'UPDATE ' . TBL_CATEGORIES . ' SET cat_sequence = cat_sequence + 1
                      WHERE cat_type = \'' . $this->getValue('cat_type') . '\'
                        AND cat_org_id IS NOT NULL ';
             $this->db->query($sql);
         }
     }
     // if new category than generate new name intern, otherwise no change will be made
     if ($this->new_record) {
         $this->setValue('cat_name_intern', $this->getNewNameIntern($this->getValue('cat_name'), 1));
     }
     $returnValue = parent::save($updateFingerPrint);
     // Nach dem Speichern noch pruefen, ob Userobjekte neu eingelesen werden muessen,
     if ($fields_changed && $this->getValue('cat_type') === 'USF' && is_object($gCurrentSession)) {
         // all active users must renew their user data because the user field structure has been changed
         $gCurrentSession->renewUserObject();
     }
     $this->db->endTransaction();
     return $returnValue;
 }
Beispiel #8
0
 /**
  * Save all changed columns of the recordset in table of database. Therefore the class remembers if it's
  * a new record or if only an update is necessary. The update statement will only update
  * the changed columns. If the table has columns for creator or editor than these column
  * with their timestamp will be updated.
  * For new records the organization, timestamp, begin date and ip address will be set per default.
  * @param bool $updateFingerPrint Default @b true. Will update the creator or editor of the recordset if table has columns like @b usr_id_create or @b usr_id_changed
  */
 public function save($updateFingerPrint = true)
 {
     if ($this->new_record) {
         // Insert
         global $gCurrentOrganization;
         $this->setValue('ses_org_id', $gCurrentOrganization->getValue('org_id'));
         $this->setValue('ses_begin', DATETIME_NOW);
         $this->setValue('ses_timestamp', DATETIME_NOW);
         $this->setValue('ses_ip_address', $_SERVER['REMOTE_ADDR']);
     } else {
         // Update
         $this->setValue('ses_timestamp', DATETIME_NOW);
     }
     parent::save($updateFingerPrint);
 }
Beispiel #9
0
 /**
  * Save all changed columns of the recordset in table of database. Therefore the class remembers if it's
  * a new record or if only an update is necessary. The update statement will only update the changed columns.
  * If the table has columns for creator or editor than these column with their timestamp will be updated.
  * For new records the organization and ip address will be set per default.
  * @param bool $updateFingerPrint Default @b true. Will update the creator or editor of the recordset if table has columns like @b usr_id_create or @b usr_id_changed
  * @return bool If an update or insert into the database was done then return true, otherwise false.
  */
 public function save($updateFingerPrint = true)
 {
     global $gCurrentSession;
     $fields_changed = $this->columnsValueChanged;
     $returnValue = parent::save($updateFingerPrint);
     // Nach dem Speichern noch pruefen, ob Userobjekte neu eingelesen werden muessen,
     if ($fields_changed && is_object($gCurrentSession)) {
         // all active users must renew their user data because maybe their
         // rights have been changed if they where members of this role
         $gCurrentSession->renewUserObject();
     }
     return $returnValue;
 }
 /**
  * Save all changed columns of the recordset in table of database. Therefore the class remembers if it's
  * a new record or if only an update is necessary. The update statement will only update
  * the changed columns. If the table has columns for creator or editor than these column
  * with their timestamp will be updated.
  * For new records the name intern will be set per default.
  * @param bool $updateFingerPrint Default @b true. Will update the creator or editor of the recordset if table has columns like @b usr_id_create or @b usr_id_changed
  * @return bool If an update or insert into the database was done then return true, otherwise false.
  */
 public function save($updateFingerPrint = true)
 {
     // if new field than generate new name intern, otherwise no change will be made
     if ($this->new_record) {
         $this->setValue('inf_name_intern', $this->getNewNameIntern($this->getValue('inf_name', 'database'), 1));
     }
     return parent::save($updateFingerPrint);
 }
Beispiel #11
0
 /**
  * Save all changed columns of the recordset in table of database. Therefore the class remembers if it's
  * a new record or if only an update is necessary. The update statement will only update the changed columns.
  * If the table has columns for creator or editor than these column with their timestamp will be updated.
  * For new records the user and timestamp will be set per default.
  * @param bool $updateFingerPrint Default @b true. Will update the creator or editor of the recordset if table has columns like @b usr_id_create or @b usr_id_changed
  * @return bool If an update or insert into the database was done then return true, otherwise false.
  */
 public function save($updateFingerPrint = true)
 {
     global $gCurrentOrganization, $gCurrentUser;
     if ($this->new_record) {
         $this->setValue('fil_timestamp', DATETIME_NOW);
         $this->setValue('fil_usr_id', $gCurrentUser->getValue('usr_id'));
     }
     return parent::save($updateFingerPrint);
 }
Beispiel #12
0
 /**
  * Save all changed columns of the recordset in table of database. Therefore the class remembers if it's
  * a new record or if only an update is necessary. The update statement will only update the changed columns.
  * If the table has columns for creator or editor than these column with their timestamp will be updated.
  * Saves also all roles that could see this date.
  * @param  bool $updateFingerPrint Default @b true. Will update the creator or editor of the recordset
  *                                 if table has columns like @b usr_id_create or @b usr_id_changed
  * @return bool
  */
 public function save($updateFingerPrint = true)
 {
     $this->db->startTransaction();
     parent::save($updateFingerPrint);
     if ($this->changeVisibleRoles) {
         // Sichbarkeit der Rollen wegschreiben
         if (!$this->new_record) {
             // erst einmal alle bisherigen Rollenzuordnungen loeschen, damit alles neu aufgebaut werden kann
             $sql = 'DELETE FROM ' . TBL_DATE_ROLE . ' WHERE dtr_dat_id = ' . $this->getValue('dat_id');
             $this->db->query($sql);
         }
         // nun alle Rollenzuordnungen wegschreiben
         $date_role = new TableAccess($this->db, TBL_DATE_ROLE, 'dtr');
         foreach ($this->visibleRoles as $roleID) {
             if (is_numeric($roleID)) {
                 if ($roleID > 0) {
                     $date_role->setValue('dtr_rol_id', $roleID);
                 }
                 $date_role->setValue('dtr_dat_id', $this->getValue('dat_id'));
                 $date_role->save();
                 $date_role->clear();
             }
         }
     }
     $this->changeVisibleRoles = false;
     $result = $this->db->endTransaction();
     return $result;
 }
Beispiel #13
0
 /**
  * Set a new value for a column of the database table if the column has the prefix @b usr_
  * otherwise the value of the profile field of the table adm_user_data will set.
  * If the user log is activated than the change of the value will be logged in @b adm_user_log.
  * The value is only saved in the object. You must call the method @b save to store the new value to the database
  * @param string $columnName The name of the database column whose value should get a new value or the
  *                            internal unique profile field name
  * @param mixed  $newValue   The new value that should be stored in the database field
  * @param bool   $checkValue The value will be checked if it's valid. If set to @b false than the value will
  *                            not be checked.
  * @return bool Returns @b true if the value is stored in the current object and @b false if a check failed
  * @par Examples
  * @code  // set data of adm_users column
  *                           $gCurrentUser->getValue('usr_login_name', 'Admidio');
  *                           // reads data of adm_user_fields
  *                           $gCurrentUser->getValue('EMAIL', '*****@*****.**'); @endcode
  */
 public function setValue($columnName, $newValue, $checkValue = true)
 {
     global $gCurrentUser, $gPreferences;
     $returnCode = true;
     $oldFieldValue = $this->mProfileFieldsData->getValue($columnName, 'database');
     if (strpos($columnName, 'usr_') !== 0) {
         // user data from adm_user_fields table
         // only to a update if value has changed
         if (strcmp($newValue, $oldFieldValue) !== 0) {
             // Disabled fields can only be edited by users with the right "edit_users" except on registration.
             // Here is no need to check hidden fields because we check on save() method that only users who
             // can edit the profile are allowed to save and change data.
             if ($this->mProfileFieldsData->getProperty($columnName, 'usf_disabled') == 0 || $this->mProfileFieldsData->getProperty($columnName, 'usf_disabled') == 1 && $gCurrentUser->hasRightEditProfile($this, false) || $gCurrentUser->getValue('usr_id') == 0 && $this->getValue('usr_id') == 0) {
                 $returnCode = $this->mProfileFieldsData->setValue($columnName, $newValue);
             }
         }
     } else {
         // users data from adm_users table
         $returnCode = parent::setValue($columnName, $newValue);
     }
     $newFieldValue = $this->mProfileFieldsData->getValue($columnName, 'database');
     // Nicht alle Aenderungen werden geloggt. Ausnahmen:
     // usr_id ist Null, wenn der User neu angelegt wird. Das wird bereits dokumentiert.
     // Felder, die mit usr_ beginnen, werden nicht geloggt
     // Falls die Feldwerte sich nicht geaendert haben, wird natuerlich ebenfalls nicht geloggt
     if ($gPreferences['profile_log_edit_fields'] == 1 && $this->getValue('usr_id') != 0 && strpos($columnName, 'usr_') === false && $newFieldValue !== $oldFieldValue && $returnCode === true) {
         $logEntry = new TableAccess($this->db, TBL_USER_LOG, 'usl');
         $logEntry->setValue('usl_usr_id', $this->getValue('usr_id'));
         $logEntry->setValue('usl_usf_id', $this->mProfileFieldsData->getProperty($columnName, 'usf_id'));
         $logEntry->setValue('usl_value_old', $oldFieldValue);
         $logEntry->setValue('usl_value_new', $newFieldValue);
         $logEntry->setValue('usl_comm', '');
         $logEntry->save();
     }
     return $returnCode;
 }
Beispiel #14
0
 /**
  * Save all changed columns of the recordset in table of database. Therefore the class remembers if it's
  * a new record or if only an update is necessary. The update statement will only update
  * the changed columns. If the table has columns for creator or editor than these column
  * with their timestamp will be updated.
  * For new records the name intern will be set per default.
  * @param bool $updateFingerPrint Default @b true. Will update the creator or editor of the recordset if table has columns like @b usr_id_create or @b usr_id_changed
  */
 public function save($updateFingerPrint = true)
 {
     global $gCurrentSession;
     $fields_changed = $this->columnsValueChanged;
     // if new field than generate new name intern, otherwise no change will be made
     if ($this->new_record == true) {
         $this->setValue('usf_name_intern', $this->getNewNameIntern($this->getValue('usf_name', 'database'), 1));
     }
     parent::save($updateFingerPrint);
     if ($fields_changed && is_object($gCurrentSession)) {
         // all active users must renew their user data because the user field structure has been changed
         $gCurrentSession->renewUserObject();
     }
 }
Beispiel #15
0
 /**
  * Save all changed columns of the recordset in table of database. Therefore the class remembers if it's
  * a new record or if only an update is necessary. The update statement will only update
  * the changed columns. If the table has columns for creator or editor than these column
  * with their timestamp will be updated.
  * The current organization will be set per default.
  * @param bool $updateFingerPrint Default @b true. Will update the creator or editor of the recordset if table has columns like @b usr_id_create or @b usr_id_changed
  * @return bool If an update or insert into the database was done then return true, otherwise false.
  */
 public function save($updateFingerPrint = true)
 {
     global $gCurrentOrganization;
     if ($this->new_record) {
         $this->setValue('pho_org_id', $gCurrentOrganization->getValue('org_id'));
     }
     return parent::save($updateFingerPrint);
 }