/** * Creates a valid date format @b YYYY-MM-DD for the SQL statement * @param string $date The unformated date from user input e.g. @b 12.04.2012 * @param string $operator The actual operator for the @b date parameter * @return string String with a SQL valid date format @b YYYY-MM-DD */ private function getFormatDate($date, $operator) { global $gPreferences; $formatDate = ''; // if last char is Y or J then user searches for age $last = substr($date, -1); $last = admStrToUpper($last); if ($last === 'J' || $last === 'Y') { $age = (int) substr($date, 0, -1); $date = new DateTimeExtended(date('Y') . '-' . date('m') . '-' . date('d'), 'Y-m-d', 'date'); $ageCondition = ''; switch ($operator) { case '=': // first remove = from destination condition $this->mDestCond = substr($this->mDestCond, 0, strlen($this->mDestCond) - 4); // now compute the dates for a valid birthday with that age $date->modify('-' . $age . ' years'); $dateTo = $date->format('Y-m-d'); $date->modify('-1 year'); $date->modify('+1 day'); $dateFrom = $date->format('Y-m-d'); $ageCondition = ' BETWEEN \'' . $dateFrom . '\' AND \'' . $dateTo . '\''; $this->mOpenQuotes = false; break; case '}': // search for dates that are older than the age // because the age itself takes 1 year we must add 1 year and 1 day to age $date->modify('-' . ($age + 1) . ' years'); $date->modify('+1 day'); $ageCondition = $date->format('Y-m-d'); break; case '{': // search for dates that are younger than the age // we must add 1 day to the date because the day itself belongs to the age $date->modify('-' . $age . ' years'); $date->modify('+1 day'); $ageCondition = $date->format('Y-m-d'); break; } return $ageCondition; } // validate date and return it in database format if ($date !== '') { $date = new DateTimeExtended($date, $gPreferences['system_date']); if ($date->isValid()) { $formatDate = $date->format('Y-m-d'); } } return $formatDate; }
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2.0 only * * Parameters: * * usr_id : If set only show the profile field history of that user * filter_date_from : is set to actual date, * if no date information is delivered * filter_date_to : is set to 31.12.9999, * if no date information is delivered *********************************************************************************************** */ require_once '../../system/common.php'; require_once '../../system/login_valid.php'; // calculate default date from which the profile fields history should be shown $filterDateFrom = new DateTimeExtended(DATE_NOW, 'Y-m-d'); $filterDateFrom->modify('-' . $gPreferences['members_days_field_history'] . ' day'); // Initialize and check the parameters $getUserId = admFuncVariableIsValid($_GET, 'usr_id', 'int'); $getDateFrom = admFuncVariableIsValid($_GET, 'filter_date_from', 'date', array('defaultValue' => $filterDateFrom->format($gPreferences['system_date']))); $getDateTo = admFuncVariableIsValid($_GET, 'filter_date_to', 'date', array('defaultValue' => DATE_NOW)); // create a user object from the user parameter $user = new User($gDb, $gProfileFields, $getUserId); // set headline of the script if ($getUserId > 0) { $headline = $gL10n->get('MEM_CHANGE_HISTORY_OF', $user->getValue('FIRST_NAME') . ' ' . $user->getValue('LAST_NAME')); } else { $headline = $gL10n->get('MEM_CHANGE_HISTORY'); } // Initialize local parameteres $sqlConditions = ''; // if profile log is activated and current user is allowed to edit users