'.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
, 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 = ''.$forum_categories_list[$row['forum_id']['forum_category']]['cat_title'].' > ';
+ $search_results_item .= ''.$forum_list[$row['forum_id']]['forum_title'].' > ';
+ //$search_results_item .= 'THREAD > ';
+ $search_results_item .= ''.$row['post_title'].'';
+ $search_results_item .= '
';
+ 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 .= '';
+
+
+
+ $search_results[] = $search_results_item;
+ }
+ }
+ echo '';
+ echo '';
+ echo implode($search_results);
+ echo '
';
+}
?>
\ No newline at end of file
diff --git a/main/forum/index.php b/main/forum/index.php
index 3585434288..97cd1565ca 100644
--- a/main/forum/index.php
+++ b/main/forum/index.php
@@ -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
- **************************************************************************
- */
-
-/*
-==============================================================================
- 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 ' '.Display::return_icon('search.gif').' '.get_lang('Search').'';
if (api_is_allowed_to_edit())
{
echo ' '.Display::return_icon('forum_category_new.gif').' '.get_lang('AddForumCategory').' ';
diff --git a/main/forum/newthread.php b/main/forum/newthread.php
index 60655fed3b..065f0cdc7a 100644
--- a/main/forum/newthread.php
+++ b/main/forum/newthread.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
- **************************************************************************
- */
-
-/*
-==============================================================================
- 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');
diff --git a/main/forum/reply.php b/main/forum/reply.php
index f127d81fe2..513211ed3e 100644
--- a/main/forum/reply.php
+++ b/main/forum/reply.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
- **************************************************************************
- */
-
-
-/*
-==============================================================================
- 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';
diff --git a/main/forum/viewforum.php b/main/forum/viewforum.php
index ba3782de2f..4c5f438b29 100644
--- a/main/forum/viewforum.php
+++ b/main/forum/viewforum.php
@@ -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
- **************************************************************************
- */
-
-/*
-==============================================================================
- 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 ' '.Display::return_icon('search.gif').' '.get_lang('Search').'';
// The link should appear when
// 1. the course admin is here
// 2. the course member is here and new threads are allowed
diff --git a/main/forum/viewforumcategory.php b/main/forum/viewforumcategory.php
index 12bc74ff77..85c4a3812a 100644
--- a/main/forum/viewforumcategory.php
+++ b/main/forum/viewforumcategory.php
@@ -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
- **************************************************************************
- */
-
-/*
-==============================================================================
- 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 ' '.Display::return_icon('search.gif').' '.get_lang('Search').'';
if (api_is_allowed_to_edit())
{
//echo ''.get_lang('AddForumCategory').' | ';
diff --git a/main/forum/viewthread.php b/main/forum/viewthread.php
index 1de487993c..c39116f5ea 100644
--- a/main/forum/viewthread.php
+++ b/main/forum/viewthread.php
@@ -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');