Update Basic, DB IO, Login class
- DB IO: update the write data method to update data that is empty (aka null) and not skip it (aka never unset data) - Basic: add date time compare method based on strtotime - Login: ACL for page level check if array is set before setting anything
This commit is contained in:
@@ -54,6 +54,7 @@
|
||||
* GenAssocArray -> generactes a new associativ array from an existing array
|
||||
* CheckDate -> checks if a date is valid
|
||||
* CompareDate -> compares two dates. -1 if the first is smaller, 0 if they are equal, 1 if the first is bigger
|
||||
* CompareDateTime -> compares two dates with time. -1 if the first is smaller, 0 if they are equal, 1 if the first is bigger
|
||||
* _crc32b -> behaves like the hash("crc32b") in php < 5.2.8. this function will flip the hash like it was (wrong)
|
||||
* before if a new php version is found
|
||||
* crypt* -> encrypt and decrypt login string data, used by Login class
|
||||
@@ -1274,6 +1275,25 @@
|
||||
return 1;
|
||||
}
|
||||
|
||||
// METHOD: CompareDateTime
|
||||
// PARAMS: start_datetime, end_datetime (both YYYY-MM-DD HH:mm:ss)
|
||||
// RETURN: -1 if the first date is smaller the last, 0 if both are equal, 1 if the end date is bigger than the last
|
||||
// DESC : compares the two dates + times. if seconds missing in one set, add :00, converts / to -
|
||||
public static function CompareDateTime($start_datetime, $end_datetime)
|
||||
{
|
||||
// pre check for empty or wrong
|
||||
if ($start_date == '--' || $end_date == '--' || !$start_date || !$end_date)
|
||||
return FALSE;
|
||||
$start_timestamp = strtotime($start_datetime);
|
||||
$end_timestamp = strtotime($end_datetime);
|
||||
if ($start_timestamp < $end_timestamp)
|
||||
return -1;
|
||||
if ($start_timestamp == $end_timestamp)
|
||||
return 0;
|
||||
if ($start_timestamp > $end_timestamp)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// METHOD: ArrayToString
|
||||
// PARAMS: array, connect char
|
||||
// RETRUN: string
|
||||
|
||||
@@ -1667,7 +1667,13 @@ $this->debug('ExecuteData', 'ERROR in STM['.$stm_name.'|'.$this->prepare_cursor[
|
||||
// DESC: writes into one table based on array of table columns
|
||||
public function db_write_data($write_array, $not_write_array, $primary_key, $table, $data = array ())
|
||||
{
|
||||
$not_write_upodate_array = array ();
|
||||
if (!is_array($write_array))
|
||||
$write_array = array ();
|
||||
if (!is_array($not_write_array))
|
||||
$not_write_array = array ();
|
||||
if (is_array($table))
|
||||
return false;
|
||||
$not_write_update_array = array ();
|
||||
return $this->db_write_data_ext($write_array, $primary_key, $table, $not_write_array, $not_write_update_array, $data);
|
||||
}
|
||||
|
||||
@@ -1691,7 +1697,9 @@ $this->debug('ExecuteData', 'ERROR in STM['.$stm_name.'|'.$this->prepare_cursor[
|
||||
'value' => $primary_key
|
||||
);
|
||||
}
|
||||
|
||||
// var set for strings
|
||||
$q_sub_value = '';
|
||||
$q_sub_data = '';
|
||||
// get the table layout and row types
|
||||
$table_data = $this->db_show_table_meta_data(($this->db_schema ? $this->db_schema.'.' : '').$table);
|
||||
foreach ($write_array as $field)
|
||||
@@ -1705,7 +1713,7 @@ $this->debug('ExecuteData', 'ERROR in STM['.$stm_name.'|'.$this->prepare_cursor[
|
||||
// we detect bool, so we can force a write on "false"
|
||||
$is_bool = $table_data[$field]['type'] == 'bool' ? true : false;
|
||||
// write if the field has to be not null, or if there is no data and the field has no default values or if there is data
|
||||
if (($not_null && !$_data) || (!$has_default && !$_data) || ($is_bool && !$_data) || (is_numeric($_data) && isset($_data)) || $_data)
|
||||
if (($not_null && !$_data) || (!$has_default && !$_data) || ($is_bool && !$_data) || (is_numeric($_data) && isset($_data)) || ($primary_key['value'] && !$_data) || $_data)
|
||||
{
|
||||
if ($q_sub_value && !$primary_key['value'])
|
||||
$q_sub_value .= ', ';
|
||||
|
||||
@@ -581,7 +581,7 @@
|
||||
{
|
||||
$this->acl['page'] = $_SESSION['GROUP_ACL_LEVEL'];
|
||||
}
|
||||
if ($_SESSION['PAGES_ACL_LEVEL'][$this->page_name] != -1)
|
||||
if (isset($_SESSION['PAGES_ACL_LEVEL'][$this->page_name]) && $_SESSION['PAGES_ACL_LEVEL'][$this->page_name] != -1)
|
||||
{
|
||||
$this->acl['page'] = $_SESSION['PAGES_ACL_LEVEL'][$this->page_name];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user