<?php
// $Id: course_list.php,v 1.15 2005/07/01 11:53:21 olivierb78 Exp $
/*
==============================================================================
        Dokeos - elearning and course management software

        Copyright (c) 2004 Dokeos S.A.
        Copyright (c) 2003 University of Ghent (UGent)
        Copyright (c) 2001 Universite catholique de Louvain (UCL)
        Copyright (c) Olivier Brouckaert

        For a full list of contributors, see "credits.txt".
        The full license can be read in "license.txt".

        This program is free software; you can redistribute it and/or
        modify it under the terms of the GNU General Public License
        as published by the Free Software Foundation; either version 2
        of the License, or (at your option) any later version.

        See the GNU General Public License for more details.

        Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/**
==============================================================================
        @author Bart Mollet
*        @package dokeos.admin
==============================================================================
*/
/*
==============================================================================
                INIT SECTION
==============================================================================
*/
$langFile = 'admin';
$cidReset = true;
require ('../inc/claro_init_global.inc.php');
//api_protect_admin_script();
require_once (api_get_library_path()."/course.lib.php");
//if (isset ($_POST['action']))
{

        $tool_name = get_lang('SearchACourse');
        Display :: display_header($tool_name);
        api_display_tool_title($tool_name);
?>
                <form method="get" action="course_search.php">
        <table>
        <tr>
        <td>


        <?php


}
//else
{

        if (isset ($_GET['delete_course']))
        {
                CourseManager :: delete_course($_GET['delete_course']);
        }
?>
        <form method="get" action="course_search.php">

        <input type="text" name="keyword" value="<?php echo $_GET['keyword']; ?>"/>
        <input type="submit" value="<?php echo get_lang('Search'); ?>"/>

        </form>
        Par Titre, code ou enseignant.
<?php

        $course_table = Database :: get_main_table(MAIN_COURSE_TABLE);

        if (isset ($_GET['keyword']))
        {
                $keyword = addslashes($_GET['keyword']);

                $sql = "SELECT * FROM ".$course_table." WHERE title LIKE '%".$keyword."%'OR tutor_name LIKE '%".$keyword."%' OR code LIKE '%".$keyword."%'AND visibility ='3'";

                $parameters = array ('keyword' => $_GET['keyword']);

        }
        elseif (isset ($_GET['keyword_title']))
        {
                $keyword_title = addslashes($_GET['keyword_title']);
                $keyword_code = addslashes($_GET['keyword_code']);
                $keyword_category = addslashes($_GET['keyword_category']);
                $keyword_category = addslashes($_GET['keyword_tutor_name']);
                //$keyword_language = addslashes($_GET['keyword_language']);
                $keyword_visibility = addslashes($_GET['keyword_visibility']);
                $keyword_subscribe = addslashes($_GET['keyword_subscribe']);
                $keyword_unsubscribe = addslashes($_GET['keyword_unsubscribe']);
                $sql = "SELECT * FROM ".$course_table."WHERE title LIKE '%".$keyword_title."%' AND code LIKE '%".$keyword_code."%' AND category_code LIKE '%".$keyword_category."%' AND tutor_name LIKE '%".$keyword."%'AND  visibility ='3'";
                $parameters['keyword_title'] = $_GET['keyword_title'];
                $parameters['keyword_code'] = $_GET['keyword_code'];
                $parameters['keyword_category'] = $_GET['keyword_category'];
                $parameters['keyword_tutor_name'] = $_GET['keyword_tutor_name'];
                $parameters['keyword_visibility'] = $_GET['keyword_visibility'];
                $parameters['keyword_subscribe'] = $_GET['keyword_subscribe'];
                $parameters['keyword_unsubscribe'] = $_GET['keyword_unsubscribe'];
        }
        else
        {
                $sql = "SELECT * FROM $course_table WHERE visibility ='3' ";
                $parameters = array ();
        }
        $res = api_sql_query($sql,__FILE__,__LINE__);
        if (mysql_num_rows($res) > 0)
        {
                $courses = array ();
                while ($obj = mysql_fetch_object($res))
                {
                        $course = array ();
                        //$course[] = '<input type="checkbox" name="course[]" value="'.$obj->code.'"/>';
                        $course[] = $obj->code;
                        $course[] = $obj->title;
                        //$course[] = $obj->description;
                        $course[] = $obj->tutor_name;
                        //$course[] = $obj->course_language;
                        $course[] = $obj->category_code;
                        $course[] = $obj->subscribe == SUBSCRIBE_ALLOWED ? get_lang('Yes') : get_lang('No');
                        //$course[] = $obj->visibility ==3;

                        //$course[] = $obj->unsubscribe == UNSUBSCRIBE_ALLOWED ? get_lang('Yes') : get_lang('No');
                        //$course[] = CourseManager :: is_virtual_course_from_system_code($obj->code) ? get_lang('Yes') : get_lang('No');
                        $course[] = '<a href="'.api_get_path(WEB_COURSE_PATH).$obj->directory.'"><img src="../img/home_small.gif" border="0" align="absmiddle"></a>';
                        $courses[] = $course;
                }
                //$table_header[] = array (' ', false);
                $table_header[] = array (get_lang('Code'), true);
                $table_header[] = array (get_lang('Title'), true);
                //$table_header[] = array (get_lang('Description'), true);
                 $table_header[] = array (get_lang('Teacher'), true);
                //$table_header[] = array (get_lang('Language'), true);
                $table_header[] = array (get_lang('Category'), true);
                $table_header[] = array (get_lang('SubscriptionAllowed'), true);
                //$table_header[] = array (get_lang('keyword_visibility'), true);

                $table_header[] = array (get_lang('HomepageViewTitle'), true);
                //$table_header[] = array (get_lang("IsVirtualCourse"), true, '');
                //$table_header[] = array ('', false);
                echo '<form method="post" action="course_search.php">';
                Display :: display_sortable_table($table_header, $courses, array (), array (), $parameters);
                //echo '<select name="action">';
              //echo '<option value="delete_courses">'.get_lang('DeleteCourse').'</option>';
                //echo '</select>';
               // echo '<input type="submit" value="'.get_lang('Ok').'" onclick="javascript:if(!confirm('."'".addslashes(htmlspecialchars(get_lang("ConfirmYourChoice")))."'".')) return false;"/>';
                //echo '</form>';
        }
        else
        {
                echo get_lang('NoSearchResults');
        }
}
/*
==============================================================================
                FOOTER
==============================================================================
*/
Display :: display_footer();
?>




