groups.php 1.74 KB
Newer Older
1
2
3
4
5
6
<?php
/**
 *
 * @package    mahara
 * @subpackage admin
 * @author     Catalyst IT Ltd
7
8
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
9
10
11
12
13
14
15
 *
 */

define('INTERNAL', 1);
define('ADMIN', 1);
define('MENUITEM', 'managegroups/groups');

16
17
18
19
20
21
22
23
24
require(dirname(dirname(dirname(__FILE__))) . '/init.php');

define('TITLE', get_string('administergroups', 'admin'));

require_once('group.php');
require_once('searchlib.php');

$query = param_variable('query', '');
$offset = param_integer('offset', 0);
25
26
27
$limit = 10;

$data = build_grouplist_html($query, $limit, $offset);
28
29
30
31
32
33
34
35
36

$searchform = pieform(array(
    'name'   => 'search',
    'renderer' => 'oneline',
    'elements' => array(
        'query' => array(
            'type' => 'text',
            'defaultvalue' => $query,
        ),
37
        'submit' => array(
38
39
40
41
42
43
            'type' => 'submit',
            'value' => get_string('search'),
        ),
    ),
));

44
45
46
47
48
49
50
51
52
53
54
$js = <<< EOF
addLoadEvent(function () {
p = {$data['pagination_js']}
connect('search_submit', 'onclick', function (event) {
    replaceChildNodes('messages');
    var params = {'query': $('search_query').value};
    p.sendQuery(params);
    event.stop();
    });
});
EOF;
55

56
$smarty = smarty(array('paginator'));
57
$smarty->assign('PAGEHEADING', TITLE);
58
$smarty->assign('INLINEJAVASCRIPT', $js);
59
$smarty->assign('searchform', $searchform);
60
$smarty->assign('results', $data);
61
62
$smarty->display('admin/groups/groups.tpl');

63
function search_submit(Pieform $form, $values) {
64
    redirect(get_config('wwwroot') . 'admin/groups/groups.php' . ((isset($values['query']) && ($values['query'] != '')) ? '?query=' . urlencode($values['query']) : ''));
65
}