From 3ab37034e86a7d7ccb0d2d5f38c657d720f11153 Mon Sep 17 00:00:00 2001 From: Eric Marguin Date: Mon, 22 Jan 2007 17:46:47 +0100 Subject: [PATCH] [svn r10824] add the possibility to include forum and threads in lp --- main/forum/forumfunction.inc.php | 20 +- main/forum/newthread.php | 35 +- main/forum/viewforum.php | 75 +++-- main/forum/viewthread.php | 64 ++-- main/forum/viewthread_flat.inc.php | 21 +- main/newscorm/kevin_lp_add_item.php | 12 + main/newscorm/learnpath.class.php | 468 ++++++++++++++++++++++++++- main/newscorm/resourcelinker.inc.php | 10 +- 8 files changed, 627 insertions(+), 78 deletions(-) diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index 5a1960d897..1b8c678a6c 100644 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -1293,7 +1293,7 @@ function get_threads($forum_id) AND thread.thread_id=item_properties.ref AND item_properties.visibility='1' AND item_properties.tool='".TOOL_FORUM_THREAD."' - ORDER BY thread.thread_sticky DESC, thread.thread_date DESC"; + ORDER BY thread.thread_sticky DESC, thread.thread_date DESC"; if (is_allowed_to_edit()) { // important note: it might seem a little bit awkward that we have 'thread.locked as locked' in the sql statement @@ -1518,7 +1518,8 @@ function store_thread($values) global $table_posts; global $_user; global $_course; - global $current_forum; + global $current_forum; + global $origin; $post_date=date('Y-m-d H:i:s'); @@ -1582,8 +1583,8 @@ function store_thread($values) } else { - $message.=get_lang('ReturnTo').' '.get_lang('Forum').'
'; - $message.=get_lang('ReturnTo').' '.get_lang('Message').''; + $message.=get_lang('ReturnTo').' '.get_lang('Forum').'
'; + $message.=get_lang('ReturnTo').' '.get_lang('Message').''; } session_unregister('formelements'); @@ -1609,10 +1610,11 @@ function show_add_post_form($action='', $id='', $form_values='') { global $forum_setting; global $current_forum; - global $_user; + global $_user; + global $origin; // initiate the object - $form = new FormValidator('thread', 'post', $_SERVER['PHP_SELF'].'?forum='.$_GET['forum'].'&thread='.$_GET['thread'].'&post='.$_GET['post'].'&action='.$_GET['action']); + $form = new FormValidator('thread', 'post', $_SERVER['PHP_SELF'].'?forum='.$_GET['forum'].'&thread='.$_GET['thread'].'&post='.$_GET['post'].'&action='.$_GET['action'].'&origin='.$origin); $form->setConstants(array('forum' => '5')); // settting the form elements @@ -2351,9 +2353,11 @@ function send_mail($user_info=array(), $thread_information=array()) * @version february 2006, dokeos 1.8 */ function move_thread_form() -{ +{ + global $origin; + // initiate the object - $form = new FormValidator('movepost', 'post', $_SERVER['PHP_SELF'].'?forum='.$_GET['forum'].'&thread='.$_GET['thread'].'&action='.$_GET['action']); + $form = new FormValidator('movepost', 'post', $_SERVER['PHP_SELF'].'?forum='.$_GET['forum'].'&thread='.$_GET['thread'].'&action='.$_GET['action'].'&origin='.$origin); // the header for the form $form->addElement('header', '', get_lang('MoveThread')); // invisible form: the thread_id diff --git a/main/forum/newthread.php b/main/forum/newthread.php index 948732d8a2..5c8a7c259f 100644 --- a/main/forum/newthread.php +++ b/main/forum/newthread.php @@ -85,7 +85,15 @@ if(!api_is_allowed_to_edit()) $fck_attribute['Config']['UserStatus'] = 'student' ----------------------------------------------------------- */ include('forumconfig.inc.php'); -include('forumfunction.inc.php'); +include('forumfunction.inc.php'); + + +//are we in a lp ? +$origin = ''; +if(isset($_GET['origin'])) +{ + $origin = $_GET['origin']; +} /* @@ -129,8 +137,14 @@ if (isset($_POST['add_resources']) AND $_POST['add_resources']==get_lang('Resour Header ----------------------------------------------------------- */ -Display :: display_header($nameTools); -api_display_tool_title($nameTools); +if($origin=='learnpath') +{ + include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php'); +} else +{ + Display :: display_header(); + api_display_tool_title($nameTools); +} //echo ''; /* ----------------------------------------------------------- @@ -178,12 +192,15 @@ handle_forum_and_forumcategories(); */ echo "\n"; -// the forum category -echo "\t\n\t\t\n"; -echo "\t\n"; +// the forum category +if($origin != 'learnpath') +{ + echo "\t\n\t\t\n"; + echo "\t\n"; +} // the forum echo "\t\n"; diff --git a/main/forum/viewforum.php b/main/forum/viewforum.php index 8cb1c3cee9..d5a83615b9 100644 --- a/main/forum/viewforum.php +++ b/main/forum/viewforum.php @@ -68,7 +68,16 @@ $language_file = 'forum'; require ('../inc/global.inc.php'); require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'); include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php'); -$nameTools=get_lang('Forum'); +$nameTools=get_lang('Forum'); + + +//are we in a lp ? +$origin = ''; +if(isset($_GET['origin'])) +{ + $origin = $_GET['origin']; + $origin_string = '&origin='.$origin; +} /* ----------------------------------------------------------- @@ -107,9 +116,15 @@ $current_forum_category=get_forumcategory_information($current_forum['forum_cate $interbreadcrumb[]=array("url" => "index.php","name" => $nameTools); $interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id'],"name" => prepare4display($current_forum_category['cat_title'])); $interbreadcrumb[]=array("url" => "viewforum.php?forum=".$_GET['forum'],"name" => prepare4display($current_forum['forum_title'])); +if($origin=='learnpath') +{ + include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php'); +} else +{ + Display :: display_header(); + api_display_tool_title($nameTools); +} -Display :: display_header(); -api_display_tool_title($nameTools); //echo ''; /* @@ -171,7 +186,7 @@ if (isset($message)) // 3. a visitor is here and new threads AND allowed AND anonymous posts are allowed if (api_is_allowed_to_edit() OR ($current_forum['allow_new_threads']==1 AND isset($_user['user_id'])) OR ($current_forum['allow_new_threads']==1 AND !isset($_user['user_id']) AND $current_forum['allow_anonymous']==1)) { - echo ''.Display::return_icon('forumthread_new.gif').' '.get_lang('NewTopic').''; + echo ''.Display::return_icon('forumthread_new.gif').' '.get_lang('NewTopic').''; } /* @@ -181,12 +196,15 @@ if (api_is_allowed_to_edit() OR ($current_forum['allow_new_threads']==1 AND isse */ echo "
"; -echo ''.$current_forum_category['cat_title'].'
'; -echo ''.$current_forum_category['cat_comment'].''; -echo "
"; + echo ''.$current_forum_category['cat_title'].'
'; + echo ''.$current_forum_category['cat_comment'].''; + echo "
\n"; -// the forum category -echo "\t\n\t\t\n"; -echo "\t\n"; +// the forum category +if($origin != 'learnpath') +{ + echo "\t\n\t\t\n"; + echo "\t\n"; +} // the forum echo "\t\n"; @@ -235,7 +253,7 @@ foreach ($threads as $row) echo icon('../img/exclamation.gif'); } echo "\n"; - echo "\t\t\n"; + echo "\t\t\n"; echo "\t\t\n"; if ($row['user_id']=='0') { @@ -244,8 +262,15 @@ foreach ($threads as $row) else { $name=$row['firstname'].' '.$row['lastname']; + } + if($origin != 'learnpath') + { + echo "\t\t\n"; + } + else + { + echo "\t\t\n"; } - echo "\t\t\n"; echo "\t\t\n"; if ($row['last_poster_user_id']=='0') { @@ -256,26 +281,34 @@ foreach ($threads as $row) $name=$row['last_poster_firstname'].' '.$row['last_poster_lastname']; } // if the last post is invisible and it is not the teacher who is looking then we have to find the last visible post of the thread - if ($row['visible']=='1' OR api_is_allowed_to_edit()) - { + if (($row['visible']=='1' OR api_is_allowed_to_edit()) && $origin!='learnpath') + { $last_post=$row['thread_date']." ".get_lang('By').' '.display_user_link($row['last_poster_user_id'], $name); } - else + else if($origin!='learnpath') { $last_post_sql="SELECT post.*, user.firstname, user.lastname FROM $table_posts post, $table_users user WHERE post.poster_id=user.user_id AND visible='1' AND thread_id='".$row['thread_id']."' ORDER BY post_id DESC"; $last_post_result=api_sql_query($last_post_sql, __LINE__, __FILE__); $last_post_row=mysql_fetch_array($last_post_result); $name=$last_post_row['firstname'].' '.$last_post_row['lastname']; $last_post=$last_post_row['post_date']." ".get_lang('By').' '.display_user_link($last_post_row['poster_id'], $name); + } + else + { + $last_post_sql="SELECT post.*, user.firstname, user.lastname FROM $table_posts post, $table_users user WHERE post.poster_id=user.user_id AND visible='1' AND thread_id='".$row['thread_id']."' ORDER BY post_id DESC"; + $last_post_result=api_sql_query($last_post_sql, __LINE__, __FILE__); + $last_post_row=mysql_fetch_array($last_post_result); + $name=$last_post_row['firstname'].' '.$last_post_row['lastname']; + $last_post=$last_post_row['post_date']." ".get_lang('By').' '.$name; } echo "\t\t\n"; if (api_is_allowed_to_edit()) { echo "\t\t\n"; } echo "\t\n"; @@ -289,8 +322,8 @@ echo "
"; -echo ''.prepare4display($current_forum_category['cat_title']).'
'; -echo ''.prepare4display($current_forum_category['cat_comment']).''; -echo "
"; + echo ''.prepare4display($current_forum_category['cat_title']).'
'; + echo ''.prepare4display($current_forum_category['cat_comment']).''; + echo "
".prepare4display($row['thread_title'])."".prepare4display($row['thread_title'])."".$row['thread_replies']."".display_user_link($row['user_id'], $name)."".$name."".display_user_link($row['user_id'], $name)."".$row['thread_views']."".$last_post.""; - echo "".icon('../img/delete.gif',get_lang('Delete')).""; - display_visible_invisible_icon('thread', $row['thread_id'], $row['visibility'], array("forum"=>$_GET['forum'])); - display_lock_unlock_icon('thread',$row['thread_id'], $row['locked'], array("forum"=>$_GET['forum'])); - echo "".icon('../img/forummovepost.gif',get_lang('MoveThread')).""; + echo "".icon('../img/delete.gif',get_lang('Delete')).""; + display_visible_invisible_icon('thread', $row['thread_id'], $row['visibility'], array("forum"=>$_GET['forum'],'origin'=>$origin)); + display_lock_unlock_icon('thread',$row['thread_id'], $row['locked'], array("forum"=>$_GET['forum'],'origin'=>$origin)); + echo "".icon('../img/forummovepost.gif',get_lang('MoveThread')).""; echo "
"; FOOTER ============================================================================== */ - -Display :: display_footer(); +if($origin != 'learnpath') + Display :: display_footer(); ?> diff --git a/main/forum/viewthread.php b/main/forum/viewthread.php index 2271fb2a66..0b74815653 100644 --- a/main/forum/viewthread.php +++ b/main/forum/viewthread.php @@ -77,7 +77,15 @@ $nameTools=get_lang('Forum'); ----------------------------------------------------------- */ include('forumconfig.inc.php'); -include('forumfunction.inc.php'); +include('forumfunction.inc.php'); + + +//are we in a lp ? +$origin = ''; +if(isset($_GET['origin'])) +{ + $origin = $_GET['origin']; +} /* @@ -103,17 +111,24 @@ $whatsnew_post_info=$_SESSION['whatsnew_post_info']; ----------------------------------------------------------- Header and Breadcrumbs ----------------------------------------------------------- -*/ -$interbreadcrumb[]=array("url" => "index.php","name" => $nameTools); -$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id'],"name" => prepare4display($current_forum_category['cat_title'])); -$interbreadcrumb[]=array("url" => "viewforum.php?forum=".$_GET['forum'],"name" => prepare4display($current_forum['forum_title'])); -if ($message<>'PostDeletedSpecial') -{ - $interbreadcrumb[]=array("url" => "viewthread.php?forum=".$_GET['forum']."&thread=".$_GET['thread'],"name" => prepare4display($current_thread['thread_title'])); +*/ +if($origin=='learnpath') +{ + include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php'); +} else +{ + + $interbreadcrumb[]=array("url" => "index.php","name" => $nameTools); + $interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id'],"name" => prepare4display($current_forum_category['cat_title'])); + $interbreadcrumb[]=array("url" => "viewforum.php?forum=".$_GET['forum'],"name" => prepare4display($current_forum['forum_title'])); + if ($message<>'PostDeletedSpecial') + { + $interbreadcrumb[]=array("url" => "viewthread.php?forum=".$_GET['forum']."&thread=".$_GET['thread'],"name" => prepare4display($current_thread['thread_title'])); + } + Display :: display_header(); + api_display_tool_title($nameTools); + } - -Display :: display_header(); -api_display_tool_title($nameTools); //echo ''; /* @@ -171,9 +186,9 @@ if ($message<>'PostDeletedSpecial') // in this case the first and only post of t ----------------------------------------------------------- */ echo '
'; - echo ''.get_lang('FlatView').' | '; - echo ''.get_lang('ThreadedView').' | '; - echo ''.get_lang('NestedView').''; + echo ''.get_lang('FlatView').' | '; + echo ''.get_lang('ThreadedView').' | '; + echo ''.get_lang('NestedView').''; echo '
'; // the reply to thread link should only appear when the forum_category is not locked AND the forum is not locked AND the thread is not locked. // if one of the three levels is locked then the link should not be displayed @@ -182,7 +197,7 @@ if ($message<>'PostDeletedSpecial') // in this case the first and only post of t // The link should only appear when the user is logged in or when anonymous posts are allowed. if ($_user['user_id'] OR ($current_forum['allow_anonymous']==1 AND !$_user['user_id'])) { - echo ''.get_lang('ReplyToThread').''; + echo ''.get_lang('ReplyToThread').''; } } // note: this is to prevent that some browsers display the links over the table (FF does it but Opera doesn't) @@ -222,12 +237,15 @@ if ($message<>'PostDeletedSpecial') // in this case the first and only post of t // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table echo "\n"; - // the forum category - echo "\t\n\t\t\n"; - echo "\t\n"; + // the forum category + if($origin!='learnpath') + { + echo "\t\n\t\t\n"; + echo "\t\n"; + } // the forum echo "\t\n"; @@ -266,8 +284,8 @@ if ($message<>'PostDeletedSpecial') // in this case the first and only post of t FOOTER ============================================================================== */ - -Display :: display_footer(); +if($origin!='learnpath') + Display :: display_footer(); ?> diff --git a/main/forum/viewthread_flat.inc.php b/main/forum/viewthread_flat.inc.php index 12a43c2eef..87abf0ff65 100644 --- a/main/forum/viewthread_flat.inc.php +++ b/main/forum/viewthread_flat.inc.php @@ -83,21 +83,28 @@ foreach ($rows as $row) else { $name=$row['firstname'].' '.$row['lastname']; + } + if($origin!='learnpath') + { + echo display_user_link($row['user_id'], $name).'
'; + } + else + { + echo $name. '
'; } - echo display_user_link($row['user_id'], $name).'
'; echo $row['post_date'].'

'; // The user who posted it can edit his thread only if the course admin allowed this in the properties of the forum // The course admin him/herself can do this off course always if (($current_forum['allow_edit']==1 AND $row['user_id']==$_user['user_id']) or api_is_allowed_to_edit()) { - echo "".icon('../img/edit.gif',get_lang('Edit'))."\n"; + echo "".icon('../img/edit.gif',get_lang('Edit'))."\n"; } if (api_is_allowed_to_edit()) { - echo "".icon('../img/delete.gif',get_lang('Delete'))."\n"; - display_visible_invisible_icon('post', $row['post_id'], $row['visible'],array('forum'=>$_GET['forum'],'thread'=>$_GET['thread'] )); + echo "".icon('../img/delete.gif',get_lang('Delete'))."\n"; + display_visible_invisible_icon('post', $row['post_id'], $row['visible'],array('forum'=>$_GET['forum'],'thread'=>$_GET['thread'], 'origin'=>$origin )); echo "\n"; - echo "".icon('../img/forummovepost.gif',get_lang('Edit')).""; + echo "".icon('../img/forummovepost.gif',get_lang('Edit')).""; } echo '

'; //if (($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0) OR api_is_allowed_to_edit()) @@ -105,8 +112,8 @@ foreach ($rows as $row) { if ($_user['user_id'] OR ($current_forum['allow_anonymous']==1 AND !$_user['user_id'])) { - echo ''.get_lang('ReplyToMessage').'
'; - echo ''.get_lang('QuoteMessage').'

'; + echo ''.get_lang('ReplyToMessage').'
'; + echo ''.get_lang('QuoteMessage').'

'; } } else diff --git a/main/newscorm/kevin_lp_add_item.php b/main/newscorm/kevin_lp_add_item.php index 2c7250dffd..df2383c617 100644 --- a/main/newscorm/kevin_lp_add_item.php +++ b/main/newscorm/kevin_lp_add_item.php @@ -324,6 +324,18 @@ echo '
"; - echo ''.prepare4display($current_forum_category['cat_title']).'
'; - echo ''.prepare4display($current_forum_category['cat_comment']).''; - echo "
"; + echo ''.prepare4display($current_forum_category['cat_title']).'
'; + echo ''.prepare4display($current_forum_category['cat_comment']).''; + echo "
'; echo $_SESSION['oLP']->display_quiz_form('add', 0, $_GET['file']); + break; + + case 'forum': + + echo $_SESSION['oLP']->display_forum_form('add', 0, $_GET['forum_id']); + + break; + + case 'thread': + + echo $_SESSION['oLP']->display_thread_form('add', 0, $_GET['thread_id']); + break; case 'link': diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index 425b6ddb54..fce98cbffe 100644 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -4575,7 +4575,10 @@ class learnpath { $return .= $this->get_links(); /* get al the student publications */ - $return .= $this->get_student_publications(); + $return .= $this->get_student_publications(); + + /* get al the forums */ + $return .= $this->get_forums(); $return .= '' . "\n"; @@ -4845,6 +4848,404 @@ class learnpath { $return .= '' . "\n"; return $return; + } + +/** + * Enter description here... + * + * @param unknown_type $action + * @param unknown_type $id + * @param unknown_type $extra_info + * @return unknown + */ + function display_forum_form($action = 'add', $id = 0, $extra_info = '') + { + + $tbl_lp_item = Database::get_course_table('lp_item'); + $tbl_forum = Database::get_course_table(TABLE_FORUM); + + if($id != 0 && is_array($extra_info)) + { + $item_title = stripslashes($extra_info['title']); + } + elseif(is_numeric($extra_info)) + { + $sql_forum = " + SELECT + forum_title as title + FROM " . $tbl_forum . " + WHERE forum_id = " . $extra_info; + + $result = api_sql_query($sql_forum, __FILE__, __LINE__); + $row = Database::fetch_array($result); + + $item_title = $row['title']; + } + else + { + $item_title = ''; + } + + $return = '
'; + + if($id != 0 && is_array($extra_info)) + $parent = $extra_info['parent_item_id']; + else + $parent = 0; + + $sql = " + SELECT * + FROM " . $tbl_lp_item . " + WHERE + lp_id = " . $this->lp_id; + + $result = api_sql_query($sql, __FILE__, __LINE__); + + $arrLP = array(); + + while($row = Database::fetch_array($result)) + { + $arrLP[] = array( + 'id' => $row['id'], + 'item_type' => $row['item_type'], + 'title' => $row['title'], + 'path' => $row['path'], + 'description' => $row['description'], + 'parent_item_id' => $row['parent_item_id'], + 'previous_item_id' => $row['previous_item_id'], + 'next_item_id' => $row['next_item_id'], + 'display_order' => $row['display_order']); + } + + $this->tree_array($arrLP); + + $arrLP = $this->arrMenu; + + unset($this->arrMenu); + + if($action == 'add') + $return .= '

'.get_lang("CreateTheForum").' :

' . "\n"; + elseif($action == 'move') + $return .= '

'.get_lang("MoveTheCurrentForum").' :

' . "\n"; + else + $return .= '

'.get_lang("EditCurrentForum").' :

' . "\n"; + + $return .= '
' . "\n"; + + $return .= "\t" . '
' . "\n"; + + $return .= "\t\t" . '' . "\n"; + + $return .= "\t\t\t" . '' . "\n"; + $return .= "\t\t\t" . '' . "\n"; + + $return .= "\t\t" . '' . "\n"; + + $return .= "\t\t" . '' . "\n"; + + $return .= "\t\t\t" . '' . "\n"; + $return .= "\t\t\t" . '' . "\n"; + + $return .= "\t\t" . '' . "\n"; + + if($action != 'move') + { + $return .= "\t\t" . '' . "\n"; + + $return .= "\t\t\t" . '' . "\n"; + $return .= "\t\t\t" . '' . "\n"; + + $return .= "\t\t" . '' . "\n"; + + $return .= "\t\t" . '' . "\n"; + + //Remove temporaly the test description + //$return .= "\t\t\t" . '' . "\n"; + //$return .= "\t\t\t" . '' . "\n"; + + $return .= "\t\t" . '' . "\n"; + } + + $return .= "\t\t" . '' . "\n"; + + $return .= "\t\t\t" . '' . "\n"; + + $return .= "\t\t" . '' . "\n"; + + $return .= "\t" . '
' . "\n"; + + $return .= "\t\t\t\t" . ''; + + $return .= "\t\t\t" . '
' . "\n"; + + $return .= "\t\t\t\t" . ''; + + $return .= "\t\t\t" . '
' . "\n"; + + if($action == 'move') + { + $return .= "\t" . '' . "\n"; + $return .= "\t" . '' . "\n"; + } + + if(is_numeric($extra_info)) + { + $return .= "\t" . '' . "\n"; + } + elseif(is_array($extra_info)) + { + $return .= "\t" . '' . "\n"; + } + + $return .= "\t" . '' . "\n"; + $return .= "\t" . '' . "\n"; + + $return .= '' . "\n"; + + $return .= '' . "\n"; + return $return; + } + +function display_thread_form($action = 'add', $id = 0, $extra_info = '') + { + + $tbl_lp_item = Database::get_course_table('lp_item'); + $tbl_forum = Database::get_course_table(TABLE_FORUM_THREAD); + + if($id != 0 && is_array($extra_info)) + { + $item_title = stripslashes($extra_info['title']); + } + elseif(is_numeric($extra_info)) + { + $sql_forum = " + SELECT + thread_title as title + FROM " . $tbl_forum . " + WHERE thread_id = " . $extra_info; + + $result = api_sql_query($sql_forum, __FILE__, __LINE__); + $row = Database::fetch_array($result); + + $item_title = $row['title']; + } + else + { + $item_title = ''; + } + + $return = '
'; + + if($id != 0 && is_array($extra_info)) + $parent = $extra_info['parent_item_id']; + else + $parent = 0; + + $sql = " + SELECT * + FROM " . $tbl_lp_item . " + WHERE + lp_id = " . $this->lp_id; + + $result = api_sql_query($sql, __FILE__, __LINE__); + + $arrLP = array(); + + while($row = Database::fetch_array($result)) + { + $arrLP[] = array( + 'id' => $row['id'], + 'item_type' => $row['item_type'], + 'title' => $row['title'], + 'path' => $row['path'], + 'description' => $row['description'], + 'parent_item_id' => $row['parent_item_id'], + 'previous_item_id' => $row['previous_item_id'], + 'next_item_id' => $row['next_item_id'], + 'display_order' => $row['display_order']); + } + + $this->tree_array($arrLP); + + $arrLP = $this->arrMenu; + + unset($this->arrMenu); + + if($action == 'add') + $return .= '

'.get_lang("CreateTheForum").' :

' . "\n"; + elseif($action == 'move') + $return .= '

'.get_lang("MoveTheCurrentForum").' :

' . "\n"; + else + $return .= '

'.get_lang("EditCurrentForum").' :

' . "\n"; + + $return .= '
' . "\n"; + + $return .= "\t" . '' . "\n"; + + $return .= "\t\t" . '' . "\n"; + + $return .= "\t\t\t" . '' . "\n"; + $return .= "\t\t\t" . '' . "\n"; + + $return .= "\t\t" . '' . "\n"; + + $return .= "\t\t" . '' . "\n"; + + $return .= "\t\t\t" . '' . "\n"; + $return .= "\t\t\t" . '' . "\n"; + + $return .= "\t\t" . '' . "\n"; + + if($action != 'move') + { + $return .= "\t\t" . '' . "\n"; + + $return .= "\t\t\t" . '' . "\n"; + $return .= "\t\t\t" . '' . "\n"; + + $return .= "\t\t" . '' . "\n"; + + $return .= "\t\t" . '' . "\n"; + + //Remove temporaly the test description + //$return .= "\t\t\t" . '' . "\n"; + //$return .= "\t\t\t" . '' . "\n"; + + $return .= "\t\t" . '' . "\n"; + } + + $return .= "\t\t" . '' . "\n"; + + $return .= "\t\t\t" . '' . "\n"; + + $return .= "\t\t" . '' . "\n"; + + $return .= "\t" . '
' . "\n"; + + $return .= "\t\t\t\t" . ''; + + $return .= "\t\t\t" . '
' . "\n"; + + $return .= "\t\t\t\t" . ''; + + $return .= "\t\t\t" . '
' . "\n"; + + if($action == 'move') + { + $return .= "\t" . '' . "\n"; + $return .= "\t" . '' . "\n"; + } + + if(is_numeric($extra_info)) + { + $return .= "\t" . '' . "\n"; + } + elseif(is_array($extra_info)) + { + $return .= "\t" . '' . "\n"; + } + + $return .= "\t" . '' . "\n"; + $return .= "\t" . '' . "\n"; + + $return .= '
' . "\n"; + + $return .= '
' . "\n"; + return $return; } /** @@ -5075,12 +5476,17 @@ class learnpath { if($id != 0 && is_array($extra_info)) { $item_title = stripslashes($extra_info['title']); - $item_description = stripslashes($extra_info['description']); + $item_description = stripslashes($extra_info['description']); + if(empty($item_title)) + { + $path_parts = pathinfo($extra_info['path']); + $item_title = stripslashes($path_parts['filename']); + } } elseif(is_numeric($extra_info)) { $sql_doc = " - SELECT title + SELECT path, title FROM " . $tbl_doc . " WHERE id = " . $extra_info; @@ -5092,13 +5498,20 @@ class learnpath { for($i = 0; $i < count($explode) - 1; $i++) $item_title .= $explode[$i]; - $item_title = str_replace('_', ' ', $item_title); + $item_title = str_replace('_', ' ', $item_title); + if(empty($item_title)) + { + $path_parts = pathinfo($row['path']); + $item_title = stripslashes($path_parts['filename']); + } + } else { $item_title = ''; $item_description = ''; - } + } + $return = '
'; @@ -6322,6 +6735,51 @@ class learnpath { $return .= '
'; return $return; + } + + function get_forums() + { + include ('../forum/forumfunction.inc.php'); + include ('../forum/forumconfig.inc.php'); + global $table_forums, $table_threads,$table_posts, $table_item_property, $table_users; + $table_forums = Database :: get_course_table(TABLE_FORUM); + $table_threads = Database :: get_course_table(TABLE_FORUM_THREAD); + $table_posts = Database :: get_course_table(TABLE_FORUM_POST); + $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); + $table_users = Database :: get_main_table(TABLE_MAIN_USER); + $a_forums = get_forums(); + + $return .= '
'.get_lang('Forums').'
'; + $return .= '
'; + + foreach($a_forums as $forum) + { + $return .= '
'; + $return .= ' + '; + $return .= ''; + $return .= ' + ' . $forum['forum_title'] . '
'; + } + + return $return; } } diff --git a/main/newscorm/resourcelinker.inc.php b/main/newscorm/resourcelinker.inc.php index 7ade39f678..5034d292f8 100644 --- a/main/newscorm/resourcelinker.inc.php +++ b/main/newscorm/resourcelinker.inc.php @@ -1318,7 +1318,7 @@ function get_addedresource_link_in_learnpath($type, $id, $id_in_path) } else { - $link .= "../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]; + $link .= "../forum/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]; } break; @@ -1879,20 +1879,20 @@ function rl_get_resource_link_for_learnpath($course_code, $learnpath_id, $id_in_ break; case TOOL_FORUM: - $link .= $main_dir_path.'phpbb/viewforum.php?forum='.$id.'&lp=true'; + $link .= $main_dir_path.'forum/viewforum.php?forum='.$id.'&lp=true&origin=learnpath'; break; case TOOL_THREAD: //forum post - $tbl_topics = Database::get_course_table(TOOL_FORUM_THREAD,$_course['database']); + $tbl_topics = Database::get_course_table(TABLE_FORUM_THREAD,$_course['database']); $sql="SELECT * FROM $tbl_topics where thread_id=$id"; $result= api_sql_query($sql,__FILE__,__LINE__); $myrow=Database::fetch_array($result); - $link .= $main_dir_path.'phpbb/viewtopic.php?topic='.$id.'' . + $link .= $main_dir_path.'forum/viewthread.php?origin=learnpath&thread='.$id.'' . '&forum='.$myrow['forum_id'].'&lp=true'; break; case TOOL_POST: - $tbl_post = Database::get_course_table(TABLE_FORUM_POST,$_course['database']); + $tbl_post = Database::get_course_table(TABLE_FORUM_THREAD,$_course['database']); $result= api_sql_query("SELECT * FROM $tbl_post where post_id=$id",__FILE__,__LINE__); $myrow=Database::fetch_array($result); $title=$myrow['post_title'];