[svn r14612] search the forum

+ cleanup some mess (comments, double include of global.inc.php, ....
skala
Patrick Cool 18 years ago
parent 1a2da7b797
commit 955e5c985f
  1. 108
      main/forum/forumfunction.inc.php
  2. 30
      main/forum/index.php
  3. 31
      main/forum/newthread.php
  4. 31
      main/forum/reply.php
  5. 29
      main/forum/viewforum.php
  6. 30
      main/forum/viewforumcategory.php
  7. 19
      main/forum/viewthread.php

@ -2398,7 +2398,6 @@ function send_mail($user_info=array(), $thread_information=array())
if (isset($thread_information) and is_array($thread_information))
{
$thread_link= api_get_path('WEB_CODE_PATH').'forum/viewthread.php?'.api_get_cidreq().'&forum='.$thread_information['forum_id'].'&thread='.$thread_information['thread_id'];
//http://157.193.57.110/dokeos_cvs/claroline/forum/viewthread.php?forum=12&thread=49
}
$email_body= $user_info['firstname']." ".$user_info['lastname']."\n\r";
$email_body .= '['.$_course['official_code'].'] - ['.$_course['name']."]<br>\n";
@ -2651,4 +2650,111 @@ function prepare4display($input='')
}
}
/**
* Display the search form for the forum and display the search results
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @version march 2008, dokeos 1.8.5
*/
function forum_search()
{
// initiate the object
$form = new FormValidator('forumsearch');
// settting the form elements
$form->addElement('header', '', get_lang('ForumSearch'));
$form->addElement('text', 'search_term', get_lang('SearchTerm'),'class="input_titles"');
$form->addElement('submit', 'SubmitForumCategory', get_lang('Search'));
// setting the rules
$form->addRule('search_term', '<div class="required">'.get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('search_term', get_lang('TooShort'),'minlength',3);
// The validation or display
if( $form->validate() )
{
$values = $form->exportValues();
$form->setDefaults($values);
$form->display();
// display the search results
display_forum_search_results($values['search_term']);
}
else
{
$form->display();
}
}
/**
* Display the search results
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @version march 2008, dokeos 1.8.5
*/
function display_forum_search_results($search_term)
{
global $table_categories, $table_forums, $table_threads, $table_posts;
$sql = "SELECT * FROM $table_posts posts
WHERE posts.post_title LIKE '%".Database::escape_string($search_term)."%'
OR posts.post_text LIKE '%".Database::escape_string($search_term)."%'
/*AND posts.thread_id = threads.thread_id*/
GROUP BY posts.post_id";
// getting all the information of the forum categories
$forum_categories_list=get_forum_categories();
// getting all the information of the forums
$forum_list=get_forums();
$result = api_sql_query($sql, __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
$display_result = false;
/*
we only show it when
1. forum cateogory is visible
2. forum is visible
3. thread is visible (to do)
4. post is visible
*/
if (!api_is_allowed_to_edit())
{
if ($forum_categories_list[$row['forum_id']['forum_category']]['visibility'] == '1' AND $forum_list[$row['forum_id']]['visibility'] == '1' AND $row['visible'] == '1')
{
$display_result = true;
}
}
else
{
$display_result = true;
}
if ($display_result == true)
{
$search_results_item = '<li><a href="viewforumcategory.php?forumcategory='.$forum_list[$row['forum_id']]['forum_category'].'">'.$forum_categories_list[$row['forum_id']['forum_category']]['cat_title'].'</a> > ';
$search_results_item .= '<a href="viewforum.php?forum='.$row['forum_id'].'">'.$forum_list[$row['forum_id']]['forum_title'].'</a> > ';
//$search_results_item .= '<a href="">THREAD</a> > ';
$search_results_item .= '<a href="viewthread.php?forum='.$row['forum_id'].'&amp;thread='.$row['thread_id'].'">'.$row['post_title'].'</a>';
$search_results_item .= '<br />';
if (strlen($row['post_title']) > 200 )
{
$search_results_item .= substr(strip_tags($row['post_title']),0,200).'...';
}
else
{
$search_results_item .= $row['post_title'];
}
$search_results_item .= '</li>';
$search_results[] = $search_results_item;
}
}
echo '<div class="row"><div class="form_header">'.count($search_results).' '.get_lang('ForumSearchResults').'</div></div>';
echo '<ol>';
echo implode($search_results);
echo '</ol>';
}
?>

@ -42,32 +42,6 @@
* @package dokeos.forum
*/
/**
**************************************************************************
* IMPORTANT NOTICE
* Please do not change anything is this code yet because there are still
* some significant code that need to happen and I do not have the time to
* merge files and test it all over again. So for the moment, please do not
* touch the code
* -- Patrick Cool <patrick.cool@UGent.be>
**************************************************************************
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
include('../inc/global.inc.php');
$this_section=SECTION_COURSES;
/* ------------ ACCESS RIGHTS ------------ */
// notice for unauthorized people.
api_protect_course_script(true);
/*
-----------------------------------------------------------
Language Initialisation
-----------------------------------------------------------
*/
// name of the language file that needs to be included
$language_file = 'forum';
@ -77,6 +51,9 @@ require ('../inc/global.inc.php');
// the section (tabs)
$this_section=SECTION_COURSES;
// notice 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');
@ -177,6 +154,7 @@ if(is_array($all_groups))
------------------------------------------------------------------------------------------------------
*/
//if (api_is_allowed_to_edit() and !$_GET['action'])
echo '<span style="float:right;"><a href="forumsearch.php?'.api_get_cidreq().'&action=search"> '.Display::return_icon('search.gif').' '.get_lang('Search').'</a></span>';
if (api_is_allowed_to_edit())
{
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=add&amp;content=forumcategory"> '.Display::return_icon('forum_category_new.gif').' '.get_lang('AddForumCategory').'</a> ';

@ -42,34 +42,6 @@
* @package dokeos.forum
*/
/**
**************************************************************************
* IMPORTANT NOTICE
* Please do not change anything is this code yet because there are still
* some significant code that need to happen and I do not have the time to
* merge files and test it all over again. So for the moment, please do not
* touch the code
* -- Patrick Cool <patrick.cool@UGent.be>
**************************************************************************
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
include('../inc/global.inc.php');
$this_section=SECTION_COURSES;
/* ------------ ACCESS RIGHTS ------------ */
// notice for unauthorized people.
api_protect_course_script(true);
/*
-----------------------------------------------------------
Language Initialisation
-----------------------------------------------------------
*/
// name of the language file that needs to be included
$language_file = 'forum';
@ -79,6 +51,9 @@ require ('../inc/global.inc.php');
// the section (tabs)
$this_section=SECTION_COURSES;
// notice 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');

@ -42,34 +42,6 @@
* @package dokeos.forum
*/
/**
**************************************************************************
* IMPORTANT NOTICE
* Please do not change anything is this code yet because there are still
* some significant code that need to happen and I do not have the time to
* merge files and test it all over again. So for the moment, please do not
* touch the code
* -- Patrick Cool <patrick.cool@UGent.be>
**************************************************************************
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
include('../inc/global.inc.php');
$this_section=SECTION_COURSES;
/* ------------ ACCESS RIGHTS ------------ */
// notice for unauthorized people.
api_protect_course_script(true);
/*
-----------------------------------------------------------
Language Initialisation
-----------------------------------------------------------
*/
// name of the language file that needs to be included
$language_file = 'forum';
@ -79,6 +51,9 @@ require ('../inc/global.inc.php');
// the section (tabs)
$this_section=SECTION_COURSES;
// notice for unauthorized people.
api_protect_course_script(true);
// configuration for FCKeditor
$fck_attribute['Width'] = '100%';
$fck_attribute['Height'] = '300';

@ -42,38 +42,14 @@
* @package dokeos.forum
*/
/**
**************************************************************************
* IMPORTANT NOTICE
* Please do not change anything is this code yet because there are still
* some significant code that need to happen and I do not have the time to
* merge files and test it all over again. So for the moment, please do not
* touch the code
* -- Patrick Cool <patrick.cool@UGent.be>
**************************************************************************
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
include('../inc/global.inc.php');
$this_section=SECTION_COURSES;
/* ------------ ACCESS RIGHTS ------------ */
// notice for unauthorized people.
api_protect_course_script(true);
/*
-----------------------------------------------------------
Language Initialisation
-----------------------------------------------------------
*/
// name of the language file that needs to be included
$language_file = 'forum';
// including the global dokeos file
require ('../inc/global.inc.php');
// notice for unauthorized people.
api_protect_course_script(true);
// the section (tabs)
$this_section=SECTION_COURSES;
@ -194,6 +170,7 @@ if (isset($message))
Action Links
-----------------------------------------------------------
*/
echo '<span style="float:right;"><a href="forumsearch.php?'.api_get_cidreq().'&action=search"> '.Display::return_icon('search.gif').' '.get_lang('Search').'</a></span>';
// The link should appear when
// 1. the course admin is here
// 2. the course member is here and new threads are allowed

@ -42,32 +42,6 @@
* @package dokeos.forum
*/
/**
**************************************************************************
* IMPORTANT NOTICE
* Please do not change anything is this code yet because there are still
* some significant code that need to happen and I do not have the time to
* merge files and test it all over again. So for the moment, please do not
* touch the code
* -- Patrick Cool <patrick.cool@UGent.be>
**************************************************************************
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
include('../inc/global.inc.php');
$this_section=SECTION_COURSES;
/* ------------ ACCESS RIGHTS ------------ */
// notice for unauthorized people.
api_protect_course_script(true);
/*
-----------------------------------------------------------
Language Initialisation
-----------------------------------------------------------
*/
// name of the language file that needs to be included
$language_file = 'forum';
@ -77,6 +51,9 @@ require ('../inc/global.inc.php');
// the section (tabs)
$this_section=SECTION_COURSES;
// notice 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');
@ -178,6 +155,7 @@ $groups_of_user=GroupManager::get_group_ids($_course['dbName'], $_user['user_id'
Action Links
-----------------------------------------------------------
*/
echo '<span style="float:right;"><a href="forumsearch.php?'.api_get_cidreq().'&action=search"> '.Display::return_icon('search.gif').' '.get_lang('Search').'</a></span>';
if (api_is_allowed_to_edit())
{
//echo '<a href="'.api_get_self().'?forumcategory='.$_GET['forumcategory'].'&amp;action=add&amp;content=forumcategory">'.get_lang('AddForumCategory').'</a> | ';

@ -53,22 +53,6 @@
**************************************************************************
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
include('../inc/global.inc.php');
$this_section=SECTION_COURSES;
/* ------------ ACCESS RIGHTS ------------ */
// notice for unauthorized people.
api_protect_course_script(true);
/*
-----------------------------------------------------------
Language Initialisation
-----------------------------------------------------------
*/
// name of the language file that needs to be included
$language_file = 'forum';
@ -78,6 +62,9 @@ require ('../inc/global.inc.php');
// the section (tabs)
$this_section=SECTION_COURSES;
// notice 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');

Loading…
Cancel
Save