[svn r10824] add the possibility to include forum and threads in lp

skala
Eric Marguin 19 years ago
parent c834eb0c71
commit 3ab37034e8
  1. 20
      main/forum/forumfunction.inc.php
  2. 35
      main/forum/newthread.php
  3. 75
      main/forum/viewforum.php
  4. 64
      main/forum/viewthread.php
  5. 21
      main/forum/viewthread_flat.inc.php
  6. 12
      main/newscorm/kevin_lp_add_item.php
  7. 468
      main/newscorm/learnpath.class.php
  8. 10
      main/newscorm/resourcelinker.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').' <a href="viewforum.php?forum='.$values['forum_id'].'">'.get_lang('Forum').'</a><br />';
$message.=get_lang('ReturnTo').' <a href="viewthread.php?forum='.$values['forum_id'].'&amp;thread='.$last_thread_id.'">'.get_lang('Message').'</a>';
$message.=get_lang('ReturnTo').' <a href="viewforum.php?forum='.$values['forum_id'].'&origin='.$origin.'">'.get_lang('Forum').'</a><br />';
$message.=get_lang('ReturnTo').' <a href="viewthread.php?forum='.$values['forum_id'].'&origin='.$origin.'&amp;thread='.$last_thread_id.'">'.get_lang('Message').'</a>';
}
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

@ -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 '<link href="forumstyles.css" rel="stylesheet" type="text/css" />';
/*
-----------------------------------------------------------
@ -178,12 +192,15 @@ handle_forum_and_forumcategories();
*/
echo "<table class=\"data_table\" width='100%'>\n";
// the forum category
echo "\t<tr>\n\t\t<th style=\"padding-left:5px;\" align=\"left\" colspan=\"2\">";
echo '<a href="index.php" '.class_visible_invisible($current_forum_category['visibility']).'>'.$current_forum_category['cat_title'].'</a><br />';
echo '<span>'.$current_forum_category['cat_comment'].'</span>';
echo "</th>\n";
echo "\t</tr>\n";
// the forum category
if($origin != 'learnpath')
{
echo "\t<tr>\n\t\t<th style=\"padding-left:5px;\" align=\"left\" colspan=\"2\">";
echo '<a href="index.php?origin='.$origin.'" '.class_visible_invisible($current_forum_category['visibility']).'>'.$current_forum_category['cat_title'].'</a><br />';
echo '<span>'.$current_forum_category['cat_comment'].'</span>';
echo "</th>\n";
echo "\t</tr>\n";
}
// the forum
echo "\t<tr class=\"forum_header\">\n";

@ -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 '<link href="forumstyles.css" rel="stylesheet" type="text/css" />';
/*
@ -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 '<a href="newthread.php?forum='.$_GET['forum'].'">'.Display::return_icon('forumthread_new.gif').' '.get_lang('NewTopic').'</a>';
echo '<a href="newthread.php?forum='.$_GET['forum'].$origin_string.'">'.Display::return_icon('forumthread_new.gif').' '.get_lang('NewTopic').'</a>';
}
/*
@ -181,12 +196,15 @@ if (api_is_allowed_to_edit() OR ($current_forum['allow_new_threads']==1 AND isse
*/
echo "<table class=\"data_table\" width='100%'>\n";
// the forum category
echo "\t<tr>\n\t\t<th style=\"padding-left:5px;\" align=\"left\" colspan=\"7\">";
echo '<a href="index.php" '.class_visible_invisible($current_forum_category['visibility']).'>'.prepare4display($current_forum_category['cat_title']).'</a><br />';
echo '<span>'.prepare4display($current_forum_category['cat_comment']).'</span>';
echo "</th>\n";
echo "\t</tr>\n";
// the forum category
if($origin != 'learnpath')
{
echo "\t<tr>\n\t\t<th style=\"padding-left:5px;\" align=\"left\" colspan=\"7\">";
echo '<a href="index.php" '.class_visible_invisible($current_forum_category['visibility']).'>'.prepare4display($current_forum_category['cat_title']).'</a><br />';
echo '<span>'.prepare4display($current_forum_category['cat_comment']).'</span>';
echo "</th>\n";
echo "\t</tr>\n";
}
// the forum
echo "\t<tr class=\"forum_header\">\n";
@ -235,7 +253,7 @@ foreach ($threads as $row)
echo icon('../img/exclamation.gif');
}
echo "</td>\n";
echo "\t\t<td><a href=\"viewthread.php?forum=".$_GET['forum']."&amp;thread=".$row['thread_id']."\" ".class_visible_invisible($row['visibility']).">".prepare4display($row['thread_title'])."</a></td>\n";
echo "\t\t<td><a href=\"viewthread.php?forum=".$_GET['forum']."&amp;thread=".$row['thread_id'].$origin_string."\" ".class_visible_invisible($row['visibility']).">".prepare4display($row['thread_title'])."</a></td>\n";
echo "\t\t<td>".$row['thread_replies']."</td>\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<td>".display_user_link($row['user_id'], $name)."</td>\n";
}
else
{
echo "\t\t<td>".$name."</td>\n";
}
echo "\t\t<td>".display_user_link($row['user_id'], $name)."</td>\n";
echo "\t\t<td>".$row['thread_views']."</td>\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<td>".$last_post."</td>\n";
if (api_is_allowed_to_edit())
{
echo "\t\t<td>";
echo "<a href=\"".$_SERVER['PHP_SELF']."?forum=".$_GET['forum']."&amp;action=delete&amp;content=thread&amp;id=".$row['thread_id']."\" onclick=\"javascript:if(!confirm('".addslashes(htmlentities(get_lang("DeleteCompleteThread")))."')) return false;\">".icon('../img/delete.gif',get_lang('Delete'))."</a>";
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 "<a href=\"viewforum.php?forum=".$_GET['forum']."&amp;action=move&amp;thread=".$row['thread_id']."\">".icon('../img/forummovepost.gif',get_lang('MoveThread'))."</a>";
echo "<a href=\"".$_SERVER['PHP_SELF']."?forum=".$_GET['forum']."&amp;action=delete&amp;content=thread&amp;id=".$row['thread_id'].$origin_string."\" onclick=\"javascript:if(!confirm('".addslashes(htmlentities(get_lang("DeleteCompleteThread")))."')) return false;\">".icon('../img/delete.gif',get_lang('Delete'))."</a>";
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 "<a href=\"viewforum.php?forum=".$_GET['forum']."&amp;action=move&amp;thread=".$row['thread_id'].$origin_string."\">".icon('../img/forummovepost.gif',get_lang('MoveThread'))."</a>";
echo "</td>\n";
}
echo "\t</tr>\n";
@ -289,8 +322,8 @@ echo "</table>";
FOOTER
==============================================================================
*/
Display :: display_footer();
if($origin != 'learnpath')
Display :: display_footer();
?>

@ -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']."&amp;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']."&amp;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 '<link href="forumstyles.css" rel="stylesheet" type="text/css" />';
/*
@ -171,9 +186,9 @@ if ($message<>'PostDeletedSpecial') // in this case the first and only post of t
-----------------------------------------------------------
*/
echo '<div style="float:right;">';
echo '<a href="viewthread.php?forum='.$_GET['forum'].'&amp;thread='.$_GET['thread'].'&amp;view=flat">'.get_lang('FlatView').'</a> | ';
echo '<a href="viewthread.php?forum='.$_GET['forum'].'&amp;thread='.$_GET['thread'].'&amp;view=threaded">'.get_lang('ThreadedView').'</a> | ';
echo '<a href="viewthread.php?forum='.$_GET['forum'].'&amp;thread='.$_GET['thread'].'&amp;view=nested">'.get_lang('NestedView').'</a>';
echo '<a href="viewthread.php?forum='.$_GET['forum'].'&amp;thread='.$_GET['thread'].'&amp;view=flat&origin='.$origin.'">'.get_lang('FlatView').'</a> | ';
echo '<a href="viewthread.php?forum='.$_GET['forum'].'&amp;thread='.$_GET['thread'].'&amp;view=threaded&origin='.$origin.'">'.get_lang('ThreadedView').'</a> | ';
echo '<a href="viewthread.php?forum='.$_GET['forum'].'&amp;thread='.$_GET['thread'].'&amp;view=nested&origin='.$origin.'">'.get_lang('NestedView').'</a>';
echo '</div>';
// 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 '<a href="reply.php?forum='.$_GET['forum'].'&amp;thread='.$_GET['thread'].'&amp;action=replythread">'.get_lang('ReplyToThread').'</a>';
echo '<a href="reply.php?forum='.$_GET['forum'].'&amp;thread='.$_GET['thread'].'&amp;action=replythread&origin='.$origin.'">'.get_lang('ReplyToThread').'</a>';
}
}
// 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 "<table class=\"data_table\" width='100%'>\n";
// the forum category
echo "\t<tr>\n\t\t<th style=\"padding-left:5px;\" align=\"left\" colspan=\"6\">";
echo '<a href="index.php" '.class_visible_invisible($current_forum_category['visibility']).'>'.prepare4display($current_forum_category['cat_title']).'</a><br />';
echo '<span>'.prepare4display($current_forum_category['cat_comment']).'</span>';
echo "</th>\n";
echo "\t</tr>\n";
// the forum category
if($origin!='learnpath')
{
echo "\t<tr>\n\t\t<th style=\"padding-left:5px;\" align=\"left\" colspan=\"6\">";
echo '<a href="index.php" '.class_visible_invisible($current_forum_category['visibility']).'>'.prepare4display($current_forum_category['cat_title']).'</a><br />';
echo '<span>'.prepare4display($current_forum_category['cat_comment']).'</span>';
echo "</th>\n";
echo "\t</tr>\n";
}
// the forum
echo "\t<tr class=\"forum_header\">\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();
?>

@ -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).'<br />';
}
else
{
echo $name. '<br />';
}
echo display_user_link($row['user_id'], $name).'<br />';
echo $row['post_date'].'<br /><br />';
// 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 "<a href=\"editpost.php?forum=".$_GET['forum']."&amp;thread=".$_GET['thread']."&amp;post=".$row['post_id']."\">".icon('../img/edit.gif',get_lang('Edit'))."</a>\n";
echo "<a href=\"editpost.php?forum=".$_GET['forum']."&amp;thread=".$_GET['thread']."&amp;post=".$row['post_id']."&origin=".$origin."\">".icon('../img/edit.gif',get_lang('Edit'))."</a>\n";
}
if (api_is_allowed_to_edit())
{
echo "<a href=\"".$_SERVER['PHP_SELF']."?forum=".$_GET['forum']."&amp;thread=".$_GET['thread']."&amp;action=delete&amp;content=post&amp;id=".$row['post_id']."\" onclick=\"javascript:if(!confirm('".addslashes(htmlentities(get_lang("DeletePost")))."')) return false;\">".icon('../img/delete.gif',get_lang('Delete'))."</a>\n";
display_visible_invisible_icon('post', $row['post_id'], $row['visible'],array('forum'=>$_GET['forum'],'thread'=>$_GET['thread'] ));
echo "<a href=\"".$_SERVER['PHP_SELF']."?forum=".$_GET['forum']."&amp;thread=".$_GET['thread']."&amp;action=delete&amp;content=post&amp;id=".$row['post_id']."&origin=".$origin."\" onclick=\"javascript:if(!confirm('".addslashes(htmlentities(get_lang("DeletePost")))."')) return false;\">".icon('../img/delete.gif',get_lang('Delete'))."</a>\n";
display_visible_invisible_icon('post', $row['post_id'], $row['visible'],array('forum'=>$_GET['forum'],'thread'=>$_GET['thread'], 'origin'=>$origin ));
echo "\n";
echo "<a href=\"viewthread.php?forum=".$_GET['forum']."&amp;thread=".$_GET['thread']."&amp;action=move&amp;post=".$row['post_id']."\">".icon('../img/forummovepost.gif',get_lang('Edit'))."</a>";
echo "<a href=\"viewthread.php?forum=".$_GET['forum']."&amp;thread=".$_GET['thread']."&amp;action=move&amp;post=".$row['post_id']."&origin=".$origin."\">".icon('../img/forummovepost.gif',get_lang('Edit'))."</a>";
}
echo '<br /><br />';
//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 '<a href="reply.php?forum='.$_GET['forum'].'&amp;thread='.$_GET['thread'].'&amp;post='.$row['post_id'].'&amp;action=replymessage">'.get_lang('ReplyToMessage').'</a><br />';
echo '<a href="reply.php?forum='.$_GET['forum'].'&amp;thread='.$_GET['thread'].'&amp;post='.$row['post_id'].'&amp;action=quote">'.get_lang('QuoteMessage').'</a><br /><br />';
echo '<a href="reply.php?forum='.$_GET['forum'].'&amp;thread='.$_GET['thread'].'&amp;post='.$row['post_id'].'&amp;action=replymessage&origin='.$origin.'">'.get_lang('ReplyToMessage').'</a><br />';
echo '<a href="reply.php?forum='.$_GET['forum'].'&amp;thread='.$_GET['thread'].'&amp;post='.$row['post_id'].'&amp;action=quote&origin='.$origin.'">'.get_lang('QuoteMessage').'</a><br /><br />';
}
}
else

@ -324,6 +324,18 @@ echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
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':

@ -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 .= '</div>' . "\n";
@ -4845,6 +4848,404 @@ class learnpath {
$return .= '</div>' . "\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 = '<div style="margin:3px 10px;">';
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 .= '<p class="lp_title">'.get_lang("CreateTheForum").' :</p>' . "\n";
elseif($action == 'move')
$return .= '<p class="lp_title">'.get_lang("MoveTheCurrentForum").' :</p>' . "\n";
else
$return .= '<p class="lp_title">'.get_lang("EditCurrentForum").' :</p>' . "\n";
$return .= '<form method="POST">' . "\n";
$return .= "\t" . '<table cellpadding="0" cellspacing="0" class="lp_form">' . "\n";
$return .= "\t\t" . '<tr>' . "\n";
$return .= "\t\t\t" . '<td class="label"><label for="idParent">'.get_lang("Parent").' :</label></td>' . "\n";
$return .= "\t\t\t" . '<td class="input">' . "\n";
$return .= "\t\t\t\t" . '<select id="idParent" name="parent" onchange="load_cbo(this.value);" size="1">';
$return .= "\t\t\t\t\t" . '<option class="top" value="0">' . $this->name . '</option>';
$arrHide = array($id);
for($i = 0; $i < count($arrLP); $i++)
{
if($action != 'add')
{
if(($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter') && !in_array($arrLP[$i]['id'], $arrHide) && !in_array($arrLP[$i]['parent_item_id'], $arrHide))
{
$return .= "\t\t\t\t\t" . '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . html_entity_decode(stripslashes($arrLP[$i]['title'])) . '</option>';
}
else
{
$arrHide[] = $arrLP[$i]['id'];
}
}
else
{
if($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter')
$return .= "\t\t\t\t\t" . '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . html_entity_decode(stripslashes($arrLP[$i]['title'])) . '</option>';
}
}
reset($arrLP);
$return .= "\t\t\t\t" . '</select>';
$return .= "\t\t\t" . '</td>' . "\n";
$return .= "\t\t" . '</tr>' . "\n";
$return .= "\t\t" . '<tr>' . "\n";
$return .= "\t\t\t" . '<td class="label"><label for="idPosition">'.get_lang("Position").' :</label></td>' . "\n";
$return .= "\t\t\t" . '<td class="input">' . "\n";
$return .= "\t\t\t\t" . '<select id="idPosition" name="previous" size="1">';
$return .= "\t\t\t\t\t" . '<option class="top" value="0">First position</option>';
for($i = 0; $i < count($arrLP); $i++)
{
if($arrLP[$i]['parent_item_id'] == $parent && $arrLP[$i]['id'] != $id)
{
if($extra_info['previous_item_id'] == $arrLP[$i]['id'])
$selected = 'selected="selected" ';
elseif($action == 'add')
$selected = 'selected="selected" ';
else
$selected = '';
$return .= "\t\t\t\t\t" . '<option ' . $selected . 'value="' . $arrLP[$i]['id'] . '">'.get_lang("After").' "' . html_entity_decode(stripslashes($arrLP[$i]['title'])) . '"</option>';
}
}
$return .= "\t\t\t\t" . '</select>';
$return .= "\t\t\t" . '</td>' . "\n";
$return .= "\t\t" . '</tr>' . "\n";
if($action != 'move')
{
$return .= "\t\t" . '<tr>' . "\n";
$return .= "\t\t\t" . '<td class="label"><label for="idTitle">'.get_lang("Title").' :</label></td>' . "\n";
$return .= "\t\t\t" . '<td class="input"><input id="idTitle" name="title" type="text" value="' . $item_title . '" /></td>' . "\n";
$return .= "\t\t" . '</tr>' . "\n";
$return .= "\t\t" . '<tr>' . "\n";
//Remove temporaly the test description
//$return .= "\t\t\t" . '<td class="label"><label for="idDescription">'.get_lang("Description").' :</label></td>' . "\n";
//$return .= "\t\t\t" . '<td class="input"><textarea id="idDescription" name="description" rows="4">' . $item_description . '</textarea></td>' . "\n";
$return .= "\t\t" . '</tr>' . "\n";
}
$return .= "\t\t" . '<tr>' . "\n";
$return .= "\t\t\t" . '<td colspan="2"><input class="button" name="submit_button" type="submit" value="OK" /></td>' . "\n";
$return .= "\t\t" . '</tr>' . "\n";
$return .= "\t" . '</table>' . "\n";
if($action == 'move')
{
$return .= "\t" . '<input name="title" type="hidden" value="' . $item_title . '" />' . "\n";
$return .= "\t" . '<input name="description" type="hidden" value="' . $item_description . '" />' . "\n";
}
if(is_numeric($extra_info))
{
$return .= "\t" . '<input name="path" type="hidden" value="' . $extra_info . '" />' . "\n";
}
elseif(is_array($extra_info))
{
$return .= "\t" . '<input name="path" type="hidden" value="' . $extra_info['path'] . '" />' . "\n";
}
$return .= "\t" . '<input name="type" type="hidden" value="'.TOOL_FORUM.'" />' . "\n";
$return .= "\t" . '<input name="post_time" type="hidden" value="' . time() . '" />' . "\n";
$return .= '</form>' . "\n";
$return .= '</div>' . "\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 = '<div style="margin:3px 10px;">';
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 .= '<p class="lp_title">'.get_lang("CreateTheForum").' :</p>' . "\n";
elseif($action == 'move')
$return .= '<p class="lp_title">'.get_lang("MoveTheCurrentForum").' :</p>' . "\n";
else
$return .= '<p class="lp_title">'.get_lang("EditCurrentForum").' :</p>' . "\n";
$return .= '<form method="POST">' . "\n";
$return .= "\t" . '<table cellpadding="0" cellspacing="0" class="lp_form">' . "\n";
$return .= "\t\t" . '<tr>' . "\n";
$return .= "\t\t\t" . '<td class="label"><label for="idParent">'.get_lang("Parent").' :</label></td>' . "\n";
$return .= "\t\t\t" . '<td class="input">' . "\n";
$return .= "\t\t\t\t" . '<select id="idParent" name="parent" onchange="load_cbo(this.value);" size="1">';
$return .= "\t\t\t\t\t" . '<option class="top" value="0">' . $this->name . '</option>';
$arrHide = array($id);
for($i = 0; $i < count($arrLP); $i++)
{
if($action != 'add')
{
if(($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter') && !in_array($arrLP[$i]['id'], $arrHide) && !in_array($arrLP[$i]['parent_item_id'], $arrHide))
{
$return .= "\t\t\t\t\t" . '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . html_entity_decode(stripslashes($arrLP[$i]['title'])) . '</option>';
}
else
{
$arrHide[] = $arrLP[$i]['id'];
}
}
else
{
if($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter')
$return .= "\t\t\t\t\t" . '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . html_entity_decode(stripslashes($arrLP[$i]['title'])) . '</option>';
}
}
reset($arrLP);
$return .= "\t\t\t\t" . '</select>';
$return .= "\t\t\t" . '</td>' . "\n";
$return .= "\t\t" . '</tr>' . "\n";
$return .= "\t\t" . '<tr>' . "\n";
$return .= "\t\t\t" . '<td class="label"><label for="idPosition">'.get_lang("Position").' :</label></td>' . "\n";
$return .= "\t\t\t" . '<td class="input">' . "\n";
$return .= "\t\t\t\t" . '<select id="idPosition" name="previous" size="1">';
$return .= "\t\t\t\t\t" . '<option class="top" value="0">First position</option>';
for($i = 0; $i < count($arrLP); $i++)
{
if($arrLP[$i]['parent_item_id'] == $parent && $arrLP[$i]['id'] != $id)
{
if($extra_info['previous_item_id'] == $arrLP[$i]['id'])
$selected = 'selected="selected" ';
elseif($action == 'add')
$selected = 'selected="selected" ';
else
$selected = '';
$return .= "\t\t\t\t\t" . '<option ' . $selected . 'value="' . $arrLP[$i]['id'] . '">'.get_lang("After").' "' . html_entity_decode(stripslashes($arrLP[$i]['title'])) . '"</option>';
}
}
$return .= "\t\t\t\t" . '</select>';
$return .= "\t\t\t" . '</td>' . "\n";
$return .= "\t\t" . '</tr>' . "\n";
if($action != 'move')
{
$return .= "\t\t" . '<tr>' . "\n";
$return .= "\t\t\t" . '<td class="label"><label for="idTitle">'.get_lang("Title").' :</label></td>' . "\n";
$return .= "\t\t\t" . '<td class="input"><input id="idTitle" name="title" type="text" value="' . $item_title . '" /></td>' . "\n";
$return .= "\t\t" . '</tr>' . "\n";
$return .= "\t\t" . '<tr>' . "\n";
//Remove temporaly the test description
//$return .= "\t\t\t" . '<td class="label"><label for="idDescription">'.get_lang("Description").' :</label></td>' . "\n";
//$return .= "\t\t\t" . '<td class="input"><textarea id="idDescription" name="description" rows="4">' . $item_description . '</textarea></td>' . "\n";
$return .= "\t\t" . '</tr>' . "\n";
}
$return .= "\t\t" . '<tr>' . "\n";
$return .= "\t\t\t" . '<td colspan="2"><input class="button" name="submit_button" type="submit" value="OK" /></td>' . "\n";
$return .= "\t\t" . '</tr>' . "\n";
$return .= "\t" . '</table>' . "\n";
if($action == 'move')
{
$return .= "\t" . '<input name="title" type="hidden" value="' . $item_title . '" />' . "\n";
$return .= "\t" . '<input name="description" type="hidden" value="' . $item_description . '" />' . "\n";
}
if(is_numeric($extra_info))
{
$return .= "\t" . '<input name="path" type="hidden" value="' . $extra_info . '" />' . "\n";
}
elseif(is_array($extra_info))
{
$return .= "\t" . '<input name="path" type="hidden" value="' . $extra_info['path'] . '" />' . "\n";
}
$return .= "\t" . '<input name="type" type="hidden" value="'.TOOL_THREAD.'" />' . "\n";
$return .= "\t" . '<input name="post_time" type="hidden" value="' . time() . '" />' . "\n";
$return .= '</form>' . "\n";
$return .= '</div>' . "\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 = '<div style="margin:3px 10px;">';
@ -6322,6 +6735,51 @@ class learnpath {
$return .= '</div>';
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 .= '<div class="lp_resource_header"' . " onclick=\"if(document.getElementById('forums').style.display == 'block') {document.getElementById('forums').style.display = 'none';} else {document.getElementById('forums').style.display = 'block';}\"" . ' style="border-bottom:1px solid #999999; cursor:pointer;"><img align="left" alt="" src="img/lp_' . TOOL_FORUM . '.png" style="margin-right:5px;" title="" />'.get_lang('Forums').'</div>';
$return .= '<div class="lp_resource_elements" id="forums" style="border-bottom:1px solid #999999; border-top:0;">';
foreach($a_forums as $forum)
{
$return .= '<div class="lp_resource_element">';
$return .= '<script type="text/javascript">
function toggle_forum(forum_id){
if(document.getElementById("forum_"+forum_id+"_content").style.display == "none"){
document.getElementById("forum_"+forum_id+"_content").style.display = "block";
document.getElementById("forum_"+forum_id+"_opener").src = "'.api_get_path(WEB_IMG_PATH).'remove.gif";
}
else {
document.getElementById("forum_"+forum_id+"_content").style.display = "none";
document.getElementById("forum_"+forum_id+"_opener").src = "'.api_get_path(WEB_IMG_PATH).'add.gif";
}
}
</script>
';
$return .= '<img align="left" alt="" src="img/lp_' . TOOL_FORUM . '.png" style="margin-right:5px;" title="" />';
$return .= '<a style="cursor:hand" onclick="toggle_forum('.$forum['forum_id'].')" style="vertical-align:middle"><img src="'.api_get_path(WEB_IMG_PATH).'add.gif" id="forum_'.$forum['forum_id'].'_opener" align="absbottom" /></a>
<a href="' . $_SERVER['PHP_SELF'] . '?cidReq=' . $_GET['cidReq'] . '&amp;action=add_item&amp;type=' . TOOL_FORUM . '&amp;forum_id=' . $forum['forum_id'] . '&amp;lp_id=' . $this->lp_id . '" style="vertical-align:middle">' . $forum['forum_title'] . '</a><ul style="display:none" id="forum_'.$forum['forum_id'].'_content">';
$a_threads = get_threads($forum['forum_id']);
foreach($a_threads as $thread)
{
$return .= '<li><a href="' . $_SERVER['PHP_SELF'] . '?cidReq=' . $_GET['cidReq'] . '&amp;action=add_item&amp;type=' . TOOL_THREAD . '&amp;thread_id=' . $thread['thread_id'] . '&amp;lp_id=' . $this->lp_id . '">' . $thread['thread_title'] . '</a></li>';
}
$return .= '</ul></div>';
}
return $return;
}
}

@ -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'];

Loading…
Cancel
Save