events();
foreach ($events as $event) {
$event_date = substr($event['DTSTART'], 0, 8);
$event_month = substr($event['DTSTART'], 0, 6);
if ($event_month >= $this_month) {
$values['description'] = @$event['SUMMARY'];
$values['date'] = $event_date;
$date = date('Y-m-d', strtotime($event_date));
$date_check = '';
$filter['id_group'] = $values['id_group'];
$filter['date'] = $date;
$date_check = db_get_value_filter('date', 'talert_special_days', $filter);
if ($date_check == $date) {
if ($overwrite) {
$id_special_day = db_get_value_filter('id', 'talert_special_days', $filter);
alerts_update_alert_special_day($id_special_day, $values);
} else {
if ($skipped_dates == '') {
$skipped_dates = __('Skipped dates: ');
}
$skipped_dates .= $date.' ';
}
} else {
alerts_create_alert_special_day($date, $same_day, $values);
}
}
}
$result = true;
} else {
$result = false;
}
if ($result) {
db_pandora_audit('Special days list', 'Upload iCalendar '.$_FILES['ical_file']['name']);
}
ui_print_result_message($result, __('Success to upload iCalendar').'
'.$skipped_dates, __('Fail to upload iCalendar'));
}
if ($create_special_day) {
$date = (string) get_parameter('date');
$same_day = (string) get_parameter('same_day');
$values = [];
$values['id_group'] = (string) get_parameter('id_group');
$values['description'] = io_safe_input(strip_tags(io_safe_output((string) get_parameter('description'))));
$aviable_description = true;
if (preg_match('/script/i', $values['description'])) {
$aviable_description = false;
}
$array_date = explode('-', $date);
$year = $array_date[0];
$month = $array_date[1];
$day = $array_date[2];
if ($year == '*') {
// '0001' means every year.
$year = '0001';
$date = $year.'-'.$month.'-'.$day;
}
if (!checkdate($month, $day, $year)) {
$result = '';
} else {
$date_check = '';
$filter['id_group'] = $values['id_group'];
$filter['date'] = $date;
$date_check = db_get_value_filter('date', 'talert_special_days', $filter);
if ($date_check == $date) {
$result = '';
$messageAction = __('Could not be created, it already exists');
} else {
if ($aviable_description) {
$result = alerts_create_alert_special_day($date, $same_day, $values);
$info = '{"Date":"'.$date.'","Same day of the week":"'.$same_day.'","Description":"'.$values['description'].'"}';
} else {
$result = false;
}
}
}
if ($result) {
db_pandora_audit('Command management', 'Create special day '.$result, false, false, $info);
} else {
db_pandora_audit('Command management', 'Fail try to create special day', false, false);
}
// Show errors
if (!isset($messageAction)) {
$messageAction = __('Could not be created');
}
$messageAction = ui_print_result_message(
$result,
__('Successfully created'),
$messageAction
);
}
if ($update_special_day) {
$id = (int) get_parameter('id');
$alert = alerts_get_alert_special_day($id);
$date = (string) get_parameter('date');
$date_orig = (string) get_parameter('date_orig');
$same_day = (string) get_parameter('same_day');
$description = io_safe_input(strip_tags(io_safe_output((string) get_parameter('description'))));
$id_group = (string) get_parameter('id_group');
$id_group_orig = (string) get_parameter('id_group_orig');
$aviable_description = true;
if (preg_match('/script/i', $description)) {
$aviable_description = false;
}
$array_date = explode('-', $date);
$year = $array_date[0];
$month = $array_date[1];
$day = $array_date[2];
if ($year == '*') {
// '0001' means every year.
$year = '0001';
$date = $year.'-'.$month.'-'.$day;
}
$values = [];
$values['date'] = $date;
$values['id_group'] = $id_group;
$values['same_day'] = $same_day;
$values['description'] = $description;
if (!checkdate($month, $day, $year)) {
$result = '';
} else {
if ($id_group != $id_group_orig || $date != $date_orig) {
$date_check = '';
$filter['id_group'] = $id_group;
$filter['date'] = $date;
$date_check = db_get_value_filter('date', 'talert_special_days', $filter);
if ($date_check == $date) {
$result = '';
$messageAction = __('Could not be updated, it already exists');
} else {
if ($aviable_description !== false) {
$result = alerts_update_alert_special_day($id, $values);
$info = '{"Date":"'.$date.'","Same day of the week":"'.$same_day.'","Description":"'.$description.'"}';
}
}
} else {
if ($aviable_description !== false) {
$result = alerts_update_alert_special_day($id, $values);
$info = '{"Date":"'.$date.'","Same day of the week":"'.$same_day.'","Description":"'.$description.'"}';
}
}
}
if ($result) {
db_pandora_audit('Command management', 'Update special day '.$id, false, false, $info);
} else {
db_pandora_audit('Command management', 'Fail to update special day '.$id, false, false);
}
// Show errors
if (!isset($messageAction)) {
$messageAction = __('Could not be updated');
}
$messageAction = ui_print_result_message(
$result,
__('Successfully updated'),
$messageAction
);
}
if ($delete_special_day) {
$id = (int) get_parameter('id');
$result = alerts_delete_alert_special_day($id);
if ($result) {
db_pandora_audit('Command management', 'Delete special day '.$id);
} else {
db_pandora_audit('Command management', 'Fail to delete special day '.$id);
}
ui_print_result_message(
$result,
__('Successfully deleted'),
__('Could not be deleted')
);
}
echo "
".__('Display range: '); if ($display_range) { $html .= '['.__('Default').'] '; if ($display_range > 1970) { $html .= '<< '; } $html .= '['.$display_range.']'; $html .= ' >>'; } else { $html .= '['.__('Default').'] '; $html .= '<< '; $html .= '['; $html .= $this_year; $html .= ']'; $html .= ' >>'; } $html .= ' |