dokeos-admin
[ class tree: dokeos-admin ] [ index: dokeos-admin ] [ all elements ]

Source for file class_list.php

Documentation is available at class_list.php

  1. <?php
  2. // $Id: class_list.php 14209 2008-01-30 23:16:20Z yannoo $
  3. /*
  4. ==============================================================================
  5.     Dokeos - elearning and course management software
  6.  
  7.     Copyright (c) 2004 Dokeos S.A.
  8.     Copyright (c) 2003 Ghent University (UGent)
  9.     Copyright (c) 2001 Universite catholique de Louvain (UCL)
  10.     Copyright (c) Olivier Brouckaert
  11.  
  12.     For a full list of contributors, see "credits.txt".
  13.     The full license can be read in "license.txt".
  14.  
  15.     This program is free software; you can redistribute it and/or
  16.     modify it under the terms of the GNU General Public License
  17.     as published by the Free Software Foundation; either version 2
  18.     of the License, or (at your option) any later version.
  19.  
  20.     See the GNU General Public License for more details.
  21.  
  22.     Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  23. ==============================================================================
  24. */
  25. /**
  26. ==============================================================================
  27. *    @package dokeos.admin
  28. ==============================================================================
  29. */
  30.  
  31. // name of the language file that needs to be included 
  32. $language_file 'admin';
  33. $cidReset true;
  34. require ('../inc/global.inc.php');
  35. $this_section SECTION_PLATFORM_ADMIN;
  36.  
  37. /**
  38.  * Gets the total number of classes
  39.  */
  40. {
  41.     $tbl_class Database :: get_main_table(TABLE_MAIN_CLASS);
  42.     $sql "SELECT COUNT(*) AS number_of_classes FROM $tbl_class";
  43.     if (isset ($_GET['keyword']))
  44.     {
  45.         $sql .= " WHERE (name LIKE '%".Database::escape_string(trim($_GET['keyword']))."%')";
  46.     }
  47.     $res api_sql_query($sql__FILE____LINE__);
  48.     $obj Database::fetch_object($res);
  49.     return $obj->number_of_classes;
  50. }
  51. /**
  52.  * Gets the information about some classes
  53.  * @param int $from 
  54.  * @param int $number_of_items 
  55.  * @param string $direction 
  56.  */
  57. function get_class_data($from$number_of_items$column$direction)
  58. {
  59.     $tbl_class_user Database :: get_main_table(TABLE_MAIN_CLASS_USER);
  60.     $tbl_class Database :: get_main_table(TABLE_MAIN_CLASS);
  61.     $from                 Database::escape_string($from);
  62.     $number_of_items     Database::escape_string($number_of_items);
  63.     $column             Database::escape_string($column);
  64.     $direction             Database::escape_string($direction);
  65.     
  66.     $sql "SELECT     id AS col0, name AS col1, COUNT(user_id) AS col2, id AS col3
  67.                 FROM $tbl_class
  68.                 LEFT JOIN $tbl_class_user ON id=class_id ";
  69.     if (isset ($_GET['keyword']))
  70.     {
  71.         $sql .= " WHERE (name LIKE '%".Database::escape_string(trim($_GET['keyword']))."%')";
  72.     }
  73.     $sql .= "GROUP BY id,name ORDER BY col$column $direction LIMIT $from,$number_of_items";
  74.     $res api_sql_query($sql__FILE____LINE__);
  75.     $classes array ();
  76.     while ($class Database::fetch_row($res))
  77.     {
  78.         $classes[$class;
  79.     }
  80.     return $classes;
  81. }
  82. /**
  83.  * Filter for sortable table to display edit icons for class
  84.  */
  85. function modify_filter($class_id)
  86. {
  87.     global $charset;
  88.     $class_id Security::remove_XSS($class_id);
  89.     $result '<a href="class_information.php?id='.$class_id.'"><img src="../img/synthese_view.gif" border="0" title="'.get_lang('Info').'" alt="'.get_lang('Info').'"/></a>';
  90.     $result .= '<a href="class_edit.php?idclass='.$class_id.'"><img src="../img/edit.gif" border="0" title="'.get_lang('Edit').'" alt="'.get_lang('Edit').'"/></a>';
  91.     $result .= '<a href="class_list.php?action=delete_class&amp;class_id='.$class_id.'" onclick="javascript:if(!confirm('."'".addslashes(htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."'".')) return false;"><img src="../img/delete.gif" border="0" title="'.get_lang('Delete').'" alt="'.get_lang('Delete').'"/></a>';
  92.     $result .= '<a href="subscribe_user2class.php?idclass='.$class_id.'"><img src="../img/add_multiple_users.gif" border="0" alt="'.get_lang('AddUsersToAClass').'" title="'.get_lang('AddUsersToAClass').'"/></a>';
  93.     return $result;
  94. }
  95.  
  96. require (api_get_path(LIBRARY_PATH).'fileManage.lib.php');
  97. require (api_get_path(LIBRARY_PATH).'classmanager.lib.php');
  98. require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  99. $tool_name get_lang('ClassList');
  100. $interbreadcrumb[array ("url" => 'index.php'"name" => get_lang('PlatformAdmin'));
  101.  
  102. Display :: display_header($tool_name);
  103. //api_display_tool_title($tool_name);
  104. if (isset ($_POST['action']))
  105. {
  106.     switch ($_POST['action'])
  107.     {
  108.         // Delete selected classes
  109.         case 'delete_classes' :
  110.             $classes $_POST['class'];
  111.             if (count($classes0)
  112.             {
  113.                 foreach ($classes as $index => $class_id)
  114.                 {
  115.                     ClassManager :: delete_class($class_id);
  116.                 }
  117.                 Display :: display_normal_message(get_lang('ClassesDeleted'));
  118.             }
  119.             break;
  120.     }
  121. }
  122. if (isset ($_GET['action']))
  123. {
  124.     switch ($_GET['action'])
  125.     {
  126.         case 'delete_class' :
  127.             ClassManager :: delete_class($_GET['class_id']);
  128.             Display :: display_normal_message(get_lang('ClassDeleted'));
  129.     }
  130. }
  131. // Create a search-box
  132. $form new FormValidator('search_simple','get','','',null,false);
  133. $renderer =$form->defaultRenderer();
  134. $renderer->setElementTemplate('<span>{element}</span> ');
  135. $form->addElement('text','keyword',get_lang('keyword'));
  136. $form->addElement('submit','submit',get_lang('Search'));
  137. $form->display();
  138. // Create the sortable table with class information
  139. $table new SortableTable('classes''get_number_of_classes''get_class_data'1);
  140. $table->set_additional_parameters(array('keyword'=>$_GET['keyword']));
  141. $table->set_header(0''false);
  142. $table->set_header(1get_lang('ClassName'));
  143. $table->set_header(2get_lang('NumberOfUsers'));
  144. $table->set_header(3''false);
  145. $table->set_column_filter(3'modify_filter');
  146. $table->set_form_actions(array ('delete_classes' => get_lang('DeleteSelectedClasses')),'class');
  147. $table->display();
  148. /*
  149. ==============================================================================
  150.         FOOTER
  151. ==============================================================================
  152. */
  153. ?>

Documentation generated on Thu, 12 Jun 2008 13:07:53 -0500 by phpDocumentor 1.4.1