예제 #1
0
 /**
  * Set a new value for a column of the database table.
  * 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
  * @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
  */
 public function setValue($columnName, $newValue, $checkValue = true)
 {
     if ($columnName === 'room_description') {
         return parent::setValue($columnName, $newValue, false);
     }
     return parent::setValue($columnName, $newValue, $checkValue);
 }
예제 #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);
 }
예제 #3
0
 /**
  * Deletes the selected item of the table and all the many references in other tables.
  * After that the class will be initialize.
  * @return bool @b true if no error occurred
  */
 public function delete()
 {
     $this->db->startTransaction();
     $sql = 'DELETE FROM ' . TBL_INVENT_DATA . ' WHERE ind_itm_id = ' . $this->getValue('inv_id');
     $this->db->query($sql);
     $return = parent::delete();
     $this->db->endTransaction();
     return $return;
 }
예제 #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;
 }
예제 #5
0
 /**
  * Set a new value for a column of the database table.
  * 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
  * @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
  */
 public function setValue($columnName, $newValue, $checkValue = true)
 {
     if ($columnName === 'lnk_url' && $newValue !== '') {
         // Homepage darf nur gueltige Zeichen enthalten
         if (!strValidCharacters($newValue, 'url')) {
             return false;
         }
         // Homepage noch mit http vorbelegen
         if (strpos(admStrToLower($newValue), 'http://') === false && strpos(admStrToLower($newValue), 'https://') === false) {
             $newValue = 'http://' . $newValue;
         }
     } elseif ($columnName === 'lnk_description') {
         return parent::setValue($columnName, $newValue, false);
     }
     return parent::setValue($columnName, $newValue, $checkValue);
 }
예제 #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.
  * 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);
 }
예제 #7
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);
 }
예제 #8
0
 /**
  * Set a new value for a column of the database table.
  * 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
  * @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
  */
 public function setValue($columnName, $newValue, $checkValue = true)
 {
     // encode Password with phpAss
     if (($columnName === 'usr_password' || $columnName === 'usr_new_password') && strlen($newValue) < 30) {
         $checkValue = false;
         $passwordHasher = new PasswordHash(9, true);
         // only use private hash because of compatibility
         $newValue = $passwordHasher->HashPassword($newValue);
     } elseif ($columnName === 'usr_login_name') {
         if ($newValue === '' || !strValidCharacters($newValue, 'noSpecialChar')) {
             return false;
         }
     }
     return parent::setValue($columnName, $newValue, $checkValue);
 }
예제 #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.
  *  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('pho_org_shortname', $gCurrentOrganization->getValue('org_shortname'));
     }
     parent::save($updateFingerPrint);
 }
예제 #10
0
 /**
  * Set a new value for a column of the database table.
  * 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
  * @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
  */
 public function setValue($columnName, $newValue, $checkValue = true)
 {
     // name, category and type couldn't be edited if it's a system field
     if (($columnName === 'inf_name' || $columnName === 'inf_cat_id' || $columnName === 'inf_type') && $this->getValue('inf_system') == 1) {
         return false;
     } elseif ($columnName === 'inf_cat_id' && $this->getValue($columnName) != $newValue) {
         // erst einmal die hoechste Reihenfolgennummer der Kategorie ermitteln
         $sql = 'SELECT COUNT(*) as count
                   FROM ' . TBL_INVENT_FIELDS . '
                  WHERE inf_cat_id = ' . $newValue;
         $pdoStatement = $this->db->query($sql);
         $row = $pdoStatement->fetch();
         $this->setValue('inf_sequence', $row['count'] + 1);
     } elseif ($columnName === 'inf_description') {
         return parent::setValue($columnName, $newValue, false);
     }
     return parent::setValue($columnName, $newValue, $checkValue);
 }
예제 #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);
 }
예제 #12
0
 /**
  * Set a new value for a password column of the database table.
  * 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 $newPassword   The new value that should be stored in the database field
  * @param bool   $isNewPassword Should the column password or new_password be set
  * @param bool   $doHashing     Should the password get hashed before inserted. Default is true
  * @return bool Returns @b true if the value is stored in the current object and @b false if a check failed
  */
 public function setPassword($newPassword, $isNewPassword = false, $doHashing = true)
 {
     global $gPreferences;
     $columnName = 'usr_password';
     if ($isNewPassword) {
         $columnName = 'usr_new_password';
     }
     if ($doHashing) {
         // get the saved cost value that fits your server performance best and rehash your password
         $cost = 10;
         if (isset($gPreferences['system_hashing_cost'])) {
             $cost = intval($gPreferences['system_hashing_cost']);
         }
         $newPassword = PasswordHashing::hash($newPassword, PASSWORD_DEFAULT, array('cost' => $cost));
     }
     return parent::setValue($columnName, $newPassword, false);
 }
예제 #13
0
 /**
  * Set the database object for communication with the database of this class.
  * @param object $database An object of the class Database. This should be the global $gDb object.
  */
 public function setDatabase(&$database)
 {
     parent::setDatabase($database);
     if (is_object($this->mAutoLogin)) {
         $this->mAutoLogin->setDatabase($database);
     }
 }
예제 #14
0
 /**
  * Constructor that will create an object of a recordset of the table adm_component.
  * If the id is set than the specific component will be loaded.
  * @param object $database Object of the class Database. This should be the default global object @b $gDb.
  * @param int    $com_id         The recordset of the component with this id will be loaded.
  *                                   If com_id isn't set than an empty object of the table is created.
  */
 public function __construct(&$database, $com_id = 0)
 {
     parent::__construct($database, TBL_COMPONENTS, 'com', $com_id);
 }
예제 #15
0
 /** Constructor that will create an object of a recordset of the table adm_messages.
  *  If the id is set than the specific message will be loaded.
  *  @param $db Object of the class database. This should be the default object $gDb.
  *  @param $msg_converation_id The recordset of the message with this conversation id will be loaded. If id isn't set than an empty object of the table is created.
  */
 public function __construct(&$db, $msg_id = 0)
 {
     $this->msg_id = $msg_id;
     parent::__construct($db, TBL_MESSAGES, 'msg', $this->msg_id);
 }
예제 #16
0
 /**
  * Set a new value for a column of the database table.
  * 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
  * @param        $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
  */
 public function setValue($columnName, $newValue, $checkValue = true)
 {
     if ($newValue !== '') {
         if ($columnName === 'gbc_email') {
             $newValue = admStrToLower($newValue);
             if (!strValidCharacters($newValue, 'email')) {
                 // falls die Email ein ungueltiges Format aufweist wird sie nicht gesetzt
                 return false;
             }
         }
     }
     if ($columnName === 'gbc_text') {
         return parent::setValue($columnName, $newValue, false);
     }
     return parent::setValue($columnName, $newValue, $checkValue);
 }
예제 #17
0
 /**
  * Set a new value for a column of the database table. 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
  * @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
  */
 public function setValue($columnName, $newValue, $checkValue = true)
 {
     global $gCurrentOrganization;
     if ($columnName === 'rol_default_registration' && $newValue == '0' && $this->dbColumns[$columnName] == '1') {
         // checks if at least one other role has this flag
         $sql = 'SELECT COUNT(*) AS count
                   FROM ' . TBL_ROLES . '
             INNER JOIN ' . TBL_CATEGORIES . '
                     ON cat_id = rol_cat_id
                  WHERE rol_default_registration = 1
                    AND rol_id    <> ' . $this->getValue('rol_id') . '
                    AND cat_org_id = ' . $gCurrentOrganization->getValue('org_id');
         $countRolesStatement = $this->db->query($sql);
         $row = $countRolesStatement->fetch();
         if ($row['count'] === 0) {
             return false;
         }
     }
     return parent::setValue($columnName, $newValue, $checkValue);
 }
예제 #18
0
 /**
  * Set a new value for a column of the database table.
  * 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
  * @param        $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
  */
 public function setValue($columnName, $newValue, $checkValue = true)
 {
     if ($newValue !== '') {
         if ($columnName === 'gbo_email') {
             $newValue = admStrToLower($newValue);
             if (!strValidCharacters($newValue, 'email')) {
                 // falls die Email ein ungueltiges Format aufweist wird sie nicht gesetzt
                 return false;
             }
         } elseif ($columnName === 'gbo_homepage') {
             // Homepage darf nur gueltige Zeichen enthalten
             if (!strValidCharacters($newValue, 'url')) {
                 return false;
             }
             // Homepage noch mit http vorbelegen
             if (strpos(admStrToLower($newValue), 'http://') === false && strpos(admStrToLower($newValue), 'https://') === false) {
                 $newValue = 'http://' . $newValue;
             }
         }
     }
     if ($columnName === 'gbo_text') {
         return parent::setValue($columnName, $newValue, false);
     }
     return parent::setValue($columnName, $newValue, $checkValue);
 }
예제 #19
0
 /**
  * Set a new value for a column of the database table.
  * 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
  * @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
  */
 public function setValue($columnName, $newValue, $checkValue = true)
 {
     // name, category and type couldn't be edited if it's a system field
     if (($columnName === 'usf_cat_id' || $columnName === 'usf_type' || $columnName === 'usf_name') && $this->getValue('usf_system') == 1) {
         return false;
     } elseif ($columnName === 'usf_cat_id' && $this->getValue($columnName) !== $newValue) {
         // erst einmal die hoechste Reihenfolgennummer der Kategorie ermitteln
         $sql = 'SELECT COUNT(*) as count FROM ' . TBL_USER_FIELDS . '
                  WHERE usf_cat_id = ' . $newValue;
         $countUserFieldsStatement = $this->db->query($sql);
         $row = $countUserFieldsStatement->fetch();
         $this->setValue('usf_sequence', $row['count'] + 1);
     } elseif ($columnName === 'usf_description') {
         return parent::setValue($columnName, $newValue, false);
     } elseif ($columnName === 'usf_url' && $newValue !== '') {
         // Homepage darf nur gueltige Zeichen enthalten
         if (!strValidCharacters($newValue, 'url')) {
             return false;
         }
         // Homepage noch mit http vorbelegen
         if (strpos(admStrToLower($newValue), 'http://') === false && strpos(admStrToLower($newValue), 'https://') === false) {
             $newValue = 'http://' . $newValue;
         }
     }
     return parent::setValue($columnName, $newValue, $checkValue);
 }
예제 #20
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;
 }
예제 #21
0
 /**
  * Set a new value for a column of the database table.
  * 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
  * @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
  */
 public function setValue($columnName, $newValue, $checkValue = true)
 {
     if ($columnName === 'dat_end' && $this->getValue('dat_all_day') == 1) {
         // hier muss bei ganztaegigen Terminen das bis-Datum um einen Tag hochgesetzt werden
         // damit der Termin bei SQL-Abfragen richtig beruecksichtigt wird
         list($year, $month, $day, $hour, $minute, $second) = preg_split('/[- :]/', $newValue);
         $newValue = date('Y-m-d H:i:s', mktime($hour, $minute, $second, $month, $day, $year) + 86400);
     } elseif ($columnName === 'dat_description') {
         return parent::setValue($columnName, $newValue, false);
     }
     return parent::setValue($columnName, $newValue, $checkValue);
 }
예제 #22
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);
 }
예제 #23
0
 /**
  * Set a new value for a column of the database table.
  * 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
  * @param         $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
  */
 public function setValue($columnName, $newValue, $checkValue = true)
 {
     // org_shortname shouldn't be edited
     if ($columnName == 'org_shortname' && $this->new_record == false) {
         return false;
     } elseif ($columnName == 'org_homepage' && $newValue !== '') {
         // Homepage darf nur gueltige Zeichen enthalten
         if (!strValidCharacters($newValue, 'url')) {
             return false;
         }
         // Homepage noch mit http vorbelegen
         if (strpos(admStrToLower($newValue), 'http://') === false && strpos(admStrToLower($newValue), 'https://') === false) {
             $newValue = 'http://' . $newValue;
         }
     }
     return parent::setValue($columnName, $newValue, $checkValue);
 }
예제 #24
0
 /**
  * Set a new value for a column of the database table.
  * 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
  * @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
  */
 public function setValue($columnName, $newValue, $checkValue = true)
 {
     global $gCurrentOrganization;
     // Systemkategorien duerfen nicht umbenannt werden
     if ($columnName === 'cat_name' && $this->getValue('cat_system') == 1) {
         return false;
     } elseif ($columnName === 'cat_default' && $newValue == '1') {
         // es darf immer nur eine Default-Kategorie je Bereich geben
         $sql = 'UPDATE ' . TBL_CATEGORIES . ' SET cat_default = 0
                  WHERE cat_type = \'' . $this->getValue('cat_type') . '\'
                    AND (  cat_org_id IS NOT NULL
                        OR cat_org_id = ' . $gCurrentOrganization->getValue('org_id') . ')';
         $this->db->query($sql);
     }
     return parent::setValue($columnName, $newValue, $checkValue);
 }
예제 #25
0
 /**
  * Deletes the selected message with all associated fields.
  * After that the class will be initialize.
  * @return bool @b true if message is deleted or message with additional information if it is marked
  *         for other user to delete. On error it is false
  */
 public function delete()
 {
     global $gCurrentUser;
     $this->db->startTransaction();
     if ($this->getValue('msg_read') == 2 || $this->getValue('msg_type') === 'EMAIL') {
         $sql = 'DELETE FROM ' . TBL_MESSAGES_CONTENT . '
          WHERE msc_msg_id = ' . $this->getValue('msg_id');
         $this->db->query($sql);
         parent::delete();
     } else {
         $other = $this->getValue('msg_usr_id_sender');
         if ($other == $gCurrentUser->getValue('usr_id')) {
             $other = $this->getValue('msg_usr_id_receiver');
         }
         $sql = "UPDATE " . TBL_MESSAGES . " SET msg_read = 2, msg_timestamp = CURRENT_TIMESTAMP\n                                                , msg_usr_id_sender = " . $gCurrentUser->getValue('usr_id') . ", msg_usr_id_receiver = '" . $other . "'\n             WHERE msg_id = " . $this->getValue('msg_id');
         $this->db->query($sql);
     }
     $this->db->endTransaction();
     return true;
 }