Browse Source

Datetime changes c_forum_forum.start_time and c_forum_forum.end_time accept null

jmontoyaa 9 years ago
parent
commit
619574a886

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

@@ -76,6 +76,9 @@ class Version111 extends AbstractMigrationChamilo
 
         $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('ALTER TABLE c_forum_forum CHANGE start_time start_time DATETIME');
+        $this->addSql('ALTER TABLE c_forum_forum CHANGE end_time end_time DATETIME');
     }
 
     /**

+ 19 - 12
main/forum/forumfunction.inc.php

@@ -556,6 +556,8 @@ function store_forumcategory($values, $courseInfo = array(), $showMessage = true
             'cat_comment' => isset($values['forum_category_comment']) ? $values['forum_category_comment'] : '',
             'cat_order' => $new_max,
             'session_id' => $session_id,
+            'locked' => 0,
+            'cat_id' => 0
         ];
         $last_id = Database::insert($table_categories, $params);
 
@@ -742,8 +744,11 @@ function store_forum($values, $courseInfo = array(), $returnId = false)
             'session_id'=> $session_id,
             'lp_id' => isset($values['lp_id']) ? intval($values['lp_id']) : 0,
             'locked' => 0,
-            'forum_id' => 0
+            'forum_id' => 0,
+            'start_time' => null,
+            'end_time' => null
         ];
+
         $last_id = Database::insert($table_forums, $params);
         if ($last_id > 0) {
 
@@ -2424,15 +2429,17 @@ function store_thread($current_forum, $values, $courseInfo = array(), $showMessa
                 'thread_title' => $clean_post_title,
                 'forum_id' => $values['forum_id'],
                 'thread_poster_id' => $_user['user_id'],
-                'thread_poster_name' => stripslashes(isset($values['poster_name']) ? $values['poster_name'] : ''),
+                'thread_poster_name' => isset($values['poster_name']) ? $values['poster_name'] : '',
                 'thread_date' => $post_date,
-                'thread_sticky' => isset($values['thread_sticky']) ? $values['thread_sticky'] : '',
+                'thread_sticky' => isset($values['thread_sticky']) ? $values['thread_sticky'] : 0,
                 'thread_title_qualify' => isset($values['calification_notebook_title']) ? $values['calification_notebook_title'] : '',
-                'thread_qualify_max' => isset($values['numeric_calification']) ? $values['numeric_calification'] : '',
-                'thread_weight' => isset($values['weight_calification']) ? $values['weight_calification'] : '',
-                'thread_peer_qualify' => isset($values['thread_peer_qualify']) ? $values['thread_peer_qualify'] : '',
+                'thread_qualify_max' => isset($values['numeric_calification']) ? (int) $values['numeric_calification'] : 0,
+                'thread_weight' => isset($values['weight_calification']) ? (int) $values['weight_calification'] : 0,
+                'thread_peer_qualify' => isset($values['thread_peer_qualify']) ? (int) $values['thread_peer_qualify'] : 0,
                 'session_id' => api_get_session_id(),
-                'lp_item_id' => isset($values['lp_item_id']) ? intval($values['lp_item_id']) : 0
+                'lp_item_id' => isset($values['lp_item_id']) ? (int) $values['lp_item_id'] : 0,
+                'thread_id' => 0,
+                'locked' => 0
             ]
         );
 
@@ -2520,9 +2527,10 @@ function store_thread($current_forum, $values, $courseInfo = array(), $showMessa
             'poster_id' => $_user['user_id'],
             'poster_name' => isset($values['poster_name']) ? $values['poster_name'] : '',
             'post_date' => $post_date,
-            'post_notification' => isset($values['post_notification']) ? $values['post_notification'] : '',
+            'post_notification' => isset($values['post_notification']) ? (int) $values['post_notification'] : 0,
             'post_parent_id' => 0,
             'visible' => $visible,
+            'post_id' => 0
         ];
         $last_post_id = Database::insert($table_posts, $params);
 
@@ -2762,8 +2770,6 @@ function show_add_post_form($current_forum, $forum_setting, $action = '', $id =
 {
     $_user = api_get_user_info();
     $action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : null;
-
-    // Initialize the object.
     $myThread = isset($_GET['thread']) ? $_GET['thread'] : '';
     $my_forum = isset($_GET['forum']) ? $_GET['forum'] : '';
     $my_post = isset($_GET['post']) ? $_GET['post'] : '';
@@ -2963,7 +2969,8 @@ function show_add_post_form($current_forum, $forum_setting, $action = '', $id =
             }
             Security::clear_token();
 
-            return $values;
+            // Add new thread in table forum_thread.
+            store_thread($current_forum, $values);
         }
     } else {
         $token = Security::get_token();
@@ -2978,7 +2985,7 @@ function show_add_post_form($current_forum, $forum_setting, $action = '', $id =
         $ajaxHtml = $attachmentAjaxTable;
         $form->addElement('html', $ajaxHtml);
 
-        return $form;
+        $form->display();
     }
 }
 

+ 9 - 24
main/forum/index.php

@@ -348,19 +348,7 @@ if (is_array($forumCategories)) {
 
         echo '<div class="forum_display">';
         if (!empty($forumsInCategory)) {
-
-            // Step 4: The interim headers (for the forum).
-            /* echo '<tr class="forum_header">';
-            echo '<td></td>';
-            echo '<td>'.get_lang('Forum').'</td>';
-            echo '<td>'.get_lang('Topics').'</td>';
-            echo '<td>'.get_lang('Posts').'</td>';
-            echo '<td>'.get_lang('LastPosts').'</td>';
-            echo '<td>'.get_lang('Actions').'</td>';
-            echo '</tr>'; */
-
-            // Step 5: We display all the forums in this category.
-
+            // We display all the forums in this category.
             foreach ($forum_list as $forum) {
                 // Here we clean the whatnew_post_info array a little bit because to display the icon we
                 // test if $whatsnew_post_info[$forum['forum_id']] is empty or not.
@@ -420,10 +408,7 @@ if (is_array($forumCategories)) {
                         // Showing the image
                         if (!empty($forum['forum_image'])) {
 
-                            $image_path = api_get_path(WEB_COURSE_PATH)
-                                . api_get_course_path()
-                                . '/upload/forum/images/'
-                                . $forum['forum_image'];
+                            $image_path = api_get_path(WEB_COURSE_PATH). api_get_course_path(). '/upload/forum/images/'. $forum['forum_image'];
                             $image_size = api_getimagesize($image_path);
                             $img_attributes = '';
                             if (!empty($image_size)) {
@@ -501,23 +486,21 @@ if (is_array($forumCategories)) {
                             null,
                             ICON_SIZE_MEDIUM
                         );
-                        $linkForum  = '';
-                        $linkForum .= Display::tag(
+                        $linkForum = Display::tag(
                             'a',
                             $forum['forum_title'],
                             array (
                                 'href' => 'viewforum.php?' . api_get_cidreq()
                                     . '&gidReq=' . intval($groupid)
                                     . '&forum=' . intval($forum['forum_id']),
-                                'class' => return_visible_invisible( strval( intval($forum['visibility']) ) )
+                                'class' => return_visible_invisible(strval(intval($forum['visibility'])))
                             )
                         );
 
                         $html .= '<h3 class="title">' . $iconForum . $linkForum . '</h3>';
-
                         $html .= Display::tag(
                             'p',
-                            strip_tags($forum['forum_comment']),
+                            Security::remove_XSS($forum['forum_comment']),
                             array(
                                 'class'=>'description'
                             )
@@ -597,8 +580,7 @@ if (is_array($forumCategories)) {
                         $html .= '</div>';
                         $html .= '<div class="col-md-4">';
 
-                        if (
-                            api_is_allowed_to_edit(false, true) &&
+                        if (api_is_allowed_to_edit(false, true) &&
                             !($forum['session_id'] == 0 && intval($sessionId) != 0)
                         ) {
                             $html .= '<a href="'.api_get_self() . '?' . api_get_cidreq()
@@ -613,16 +595,19 @@ if (is_array($forumCategories)) {
                                 . "')) return false;\">"
                                 . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL)
                                 . '</a>';
+
                             $html .= return_visible_invisible_icon(
                                 'forum',
                                 $forum['forum_id'],
                                 $forum['visibility']
                             );
+
                             $html .= return_lock_unlock_icon(
                                 'forum',
                                 $forum['forum_id'],
                                 $forum['locked']
                             );
+
                             $html .= return_up_down_icon(
                                 'forum',
                                 $forum['forum_id'],

+ 2 - 6
main/forum/newthread.php

@@ -167,7 +167,8 @@ echo '</div>';
 
 // Set forum attachment data into $_SESSION
 getAttachedFiles($current_forum['forum_id'], 0, 0);
-$values = show_add_post_form(
+
+show_add_post_form(
     $current_forum,
     $forum_setting,
     'newthread',
@@ -175,11 +176,6 @@ $values = show_add_post_form(
     isset($_SESSION['formelements']) ? $_SESSION['formelements'] : null
 );
 
-if (!empty($values) && isset($values['SubmitPost'])) {
-    // Add new thread in table forum_thread.
-    store_thread($current_forum, $values);
-}
-
 if (isset($origin) && $origin == 'learnpath') {
     Display::display_reduced_footer();
 } else {

+ 1 - 1
main/forum/viewforum.php

@@ -410,7 +410,7 @@ if ($origin != 'learnpath') {
     if (!empty($descriptionForum)) {
         $html .= Display::tag(
             'p',
-            strip_tags($descriptionForum),
+            Security::remove_XSS($descriptionForum),
             array(
                 'class' => 'description',
             )

+ 1 - 0
main/newscorm/lp_add_audio.php

@@ -1,5 +1,6 @@
 <?php
 /* For licensing terms, see /license.txt */
+
 /**
  * This is a learning path creation and player tool in Chamilo - previously
  * @author Julio Montoya  - Improving the list of templates

+ 1 - 4
main/newscorm/lp_view_item.php

@@ -111,8 +111,6 @@ if ($mode == 'fullpage') {
 $suredel = trim(get_lang('AreYouSureToDeleteJS'));
 ?>
 <script>
-/* <![CDATA[ */
-
 function stripslashes(str) {
     str=str.replace(/\\'/g,'\'');
     str=str.replace(/\\"/g,'"');
@@ -131,7 +129,7 @@ function confirmation(name) {
 </script>
 <?php
 
-$id = (isset($new_item_id)) ? $new_item_id : $_GET['id'];
+$id = isset($new_item_id) ? $new_item_id : $_GET['id'];
 if (is_object($_SESSION['oLP'])) {
     switch ($mode) {
         case 'fullpage':
@@ -150,5 +148,4 @@ if (is_object($_SESSION['oLP'])) {
             echo $_SESSION['oLP']->display_item($id, null, false);
             break;
     }
-
 }

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

@@ -170,14 +170,14 @@ class CForumForum
     /**
      * @var \DateTime
      *
-     * @ORM\Column(name="start_time", type="datetime", nullable=false)
+     * @ORM\Column(name="start_time", type="datetime", nullable=true)
      */
     private $startTime;
 
     /**
      * @var \DateTime
      *
-     * @ORM\Column(name="end_time", type="datetime", nullable=false)
+     * @ORM\Column(name="end_time", type="datetime", nullable=true)
      */
     private $endTime;