groups.php 2.2 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

$searchform = pieform(array(
    'name'   => 'search',
31
    'renderer' => 'div',
32
    'class' => 'form-inline mbl',
33
    'elements' => array(
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
        'inputgroup' => array(
            'type'  => 'fieldset',
            'title' => get_string('Query') . ': ',
            'class' => 'input-group form-inline',
            'elements'     => array(
                'query' => array(
                    'type'  => 'text',
                    'defaultvalue' => $query,
                ),
                'submit' => array(
                    'type'  => 'button',
                    'usebuttontag' => true,
                    'class' => 'btn btn-success input-group-btn',
                    'value' => get_string('search'),
                )
            ),
50
51
52
53
        ),
    ),
));

54
55
56
57
58
59
60
61
62
63
64
$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;
65

66
$smarty = smarty(array('paginator'));
67
68
setpageicon($smarty, 'icon-users');

69
$smarty->assign('PAGEHEADING', TITLE);
70
$smarty->assign('INLINEJAVASCRIPT', $js);
71
$smarty->assign('searchform', $searchform);
72
$smarty->assign('results', $data);
73
74
$smarty->display('admin/groups/groups.tpl');

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