コード例 #1
0
ファイル: tablerooms.php プロジェクト: sistlind/admidio
 /**
  * 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
ファイル: tableweblink.php プロジェクト: sistlind/admidio
 /**
  * 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);
 }
コード例 #3
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);
 }
コード例 #4
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);
 }
コード例 #5
0
ファイル: tableroles.php プロジェクト: martinbrylski/admidio
 /**
  * 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);
 }
コード例 #6
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);
 }
コード例 #7
0
ファイル: organization.php プロジェクト: bash-t/admidio
 /**
  * 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);
 }
コード例 #8
0
ファイル: tabledate.php プロジェクト: sistlind/admidio
 /**
  * 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);
 }
コード例 #9
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;
 }
コード例 #10
0
ファイル: tableusers.php プロジェクト: bash-t/admidio
 /**
  * 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);
 }
コード例 #11
0
ファイル: tableguestbook.php プロジェクト: sistlind/admidio
 /**
  * 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);
 }
コード例 #12
0
ファイル: tableuserfield.php プロジェクト: sistlind/admidio
 /**
  * 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);
 }
コード例 #13
0
ファイル: tableusers.php プロジェクト: martinbrylski/admidio
 /**
  * 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);
 }