Selaa lähdekoodia

WIP: Fix mysql 5.7 dates with "0000-00-00 00:00:00" values see #8200

jmontoyaa 8 vuotta sitten
vanhempi
commit
f2e496009e
34 muutettua tiedostoa jossa 188 lisäystä ja 150 poistoa
  1. 53 3
      app/Migrations/Schema/V111/Version111.php
  2. 1 1
      main/admin/ldap_synchro.php
  3. 1 1
      main/auth/external_login/functions.inc.php
  4. 1 1
      main/auth/external_login/ldap.inc.php
  5. 1 1
      main/auth/ldap/authldap.php
  6. 3 3
      main/coursecopy/classes/CourseRestorer.class.php
  7. 2 2
      main/coursecopy/classes/DummyCourseCreator.class.php
  8. 2 2
      main/glossary/index.php
  9. 5 5
      main/inc/ajax/course_home.ajax.php
  10. 15 15
      main/inc/lib/agenda.lib.php
  11. 4 5
      main/inc/lib/exercise.lib.php
  12. 4 0
      main/inc/lib/internationalization.lib.php
  13. 4 6
      main/inc/lib/message.lib.php
  14. 5 5
      main/inc/lib/statistics.lib.php
  15. 1 1
      main/inc/lib/thematic.lib.php
  16. 1 1
      main/inc/lib/tracking.lib.php
  17. 8 10
      main/newscorm/learnpath.class.php
  18. 8 8
      main/newscorm/learnpathList.class.php
  19. 4 4
      main/newscorm/lp_edit.php
  20. 4 6
      main/newscorm/lp_list.php
  21. 1 1
      main/session/index.php
  22. 25 27
      main/wiki/wiki.inc.php
  23. 6 6
      src/Chamilo/CoreBundle/Entity/AccessUrl.php
  24. 0 2
      src/Chamilo/CoreBundle/Entity/ExtraFieldOptions.php
  25. 1 1
      src/Chamilo/CoreBundle/Entity/Message.php
  26. 2 2
      src/Chamilo/CoreBundle/Entity/SysCalendar.php
  27. 1 1
      src/Chamilo/CoreBundle/Entity/TrackEAttempt.php
  28. 9 11
      src/Chamilo/CoreBundle/Entity/TrackEAttemptRecording.php
  29. 0 1
      src/Chamilo/CoreBundle/Entity/TrackECourseAccess.php
  30. 1 1
      src/Chamilo/CoreBundle/Entity/TrackEDefault.php
  31. 9 11
      src/Chamilo/CoreBundle/Entity/TrackEDownloads.php
  32. 2 2
      src/Chamilo/CourseBundle/Entity/CCalendarEvent.php
  33. 2 2
      src/Chamilo/CourseBundle/Entity/CWiki.php
  34. 2 2
      src/Chamilo/CourseBundle/Entity/CWikiConf.php

+ 53 - 3
app/Migrations/Schema/V111/Version111.php

@@ -65,21 +65,71 @@ class Version111 extends AbstractMigrationChamilo
 
         $this->addSql('ALTER TABLE notification CHANGE content content TEXT');
 
+        // Needed to update 0000-00-00 00:00:00 values
+        $this->addSql('SET sql_mode = ""');
+
+        $this->addSql('UPDATE c_lp SET publicated_on = NULL WHERE publicated_on = "0000-00-00 00:00:00"');
+        $this->addSql('UPDATE c_lp SET expired_on = NULL WHERE expired_on = "0000-00-00 00:00:00"');
+
         $this->addSql('ALTER TABLE c_lp CHANGE publicated_on publicated_on DATETIME');
         $this->addSql('ALTER TABLE c_lp CHANGE expired_on expired_on DATETIME');
 
-        $this->addSql('UPDATE TABLE c_quiz SET start_time = "" WHERE start_time = "0000-00-00 00:00:00"');
-        $this->addSql('UPDATE TABLE c_quiz SET end_time = "" WHERE end_time = "0000-00-00 00:00:00"');
+        $this->addSql('UPDATE c_quiz SET start_time = NULL WHERE start_time = "0000-00-00 00:00:00"');
+        $this->addSql('UPDATE c_quiz SET end_time = NULL WHERE end_time = "0000-00-00 00:00:00"');
 
         $this->addSql('ALTER TABLE c_quiz CHANGE start_time start_time DATETIME');
         $this->addSql('ALTER TABLE c_quiz CHANGE end_time end_time DATETIME');
 
+        $this->addSql('UPDATE c_calendar_event SET start_date = NULL WHERE start_date = "0000-00-00 00:00:00"');
+        $this->addSql('UPDATE c_calendar_event SET end_date = NULL WHERE end_date = "0000-00-00 00:00:00"');
+
+        $this->addSql('ALTER TABLE c_calendar_event CHANGE start_date start_date DATETIME');
+        $this->addSql('ALTER TABLE c_calendar_event CHANGE end_date end_date DATETIME');
+
+        $this->addSql('UPDATE personal_agenda SET date = NULL WHERE date = "0000-00-00 00:00:00"');
+        $this->addSql('UPDATE personal_agenda SET enddate = NULL WHERE enddate = "0000-00-00 00:00:00"');
+
+        $this->addSql('ALTER TABLE personal_agenda CHANGE date date DATETIME');
+        $this->addSql('ALTER TABLE personal_agenda CHANGE enddate enddate DATETIME');
+
+        $this->addSql('UPDATE c_forum_forum SET start_time = NULL WHERE start_time = "0000-00-00 00:00:00"');
+        $this->addSql('UPDATE c_forum_forum SET end_time = NULL WHERE end_time = "0000-00-00 00:00:00"');
+
         $this->addSql('ALTER TABLE c_forum_forum CHANGE start_time start_time DATETIME');
         $this->addSql('ALTER TABLE c_forum_forum CHANGE end_time end_time DATETIME');
 
-        $this->addSql('ALTER TABLE track_e_exercises CHANGE expired_time_control expired_time_control DATETIME');
+        $this->addSql('UPDATE sys_calendar SET start_date = NULL WHERE start_date = "0000-00-00 00:00:00"');
+        $this->addSql('UPDATE sys_calendar SET end_date = NULL WHERE end_date = "0000-00-00 00:00:00"');
+
+        $this->addSql('ALTER TABLE sys_calendar CHANGE start_date start_date DATETIME');
+        $this->addSql('ALTER TABLE sys_calendar CHANGE end_date end_date DATETIME');
 
+        $this->addSql('UPDATE message SET update_date = NULL WHERE update_date = "0000-00-00 00:00:00"');
+        $this->addSql('ALTER TABLE message CHANGE update_date update_date DATETIME');
 
+        $this->addSql('UPDATE c_wiki_conf SET startdate_assig = NULL WHERE startdate_assig = "0000-00-00 00:00:00"');
+        $this->addSql('UPDATE c_wiki_conf SET enddate_assig = NULL WHERE enddate_assig = "0000-00-00 00:00:00"');
+
+        $this->addSql('ALTER TABLE c_wiki_conf CHANGE startdate_assig startdate_assig DATETIME');
+        $this->addSql('ALTER TABLE c_wiki_conf CHANGE enddate_assig enddate_assig DATETIME');
+
+        $this->addSql('UPDATE c_wiki SET time_edit = NULL WHERE time_edit = "0000-00-00 00:00:00"');
+        $this->addSql('ALTER TABLE c_wiki CHANGE time_edit time_edit DATETIME');
+
+        $this->addSql('UPDATE c_wiki SET dtime = NULL WHERE dtime = "0000-00-00 00:00:00"');
+        $this->addSql('ALTER TABLE c_wiki CHANGE dtime dtime DATETIME');
+
+        $this->addSql('UPDATE access_url SET tms = NULL WHERE tms = "0000-00-00 00:00:00"');
+        $this->addSql('ALTER TABLE access_url CHANGE tms tms DATETIME');
+
+        $this->addSql('UPDATE track_e_attempt SET tms = NULL WHERE tms = "0000-00-00 00:00:00"');
+        $this->addSql('ALTER TABLE track_e_attempt CHANGE tms tms DATETIME');
+
+        $this->addSql('UPDATE track_e_default SET default_date = NULL WHERE default_date = "0000-00-00 00:00:00"');
+        $this->addSql('ALTER TABLE track_e_default CHANGE default_date default_date DATETIME');
+
+
+        $this->addSql('ALTER TABLE track_e_exercises CHANGE expired_time_control expired_time_control DATETIME');
     }
 
     /**

+ 1 - 1
main/admin/ldap_synchro.php

@@ -99,7 +99,7 @@ foreach($Sessions as $session){
 					$official_code=$etape."-".$annee;
 					$auth_source="ldap";
 					// Pas de date d'expiration d'etudiant (a recuperer par rapport au shadow expire LDAP)
-					$expiration_date='0000-00-00 00:00:00';
+					$expiration_date='';
 					$active=1;
 					// Ajout de l'utilisateur
 					if (UserManager::is_username_available($username)) {

+ 1 - 1
main/auth/external_login/functions.inc.php

@@ -110,7 +110,7 @@ function external_add_user($u) {
     if (!isset($u['auth_source']))
         $u['auth_source'] = PLATFORM_AUTH_SOURCE;
     if (!isset($u['expiration_date']))
-        $u['expiration_date'] = '0000-00-00 00:00:00';
+        $u['expiration_date'] = '';
     if (!isset($u['active']))
         $u['active'] = 1;
     if (!isset($u['hr_dept_id']))

+ 1 - 1
main/auth/external_login/ldap.inc.php

@@ -311,7 +311,7 @@ function extldap_add_user_by_array($data, $update_if_exists = true)
     $auth_source   = 'ldap';
 
     // No expiration date for students (recover from LDAP's shadow expiry)
-    $expiration_date = '0000-00-00 00:00:00';
+    $expiration_date = '';
     $active          = 1;
     if (empty($status)) {
         $status = 5;

+ 1 - 1
main/auth/ldap/authldap.php

@@ -515,7 +515,7 @@ function ldap_add_user_by_array($data, $update_if_exists = true) {
     $official_code=$etape."-".$annee;
     $auth_source='ldap';
     // No expiration date for students (recover from LDAP's shadow expiry)
-    $expiration_date='0000-00-00 00:00:00';
+    $expiration_date='';
     $active=1;
     if(empty($status)){$status = 5;}
     if(empty($phone)){$phone = '';}

+ 3 - 3
main/coursecopy/classes/CourseRestorer.class.php

@@ -1166,7 +1166,7 @@ class CourseRestorer
         $params['forum_id'] = $forum_id;
         $params['thread_poster_id'] = $this->first_teacher_id;
         $params['thread_date'] = api_get_utc_datetime();
-        $params['thread_close_date']  = '0000-00-00 00:00:00';
+        $params['thread_close_date'] = null;
         $params['thread_last_post'] = 0;
         $params['thread_replies'] = 0;
         $params['thread_views'] = 0;
@@ -3179,8 +3179,8 @@ class CourseRestorer
                             }
 
                             //$obj->params['qualification'] = empty($row['enable_qualification']) ? true : false;
-                            $obj->params['enableExpiryDate'] = $row['expires_on'] == '0000-00-00 00:00:00' ? false : true;
-                            $obj->params['enableEndDate'] = $row['ends_on'] == '0000-00-00 00:00:00' ? false : true;
+                            $obj->params['enableExpiryDate'] = empty($row['expires_on']) ? false : true;
+                            $obj->params['enableEndDate'] = empty($row['ends_on']) ? false : true;
                             $obj->params['expires_on'] = $row['expires_on'];
                             $obj->params['ends_on'] = $row['ends_on'];
                             $obj->params['enable_qualification'] = $row['enable_qualification'];

+ 2 - 2
main/coursecopy/classes/DummyCourseCreator.class.php

@@ -41,8 +41,8 @@ class DummyCourseCreator
 		$this->default_property['to_group_id'] = '0';
 		$this->default_property['to_user_id'] = null;
 		$this->default_property['visibility'] = '1';
-		$this->default_property['start_visible'] = '0000-00-00 00:00:00';
-		$this->default_property['end_visible'] =  '0000-00-00 00:00:00';
+		$this->default_property['start_visible'] = null;
+		$this->default_property['end_visible'] =  null;
 
 		$course = api_get_course_info($course_code);
 		$this->course = new Course();

+ 2 - 2
main/glossary/index.php

@@ -156,13 +156,13 @@ if (api_is_allowed_to_edit(null, true)) {
                 $glossary_data = GlossaryManager::get_glossary_information($_GET['glossary_id']);
 
                 // Date treatment for timezones
-                if (!empty($glossary_data['insert_date'])  && $glossary_data['insert_date'] != '0000-00-00 00:00:00:') {
+                if (!empty($glossary_data['insert_date'])) {
                     $glossary_data['insert_date'] = api_get_local_time($glossary_data['insert_date']);
                 } else {
                     $glossary_data['insert_date']  = '';
                 }
 
-                if (!empty($glossary_data['update_date'])  && $glossary_data['update_date'] != '0000-00-00 00:00:00:') {
+                if (!empty($glossary_data['update_date'])) {
                     $glossary_data['update_date'] = api_get_local_time($glossary_data['update_date']);
                 } else {
                     $glossary_data['update_date']  = '';

+ 5 - 5
main/inc/ajax/course_home.ajax.php

@@ -159,14 +159,14 @@ switch ($action) {
                     false
                 );
 
-                if ($lp_item['modified_on'] == '0000-00-00 00:00:00' || empty($lp_item['modified_on'])) {
+                if (empty($lp_item['modified_on'])) {
                     $lp_date = api_get_local_time($lp_item['created_on']);
                     $image = 'new.gif';
-                    $label      = get_lang('LearnpathAdded');
+                    $label = get_lang('LearnpathAdded');
                 } else {
-                    $lp_date    = api_get_local_time($lp_item['modified_on']);
-                    $image      = 'moderator_star.png';
-                    $label      = get_lang('LearnpathUpdated');
+                    $lp_date = api_get_local_time($lp_item['modified_on']);
+                    $image = 'moderator_star.png';
+                    $label = get_lang('LearnpathUpdated');
                 }
 
                 $icons = '';

+ 15 - 15
main/inc/lib/agenda.lib.php

@@ -1281,12 +1281,12 @@ class Agenda
                 $event['sent_to'] = get_lang('Me');
                 $event['type'] = 'personal';
 
-                if (!empty($row['date']) && $row['date'] != '0000-00-00 00:00:00') {
+                if (!empty($row['date'])) {
                     $event['start'] = $this->formatEventDate($row['date']);
                     $event['start_date_localtime'] = api_get_local_time($row['date']);
                 }
 
-                if (!empty($row['enddate']) && $row['enddate'] != '0000-00-00 00:00:00') {
+                if (!empty($row['enddate'])) {
                     $event['end'] = $this->formatEventDate($row['enddate']);
                     $event['end_date_localtime'] = api_get_local_time($row['enddate']);
                 }
@@ -1667,11 +1667,11 @@ class Agenda
                     }
                 }
 
-                if (!empty($row['start_date']) && $row['start_date'] != '0000-00-00 00:00:00') {
+                if (!empty($row['start_date'])) {
                     $event['start'] = $this->formatEventDate($row['start_date']);
                     $event['start_date_localtime'] = api_get_local_time($row['start_date']);
                 }
-                if (!empty($row['end_date']) && $row['end_date'] != '0000-00-00 00:00:00') {
+                if (!empty($row['end_date'])) {
                     $event['end'] = $this->formatEventDate($row['end_date']);
                     $event['end_date_localtime'] = api_get_local_time($row['end_date']);
                 }
@@ -1779,11 +1779,11 @@ class Agenda
                     $event['editable'] = true;
                 }
 
-                if (!empty($row['start_date']) && $row['start_date'] != '0000-00-00 00:00:00') {
+                if (!empty($row['start_date'])) {
                     $event['start'] = $this->formatEventDate($row['start_date']);
                     $event['start_date_localtime'] = api_get_local_time($row['start_date']);
                 }
-                if (!empty($row['end_date']) && $row['end_date'] != '0000-00-00 00:00:00') {
+                if (!empty($row['end_date'])) {
                     $event['end'] = $this->formatEventDate($row['end_date']);
                     $event['end_date_localtime'] = api_get_local_time($row['end_date']);
                 }
@@ -2900,12 +2900,12 @@ class Agenda
 
             while ($item = Database::fetch_array($result, 'ASSOC')) {
                 $agendaday = -1;
-                if ($item['start_date'] != '0000-00-00 00:00:00') {
+                if (!empty($item['start_date'])) {
                     $item['start_date'] = api_get_local_time($item['start_date']);
                     $item['start_date_tms']  = api_strtotime($item['start_date']);
                     $agendaday = date("j", $item['start_date_tms']);
                 }
-                if ($item['end_date'] != '0000-00-00 00:00:00') {
+                if (!empty($item['end_date'])) {
                     $item['end_date'] = api_get_local_time($item['end_date']);
                 }
 
@@ -2993,11 +2993,11 @@ class Agenda
 
         while ($item = Database::fetch_array($result)) {
 
-            if ($item['start_date'] != '0000-00-00 00:00:00') {
+            if (!empty($item['start_date'])) {
                 $item['start_date'] = api_get_local_time($item['start_date']);
                 $item['start_date_tms'] = api_strtotime($item['start_date']);
             }
-            if ($item['end_date'] != '0000-00-00 00:00:00') {
+            if (!empty($item['end_date'])) {
                 $item['end_date'] = api_get_local_time($item['end_date']);
             }
 
@@ -3027,11 +3027,11 @@ class Agenda
                 TIME_NO_SEC_FORMAT
             );
             $end_time = '';
-            if ($item['end_date'] != '0000-00-00 00:00:00') {
+            if (!empty($item['end_date'])) {
                 $end_time = ' - '.api_format_date(
-                        $item['end_date'],
-                        DATE_TIME_FORMAT_LONG
-                    );
+                    $item['end_date'],
+                    DATE_TIME_FORMAT_LONG
+                );
             }
 
             // if the student has specified a course we a add a link to that course
@@ -3250,7 +3250,7 @@ class Agenda
                             $start_time = api_format_date($value['start_date'], TIME_NO_SEC_FORMAT);
                             $end_time = '';
 
-                            if (!empty($value['end_date']) && $value['end_date'] != '0000-00-00 00:00:00') {
+                            if (!empty($value['end_date'])) {
                                 $end_time    = '-&nbsp;<i>'.api_format_date($value['end_date'], DATE_TIME_FORMAT_LONG).'</i>';
                             }
                             $complete_time = '<i>'.api_format_date($value['start_date'], DATE_TIME_FORMAT_LONG).'</i>&nbsp;'.$end_time;

+ 4 - 5
main/inc/lib/exercise.lib.php

@@ -2265,13 +2265,13 @@ HOTSPOT;
 
         if ($check_publication_dates) {
             //start and end are set
-            $time_conditions = " AND ((start_time <> '0000-00-00 00:00:00' AND start_time < '$now' AND end_time <> '0000-00-00 00:00:00' AND end_time > '$now' )  OR ";
+            $time_conditions = " AND ((start_time <> '' AND start_time < '$now' AND end_time <> '' AND end_time > '$now' )  OR ";
             // only start is set
-            $time_conditions .= " (start_time <> '0000-00-00 00:00:00' AND start_time < '$now' AND end_time = '0000-00-00 00:00:00') OR ";
+            $time_conditions .= " (start_time <> '' AND start_time < '$now' AND end_time is NULL) OR ";
             // only end is set
-            $time_conditions .= " (start_time = '0000-00-00 00:00:00' AND end_time <> '0000-00-00 00:00:00' AND end_time > '$now') OR ";
+            $time_conditions .= " (start_time IS NULL AND end_time <> '' AND end_time > '$now') OR ";
             // nothing is set
-            $time_conditions .= " (start_time = '0000-00-00 00:00:00' AND end_time = '0000-00-00 00:00:00'))  ";
+            $time_conditions .= " (start_time IS NULL AND end_time IS NULL))  ";
         }
 
         $needle_where = !empty($search) ? " AND title LIKE '?' " : '';
@@ -2807,7 +2807,6 @@ HOTSPOT;
         foreach ($exercises as $exercise_item) {
             if (isset($exercise_item['end_time']) &&
                 !empty($exercise_item['end_time']) &&
-                $exercise_item['end_time'] != '0000-00-00 00:00:00' &&
                 api_strtotime($exercise_item['end_time'], 'UTC') < $now
             ) {
                 $result[] = $exercise_item;

+ 4 - 0
main/inc/lib/internationalization.lib.php

@@ -660,6 +660,10 @@ function api_format_date($time, $format = null, $language = null)
 
 function date_to_str_ago($date, $timeZone = 'UTC')
 {
+    if ($date == '0000-00-00 00:00:00')  {
+        return '';
+    }
+    
     $timeAgo = new TimeAgo($timeZone, api_get_language_isocode());
 
     return $timeAgo->inWords($date);

+ 4 - 6
main/inc/lib/message.lib.php

@@ -362,7 +362,7 @@ class MessageManager
             // Load user settings.
             $notification = new Notification();
             $sender_info = api_get_user_info($user_sender_id);
-            
+
             // add file attachment additional attributes
             foreach ($file_attachments as $index => $file_attach) {
                 $file_attachments[$index]['path'] = $file_attach['tmp_name'];
@@ -1190,9 +1190,7 @@ class MessageManager
 
                 $date = '';
                 if ($topic['send_date'] != $topic['update_date']) {
-                    if (!empty($topic['update_date']) &&
-                        $topic['update_date'] != '0000-00-00 00:00:00'
-                    ) {
+                    if (!empty($topic['update_date'])) {
                         $date .= '<div class="message-group-date" >
                             <i>'.get_lang('LastUpdate').' '.date_to_str_ago($topic['update_date']).'</i></div>';
                     }
@@ -1344,7 +1342,7 @@ class MessageManager
 
         $date = '';
         if ($main_message['send_date'] != $main_message['update_date']) {
-            if (!empty($main_message['update_date']) && $main_message['update_date'] != '0000-00-00 00:00:00') {
+            if (!empty($main_message['update_date'])) {
                 $date = '<div class="message-group-date"> '.get_lang('LastUpdate').' '.date_to_str_ago($main_message['update_date']).'</div>';
             }
         } else {
@@ -1388,7 +1386,7 @@ class MessageManager
 
                 $date = '';
                 if ($topic['send_date'] != $topic['update_date']) {
-                    if (!empty($topic['update_date']) && $topic['update_date'] != '0000-00-00 00:00:00') {
+                    if (!empty($topic['update_date'])) {
                         $date = '<div class="message-group-date"> '.get_lang('LastUpdate').' '.date_to_str_ago($topic['update_date']).'</div>';
                     }
                 } else {

+ 5 - 5
main/inc/lib/statistics.lib.php

@@ -293,7 +293,7 @@ class Statistics
                 }
             }
 
-            if (!empty($row['default_date']) && $row['default_date'] != '0000-00-00 00:00:00') {
+            if (!empty($row['default_date'])) {
                 $row['default_date'] = api_get_local_time($row['default_date']);
             } else {
                 $row['default_date'] = '-';
@@ -530,7 +530,7 @@ class Statistics
             Statistics::printStats(get_lang('Logins'), $totalLogin, false);
         }
     }
-    
+
     /**
      * get the number of recent logins
      * @param bool    $distinct   Whether to only give distinct users stats, or *all* logins
@@ -555,15 +555,15 @@ class Statistics
             $field = 'DISTINCT(login_user_id)';
         }
         $sql = "SELECT count($field) AS number, date(login_date) as login_date FROM $table $table_url WHERE DATE_ADD(login_date, INTERVAL 15 DAY) >= '$now' $where_url GROUP BY date(login_date)";
-        
+
         $res = Database::query($sql);
         while($row = Database::fetch_array($res,'ASSOC')){
             $totalLogin[$row['login_date']] = $row['number'];
         }
-        
+
         return $totalLogin;
     }
-    
+
     /**
      * Show some stats about the accesses to the different course tools
      */

+ 1 - 1
main/inc/lib/thematic.lib.php

@@ -1410,7 +1410,7 @@ class Thematic
         $thematic_id = 0,
         $attendance_id = 0,
         $content = '',
-        $start_date = '0000-00-00 00:00:00',
+        $start_date = null,
         $duration = 0
     ) {
         $this->thematic_advance_id = $id;

+ 1 - 1
main/inc/lib/tracking.lib.php

@@ -1605,7 +1605,7 @@ class Tracking
     	$rs = Database::query($sql);
     	if (Database::num_rows($rs) > 0) {
     		if ($last_login_date = Database::result($rs, 0, 0)) {
-                if (empty($last_login_date) || $last_login_date == '0000-00-00 00:00:00') {
+                if (empty($last_login_date)) {
                     return false;
                 }
                 //see #5736

+ 8 - 10
main/newscorm/learnpath.class.php

@@ -149,11 +149,11 @@ class learnpath
                 $this->ref = $row['ref'];
                 $this->categoryId = $row['category_id'];
 
-                if ($row['publicated_on'] != '0000-00-00 00:00:00') {
+                if (!empty($row['publicated_on'])) {
                     $this->publicated_on = $row['publicated_on'];
                 }
 
-                if ($row['expired_on'] != '0000-00-00 00:00:00') {
+                if (!empty($row['expired_on'])) {
                     $this->expired_on  = $row['expired_on'];
                 }
                 if ($this->type == 2) {
@@ -774,7 +774,7 @@ class learnpath
 
         $res_name = Database::query($check_name);
 
-        if ($publicated_on == '0000-00-00 00:00:00' || empty($publicated_on)) {
+        if (empty($publicated_on)) {
             //by default the publication date is the same that the creation date
             //The behaviour above was changed due BT#2800
             global $_custom;
@@ -787,7 +787,7 @@ class learnpath
             $publicated_on = Database::escape_string(api_get_utc_datetime($publicated_on));
         }
 
-        if ($expired_on == '0000-00-00 00:00:00' || empty($expired_on)) {
+        if (empty($expired_on)) {
             $expired_on = null;
         } else {
             $expired_on = Database::escape_string(api_get_utc_datetime($expired_on));
@@ -2350,9 +2350,7 @@ class learnpath
             // Also check the time availability of the LP
             if ($is_visible) {
                 // Adding visibility restrictions
-                if (!empty($row['publicated_on']) &&
-                    $row['publicated_on'] != '0000-00-00 00:00:00'
-                ) {
+                if (!empty($row['publicated_on'])) {
                     if ($now < api_strtotime($row['publicated_on'], 'UTC')) {
                         //api_not_allowed();
                         $is_visible = false;
@@ -2364,13 +2362,13 @@ class learnpath
                 if (isset($_custom['lps_hidden_when_no_start_date']) &&
                     $_custom['lps_hidden_when_no_start_date']
                 ) {
-                    if (empty($row['publicated_on']) || $row['publicated_on'] == '0000-00-00 00:00:00') {
+                    if (empty($row['publicated_on'])) {
                         //api_not_allowed();
                         $is_visible = false;
                     }
                 }
 
-                if (!empty($row['expired_on']) && $row['expired_on'] != '0000-00-00 00:00:00') {
+                if (!empty($row['expired_on'])) {
                     if ($now > api_strtotime($row['expired_on'], 'UTC')) {
                         //api_not_allowed();
                         $is_visible = false;
@@ -5543,7 +5541,7 @@ class learnpath
         if ($update_audio == 'true' && count($this->arrMenu) != 0) {
             $return .= '</form>';
         }
-        
+
         return $return;
     }
 

+ 8 - 8
main/newscorm/learnpathList.class.php

@@ -78,10 +78,10 @@ class LearnpathList
 
         if ($check_publication_dates) {
             $time_conditions = " AND (
-                (publicated_on <> '0000-00-00 00:00:00' AND publicated_on < '$now' AND expired_on <> '0000-00-00 00:00:00' AND expired_on > '$now' )  OR
-                (publicated_on <> '0000-00-00 00:00:00' AND publicated_on < '$now' AND expired_on = '0000-00-00 00:00:00') OR
-                (publicated_on = '0000-00-00 00:00:00' AND expired_on <> '0000-00-00 00:00:00' AND expired_on > '$now') OR
-                (publicated_on = '0000-00-00 00:00:00' AND expired_on = '0000-00-00 00:00:00' ))
+                (publicated_on <> '' AND publicated_on < '$now' AND expired_on <> '' AND expired_on > '$now') OR
+                (publicated_on <> '' AND publicated_on < '$now' AND expired_on IS NULL) OR
+                (publicated_on IS NULL AND expired_on <> '' AND expired_on > '$now') OR
+                (publicated_on IS NULL AND expired_on IS NULL ))
             ";
         }
 
@@ -137,25 +137,25 @@ class LearnpathList
                 $session_id
             );
 
-            if (!empty($row['created_on']) && $row['created_on'] != '0000-00-00 00:00:00') {
+            if (!empty($row['created_on'])) {
                 $row['created_on'] = $row['created_on'];
             } else {
                 $row['created_on'] = '';
             }
 
-            if (!empty($row['modified_on']) && $row['modified_on'] != '0000-00-00 00:00:00') {
+            if (!empty($row['modified_on'])) {
                 $row['modified_on'] = $row['modified_on'];
             } else {
                 $row['modified_on'] = '';
             }
 
-            if (!empty($row['publicated_on']) && $row['publicated_on'] != '0000-00-00 00:00:00') {
+            if (!empty($row['publicated_on'])) {
                 $row['publicated_on'] = $row['publicated_on'];
             } else {
                 $row['publicated_on'] = '';
             }
 
-            if (!empty($row['expired_on']) && $row['expired_on'] != '0000-00-00 00:00:00') {
+            if (!empty($row['expired_on'])) {
                 $row['expired_on'] = $row['expired_on'];
             } else {
                 $row['expired_on'] = '';

+ 4 - 4
main/newscorm/lp_edit.php

@@ -158,7 +158,7 @@ $form->addElement('html', '<div class="help-block">'.get_lang('LpPrerequisiteDes
 //Start date
 $form->addElement('checkbox', 'activate_start_date_check', null,get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()'));
 $display_date = 'none';
-if ($publicated_on!='0000-00-00 00:00:00' && !empty($publicated_on)) {
+if (!empty($publicated_on)) {
 	$display_date = 'block';
 	$defaults['activate_start_date_check'] = 1;
 }
@@ -170,7 +170,7 @@ $form->addElement('html','</div>');
 //End date
 $form->addElement('checkbox', 'activate_end_date_check',  null, get_lang('EnableEndTime'),  array('onclick' => 'activate_end_date()'));
 $display_date = 'none';
-if ($expired_on!='0000-00-00 00:00:00' && !empty($expired_on)) {
+if (!empty($expired_on)) {
 	$display_date = 'block';
 	$defaults['activate_end_date_check'] = 1;
 }
@@ -209,8 +209,8 @@ if ($enableLpExtraFields) {
 }
 
 
-$defaults['publicated_on']  = ($publicated_on!='0000-00-00 00:00:00' && !empty($publicated_on))? api_get_local_time($publicated_on) : date('Y-m-d 12:00:00');
-$defaults['expired_on']     = ($expired_on   !='0000-00-00 00:00:00' && !empty($expired_on) )? api_get_local_time($expired_on): date('Y-m-d 12:00:00',time()+84600);
+$defaults['publicated_on'] = (!empty($publicated_on))? api_get_local_time($publicated_on) : date('Y-m-d 12:00:00');
+$defaults['expired_on'] = (!empty($expired_on) )? api_get_local_time($expired_on): date('Y-m-d 12:00:00',time()+84600);
 //$defaults['max_attempts'] = $_SESSION['oLP']->get_max_attempts();
 $defaults['subscribe_users'] = $_SESSION['oLP']->getSubscribeUsers();
 $form->setDefaults($defaults);

+ 4 - 6
main/newscorm/lp_list.php

@@ -201,22 +201,20 @@ foreach ($categories as $item) {
                 $time_limits = false;
 
                 //This is an old LP (from a migration 1.8.7) so we do nothing
-                if ((empty($details['created_on']) || $details['created_on'] == '0000-00-00 00:00:00') &&
-                    (empty($details['modified_on']) || $details['modified_on'] == '0000-00-00 00:00:00')
+                if ((empty($details['created_on'])) &&
+                    (empty($details['modified_on']))
                 ) {
                     $time_limits = false;
                 }
 
                 //Checking if expired_on is ON
-                if ($details['expired_on'] != '' && $details['expired_on'] != '0000-00-00 00:00:00') {
+                if ($details['expired_on'] != '') {
                     $time_limits = true;
                 }
 
                 if ($time_limits) {
                     // Check if start time
-                    if (!empty($details['publicated_on']) && $details['publicated_on'] != '0000-00-00 00:00:00' &&
-                        !empty($details['expired_on']) && $details['expired_on'] != '0000-00-00 00:00:00'
-                    ) {
+                    if (!empty($details['publicated_on']) && !empty($details['expired_on'])) {
                         $start_time = api_strtotime(
                             $details['publicated_on'],
                             'UTC'

+ 1 - 1
main/session/index.php

@@ -303,9 +303,9 @@ foreach ($final_array as $session_data) {
                     if (!empty($best_score_data)) {
                         $best_score = ExerciseLib::show_score($best_score_data['exe_result'], $best_score_data['exe_weighting']);
                     }
+                    
                     // Exercise results
                     $counter = 1;
-
                     foreach ($exercise_data as $exercise_item) {
                         $result_list     = $exercise_item['results'];
                         $exercise_info   = $exercise_item['exercise_data'];

+ 25 - 27
main/wiki/wiki.inc.php

@@ -316,13 +316,13 @@ class Wiki
         if (isset($values['initstartdate']) && $values['initstartdate'] == 1) {
             $_clean['startdate_assig'] = $values['startdate_assig'];
         } else {
-            $_clean['startdate_assig'] = '0000-00-00 00:00:00';
+            $_clean['startdate_assig'] = null;
         }
 
         if (isset($values['initenddate']) && $values['initenddate']==1) {
             $_clean['enddate_assig'] = $values['enddate_assig'];
         } else {
-            $_clean['enddate_assig'] = '0000-00-00 00:00:00';
+            $_clean['enddate_assig'] = null;
         }
 
         if (isset($values['delayedsubmit'])) {
@@ -622,13 +622,13 @@ class Wiki
         if (isset($values['initstartdate']) && $values['initstartdate'] == 1) {
             $_clean['startdate_assig'] = $values['startdate_assig'];
         } else {
-            $_clean['startdate_assig'] = '0000-00-00 00:00:00';
+            $_clean['startdate_assig'] = null;
         }
 
         if (isset($values['initenddate']) && $values['initenddate'] == 1) {
             $_clean['enddate_assig'] = $values['enddate_assig'];
         } else {
-            $_clean['enddate_assig'] = '0000-00-00 00:00:00';
+            $_clean['enddate_assig'] = null;
         }
 
         $_clean['delayedsubmit'] = isset($values['delayedsubmit']) ? $values['delayedsubmit'] : '';
@@ -768,7 +768,7 @@ class Wiki
 
             $style = "display:block";
             $row['initstartdate'] = 1;
-            if ($row['startdate_assig'] == '0000-00-00 00:00:00') {
+            if (empty($row['startdate_assig'])) {
                 $style = "display:none";
                 $row['initstartdate'] = null;
             }
@@ -780,7 +780,7 @@ class Wiki
 
             $style = "display:block";
             $row['initenddate'] = 1;
-            if ($row['enddate_assig'] == '0000-00-00 00:00:00') {
+            if (empty($row['enddate_assig'])) {
                 $style = "display:none";
                 $row['initenddate'] = null;
             }
@@ -2655,7 +2655,7 @@ class Wiki
 
         $sql = 'UPDATE '.$tbl_wiki.' SET
                 is_editing = "0",
-                time_edit="0000-00-00 00:00:00"
+                time_edit = NULL
                 WHERE
                     c_id = '.$course_id.' AND
                     is_editing="'.$isEditing.'" '.
@@ -3006,24 +3006,26 @@ class Wiki
 
         //Creation date of the oldest wiki page and version
 
-        $first_wiki_date='0000-00-00 00:00:00';
+        $first_wiki_date = null;
         $sql = 'SELECT * FROM '.$tbl_wiki.'
                 WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
-                ORDER BY dtime ASC LIMIT 1';
-        $allpages=Database::query($sql);
-        while ($row=Database::fetch_array($allpages)) {
-            $first_wiki_date=$row['dtime'];
+                ORDER BY dtime ASC 
+                LIMIT 1';
+        $allpages = Database::query($sql);
+        while ($row = Database::fetch_array($allpages)) {
+            $first_wiki_date = $row['dtime'];
         }
 
         // Date of publication of the latest wiki version.
 
-        $last_wiki_date='0000-00-00 00:00:00';
+        $last_wiki_date = null;
         $sql = 'SELECT * FROM '.$tbl_wiki.'
                 WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
-                ORDER BY dtime DESC LIMIT 1';
-        $allpages=Database::query($sql);
+                ORDER BY dtime DESC 
+                LIMIT 1';
+        $allpages = Database::query($sql);
         while ($row=Database::fetch_array($allpages)) {
-            $last_wiki_date=$row['dtime'];
+            $last_wiki_date = $row['dtime'];
         }
 
         // Average score of all wiki pages. (If a page has not scored zero rated)
@@ -4903,11 +4905,9 @@ class Wiki
                 } else {
                     // Check tasks
 
-                    if (!empty($row['startdate_assig']) &&
-                        $row['startdate_assig']!='0000-00-00 00:00:00' &&
-                        time()<strtotime($row['startdate_assig'])
+                    if (!empty($row['startdate_assig']) &&  time() < api_strtotime($row['startdate_assig'])
                     ) {
-                        $message = get_lang('TheTaskDoesNotBeginUntil').': '.api_get_local_time($row['startdate_assig'], null, date_default_timezone_get());
+                        $message = get_lang('TheTaskDoesNotBeginUntil').': '.api_get_local_time($row['startdate_assig']);
 
                         Display::addFlash(
                             Display::return_message(
@@ -4922,12 +4922,10 @@ class Wiki
                     }
 
                     if (!empty($row['enddate_assig']) &&
-                        $row['enddate_assig']!='0000-00-00 00:00:00' &&
                         time() > strtotime($row['enddate_assig']) &&
-                        $row['enddate_assig']!='0000-00-00 00:00:00' &&
                         $row['delayedsubmit']==0
                     ) {
-                        $message = get_lang('TheDeadlineHasBeenCompleted').': '.api_get_local_time($row['enddate_assig'], null, date_default_timezone_get());
+                        $message = get_lang('TheDeadlineHasBeenCompleted').': '.api_get_local_time($row['enddate_assig']);
                         Display::addFlash(
                             Display::return_message(
                                 $message,
@@ -4967,16 +4965,16 @@ class Wiki
 
                     if (!empty($row['task'])) {
                         //previous change 0 by text
-                        if ($row['startdate_assig']=='0000-00-00 00:00:00') {
+                        if (!empty($row['startdate_assig'])) {
                             $message_task_startdate  =get_lang('No');
                         } else {
-                            $message_task_startdate = api_get_local_time($row['startdate_assig'], null, date_default_timezone_get());
+                            $message_task_startdate = api_get_local_time($row['startdate_assig']);
                         }
 
-                        if ($row['enddate_assig']=='0000-00-00 00:00:00') {
+                        if (!empty($row['enddate_assig'])) {
                             $message_task_enddate = get_lang('No');
                         } else {
-                            $message_task_enddate = api_get_local_time($row['enddate_assig'], null, date_default_timezone_get());
+                            $message_task_enddate = api_get_local_time($row['enddate_assig']);
                         }
 
                         if ($row['delayedsubmit']==0) {

+ 6 - 6
src/Chamilo/CoreBundle/Entity/AccessUrl.php

@@ -25,42 +25,42 @@ class AccessUrl
     /**
      * @var string
      *
-     * @ORM\Column(name="url", type="string", length=255, precision=0, scale=0, nullable=false, unique=false)
+     * @ORM\Column(name="url", type="string", length=255, nullable=false, unique=false)
      */
     private $url;
 
     /**
      * @var string
      *
-     * @ORM\Column(name="description", type="text", precision=0, scale=0, nullable=true, unique=false)
+     * @ORM\Column(name="description", type="text", unique=false)
      */
     private $description;
 
     /**
      * @var integer
      *
-     * @ORM\Column(name="active", type="integer", precision=0, scale=0, nullable=false, unique=false)
+     * @ORM\Column(name="active", type="integer", nullable=false, unique=false)
      */
     private $active;
 
     /**
      * @var integer
      *
-     * @ORM\Column(name="created_by", type="integer", precision=0, scale=0, nullable=false, unique=false)
+     * @ORM\Column(name="created_by", type="integer", nullable=false, unique=false)
      */
     private $createdBy;
 
     /**
      * @var \DateTime
      *
-     * @ORM\Column(name="tms", type="datetime", precision=0, scale=0, nullable=false, unique=false)
+     * @ORM\Column(name="tms", type="datetime", nullable=true)
      */
     private $tms;
 
     /**
      * @var boolean
      *
-     * @ORM\Column(name="url_type", type="boolean", precision=0, scale=0, nullable=true, unique=false)
+     * @ORM\Column(name="url_type", type="boolean", nullable=true)
      */
     private $urlType;
 

+ 0 - 2
src/Chamilo/CoreBundle/Entity/ExtraFieldOptions.php

@@ -16,7 +16,6 @@ use Gedmo\Mapping\Annotation as Gedmo;
  */
 class ExtraFieldOptions
 {
-
     /**
      * @var integer
      *
@@ -194,5 +193,4 @@ class ExtraFieldOptions
 
         return $this;
     }
-
 }

+ 1 - 1
src/Chamilo/CoreBundle/Entity/Message.php

@@ -71,7 +71,7 @@ class Message
     /**
      * @var \DateTime
      *
-     * @ORM\Column(name="update_date", type="datetime", nullable=false)
+     * @ORM\Column(name="update_date", type="datetime", nullable=true)
      */
     private $updateDate;
 

+ 2 - 2
src/Chamilo/CoreBundle/Entity/SysCalendar.php

@@ -29,14 +29,14 @@ class SysCalendar
     /**
      * @var \DateTime
      *
-     * @ORM\Column(name="start_date", type="datetime", nullable=false)
+     * @ORM\Column(name="start_date", type="datetime", nullable=true)
      */
     private $startDate;
 
     /**
      * @var \DateTime
      *
-     * @ORM\Column(name="end_date", type="datetime", nullable=false)
+     * @ORM\Column(name="end_date", type="datetime", nullable=true)
      */
     private $endDate;
 

+ 1 - 1
src/Chamilo/CoreBundle/Entity/TrackEAttempt.php

@@ -87,7 +87,7 @@ class TrackEAttempt
     /**
      * @var \DateTime
      *
-     * @ORM\Column(name="tms", type="datetime", nullable=false)
+     * @ORM\Column(name="tms", type="datetime", nullable=true)
      */
     private $tms;
 

+ 9 - 11
src/Chamilo/CoreBundle/Entity/TrackEAttemptRecording.php

@@ -12,6 +12,15 @@ use Doctrine\ORM\Mapping as ORM;
  */
 class TrackEAttemptRecording
 {
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer")
+     * @ORM\Id
+     * @ORM\GeneratedValue
+     */
+    private $id;
+
     /**
      * @var integer
      *
@@ -61,17 +70,6 @@ class TrackEAttemptRecording
      */
     private $sessionId;
 
-    /**
-     * @var integer
-     *
-     * @ORM\Column(name="id", type="integer")
-     * @ORM\Id
-     * @ORM\GeneratedValue(strategy="IDENTITY")
-     */
-    private $id;
-
-
-
     /**
      * Set exeId
      *

+ 0 - 1
src/Chamilo/CoreBundle/Entity/TrackECourseAccess.php

@@ -79,7 +79,6 @@ class TrackECourseAccess
     private $courseAccessId;
 
 
-
     /**
      * Set cId
      *

+ 1 - 1
src/Chamilo/CoreBundle/Entity/TrackEDefault.php

@@ -46,7 +46,7 @@ class TrackEDefault
     /**
      * @var \DateTime
      *
-     * @ORM\Column(name="default_date", type="datetime", nullable=false)
+     * @ORM\Column(name="default_date", type="datetime", nullable=true)
      */
     private $defaultDate;
 

+ 9 - 11
src/Chamilo/CoreBundle/Entity/TrackEDownloads.php

@@ -12,6 +12,15 @@ use Doctrine\ORM\Mapping as ORM;
  */
 class TrackEDownloads
 {
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="down_id", type="integer")
+     * @ORM\Id
+     * @ORM\GeneratedValue
+     */
+    private $downId;
+    
     /**
      * @var integer
      *
@@ -47,17 +56,6 @@ class TrackEDownloads
      */
     private $downSessionId;
 
-    /**
-     * @var integer
-     *
-     * @ORM\Column(name="down_id", type="integer")
-     * @ORM\Id
-     * @ORM\GeneratedValue(strategy="IDENTITY")
-     */
-    private $downId;
-
-
-
     /**
      * Set downUserId
      *

+ 2 - 2
src/Chamilo/CourseBundle/Entity/CCalendarEvent.php

@@ -59,14 +59,14 @@ class CCalendarEvent
     /**
      * @var \DateTime
      *
-     * @ORM\Column(name="start_date", type="datetime", nullable=false)
+     * @ORM\Column(name="start_date", type="datetime", nullable=true)
      */
     private $startDate;
 
     /**
      * @var \DateTime
      *
-     * @ORM\Column(name="end_date", type="datetime", nullable=false)
+     * @ORM\Column(name="end_date", type="datetime", nullable=true)
      */
     private $endDate;
 

+ 2 - 2
src/Chamilo/CourseBundle/Entity/CWiki.php

@@ -90,7 +90,7 @@ class CWiki
     /**
      * @var \DateTime
      *
-     * @ORM\Column(name="dtime", type="datetime", nullable=false)
+     * @ORM\Column(name="dtime", type="datetime", nullable=true)
      */
     private $dtime;
 
@@ -181,7 +181,7 @@ class CWiki
     /**
      * @var \DateTime
      *
-     * @ORM\Column(name="time_edit", type="datetime", nullable=false)
+     * @ORM\Column(name="time_edit", type="datetime", nullable=true)
      */
     private $timeEdit;
 

+ 2 - 2
src/Chamilo/CourseBundle/Entity/CWikiConf.php

@@ -117,14 +117,14 @@ class CWikiConf
     /**
      * @var \DateTime
      *
-     * @ORM\Column(name="startdate_assig", type="datetime", nullable=false)
+     * @ORM\Column(name="startdate_assig", type="datetime", nullable=true)
      */
     private $startdateAssig;
 
     /**
      * @var \DateTime
      *
-     * @ORM\Column(name="enddate_assig", type="datetime", nullable=false)
+     * @ORM\Column(name="enddate_assig", type="datetime", nullable=true)
      */
     private $enddateAssig;