Task #1297 - Cosmetic cahnges and minor corrections.

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

@ -22,39 +22,37 @@
* @package chamilo.forum
*/
/*
INIT SECTION
*/
// name of the language file that needs to be included
$language_file = array ('forum','group');
/* INIT SECTION */
// 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 '../gradebook/lib/gradebook_functions.inc.php';
require_once '../gradebook/lib/be/gradebookitem.class.php';
require_once '../gradebook/lib/be/evaluation.class.php';
require_once '../gradebook/lib/be/abstractlink.class.php';
require_once '../gradebook/lib/gradebook_functions.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);
// 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).'groupmanager.lib.php';
$nameTools=get_lang('ToolForum');
$nameTools = get_lang('ToolForum');
/*
Including necessary files
*/
/* Including necessary files */
include 'forumconfig.inc.php';
include 'forumfunction.inc.php';
//
$origin = '';
if(isset($_GET['origin'])) {
if (isset($_GET['origin'])) {
$origin = Security::remove_XSS($_GET['origin']);
}
@ -73,129 +71,124 @@ $htmlHeadXtra[] = '<script>
}
</script>';
/*
MAIN DISPLAY SECTION
*/
/*
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
// 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_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_post=get_post_information($_GET['post']);
/*
Header and Breadcrumbs
*/
if (isset($_SESSION['gradebook'])){
$gradebook= $_SESSION['gradebook'];
/* MAIN DISPLAY SECTION */
/* 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,
// 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_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_post = get_post_information($_GET['post']);
/* Header and Breadcrumbs */
if (isset($_SESSION['gradebook'])) {
$gradebook = $_SESSION['gradebook'];
}
if (!empty($gradebook) && $gradebook=='view') {
$interbreadcrumb[]= array (
if (!empty($gradebook) && $gradebook == 'view') {
$interbreadcrumb[] = array (
'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
'name' => get_lang('ToolGradebook')
);
}
if ($origin=='group') {
$_clean['toolgroup']=(int)$_SESSION['toolgroup'];
$group_properties = GroupManager :: get_group_properties($_clean['toolgroup']);
$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" => "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'));
if ($origin == 'group') {
$_clean['toolgroup'] = (int)$_SESSION['toolgroup'];
$group_properties = GroupManager :: get_group_properties($_clean['toolgroup']);
$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' => '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'));
} else {
$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" => "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" => "javascript: void (0);","name" => get_lang('EditPost'));
$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' => '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' => 'javascript: void (0);', 'name' => get_lang('EditPost'));
}
/*
Resource Linker
*/
/* Resource Linker */
if (isset($_POST['add_resources']) AND $_POST['add_resources']==get_lang('Resources')) {
$_SESSION['formelements']=$_POST;
$_SESSION['origin']=$_SERVER['REQUEST_URI'];
$_SESSION['breadcrumbs']=$interbreadcrumb;
header("Location: ../resourcelinker/resourcelinker.php");
header('Location: ../resourcelinker/resourcelinker.php');
}
$table_link = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
/*
Header
*/
//are we in a lp ?
$table_link = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
/* Header */
// Are we in a lp ?
$origin = '';
if (isset($_GET['origin'])) {
$origin = Security::remove_XSS($_GET['origin']);
}
if ($origin=='learnpath') {
include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php');
if ($origin == 'learnpath') {
include api_get_path(INCLUDE_PATH).'reduced_header.inc.php';
} else {
Display :: display_header(null);
//api_display_tool_title($nameTools);
}
//echo '<link href="forumstyles.css" rel="stylesheet" type="text/css" />';
/*
Is the user allowed here?
*/
// the user is not allowed here if
/* Is the user allowed here? */
// The user is not allowed here if
// 1. the forumcategory, forum or thread is invisible (visibility==0)
// 2. the forumcategory, forum or thread is locked (locked <>0)
// 3. if anonymous posts are not allowed
// 4. if editing of replies is not allowed
// The only exception is the course manager
// 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(null,true) AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==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))) {
$forum_allow = forum_not_allowed_here();
if ($forum_allow === false) {
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();
if ($forum_allow === false) {
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();
if ($forum_allow === false) {
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();
if ($forum_allow === false) {
exit;
}
}
// action links
if ($origin!='learnpath') {
// Action links
if ($origin != 'learnpath') {
echo '<div class="actions">';
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>';
}
else{
} else {
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 '</div>';
}
/*
Display Forum Category and the Forum information
*/
/* Display Forum Category and the Forum information */
echo "<table class=\"forum_table\" width=\"100%\">\n";
// the forum category
// The forum category
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 '<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 '</table>';
// the form for the reply
$values=show_edit_post_form($current_post, $current_thread, $current_forum, isset($_SESSION['formelements'])?$_SESSION['formelements']:'');
// The form for the reply
$values = show_edit_post_form($current_post, $current_thread, $current_forum, isset($_SESSION['formelements']) ? $_SESSION['formelements'] : '');
if (!empty($values) and isset($_POST['SubmitPost'])) {
store_edit_post($values);
$option_chek=isset($values['thread_qualify_gradebook'])?$values['thread_qualify_gradebook']:null;// values 1 or 0
if ( 1== $option_chek ) {
$id=$values['thread_id'];
$title_gradebook=stripslashes($values['calification_notebook_title']);
$value_calification=$values['numeric_calification'];
$weight_calification=$values['weight_calification'];
$description='';
$session_id=api_get_session_id();
$link_id=is_resource_in_course_gradebook(api_get_course_id(),5,$id,$session_id);
$option_chek = isset($values['thread_qualify_gradebook']) ? $values['thread_qualify_gradebook'] : null; // values 1 or 0
if (1 == $option_chek) {
$id = $values['thread_id'];
$title_gradebook = stripslashes($values['calification_notebook_title']);
$value_calification = $values['numeric_calification'];
$weight_calification = $values['weight_calification'];
$description = '';
$session_id = api_get_session_id();
$link_id = is_resource_in_course_gradebook(api_get_course_id(), 5, $id,$session_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 {
Database::query('UPDATE '.$table_link.' SET weight='.$weight_calification.' WHERE id='.$link_id.'');
}
}
}
// footer
if ($origin!='learnpath') {
// Footer
if ($origin != 'learnpath') {
Display :: display_footer();
}
}

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

@ -22,20 +22,21 @@
* @package chamilo.forum
*/
// name of the language file that needs to be included
$language_file = array('forum','document');
// Language file that need to be included.
$language_file = array('forum', 'document');
// including the global dokeos file
// Including the global initialization file.
require_once '../inc/global.inc.php';
require_once '../gradebook/lib/gradebook_functions.inc.php';
// the section (tabs)
// The section (tabs).
$this_section=SECTION_COURSES;
// notice for unauthorized people.
// Notification for unauthorized people.
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).'groupmanager.lib.php';
@ -46,9 +47,9 @@ $nameTools = get_lang('ToolForum');
require_once 'forumconfig.inc.php';
require_once 'forumfunction.inc.php';
//are we in a lp ?
// Are we in a lp ?
$origin = '';
if(isset($_GET['origin'])) {
if (isset($_GET['origin'])) {
$origin = Security::remove_XSS($_GET['origin']);
}
@ -69,10 +70,10 @@ $htmlHeadXtra[] = '<script>
/* 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_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_forum_category = get_forumcategory_information($current_forum['forum_category']);
/* Breadcrumbs */
@ -80,8 +81,8 @@ if (isset($_SESSION['gradebook'])){
$gradebook = Security::remove_XSS($_SESSION['gradebook']);
}
if (!empty($gradebook) && $gradebook=='view') {
$interbreadcrumb[]= array (
if (!empty($gradebook) && $gradebook == 'view') {
$interbreadcrumb[] = array (
'url' => '../gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']),
'name' => get_lang('ToolGradebook')
);
@ -93,32 +94,32 @@ if (!empty($_GET['gidReq'])) {
}
$session_toolgroup = 0;
if ($origin=='group') {
if ($origin == 'group') {
$session_toolgroup = intval($_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_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" => "newthread.php?origin=".$origin."&amp;forum=".Security::remove_XSS($_GET['forum']),"name" => get_lang('NewTopic'));
$group_properties = GroupManager :: get_group_properties($session_toolgroup);
$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' => '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'));
} else {
$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" => "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' => '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' => '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'));
}
/* 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['origin'] = $_SERVER['REQUEST_URI'];
$_SESSION['breadcrumbs'] = $interbreadcrumb;
header("Location: ../resourcelinker/resourcelinker.php");
header('Location: ../resourcelinker/resourcelinker.php');
}
/* Header */
if($origin=='learnpath') {
if ($origin == 'learnpath') {
require_once api_get_path(INCLUDE_PATH).'reduced_header.inc.php';
} else {
Display :: display_header(null);
@ -134,28 +135,28 @@ if($origin=='learnpath') {
// 4. anonymous posts are not allowed and the user is not logged in
// 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();
if ($forum_allow === false) {
exit;
}
}
// 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();
if ($forum_allow === false) {
exit;
}
}
// 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();
if ($forum_allow === false) {
exit;
}
}
// 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();
if ($forum_allow === false) {
exit;
@ -165,14 +166,14 @@ if (!$_user['user_id'] AND $current_forum['allow_anonymous']<>1) {
/* Display forms / Feedback Messages */
handle_forum_and_forumcategories();
// action links
// Action links
echo '<div class="actions">';
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>';
}
else{
} else {
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>';
@ -180,18 +181,18 @@ echo '</div>';
/* 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') {
echo "<tr>\n<th align=\"left\" colspan=\"2\">";
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>';
}
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 "</th>\n";
@ -199,15 +200,15 @@ if ($origin != 'learnpath') {
}
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'])) {
//add new thread in table forum_thread
if (!empty($values) && isset($values['SubmitPost'])) {
// Add new thread in table forum_thread.
store_thread($values);
}
/* FOOTER */
if ($origin!='learnpath') {
if ($origin != 'learnpath') {
Display :: display_footer();
}
}

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* 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
@ -17,19 +18,19 @@
* @package chamilo.forum
*/
// name of the language file that needs to be included
$language_file = array('forum','document');
// Language files that need to be included.
$language_file = array('forum', 'document');
// including the global dokeos file
// Including the global initialization file.
require_once '../inc/global.inc.php';
// the section (tabs)
$this_section=SECTION_COURSES;
// The section (tabs).
$this_section = SECTION_COURSES;
// notice for unauthorized people.
// Notification for unauthorized people.
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).'groupmanager.lib.php';
$nameTools = get_lang('ToolForum');
@ -63,54 +64,60 @@ $htmlHeadXtra[] = '<script>
/* 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
// 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_forum = get_forum_information($current_thread['forum_id']); // note: this has to be validated that it is an existing forum.
// 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.
$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_category = get_forumcategory_information(Security::remove_XSS($current_forum['forum_category']));
/* Breadcrumbs */
if (isset($_SESSION['gradebook'])){
$gradebook = Security::remove_XSS($_SESSION['gradebook']);
}
if (!empty($gradebook) && $gradebook == 'view') {
$interbreadcrumb[]= array (
$interbreadcrumb[] = array (
'url' => '../gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']),
'name' => get_lang('ToolGradebook')
);
}
if ($origin=='group') {
$_clean['toolgroup']=(int)$_SESSION['toolgroup'];
if ($origin == 'group') {
$_clean['toolgroup'] = (int)$_SESSION['toolgroup'];
$group_properties = GroupManager :: get_group_properties($_clean['toolgroup']);
$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" => "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" => "javascript: void(0);","name" => get_lang('Reply'));
$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' => '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' => 'javascript: void(0);', 'name' => get_lang('Reply'));
} else {
$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" => "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" => "javascript: void(0);","name" => get_lang('Reply'));
$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' => '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' => 'javascript: void(0);', 'name' => get_lang('Reply'));
}
/* 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['origin'] = $_SERVER['REQUEST_URI'];
$_SESSION['breadcrumbs'] = $interbreadcrumb;
header("Location: ../resourcelinker/resourcelinker.php");
header('Location: ../resourcelinker/resourcelinker.php');
}
/* Header */
if($origin=='learnpath') {
if ($origin == 'learnpath') {
include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php');
} 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('');
api_display_tool_title($nameTools);
}
/* Is the user allowed here? */
// The user is not allowed here if
// 1. the forumcategory, forum or thread is invisible (visibility==0
@ -118,47 +125,48 @@ if($origin=='learnpath') {
// 3. if anonymous posts are not allowed
// The only exception is the course manager
// 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(false,true) AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==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))) {
$forum_allow = forum_not_allowed_here();
if ($forum_allow === false) {
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();
if ($forum_allow === false) {
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();
if ($forum_allow === false) {
exit;
}
}
/* Action links */
if ($origin != 'learnpath') {
echo '<div class="actions">';
echo '<span style="float:right;">'.search_link().'</span>';
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>';
}
else{
echo '<a href="index.php?gradebook='.$gradebook.'">'.Display::return_icon('back.png',get_lang('BackToForumOverview'),'','32').'</a>';
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>';
} else {
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="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="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 '</div>';
} else {
echo '<div style="height:15px">&nbsp;</div>';
}
/* 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 '<span class="forum_title">'.prepare4display($current_thread['thread_title']).'</span><br />';
@ -169,17 +177,17 @@ echo "</th>\n";
echo "\t</tr>\n";
echo '</table>';
// the form for the reply
// The form for the reply
$my_action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : '';
$my_post = isset($_GET['post']) ? Security::remove_XSS($_GET['post']) : '';
$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'])) {
store_reply($values);
}
if ($origin!='learnpath') {
if ($origin != 'learnpath') {
Display :: display_footer();
}
}

@ -22,83 +22,75 @@
* @package chamilo.forum
*/
// name of the language file that needs to be included
$language_file = array ('forum','group');
// Language files that need to be included.
$language_file = array('forum', 'group');
// including the global dokeos file
// Including the global initialization file.
require_once '../inc/global.inc.php';
// notice for unauthorized people.
// Notification for unauthorized people.
api_protect_course_script(true);
// the section (tabs)
$this_section=SECTION_COURSES;
// The section (tabs).
$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).'groupmanager.lib.php';
$nameTools=get_lang('ToolForum');
$nameTools = get_lang('ToolForum');
//are we in a lp ?
// Are we in a lp ?
$origin = '';
$origin_string='';
$origin_string = '';
if (isset($_GET['origin'])) {
$origin = Security::remove_XSS($_GET['origin']);
$origin_string = '&amp;origin='.$origin;
}
/*
Including necessary files
*/
/* Including necessary files */
require 'forumconfig.inc.php';
require_once 'forumfunction.inc.php';
$userid=api_get_user_id();
$userinf=api_get_user_info($userid);
$userid = api_get_user_id();
$userinf = api_get_user_info($userid);
/*
MAIN DISPLAY SECTION
*/
/* MAIN DISPLAY SECTION */
/* Retrieving forum and forum category 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
// 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=isset($_GET['forum'])?$_GET['forum']:'';
$val=GroupManager::user_has_access($userid,$my_forum_group,GROUP_TOOL_FORUM);
$my_forum_group = isset($_GET['gidReq']) ? $_GET['gidReq'] : '';
$my_forum = isset($_GET['forum']) ? $_GET['forum'] : '';
$val = GroupManager::user_has_access($userid, $my_forum_group, GROUP_TOOL_FORUM);
if(!empty($my_forum_group)){
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_category=get_forumcategory_information($current_forum['forum_category']);
}
if (!empty($my_forum_group)) {
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_category = get_forumcategory_information($current_forum['forum_category']);
}
} else {
$result=get_forum_information($my_forum);
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_category=get_forumcategory_information($current_forum['forum_category']);
$result = get_forum_information($my_forum);
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_category = get_forumcategory_information($current_forum['forum_category']);
}
}
/* Header and Breadcrumbs */
/*
Header and Breadcrumbs
*/
$my_search=isset($_GET['search'])?$_GET['search']:'';
$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'])){
$gradebook= $_SESSION['gradebook'];
$gradebook = $_SESSION['gradebook'];
}
if (!empty($gradebook) && $gradebook=='view') {
$interbreadcrumb[]= array (
if (!empty($gradebook) && $gradebook == 'view') {
$interbreadcrumb[] = array (
'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
'name' => get_lang('ToolGradebook')
);
@ -109,83 +101,82 @@ if (!empty($_GET['gidReq'])) {
api_session_register('toolgroup');
}
if ($origin=='group') {
$_clean['toolgroup']=(int)$_SESSION['toolgroup'];
$group_properties = GroupManager :: get_group_properties($_clean['toolgroup']);
$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" => "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" => "#","name" => get_lang('Forum').' '.Security::remove_XSS($current_forum['forum_title']));
if ($origin == 'group') {
$_clean['toolgroup'] = (int)$_SESSION['toolgroup'];
$group_properties = GroupManager :: get_group_properties($_clean['toolgroup']);
$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' => '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' => '#', '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)),
} else {
$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" => "#","name" => Security::remove_XSS($current_forum['forum_title']));
$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' => '#', '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))
}
if ($origin=='learnpath') {
include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php');
if ($origin == 'learnpath') {
include api_get_path(INCLUDE_PATH).'reduced_header.inc.php';
} 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('');
//api_display_tool_title($nameTools);
}
/*
Actions
*/
/* Actions */
$table_link = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
// 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)) {
$message=change_visibility($_GET['content'], $_GET['id'],$_GET['action']);// note: this has to be cleaned first
// 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)) {
$message = change_visibility($_GET['content'], $_GET['id'], $_GET['action']); // Note: This has to be cleaned first.
}
// 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)) {
$message=change_lock_status($_GET['content'], $_GET['id'],$my_action);// note: this has to be cleaned first
// 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)) {
$message = change_lock_status($_GET['content'], $_GET['id'], $my_action); // Note: This has to be cleaned first.
}
// 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)) {
$message=delete_forum_forumcategory_thread($_GET['content'],$_GET['id']); // note: this has to be cleaned first
//delete link
$sql_link='DELETE FROM '.$table_link.' WHERE ref_id='.intval($_GET['id']).' and type=5 and course_code="'.api_get_course_id().'";';
// 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)) {
$message = delete_forum_forumcategory_thread($_GET['content'], $_GET['id']); // Note: This has to be cleaned first.
// Delete link
$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);
}
// 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)) {
$message=move_thread_form();
// 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)) {
$message = move_thread_form();
}
// notification
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']);
Display :: display_confirmation_message($return_message,false);
// Notification.
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']);
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']) {
case "qualify":
$student_list=get_thread_users_qualify($_GET['id']);
$nrorow3 =-2;
case 'qualify':
$student_list = get_thread_users_qualify($_GET['id']);
$nrorow3 = -2;
break;
case "notqualify":
$student_list=get_thread_users_not_qualify($_GET['id']);
$nrorow3 =-2;
case 'notqualify':
$student_list = get_thread_users_not_qualify($_GET['id']);
$nrorow3 = -2;
break;
default:
$student_list=get_thread_users_details($_GET['id']);
$student_list = get_thread_users_details($_GET['id']);
$nrorow3 = Database::num_rows($student_list);
break;
}
$table_list = '<p><br /><h3>'.get_lang('ThreadUsersList').'&nbsp;:'.get_name_thread_by_id($_GET['id']).'</h3>';
if ($nrorow3>0 || $nrorow3==-2) {
$table_list = '<p><br /><h3>'.get_lang('ThreadUsersList').': '.get_name_thread_by_id($_GET['id']).'</h3>';
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']);
$table_list.= '<br />
$table_list .= '<br />
<div style="width:50%">
<table class="data_table" border="0">
<tr>
@ -198,48 +189,48 @@ if ($my_action == 'liststd' AND isset($_GET['content']) AND isset($_GET['id']) A
';
$icon_qualify = 'blog_new.gif';
$table_list.= '<center><br /><table class="data_table" style="width:50%">';
// The column headers (to do: make this sortable)
$table_list.= '<tr >';
$table_list.= '<th height="24">'.get_lang('NamesAndLastNames').'</th>';
$table_list .= '<center><br /><table class="data_table" style="width:50%">';
// The column headers (TODO: Make this sortable).
$table_list .= '<tr >';
$table_list .= '<th height="24">'.get_lang('NamesAndLastNames').'</th>';
if ($_GET['list']=='qualify') {
if ($_GET['list'] == 'qualify') {
$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.= '</tr>';
$max_qualify=show_qualify('2',$_GET['cidReq'],$my_forum,$userid,$_GET['id']);
$counter_stdlist=0;
$table_list .= '</tr>';
$max_qualify = show_qualify('2', $_GET['cidReq'], $my_forum, $userid, $_GET['id']);
$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)) {
if ($counter_stdlist%2==0) {
$class_stdlist="row_odd";
if ($counter_stdlist % 2 == 0) {
$class_stdlist = 'row_odd';
} else {
$class_stdlist="row_even";
$class_stdlist = 'row_even';
}
$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>';
if ($_GET['list']=='qualify') {
$table_list.= '<td>'.$row_student_list['qualify'].'/'.$max_qualify.'</td>';
$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>';
if ($_GET['list'] == 'qualify') {
$table_list .= '<td>'.$row_student_list['qualify'].'/'.$max_qualify.'</td>';
}
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']);
$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>';
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']);
$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++;
}
} else {
if ($_GET['list']=='qualify'){
$table_list.='<tr><td colspan="2">'.get_lang('ThereIsNotQualifiedLearners').'</td></tr>';
if ($_GET['list'] == 'qualify') {
$table_list .= '<tr><td colspan="2">'.get_lang('ThereIsNotQualifiedLearners').'</td></tr>';
} 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>';
} else {
$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?
*/
// if the user is not a course administrator and the forum is hidden
/* Is the user allowed here? */
// If the user is not a course administrator and the forum is hidden
// 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();
if ($forum_allow === false) {
exit;
@ -263,40 +253,35 @@ if ($origin == 'learnpath') {
echo '<div style="height:15px">&nbsp;</div>';
}
/*
Display the action messages
*/
/* Display the action messages */
if (!empty($message)) {
Display :: display_confirmation_message($message);
}
/* Action links */
/*
Action Links
*/
if ($origin!='learnpath') {
if ($origin != 'learnpath') {
echo '<div class="actions">';
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>';
}
else{
} else {
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
// 1. the course admin is here
// 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
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 (!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>';
} 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>';
}
}
} else {
echo get_lang('ForumLocked');
@ -305,161 +290,148 @@ if ($origin!='learnpath') {
echo '</div>';
}
/*
Display
*/
/* Display */
echo '<table class="forum_table" >';
// the current forum
// The current forum
if ($origin != 'learnpath') {
echo '<thead>';
echo "<tr><th class=\"forum_head\" colspan=\"7\">";
echo '<thead><tr><th class="forum_head" colspan="7">';
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_title">'.prepare4display($current_forum['forum_title']).'</span>';
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>";
echo "</tr>";
echo '</thead>';
echo '</th></tr></thead>';
}
echo "</th>";
echo "</tr>";
// The column headers (to do: make this sortable)
echo "<tr class=\"forum_threadheader\">";
echo "<td></td>";
echo "<td>".get_lang('Title')."</td>";
echo "<td>".get_lang('Replies')."</td>";
echo "<td>".get_lang('Views')."</td>";
echo "<td>".get_lang('Author')."</td>";
echo "<td>".get_lang('LastPost')."</td>";
echo "<td>".get_lang('Actions')."</td>";
echo "</tr>";
// The column headers (TODO: Make this sortable).
echo '<tr class="forum_threadheader">';
echo '<td></td>';
echo '<td>'.get_lang('Title').'</td>';
echo '<td>'.get_lang('Replies').'</td>';
echo '<td>'.get_lang('Views').'</td>';
echo '<td>'.get_lang('Author').'</td>';
echo '<td>'.get_lang('LastPost').'</td>';
echo '<td>'.get_lang('Actions').'</td>';
echo '</tr>';
// getting al the threads
$threads=get_threads($my_forum); // note: this has to be cleaned first
// Getting al the threads
$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;
if(is_array($threads)) {
$counter = 0;
if (is_array($threads)) {
foreach ($threads as $row) {
// 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($counter%2==0) {
$class="row_odd";
// 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 ($counter % 2 == 0) {
$class = 'row_odd';
} else {
$class="row_even";
$class = 'row_even';
}
echo "<tr class=\"$class\">";
echo "<td>";
$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)) {
echo '<td>';
$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) && !empty($my_whatsnew_post_info)) {
echo Display::return_icon('forumthread.gif');
} else {
echo Display::return_icon('forumthread.gif');
}
if ($row['thread_sticky']==1) {
if ($row['thread_sticky'] == 1) {
echo Display::return_icon('exclamation.gif');
}
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 "<td>".$row['thread_replies']."</td>";
if ($row['user_id']=='0') {
$name=prepare4display($row['thread_poster_name']);
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 '<td>'.$row['thread_replies'].'</td>';
if ($row['user_id'] == '0') {
$name = prepare4display($row['thread_poster_name']);
} 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>";
if ($row['last_poster_user_id']=='0') {
$name=$row['poster_name'];
echo '<td>'.$row['thread_views'].'</td>';
if ($row['last_poster_user_id'] == '0') {
$name = $row['poster_name'];
} 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') {
echo "<td>".display_user_link($row['user_id'], api_get_person_name($row['firstname'], $row['lastname']))."</td>";
if ($origin != 'learnpath') {
echo '<td>'.display_user_link($row['user_id'], api_get_person_name($row['firstname'], $row['lastname'])).'</td>';
} 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 (($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);
} 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_result=Database::query($last_post_sql);
$last_post_row=Database::fetch_array($last_post_result);
$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);
// 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') {
$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') {
$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_row = Database::fetch_array($last_post_result);
$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);
} else {
$last_post_sql="SELECT post.*, user.firstname, user.lastname FROM $table_posts post, $table_users user WHERE post.poster_id=user.user_id AND visible='1' AND thread_id='".$row['thread_id']."' ORDER BY post_id DESC";
$last_post_result=Database::query($last_post_sql);
$last_post_row=Database::fetch_array($last_post_result);
$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_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_row = Database::fetch_array($last_post_result);
$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;
}
echo "<td>".$last_post."</td>";
echo "<td>";
// get attach id
$attachment_list=get_attachment($row['post_id']);
$id_attach = !empty($attachment_list)?$attachment_list['id']:'';
echo '<td>'.$last_post.'</td>';
echo '<td>';
// Get attachment id.
$attachment_list = get_attachment($row['post_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'])."'";
$result_post_id=Database::query($sql_post_id);
$row_post_id=Database::fetch_array($result_post_id);
$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);
$row_post_id = Database::fetch_array($result_post_id);
if ($origin != 'learnpath') {
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=\"".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_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>";
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="'.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_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>';
}
}
$iconnotify = 'send_mail.gif';
if (is_array(isset($_SESSION['forum_notification']['thread'])?$_SESSION['forum_notification']['thread']:null)) {
if (in_array($row['thread_id'],$_SESSION['forum_notification']['thread'])) {
if (is_array(isset($_SESSION['forum_notification']['thread']) ? $_SESSION['forum_notification']['thread'] : null)) {
if (in_array($row['thread_id'], $_SESSION['forum_notification']['thread'])) {
$iconnotify = 'send_mail_checked.gif';
}
}
$icon_liststd = 'user.png';
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>";
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>';
}
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 "</td>";
echo "</tr>";
echo '</td></tr>';
}
$counter++;
}
}
echo "</table>";
echo isset($table_list)?$table_list:'';
echo '</table>';
echo isset($table_list) ? $table_list : '';
/* FOOTER */
if ($origin != 'learnpath') {
Display :: display_footer();
}

@ -22,10 +22,12 @@
* @package chamilo.forum
*/
// name of the language file that needs to be included
// Language file that needs to be included.
$language_file = 'forum';
// including the global dokeos init file
// Including the global initialization file.
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" language="javascript">
$(document).ready(function(){ $(\'.hide-me\').slideUp() });
@ -44,22 +46,18 @@ $htmlHeadXtra[] = '<script type="text/javascript" language="javascript">
}
</script>';
// The section (tabs)
$this_section = SECTION_COURSES;
// including the global dokeos file
require '../inc/global.inc.php';
// the section (tabs)
$this_section=SECTION_COURSES;
// notice for unauthorized people.
// Notification for unauthorized people.
api_protect_course_script(true);
// including additional library scripts
// Including additional library scripts.
require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
$nameTools=get_lang('ToolForum');
/* Including necessary files */
// Including necessary files
require 'forumconfig.inc.php';
require_once 'forumfunction.inc.php';
@ -68,25 +66,25 @@ require_once 'forumfunction.inc.php';
/* Header and Breadcrumbs */
if (isset($_SESSION['gradebook'])){
if (isset($_SESSION['gradebook'])) {
$gradebook= $_SESSION['gradebook'];
}
if (!empty($gradebook) && $gradebook=='view') {
$interbreadcrumb[]= array (
if (!empty($gradebook) && $gradebook == 'view') {
$interbreadcrumb[] = array (
'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
'name' => get_lang('ToolGradebook')
);
}
$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" => "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']));
$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' => '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 ($_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 '<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)) {
//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>';
@ -132,237 +130,232 @@ echo '</div>';
/* ACTIONS */
$action_forums=isset($_GET['action']) ? $_GET['action'] : '';
if (api_is_allowed_to_edit(false,true)) {
$action_forums = isset($_GET['action']) ? $_GET['action'] : '';
if (api_is_allowed_to_edit(false, true)) {
handle_forum_and_forumcategories();
}
// notification
if ($action_forums == 'notify' AND isset($_GET['content']) AND isset($_GET['id'])) {
$return_message = set_notification($_GET['content'],$_GET['id']);
Display :: display_confirmation_message($return_message,false);
// Notification
if ($action_forums == 'notify' && isset($_GET['content']) && isset($_GET['id'])) {
$return_message = set_notification($_GET['content'], $_GET['id']);
Display :: display_confirmation_message($return_message, false);
}
if ($action_forums!='add') {
if ($action_forums != 'add') {
/*
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
latest changes
Note: We do this here just after het handling of the actions to be sure that we already incorporate the
latest changes.
*/
// Step 1: We store all the forum categories in an array $forum_categories
$forum_categories=array();
$forum_category=get_forum_categories($_GET['forumcategory']);
// Step 1: We store all the forum categories in an array $forum_categories.
$forum_categories = array();
$forum_category = get_forum_categories($_GET['forumcategory']);
// step 2: we find all the forums
$forum_list=array();
$forum_list=get_forums();
// Step 2: We find all the forums.
$forum_list = array();
$forum_list = get_forums();
/* RETRIEVING ALL GROUPS AND THOSE OF THE USER */
// the groups of the user
$groups_of_user=array();
$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=GroupManager::get_group_list();
if(is_array($all_groups)) {
// The groups of the user.
$groups_of_user = array();
$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 = GroupManager::get_group_list();
if (is_array($all_groups)) {
foreach ($all_groups as $group) {
$all_groups[$group['id']]=$group;
$all_groups[$group['id']] = $group;
}
}
/* CLEAN GROUP ID FOR AJAXFILEMANAGER */
if(isset($_SESSION['_gid']))
{
if (isset($_SESSION['_gid'])) {
unset($_SESSION['_gid']);
}
/* Display Forum Categories and the Forums in it */
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']).')';
} else {
$session_displayed = '';
}
$forum_categories_list='';
$forum_categories_list = '';
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 '<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)) {
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=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_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);
echo "</th>";
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 '<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>';
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_up_down_icon('forumcategory', $forum_category['cat_id'], $forum_categories_list);
echo '</th>';
}
echo "</tr>";
echo '</tr>';
// step 3: the interim headers (for the forum)
echo "<tr class=\"forum_header\">";
echo "<td colspan='2'>".get_lang('Forum')."</td>";
echo "<td>".get_lang('Topics')."</td>";
echo "<td>".get_lang('Posts')."</td>";
echo "<td>".get_lang('LastPosts')."</td>";
echo "<td>".get_lang('Actions')."</td>";
echo "</tr>";
// Step 3: The interim headers (for the forum).
echo '<tr class="forum_header">';
echo '<td colspan="2">'.get_lang('Forum').'</td>';
echo '<td>'.get_lang('Topics').'</td>';
echo '<td>'.get_lang('Posts').'</td>';
echo '<td>'.get_lang('LastPosts').'</td>';
echo '<td>'.get_lang('Actions').'</td>';
echo '</tr>';
echo '</thead>';
// the forums in this category
$forums_in_category=get_forums_in_category($forum_category['cat_id']);
// The forums in this category.
$forums_in_category = get_forums_in_category($forum_category['cat_id']);
// step 4: we display all the forums in this category.
$forum_count=0;
foreach ($forum_list as $key=>$forum) {
if ($forum['forum_category']==$forum_category['cat_id']) {
// the forum has to be showed if
// Step 4: We display all the forums in this category.
$forum_count = 0;
foreach ($forum_list as $key => $forum) {
if ($forum['forum_category'] == $forum_category['cat_id']) {
// The forum has to be showed if
// 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)
// 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 (!($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;
//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;
// SHOULD WE SHOW THIS PARTICULAR FORUM
// you are teacher => show forum
if (api_is_allowed_to_edit(false,true)) {
//echo 'teacher';
$show_forum=true;
$show_forum = true;
} else {
// you are not a teacher
//echo 'student';
// 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';
$show_forum=true;
$show_forum = true;
} else {
// it is a group forum
//echo '-groepsforum';
// it is a group forum but it is public => show
if ($forum['forum_group_public_private']=='public') {
$show_forum=true;
if ($forum['forum_group_public_private'] == 'public') {
$show_forum = true;
//echo '-publiek';
} else {
// it is a group forum and it is private
//echo '-prive';
// 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';
$show_forum=true;
$show_forum = true;
} else {
//echo '-is GEEN lid';
$show_forum=false;
$show_forum = false;
}
}
}
}
//echo '<hr>';
$form_count=isset($form_count)?$form_count:0;
//echo '<hr />';
$form_count = isset($form_count) ? $form_count : 0;
if ($show_forum === true) {
$form_count++;
echo "<tr class=\"forum\">";
echo "<td width=\"20\">";
$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 (is_array($my_whatsnew_post_info) and !empty($my_whatsnew_post_info)) {
echo '<tr class="forum">';
echo '<td width="20">';
$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 (is_array($my_whatsnew_post_info) && !empty($my_whatsnew_post_info)) {
echo Display::return_icon('forumgroupnew.gif');
} else {
echo Display::return_icon('forumgroup.gif', get_lang('GroupForum'));
}
} 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'));
} else {
echo Display::return_icon('forum.gif');
}
}
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='';
}
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((!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'].')';
} else {
$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
// the number of topics and posts
$my_number_threads=isset($forum['number_of_threads']) ? $forum['number_of_threads'] : '';
$my_number_posts=isset($forum['number_of_posts']) ? $forum['number_of_posts'] : '';
echo "<td>".$my_number_threads."</td>";
echo "<td>".$my_number_posts."</td>";
$my_number_threads = isset($forum['number_of_threads']) ? $forum['number_of_threads'] : '';
$my_number_posts = isset($forum['number_of_posts']) ? $forum['number_of_posts'] : '';
echo '<td>'.$my_number_threads.'</td>';
echo '<td>'.$my_number_posts.'</td>';
// the last post in the forum
if ($forum['last_poster_name']<>'') {
$name=$forum['last_poster_name'];
$poster_id=0;
if ($forum['last_poster_name'] != '') {
$name = $forum['last_poster_name'];
$poster_id = 0;
} else {
$name=api_get_person_name($forum['last_poster_firstname'], $forum['last_poster_lastname']);
$poster_id=$forum['last_poster_id'];
$name = api_get_person_name($forum['last_poster_firstname'], $forum['last_poster_lastname']);
$poster_id = $forum['last_poster_id'];
}
echo "<td>";
echo '<td>';
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 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)) {
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>";
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_up_down_icon('forum',$forum['forum_id'], $forums_in_category);
echo '</td>';
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)) {
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>';
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_up_down_icon('forum', $forum['forum_id'], $forums_in_category);
}
$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'])) {
$iconnotify = 'send_mail_checked.gif';
}
}
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 "</tr>";
echo '</td></tr>';
}
}
}
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 */
if ($origin!='learnpath') {
if ($origin != 'learnpath') {
Display :: display_footer();
}

@ -3,23 +3,26 @@
/**
* @package chamilo.forum
*/
// name of the language file that needs to be included
// Language file that needs to be included.
$language_file = 'forum';
// including the global dokeos file
// Including the global initialization file.
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);
// including additional library scripts
require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
//require_once (api_get_path(LIBRARY_PATH).'resourcelinker.lib.php');
$nameTools=get_lang('ToolForum');
// Including additional library scripts.
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
include_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
//require_once api_get_path(LIBRARY_PATH).'resourcelinker.lib.php';
$nameTools = get_lang('ToolForum');
/* Including necessary files */
// Including necessary files.
require 'forumconfig.inc.php';
require_once 'forumfunction.inc.php';
@ -39,33 +42,33 @@ if (isset($_GET['origin'])) {
/* 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
// 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_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']);
$whatsnew_post_info=$_SESSION['whatsnew_post_info'];
// 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.
$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_category = get_forumcategory_information($current_forum['forum_category']);
$whatsnew_post_info = $_SESSION['whatsnew_post_info'];
/* Header and Breadcrumbs */
if (isset($_SESSION['gradebook'])){
$gradebook= $_SESSION['gradebook'];
$gradebook = $_SESSION['gradebook'];
}
if (!empty($gradebook) && $gradebook=='view') {
$interbreadcrumb[]= array (
if (!empty($gradebook) && $gradebook == 'view') {
$interbreadcrumb[] = array (
'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
'name' => get_lang('ToolGradebook')
);
}
if ($origin=='learnpath') {
if ($origin == 'learnpath') {
include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php');
} else {
$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" => "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' => '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' => '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
Display :: display_header('');
@ -76,7 +79,7 @@ if ($origin=='learnpath') {
// if the user is not a course administrator and the forum is hidden
// 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();
if ($forum_allow === false) {
exit;
@ -85,14 +88,14 @@ if (!api_is_allowed_to_edit(false,true) AND ($current_forum['visibility']==0 OR
/* Actions */
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
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.
}
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
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.
}
if ($_GET['action']=='move' and isset($_GET['post'])) {
$message=move_post_form();
if ($_GET['action'] == 'move' && isset($_GET['post'])) {
$message = move_post_form();
}
/* Display the action messages */
@ -101,8 +104,8 @@ if (!empty($message)) {
Display :: display_confirmation_message(get_lang($message));
}
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
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.
increase_thread_view($_GET['thread']);
/* Action Links */
@ -116,14 +119,14 @@ if ($message <> 'PostDeletedSpecial') { // in this case the first and only post
echo '</div>';
// The reply to thread link should only appear when the forum_category is not locked AND the forum is not locked AND the thread is not locked.
// If one of the three levels is locked then the link should not be displayed.
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.
if ($_user['user_id'] OR ($current_forum['allow_anonymous']==1 AND !$_user['user_id'])) {
//reply link
if ($_user['user_id'] OR ($current_forum['allow_anonymous'] == 1 AND !$_user['user_id'])) {
// 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>';
//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)) {
// 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 ($current_forum['locked'] <> 1 AND $current_forum['locked'] <> 1) {
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>';*/
@ -139,15 +142,15 @@ if ($message <> 'PostDeletedSpecial') { // in this case the first and only post
/* Display Forum Category and the Forum information */
if (!$_SESSION['view']) {
$viewmode=$current_forum['default_view'];
$viewmode = $current_forum['default_view'];
} else {
$viewmode=$_SESSION['view'];
$viewmode = $_SESSION['view'];
}
$viewmode_whitelist=array('flat', 'threaded', 'nested');
if (isset($_GET['view']) and in_array($_GET['view'],$viewmode_whitelist)) {
$viewmode=Database::escape_string($_GET['view']);
$_SESSION['view']=$viewmode;
if (isset($_GET['view']) && in_array($_GET['view'], $viewmode_whitelist)) {
$viewmode = Database::escape_string($_GET['view']);
$_SESSION['view'] = $viewmode;
}
if (empty($viewmode)) {
$viewmode = 'flat';
@ -175,9 +178,10 @@ if ($message <> 'PostDeletedSpecial') { // in this case the first and only post
echo "</table>";
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 */
if ($origin!='learnpath') {
if ($origin != 'learnpath') {
Display :: display_footer();
}
}

@ -1,32 +1,33 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @author Julio Montoya <gugli100@gmail.com> UI Improvements + lots of bugfixes
* @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';
// the section (tabs)
$this_section=SECTION_COURSES;
// The section (tabs.)
$this_section = SECTION_COURSES;
// notice for unauthorized people.
// Notification for unauthorized people.
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).'groupmanager.lib.php';
require_once 'forumconfig.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 = '';
if (isset($_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.
// 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.
$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_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_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 */
if (!empty($_GET['gradebook']) && $_GET['gradebook']=='view' ) {
$_SESSION['gradebook']=Security::remove_XSS($_GET['gradebook']);
$gradebook= $_SESSION['gradebook'];
if (!empty($_GET['gradebook']) && $_GET['gradebook'] == 'view') {
$_SESSION['gradebook'] = Security::remove_XSS($_GET['gradebook']);
$gradebook = $_SESSION['gradebook'];
}
if (!empty($gradebook) && $gradebook=='view') {
if (!empty($gradebook) && $gradebook == 'view') {
$interbreadcrumb[] = array (
'url' => '../gradebook/' . $_SESSION['gradebook_dest'],
'name' => get_lang('ToolGradebook')
);
}
if ($origin=='group') {
$session_toolgroup = intval($_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_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"=>"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']));
if ($origin == 'group') {
$session_toolgroup = intval($_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_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'=>'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('');
//api_display_tool_title($nameTools);
} 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';
} else {
$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" => "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' => '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' => '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 : '';
// the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string
Display :: display_header('');
@ -89,9 +90,9 @@ if ($origin=='group') {
/* 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.
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();
if ($forum_allow === false) {
exit;
@ -101,14 +102,14 @@ if (!api_is_allowed_to_edit(false,true) AND ($current_forum['visibility']==0 OR
/* Actions */
$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)) {
$message=delete_post($_GET['id']); // note: this has to be cleaned first
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.
}
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
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.
}
if ($my_action=='move' AND isset($_GET['post'])) {
$message=move_post_form();
if ($my_action == 'move' AND isset($_GET['post'])) {
$message = move_post_form();
}
/* Display the action messages */
@ -118,48 +119,47 @@ if ($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
// this increases the number of times the thread has been viewed
increase_thread_view($_GET['thread']);
/* Action Links */
if ($origin=='learnpath') {
if ($origin == 'learnpath') {
echo '<div style="height:15px">&nbsp;</div>';
}
echo '<div class="actions">';
echo '<span style="float:right;">'.search_link().'</span>';
if ($origin != 'learnpath') {
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="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{
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>';
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="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 {
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>';
}
}
// 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 ($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.
if ($_user['user_id'] OR ($current_forum['allow_anonymous']==1 AND !$_user['user_id'])) {
//reply link
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>';
if ($_user['user_id'] OR ($current_forum['allow_anonymous'] == 1 AND !$_user['user_id'])) {
// reply link
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>';
}
//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)) {
// 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 ($current_forum['locked'] <> 1 AND $current_forum['locked'] <> 1) {
echo '&nbsp;&nbsp;';
/* if ( isset($_GET['gradebook']) && $_GET['gradebook']!=""){
$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>';
/* if ( isset($_GET['gradebook']) && $_GET['gradebook'] != '') {
$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>';
} 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 {
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') {
$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=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=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=nested&amp;origin='.$origin.'&amp;gradebook='.$gradebook.'">'.Display::return_icon('forum_nestedview.gif', get_lang('NestedView')).get_lang('NestedView').'</a>';
}
$my_url = null;
@ -182,17 +182,17 @@ if ($my_message <> 'PostDeletedSpecial') {
/* Display Forum Category and the Forum information */
if (!isset($_SESSION['view'])) {
$viewmode=$current_forum['default_view'];
$viewmode = $current_forum['default_view'];
} else {
$viewmode=$_SESSION['view'];
$viewmode = $_SESSION['view'];
}
$viewmode_whitelist=array('flat', 'threaded', 'nested');
if (isset($_GET['view']) and in_array($_GET['view'],$viewmode_whitelist)) {
$viewmode=$_GET['view'];
$_SESSION['view']=$viewmode;
$viewmode_whitelist = array('flat', 'threaded', 'nested');
if (isset($_GET['view']) && in_array($_GET['view'], $viewmode_whitelist)) {
$viewmode = $_GET['view'];
$_SESSION['view'] = $viewmode;
}
if(empty($viewmode)) {
if (empty($viewmode)) {
$viewmode = 'flat';
}
@ -202,10 +202,10 @@ if ($my_message <> 'PostDeletedSpecial') {
// 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.
echo "<table class=\"forum_table_title\" width='100%'>";
echo '<table class="forum_table_title" width="100%">';
// the thread
echo "<tr><th style=\"padding:5px;\" align=\"left\" colspan=\"6\">";
// The thread
echo '<tr><th style="padding:5px;" align="left" colspan="6">';
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 '<span class="forum_description">';
@ -214,13 +214,12 @@ if ($my_message <> 'PostDeletedSpecial') {
echo '</div>';
if ($origin!='learnpath') {
if ($origin != 'learnpath') {
//echo '<span class="forum_low_description">'.prepare4display($current_forum_category['cat_title']).' ';
}
echo "</th>";
echo "</tr>";
echo "</table>";
echo '</th></tr>';
echo '</table>';
switch ($viewmode) {
case 'flat':
@ -236,9 +235,10 @@ if ($my_message <> 'PostDeletedSpecial') {
include_once('viewthread_flat.inc.php');
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 */
if ($origin!='learnpath') {
if ($origin != 'learnpath') {
Display :: display_footer();
}
}

@ -1,12 +1,14 @@
<?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';
// Including additional libraries.
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;
//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();
if (isset($_POST['glossary_id']) && $_POST['glossary_id']==strval(intval($_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=str_replace($path_image_search,$path_image,$glossary_description_by_id);
echo api_xml_http_response_encode($glossary_description_by_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=str_replace($path_image_search,$path_image,$glossary_description_by_id);
echo api_xml_http_response_encode($glossary_description_by_id);
} elseif (isset($_POST['glossary_data']) && $_POST['glossary_data']=='true') {
//get_glossary_terms
$glossary_data=GlossaryManager::get_glossary_terms();
$glossary_all_data=array();
if (count($glossary_data)>0) {
foreach ($glossary_data as $glossary_index=>$glossary_value) {
$glossary_all_data[]=$glossary_value['id'].'__|__|'.$glossary_value['name'];
}
$glossary_all_data=implode('[|.|_|.|-|.|]',$glossary_all_data);
echo api_xml_http_response_encode($glossary_all_data);
}
//get_glossary_terms
$glossary_data=GlossaryManager::get_glossary_terms();
$glossary_all_data=array();
if (count($glossary_data)>0) {
foreach ($glossary_data as $glossary_index=>$glossary_value) {
$glossary_all_data[]=$glossary_value['id'].'__|__|'.$glossary_value['name'];
}
$glossary_all_data=implode('[|.|_|.|-|.|]',$glossary_all_data);
echo api_xml_http_response_encode($glossary_all_data);
}
} elseif(isset($_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=trim($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);
if (is_null($glossary_description) || strlen(trim($glossary_description))==0) {
echo api_xml_http_response_encode(get_lang('NoResults'));
} else {
echo api_xml_http_response_encode($glossary_description);
}
$my_glossary_name=Security::remove_XSS($_POST['glossary_name']);
$my_glossary_name=api_convert_encoding($my_glossary_name,$charset,'UTF-8');
$my_glossary_name=trim($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);
if (is_null($glossary_description) || strlen(trim($glossary_description))==0) {
echo api_xml_http_response_encode(get_lang('NoResults'));
} else {
echo api_xml_http_response_encode($glossary_description);
}
} 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
*/
// name of the language file that needs to be included
// The language file that needs to be included.
$language_file = array('glossary');
// including the global dokeos file
// Including the global initialization file.
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
require_once api_get_path(LIBRARY_PATH).'glossary.lib.php';
// the section (tabs)
$this_section=SECTION_COURSES;
// The section (tabs).
$this_section = SECTION_COURSES;
// notice for unauthorized people.
// Notification for unauthorized people.
api_protect_course_script(true);
// including additional libraries
// Including additional libraries.
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
// additional javascript
// Additional javascripts.
$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 type="text/javascript">
@ -37,14 +37,14 @@ $(document).ready(function () {
// setting the tool constants
$tool = TOOL_GLOSSARY;
// tracking
// Tracking
event_access_tool(TOOL_GLOSSARY);
// displaying the header
// Displaying the header
if (isset($_GET['action']) && ($_GET['action'] == 'addglossary' || $_GET['action'] == 'edit_glossary')) {
$tool='GlossaryManagement';
$interbreadcrumb[] = array ("url"=>"index.php", "name"=> get_lang('ToolGlossary'));
$tool='GlossaryManagement';
$interbreadcrumb[] = array ("url"=>"index.php", "name"=> get_lang('ToolGlossary'));
}
Display::display_header(get_lang(ucfirst($tool)));
@ -52,90 +52,90 @@ Display::display_header(get_lang(ucfirst($tool)));
// Tool introduction
Display::display_introduction_section(TOOL_GLOSSARY);
if ($_GET['action'] == 'changeview' AND in_array($_GET['view'],array('list','table'))) {
$_SESSION['glossary_view'] = $_GET['view'];
$_SESSION['glossary_view'] = $_GET['view'];
} else {
if (!isset($_SESSION['glossary_view'])) {
$_SESSION['glossary_view'] = 'table';//Default option
}
}
if (api_is_allowed_to_edit(null,true)) {
// Adding a glossary
if (isset($_GET['action']) && $_GET['action'] == 'addglossary') {
// initiate the object
$form = new FormValidator('glossary','post', api_get_self().'?action='.Security::remove_XSS($_GET['action']));
// settting the form elements
$form->addElement('header', '', get_lang('TermAddNew'));
$form->addElement('text', 'glossary_title', get_lang('TermName'), array('size'=>'95', 'id'=>'glossary_title'));
//$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('style_submit_button', 'SubmitGlossary', get_lang('TermAddButton'), 'class="save"');
// setting the rules
$form->addRule('glossary_title',get_lang('ThisFieldIsRequired'), 'required');
// The validation or display
if ($form->validate()) {
$check = Security::check_token('post');
if ($check) {
$values = $form->exportValues();
GlossaryManager::save_glossary($values);
}
Security::clear_token();
GlossaryManager::display_glossary();
} else {
$token = Security::get_token();
$form->addElement('hidden','sec_token');
$form->setConstants(array('sec_token' => $token));
$form->display();
}
} else if (isset($_GET['action']) && $_GET['action'] == 'edit_glossary' && is_numeric($_GET['glossary_id'])) { // Editing a glossary
// 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']));
// settting the form elements
$form->addElement('header', '', get_lang('TermEdit'));
$form->addElement('hidden', 'glossary_id');
$form->addElement('text', 'glossary_title', get_lang('TermName'),array('size'=>'100'));
//$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('style_submit_button', 'SubmitGlossary', get_lang('TermUpdateButton'), 'class="save"');
// setting the defaults
$defaults = GlossaryManager::get_glossary_information(Security::remove_XSS($_GET['glossary_id']));
$form->setDefaults($defaults);
// setting the rules
$form->addRule('glossary_title', '<div class="required">'.get_lang('ThisFieldIsRequired'), 'required');
// The validation or display
if ($form->validate()) {
$check = Security::check_token('post');
if ($check) {
$values = $form->exportValues();
GlossaryManager::update_glossary($values);
}
Security::clear_token();
GlossaryManager::display_glossary();
} else {
$token = Security::get_token();
$form->addElement('hidden','sec_token');
$form->setConstants(array('sec_token' => $token));
$form->display();
}
} 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::display_glossary();
} 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::display_glossary();
} else if (isset($_GET['action']) && $_GET['action'] == 'movedown' && is_numeric($_GET['glossary_id'])) {// moving a glossary term up
GlossaryManager::move_glossary('down',$_GET['glossary_id']);
GlossaryManager::display_glossary();
} else {
GlossaryManager::display_glossary();
}
if (api_is_allowed_to_edit(null, true)) {
// Adding a glossary
if (isset($_GET['action']) && $_GET['action'] == 'addglossary') {
// initiate the object
$form = new FormValidator('glossary','post', api_get_self().'?action='.Security::remove_XSS($_GET['action']));
// settting the form elements
$form->addElement('header', '', get_lang('TermAddNew'));
$form->addElement('text', 'glossary_title', get_lang('TermName'), array('size'=>'95', 'id'=>'glossary_title'));
//$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('style_submit_button', 'SubmitGlossary', get_lang('TermAddButton'), 'class="save"');
// setting the rules
$form->addRule('glossary_title',get_lang('ThisFieldIsRequired'), 'required');
// The validation or display
if ($form->validate()) {
$check = Security::check_token('post');
if ($check) {
$values = $form->exportValues();
GlossaryManager::save_glossary($values);
}
Security::clear_token();
GlossaryManager::display_glossary();
} else {
$token = Security::get_token();
$form->addElement('hidden','sec_token');
$form->setConstants(array('sec_token' => $token));
$form->display();
}
} else if (isset($_GET['action']) && $_GET['action'] == 'edit_glossary' && is_numeric($_GET['glossary_id'])) { // Editing a glossary
// 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']));
// settting the form elements
$form->addElement('header', '', get_lang('TermEdit'));
$form->addElement('hidden', 'glossary_id');
$form->addElement('text', 'glossary_title', get_lang('TermName'),array('size'=>'100'));
//$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('style_submit_button', 'SubmitGlossary', get_lang('TermUpdateButton'), 'class="save"');
// setting the defaults
$defaults = GlossaryManager::get_glossary_information(Security::remove_XSS($_GET['glossary_id']));
$form->setDefaults($defaults);
// setting the rules
$form->addRule('glossary_title', '<div class="required">'.get_lang('ThisFieldIsRequired'), 'required');
// The validation or display
if ($form->validate()) {
$check = Security::check_token('post');
if ($check) {
$values = $form->exportValues();
GlossaryManager::update_glossary($values);
}
Security::clear_token();
GlossaryManager::display_glossary();
} else {
$token = Security::get_token();
$form->addElement('hidden', 'sec_token');
$form->setConstants(array('sec_token' => $token));
$form->display();
}
} 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::display_glossary();
} 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::display_glossary();
} 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::display_glossary();
} else {
GlossaryManager::display_glossary();
}
} else {
GlossaryManager::display_glossary();
GlossaryManager::display_glossary();
}
// footer
// Footer
Display::display_footer();
Loading…
Cancel
Save