Task #1297 - Cosmetic cahnges and minor corrections.

skala
Ivan Tcholakov 15 years ago
parent adbb7fb3e2
commit abe29a9a06
  1. 416
      main/admin/system_announcements.php
  2. 179
      main/forum/editpost.php
  3. 2
      main/forum/index.php
  4. 85
      main/forum/newthread.php
  5. 102
      main/forum/reply.php
  6. 426
      main/forum/viewforum.php
  7. 257
      main/forum/viewforumcategory.php
  8. 98
      main/forum/viewpost.php
  9. 156
      main/forum/viewthread.php
  10. 58
      main/glossary/glossary_ajax_request.php
  11. 176
      main/glossary/index.php

@ -1,34 +1,37 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* This page allows the administrator to manage the system announcements. * This page allows the administrator to manage the system announcements.
* @package chamilo.admin.announcement * @package chamilo.admin.announcement
*/ */
/* INIT SECTION */
// name of the language file that needs to be included /* INIT SECTION */
$language_file = array ('admin', 'agenda');
// Language files that need to be included.
$language_file = array('admin', 'agenda');
// resetting the course id // Resetting the course id.
$cidReset = true; $cidReset = true;
// including the global dokeos files // Including the global initialization file.
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
// including additional libraries // Including additional libraries.
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php'; require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
require_once api_get_path(LIBRARY_PATH).'system_announcements.lib.php'; require_once api_get_path(LIBRARY_PATH).'system_announcements.lib.php';
require_once api_get_path(LIBRARY_PATH).'WCAG/WCAG_rendering.php'; require_once api_get_path(LIBRARY_PATH).'WCAG/WCAG_rendering.php';
require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php'; require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
// setting the section (for the tabs) // Setting the section (for the tabs).
$this_section=SECTION_PLATFORM_ADMIN; $this_section=SECTION_PLATFORM_ADMIN;
$_SESSION['this_section']=$this_section; $_SESSION['this_section']=$this_section;
// Access restrictions // Access restrictions
api_protect_admin_script(true); api_protect_admin_script(true);
// setting breadcrumbs // Setting breadcrumbs.
$interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin')); $interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
$tool_name = get_lang('SystemAnnouncements'); $tool_name = get_lang('SystemAnnouncements');
@ -37,241 +40,222 @@ if (empty($_GET['lang'])) {
$_GET['lang'] = $_SESSION['user_language_choice']; $_GET['lang'] = $_SESSION['user_language_choice'];
} }
// displaying the header // Displaying the header.
Display :: display_header($tool_name); Display :: display_header($tool_name);
/* /* MAIN CODE */
MAIN CODE
*/
if($_GET['action'] != 'add' && $_GET['action'] != 'edit') { if ($_GET['action'] != 'add' && $_GET['action'] != 'edit') {
echo '<div class="actions">'; echo '<div class="actions">';
echo '<a href="?action=add">'.Display::return_icon('announce_add.gif', get_lang('langAddAnnouncement')).get_lang('langAddAnnouncement').'</a>'; echo '<a href="?action=add">'.Display::return_icon('announce_add.gif', get_lang('langAddAnnouncement')).get_lang('langAddAnnouncement').'</a>';
echo '</div>'; echo '</div>';
} }
$form_action = ""; $form_action = '';
$show_announcement_list = true; $show_announcement_list = true;
if (isset ($_GET['action']) && $_GET['action'] == 'make_visible') if (isset ($_GET['action']) && $_GET['action'] == 'make_visible') {
{ switch ($_GET['person']) {
switch ($_GET['person']) case VISIBLE_TEACHER :
{ SystemAnnouncementManager :: set_visibility($_GET['id'], VISIBLE_TEACHER, true);
case VISIBLE_TEACHER : break;
SystemAnnouncementManager :: set_visibility($_GET['id'], VISIBLE_TEACHER, true); case VISIBLE_STUDENT :
break; SystemAnnouncementManager :: set_visibility($_GET['id'], VISIBLE_STUDENT, true);
case VISIBLE_STUDENT : break;
SystemAnnouncementManager :: set_visibility($_GET['id'], VISIBLE_STUDENT, true); case VISIBLE_GUEST :
break; SystemAnnouncementManager :: set_visibility($_GET['id'], VISIBLE_GUEST, true);
case VISIBLE_GUEST : break;
SystemAnnouncementManager :: set_visibility($_GET['id'], VISIBLE_GUEST, true); }
break;
}
} }
if (isset ($_GET['action']) && $_GET['action'] == 'make_invisible') { if (isset ($_GET['action']) && $_GET['action'] == 'make_invisible') {
switch ($_GET['person']) { switch ($_GET['person']) {
case VISIBLE_TEACHER : case VISIBLE_TEACHER :
SystemAnnouncementManager :: set_visibility($_GET['id'], VISIBLE_TEACHER, false); SystemAnnouncementManager :: set_visibility($_GET['id'], VISIBLE_TEACHER, false);
break; break;
case VISIBLE_STUDENT : case VISIBLE_STUDENT :
SystemAnnouncementManager :: set_visibility($_GET['id'], VISIBLE_STUDENT, false); SystemAnnouncementManager :: set_visibility($_GET['id'], VISIBLE_STUDENT, false);
break; break;
case VISIBLE_GUEST : case VISIBLE_GUEST :
SystemAnnouncementManager :: set_visibility($_GET['id'], VISIBLE_GUEST, false); SystemAnnouncementManager :: set_visibility($_GET['id'], VISIBLE_GUEST, false);
break; break;
} }
} }
// Form was posted? // Form was posted?
if (isset ($_POST['action'])) { if (isset ($_POST['action'])) {
$action_todo = true; $action_todo = true;
} }
// Delete an announcement // Delete an announcement.
if (isset ($_GET['action']) && $_GET['action'] == 'delete') { if (isset ($_GET['action']) && $_GET['action'] == 'delete') {
SystemAnnouncementManager :: delete_announcement($_GET['id']); SystemAnnouncementManager :: delete_announcement($_GET['id']);
Display :: display_confirmation_message(get_lang('AnnouncementDeleted')); Display :: display_confirmation_message(get_lang('AnnouncementDeleted'));
} }
// Delete selected announcements
// Delete selected announcements.
if (isset ($_POST['action']) && $_POST['action'] == 'delete_selected') { if (isset ($_POST['action']) && $_POST['action'] == 'delete_selected') {
foreach($_POST['id'] as $index => $id) { foreach($_POST['id'] as $index => $id) {
SystemAnnouncementManager :: delete_announcement($id); SystemAnnouncementManager :: delete_announcement($id);
} }
Display :: display_confirmation_message(get_lang('AnnouncementDeleted')); Display :: display_confirmation_message(get_lang('AnnouncementDeleted'));
$action_todo = false; $action_todo = false;
} }
// Add an announcement
// Add an announcement.
if (isset ($_GET['action']) && $_GET['action'] == 'add') { if (isset ($_GET['action']) && $_GET['action'] == 'add') {
$values['action'] = 'add'; $values['action'] = 'add';
// Set default time window: NOW -> NEXT WEEK // Set default time window: NOW -> NEXT WEEK
$values['start'] = date('Y-m-d H:i:s',api_strtotime(api_get_local_time())); $values['start'] = date('Y-m-d H:i:s',api_strtotime(api_get_local_time()));
$values['end'] = date('Y-m-d H:i:s',api_strtotime(api_get_local_time()) + (7 * 24 * 60 * 60)); $values['end'] = date('Y-m-d H:i:s',api_strtotime(api_get_local_time()) + (7 * 24 * 60 * 60));
$action_todo = true; $action_todo = true;
} }
// Edit an announcement
// Edit an announcement.
if (isset ($_GET['action']) && $_GET['action'] == 'edit') { if (isset ($_GET['action']) && $_GET['action'] == 'edit') {
$announcement = SystemAnnouncementManager :: get_announcement($_GET['id']); $announcement = SystemAnnouncementManager :: get_announcement($_GET['id']);
$values['id'] = $announcement->id; $values['id'] = $announcement->id;
$values['title'] = $announcement->title; $values['title'] = $announcement->title;
$values['content'] = $announcement->content; $values['content'] = $announcement->content;
$values['start'] = $announcement->date_start; $values['start'] = $announcement->date_start;
$values['end'] = $announcement->date_end; $values['end'] = $announcement->date_end;
$values['visible_teacher'] = $announcement->visible_teacher; $values['visible_teacher'] = $announcement->visible_teacher;
$values['visible_student'] = $announcement->visible_student ; $values['visible_student'] = $announcement->visible_student ;
$values['visible_guest'] = $announcement->visible_guest ; $values['visible_guest'] = $announcement->visible_guest ;
$values['lang'] = $announcement->lang; $values['lang'] = $announcement->lang;
$values['action'] = 'edit'; $values['action'] = 'edit';
$action_todo = true; $action_todo = true;
} }
if ($action_todo) { if ($action_todo) {
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add') { if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add') {
$form_title = get_lang('AddNews'); $form_title = get_lang('AddNews');
} elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') { } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') {
$form_title = get_lang('EditNews'); $form_title = get_lang('EditNews');
} }
$form = new FormValidator('system_announcement'); $form = new FormValidator('system_announcement');
$form->addElement('header', '', $form_title); $form->addElement('header', '', $form_title);
$form->add_textfield('title', get_lang('Title')); $form->add_textfield('title', get_lang('Title'));
$language_list = api_get_languages(); $language_list = api_get_languages();
$language_list_with_keys = array(); $language_list_with_keys = array();
$language_list_with_keys['all'] = get_lang('All'); $language_list_with_keys['all'] = get_lang('All');
for($i=0; $i<count($language_list['name']) ; $i++) { for($i=0; $i<count($language_list['name']) ; $i++) {
$language_list_with_keys[$language_list['folder'][$i]] = $language_list['name'][$i]; $language_list_with_keys[$language_list['folder'][$i]] = $language_list['name'][$i];
} }
$form->addElement('select', 'lang',get_lang('Language'),$language_list_with_keys); $form->addElement('select', 'lang',get_lang('Language'),$language_list_with_keys);
if (api_get_setting('wcag_anysurfer_public_pages')=='true') { if (api_get_setting('wcag_anysurfer_public_pages')=='true') {
$form->addElement('textarea', 'content', get_lang('Content')); $form->addElement('textarea', 'content', get_lang('Content'));
} else { } else {
$form->add_html_editor('content', get_lang('Content'), true, false, array('ToolbarSet' => 'PortalNews', 'Width' => '100%', 'Height' => '300')); $form->add_html_editor('content', get_lang('Content'), true, false, array('ToolbarSet' => 'PortalNews', 'Width' => '100%', 'Height' => '300'));
} }
$form->add_timewindow('start','end',get_lang('StartTimeWindow'),get_lang('EndTimeWindow')); $form->add_timewindow('start','end',get_lang('StartTimeWindow'),get_lang('EndTimeWindow'));
$form->addElement('checkbox', 'visible_teacher', get_lang('Visible'), get_lang('Teacher')); $form->addElement('checkbox', 'visible_teacher', get_lang('Visible'), get_lang('Teacher'));
$form->addElement('checkbox', 'visible_student', null, get_lang('Student')); $form->addElement('checkbox', 'visible_student', null, get_lang('Student'));
$form->addElement('checkbox', 'visible_guest', null, get_lang('Guest')); $form->addElement('checkbox', 'visible_guest', null, get_lang('Guest'));
$form->addElement('hidden', 'id'); $form->addElement('hidden', 'id');
$form->addElement('checkbox', 'send_mail', get_lang('SendMail')); $form->addElement('checkbox', 'send_mail', get_lang('SendMail'));
if (isset($_REQUEST['action']) && $_REQUEST['action']=='add') { if (isset($_REQUEST['action']) && $_REQUEST['action']=='add') {
$text=get_lang('AddNews'); $text=get_lang('AddNews');
$class='add'; $class='add';
$form->addElement('hidden', 'action','add'); $form->addElement('hidden', 'action','add');
} elseif (isset($_REQUEST['action']) && $_REQUEST['action']=='edit') { } elseif (isset($_REQUEST['action']) && $_REQUEST['action']=='edit') {
$text=get_lang('EditNews'); $text=get_lang('EditNews');
$class='save'; $class='save';
$form->addElement('hidden', 'action','edit'); $form->addElement('hidden', 'action','edit');
} }
$form->addElement('style_submit_button', 'submit', $text,'class="'.$class.'"'); $form->addElement('style_submit_button', 'submit', $text,'class="'.$class.'"');
if (api_get_setting('wcag_anysurfer_public_pages')=='true') if (api_get_setting('wcag_anysurfer_public_pages') == 'true') {
{ $values['content'] = WCAG_Rendering::HTML_to_text($values['content']);
$values['content'] = WCAG_Rendering::HTML_to_text($values['content']); }
} $form->setDefaults($values);
$form->setDefaults($values); if ($form->validate()) {
if($form->validate()) $values = $form->exportValues();
{ if ( !isset($values['visible_teacher'])) {
$values = $form->exportValues(); $values['visible_teacher'] = false;
if( !isset($values['visible_teacher'])) }
{ if ( !isset($values['visible_student'])) {
$values['visible_teacher'] = false; $values['visible_student'] = false;
} }
if( !isset($values['visible_student'])) if ( !isset($values['visible_guest'])) {
{ $values['visible_guest'] = false;
$values['visible_student'] = false; }
} if ($values['lang'] == 'all') {
if( !isset($values['visible_guest'])) $values['lang'] = null;
{ }
$values['visible_guest'] = false; if (api_get_setting('wcag_anysurfer_public_pages') == 'true') {
} $values['content'] = WCAG_Rendering::text_to_HTML($values['content']);
if($values['lang'] == 'all') }
{ switch ($values['action']) {
$values['lang'] = null; case 'add':
} if (SystemAnnouncementManager::add_announcement($values['title'], $values['content'], $values['start'], $values['end'], $values['visible_teacher'], $values['visible_student'], $values['visible_guest'], $values['lang'], $values['send_mail'])) {
if (api_get_setting('wcag_anysurfer_public_pages')=='true') Display :: display_confirmation_message(get_lang('AnnouncementAdded'));
{ } else {
$values['content'] = WCAG_Rendering::text_to_HTML($values['content']); $show_announcement_list = false;
} $form->display();
switch($values['action']) }
{ break;
case 'add': case 'edit':
if(SystemAnnouncementManager::add_announcement($values['title'],$values['content'],$values['start'],$values['end'],$values['visible_teacher'],$values['visible_student'],$values['visible_guest'], $values['lang'],$values['send_mail'])) if (SystemAnnouncementManager::update_announcement($values['id'], $values['title'], $values['content'], $values['start'], $values['end'], $values['visible_teacher'], $values['visible_student'], $values['visible_guest'], $values['lang'], $values['send_mail'])) {
{ Display :: display_confirmation_message(get_lang('AnnouncementUpdated'));
Display :: display_confirmation_message(get_lang('AnnouncementAdded')); } else {
} else { $show_announcement_list = false;
$show_announcement_list = false; $form->display();
$form->display(); }
} break;
break; default:
case 'edit': break;
if (SystemAnnouncementManager::update_announcement($values['id'],$values['title'],$values['content'],$values['start'],$values['end'],$values['visible_teacher'],$values['visible_student'],$values['visible_guest'], $values['lang'],$values['send_mail'])) }
{ $show_announcement_list = true;
Display :: display_confirmation_message(get_lang('AnnouncementUpdated')); } else {
} if (api_get_setting('wcag_anysurfer_public_pages') == 'true') {
else echo '<div class="WCAG-form">';
{ }
$show_announcement_list = false; $form->display();
$form->display(); if (api_get_setting('wcag_anysurfer_public_pages') == 'true') {
} echo '</div>';
break; }
default: $show_announcement_list = false;
break; }
}
$show_announcement_list = true;
}
else
{
if (api_get_setting('wcag_anysurfer_public_pages')=='true')
{
echo('<div class="WCAG-form">');
}
$form->display();
if (api_get_setting('wcag_anysurfer_public_pages')=='true')
{
echo('</div>');
}
$show_announcement_list = false;
}
} }
if ($show_announcement_list)
{ if ($show_announcement_list) {
$announcements = SystemAnnouncementManager :: get_all_announcements(); $announcements = SystemAnnouncementManager :: get_all_announcements();
$announcement_data = array (); $announcement_data = array ();
foreach ($announcements as $index => $announcement) foreach ($announcements as $index => $announcement) {
{ $row = array();
$row = array (); $row[] = $announcement->id;
$row[] = $announcement->id; $row[] = Display::return_icon(($announcement->visible ? 'accept.png' : 'exclamation.png'), ($announcement->visible ? get_lang('AnnouncementAvailable') : get_lang('AnnouncementNotAvailable')));
$row[] = Display::return_icon(($announcement->visible ? 'accept.png' : 'exclamation.png'), ($announcement->visible ? get_lang('AnnouncementAvailable') : get_lang('AnnouncementNotAvailable'))); $row[] = api_convert_and_format_date($announcement->date_start, null, date_default_timezone_get());
$row[] = api_convert_and_format_date($announcement->date_start, null, date_default_timezone_get()); $row[] = api_convert_and_format_date($announcement->date_end, null, date_default_timezone_get());
$row[] = api_convert_and_format_date($announcement->date_end, null, date_default_timezone_get()); $row[] = "<a href=\"?id=".$announcement->id."&amp;person=".VISIBLE_TEACHER."&amp;action=". ($announcement->visible_teacher ? 'make_invisible' : 'make_visible')."\">".Display::return_icon(($announcement->visible_teacher ? 'visible.gif' : 'invisible.gif'), get_lang('show_hide'))."</a>";
$row[] = "<a href=\"?id=".$announcement->id."&amp;person=".VISIBLE_TEACHER."&amp;action=". ($announcement->visible_teacher ? 'make_invisible' : 'make_visible')."\">".Display::return_icon(($announcement->visible_teacher ? 'visible.gif' : 'invisible.gif'), get_lang('show_hide'))."</a>"; $row[] = "<a href=\"?id=".$announcement->id."&amp;person=".VISIBLE_STUDENT."&amp;action=". ($announcement->visible_student ? 'make_invisible' : 'make_visible')."\">".Display::return_icon(($announcement->visible_student ? 'visible.gif' : 'invisible.gif'), get_lang('show_hide'))."</a>";
$row[] = "<a href=\"?id=".$announcement->id."&amp;person=".VISIBLE_STUDENT."&amp;action=". ($announcement->visible_student ? 'make_invisible' : 'make_visible')."\">".Display::return_icon(($announcement->visible_student ? 'visible.gif' : 'invisible.gif'), get_lang('show_hide'))."</a>"; $row[] = "<a href=\"?id=".$announcement->id."&amp;person=".VISIBLE_GUEST."&amp;action=". ($announcement->visible_guest ? 'make_invisible' : 'make_visible')."\">".Display::return_icon(($announcement->visible_guest ? 'visible.gif' : 'invisible.gif'), get_lang('show_hide'))."</a>";
$row[] = "<a href=\"?id=".$announcement->id."&amp;person=".VISIBLE_GUEST."&amp;action=". ($announcement->visible_guest ? 'make_invisible' : 'make_visible')."\">".Display::return_icon(($announcement->visible_guest ? 'visible.gif' : 'invisible.gif'), get_lang('show_hide'))."</a>"; $row[] = $announcement->title;
$row[] = $announcement->title; $row[] = $announcement->lang;
$row[] = $announcement->lang; $row[] = "<a href=\"?action=edit&id=".$announcement->id."\">".Display::return_icon('edit.gif', get_lang('Edit'))."</a> <a href=\"?action=delete&id=".$announcement->id."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES))."')) return false;\">".Display::return_icon('delete.gif', get_lang('Delete'))."</a>";
$row[] = "<a href=\"?action=edit&id=".$announcement->id."\">".Display::return_icon('edit.gif', get_lang('Edit'))."</a> <a href=\"?action=delete&id=".$announcement->id."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."')) return false;\">".Display::return_icon('delete.gif', get_lang('Delete'))."</a>"; $announcement_data[] = $row;
$announcement_data[] = $row; }
} $table = new SortableTableFromArray($announcement_data);
$table = new SortableTableFromArray($announcement_data); $table->set_header(0, '', false);
$table->set_header(0,'',false); $table->set_header(1, get_lang('Active'));
$table->set_header(1,get_lang('Active')); $table->set_header(2, get_lang('StartTimeWindow'));
$table->set_header(2,get_lang('StartTimeWindow')); $table->set_header(3, get_lang('EndTimeWindow'));
$table->set_header(3,get_lang('EndTimeWindow')); $table->set_header(4, get_lang('Teacher'));
$table->set_header(4,get_lang('Teacher')); $table->set_header(5, get_lang('Student'));
$table->set_header(5,get_lang('Student')); $table->set_header(6, get_lang('Guest'));
$table->set_header(6,get_lang('Guest')); $table->set_header(7, get_lang('Title'));
$table->set_header(7,get_lang('Title')); $table->set_header(8, get_lang('Language'));
$table->set_header(8,get_lang('Language')); $table->set_header(9, get_lang('Modify'), false, 'width="50px"');
$table->set_header(9,get_lang('Modify'), false,'width="50px"'); $form_actions = array();
$form_actions = array(); $form_actions['delete_selected'] = get_lang('Delete');
$form_actions['delete_selected'] = get_lang('Delete'); $table->set_form_actions($form_actions);
$table->set_form_actions($form_actions); $table->display();
$table->display();
} }
/*
FOOTER /* FOOTER */
*/
Display :: display_footer(); Display :: display_footer();
?>

@ -22,39 +22,37 @@
* @package chamilo.forum * @package chamilo.forum
*/ */
/* /* INIT SECTION */
INIT SECTION
*/
// name of the language file that needs to be included
$language_file = array ('forum','group');
// including the global dokeos file // Language files that need to be included.
$language_file = array ('forum', 'group');
// Including the global initialization file.
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
require_once '../gradebook/lib/gradebook_functions.inc.php'; require_once '../gradebook/lib/gradebook_functions.inc.php';
require_once '../gradebook/lib/be/gradebookitem.class.php'; require_once '../gradebook/lib/be/gradebookitem.class.php';
require_once '../gradebook/lib/be/evaluation.class.php'; require_once '../gradebook/lib/be/evaluation.class.php';
require_once '../gradebook/lib/be/abstractlink.class.php'; require_once '../gradebook/lib/be/abstractlink.class.php';
require_once '../gradebook/lib/gradebook_functions.inc.php'; require_once '../gradebook/lib/gradebook_functions.inc.php';
// the section (tabs)
$this_section=SECTION_COURSES; // The section (tabs).
// notice for unauthorized people. $this_section = SECTION_COURSES;
// Notification for unauthorized people.
api_protect_course_script(true); api_protect_course_script(true);
// including additional library scripts // Including additional library scripts.
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php'; require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
$nameTools=get_lang('ToolForum'); $nameTools = get_lang('ToolForum');
/* /* Including necessary files */
Including necessary files
*/
include 'forumconfig.inc.php'; include 'forumconfig.inc.php';
include 'forumfunction.inc.php'; include 'forumfunction.inc.php';
//
$origin = ''; $origin = '';
if(isset($_GET['origin'])) { if (isset($_GET['origin'])) {
$origin = Security::remove_XSS($_GET['origin']); $origin = Security::remove_XSS($_GET['origin']);
} }
@ -73,129 +71,124 @@ $htmlHeadXtra[] = '<script>
} }
</script>'; </script>';
/* /* MAIN DISPLAY SECTION */
MAIN DISPLAY SECTION
*/ /* Retrieving forum and forum categorie information */
/*
Retrieving forum and forum categorie information // We are getting all the information about the current forum and forum category.
*/ // Note pcool: I tried to use only one sql statement (and function) for this,
// we are getting all the information about the current forum and forum category. // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table.
// note pcool: I tried to use only one sql statement (and function) for this $current_thread = get_thread_information($_GET['thread']); // Note: This has to be validated that it is an existing thread.
// but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table $current_forum = get_forum_information($_GET['forum']); // Note: This has to be validated that it is an existing forum.
$current_thread=get_thread_information($_GET['thread']); // note: this has to be validated that it is an existing thread $current_forum_category = get_forumcategory_information($current_forum['forum_category']);
$current_forum=get_forum_information($_GET['forum']); // note: this has to be validated that it is an existing forum. $current_post = get_post_information($_GET['post']);
$current_forum_category=get_forumcategory_information($current_forum['forum_category']);
$current_post=get_post_information($_GET['post']); /* Header and Breadcrumbs */
/*
Header and Breadcrumbs if (isset($_SESSION['gradebook'])) {
*/ $gradebook = $_SESSION['gradebook'];
if (isset($_SESSION['gradebook'])){
$gradebook= $_SESSION['gradebook'];
} }
if (!empty($gradebook) && $gradebook=='view') { if (!empty($gradebook) && $gradebook == 'view') {
$interbreadcrumb[]= array ( $interbreadcrumb[] = array (
'url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
'name' => get_lang('ToolGradebook') 'name' => get_lang('ToolGradebook')
); );
} }
if ($origin=='group') { if ($origin == 'group') {
$_clean['toolgroup']=(int)$_SESSION['toolgroup']; $_clean['toolgroup'] = (int)$_SESSION['toolgroup'];
$group_properties = GroupManager :: get_group_properties($_clean['toolgroup']); $group_properties = GroupManager :: get_group_properties($_clean['toolgroup']);
$interbreadcrumb[] = array ("url" => "../group/group.php", "name" => get_lang('Groups')); $interbreadcrumb[] = array('url' => '../group/group.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array ("url"=>"../group/group_space.php?gidReq=".$_SESSION['toolgroup'], "name"=> get_lang('GroupSpace').' '.$group_properties['name']); $interbreadcrumb[] = array('url'=>'../group/group_space.php?gidReq='.$_SESSION['toolgroup'], 'name'=> get_lang('GroupSpace').' '.$group_properties['name']);
$interbreadcrumb[] = array("url" => "viewforum.php?origin=".$origin."&amp;gidReq=".$_SESSION['toolgroup']."&amp;forum=".Security::remove_XSS($_GET['forum']),"name" => prepare4display($current_forum['forum_title'])); $interbreadcrumb[] = array('url' => 'viewforum.php?origin='.$origin.'&amp;gidReq='.$_SESSION['toolgroup'].'&amp;forum='.Security::remove_XSS($_GET['forum']), 'name' => prepare4display($current_forum['forum_title']));
$interbreadcrumb[] = array("url" => "javascript: void (0);","name" => get_lang('EditPost')); $interbreadcrumb[] = array('url' => 'javascript: void (0);', 'name' => get_lang('EditPost'));
} else { } else {
$interbreadcrumb[]=array("url" => "index.php?gradebook=$gradebook","name" => $nameTools); $interbreadcrumb[] = array('url' => 'index.php?gradebook='.$gradebook, 'name' => $nameTools);
$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id'],"name" => prepare4display($current_forum_category['cat_title'])); $interbreadcrumb[] = array('url' => 'viewforumcategory.php?forumcategory='.$current_forum_category['cat_id'], 'name' => prepare4display($current_forum_category['cat_title']));
$interbreadcrumb[]=array("url" => "viewforum.php?origin=".$origin."&amp;forum=".Security::remove_XSS($_GET['forum']),"name" => prepare4display($current_forum['forum_title'])); $interbreadcrumb[] = array('url' => 'viewforum.php?origin='.$origin.'&amp;forum='.Security::remove_XSS($_GET['forum']), 'name' => prepare4display($current_forum['forum_title']));
$interbreadcrumb[]=array("url" => "viewthread.php?gradebook=$gradebook&amp;origin=".$origin."&amp;forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread']),"name" => prepare4display($current_thread['thread_title'])); $interbreadcrumb[] = array('url' => 'viewthread.php?gradebook='.$gradebook.'&amp;origin='.$origin.'&amp;forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.Security::remove_XSS($_GET['thread']), 'name' => prepare4display($current_thread['thread_title']));
$interbreadcrumb[]=array("url" => "javascript: void (0);","name" => get_lang('EditPost')); $interbreadcrumb[] = array('url' => 'javascript: void (0);', 'name' => get_lang('EditPost'));
} }
/*
Resource Linker /* Resource Linker */
*/
if (isset($_POST['add_resources']) AND $_POST['add_resources']==get_lang('Resources')) { if (isset($_POST['add_resources']) AND $_POST['add_resources']==get_lang('Resources')) {
$_SESSION['formelements']=$_POST; $_SESSION['formelements']=$_POST;
$_SESSION['origin']=$_SERVER['REQUEST_URI']; $_SESSION['origin']=$_SERVER['REQUEST_URI'];
$_SESSION['breadcrumbs']=$interbreadcrumb; $_SESSION['breadcrumbs']=$interbreadcrumb;
header("Location: ../resourcelinker/resourcelinker.php"); header('Location: ../resourcelinker/resourcelinker.php');
} }
$table_link = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); $table_link = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
/*
Header /* Header */
*/
//are we in a lp ? // Are we in a lp ?
$origin = ''; $origin = '';
if (isset($_GET['origin'])) { if (isset($_GET['origin'])) {
$origin = Security::remove_XSS($_GET['origin']); $origin = Security::remove_XSS($_GET['origin']);
} }
if ($origin=='learnpath') { if ($origin == 'learnpath') {
include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php'); include api_get_path(INCLUDE_PATH).'reduced_header.inc.php';
} else { } else {
Display :: display_header(null); Display :: display_header(null);
//api_display_tool_title($nameTools); //api_display_tool_title($nameTools);
} }
//echo '<link href="forumstyles.css" rel="stylesheet" type="text/css" />';
/* /* Is the user allowed here? */
Is the user allowed here?
*/ // The user is not allowed here if
// the user is not allowed here if
// 1. the forumcategory, forum or thread is invisible (visibility==0) // 1. the forumcategory, forum or thread is invisible (visibility==0)
// 2. the forumcategory, forum or thread is locked (locked <>0) // 2. the forumcategory, forum or thread is locked (locked <>0)
// 3. if anonymous posts are not allowed // 3. if anonymous posts are not allowed
// 4. if editing of replies is not allowed // 4. if editing of replies is not allowed
// The only exception is the course manager // The only exception is the course manager
// I have split this is several pieces for clarity. // I have split this is several pieces for clarity.
//if (!api_is_allowed_to_edit() AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0) OR ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0 OR $current_thread['locked']<>0))) //if (!api_is_allowed_to_edit() AND (($current_forum_category['visibility'] == 0 OR $current_forum['visibility'] == 0) OR ($current_forum_category['locked'] <> 0 OR $current_forum['locked'] <> 0 OR $current_thread['locked'] <> 0))) {
if (!api_is_allowed_to_edit(null,true) AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0))) { if (!api_is_allowed_to_edit(null, true) AND (($current_forum_category['visibility'] == 0 OR $current_forum['visibility'] == 0))) {
$forum_allow = forum_not_allowed_here(); $forum_allow = forum_not_allowed_here();
if ($forum_allow === false) { if ($forum_allow === false) {
exit; exit;
} }
} }
if (!api_is_allowed_to_edit(null,true) AND ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0 OR $current_thread['locked']<>0)) { if (!api_is_allowed_to_edit(null, true) AND ($current_forum_category['locked'] <> 0 OR $current_forum['locked'] <> 0 OR $current_thread['locked'] <> 0)) {
$forum_allow = forum_not_allowed_here(); $forum_allow = forum_not_allowed_here();
if ($forum_allow === false) { if ($forum_allow === false) {
exit; exit;
} }
} }
if (!$_user['user_id'] AND $current_forum['allow_anonymous']==0) { if (!$_user['user_id'] AND $current_forum['allow_anonymous'] == 0) {
$forum_allow = forum_not_allowed_here(); $forum_allow = forum_not_allowed_here();
if ($forum_allow === false) { if ($forum_allow === false) {
exit; exit;
} }
} }
if (!api_is_allowed_to_edit(null,true) AND $current_forum['allow_edit']==0) { if (!api_is_allowed_to_edit(null, true) AND $current_forum['allow_edit'] == 0) {
$forum_allow = forum_not_allowed_here(); $forum_allow = forum_not_allowed_here();
if ($forum_allow === false) { if ($forum_allow === false) {
exit; exit;
} }
} }
// action links // Action links
if ($origin!='learnpath') { if ($origin != 'learnpath') {
echo '<div class="actions">'; echo '<div class="actions">';
echo '<span style="float:right;">'.search_link().'</span>'; echo '<span style="float:right;">'.search_link().'</span>';
if ($origin=='group') { if ($origin == 'group') {
echo '<a href="../group/group_space.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;gradebook='.$gradebook.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('Groups'),'','32').'</a>'; echo '<a href="../group/group_space.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;gradebook='.$gradebook.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('Groups'),'','32').'</a>';
} } else {
else{
echo '<a href="index.php?gradebook='.$gradebook.'">'.Display::return_icon('back.png',get_lang('BackToForumOverview'),'','32' ).'</a>'; echo '<a href="index.php?gradebook='.$gradebook.'">'.Display::return_icon('back.png',get_lang('BackToForumOverview'),'','32' ).'</a>';
} }
echo '<a href="viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;origin='.$origin.'">'.Display::return_icon('forum.png',get_lang('BackToForum'),'','32').'</a>'; echo '<a href="viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;origin='.$origin.'">'.Display::return_icon('forum.png',get_lang('BackToForum'),'','32').'</a>';
echo '</div>'; echo '</div>';
} }
/* /* Display Forum Category and the Forum information */
Display Forum Category and the Forum information
*/
echo "<table class=\"forum_table\" width=\"100%\">\n"; echo "<table class=\"forum_table\" width=\"100%\">\n";
// the forum category // The forum category
echo "<tr><th class=\"forum_head\" colspan=\"2\">"; echo "<tr><th class=\"forum_head\" colspan=\"2\">";
echo '<a href="viewforum.php?&amp;origin='.$origin.'&amp;forum='.$current_forum['forum_id'].'" '.class_visible_invisible($current_forum['visibility']).'>'.prepare4display($current_forum['forum_title']).'</a><br />'; echo '<a href="viewforum.php?&amp;origin='.$origin.'&amp;forum='.$current_forum['forum_id'].'" '.class_visible_invisible($current_forum['visibility']).'>'.prepare4display($current_forum['forum_title']).'</a><br />';
echo '<span class="forum_description">'.prepare4display($current_forum['forum_comment']).'</span>';echo "</th>\n"; echo '<span class="forum_description">'.prepare4display($current_forum['forum_comment']).'</span>';echo "</th>\n";
@ -203,30 +196,30 @@ echo "</th>\n";
echo "\t</tr>\n"; echo "\t</tr>\n";
echo '</table>'; echo '</table>';
// the form for the reply // The form for the reply
$values=show_edit_post_form($current_post, $current_thread, $current_forum, isset($_SESSION['formelements'])?$_SESSION['formelements']:''); $values = show_edit_post_form($current_post, $current_thread, $current_forum, isset($_SESSION['formelements']) ? $_SESSION['formelements'] : '');
if (!empty($values) and isset($_POST['SubmitPost'])) { if (!empty($values) and isset($_POST['SubmitPost'])) {
store_edit_post($values); store_edit_post($values);
$option_chek=isset($values['thread_qualify_gradebook'])?$values['thread_qualify_gradebook']:null;// values 1 or 0 $option_chek = isset($values['thread_qualify_gradebook']) ? $values['thread_qualify_gradebook'] : null; // values 1 or 0
if ( 1== $option_chek ) { if (1 == $option_chek) {
$id=$values['thread_id']; $id = $values['thread_id'];
$title_gradebook=stripslashes($values['calification_notebook_title']); $title_gradebook = stripslashes($values['calification_notebook_title']);
$value_calification=$values['numeric_calification']; $value_calification = $values['numeric_calification'];
$weight_calification=$values['weight_calification']; $weight_calification = $values['weight_calification'];
$description=''; $description = '';
$session_id=api_get_session_id(); $session_id = api_get_session_id();
$link_id=is_resource_in_course_gradebook(api_get_course_id(),5,$id,$session_id); $link_id = is_resource_in_course_gradebook(api_get_course_id(), 5, $id,$session_id);
if (!$link_id) { if (!$link_id) {
add_resource_to_course_gradebook(api_get_course_id(), 5, $id, $title_gradebook,$weight_calification,$value_calification,$description,time(),1,api_get_session_id()); add_resource_to_course_gradebook(api_get_course_id(), 5, $id, $title_gradebook, $weight_calification, $value_calification, $description, time(), 1, api_get_session_id());
} else { } else {
Database::query('UPDATE '.$table_link.' SET weight='.$weight_calification.' WHERE id='.$link_id.''); Database::query('UPDATE '.$table_link.' SET weight='.$weight_calification.' WHERE id='.$link_id.'');
} }
} }
} }
// footer // Footer
if ($origin!='learnpath') { if ($origin != 'learnpath') {
Display :: display_footer(); Display :: display_footer();
} }

@ -99,14 +99,12 @@ if (isset($_GET['action']) && $_GET['action'] == 'add') {
Display::display_header(''); Display::display_header('');
//api_display_tool_title($nameTools); //api_display_tool_title($nameTools);
//echo '<link href="forumstyles.css" rel="stylesheet" type="text/css" />';
// Tool introduction // Tool introduction
Display::display_introduction_section(TOOL_FORUM); Display::display_introduction_section(TOOL_FORUM);
$form_count = 0; $form_count = 0;
/* ACTIONS */ /* ACTIONS */
$get_actions = isset($_GET['action']) ? $_GET['action'] : ''; $get_actions = isset($_GET['action']) ? $_GET['action'] : '';

@ -22,20 +22,21 @@
* @package chamilo.forum * @package chamilo.forum
*/ */
// name of the language file that needs to be included // Language file that need to be included.
$language_file = array('forum','document'); $language_file = array('forum', 'document');
// including the global dokeos file // Including the global initialization file.
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
require_once '../gradebook/lib/gradebook_functions.inc.php'; require_once '../gradebook/lib/gradebook_functions.inc.php';
// the section (tabs) // The section (tabs).
$this_section=SECTION_COURSES; $this_section=SECTION_COURSES;
// notice for unauthorized people. // Notification for unauthorized people.
api_protect_course_script(true); api_protect_course_script(true);
// including additional library scripts // Including additional library scripts.
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php'; require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
@ -46,9 +47,9 @@ $nameTools = get_lang('ToolForum');
require_once 'forumconfig.inc.php'; require_once 'forumconfig.inc.php';
require_once 'forumfunction.inc.php'; require_once 'forumfunction.inc.php';
//are we in a lp ? // Are we in a lp ?
$origin = ''; $origin = '';
if(isset($_GET['origin'])) { if (isset($_GET['origin'])) {
$origin = Security::remove_XSS($_GET['origin']); $origin = Security::remove_XSS($_GET['origin']);
} }
@ -69,10 +70,10 @@ $htmlHeadXtra[] = '<script>
/* MAIN DISPLAY SECTION */ /* MAIN DISPLAY SECTION */
/* Retrieving forum and forum categorie information */ /* Retrieving forum and forum category information */
$current_forum=get_forum_information($_GET['forum']); // note: this has to be validated that it is an existing forum. $current_forum = get_forum_information($_GET['forum']); // Note: This has to be validated that it is an existing forum.
$current_forum_category=get_forumcategory_information($current_forum['forum_category']); $current_forum_category = get_forumcategory_information($current_forum['forum_category']);
/* Breadcrumbs */ /* Breadcrumbs */
@ -80,8 +81,8 @@ if (isset($_SESSION['gradebook'])){
$gradebook = Security::remove_XSS($_SESSION['gradebook']); $gradebook = Security::remove_XSS($_SESSION['gradebook']);
} }
if (!empty($gradebook) && $gradebook=='view') { if (!empty($gradebook) && $gradebook == 'view') {
$interbreadcrumb[]= array ( $interbreadcrumb[] = array (
'url' => '../gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']), 'url' => '../gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']),
'name' => get_lang('ToolGradebook') 'name' => get_lang('ToolGradebook')
); );
@ -93,32 +94,32 @@ if (!empty($_GET['gidReq'])) {
} }
$session_toolgroup = 0; $session_toolgroup = 0;
if ($origin=='group') { if ($origin == 'group') {
$session_toolgroup = intval($_SESSION['toolgroup']); $session_toolgroup = intval($_SESSION['toolgroup']);
$group_properties = GroupManager :: get_group_properties($session_toolgroup); $group_properties = GroupManager :: get_group_properties($session_toolgroup);
$interbreadcrumb[] = array ("url" => "../group/group.php", "name" => get_lang('Groups')); $interbreadcrumb[] = array('url' => '../group/group.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array ("url"=>"../group/group_space.php?gidReq=".$session_toolgroup, "name"=> get_lang('GroupSpace').' '.$group_properties['name']); $interbreadcrumb[] = array('url' => '../group/group_space.php?gidReq='.$session_toolgroup, 'name' => get_lang('GroupSpace').' '.$group_properties['name']);
$interbreadcrumb[]=array("url" => "viewforum.php?origin=".$origin."&amp;gidReq=".$session_toolgroup."&amp;forum=".Security::remove_XSS($_GET['forum']),"name" => $current_forum['forum_title']); $interbreadcrumb[] = array('url' => 'viewforum.php?origin='.$origin.'&amp;gidReq='.$session_toolgroup.'&amp;forum='.Security::remove_XSS($_GET['forum']), 'name' => $current_forum['forum_title']);
$interbreadcrumb[]=array("url" => "newthread.php?origin=".$origin."&amp;forum=".Security::remove_XSS($_GET['forum']),"name" => get_lang('NewTopic')); $interbreadcrumb[] = array('url' => 'newthread.php?origin='.$origin.'&amp;forum='.Security::remove_XSS($_GET['forum']),'name' => get_lang('NewTopic'));
} else { } else {
$interbreadcrumb[]=array("url" => "index.php?gradebook=$gradebook","name" => $nameTools); $interbreadcrumb[] = array('url' => 'index.php?gradebook='.$gradebook, 'name' => $nameTools);
$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id'],"name" => $current_forum_category['cat_title']); $interbreadcrumb[] = array('url' => 'viewforumcategory.php?forumcategory='.$current_forum_category['cat_id'], 'name' => $current_forum_category['cat_title']);
$interbreadcrumb[]=array("url" => "viewforum.php?origin=".$origin."&amp;forum=".Security::remove_XSS($_GET['forum']),"name" => $current_forum['forum_title']); $interbreadcrumb[] = array('url' => 'viewforum.php?origin='.$origin.'&amp;forum='.Security::remove_XSS($_GET['forum']), 'name' => $current_forum['forum_title']);
$interbreadcrumb[]=array("url" => "newthread.php?origin=".$origin."&amp;forum=".Security::remove_XSS($_GET['forum']),"name" => get_lang('NewTopic')); $interbreadcrumb[] = array('url' => 'newthread.php?origin='.$origin.'&amp;forum='.Security::remove_XSS($_GET['forum']), 'name' => get_lang('NewTopic'));
} }
/* Resource Linker */ /* Resource Linker */
if (isset($_POST['add_resources']) AND $_POST['add_resources']==get_lang('Resources')) { if (isset($_POST['add_resources']) AND $_POST['add_resources'] == get_lang('Resources')) {
$_SESSION['formelements'] = $_POST; $_SESSION['formelements'] = $_POST;
$_SESSION['origin'] = $_SERVER['REQUEST_URI']; $_SESSION['origin'] = $_SERVER['REQUEST_URI'];
$_SESSION['breadcrumbs'] = $interbreadcrumb; $_SESSION['breadcrumbs'] = $interbreadcrumb;
header("Location: ../resourcelinker/resourcelinker.php"); header('Location: ../resourcelinker/resourcelinker.php');
} }
/* Header */ /* Header */
if($origin=='learnpath') { if ($origin == 'learnpath') {
require_once api_get_path(INCLUDE_PATH).'reduced_header.inc.php'; require_once api_get_path(INCLUDE_PATH).'reduced_header.inc.php';
} else { } else {
Display :: display_header(null); Display :: display_header(null);
@ -134,28 +135,28 @@ if($origin=='learnpath') {
// 4. anonymous posts are not allowed and the user is not logged in // 4. anonymous posts are not allowed and the user is not logged in
// I have split this is several pieces for clarity. // I have split this is several pieces for clarity.
if (!api_is_allowed_to_edit(false,true) && (($current_forum_category['visibility']==0 || $current_forum['visibility']==0))) { if (!api_is_allowed_to_edit(false, true) && (($current_forum_category['visibility'] == 0 || $current_forum['visibility'] == 0))) {
$forum_allow = forum_not_allowed_here(); $forum_allow = forum_not_allowed_here();
if ($forum_allow === false) { if ($forum_allow === false) {
exit; exit;
} }
} }
// 2. the forumcategory or forum is locked (locked <>0) and the user is not a course manager // 2. the forumcategory or forum is locked (locked <>0) and the user is not a course manager
if (!api_is_allowed_to_edit(false,true) AND ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0)) { if (!api_is_allowed_to_edit(false, true) AND ($current_forum_category['locked'] <> 0 OR $current_forum['locked'] <> 0)) {
$forum_allow = forum_not_allowed_here(); $forum_allow = forum_not_allowed_here();
if ($forum_allow === false) { if ($forum_allow === false) {
exit; exit;
} }
} }
// 3. new threads are not allowed and the user is not a course manager // 3. new threads are not allowed and the user is not a course manager
if (!api_is_allowed_to_edit(false,true) AND $current_forum['allow_new_threads']<>1) { if (!api_is_allowed_to_edit(false, true) AND $current_forum['allow_new_threads'] <> 1) {
$forum_allow = forum_not_allowed_here(); $forum_allow = forum_not_allowed_here();
if ($forum_allow === false) { if ($forum_allow === false) {
exit; exit;
} }
} }
// 4. anonymous posts are not allowed and the user is not logged in // 4. anonymous posts are not allowed and the user is not logged in
if (!$_user['user_id'] AND $current_forum['allow_anonymous']<>1) { if (!$_user['user_id'] AND $current_forum['allow_anonymous'] <> 1) {
$forum_allow = forum_not_allowed_here(); $forum_allow = forum_not_allowed_here();
if ($forum_allow === false) { if ($forum_allow === false) {
exit; exit;
@ -165,14 +166,14 @@ if (!$_user['user_id'] AND $current_forum['allow_anonymous']<>1) {
/* Display forms / Feedback Messages */ /* Display forms / Feedback Messages */
handle_forum_and_forumcategories(); handle_forum_and_forumcategories();
// action links
// Action links
echo '<div class="actions">'; echo '<div class="actions">';
echo '<span style="float:right;">'.search_link().'</span>'; echo '<span style="float:right;">'.search_link().'</span>';
if ($origin=='group') { if ($origin == 'group') {
echo '<a href="../group/group_space.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;gradebook='.$gradebook.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('Groups'),'','32').'</a>'; echo '<a href="../group/group_space.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;gradebook='.$gradebook.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('Groups'),'','32').'</a>';
} } else {
else{
echo '<a href="index.php?gradebook='.$gradebook.'">'.Display::return_icon('back.png',get_lang('BackToForumOverview'),'','32').'</a>'; echo '<a href="index.php?gradebook='.$gradebook.'">'.Display::return_icon('back.png',get_lang('BackToForumOverview'),'','32').'</a>';
} }
echo '<a href="viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;origin=group">'.Display::return_icon('forum.png',get_lang('BackToForum'),'','32').'</a>'; echo '<a href="viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;origin=group">'.Display::return_icon('forum.png',get_lang('BackToForum'),'','32').'</a>';
@ -180,18 +181,18 @@ echo '</div>';
/* Display Forum Category and the Forum information */ /* Display Forum Category and the Forum information */
echo "<table class=\"data_table\" width='100%'>\n"; echo "<table class=\"data_table\" width=\"100%\">\n";
if ($origin != 'learnpath') { if ($origin != 'learnpath') {
echo "<tr>\n<th align=\"left\" colspan=\"2\">"; echo "<tr>\n<th align=\"left\" colspan=\"2\">";
echo '<span class="forum_title">'.prepare4display($current_forum['forum_title']).'</span>'; echo '<span class="forum_title">'.prepare4display($current_forum['forum_title']).'</span>';
if (!empty ($current_forum['forum_comment'])) { if (!empty($current_forum['forum_comment'])) {
echo '<br><span class="forum_description">'.prepare4display($current_forum['forum_comment']).'</span>'; echo '<br><span class="forum_description">'.prepare4display($current_forum['forum_comment']).'</span>';
} }
if (!empty ($current_forum_category['cat_title'])) { if (!empty($current_forum_category['cat_title'])) {
echo '<br /><span class="forum_low_description">'.prepare4display($current_forum_category['cat_title'])."</span><br />"; echo '<br /><span class="forum_low_description">'.prepare4display($current_forum_category['cat_title'])."</span><br />";
} }
echo "</th>\n"; echo "</th>\n";
@ -199,15 +200,15 @@ if ($origin != 'learnpath') {
} }
echo '</table>'; echo '</table>';
$values=show_add_post_form('newthread','', isset($_SESSION['formelements'])?$_SESSION['formelements']:null); $values = show_add_post_form('newthread', '', isset($_SESSION['formelements']) ? $_SESSION['formelements'] : null);
if (!empty($values) and isset($values['SubmitPost'])) { if (!empty($values) && isset($values['SubmitPost'])) {
//add new thread in table forum_thread // Add new thread in table forum_thread.
store_thread($values); store_thread($values);
} }
/* FOOTER */ /* FOOTER */
if ($origin!='learnpath') { if ($origin != 'learnpath') {
Display :: display_footer(); Display :: display_footer();
} }

@ -1,5 +1,6 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* These files are a complete rework of the forum. The database structure is * These files are a complete rework of the forum. The database structure is
* based on phpBB but all the code is rewritten. A lot of new functionalities * based on phpBB but all the code is rewritten. A lot of new functionalities
@ -17,19 +18,19 @@
* @package chamilo.forum * @package chamilo.forum
*/ */
// name of the language file that needs to be included // Language files that need to be included.
$language_file = array('forum','document'); $language_file = array('forum', 'document');
// including the global dokeos file // Including the global initialization file.
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
// the section (tabs) // The section (tabs).
$this_section=SECTION_COURSES; $this_section = SECTION_COURSES;
// notice for unauthorized people. // Notification for unauthorized people.
api_protect_course_script(true); api_protect_course_script(true);
// including additional library scripts // Including additional library scripts.
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php'; require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
$nameTools = get_lang('ToolForum'); $nameTools = get_lang('ToolForum');
@ -63,54 +64,60 @@ $htmlHeadXtra[] = '<script>
/* Retrieving forum and forum categorie information */ /* Retrieving forum and forum categorie information */
// We are getting all the information about the current forum and forum category. // We are getting all the information about the current forum and forum category.
// note pcool: I tried to use only one sql statement (and function) for this // Note pcool: I tried to use only one sql statement (and function) for this,
// but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table.
$current_thread = get_thread_information($_GET['thread']); // note: this has to be validated that it is an existing thread $current_thread = get_thread_information($_GET['thread']); // Note: This has to be validated that it is an existing thread.
$current_forum = get_forum_information($current_thread['forum_id']); // note: this has to be validated that it is an existing forum. $current_forum = get_forum_information($current_thread['forum_id']); // Note: This has to be validated that it is an existing forum.
$current_forum_category = get_forumcategory_information(Security::remove_XSS($current_forum['forum_category'])); $current_forum_category = get_forumcategory_information(Security::remove_XSS($current_forum['forum_category']));
/* Breadcrumbs */ /* Breadcrumbs */
if (isset($_SESSION['gradebook'])){ if (isset($_SESSION['gradebook'])){
$gradebook = Security::remove_XSS($_SESSION['gradebook']); $gradebook = Security::remove_XSS($_SESSION['gradebook']);
} }
if (!empty($gradebook) && $gradebook == 'view') { if (!empty($gradebook) && $gradebook == 'view') {
$interbreadcrumb[]= array ( $interbreadcrumb[] = array (
'url' => '../gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']), 'url' => '../gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']),
'name' => get_lang('ToolGradebook') 'name' => get_lang('ToolGradebook')
); );
} }
if ($origin=='group') { if ($origin == 'group') {
$_clean['toolgroup']=(int)$_SESSION['toolgroup']; $_clean['toolgroup'] = (int)$_SESSION['toolgroup'];
$group_properties = GroupManager :: get_group_properties($_clean['toolgroup']); $group_properties = GroupManager :: get_group_properties($_clean['toolgroup']);
$interbreadcrumb[] = array ("url" => "../group/group.php", "name" => get_lang('Groups')); $interbreadcrumb[] = array('url' => '../group/group.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array ("url" => "../group/group_space.php?gidReq=".$_SESSION['toolgroup'], "name"=> get_lang('GroupSpace').' '.$group_properties['name']); $interbreadcrumb[] = array('url' => '../group/group_space.php?gidReq='.$_SESSION['toolgroup'], 'name' => get_lang('GroupSpace').' '.$group_properties['name']);
$interbreadcrumb[]=array("url" => "viewforum.php?origin=".$origin."&amp;forum=".Security::remove_XSS($_GET['forum']),"name" => $current_forum['forum_title']); $interbreadcrumb[] = array('url' => 'viewforum.php?origin='.$origin.'&amp;forum='.Security::remove_XSS($_GET['forum']), 'name' => $current_forum['forum_title']);
$interbreadcrumb[]=array("url" => "viewthread.php?origin=".$origin."&amp;gradebook=".$gradebook."&amp;forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread']),"name" => $current_thread['thread_title']); $interbreadcrumb[] = array('url' => 'viewthread.php?origin='.$origin.'&amp;gradebook='.$gradebook.'&amp;forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.Security::remove_XSS($_GET['thread']), 'name' => $current_thread['thread_title']);
$interbreadcrumb[]=array("url" => "javascript: void(0);","name" => get_lang('Reply')); $interbreadcrumb[] = array('url' => 'javascript: void(0);', 'name' => get_lang('Reply'));
} else { } else {
$interbreadcrumb[]=array("url" => "index.php?gradebook=$gradebook","name" => $nameTools); $interbreadcrumb[] = array('url' => 'index.php?gradebook='.$gradebook, 'name' => $nameTools);
$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id'],"name" => $current_forum_category['cat_title']); $interbreadcrumb[] = array('url' => 'viewforumcategory.php?forumcategory='.$current_forum_category['cat_id'], 'name' => $current_forum_category['cat_title']);
$interbreadcrumb[]=array("url" => "viewforum.php?origin=".$origin."&amp;forum=".Security::remove_XSS($_GET['forum']),"name" => $current_forum['forum_title']); $interbreadcrumb[] = array('url' => 'viewforum.php?origin='.$origin.'&amp;forum='.Security::remove_XSS($_GET['forum']), 'name' => $current_forum['forum_title']);
$interbreadcrumb[]=array("url" => "viewthread.php?origin=".$origin."&amp;gradebook=".$gradebook."&amp;forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread']),"name" => $current_thread['thread_title']); $interbreadcrumb[] = array('url' => 'viewthread.php?origin='.$origin.'&amp;gradebook='.$gradebook.'&amp;forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.Security::remove_XSS($_GET['thread']), 'name' => $current_thread['thread_title']);
$interbreadcrumb[]=array("url" => "javascript: void(0);","name" => get_lang('Reply')); $interbreadcrumb[] = array('url' => 'javascript: void(0);', 'name' => get_lang('Reply'));
} }
/* Resource Linker */ /* Resource Linker */
if (isset($_POST['add_resources']) AND $_POST['add_resources']==get_lang('Resources')) {
if (isset($_POST['add_resources']) AND $_POST['add_resources'] == get_lang('Resources')) {
$_SESSION['formelements'] = $_POST; $_SESSION['formelements'] = $_POST;
$_SESSION['origin'] = $_SERVER['REQUEST_URI']; $_SESSION['origin'] = $_SERVER['REQUEST_URI'];
$_SESSION['breadcrumbs'] = $interbreadcrumb; $_SESSION['breadcrumbs'] = $interbreadcrumb;
header("Location: ../resourcelinker/resourcelinker.php"); header('Location: ../resourcelinker/resourcelinker.php');
} }
/* Header */ /* Header */
if($origin=='learnpath') {
if ($origin == 'learnpath') {
include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php'); include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php');
} else { } else {
// the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string // The last element of the breadcrumb navigation is already set in interbreadcrumb, so give an empty string.
Display :: display_header(''); Display :: display_header('');
api_display_tool_title($nameTools); api_display_tool_title($nameTools);
} }
/* Is the user allowed here? */ /* Is the user allowed here? */
// The user is not allowed here if // The user is not allowed here if
// 1. the forumcategory, forum or thread is invisible (visibility==0 // 1. the forumcategory, forum or thread is invisible (visibility==0
@ -118,47 +125,48 @@ if($origin=='learnpath') {
// 3. if anonymous posts are not allowed // 3. if anonymous posts are not allowed
// The only exception is the course manager // The only exception is the course manager
// I have split this is several pieces for clarity. // I have split this is several pieces for clarity.
//if (!api_is_allowed_to_edit() AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0) OR ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0 OR $current_thread['locked']<>0))) //if (!api_is_allowed_to_edit() AND (($current_forum_category['visibility'] == 0 OR $current_forum['visibility'] == 0) OR ($current_forum_category['locked'] <> 0 OR $current_forum['locked'] <> 0 OR $current_thread['locked'] <> 0))) {
if (!api_is_allowed_to_edit(false,true) AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0))) { if (!api_is_allowed_to_edit(false, true) AND (($current_forum_category['visibility'] == 0 OR $current_forum['visibility'] == 0))) {
$forum_allow = forum_not_allowed_here(); $forum_allow = forum_not_allowed_here();
if ($forum_allow === false) { if ($forum_allow === false) {
exit; exit;
} }
} }
if (!api_is_allowed_to_edit(false,true) AND ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0 OR $current_thread['locked']<>0)) { if (!api_is_allowed_to_edit(false, true) AND ($current_forum_category['locked'] <> 0 OR $current_forum['locked'] <> 0 OR $current_thread['locked'] <> 0)) {
$forum_allow = forum_not_allowed_here(); $forum_allow = forum_not_allowed_here();
if ($forum_allow === false) { if ($forum_allow === false) {
exit; exit;
} }
} }
if (!$_user['user_id'] AND $current_forum['allow_anonymous']==0) { if (!$_user['user_id'] AND $current_forum['allow_anonymous'] == 0) {
$forum_allow = forum_not_allowed_here(); $forum_allow = forum_not_allowed_here();
if ($forum_allow === false) { if ($forum_allow === false) {
exit; exit;
} }
} }
/* Action links */ /* Action links */
if ($origin != 'learnpath') { if ($origin != 'learnpath') {
echo '<div class="actions">'; echo '<div class="actions">';
echo '<span style="float:right;">'.search_link().'</span>'; echo '<span style="float:right;">'.search_link().'</span>';
if ($origin=='group') { if ($origin == 'group') {
echo '<a href="../group/group_space.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;gradebook='.$gradebook.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('Groups'),'','32').'</a>'; echo '<a href="../group/group_space.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;gradebook='.$gradebook.'">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('Groups'), '', '32').'</a>';
} } else {
else{ echo '<a href="index.php?gradebook='.$gradebook.'">'.Display::return_icon('back.png', get_lang('BackToForumOverview'), '', '32').'</a>';
echo '<a href="index.php?gradebook='.$gradebook.'">'.Display::return_icon('back.png',get_lang('BackToForumOverview'),'','32').'</a>';
} }
echo '<a href="viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;origin='.$origin.'">'.Display::return_icon('forum.png',get_lang('BackToForum'),'','32').'</a>'; echo '<a href="viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;origin='.$origin.'">'.Display::return_icon('forum.png', get_lang('BackToForum'), '', '32').'</a>';
echo '<a href="viewthread.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gradebook='.$gradebook.'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;origin='.$origin.'">'.Display::return_icon('thread.png',get_lang('BackToThread'),'','32').'</a>'; echo '<a href="viewthread.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gradebook='.$gradebook.'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;origin='.$origin.'">'.Display::return_icon('thread.png', get_lang('BackToThread'), '', '32').'</a>';
echo '</div>'; echo '</div>';
} else { } else {
echo '<div style="height:15px">&nbsp;</div>'; echo '<div style="height:15px">&nbsp;</div>';
} }
/* Display Forum Category and the Forum information */ /* Display Forum Category and the Forum information */
echo "<table class=\"data_table\" width='100%'>\n";
// the forum category 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 "\t<tr>\n\t\t<th style=\"padding-left:5px;\" align=\"left\" colspan=\"2\">";
echo '<span class="forum_title">'.prepare4display($current_thread['thread_title']).'</span><br />'; echo '<span class="forum_title">'.prepare4display($current_thread['thread_title']).'</span><br />';
@ -169,17 +177,17 @@ echo "</th>\n";
echo "\t</tr>\n"; echo "\t</tr>\n";
echo '</table>'; echo '</table>';
// the form for the reply // The form for the reply
$my_action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : ''; $my_action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : '';
$my_post = isset($_GET['post']) ? Security::remove_XSS($_GET['post']) : ''; $my_post = isset($_GET['post']) ? Security::remove_XSS($_GET['post']) : '';
$my_elements = isset($_SESSION['formelements']) ? $_SESSION['formelements'] : ''; $my_elements = isset($_SESSION['formelements']) ? $_SESSION['formelements'] : '';
$values = show_add_post_form($my_action,$my_post, $my_elements); // note: this has to be cleaned first $values = show_add_post_form($my_action, $my_post, $my_elements); // Note: This has to be cleaned first.
if (!empty($values) AND isset($_POST['SubmitPost'])) { if (!empty($values) AND isset($_POST['SubmitPost'])) {
store_reply($values); store_reply($values);
} }
if ($origin!='learnpath') { if ($origin != 'learnpath') {
Display :: display_footer(); Display :: display_footer();
} }

@ -22,83 +22,75 @@
* @package chamilo.forum * @package chamilo.forum
*/ */
// name of the language file that needs to be included // Language files that need to be included.
$language_file = array ('forum','group'); $language_file = array('forum', 'group');
// including the global dokeos file // Including the global initialization file.
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
// notice for unauthorized people. // Notification for unauthorized people.
api_protect_course_script(true); api_protect_course_script(true);
// the section (tabs) // The section (tabs).
$this_section=SECTION_COURSES; $this_section = SECTION_COURSES;
// including additional library scripts // Including additional library scripts.
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php'; require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
$nameTools=get_lang('ToolForum');
$nameTools = get_lang('ToolForum');
//are we in a lp ? // Are we in a lp ?
$origin = ''; $origin = '';
$origin_string=''; $origin_string = '';
if (isset($_GET['origin'])) { if (isset($_GET['origin'])) {
$origin = Security::remove_XSS($_GET['origin']); $origin = Security::remove_XSS($_GET['origin']);
$origin_string = '&amp;origin='.$origin; $origin_string = '&amp;origin='.$origin;
} }
/* /* Including necessary files */
Including necessary files
*/
require 'forumconfig.inc.php'; require 'forumconfig.inc.php';
require_once 'forumfunction.inc.php'; require_once 'forumfunction.inc.php';
$userid=api_get_user_id(); $userid = api_get_user_id();
$userinf=api_get_user_info($userid); $userinf = api_get_user_info($userid);
/* /* MAIN DISPLAY SECTION */
MAIN DISPLAY SECTION
*/
/* Retrieving forum and forum category information */
/* // We are getting all the information about the current forum and forum category.
Retrieving forum and forum categorie information // Note pcool: I tried to use only one sql statement (and function) for this,
*/ // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table.
// we are getting all the information about the current forum and forum category.
// note pcool: I tried to use only one sql statement (and function) for this
// but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table
$my_forum_group=isset($_GET['gidReq'])?$_GET['gidReq']:''; $my_forum_group = isset($_GET['gidReq']) ? $_GET['gidReq'] : '';
$my_forum=isset($_GET['forum'])?$_GET['forum']:''; $my_forum = isset($_GET['forum']) ? $_GET['forum'] : '';
$val=GroupManager::user_has_access($userid,$my_forum_group,GROUP_TOOL_FORUM); $val = GroupManager::user_has_access($userid, $my_forum_group, GROUP_TOOL_FORUM);
if(!empty($my_forum_group)){ if (!empty($my_forum_group)) {
if (api_is_allowed_to_edit(false, true) || $val) { if (api_is_allowed_to_edit(false, true) || $val) {
$current_forum=get_forum_information($my_forum); // note: this has to be validated that it is an existing forum. $current_forum = get_forum_information($my_forum); // Note: This has to be validated that it is an existing forum.
$current_forum_category=get_forumcategory_information($current_forum['forum_category']); $current_forum_category = get_forumcategory_information($current_forum['forum_category']);
} }
} else { } else {
$result=get_forum_information($my_forum); $result = get_forum_information($my_forum);
if($result['forum_of_group']==0){ if ($result['forum_of_group'] == 0) {
$current_forum=get_forum_information($my_forum); // note: this has to be validated that it is an existing forum. $current_forum = get_forum_information($my_forum); // Note: This has to be validated that it is an existing forum.
$current_forum_category=get_forumcategory_information($current_forum['forum_category']); $current_forum_category = get_forumcategory_information($current_forum['forum_category']);
} }
} }
/* Header and Breadcrumbs */
/* $my_search = isset($_GET['search']) ? $_GET['search'] : '';
Header and Breadcrumbs $my_action = isset($_GET['action']) ? $_GET['action'] : '';
*/
$my_search=isset($_GET['search'])?$_GET['search']:'';
$my_action=isset($_GET['action'])?$_GET['action']:'';
if (isset($_SESSION['gradebook'])){ if (isset($_SESSION['gradebook'])){
$gradebook= $_SESSION['gradebook']; $gradebook = $_SESSION['gradebook'];
} }
if (!empty($gradebook) && $gradebook=='view') { if (!empty($gradebook) && $gradebook == 'view') {
$interbreadcrumb[]= array ( $interbreadcrumb[] = array (
'url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
'name' => get_lang('ToolGradebook') 'name' => get_lang('ToolGradebook')
); );
@ -109,83 +101,82 @@ if (!empty($_GET['gidReq'])) {
api_session_register('toolgroup'); api_session_register('toolgroup');
} }
if ($origin=='group') { if ($origin == 'group') {
$_clean['toolgroup']=(int)$_SESSION['toolgroup']; $_clean['toolgroup'] = (int)$_SESSION['toolgroup'];
$group_properties = GroupManager :: get_group_properties($_clean['toolgroup']); $group_properties = GroupManager :: get_group_properties($_clean['toolgroup']);
$interbreadcrumb[] = array ("url" => "../group/group.php", "name" => get_lang('Groups')); $interbreadcrumb[] = array('url' => '../group/group.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array ("url"=>"../group/group_space.php?gidReq=".$_SESSION['toolgroup'], "name"=> get_lang('GroupSpace').' '.$group_properties['name']); $interbreadcrumb[] = array('url'=>'../group/group_space.php?gidReq='.$_SESSION['toolgroup'], 'name'=> get_lang('GroupSpace').' '.$group_properties['name']);
//$interbreadcrumb[]=array("url" => "index.php?search=".Security::remove_XSS($my_search),"name" => $nameTools); //$interbreadcrumb[] = array('url' => 'index.php?search='.Security::remove_XSS($my_search), 'name' => $nameTools);
//$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&amp;search=".Security::remove_XSS(urlencode($my_search)),"name" => prepare4display($current_forum_category['cat_title'])); //$interbreadcrumb[] = array('url' => 'viewforumcategory.php?forumcategory='.$current_forum_category['cat_id'].'&amp;search='.Security::remove_XSS(urlencode($my_search)), 'name' => prepare4display($current_forum_category['cat_title']));
$interbreadcrumb[]=array("url" => "#","name" => get_lang('Forum').' '.Security::remove_XSS($current_forum['forum_title'])); $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Forum').' '.Security::remove_XSS($current_forum['forum_title']));
//viewforum.php?forum=".Security::remove_XSS($my_forum)."&amp;origin=".$origin."&amp;gidReq=".$_SESSION['toolgroup']."&amp;search=".Security::remove_XSS(urlencode($my_search)), //viewforum.php?forum=".Security::remove_XSS($my_forum)."&amp;origin=".$origin."&amp;gidReq=".$_SESSION['toolgroup']."&amp;search=".Security::remove_XSS(urlencode($my_search)),
} else { } else {
$interbreadcrumb[]=array("url" => "index.php?gradebook=$gradebook&amp;search=".Security::remove_XSS($my_search),"name" => $nameTools); $interbreadcrumb[] = array('url' => 'index.php?gradebook='.$gradebook.'&amp;search='.Security::remove_XSS($my_search), 'name' => $nameTools);
$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&amp;search=".Security::remove_XSS(urlencode($my_search)),"name" => prepare4display($current_forum_category['cat_title'])); $interbreadcrumb[] = array('url' => 'viewforumcategory.php?forumcategory='.$current_forum_category['cat_id'].'&amp;search='.Security::remove_XSS(urlencode($my_search)), 'name' => prepare4display($current_forum_category['cat_title']));
$interbreadcrumb[]=array("url" => "#","name" => Security::remove_XSS($current_forum['forum_title'])); $interbreadcrumb[] = array('url' => '#', 'name' => Security::remove_XSS($current_forum['forum_title']));
//viewforum.php?forum=".Security::remove_XSS($my_forum)."&amp;origin=".$origin."&amp;search=".Security::remove_XSS(urlencode($my_search)) //viewforum.php?forum=".Security::remove_XSS($my_forum)."&amp;origin=".$origin."&amp;search=".Security::remove_XSS(urlencode($my_search))
} }
if ($origin=='learnpath') { if ($origin == 'learnpath') {
include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php'); include api_get_path(INCLUDE_PATH).'reduced_header.inc.php';
} else { } else {
// the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string // The last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string.
Display :: display_header(''); Display :: display_header('');
//api_display_tool_title($nameTools); //api_display_tool_title($nameTools);
} }
/* /* Actions */
Actions
*/
$table_link = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); $table_link = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
// Change visibility of a forum or a forum category // Change visibility of a forum or a forum category.
if (($my_action=='invisible' OR $my_action=='visible') AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit(false,true) && api_is_allowed_to_session_edit(false,true)) { if (($my_action == 'invisible' OR $my_action=='visible') AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit(false, true) && api_is_allowed_to_session_edit(false, true)) {
$message=change_visibility($_GET['content'], $_GET['id'],$_GET['action']);// note: this has to be cleaned first $message = change_visibility($_GET['content'], $_GET['id'], $_GET['action']); // Note: This has to be cleaned first.
} }
// locking and unlocking // Locking and unlocking.
if (($my_action=='lock' OR $my_action=='unlock') AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit(false,true) && api_is_allowed_to_session_edit(false,true)) { if (($my_action == 'lock' OR $my_action == 'unlock') AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit(false, true) && api_is_allowed_to_session_edit(false, true)) {
$message=change_lock_status($_GET['content'], $_GET['id'],$my_action);// note: this has to be cleaned first $message = change_lock_status($_GET['content'], $_GET['id'], $my_action); // Note: This has to be cleaned first.
} }
// deleting // Deleting.
if ($my_action=='delete' AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit(false,true) && api_is_allowed_to_session_edit(false,true)) { if ($my_action == 'delete' AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit(false, true) && api_is_allowed_to_session_edit(false, true)) {
$message=delete_forum_forumcategory_thread($_GET['content'],$_GET['id']); // note: this has to be cleaned first $message = delete_forum_forumcategory_thread($_GET['content'], $_GET['id']); // Note: This has to be cleaned first.
//delete link // Delete link
$sql_link='DELETE FROM '.$table_link.' WHERE ref_id='.intval($_GET['id']).' and type=5 and course_code="'.api_get_course_id().'";'; $sql_link = 'DELETE FROM '.$table_link.' WHERE ref_id='.intval($_GET['id']).' and type=5 and course_code="'.api_get_course_id().'";';
Database::query($sql_link); Database::query($sql_link);
} }
// moving // Moving.
if ($my_action=='move' and isset($_GET['thread']) AND api_is_allowed_to_edit(false,true) && api_is_allowed_to_session_edit(false,true)) { if ($my_action == 'move' AND isset($_GET['thread']) AND api_is_allowed_to_edit(false, true) && api_is_allowed_to_session_edit(false, true)) {
$message=move_thread_form(); $message = move_thread_form();
} }
// notification // Notification.
if ($my_action == 'notify' AND isset($_GET['content']) AND isset($_GET['id']) && api_is_allowed_to_session_edit(false,true)) { if ($my_action == 'notify' AND isset($_GET['content']) AND isset($_GET['id']) && api_is_allowed_to_session_edit(false, true)) {
$return_message = set_notification($_GET['content'],$_GET['id']); $return_message = set_notification($_GET['content'], $_GET['id']);
Display :: display_confirmation_message($return_message,false); Display :: display_confirmation_message($return_message, false);
} }
// student list // Student list
if ($my_action == 'liststd' AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit(null,true)) { if ($my_action == 'liststd' AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit(null, true)) {
switch($_GET['list']) { switch($_GET['list']) {
case "qualify": case 'qualify':
$student_list=get_thread_users_qualify($_GET['id']); $student_list = get_thread_users_qualify($_GET['id']);
$nrorow3 =-2; $nrorow3 = -2;
break; break;
case "notqualify": case 'notqualify':
$student_list=get_thread_users_not_qualify($_GET['id']); $student_list = get_thread_users_not_qualify($_GET['id']);
$nrorow3 =-2; $nrorow3 = -2;
break; break;
default: default:
$student_list=get_thread_users_details($_GET['id']); $student_list = get_thread_users_details($_GET['id']);
$nrorow3 = Database::num_rows($student_list); $nrorow3 = Database::num_rows($student_list);
break; break;
} }
$table_list = '<p><br /><h3>'.get_lang('ThreadUsersList').'&nbsp;:'.get_name_thread_by_id($_GET['id']).'</h3>'; $table_list = '<p><br /><h3>'.get_lang('ThreadUsersList').': '.get_name_thread_by_id($_GET['id']).'</h3>';
if ($nrorow3>0 || $nrorow3==-2) { if ($nrorow3 > 0 || $nrorow3 == -2) {
$url = 'cidReq='.Security::remove_XSS($_GET['cidReq']).'&amp;forum='.Security::remove_XSS($my_forum).'&amp;action='.Security::remove_XSS($_GET['action']).'&amp;content='.Security::remove_XSS($_GET['content'],STUDENT).'&amp;id='.Security::remove_XSS($_GET['id']); $url = 'cidReq='.Security::remove_XSS($_GET['cidReq']).'&amp;forum='.Security::remove_XSS($my_forum).'&amp;action='.Security::remove_XSS($_GET['action']).'&amp;content='.Security::remove_XSS($_GET['content'],STUDENT).'&amp;id='.Security::remove_XSS($_GET['id']);
$table_list.= '<br /> $table_list .= '<br />
<div style="width:50%"> <div style="width:50%">
<table class="data_table" border="0"> <table class="data_table" border="0">
<tr> <tr>
@ -198,48 +189,48 @@ if ($my_action == 'liststd' AND isset($_GET['content']) AND isset($_GET['id']) A
'; ';
$icon_qualify = 'blog_new.gif'; $icon_qualify = 'blog_new.gif';
$table_list.= '<center><br /><table class="data_table" style="width:50%">'; $table_list .= '<center><br /><table class="data_table" style="width:50%">';
// The column headers (to do: make this sortable) // The column headers (TODO: Make this sortable).
$table_list.= '<tr >'; $table_list .= '<tr >';
$table_list.= '<th height="24">'.get_lang('NamesAndLastNames').'</th>'; $table_list .= '<th height="24">'.get_lang('NamesAndLastNames').'</th>';
if ($_GET['list']=='qualify') { if ($_GET['list'] == 'qualify') {
$table_list.= '<th>'.get_lang('Qualification').'</th>'; $table_list.= '<th>'.get_lang('Qualification').'</th>';
} }
if (api_is_allowed_to_edit(null,true)) { if (api_is_allowed_to_edit(null, true)) {
$table_list.= '<th>'.get_lang('Qualify').'</th>'; $table_list.= '<th>'.get_lang('Qualify').'</th>';
} }
$table_list.= '</tr>'; $table_list .= '</tr>';
$max_qualify=show_qualify('2',$_GET['cidReq'],$my_forum,$userid,$_GET['id']); $max_qualify = show_qualify('2', $_GET['cidReq'], $my_forum, $userid, $_GET['id']);
$counter_stdlist=0; $counter_stdlist = 0;
if (Database::num_rows($student_list)>0) { if (Database::num_rows($student_list) > 0) {
while ($row_student_list=Database::fetch_array($student_list)) { while ($row_student_list=Database::fetch_array($student_list)) {
if ($counter_stdlist%2==0) { if ($counter_stdlist % 2 == 0) {
$class_stdlist="row_odd"; $class_stdlist = 'row_odd';
} else { } else {
$class_stdlist="row_even"; $class_stdlist = 'row_even';
} }
$name_user_theme = api_get_person_name($row_student_list['firstname'], $row_student_list['lastname']); $name_user_theme = api_get_person_name($row_student_list['firstname'], $row_student_list['lastname']);
$table_list.= '<tr class="$class_stdlist"><td><a href="../user/userInfo.php?uInfo='.$row_student_list['user_id'].'&amp;tipo=sdtlist&amp;'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;forum='.Security::remove_XSS($my_forum).$origin_string.'">'.$name_user_theme.'</a></td>'; $table_list .= '<tr class="'.$class_stdlist.'"><td><a href="../user/userInfo.php?uInfo='.$row_student_list['user_id'].'&amp;tipo=sdtlist&amp;'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;forum='.Security::remove_XSS($my_forum).$origin_string.'">'.$name_user_theme.'</a></td>';
if ($_GET['list']=='qualify') { if ($_GET['list'] == 'qualify') {
$table_list.= '<td>'.$row_student_list['qualify'].'/'.$max_qualify.'</td>'; $table_list .= '<td>'.$row_student_list['qualify'].'/'.$max_qualify.'</td>';
} }
if (api_is_allowed_to_edit(null,true)) { if (api_is_allowed_to_edit(null, true)) {
$current_qualify_thread=show_qualify('1',$_GET['cidReq'],$my_forum,$row_student_list['user_id'],$_GET['id']); $current_qualify_thread = show_qualify('1', $_GET['cidReq'], $my_forum, $row_student_list['user_id'], $_GET['id']);
$table_list.= '<td><a href="forumqualify.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;forum='.Security::remove_XSS($my_forum).'&amp;thread='.Security::remove_XSS($_GET['id']).'&amp;user='.$row_student_list['user_id'].'&amp;user_id='.$row_student_list['user_id'].'&amp;idtextqualify='.$current_qualify_thread.'&amp;origin='.$origin.'">'.icon($icon_qualify,get_lang('Qualify')).'</a></td></tr>'; $table_list .= '<td><a href="forumqualify.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;forum='.Security::remove_XSS($my_forum).'&amp;thread='.Security::remove_XSS($_GET['id']).'&amp;user='.$row_student_list['user_id'].'&amp;user_id='.$row_student_list['user_id'].'&amp;idtextqualify='.$current_qualify_thread.'&amp;origin='.$origin.'">'.icon($icon_qualify, get_lang('Qualify')).'</a></td></tr>';
} }
$counter_stdlist++; $counter_stdlist++;
} }
} else { } else {
if ($_GET['list']=='qualify'){ if ($_GET['list'] == 'qualify') {
$table_list.='<tr><td colspan="2">'.get_lang('ThereIsNotQualifiedLearners').'</td></tr>'; $table_list .= '<tr><td colspan="2">'.get_lang('ThereIsNotQualifiedLearners').'</td></tr>';
} else { } else {
$table_list.='<tr><td colspan="2">'.get_lang('ThereIsNotUnqualifiedLearners').'</td></tr>'; $table_list .= '<tr><td colspan="2">'.get_lang('ThereIsNotUnqualifiedLearners').'</td></tr>';
} }
} }
$table_list.= '</table></center>'; $table_list .= '</table></center>';
$table_list .= '<br /></div>'; $table_list .= '<br /></div>';
} else { } else {
$table_list .= get_lang('NoParticipation'); $table_list .= get_lang('NoParticipation');
@ -247,12 +238,11 @@ if ($my_action == 'liststd' AND isset($_GET['content']) AND isset($_GET['id']) A
} }
/* /* Is the user allowed here? */
Is the user allowed here?
*/ // If the user is not a course administrator and the forum is hidden
// if the user is not a course administrator and the forum is hidden
// then the user is not allowed here. // then the user is not allowed here.
if (!api_is_allowed_to_edit(false,true) AND ($current_forum_category['visibility']==0 OR $current_forum['visibility']==0)) { if (!api_is_allowed_to_edit(false, true) AND ($current_forum_category['visibility'] == 0 OR $current_forum['visibility'] == 0)) {
$forum_allow = forum_not_allowed_here(); $forum_allow = forum_not_allowed_here();
if ($forum_allow === false) { if ($forum_allow === false) {
exit; exit;
@ -263,40 +253,35 @@ if ($origin == 'learnpath') {
echo '<div style="height:15px">&nbsp;</div>'; echo '<div style="height:15px">&nbsp;</div>';
} }
/* /* Display the action messages */
Display the action messages
*/
if (!empty($message)) { if (!empty($message)) {
Display :: display_confirmation_message($message); Display :: display_confirmation_message($message);
} }
/* Action links */
/* if ($origin != 'learnpath') {
Action Links
*/
if ($origin!='learnpath') {
echo '<div class="actions">'; echo '<div class="actions">';
if ($origin=='group') { if ($origin=='group') {
echo '<a href="../group/group_space.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;gradebook='.$gradebook.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('Groups'),'','32').'</a>'; echo '<a href="../group/group_space.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;gradebook='.$gradebook.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('Groups'),'','32').'</a>';
} } else {
else{
echo '<span style="float:right;">'.search_link().'</span>'; echo '<span style="float:right;">'.search_link().'</span>';
echo '<a href="index.php">'.Display::return_icon('back.png',get_lang('BackToForumOverview'),'','32').'</a>'; echo '<a href="index.php">'.Display::return_icon('back.png', get_lang('BackToForumOverview'), '', '32').'</a>';
} }
// The link should appear when // The link should appear when
// 1. the course admin is here // 1. the course admin is here
// 2. the course member is here and new threads are allowed // 2. the course member is here and new threads are allowed
// 3. a visitor is here and new threads AND allowed AND anonymous posts are allowed // 3. a visitor is here and new threads AND allowed AND anonymous posts are allowed
if (api_is_allowed_to_edit(false,true) 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)) { if (api_is_allowed_to_edit(false, true) 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)) {
if ($current_forum['locked'] <> 1 AND $current_forum['locked'] <> 1) { if ($current_forum['locked'] <> 1 AND $current_forum['locked'] <> 1) {
if (!api_is_anonymous()) { if (!api_is_anonymous()) {
if ($my_forum==strval(intval($my_forum))) { if ($my_forum == strval(intval($my_forum))) {
echo '<a href="newthread.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;forum='.Security::remove_XSS($my_forum).$origin_string.'">'.Display::return_icon('new_thread.png',get_lang('NewTopic'),'','32').'</a>'; echo '<a href="newthread.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;forum='.Security::remove_XSS($my_forum).$origin_string.'">'.Display::return_icon('new_thread.png',get_lang('NewTopic'),'','32').'</a>';
} else { } else {
$my_forum=strval(intval($my_forum)); $my_forum = strval(intval($my_forum));
echo '<a href="newthread.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;forum='.$my_forum.$origin_string.'">'.Display::return_icon('new_thread.png',get_lang('NewTopic'),'','32').'</a>'; echo '<a href="newthread.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;forum='.$my_forum.$origin_string.'">'.Display::return_icon('new_thread.png',get_lang('NewTopic'),'','32').'</a>';
} }
} }
} else { } else {
echo get_lang('ForumLocked'); echo get_lang('ForumLocked');
@ -305,161 +290,148 @@ if ($origin!='learnpath') {
echo '</div>'; echo '</div>';
} }
/* /* Display */
Display
*/
echo '<table class="forum_table" >'; echo '<table class="forum_table" >';
// the current forum // The current forum
if ($origin != 'learnpath') { if ($origin != 'learnpath') {
echo '<thead>'; echo '<thead><tr><th class="forum_head" colspan="7">';
echo "<tr><th class=\"forum_head\" colspan=\"7\">";
if (!empty ($current_forum_category['cat_title'])) { if (!empty ($current_forum_category['cat_title'])) {
//echo '<span class="forum_low_description">'.prepare4display($current_forum_category['cat_title'])."</span><br />"; //echo '<span class="forum_low_description">'.prepare4display($current_forum_category['cat_title'])."</span><br />";
} }
echo '<span class="forum_title">'.prepare4display($current_forum['forum_title']).'</span>'; echo '<span class="forum_title">'.prepare4display($current_forum['forum_title']).'</span>';
if (!empty ($current_forum['forum_comment'])) { if (!empty ($current_forum['forum_comment'])) {
echo '<br><span class="forum_description">'.prepare4display($current_forum['forum_comment']).'</span>'; echo '<br /><span class="forum_description">'.prepare4display($current_forum['forum_comment']).'</span>';
} }
echo '</th></tr></thead>';
echo "</th>";
echo "</tr>";
echo '</thead>';
} }
echo "</th>"; // The column headers (TODO: Make this sortable).
echo "</tr>"; echo '<tr class="forum_threadheader">';
echo '<td></td>';
// The column headers (to do: make this sortable) echo '<td>'.get_lang('Title').'</td>';
echo "<tr class=\"forum_threadheader\">"; echo '<td>'.get_lang('Replies').'</td>';
echo "<td></td>"; echo '<td>'.get_lang('Views').'</td>';
echo "<td>".get_lang('Title')."</td>"; echo '<td>'.get_lang('Author').'</td>';
echo "<td>".get_lang('Replies')."</td>"; echo '<td>'.get_lang('LastPost').'</td>';
echo "<td>".get_lang('Views')."</td>"; echo '<td>'.get_lang('Actions').'</td>';
echo "<td>".get_lang('Author')."</td>"; echo '</tr>';
echo "<td>".get_lang('LastPost')."</td>";
echo "<td>".get_lang('Actions')."</td>";
echo "</tr>";
// getting al the threads // Getting al the threads
$threads=get_threads($my_forum); // note: this has to be cleaned first $threads = get_threads($my_forum); // Note: This has to be cleaned first.
$whatsnew_post_info=isset($_SESSION['whatsnew_post_info'])?$_SESSION['whatsnew_post_info']:null; $whatsnew_post_info = isset($_SESSION['whatsnew_post_info']) ? $_SESSION['whatsnew_post_info'] : null;
$counter=0; $counter = 0;
if(is_array($threads)) { if (is_array($threads)) {
foreach ($threads as $row) { foreach ($threads as $row) {
// thread who have no replies yet and the only post is invisible should not be displayed to students. // Thread who have no replies yet and the only post is invisible should not be displayed to students.
if (api_is_allowed_to_edit(false,true) OR !($row['thread_replies']=='0' AND $row['visible']=='0')) { if (api_is_allowed_to_edit(false, true) OR !($row['thread_replies'] == '0' AND $row['visible'] == '0')) {
if($counter%2==0) { if ($counter % 2 == 0) {
$class="row_odd"; $class = 'row_odd';
} else { } else {
$class="row_even"; $class = 'row_even';
} }
echo "<tr class=\"$class\">"; echo "<tr class=\"$class\">";
echo "<td>"; echo '<td>';
$my_whatsnew_post_info=isset($whatsnew_post_info[$my_forum][$row['thread_id']])?$whatsnew_post_info[$my_forum][$row['thread_id']]:null; $my_whatsnew_post_info = isset($whatsnew_post_info[$my_forum][$row['thread_id']]) ? $whatsnew_post_info[$my_forum][$row['thread_id']] : null;
if (is_array($my_whatsnew_post_info) and !empty($my_whatsnew_post_info)) { if (is_array($my_whatsnew_post_info) && !empty($my_whatsnew_post_info)) {
echo Display::return_icon('forumthread.gif'); echo Display::return_icon('forumthread.gif');
} else { } else {
echo Display::return_icon('forumthread.gif'); echo Display::return_icon('forumthread.gif');
} }
if ($row['thread_sticky']==1) { if ($row['thread_sticky'] == 1) {
echo Display::return_icon('exclamation.gif'); echo Display::return_icon('exclamation.gif');
} }
echo "</td>"; echo '</td>';
echo "<td>"; echo '<td>';
echo "<a href=\"viewthread.php?".api_get_cidreq()."&amp;gidReq=".Security::remove_XSS($_GET['gidReq'])."&amp;gradebook=".Security::remove_XSS($_GET['gradebook'])."&amp;forum=".Security::remove_XSS($my_forum)."&amp;origin=".$origin."&amp;thread=".$row['thread_id'].$origin_string."&amp;search=".Security::remove_XSS(urlencode($my_search))."\" ".class_visible_invisible($row['visibility']).">".prepare4display($row['thread_title'])."</a></td>"; echo '<a href="viewthread.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;gradebook='.Security::remove_XSS($_GET['gradebook']).'&amp;forum='.Security::remove_XSS($my_forum).'&amp;origin='.$origin.'&amp;thread='.$row['thread_id'].$origin_string.'&amp;search='.Security::remove_XSS(urlencode($my_search)).'" '.class_visible_invisible($row['visibility']).'>'.prepare4display($row['thread_title']).'</a></td>';
echo "<td>".$row['thread_replies']."</td>"; echo '<td>'.$row['thread_replies'].'</td>';
if ($row['user_id']=='0') { if ($row['user_id'] == '0') {
$name=prepare4display($row['thread_poster_name']); $name = prepare4display($row['thread_poster_name']);
} else { } else {
$name=api_get_person_name($row['firstname'], $row['lastname']); $name = api_get_person_name($row['firstname'], $row['lastname']);
} }
echo "<td>".$row['thread_views']."</td>"; echo '<td>'.$row['thread_views'].'</td>';
if ($row['last_poster_user_id']=='0') { if ($row['last_poster_user_id'] == '0') {
$name=$row['poster_name']; $name = $row['poster_name'];
} else { } else {
$name=api_get_person_name($row['last_poster_firstname'], $row['last_poster_lastname']); $name = api_get_person_name($row['last_poster_firstname'], $row['last_poster_lastname']);
} }
if($origin != 'learnpath') { if ($origin != 'learnpath') {
echo "<td>".display_user_link($row['user_id'], api_get_person_name($row['firstname'], $row['lastname']))."</td>"; echo '<td>'.display_user_link($row['user_id'], api_get_person_name($row['firstname'], $row['lastname'])).'</td>';
} else { } else {
echo "<td>".api_get_person_name($row['firstname'], $row['lastname'])."</td>"; echo '<td>'.api_get_person_name($row['firstname'], $row['lastname']).'</td>';
} }
// 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 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(false,true)) && $origin!='learnpath') { if (($row['visible'] == '1' OR api_is_allowed_to_edit(false, true)) && $origin != 'learnpath') {
$last_post=api_convert_and_format_date($row['thread_date'], null, date_default_timezone_get())." ".get_lang('By').' '.display_user_link($row['last_poster_user_id'], $name); $last_post = api_convert_and_format_date($row['thread_date'], null, date_default_timezone_get()).' '.get_lang('By').' '.display_user_link($row['last_poster_user_id'], $name);
} elseif ($origin!='learnpath') { } elseif ($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_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=Database::query($last_post_sql); $last_post_result = Database::query($last_post_sql);
$last_post_row=Database::fetch_array($last_post_result); $last_post_row = Database::fetch_array($last_post_result);
$name=api_get_person_name($last_post_row['firstname'], $last_post_row['lastname']); $name = api_get_person_name($last_post_row['firstname'], $last_post_row['lastname']);
$last_post=api_convert_and_format_date($last_post_row['post_date'], null, date_default_timezone_get())." ".get_lang('By').' '.display_user_link($last_post_row['poster_id'], $name); $last_post = api_convert_and_format_date($last_post_row['post_date'], null, date_default_timezone_get()).' '.get_lang('By').' '.display_user_link($last_post_row['poster_id'], $name);
} else { } 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_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=Database::query($last_post_sql); $last_post_result = Database::query($last_post_sql);
$last_post_row=Database::fetch_array($last_post_result); $last_post_row = Database::fetch_array($last_post_result);
$name=api_get_person_name($last_post_row['firstname'], $last_post_row['lastname']); $name = api_get_person_name($last_post_row['firstname'], $last_post_row['lastname']);
$last_post=api_convert_and_format_date($last_post_row['post_date'], null, date_default_timezone_get())." ".get_lang('By').' '.$name; $last_post = api_convert_and_format_date($last_post_row['post_date'], null, date_default_timezone_get()).' '.get_lang('By').' '.$name;
} }
echo "<td>".$last_post."</td>"; echo '<td>'.$last_post.'</td>';
echo "<td>"; echo '<td>';
// get attach id // Get attachment id.
$attachment_list=get_attachment($row['post_id']); $attachment_list = get_attachment($row['post_id']);
$id_attach = !empty($attachment_list)?$attachment_list['id']:''; $id_attach = !empty($attachment_list) ? $attachment_list['id'] : '';
$sql_post_id="SELECT post_id FROM $table_posts WHERE post_title='".Database::escape_string($row['thread_title'])."'"; $sql_post_id = "SELECT post_id FROM $table_posts WHERE post_title='".Database::escape_string($row['thread_title'])."'";
$result_post_id=Database::query($sql_post_id); $result_post_id = Database::query($sql_post_id);
$row_post_id=Database::fetch_array($result_post_id); $row_post_id = Database::fetch_array($result_post_id);
if ($origin != 'learnpath') { if ($origin != 'learnpath') {
if (api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])) { if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $_SESSION['id_session'])) {
echo "<a href=\"editpost.php?".api_get_cidreq()."&amp;forum=".Security::remove_XSS($my_forum)."&amp;thread=".Security::remove_XSS($row['thread_id'])."&amp;post=".$row_post_id['post_id']."&amp;gidReq=".$_SESSION['toolgroup']."&amp;origin=".$origin."&amp;id_attach=".$id_attach."\">".Display::return_icon('edit.png',get_lang('Edit'), array(), 22)."</a>"; echo '<a href="editpost.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).'&amp;thread='.Security::remove_XSS($row['thread_id']).'&amp;post='.$row_post_id['post_id'].'&amp;gidReq='.$_SESSION['toolgroup'].'&amp;origin='.$origin.'&amp;id_attach='.$id_attach.'">'.Display::return_icon('edit.png', get_lang('Edit'), array(), 22).'</a>';
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&amp;forum=".Security::remove_XSS($my_forum)."&amp;action=delete&amp;content=thread&amp;gidReq=".$_SESSION['toolgroup']."&amp;id=".$row['thread_id'].$origin_string."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('DeleteCompleteThread'), ENT_QUOTES))."')) return false;\">".Display::return_icon('delete.png',get_lang('Delete'), array(), 22)."</a>"; echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).'&amp;action=delete&amp;content=thread&amp;gidReq='.$_SESSION['toolgroup'].'&amp;id='.$row['thread_id'].$origin_string."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('DeleteCompleteThread'), ENT_QUOTES))."')) return false;\">".Display::return_icon('delete.png', get_lang('Delete'), array(), 22).'</a>';
display_visible_invisible_icon('thread', $row['thread_id'], $row['visibility'], array("forum"=>$my_forum,'origin'=>$origin,"gidReq"=>$_SESSION['toolgroup'])); display_visible_invisible_icon('thread', $row['thread_id'], $row['visibility'], array('forum' => $my_forum, 'origin' => $origin, 'gidReq' => $_SESSION['toolgroup']));
display_lock_unlock_icon('thread',$row['thread_id'], $row['locked'], array("forum"=>$my_forum,'origin'=>$origin,"gidReq"=>$_SESSION['toolgroup'])); display_lock_unlock_icon('thread', $row['thread_id'], $row['locked'], array('forum' => $my_forum, 'origin' => $origin, 'gidReq' => $_SESSION['toolgroup']));
echo "<a href=\"viewforum.php?".api_get_cidreq()."&amp;forum=".Security::remove_XSS($my_forum)."&amp;action=move&amp;gidReq=".$_SESSION['toolgroup']."&amp;thread=".$row['thread_id'].$origin_string."\">".Display::return_icon('move.png',get_lang('MoveThread'), array(), 22)."</a>"; echo '<a href="viewforum.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).'&amp;action=move&amp;gidReq='.$_SESSION['toolgroup'].'&amp;thread='.$row['thread_id'].$origin_string.'">'.Display::return_icon('move.png', get_lang('MoveThread'), array(), 22).'</a>';
} }
} }
$iconnotify = 'send_mail.gif'; $iconnotify = 'send_mail.gif';
if (is_array(isset($_SESSION['forum_notification']['thread'])?$_SESSION['forum_notification']['thread']:null)) { if (is_array(isset($_SESSION['forum_notification']['thread']) ? $_SESSION['forum_notification']['thread'] : null)) {
if (in_array($row['thread_id'],$_SESSION['forum_notification']['thread'])) { if (in_array($row['thread_id'], $_SESSION['forum_notification']['thread'])) {
$iconnotify = 'send_mail_checked.gif'; $iconnotify = 'send_mail_checked.gif';
} }
} }
$icon_liststd = 'user.png'; $icon_liststd = 'user.png';
if (!api_is_anonymous() && api_is_allowed_to_session_edit(false,true)) { if (!api_is_anonymous() && api_is_allowed_to_session_edit(false, true)) {
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&amp;forum=".Security::remove_XSS($my_forum)."&amp;origin=".$origin."&amp;action=notify&amp;content=thread&amp;gidReq=".$_SESSION['toolgroup']."&amp;id=".$row['thread_id']."\">".Display::return_icon($iconnotify,get_lang('NotifyMe'))."</a>"; echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).'&amp;origin='.$origin.'&amp;action=notify&amp;content=thread&amp;gidReq='.$_SESSION['toolgroup'].'&amp;id='.$row['thread_id'].'">'.Display::return_icon($iconnotify, get_lang('NotifyMe')).'</a>';
} }
if (api_is_allowed_to_edit(null,true) && $origin != 'learnpath') { if (api_is_allowed_to_edit(null,true) && $origin != 'learnpath') {
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).'&amp;origin='.$origin.'&amp;action=liststd&amp;content=thread&amp;gidReq='.$_SESSION['toolgroup'].'&amp;id='.$row['thread_id'].'">'.Display::return_icon($icon_liststd,get_lang('StudentList'), array(), 22).'</a>'; echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).'&amp;origin='.$origin.'&amp;action=liststd&amp;content=thread&amp;gidReq='.$_SESSION['toolgroup'].'&amp;id='.$row['thread_id'].'">'.Display::return_icon($icon_liststd,get_lang('StudentList'), array(), 22).'</a>';
} }
echo "</td>"; echo '</td></tr>';
echo "</tr>";
} }
$counter++; $counter++;
} }
} }
echo "</table>"; echo '</table>';
echo isset($table_list)?$table_list:''; echo isset($table_list) ? $table_list : '';
/* FOOTER */ /* FOOTER */
if ($origin != 'learnpath') { if ($origin != 'learnpath') {
Display :: display_footer(); Display :: display_footer();
} }

@ -22,10 +22,12 @@
* @package chamilo.forum * @package chamilo.forum
*/ */
// name of the language file that needs to be included // Language file that needs to be included.
$language_file = 'forum'; $language_file = 'forum';
// including the global dokeos init file
// Including the global initialization file.
require '../inc/global.inc.php'; require '../inc/global.inc.php';
$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/jquery.js" ></script>'; $htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/jquery.js" ></script>';
$htmlHeadXtra[] = '<script type="text/javascript" language="javascript"> $htmlHeadXtra[] = '<script type="text/javascript" language="javascript">
$(document).ready(function(){ $(\'.hide-me\').slideUp() }); $(document).ready(function(){ $(\'.hide-me\').slideUp() });
@ -44,22 +46,18 @@ $htmlHeadXtra[] = '<script type="text/javascript" language="javascript">
} }
</script>'; </script>';
// The section (tabs)
$this_section = SECTION_COURSES;
// including the global dokeos file // Notification for unauthorized people.
require '../inc/global.inc.php';
// the section (tabs)
$this_section=SECTION_COURSES;
// notice for unauthorized people.
api_protect_course_script(true); api_protect_course_script(true);
// including additional library scripts // Including additional library scripts.
require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'); require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php'); include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
$nameTools=get_lang('ToolForum'); $nameTools=get_lang('ToolForum');
/* Including necessary files */ // Including necessary files
require 'forumconfig.inc.php'; require 'forumconfig.inc.php';
require_once 'forumfunction.inc.php'; require_once 'forumfunction.inc.php';
@ -68,25 +66,25 @@ require_once 'forumfunction.inc.php';
/* Header and Breadcrumbs */ /* Header and Breadcrumbs */
if (isset($_SESSION['gradebook'])){ if (isset($_SESSION['gradebook'])) {
$gradebook= $_SESSION['gradebook']; $gradebook= $_SESSION['gradebook'];
} }
if (!empty($gradebook) && $gradebook=='view') { if (!empty($gradebook) && $gradebook == 'view') {
$interbreadcrumb[]= array ( $interbreadcrumb[] = array (
'url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
'name' => get_lang('ToolGradebook') 'name' => get_lang('ToolGradebook')
); );
} }
$current_forum_category=get_forum_categories($_GET['forumcategory']); $current_forum_category = get_forum_categories($_GET['forumcategory']);
$interbreadcrumb[]=array("url" => "index.php?gradebook=$gradebook&amp;search=".Security::remove_XSS(urlencode(isset($_GET['search'])?$_GET['search']:'')),"name" => $nameTools); $interbreadcrumb[] = array('url' => 'index.php?gradebook='.$gradebook.'&amp;search='.Security::remove_XSS(urlencode(isset($_GET['search'])?$_GET['search']:'')),'name' => $nameTools);
$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&amp;origin=".$origin."&amp;search=".Security::remove_XSS(urlencode(isset($_GET['search'])?$_GET['search']:'')),"name" => prepare4display($current_forum_category['cat_title'])); $interbreadcrumb[] = array('url' => 'viewforumcategory.php?forumcategory='.$current_forum_category['cat_id'].'&amp;origin='.$origin.'&amp;search='.Security::remove_XSS(urlencode(isset($_GET['search'])?$_GET['search']:'')),'name' => prepare4display($current_forum_category['cat_title']));
if (!empty($_GET['action']) && !empty($_GET['content'])) { if (!empty($_GET['action']) && !empty($_GET['content'])) {
if ($_GET['action']=='add' && $_GET['content']=='forum' ) { if ($_GET['action']=='add' && $_GET['content']=='forum' ) {
$interbreadcrumb[] = array ("url" => api_get_self().'?'.api_get_cidreq().'&amp;action=add&amp;content=forum', 'name' => get_lang('AddForum')); $interbreadcrumb[] = array ('url' => api_get_self().'?'.api_get_cidreq().'&amp;action=add&amp;content=forum', 'name' => get_lang('AddForum'));
} }
} }
@ -122,7 +120,7 @@ if (!api_is_allowed_to_edit(false,true) AND $current_forum_category['visibility'
echo '<div class="actions">'; echo '<div class="actions">';
echo '<span style="float:right;">'.search_link().'</span>'; echo '<span style="float:right;">'.search_link().'</span>';
echo '<a href="index.php?gradebook='.$gradebook.'">'.Display::return_icon('back.png',get_lang('BackToForumOverview'),'','32').'</a>'; echo '<a href="index.php?gradebook='.$gradebook.'">'.Display::return_icon('back.png', get_lang('BackToForumOverview'), '', '32').'</a>';
if (api_is_allowed_to_edit(false,true)) { if (api_is_allowed_to_edit(false,true)) {
//echo '<a href="'.api_get_self().'?forumcategory='.$_GET['forumcategory'].'&amp;action=add&amp;content=forumcategory">'.get_lang('AddForumCategory').'</a> | '; //echo '<a href="'.api_get_self().'?forumcategory='.$_GET['forumcategory'].'&amp;action=add&amp;content=forumcategory">'.get_lang('AddForumCategory').'</a> | ';
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;action=add&amp;content=forum"> '.Display::return_icon('new_forum.png', get_lang('AddForum'),'','32').'</a>'; echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;action=add&amp;content=forum"> '.Display::return_icon('new_forum.png', get_lang('AddForum'),'','32').'</a>';
@ -132,237 +130,232 @@ echo '</div>';
/* ACTIONS */ /* ACTIONS */
$action_forums=isset($_GET['action']) ? $_GET['action'] : ''; $action_forums = isset($_GET['action']) ? $_GET['action'] : '';
if (api_is_allowed_to_edit(false,true)) { if (api_is_allowed_to_edit(false, true)) {
handle_forum_and_forumcategories(); handle_forum_and_forumcategories();
} }
// notification // Notification
if ($action_forums == 'notify' AND isset($_GET['content']) AND isset($_GET['id'])) { if ($action_forums == 'notify' && isset($_GET['content']) && isset($_GET['id'])) {
$return_message = set_notification($_GET['content'],$_GET['id']); $return_message = set_notification($_GET['content'], $_GET['id']);
Display :: display_confirmation_message($return_message,false); Display :: display_confirmation_message($return_message, false);
} }
if ($action_forums!='add') { if ($action_forums != 'add') {
/* /*
RETRIEVING ALL THE FORUM CATEGORIES AND FORUMS RETRIEVING ALL THE FORUM CATEGORIES AND FORUMS
Note: we do this here just after het handling of the actions to be sure that we already incorporate the Note: We do this here just after het handling of the actions to be sure that we already incorporate the
latest changes latest changes.
*/ */
// Step 1: We store all the forum categories in an array $forum_categories // Step 1: We store all the forum categories in an array $forum_categories.
$forum_categories=array(); $forum_categories = array();
$forum_category=get_forum_categories($_GET['forumcategory']); $forum_category = get_forum_categories($_GET['forumcategory']);
// step 2: we find all the forums // Step 2: We find all the forums.
$forum_list=array(); $forum_list = array();
$forum_list=get_forums(); $forum_list = get_forums();
/* RETRIEVING ALL GROUPS AND THOSE OF THE USER */ /* RETRIEVING ALL GROUPS AND THOSE OF THE USER */
// the groups of the user // The groups of the user.
$groups_of_user=array(); $groups_of_user = array();
$groups_of_user=GroupManager::get_group_ids($_course['dbName'], $_user['user_id']); $groups_of_user = GroupManager::get_group_ids($_course['dbName'], $_user['user_id']);
// all groups in the course (and sorting them as the id of the group = the key of the array // All groups in the course (and sorting them as the id of the group = the key of the array.
$all_groups=GroupManager::get_group_list(); $all_groups = GroupManager::get_group_list();
if(is_array($all_groups)) { if (is_array($all_groups)) {
foreach ($all_groups as $group) { foreach ($all_groups as $group) {
$all_groups[$group['id']]=$group; $all_groups[$group['id']] = $group;
} }
} }
/* CLEAN GROUP ID FOR AJAXFILEMANAGER */ /* CLEAN GROUP ID FOR AJAXFILEMANAGER */
if(isset($_SESSION['_gid'])) if (isset($_SESSION['_gid'])) {
{
unset($_SESSION['_gid']); unset($_SESSION['_gid']);
} }
/* Display Forum Categories and the Forums in it */ /* Display Forum Categories and the Forums in it */
echo '<table class="forum_table" width="100%">'; echo '<table class="forum_table" width="100%">';
$my_session=isset($_SESSION['id_session']) ? $_SESSION['id_session'] : null; $my_session = isset($_SESSION['id_session']) ? $_SESSION['id_session'] : null;
if((!isset($_SESSION['id_session']) || $_SESSION['id_session']==0) && !empty($forum_category['session_name'])) { if ((!isset($_SESSION['id_session']) || $_SESSION['id_session'] == 0) && !empty($forum_category['session_name'])) {
$session_displayed = ' ('.Security::remove_XSS($forum_category['session_name']).')'; $session_displayed = ' ('.Security::remove_XSS($forum_category['session_name']).')';
} else { } else {
$session_displayed = ''; $session_displayed = '';
} }
$forum_categories_list=''; $forum_categories_list = '';
echo '<thead>'; echo '<thead>';
echo "<tr><th class=\"forum_head\" ".(api_is_allowed_to_edit(null,true)?"colspan='5'":"colspan='6'").">"; echo '<tr><th class="forum_head" '.(api_is_allowed_to_edit(null, true) ? 'colspan="5"' : 'colspan="6"').'>';
echo '<a href="viewforumcategory.php?'.api_get_cidreq().'&amp;forumcategory='.strval(intval($forum_category['cat_id'])).'" '.class_visible_invisible(strval(intval($forum_category['visibility']))).'>'.prepare4display($forum_category['cat_title']).$session_displayed.'</a>'. $session_img .'<br />'; echo '<a href="viewforumcategory.php?'.api_get_cidreq().'&amp;forumcategory='.strval(intval($forum_category['cat_id'])).'" '.class_visible_invisible(strval(intval($forum_category['visibility']))).'>'.prepare4display($forum_category['cat_title']).$session_displayed.'</a>'. $session_img .'<br />';
echo '<span class="forum_description">'.prepare4display($forum_category['cat_comment']).'</span>'; echo '<span class="forum_description">'.prepare4display($forum_category['cat_comment']).'</span>';
if (api_is_allowed_to_edit(false,true) && !($forum_category['session_id']==0 && intval($my_session)!=0)) { if (api_is_allowed_to_edit(false, true) && !($forum_category['session_id'] == 0 && intval($my_session) != 0)) {
echo '<th style="vertical-align: top;" align="center" >'; echo '<th style="vertical-align: top;" align="center">';
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&amp;forumcategory=".Security::remove_XSS($_GET['forumcategory'])."&amp;action=edit&amp;content=forumcategory&amp;id=".$forum_category['cat_id']."\">".Display::return_icon('edit.png',get_lang('Edit'), array(), 22)."</a>"; echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forumcategory='.Security::remove_XSS($_GET['forumcategory']).'&amp;action=edit&amp;content=forumcategory&amp;id='.$forum_category['cat_id'].'">'.Display::return_icon('edit.png', get_lang('Edit'), array(), 22).'</a>';
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&amp;forumcategory=".Security::remove_XSS($_GET['forumcategory'])."&amp;action=delete&amp;content=forumcategory&amp;amp;id=".$forum_category['cat_id']."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('DeleteForumCategory'), ENT_QUOTES))."')) return false;\">".Display::return_icon('delete.png',get_lang('Delete'), array(), 22)."</a>"; echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forumcategory='.Security::remove_XSS($_GET['forumcategory']).'&amp;action=delete&amp;content=forumcategory&amp;amp;id='.$forum_category['cat_id']."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('DeleteForumCategory'), ENT_QUOTES))."')) return false;\">".Display::return_icon('delete.png', get_lang('Delete'), array(), 22).'</a>';
display_visible_invisible_icon('forumcategory', $forum_category['cat_id'], $forum_category['visibility'], array("forumcategory"=>$_GET['forumcategory'])); display_visible_invisible_icon('forumcategory', $forum_category['cat_id'], $forum_category['visibility'], array('forumcategory' => $_GET['forumcategory']));
display_lock_unlock_icon('forumcategory',$forum_category['cat_id'], $forum_category['locked'], array("forumcategory"=>$_GET['forumcategory'])); display_lock_unlock_icon('forumcategory', $forum_category['cat_id'], $forum_category['locked'], array('forumcategory' => $_GET['forumcategory']));
display_up_down_icon('forumcategory',$forum_category['cat_id'], $forum_categories_list); display_up_down_icon('forumcategory', $forum_category['cat_id'], $forum_categories_list);
echo "</th>"; echo '</th>';
} }
echo "</tr>"; echo '</tr>';
// step 3: the interim headers (for the forum) // Step 3: The interim headers (for the forum).
echo "<tr class=\"forum_header\">"; echo '<tr class="forum_header">';
echo "<td colspan='2'>".get_lang('Forum')."</td>"; echo '<td colspan="2">'.get_lang('Forum').'</td>';
echo "<td>".get_lang('Topics')."</td>"; echo '<td>'.get_lang('Topics').'</td>';
echo "<td>".get_lang('Posts')."</td>"; echo '<td>'.get_lang('Posts').'</td>';
echo "<td>".get_lang('LastPosts')."</td>"; echo '<td>'.get_lang('LastPosts').'</td>';
echo "<td>".get_lang('Actions')."</td>"; echo '<td>'.get_lang('Actions').'</td>';
echo "</tr>"; echo '</tr>';
echo '</thead>'; echo '</thead>';
// the forums in this category // The forums in this category.
$forums_in_category=get_forums_in_category($forum_category['cat_id']); $forums_in_category = get_forums_in_category($forum_category['cat_id']);
// step 4: we display all the forums in this category. // Step 4: We display all the forums in this category.
$forum_count=0; $forum_count = 0;
foreach ($forum_list as $key=>$forum) { foreach ($forum_list as $key => $forum) {
if ($forum['forum_category']==$forum_category['cat_id']) { if ($forum['forum_category'] == $forum_category['cat_id']) {
// the forum has to be showed if // The forum has to be showed if
// 1.v it is a not a group forum (teacher and student) // 1.v it is a not a group forum (teacher and student)
// 2.v it is a group forum and it is public (teacher and student) // 2.v it is a group forum and it is public (teacher and student)
// 3. it is a group forum and it is private (always for teachers only if the user is member of the forum // 3. it is a group forum and it is private (always for teachers only if the user is member of the forum
// if the forum is private and it is a group forum and the user is not a member of the group forum then it cannot be displayed // if the forum is private and it is a group forum and the user is not a member of the group forum then it cannot be displayed
//if (!($forum['forum_group_public_private']=='private' AND !is_null($forum['forum_of_group']) AND !in_array($forum['forum_of_group'], $groups_of_user))) //if (!($forum['forum_group_public_private']=='private' AND !is_null($forum['forum_of_group']) AND !in_array($forum['forum_of_group'], $groups_of_user))) {
//{ $show_forum = false;
$show_forum=false;
// SHOULD WE SHOW THIS PARTICULAR FORUM // SHOULD WE SHOW THIS PARTICULAR FORUM
// you are teacher => show forum // you are teacher => show forum
if (api_is_allowed_to_edit(false,true)) { if (api_is_allowed_to_edit(false,true)) {
//echo 'teacher'; //echo 'teacher';
$show_forum=true; $show_forum = true;
} else { } else {
// you are not a teacher // you are not a teacher
//echo 'student'; //echo 'student';
// it is not a group forum => show forum (invisible forums are already left out see get_forums function) // it is not a group forum => show forum (invisible forums are already left out see get_forums function)
if ($forum['forum_of_group']=='0') { if ($forum['forum_of_group'] == '0') {
//echo '-gewoon forum'; //echo '-gewoon forum';
$show_forum=true; $show_forum = true;
} else { } else {
// it is a group forum // it is a group forum
//echo '-groepsforum'; //echo '-groepsforum';
// it is a group forum but it is public => show // it is a group forum but it is public => show
if ($forum['forum_group_public_private']=='public') { if ($forum['forum_group_public_private'] == 'public') {
$show_forum=true; $show_forum = true;
//echo '-publiek'; //echo '-publiek';
} else { } else {
// it is a group forum and it is private // it is a group forum and it is private
//echo '-prive'; //echo '-prive';
// it is a group forum and it is private but the user is member of the group // it is a group forum and it is private but the user is member of the group
if (in_array($forum['forum_of_group'],$groups_of_user)) { if (in_array($forum['forum_of_group'], $groups_of_user)) {
//echo '-is lid'; //echo '-is lid';
$show_forum=true; $show_forum = true;
} else { } else {
//echo '-is GEEN lid'; //echo '-is GEEN lid';
$show_forum=false; $show_forum = false;
} }
} }
} }
} }
//echo '<hr>'; //echo '<hr />';
$form_count=isset($form_count)?$form_count:0; $form_count = isset($form_count) ? $form_count : 0;
if ($show_forum === true) { if ($show_forum === true) {
$form_count++; $form_count++;
echo "<tr class=\"forum\">"; echo '<tr class="forum">';
echo "<td width=\"20\">"; echo '<td width="20">';
$my_whatsnew_post_info=isset($whatsnew_post_info[$forum['forum_id']])?$whatsnew_post_info[$forum['forum_id']]:null; $my_whatsnew_post_info = isset($whatsnew_post_info[$forum['forum_id']]) ? $whatsnew_post_info[$forum['forum_id']] : null;
if ($forum['forum_of_group']!=='0') { if ($forum['forum_of_group'] !== '0') {
if (is_array($my_whatsnew_post_info) and !empty($my_whatsnew_post_info)) { if (is_array($my_whatsnew_post_info) && !empty($my_whatsnew_post_info)) {
echo Display::return_icon('forumgroupnew.gif'); echo Display::return_icon('forumgroupnew.gif');
} else { } else {
echo Display::return_icon('forumgroup.gif', get_lang('GroupForum')); echo Display::return_icon('forumgroup.gif', get_lang('GroupForum'));
} }
} else { } else {
if (is_array($my_whatsnew_post_info) and !empty($my_whatsnew_post_info)) { if (is_array($my_whatsnew_post_info) && !empty($my_whatsnew_post_info)) {
echo Display::return_icon('forum.gif', get_lang('Forum')); echo Display::return_icon('forum.gif', get_lang('Forum'));
} else { } else {
echo Display::return_icon('forum.gif'); echo Display::return_icon('forum.gif');
} }
} }
echo "</td>"; echo '</td>';
if ($forum['forum_of_group']<>'0')
{
$my_all_groups_forum_name=isset($all_groups[$forum['forum_of_group']]['name']) ? $all_groups[$forum['forum_of_group']]['name'] : null;
$my_all_groups_forum_id=isset($all_groups[$forum['forum_of_group']]['id']) ? $all_groups[$forum['forum_of_group']]['id'] : null;
$group_title=api_substr($my_all_groups_forum_name,0,30);
$forum_title_group_addition=' (<a href="../group/group_space.php?'.api_get_cidreq().'&amp;gidReq='.$my_all_groups_forum_id.'" class="forum_group_link">'.get_lang('GoTo').' '.$group_title.'</a>)';
}
else
{
$forum_title_group_addition='';
}
if ($forum['forum_of_group'] != '0') {
$my_all_groups_forum_name = isset($all_groups[$forum['forum_of_group']]['name']) ? $all_groups[$forum['forum_of_group']]['name'] : null;
$my_all_groups_forum_id = isset($all_groups[$forum['forum_of_group']]['id']) ? $all_groups[$forum['forum_of_group']]['id'] : null;
$group_title = api_substr($my_all_groups_forum_name, 0, 30);
$forum_title_group_addition = ' (<a href="../group/group_space.php?'.api_get_cidreq().'&amp;gidReq='.$my_all_groups_forum_id.'" class="forum_group_link">'.get_lang('GoTo').' '.$group_title.'</a>)';
} else {
$forum_title_group_addition = '';
}
if((!isset($_SESSION['id_session']) || $_SESSION['id_session']==0) && !empty($forum['session_name'])) { if ((!isset($_SESSION['id_session']) || $_SESSION['id_session'] == 0) && !empty($forum['session_name'])) {
$session_displayed = ' ('.$forum['session_name'].')'; $session_displayed = ' ('.$forum['session_name'].')';
} else { } else {
$session_displayed = ''; $session_displayed = '';
} }
echo "<td><a href=\"viewforum.php?".api_get_cidreq()."&amp;forum=".$forum['forum_id']."&amp;origin=".$origin."&amp;search=".Security::remove_XSS(urlencode(isset($_GET['search'])?$_GET['search']:''))."\" ".class_visible_invisible($forum['visibility']).">".prepare4display($forum['forum_title']).$session_displayed.'</a>'.$forum_title_group_addition.'<br />'.prepare4display($forum['forum_comment'])."</td>"; echo '<td><a href="viewforum.php?'.api_get_cidreq().'&amp;forum='.$forum['forum_id'].'&amp;origin='.$origin.'&amp;search='.Security::remove_XSS(urlencode(isset($_GET['search']) ? $_GET['search'] : '')).'" '.class_visible_invisible($forum['visibility']).'>'.prepare4display($forum['forum_title']).$session_displayed.'</a>'.$forum_title_group_addition.'<br />'.prepare4display($forum['forum_comment']).'</td>';
//$number_forum_topics_and_posts=get_post_topics_of_forum($forum['forum_id']); // deprecated //$number_forum_topics_and_posts=get_post_topics_of_forum($forum['forum_id']); // deprecated
// the number of topics and posts // the number of topics and posts
$my_number_threads=isset($forum['number_of_threads']) ? $forum['number_of_threads'] : ''; $my_number_threads = isset($forum['number_of_threads']) ? $forum['number_of_threads'] : '';
$my_number_posts=isset($forum['number_of_posts']) ? $forum['number_of_posts'] : ''; $my_number_posts = isset($forum['number_of_posts']) ? $forum['number_of_posts'] : '';
echo "<td>".$my_number_threads."</td>"; echo '<td>'.$my_number_threads.'</td>';
echo "<td>".$my_number_posts."</td>"; echo '<td>'.$my_number_posts.'</td>';
// the last post in the forum // the last post in the forum
if ($forum['last_poster_name']<>'') { if ($forum['last_poster_name'] != '') {
$name=$forum['last_poster_name']; $name = $forum['last_poster_name'];
$poster_id=0; $poster_id = 0;
} else { } else {
$name=api_get_person_name($forum['last_poster_firstname'], $forum['last_poster_lastname']); $name = api_get_person_name($forum['last_poster_firstname'], $forum['last_poster_lastname']);
$poster_id=$forum['last_poster_id']; $poster_id = $forum['last_poster_id'];
} }
echo "<td>"; echo '<td>';
if (!empty($forum['last_post_id'])) { if (!empty($forum['last_post_id'])) {
echo $forum['last_post_date']." ".get_lang('By').' '.display_user_link($poster_id, $name); echo $forum['last_post_date'].' '.get_lang('By').' '.display_user_link($poster_id, $name);
} }
echo "</td>"; echo '</td>';
echo "<td NOWRAP align='center'>"; echo '<td nowrap align="center">';
if (api_is_allowed_to_edit(false,true) && !($forum['session_id']==0 && intval(isset($_SESSION['id_session'])?$_SESSION['id_session']:null)!=0)) { if (api_is_allowed_to_edit(false, true) && !($forum['session_id'] == 0 && intval(isset($_SESSION['id_session']) ? $_SESSION['id_session'] : null) != 0)) {
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&amp;forumcategory=".Security::remove_XSS($_GET['forumcategory'])."&amp;action=edit&amp;content=forum&amp;id=".$forum['forum_id']."\">".Display::return_icon('edit.png',get_lang('Edit'), array(), 22)."</a>"; echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forumcategory='.Security::remove_XSS($_GET['forumcategory']).'&amp;action=edit&amp;content=forum&amp;id='.$forum['forum_id'].'">'.Display::return_icon('edit.png', get_lang('Edit'), array(), 22).'</a>';
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&amp;forumcategory=".Security::remove_XSS($_GET['forumcategory'])."&amp;action=delete&amp;content=forum&amp;id=".$forum['forum_id']."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('DeleteForum'), ENT_QUOTES))."')) return false;\">".Display::return_icon('delete.png',get_lang('Delete'), array(), 22)."</a>"; echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forumcategory='.Security::remove_XSS($_GET['forumcategory']).'&amp;action=delete&amp;content=forum&amp;id='.$forum['forum_id']."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('DeleteForum'), ENT_QUOTES))."')) return false;\">".Display::return_icon('delete.png', get_lang('Delete'), array(), 22).'</a>';
display_visible_invisible_icon('forum',$forum['forum_id'], $forum['visibility'], array("forumcategory"=>$_GET['forumcategory'])); display_visible_invisible_icon('forum', $forum['forum_id'], $forum['visibility'], array('forumcategory' => $_GET['forumcategory']));
display_lock_unlock_icon('forum',$forum['forum_id'], $forum['locked'], array("forumcategory"=>$_GET['forumcategory'])); display_lock_unlock_icon('forum', $forum['forum_id'], $forum['locked'], array('forumcategory' => $_GET['forumcategory']));
display_up_down_icon('forum',$forum['forum_id'], $forums_in_category); display_up_down_icon('forum', $forum['forum_id'], $forums_in_category);
} }
$iconnotify = 'send_mail.gif'; $iconnotify = 'send_mail.gif';
if (is_array(isset($_SESSION['forum_notification']['forum'])?$_SESSION['forum_notification']['forum']:null)) { if (is_array(isset($_SESSION['forum_notification']['forum']) ? $_SESSION['forum_notification']['forum'] : null)) {
if (in_array($forum['forum_id'],$_SESSION['forum_notification']['forum'])) { if (in_array($forum['forum_id'],$_SESSION['forum_notification']['forum'])) {
$iconnotify = 'send_mail_checked.gif'; $iconnotify = 'send_mail_checked.gif';
} }
} }
if (!api_is_anonymous()) { if (!api_is_anonymous()) {
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&amp;forumcategory=".Security::remove_XSS($_GET['forumcategory'])."&amp;action=notify&amp;content=forum&amp;id=".$forum['forum_id']."\">".Display::return_icon($iconnotify,get_lang('NotifyMe'))."</a>"; echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forumcategory='.Security::remove_XSS($_GET['forumcategory']).'&amp;action=notify&amp;content=forum&amp;id='.$forum['forum_id'].'">'.Display::return_icon($iconnotify, get_lang('NotifyMe')).'</a>';
} }
echo "</td>"; echo '</td></tr>';
echo "</tr>";
} }
} }
} }
if (count($forum_list) == 0) { if (count($forum_list) == 0) {
echo "<tr><td>".get_lang('NoForumInThisCategory')."</td></tr>"; echo '<tr><td>'.get_lang('NoForumInThisCategory').'</td></tr>';
} }
echo "</table>"; echo '</table>';
} }
/* FOOTER */ /* FOOTER */
if ($origin!='learnpath') {
if ($origin != 'learnpath') {
Display :: display_footer(); Display :: display_footer();
} }

@ -3,23 +3,26 @@
/** /**
* @package chamilo.forum * @package chamilo.forum
*/ */
// name of the language file that needs to be included // Language file that needs to be included.
$language_file = 'forum'; $language_file = 'forum';
// including the global dokeos file
// Including the global initialization file.
require '../inc/global.inc.php'; require '../inc/global.inc.php';
// the section (tabs)
$this_section=SECTION_COURSES;
// notice for unauthorized people. // The section (tabs).
$this_section = SECTION_COURSES;
// Notification for unauthorized people.
api_protect_course_script(true); api_protect_course_script(true);
// including additional library scripts // Including additional library scripts.
require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'); require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php'); include_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
//require_once (api_get_path(LIBRARY_PATH).'resourcelinker.lib.php'); //require_once api_get_path(LIBRARY_PATH).'resourcelinker.lib.php';
$nameTools=get_lang('ToolForum');
$nameTools = get_lang('ToolForum');
/* Including necessary files */ // Including necessary files.
require 'forumconfig.inc.php'; require 'forumconfig.inc.php';
require_once 'forumfunction.inc.php'; require_once 'forumfunction.inc.php';
@ -39,33 +42,33 @@ if (isset($_GET['origin'])) {
/* Retrieving forum and forum categorie information */ /* Retrieving forum and forum categorie information */
// we are getting all the information about the current forum and forum category. // We are getting all the information about the current forum and forum category.
// note pcool: I tried to use only one sql statement (and function) for this // Note pcool: I tried to use only one sql statement (and function) for this,
// but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table.
$current_thread=get_thread_information($_GET['thread']); // note: this has to be validated that it is an existing thread $current_thread = get_thread_information($_GET['thread']); // Note: This has to be validated that it is an existing thread.
$current_forum=get_forum_information($current_thread['forum_id']); // note: this has to be validated that it is an existing forum. $current_forum = get_forum_information($current_thread['forum_id']); // Note: This has to be validated that it is an existing forum.
$current_forum_category=get_forumcategory_information($current_forum['forum_category']); $current_forum_category = get_forumcategory_information($current_forum['forum_category']);
$whatsnew_post_info=$_SESSION['whatsnew_post_info']; $whatsnew_post_info = $_SESSION['whatsnew_post_info'];
/* Header and Breadcrumbs */ /* Header and Breadcrumbs */
if (isset($_SESSION['gradebook'])){ if (isset($_SESSION['gradebook'])){
$gradebook= $_SESSION['gradebook']; $gradebook = $_SESSION['gradebook'];
} }
if (!empty($gradebook) && $gradebook=='view') { if (!empty($gradebook) && $gradebook == 'view') {
$interbreadcrumb[]= array ( $interbreadcrumb[] = array (
'url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
'name' => get_lang('ToolGradebook') 'name' => get_lang('ToolGradebook')
); );
} }
if ($origin=='learnpath') { if ($origin == 'learnpath') {
include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php'); include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php');
} else { } else {
$interbreadcrumb[]=array("url" => "index.php?gradebook=$gradebook&amp;search=".Security::remove_XSS(urlencode($_GET['search'])),"name" => $nameTools); $interbreadcrumb[] = array('url' => 'index.php?gradebook='.$gradebook.'&amp;search='.Security::remove_XSS(urlencode($_GET['search'])), 'name' => $nameTools);
$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&amp;search=".Security::remove_XSS(urlencode($_GET['search'])),"name" => prepare4display($current_forum_category['cat_title'])); $interbreadcrumb[] = array('url' => 'viewforumcategory.php?forumcategory='.$current_forum_category['cat_id'].'&amp;search='.Security::remove_XSS(urlencode($_GET['search'])), 'name' => prepare4display($current_forum_category['cat_title']));
$interbreadcrumb[]=array("url" => "viewforum.php?forum=".Security::remove_XSS($_GET['forum'])."&amp;origin=".$origin."&amp;search=".Security::remove_XSS(urlencode($_GET['search'])),"name" => prepare4display($current_forum['forum_title'])); $interbreadcrumb[] = array('url' => 'viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;origin='.$origin.'&amp;search='.Security::remove_XSS(urlencode($_GET['search'])), 'name' => prepare4display($current_forum['forum_title']));
// the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string // the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string
Display :: display_header(''); Display :: display_header('');
@ -76,7 +79,7 @@ if ($origin=='learnpath') {
// if the user is not a course administrator and the forum is hidden // if the user is not a course administrator and the forum is hidden
// then the user is not allowed here. // then the user is not allowed here.
if (!api_is_allowed_to_edit(false,true) AND ($current_forum['visibility']==0 OR $current_thread['visibility']==0)) { if (!api_is_allowed_to_edit(false, true) AND ($current_forum['visibility'] == 0 OR $current_thread['visibility'] == 0)) {
$forum_allow = forum_not_allowed_here(); $forum_allow = forum_not_allowed_here();
if ($forum_allow === false) { if ($forum_allow === false) {
exit; exit;
@ -85,14 +88,14 @@ if (!api_is_allowed_to_edit(false,true) AND ($current_forum['visibility']==0 OR
/* Actions */ /* Actions */
if ($_GET['action']=='delete' && isset($_GET['content']) && isset($_GET['id']) && api_is_allowed_to_edit(false,true)) { if ($_GET['action'] == 'delete' && isset($_GET['content']) && isset($_GET['id']) && api_is_allowed_to_edit(false, true)) {
$message=delete_post($_GET['id']); // note: this has to be cleaned first $message = delete_post($_GET['id']); // Note: This has to be cleaned first.
} }
if (($_GET['action']=='invisible' || $_GET['action']=='visible') && isset($_GET['id']) && api_is_allowed_to_edit(false,true)) { if (($_GET['action'] == 'invisible' || $_GET['action'] == 'visible') && isset($_GET['id']) && api_is_allowed_to_edit(false, true)) {
$message=approve_post($_GET['id'],$_GET['action']); // note: this has to be cleaned first $message = approve_post($_GET['id'], $_GET['action']); // Note: This has to be cleaned first.
} }
if ($_GET['action']=='move' and isset($_GET['post'])) { if ($_GET['action'] == 'move' && isset($_GET['post'])) {
$message=move_post_form(); $message = move_post_form();
} }
/* Display the action messages */ /* Display the action messages */
@ -101,8 +104,8 @@ if (!empty($message)) {
Display :: display_confirmation_message(get_lang($message)); Display :: display_confirmation_message(get_lang($message));
} }
if ($message <> 'PostDeletedSpecial') { // in this case the first and only post of the thread is removed if ($message != 'PostDeletedSpecial') { // In this case the first and only post of the thread is removed.
// this increases the number of times the thread has been viewed // This increases the number of times the thread has been viewed.
increase_thread_view($_GET['thread']); increase_thread_view($_GET['thread']);
/* Action Links */ /* Action Links */
@ -116,14 +119,14 @@ if ($message <> 'PostDeletedSpecial') { // in this case the first and only post
echo '</div>'; 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. // 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. // If one of the three levels is locked then the link should not be displayed.
if ($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0 OR api_is_allowed_to_edit(false,true)) { if ($current_forum_category['locked'] == 0 AND $current_forum['locked'] == 0 AND $current_thread['locked'] == 0 OR api_is_allowed_to_edit(false, true)) {
// The link should only appear when the user is logged in or when anonymous posts are allowed. // 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'])) { if ($_user['user_id'] OR ($current_forum['allow_anonymous'] == 1 AND !$_user['user_id'])) {
//reply link // reply link
echo '<a href="reply.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;action=replythread&amp;origin='.$origin.'">'.get_lang('ReplyToThread').'</a>'; echo '<a href="reply.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;action=replythread&amp;origin='.$origin.'">'.get_lang('ReplyToThread').'</a>';
//new thread link // new thread link
if (api_is_allowed_to_edit(false,true) 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)) { if (api_is_allowed_to_edit(false, true) 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)) {
if ($current_forum['locked'] <> 1 AND $current_forum['locked'] <> 1) { if ($current_forum['locked'] <> 1 AND $current_forum['locked'] <> 1) {
echo '&nbsp;&nbsp;'; echo '&nbsp;&nbsp;';
/*echo '<a href="newthread.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($_GET['forum']).$origin_string.'">'.Display::return_icon('new_thread.png','','','32').'</a>';*/ /*echo '<a href="newthread.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($_GET['forum']).$origin_string.'">'.Display::return_icon('new_thread.png','','','32').'</a>';*/
@ -139,15 +142,15 @@ if ($message <> 'PostDeletedSpecial') { // in this case the first and only post
/* Display Forum Category and the Forum information */ /* Display Forum Category and the Forum information */
if (!$_SESSION['view']) { if (!$_SESSION['view']) {
$viewmode=$current_forum['default_view']; $viewmode = $current_forum['default_view'];
} else { } else {
$viewmode=$_SESSION['view']; $viewmode = $_SESSION['view'];
} }
$viewmode_whitelist=array('flat', 'threaded', 'nested'); $viewmode_whitelist=array('flat', 'threaded', 'nested');
if (isset($_GET['view']) and in_array($_GET['view'],$viewmode_whitelist)) { if (isset($_GET['view']) && in_array($_GET['view'], $viewmode_whitelist)) {
$viewmode=Database::escape_string($_GET['view']); $viewmode = Database::escape_string($_GET['view']);
$_SESSION['view']=$viewmode; $_SESSION['view'] = $viewmode;
} }
if (empty($viewmode)) { if (empty($viewmode)) {
$viewmode = 'flat'; $viewmode = 'flat';
@ -175,9 +178,10 @@ if ($message <> 'PostDeletedSpecial') { // in this case the first and only post
echo "</table>"; echo "</table>";
include_once('viewpost.inc.php'); include_once('viewpost.inc.php');
} // if ($message<>'PostDeletedSpecial') // in this case the first and only post of the thread is removed } // if ($message != 'PostDeletedSpecial') // In this case the first and only post of the thread is removed.
/* FOOTER */ /* FOOTER */
if ($origin!='learnpath') {
if ($origin != 'learnpath') {
Display :: display_footer(); Display :: display_footer();
} }

@ -1,32 +1,33 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* @author Julio Montoya <gugli100@gmail.com> UI Improvements + lots of bugfixes * @author Julio Montoya <gugli100@gmail.com> UI Improvements + lots of bugfixes
* @package chamilo.forum * @package chamilo.forum
*/ */
// name of the language file that needs to be included
$language_file = array ('forum','group');
// including the global dokeos file // Language file that needs to be included.
$language_file = array ('forum', 'group');
// Including the global initialization file.
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
// the section (tabs) // The section (tabs.)
$this_section=SECTION_COURSES; $this_section = SECTION_COURSES;
// notice for unauthorized people. // Notification for unauthorized people.
api_protect_course_script(true); api_protect_course_script(true);
// including additional library scripts // Including additional library scripts.
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php'; require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
require_once 'forumconfig.inc.php'; require_once 'forumconfig.inc.php';
require_once 'forumfunction.inc.php'; require_once 'forumfunction.inc.php';
$nameTools = get_lang('ToolForum');
$nameTools=get_lang('ToolForum'); // Are we in a lp ?
//are we in a lp ?
$origin = ''; $origin = '';
if (isset($_GET['origin'])) { if (isset($_GET['origin'])) {
$origin = Security::remove_XSS($_GET['origin']); $origin = Security::remove_XSS($_GET['origin']);
@ -39,47 +40,47 @@ if (isset($_GET['origin'])) {
// We are getting all the information about the current forum and forum category. // We are getting all the information about the current forum and forum category.
// Note pcool: I tried to use only one sql statement (and function) for this, // Note pcool: I tried to use only one sql statement (and function) for this,
// but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table. // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table.
$current_thread = get_thread_information($_GET['thread']); // note: this has to be validated that it is an existing thread $current_thread = get_thread_information($_GET['thread']); // Nnote: This has to be validated that it is an existing thread
$current_forum = get_forum_information($current_thread['forum_id']); // note: this has to be validated that it is an existing forum. $current_forum = get_forum_information($current_thread['forum_id']); // Note: This has to be validated that it is an existing forum.
$current_forum_category = get_forumcategory_information($current_forum['forum_category']); $current_forum_category = get_forumcategory_information($current_forum['forum_category']);
$whatsnew_post_info = $_SESSION['whatsnew_post_info']; //this variable should be deprecated? $whatsnew_post_info = $_SESSION['whatsnew_post_info']; // This variable should be deprecated?
/* Header and Breadcrumbs */ /* Header and Breadcrumbs */
if (!empty($_GET['gradebook']) && $_GET['gradebook']=='view' ) { if (!empty($_GET['gradebook']) && $_GET['gradebook'] == 'view') {
$_SESSION['gradebook']=Security::remove_XSS($_GET['gradebook']); $_SESSION['gradebook'] = Security::remove_XSS($_GET['gradebook']);
$gradebook= $_SESSION['gradebook']; $gradebook = $_SESSION['gradebook'];
} }
if (!empty($gradebook) && $gradebook=='view') { if (!empty($gradebook) && $gradebook == 'view') {
$interbreadcrumb[] = array ( $interbreadcrumb[] = array (
'url' => '../gradebook/' . $_SESSION['gradebook_dest'], 'url' => '../gradebook/' . $_SESSION['gradebook_dest'],
'name' => get_lang('ToolGradebook') 'name' => get_lang('ToolGradebook')
); );
} }
if ($origin=='group') { if ($origin == 'group') {
$session_toolgroup = intval($_SESSION['toolgroup']); $session_toolgroup = intval($_SESSION['toolgroup']);
$group_properties = GroupManager :: get_group_properties($session_toolgroup); $group_properties = GroupManager :: get_group_properties($session_toolgroup);
$interbreadcrumb[] = array("url"=>"../group/group.php", "name" => get_lang('Groups')); $interbreadcrumb[] = array('url'=>'../group/group.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array("url"=>"../group/group_space.php?gidReq=".$session_toolgroup, "name"=> get_lang('GroupSpace').' '.$group_properties['name']); $interbreadcrumb[] = array('url'=>'../group/group_space.php?gidReq='.$session_toolgroup, 'name'=> get_lang('GroupSpace').' '.$group_properties['name']);
$interbreadcrumb[] = array("url"=>"viewforum.php?forum=".Security::remove_XSS($_GET['forum'])."&amp;gidReq=".$session_toolgroup."&amp;origin=".$origin."&amp;search=".Security::remove_XSS(urlencode($my_search)),"name" => Security::remove_XSS($current_forum['forum_title'])); $interbreadcrumb[] = array('url'=>'viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gidReq='.$session_toolgroup.'&amp;origin='.$origin.'&amp;search='.Security::remove_XSS(urlencode($my_search)), 'name' => Security::remove_XSS($current_forum['forum_title']));
$interbreadcrumb[] = array("url"=>"viewthread.php?forum=".Security::remove_XSS($_GET['forum'])."&amp;gradebook=".$gradebook."&amp;thread=".Security::remove_XSS($_GET['thread']),"name" => Security::remove_XSS($current_thread['thread_title'])); $interbreadcrumb[] = array('url'=>'viewthread.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gradebook='.$gradebook.'&amp;thread='.Security::remove_XSS($_GET['thread']), 'name' => Security::remove_XSS($current_thread['thread_title']));
Display :: display_header(''); Display :: display_header('');
//api_display_tool_title($nameTools); //api_display_tool_title($nameTools);
} else { } else {
$my_search=isset($_GET['search']) ? $_GET['search'] : ''; $my_search = isset($_GET['search']) ? $_GET['search'] : '';
if ($origin=='learnpath') { if ($origin == 'learnpath') {
require_once api_get_path(INCLUDE_PATH).'reduced_header.inc.php'; require_once api_get_path(INCLUDE_PATH).'reduced_header.inc.php';
} else { } else {
$interbreadcrumb[]=array("url" => "index.php?gradebook=$gradebook&amp;search=".Security::remove_XSS(urlencode($my_search)),"name" => $nameTools); $interbreadcrumb[] = array('url' => 'index.php?gradebook='.$gradebook.'&amp;search='.Security::remove_XSS(urlencode($my_search)), 'name' => $nameTools);
$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&amp;origin=".$origin."&amp;search=".Security::remove_XSS(urlencode($my_search)),"name" => Security::remove_XSS($current_forum_category['cat_title'])); $interbreadcrumb[] = array('url' => 'viewforumcategory.php?forumcategory='.$current_forum_category['cat_id'].'&amp;origin='.$origin.'&amp;search='.Security::remove_XSS(urlencode($my_search)), 'name' => Security::remove_XSS($current_forum_category['cat_title']));
$interbreadcrumb[]=array("url" => "viewforum.php?forum=".Security::remove_XSS($_GET['forum'])."&amp;origin=".$origin."&amp;search=".Security::remove_XSS(urlencode($my_search)),"name" => Security::remove_XSS($current_forum['forum_title'])); $interbreadcrumb[] = array('url' => 'viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;origin='.$origin.'&amp;search='.Security::remove_XSS(urlencode($my_search)), 'name' => Security::remove_XSS($current_forum['forum_title']));
$message = isset($message) ? $message : ''; $message = isset($message) ? $message : '';
// the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string // the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string
Display :: display_header(''); Display :: display_header('');
@ -89,9 +90,9 @@ if ($origin=='group') {
/* Is the user allowed here? */ /* Is the user allowed here? */
// if the user is not a course administrator and the forum is hidden // If the user is not a course administrator and the forum is hidden
// then the user is not allowed here. // then the user is not allowed here.
if (!api_is_allowed_to_edit(false,true) AND ($current_forum['visibility']==0 OR $current_thread['visibility']==0)) { if (!api_is_allowed_to_edit(false, true) AND ($current_forum['visibility'] == 0 OR $current_thread['visibility'] == 0)) {
$forum_allow = forum_not_allowed_here(); $forum_allow = forum_not_allowed_here();
if ($forum_allow === false) { if ($forum_allow === false) {
exit; exit;
@ -101,14 +102,14 @@ if (!api_is_allowed_to_edit(false,true) AND ($current_forum['visibility']==0 OR
/* Actions */ /* Actions */
$my_action = isset($_GET['action']) ? $_GET['action'] : ''; $my_action = isset($_GET['action']) ? $_GET['action'] : '';
if ($my_action=='delete' AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit(false,true)) { if ($my_action == 'delete' AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit(false, true)) {
$message=delete_post($_GET['id']); // note: this has to be cleaned first $message = delete_post($_GET['id']); // Note: This has to be cleaned first.
} }
if (($my_action=='invisible' OR $my_action=='visible') AND isset($_GET['id']) AND api_is_allowed_to_edit(false,true)) { if (($my_action == 'invisible' OR $my_action == 'visible') AND isset($_GET['id']) AND api_is_allowed_to_edit(false, true)) {
$message=approve_post($_GET['id'],$_GET['action']); // note: this has to be cleaned first $message = approve_post($_GET['id'], $_GET['action']); // Note: This has to be cleaned first.
} }
if ($my_action=='move' AND isset($_GET['post'])) { if ($my_action == 'move' AND isset($_GET['post'])) {
$message=move_post_form(); $message = move_post_form();
} }
/* Display the action messages */ /* Display the action messages */
@ -118,48 +119,47 @@ if ($my_message) {
Display :: display_confirmation_message(get_lang($my_message)); Display :: display_confirmation_message(get_lang($my_message));
} }
if ($my_message <> 'PostDeletedSpecial') { if ($my_message != 'PostDeletedSpecial') {
// in this case the first and only post of the thread is removed // in this case the first and only post of the thread is removed
// this increases the number of times the thread has been viewed // this increases the number of times the thread has been viewed
increase_thread_view($_GET['thread']); increase_thread_view($_GET['thread']);
/* Action Links */ /* Action Links */
if ($origin=='learnpath') { if ($origin == 'learnpath') {
echo '<div style="height:15px">&nbsp;</div>'; echo '<div style="height:15px">&nbsp;</div>';
} }
echo '<div class="actions">'; echo '<div class="actions">';
echo '<span style="float:right;">'.search_link().'</span>'; echo '<span style="float:right;">'.search_link().'</span>';
if ($origin != 'learnpath') { if ($origin != 'learnpath') {
if ($origin=='group') { if ($origin == 'group') {
echo '<a href="../group/group_space.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;gradebook='.$gradebook.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('Groups'),'','32').'</a>'; echo '<a href="../group/group_space.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;gradebook='.$gradebook.'">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('Groups'), '', '32').'</a>';
echo '<a href="viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gidReq='.$session_toolgroup.'&amp;origin='.$origin.'">'.Display::return_icon('forum.png',get_lang('BackToForum'),'','32').'</a>'; echo '<a href="viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gidReq='.$session_toolgroup.'&amp;origin='.$origin.'">'.Display::return_icon('forum.png', get_lang('BackToForum'), '', '32').'</a>';
} } else {
else{ echo '<a href="index.php?gradebook='.$gradebook.'">'.Display::return_icon('back.png', get_lang('BackToForumOverview'), '', '32').'</a>';
echo '<a href="index.php?gradebook='.$gradebook.'">'.Display::return_icon('back.png',get_lang('BackToForumOverview'),'','32').'</a>'; echo '<a href="viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gidReq='.$session_toolgroup.'">'.Display::return_icon('forum.png', get_lang('BackToForum'), '', '32').'</a>';
echo '<a href="viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gidReq='.$session_toolgroup.'">'.Display::return_icon('forum.png',get_lang('BackToForum'),'','32').'</a>';
} }
} }
// 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. // 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. // If one of the three levels is locked then the link should not be displayed.
if ($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0 OR api_is_allowed_to_edit(false,true)) { if ($current_forum_category['locked'] == 0 AND $current_forum['locked'] == 0 AND $current_thread['locked'] == 0 OR api_is_allowed_to_edit(false, true)) {
// The link should only appear when the user is logged in or when anonymous posts are allowed. // 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'])) { if ($_user['user_id'] OR ($current_forum['allow_anonymous'] == 1 AND !$_user['user_id'])) {
//reply link // reply link
if (!api_is_anonymous() && api_is_allowed_to_session_edit(false,true)) { if (!api_is_anonymous() && api_is_allowed_to_session_edit(false, true)) {
echo '<a href="reply.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;action=replythread&amp;origin='.$origin.'">'.Display::return_icon('reply_thread.png',get_lang('ReplyToThread'),'','32').'</a>'; echo '<a href="reply.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;action=replythread&amp;origin='.$origin.'">'.Display::return_icon('reply_thread.png', get_lang('ReplyToThread'), '', '32').'</a>';
} }
//new thread link // new thread link
if ((api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])) 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)) { if ((api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $_SESSION['id_session'])) 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)) {
if ($current_forum['locked'] <> 1 AND $current_forum['locked'] <> 1) { if ($current_forum['locked'] <> 1 AND $current_forum['locked'] <> 1) {
echo '&nbsp;&nbsp;'; echo '&nbsp;&nbsp;';
/* if ( isset($_GET['gradebook']) && $_GET['gradebook']!=""){ /* if ( isset($_GET['gradebook']) && $_GET['gradebook'] != '') {
$info_thread=get_thread_information($_GET['thread']); $info_thread = get_thread_information($_GET['thread']);
echo '<a href="newthread.php?'.api_get_cidreq().'&amp;forum='.$info_thread['forum_id'].'&amp;origin='.$origin.'&amp;gradebook='.Security::remove_XSS($_GET['gradebook']).'">'.Display::return_icon('new_thread.png', get_lang('NewTopic'),'','32').'</a>'; echo '<a href="newthread.php?'.api_get_cidreq().'&amp;forum='.$info_thread['forum_id'].'&amp;origin='.$origin.'&amp;gradebook='.Security::remove_XSS($_GET['gradebook']).'">'.Display::return_icon('new_thread.png', get_lang('NewTopic'), '', '32').'</a>';
} else { } else {
echo '<a href="newthread.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($_GET['forum']).'&amp;origin='.$origin.'">'.Display::return_icon('new_thread.png', get_lang('NewTopic'),'','32').'</a>'; echo '<a href="newthread.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($_GET['forum']).'&amp;origin='.$origin.'">'.Display::return_icon('new_thread.png', get_lang('NewTopic'), '', '32').'</a>';
} */ } */
} else { } else {
echo get_lang('ForumLocked'); echo get_lang('ForumLocked');
@ -168,12 +168,12 @@ if ($my_message <> 'PostDeletedSpecial') {
} }
} }
// the different views of the thread // The different views of the thread.
if ($origin != 'learnpath') { if ($origin != 'learnpath') {
$my_url = '<a href="viewthread.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;forum='.Security::remove_XSS($_GET['forum']).'&amp;origin='.$origin.'&amp;gradebook='.$gradebook.'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;search='.Security::remove_XSS(urlencode($my_search)); $my_url = '<a href="viewthread.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;forum='.Security::remove_XSS($_GET['forum']).'&amp;origin='.$origin.'&amp;gradebook='.$gradebook.'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;search='.Security::remove_XSS(urlencode($my_search));
echo $my_url.'&amp;view=flat&amp;origin='.$origin.'&amp;gradebook='.$gradebook.'">'.Display::return_icon('forum_listview.gif',get_lang('FlatView')).get_lang('FlatView').'</a>'; echo $my_url.'&amp;view=flat&amp;origin='.$origin.'&amp;gradebook='.$gradebook.'">'.Display::return_icon('forum_listview.gif', get_lang('FlatView')).get_lang('FlatView').'</a>';
echo $my_url.'&amp;view=threaded&amp;origin='.$origin.'&amp;gradebook='.$gradebook.'">'.Display::return_icon('forum_threadedview.gif',get_lang('ThreadedView')).get_lang('ThreadedView').'</a>'; echo $my_url.'&amp;view=threaded&amp;origin='.$origin.'&amp;gradebook='.$gradebook.'">'.Display::return_icon('forum_threadedview.gif', get_lang('ThreadedView')).get_lang('ThreadedView').'</a>';
echo $my_url.'&amp;view=nested&amp;origin='.$origin.'&amp;gradebook='.$gradebook.'">'.Display::return_icon('forum_nestedview.gif',get_lang('NestedView')).get_lang('NestedView').'</a>'; echo $my_url.'&amp;view=nested&amp;origin='.$origin.'&amp;gradebook='.$gradebook.'">'.Display::return_icon('forum_nestedview.gif', get_lang('NestedView')).get_lang('NestedView').'</a>';
} }
$my_url = null; $my_url = null;
@ -182,17 +182,17 @@ if ($my_message <> 'PostDeletedSpecial') {
/* Display Forum Category and the Forum information */ /* Display Forum Category and the Forum information */
if (!isset($_SESSION['view'])) { if (!isset($_SESSION['view'])) {
$viewmode=$current_forum['default_view']; $viewmode = $current_forum['default_view'];
} else { } else {
$viewmode=$_SESSION['view']; $viewmode = $_SESSION['view'];
} }
$viewmode_whitelist=array('flat', 'threaded', 'nested'); $viewmode_whitelist = array('flat', 'threaded', 'nested');
if (isset($_GET['view']) and in_array($_GET['view'],$viewmode_whitelist)) { if (isset($_GET['view']) && in_array($_GET['view'], $viewmode_whitelist)) {
$viewmode=$_GET['view']; $viewmode = $_GET['view'];
$_SESSION['view']=$viewmode; $_SESSION['view'] = $viewmode;
} }
if(empty($viewmode)) { if (empty($viewmode)) {
$viewmode = 'flat'; $viewmode = 'flat';
} }
@ -202,10 +202,10 @@ if ($my_message <> 'PostDeletedSpecial') {
// Note pcool: I tried to use only one sql statement (and function) for this, // Note pcool: I tried to use only one sql statement (and function) for this,
// but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table. // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table.
echo "<table class=\"forum_table_title\" width='100%'>"; echo '<table class="forum_table_title" width="100%">';
// the thread // The thread
echo "<tr><th style=\"padding:5px;\" align=\"left\" colspan=\"6\">"; echo '<tr><th style="padding:5px;" align="left" colspan="6">';
echo '<div class="forum_title">'; echo '<div class="forum_title">';
echo '<a href="viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gidReq='.$session_toolgroup.'&amp;origin='.$origin.'">'.$current_forum['forum_title'].'</a><br />'; echo '<a href="viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gidReq='.$session_toolgroup.'&amp;origin='.$origin.'">'.$current_forum['forum_title'].'</a><br />';
echo '<span class="forum_description">'; echo '<span class="forum_description">';
@ -214,13 +214,12 @@ if ($my_message <> 'PostDeletedSpecial') {
echo '</div>'; echo '</div>';
if ($origin!='learnpath') { if ($origin != 'learnpath') {
//echo '<span class="forum_low_description">'.prepare4display($current_forum_category['cat_title']).' '; //echo '<span class="forum_low_description">'.prepare4display($current_forum_category['cat_title']).' ';
} }
echo "</th>"; echo '</th></tr>';
echo "</tr>"; echo '</table>';
echo "</table>";
switch ($viewmode) { switch ($viewmode) {
case 'flat': case 'flat':
@ -236,9 +235,10 @@ if ($my_message <> 'PostDeletedSpecial') {
include_once('viewthread_flat.inc.php'); include_once('viewthread_flat.inc.php');
break; break;
} }
} // if ($message<>'PostDeletedSpecial') // in this case the first and only post of the thread is removed } // if ($message != 'PostDeletedSpecial') // in this case the first and only post of the thread is removed.
/* FOOTER */ /* FOOTER */
if ($origin!='learnpath') {
if ($origin != 'learnpath') {
Display :: display_footer(); Display :: display_footer();
} }

@ -1,12 +1,14 @@
<?php <?php
/* For licensing terms, see /dokeos_license.txt */ /* For licensing terms, see /license.txt */
// including the global dokeos file // Including the global initialization file.
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
// Including additional libraries.
require_once(api_get_path(LIBRARY_PATH).'glossary.lib.php'); require_once(api_get_path(LIBRARY_PATH).'glossary.lib.php');
/* /*
* search a term and return description from a glossary * Search a term and return description from a glossary.
*/ */
global $charset; global $charset;
//replace image path //replace image path
@ -14,33 +16,33 @@ $path_image=api_get_path(WEB_COURSE_PATH).api_get_course_path();
$path_image_search='../../courses/'.api_get_course_path(); $path_image_search='../../courses/'.api_get_course_path();
if (isset($_POST['glossary_id']) && $_POST['glossary_id']==strval(intval($_POST['glossary_id']))) { if (isset($_POST['glossary_id']) && $_POST['glossary_id']==strval(intval($_POST['glossary_id']))) {
$glossary_id=Security::remove_XSS($_POST['glossary_id']); $glossary_id=Security::remove_XSS($_POST['glossary_id']);
$glossary_description_by_id=GlossaryManager::get_glossary_term_by_glossary_id($glossary_id); $glossary_description_by_id=GlossaryManager::get_glossary_term_by_glossary_id($glossary_id);
$glossary_description_by_id=str_replace($path_image_search,$path_image,$glossary_description_by_id); $glossary_description_by_id=str_replace($path_image_search,$path_image,$glossary_description_by_id);
echo api_xml_http_response_encode($glossary_description_by_id); echo api_xml_http_response_encode($glossary_description_by_id);
} elseif (isset($_POST['glossary_data']) && $_POST['glossary_data']=='true') { } elseif (isset($_POST['glossary_data']) && $_POST['glossary_data']=='true') {
//get_glossary_terms //get_glossary_terms
$glossary_data=GlossaryManager::get_glossary_terms(); $glossary_data=GlossaryManager::get_glossary_terms();
$glossary_all_data=array(); $glossary_all_data=array();
if (count($glossary_data)>0) { if (count($glossary_data)>0) {
foreach ($glossary_data as $glossary_index=>$glossary_value) { foreach ($glossary_data as $glossary_index=>$glossary_value) {
$glossary_all_data[]=$glossary_value['id'].'__|__|'.$glossary_value['name']; $glossary_all_data[]=$glossary_value['id'].'__|__|'.$glossary_value['name'];
} }
$glossary_all_data=implode('[|.|_|.|-|.|]',$glossary_all_data); $glossary_all_data=implode('[|.|_|.|-|.|]',$glossary_all_data);
echo api_xml_http_response_encode($glossary_all_data); echo api_xml_http_response_encode($glossary_all_data);
} }
} elseif(isset($_POST['glossary_name'])) { } elseif(isset($_POST['glossary_name'])) {
$my_glossary_name=Security::remove_XSS($_POST['glossary_name']); $my_glossary_name=Security::remove_XSS($_POST['glossary_name']);
$my_glossary_name=api_convert_encoding($my_glossary_name,$charset,'UTF-8'); $my_glossary_name=api_convert_encoding($my_glossary_name,$charset,'UTF-8');
$my_glossary_name=trim($my_glossary_name); $my_glossary_name=trim($my_glossary_name);
$glossary_description=GlossaryManager::get_glossary_term_by_glossary_name($my_glossary_name); $glossary_description=GlossaryManager::get_glossary_term_by_glossary_name($my_glossary_name);
$glossary_description=str_replace($path_image_search,$path_image,$glossary_description); $glossary_description=str_replace($path_image_search,$path_image,$glossary_description);
if (is_null($glossary_description) || strlen(trim($glossary_description))==0) { if (is_null($glossary_description) || strlen(trim($glossary_description))==0) {
echo api_xml_http_response_encode(get_lang('NoResults')); echo api_xml_http_response_encode(get_lang('NoResults'));
} else { } else {
echo api_xml_http_response_encode($glossary_description); echo api_xml_http_response_encode($glossary_description);
} }
} else { } else {
echo api_xml_http_response_encode(get_lang('NoResults')); echo api_xml_http_response_encode(get_lang('NoResults'));
} }

@ -6,24 +6,24 @@
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium, refactoring and tighter integration in Dokeos * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium, refactoring and tighter integration in Dokeos
*/ */
// name of the language file that needs to be included // The language file that needs to be included.
$language_file = array('glossary'); $language_file = array('glossary');
// including the global dokeos file // Including the global initialization file.
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php'; require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
require_once api_get_path(LIBRARY_PATH).'glossary.lib.php'; require_once api_get_path(LIBRARY_PATH).'glossary.lib.php';
// the section (tabs) // The section (tabs).
$this_section=SECTION_COURSES; $this_section = SECTION_COURSES;
// notice for unauthorized people. // Notification for unauthorized people.
api_protect_course_script(true); api_protect_course_script(true);
// including additional libraries // Including additional libraries.
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
// additional javascript // Additional javascripts.
$htmlHeadXtra[] = GlossaryManager::javascript_glossary(); $htmlHeadXtra[] = GlossaryManager::javascript_glossary();
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
$htmlHeadXtra[] = '<script type="text/javascript"> $htmlHeadXtra[] = '<script type="text/javascript">
@ -37,14 +37,14 @@ $(document).ready(function () {
// setting the tool constants // setting the tool constants
$tool = TOOL_GLOSSARY; $tool = TOOL_GLOSSARY;
// tracking // Tracking
event_access_tool(TOOL_GLOSSARY); event_access_tool(TOOL_GLOSSARY);
// displaying the header // Displaying the header
if (isset($_GET['action']) && ($_GET['action'] == 'addglossary' || $_GET['action'] == 'edit_glossary')) { if (isset($_GET['action']) && ($_GET['action'] == 'addglossary' || $_GET['action'] == 'edit_glossary')) {
$tool='GlossaryManagement'; $tool='GlossaryManagement';
$interbreadcrumb[] = array ("url"=>"index.php", "name"=> get_lang('ToolGlossary')); $interbreadcrumb[] = array ("url"=>"index.php", "name"=> get_lang('ToolGlossary'));
} }
Display::display_header(get_lang(ucfirst($tool))); Display::display_header(get_lang(ucfirst($tool)));
@ -52,90 +52,90 @@ Display::display_header(get_lang(ucfirst($tool)));
// Tool introduction // Tool introduction
Display::display_introduction_section(TOOL_GLOSSARY); Display::display_introduction_section(TOOL_GLOSSARY);
if ($_GET['action'] == 'changeview' AND in_array($_GET['view'],array('list','table'))) { if ($_GET['action'] == 'changeview' AND in_array($_GET['view'],array('list','table'))) {
$_SESSION['glossary_view'] = $_GET['view']; $_SESSION['glossary_view'] = $_GET['view'];
} else { } else {
if (!isset($_SESSION['glossary_view'])) { if (!isset($_SESSION['glossary_view'])) {
$_SESSION['glossary_view'] = 'table';//Default option $_SESSION['glossary_view'] = 'table';//Default option
} }
} }
if (api_is_allowed_to_edit(null,true)) { if (api_is_allowed_to_edit(null, true)) {
// Adding a glossary // Adding a glossary
if (isset($_GET['action']) && $_GET['action'] == 'addglossary') { if (isset($_GET['action']) && $_GET['action'] == 'addglossary') {
// initiate the object // initiate the object
$form = new FormValidator('glossary','post', api_get_self().'?action='.Security::remove_XSS($_GET['action'])); $form = new FormValidator('glossary','post', api_get_self().'?action='.Security::remove_XSS($_GET['action']));
// settting the form elements // settting the form elements
$form->addElement('header', '', get_lang('TermAddNew')); $form->addElement('header', '', get_lang('TermAddNew'));
$form->addElement('text', 'glossary_title', get_lang('TermName'), array('size'=>'95', 'id'=>'glossary_title')); $form->addElement('text', 'glossary_title', get_lang('TermName'), array('size'=>'95', 'id'=>'glossary_title'));
//$form->applyFilter('glossary_title', 'html_filter'); //$form->applyFilter('glossary_title', 'html_filter');
$form->addElement('html_editor', 'glossary_comment', get_lang('TermDefinition'), null, array('ToolbarSet' => 'Glossary', 'Width' => '100%', 'Height' => '300')); $form->addElement('html_editor', 'glossary_comment', get_lang('TermDefinition'), null, array('ToolbarSet' => 'Glossary', 'Width' => '100%', 'Height' => '300'));
$form->addElement('style_submit_button', 'SubmitGlossary', get_lang('TermAddButton'), 'class="save"'); $form->addElement('style_submit_button', 'SubmitGlossary', get_lang('TermAddButton'), 'class="save"');
// setting the rules // setting the rules
$form->addRule('glossary_title',get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('glossary_title',get_lang('ThisFieldIsRequired'), 'required');
// The validation or display // The validation or display
if ($form->validate()) { if ($form->validate()) {
$check = Security::check_token('post'); $check = Security::check_token('post');
if ($check) { if ($check) {
$values = $form->exportValues(); $values = $form->exportValues();
GlossaryManager::save_glossary($values); GlossaryManager::save_glossary($values);
} }
Security::clear_token(); Security::clear_token();
GlossaryManager::display_glossary(); GlossaryManager::display_glossary();
} else { } else {
$token = Security::get_token(); $token = Security::get_token();
$form->addElement('hidden','sec_token'); $form->addElement('hidden','sec_token');
$form->setConstants(array('sec_token' => $token)); $form->setConstants(array('sec_token' => $token));
$form->display(); $form->display();
} }
} else if (isset($_GET['action']) && $_GET['action'] == 'edit_glossary' && is_numeric($_GET['glossary_id'])) { // Editing a glossary } else if (isset($_GET['action']) && $_GET['action'] == 'edit_glossary' && is_numeric($_GET['glossary_id'])) { // Editing a glossary
// initiate the object // initiate the object
$form = new FormValidator('glossary','post', api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&glossary_id='.Security::remove_XSS($_GET['glossary_id'])); $form = new FormValidator('glossary','post', api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&glossary_id='.Security::remove_XSS($_GET['glossary_id']));
// settting the form elements // settting the form elements
$form->addElement('header', '', get_lang('TermEdit')); $form->addElement('header', '', get_lang('TermEdit'));
$form->addElement('hidden', 'glossary_id'); $form->addElement('hidden', 'glossary_id');
$form->addElement('text', 'glossary_title', get_lang('TermName'),array('size'=>'100')); $form->addElement('text', 'glossary_title', get_lang('TermName'),array('size'=>'100'));
//$form->applyFilter('glossary_title', 'html_filter'); //$form->applyFilter('glossary_title', 'html_filter');
$form->addElement('html_editor', 'glossary_comment', get_lang('TermDefinition'), null, array('ToolbarSet' => 'Glossary', 'Width' => '100%', 'Height' => '300')); $form->addElement('html_editor', 'glossary_comment', get_lang('TermDefinition'), null, array('ToolbarSet' => 'Glossary', 'Width' => '100%', 'Height' => '300'));
$form->addElement('style_submit_button', 'SubmitGlossary', get_lang('TermUpdateButton'), 'class="save"'); $form->addElement('style_submit_button', 'SubmitGlossary', get_lang('TermUpdateButton'), 'class="save"');
// setting the defaults // setting the defaults
$defaults = GlossaryManager::get_glossary_information(Security::remove_XSS($_GET['glossary_id'])); $defaults = GlossaryManager::get_glossary_information(Security::remove_XSS($_GET['glossary_id']));
$form->setDefaults($defaults); $form->setDefaults($defaults);
// setting the rules // setting the rules
$form->addRule('glossary_title', '<div class="required">'.get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('glossary_title', '<div class="required">'.get_lang('ThisFieldIsRequired'), 'required');
// The validation or display // The validation or display
if ($form->validate()) { if ($form->validate()) {
$check = Security::check_token('post'); $check = Security::check_token('post');
if ($check) { if ($check) {
$values = $form->exportValues(); $values = $form->exportValues();
GlossaryManager::update_glossary($values); GlossaryManager::update_glossary($values);
} }
Security::clear_token(); Security::clear_token();
GlossaryManager::display_glossary(); GlossaryManager::display_glossary();
} else { } else {
$token = Security::get_token(); $token = Security::get_token();
$form->addElement('hidden','sec_token'); $form->addElement('hidden', 'sec_token');
$form->setConstants(array('sec_token' => $token)); $form->setConstants(array('sec_token' => $token));
$form->display(); $form->display();
} }
} else if (isset($_GET['action']) && $_GET['action'] == 'delete_glossary' && is_numeric($_GET['glossary_id'])) {// deleting a glossary } else if (isset($_GET['action']) && $_GET['action'] == 'delete_glossary' && is_numeric($_GET['glossary_id'])) {// deleting a glossary
GlossaryManager::delete_glossary(Security::remove_XSS($_GET['glossary_id'])); GlossaryManager::delete_glossary(Security::remove_XSS($_GET['glossary_id']));
GlossaryManager::display_glossary(); GlossaryManager::display_glossary();
} else if (isset($_GET['action']) && $_GET['action'] == 'moveup' && is_numeric($_GET['glossary_id'])) { // moving a glossary term up } else if (isset($_GET['action']) && $_GET['action'] == 'moveup' && is_numeric($_GET['glossary_id'])) { // moving a glossary term up
GlossaryManager::move_glossary('up',$_GET['glossary_id']); GlossaryManager::move_glossary('up',$_GET['glossary_id']);
GlossaryManager::display_glossary(); GlossaryManager::display_glossary();
} else if (isset($_GET['action']) && $_GET['action'] == 'movedown' && is_numeric($_GET['glossary_id'])) {// moving a glossary term up } else if (isset($_GET['action']) && $_GET['action'] == 'movedown' && is_numeric($_GET['glossary_id'])) { // moving a glossary term down
GlossaryManager::move_glossary('down',$_GET['glossary_id']); GlossaryManager::move_glossary('down',$_GET['glossary_id']);
GlossaryManager::display_glossary(); GlossaryManager::display_glossary();
} else { } else {
GlossaryManager::display_glossary(); GlossaryManager::display_glossary();
} }
} else { } else {
GlossaryManager::display_glossary(); GlossaryManager::display_glossary();
} }
// footer
// Footer
Display::display_footer(); Display::display_footer();
Loading…
Cancel
Save