Explorar o código

Merge branch '1.10.x' of github.com:chamilo/chamilo-lms into 1.10.x

Julio Montoya %!s(int64=9) %!d(string=hai) anos
pai
achega
4eb5d9a008

+ 7 - 1
main/forum/forumfunction.inc.php

@@ -2582,7 +2582,13 @@ function show_add_post_form($current_forum, $forum_setting, $action = '', $id =
     $form = new FormValidator(
         'thread',
         'post',
-        api_get_self().'?forum='.intval($my_forum).'&gradebook='.$my_gradebook.'&thread='.intval($myThread).'&post='.intval($my_post).'&action='.$action.'&'.api_get_cidreq()
+        api_get_self() . '?' . http_build_query([
+            'forum' => intval($my_forum),
+            'gradebook' => $my_gradebook,
+            'thread' => intval($myThread),
+            'post' => intval($my_post),
+            'action' => $action,
+        ]) . '&' . api_get_cidreq()
     );
     $form->setConstants(array('forum' => '5'));
 

+ 12 - 5
main/forum/reply.php

@@ -177,8 +177,6 @@ if ($origin != 'learnpath') {
     echo '<a href="viewthread.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&gradebook='.$gradebook.'&thread='.Security::remove_XSS($_GET['thread']).'&origin='.$origin.'">'.
         Display::return_icon('back.png', get_lang('BackToThread'), '', ICON_SIZE_MEDIUM).'</a>';
     echo '</div>';
-} else {
-    echo '<div style="height:15px">&nbsp;</div>';
 }
 /*New display forum div*/
 echo '<div class="forum_title">';
@@ -199,11 +197,20 @@ $values = show_add_post_form(
     $my_post,
     $my_elements
 );
-if (!empty($values) AND isset($_POST['SubmitPost'])) {
+if (!empty($values) && isset($_POST['SubmitPost'])) {
     $result = store_reply($current_forum, $values);
     //@todo split the show_add_post_form function
-
-    $url = 'viewthread.php?forum='.$current_thread['forum_id'].'&gradebook='.$gradebook.'&thread='.intval($_GET['thread']).'&gidReq='.api_get_group_id().'&origin='.(isset($origin)?$origin:'').'&msg='.$result['msg'].'&type='.$result['type'];
+    $origin = isset($_GET['origin']) && $_GET['origin'] === 'learnpath' ? 'learnpath' : null;
+
+    $url = 'viewthread.php?' . http_build_query([
+        'forum' => $current_thread['forum_id'],
+        'gradebook' => $gradebook,
+        'thread' => intval($_GET['thread']),
+        'gidReq' => api_get_group_id(),
+        'origin' => $origin,
+        'msg' => $result['msg'],
+        'type' => $result['type']
+    ]);
     echo '
     <script>
     window.location = "'.$url.'";

+ 3 - 5
main/forum/viewthread.php

@@ -262,17 +262,15 @@ if ($my_message != 'PostDeletedSpecial') {
 
     switch ($viewMode) {
         case 'flat':
+            //no break
+        default:
             include_once 'viewthread_flat.inc.php';
             break;
         case 'threaded':
-            //include_once 'viewthread_threaded.inc.php';
-            //break;
+            //no break;
         case 'nested':
             include_once 'viewthread_nested.inc.php';
             break;
-        default:
-            include_once 'viewthread_flat.inc.php';
-            break;
     }
 }
 

+ 20 - 7
main/forum/viewthread_flat.inc.php

@@ -36,6 +36,8 @@ if (isset($current_thread['thread_id'])) {
     $closedPost = null;
 
     if (!empty($rows)) {
+        $postCount = count($rows);
+
         foreach ($rows as $row) {
             if ($row['user_id'] == '0') {
                 $name = prepare4display($row['poster_name']);
@@ -118,20 +120,31 @@ if (isset($current_thread['thread_id'])) {
                     array('class' => 'title-username')
                 );
             } else {
+                $name = Display::tag('strong', "#" . $postCount--, ['class' => 'text-info']) . " | $name";
+
                 $html .= Display::tag(
-                    'span',
+                    'p',
                     $name,
                     array(
-                        'title' => api_htmlentities($username, ENT_QUOTES)
+                        'title' => api_htmlentities($username, ENT_QUOTES),
+                        'class' => 'lead'
                     )
                 );
             }
 
-            $html .= Display::tag(
-                'p',
-                api_convert_and_format_date($row['post_date']),
-                array('class' => 'post-date')
-            );
+            if ($origin != 'learnpath') {
+                $html .= Display::tag(
+                    'p',
+                    api_convert_and_format_date($row['post_date']),
+                    array('class' => 'post-date')
+                );
+            } else {
+                $html .= Display::tag(
+                    'p',
+                    api_convert_and_format_date($row['post_date'], DATE_TIME_FORMAT_SHORT),
+                    array('class' => 'text-muted')
+                );
+            }
 
             // get attach id
             $attachment_list = get_attachment($row['post_id']);

+ 35 - 12
main/forum/viewthread_nested.inc.php

@@ -34,6 +34,8 @@ $sessionId = api_get_session_id();
 $currentThread = get_thread_information($_GET['thread']);
 $userId = api_get_user_id();
 
+$postCount = count($rows);
+
 foreach ($rows as $post) {
     // The style depends on the status of the message: approved or not.
     if ($post['visible'] == '0') {
@@ -68,19 +70,40 @@ foreach ($rows as $post) {
         $name = api_get_person_name($post['firstname'], $post['lastname']);
     }
 
-    if (api_get_course_setting('allow_user_image_forum')) {
-        $html .= '<div class="thumbnail">' . display_user_image($post['user_id'], $name, $origin) . '</div>';
+    if ($origin != 'learnpath') {
+        if (api_get_course_setting('allow_user_image_forum')) {
+            $html .= '<div class="thumbnail">' . display_user_image($post['user_id'], $name, $origin) . '</div>';
+        }
+
+        $html .= Display::tag(
+            'h4',
+            display_user_link($post['user_id'], $name, $origin, $username),
+            array('class' => 'title-username')
+        );
+    } else {
+        $html .= Display::tag(
+            'p',
+            $name,
+            array(
+                'title' => api_htmlentities($username, ENT_QUOTES),
+                'class' => 'lead'
+            )
+        );
+    }
+
+    if ($origin != 'learnpath') {
+        $html .= Display::tag(
+            'p',
+            api_convert_and_format_date($post['post_date']),
+            array('class' => 'post-date')
+        );
+    } else {
+        $html .= Display::tag(
+            'p',
+            api_convert_and_format_date($post['post_date'], DATE_TIME_FORMAT_SHORT),
+            array('class' => 'text-muted')
+        );
     }
-    $html .= Display::tag(
-        'h4',
-        display_user_link($post['user_id'], $name, $origin, $username),
-        array('class' => 'title-username')
-    );
-    $html .= Display::tag(
-        'p',
-        api_convert_and_format_date($post['post_date']),
-        array('class' => 'post-date')
-    );
 
     // get attach id
     $attachment_list = get_attachment($post['post_id']);