');
+
if (empty($default)) {
- $default = date('Y-m-d 12:00:00');
+ $default = api_get_local_time();
}
$parts = split(' ', $default);
+
list($d_year, $d_month, $d_day) = split('-', $parts[0]);
list($d_hour, $d_minute) = split(':', $parts[1]);
+
if ((int)$row['weight'] == 0) {
$form_folder -> addElement('checkbox', 'make_calification', null, get_lang('MakeQualifiable'), 'onclick="javascript: if(this.checked){document.getElementById(\'option3\').style.display = \'block\';}else{document.getElementById(\'option3\').style.display = \'none\';}"');
$form_folder -> addElement('html', '
');
@@ -517,7 +522,7 @@ function display_student_publications_list($work_dir, $sub_course_dir, $currentC
}
if ($homework['expires_on'] == '0000-00-00 00:00:00') {
- $homework['expires_on'] = date('Y-m-d H:i:s');
+ $homework['expires_on'] = api_get_local_time();
$there_is_a_expire_date = true;
$form_folder -> addElement('checkbox', 'enableExpiryDate',null,get_lang('EnableExpiryDate'), 'onclick="javascript: if(this.checked){document.getElementById(\'option1\').style.display = \'block\';}else{document.getElementById(\'option1\').style.display = \'none\';}"');
$form_folder -> addElement('html', '
');
@@ -525,7 +530,7 @@ function display_student_publications_list($work_dir, $sub_course_dir, $currentC
$form_folder -> addElement('html', '
');
}
if ($homework['ends_on'] == '0000-00-00 00:00:00') {
- $homework['ends_on'] = date('Y-m-d H:i:s');
+ $homework['ends_on'] = api_get_local_time();
$there_is_a_end_date = true;
$form_folder -> addElement('checkbox', 'enableEndDate', null, get_lang('EnableEndDate'), 'onclick="javascript: if(this.checked){document.getElementById(\'option2\').style.display = \'block\';}else{document.getElementById(\'option2\').style.display = \'none\';}"');
$form_folder -> addElement('html', '
');
@@ -534,19 +539,17 @@ function display_student_publications_list($work_dir, $sub_course_dir, $currentC
}
$form_folder -> addRule(array('expires', 'ends'), get_lang('DateExpiredNotBeLessDeadLine'), 'comparedate');
-
$form_folder -> addElement('html', '
');
}
$form_folder -> addElement('style_submit_button', 'submit', get_lang('ModifyDirectory'), 'class="save"');
- if ($there_is_a_end_date) {
- $end_date_array = convert_date_to_array($homework['ends_on'], 'ends');
+ if ($there_is_a_end_date) {
+ $end_date_array = convert_date_to_array($homework['ends_on'], 'ends');
$defaults = array_merge($defaults, $end_date_array);
}
if ($there_is_a_expire_date) {
$expires_date_array = convert_date_to_array($homework['expires_on'], 'expires');
$defaults = array_merge($defaults, $expires_date_array);
-
}
if (!empty($row['qualification'])) {
$defaults = array_merge($defaults, array('qualification[qualification]' => $row['qualification']));
@@ -579,12 +582,12 @@ function display_student_publications_list($work_dir, $sub_course_dir, $currentC
if ($row['view_properties'] == '1') {
$sql_add_publication = "UPDATE ".$work_table." SET has_properties = '".$row['has_properties']. "', view_properties=1 where id ='".$row['id']."'";
Database::query($sql_add_publication);
- $expires_query = ' SET expires_on = '."'".($there_is_a_expire_date ? get_date_from_group('expires') : '0000-00-00 00:00:00')."'".',';
- $ends_query = ' ends_on = '."'".($there_is_a_end_date ? get_date_from_group('ends') : '0000-00-00 00:00:00')."'";
+ $expires_query = ' SET expires_on = '."'".($there_is_a_expire_date ? api_get_utc_datetime(get_date_from_group('expires')) : '0000-00-00 00:00:00')."'".',';
+ $ends_query = ' ends_on = '."'".($there_is_a_end_date ? api_get_utc_datetime(get_date_from_group('ends')) : '0000-00-00 00:00:00')."'";
Database::query('UPDATE '.$work_assigment.$expires_query.$ends_query.' WHERE id = '."'".$row['has_properties']."'");
} elseif ($row['view_properties'] == '0') {
if ($_POST['enableExpiryDate'] == '1') {
- $expires_query = ' SET expires_on = '."'".($there_is_a_expire_date ? get_date_from_group('expires') : '0000-00-00 00:00:00')."'";
+ $expires_query = ' SET expires_on = '."'".($there_is_a_expire_date ? api_get_utc_datetime(get_date_from_group('expires')) : '0000-00-00 00:00:00')."'";
//$ends_query = ' ends_on = '."'".($there_is_a_end_date ? get_date_from_group('ends') : '0000-00-00 00:00:00')."'";
Database::query('UPDATE '.$work_assigment.$expires_query.' WHERE id = '."'".$row['has_properties']."'");
$sql_add_publication = "UPDATE ".$work_table." SET has_properties = '".$row['has_properties']. "', view_properties=1 where id ='".$row['id']."'";
@@ -592,7 +595,7 @@ function display_student_publications_list($work_dir, $sub_course_dir, $currentC
}
if ($_POST['enableEndDate'] == '1') {
//$expires_query = ' SET expires_on = '."'".($there_is_a_expire_date ? get_date_from_group('expires') : '0000-00-00 00:00:00')."'".',';
- $ends_query = ' SET ends_on = '."'".($there_is_a_end_date ? get_date_from_group('ends') : '0000-00-00 00:00:00')."'";
+ $ends_query = ' SET ends_on = '."'".($there_is_a_end_date ? api_get_utc_datetime(get_date_from_group('ends')) : '0000-00-00 00:00:00')."'";
Database::query('UPDATE '.$work_assigment.$ends_query.' WHERE id = '."'".$row['has_properties']."'");
$sql_add_publication = "UPDATE ".$work_table." SET has_properties = '".$row['has_properties']. "', view_properties=1 where id ='".$row['id']."'";
Database::query($sql_add_publication);
@@ -722,7 +725,7 @@ function display_student_publications_list($work_dir, $sub_course_dir, $currentC
}
if ($direc_date != '' && $direc_date != '0000-00-00 00:00:00') {
- $direc_date_local = api_get_local_time($direc_date, null, date_default_timezone_get());
+ $direc_date_local = api_get_local_time($direc_date);
$row[] = date_to_str_ago($direc_date_local).'
'.api_format_date($direc_date_local).'';
} else {
$direc_date_local = '0000-00-00 00:00:00';
@@ -784,14 +787,14 @@ function display_student_publications_list($work_dir, $sub_course_dir, $currentC
$row[] = '
'.build_document_icon_tag('file', substr(basename($work->url), 13)).'';
$row[] = '
'.$work->title.''.$work->description;
$row[] = display_user_link_work($row2['insert_user_id'], $work->author).$qualification_string; // $work->author;
-
- $work_sent_date_local = api_get_local_time($work->sent_date, null, date_default_timezone_get());
+
+ $work_sent_date_local = api_get_local_time($work->sent_date);
$row[] = date_to_str_ago($work_sent_date_local).$add_string.'
'.api_format_date($work_sent_date_local).'';
if ($is_allowed_to_edit) {
$action = '';
- $action .= '

';
+ $action .= '

';
$action .= '
'.Display::return_icon('delete.gif', get_lang('WorkDelete')).'';
$action .= '

';
if ($work->accepted == '1') {
diff --git a/main/work/work.php b/main/work/work.php
index 3ee4f38a48..ad103aeba7 100755
--- a/main/work/work.php
+++ b/main/work/work.php
@@ -535,14 +535,14 @@ if (!empty($_REQUEST['new_dir'])) {
require_once api_get_path(SYS_CODE_PATH).'calendar/agenda.inc.php';
require_once api_get_path(SYS_CODE_PATH).'resourcelinker/resourcelinker.inc.php';
$course = isset($course_info) ? $course_info : null;
- $date = date('Y-m-d H:i:s');
+ $date = api_get_utc_datetime();
$title = Security::remove_XSS($_POST['new_dir']);
if (!empty($_POST['type1'])) {
- $date = get_date_from_select('expires');
+ $date = api_get_utc_datetime(get_date_from_select('expires'));
$title = sprintf(get_lang('HandingOverOfTaskX'),Security::remove_XSS($_POST['new_dir']));
}
$content = '
'.Security::remove_XSS($_POST['new_dir']).' - '.Security::remove_XSS($_POST['description']);
- error_log($date);
+
$agenda_id = agenda_add_item($course, $title, $content, $date, $date, array('GROUP:'.$toolgroup), 0);
}
$sql_add_publication = "INSERT INTO " . $work_table . " SET " .
@@ -554,7 +554,7 @@ if (!empty($_REQUEST['new_dir'])) {
accepted = '1',
filetype = 'folder',
post_group_id = '".$toolgroup."',
- sent_date = NOW(),
+ sent_date = '".api_get_utc_datetime()."',
qualification = '".(($_POST['qualification_value']!='') ? Database::escape_string($_POST['qualification_value']) : '') ."',
parent_id = '',
qualificator_id = '',
@@ -582,8 +582,8 @@ if (!empty($_REQUEST['new_dir'])) {
$enable_calification = isset($_POST['enable_calification']) ? (int)$_POST['enable_calification'] : null;
$sql_add_homework = "INSERT INTO $TSTDPUBASG SET " .
- "expires_on = '".((isset($_POST['type1']) && $_POST['type1']==1) ? get_date_from_select('expires') : '0000-00-00 00:00:00'). "',
- ends_on = '".((isset($_POST['type2']) && $_POST['type2']==1) ? get_date_from_select('ends') : '0000-00-00 00:00:00')."',
+ "expires_on = '".((isset($_POST['type1']) && $_POST['type1']==1) ? api_get_utc_datetime(get_date_from_select('expires')) : '0000-00-00 00:00:00'). "',
+ ends_on = '".((isset($_POST['type2']) && $_POST['type2']==1) ? api_get_utc_datetime(get_date_from_select('ends')) : '0000-00-00 00:00:00')."',
add_to_calendar = '$agenda_id',
enable_qualification = '".$enable_calification."',
publication_id = '".$id."'";
@@ -595,7 +595,7 @@ if (!empty($_REQUEST['new_dir'])) {
} else {
$sql_add_homework = "INSERT INTO $TSTDPUBASG SET " .
- "expires_on = '0000-00-00 00:00:00',
+ "expires_on = '0000-00-00 00:00:00',
ends_on = '0000-00-00 00:00:00',
add_to_calendar = '$agenda_id',
enable_qualification = '".(isset($_POST['enable_calification'])?(int)$_POST['enable_calification']:'')."',
@@ -885,7 +885,7 @@ if ($ctok == $_POST['sec_token']) { //check the token inserted into the form
if (!Database::num_rows($result)) {
Database::query("ALTER TABLE " . $work_table . " ADD sent_date DATETIME NOT NULL");
}
- $current_date = date('Y-m-d H:i:s');
+ $current_date = api_get_utc_datetime();
$parent_id = '';
$active = '';
$user_id = api_get_user_id();
@@ -943,7 +943,7 @@ if ($ctok == $_POST['sec_token']) { //check the token inserted into the form
if (!Database::num_rows($result)) {
Database::query("ALTER TABLE " . $work_table . " ADD sent_date DATETIME NOT NULL");
}
- $current_date = date('Y-m-d H:i:s');
+ $current_date = api_get_utc_datetime();
$sql = "INSERT INTO " . $work_table . "
SET url = '" . $url . "',
title = '" . Database::escape_string($title) . "',
@@ -992,7 +992,7 @@ if ($ctok == $_POST['sec_token']) { //check the token inserted into the form
if($is_allowed_to_edit && ($_POST['qualification']!='')) {
$add_to_update = ',qualificator_id ='."'".api_get_user_id()."',";
$add_to_update .= 'qualification ='."'".Database::escape_string($_POST['qualification'])."',";
- $add_to_update .= 'date_of_qualification ='."'".date('Y-m-d H:i:s')."'";
+ $add_to_update .= 'date_of_qualification ='."'".api_get_utc_datetime()."'";
}
if ((int)$_POST['qualification'] > (int)$_POST['qualification_over']) {
@@ -1074,7 +1074,7 @@ if (!empty($_POST['submitWork']) && !empty($succeed) && !$id) {
$emailbody = get_lang('SendMailBody')."\n".get_lang('CourseName')." : ".$_course['name']."\n";
$emailbody .= get_lang('WorkName')." : ".substr($my_cur_dir_path, 0, -1)."\n";
$emailbody .= get_lang('UserName')." : ".$currentUserFirstName .' '.$currentUserLastName ."\n";
- $emailbody .= get_lang('DateSent')." : ".date('d/m/Y H:i')."\n";
+ $emailbody .= get_lang('DateSent')." : ".api_get_local_time()."\n";
$emailbody .= get_lang('FileName')." : ".$title."\n\n".get_lang('DownloadLink')."\n";
$emailbody .= api_get_path(WEB_CODE_PATH)."work/work.php?".api_get_cidreq()."&curdirpath=".$my_cur_dir_path."\n\n" . api_get_setting('administratorName') . " " . api_get_setting('administratorSurname') . "\n" . get_lang('Manager') . " " . api_get_setting('siteName') . "\n" . get_lang('Email') . " : " . api_get_setting('emailAdministrator');
// Here we are forming one large header line
@@ -1084,7 +1084,7 @@ if (!empty($_POST['submitWork']) && !empty($succeed) && !$id) {
$emailbody_user = get_lang('Dear')." ".$currentUserFirstName .' '.$currentUserLastName ."\n";
$emailbody_user .= get_lang('MessageConfirmSendingOfTask')."\n".get_lang('CourseName')." : ".$_course['name']."\n";
$emailbody_user .= get_lang('WorkName')." : ".substr($my_cur_dir_path, 0, -1)."\n";
- $emailbody_user .= get_lang('DateSent')." : ".date('d/m/Y H:i')."\n";
+ $emailbody_user .= get_lang('DateSent')." : ".api_get_local_time()."\n";
$emailbody_user .= get_lang('FileName')." : ".$title."\n\n".api_get_setting('administratorName')." ".api_get_setting('administratorSurname') . "\n" . get_lang('Manager') . " " . api_get_setting('siteName') . "\n" . get_lang('Email') . " : " . api_get_setting('emailAdministrator');;
//Mail to user
@@ -1125,15 +1125,18 @@ if ($is_special > 0) {
$has_expiry_date = true;
if ($homework['expires_on'] != '0000-00-00 00:00:00' || $homework['ends_on'] != '0000-00-00 00:00:00') {
- $time_now = convert_date_to_number(date('Y-m-d H:i:s'));
- $time_expires = convert_date_to_number($homework['expires_on']);
- $time_ends = convert_date_to_number($homework['ends_on']);
- $difference = $time_expires - $time_now;
- $difference2 = $time_ends - $time_now;
- if ($homework['expires_on'] != '0000-00-00 00:00:00' && $difference < 0) {
+ $time_now = convert_date_to_number(api_get_local_time());
+ $time_expires = convert_date_to_number(api_get_local_time($homework['expires_on']));
+ $time_ends = convert_date_to_number(api_get_local_time($homework['ends_on']));
+
+ $difference = $time_expires - $time_now;
+
+ $difference2 = $time_ends - $time_now;
+ if ($homework['expires_on'] != '0000-00-00 00:00:00' && $difference < 0) {
$has_expired = true;
}
if ($homework['ends_on'] != '0000-00-00 00:00:00' && $difference2 < 0) {
+
$has_ended = true;
}
if ($homework['expires_on'] == '0000-00-00 00:00:00') {
@@ -1143,8 +1146,8 @@ if ($is_special > 0) {
//@todo fix me
define('ASSIGNMENT_EXPIRES', $time_expires);
}
- $ends_on = api_convert_and_format_date($homework['ends_on'], null, date_default_timezone_get());
- $expires_on = api_convert_and_format_date($homework['expires_on'], null, date_default_timezone_get());
+ $ends_on = api_convert_and_format_date($homework['ends_on']);
+ $expires_on = api_convert_and_format_date($homework['expires_on']);
if ($has_ended) {
display_action_links($cur_dir_path, $always_show_tool_options, true);
@@ -1486,7 +1489,8 @@ function make_checkbox($name, $checked = '') {
function draw_date_picker($prefix, $default = '') {
//$default = 2008-10-01 10:00:00
if (empty($default)) {
- $default = date('Y-m-d H:i:s');
+ //$default = date('Y-m-d H:i:s');
+ $default = api_get_local_time();
}
$parts = split(' ', $default);
list($d_year, $d_month, $d_day) = split('-', $parts[0]);