search.json.php 2.16 KB
Newer Older
Martyn Smith's avatar
Martyn Smith committed
1
2
<?php
/**
Francois Marier's avatar
Francois Marier committed
3
 * Mahara: Electronic portfolio, weblog, resume builder and social networking
4
5
 * Copyright (C) 2006-2009 Catalyst IT Ltd and others; see:
 *                         http://wiki.mahara.org/Contributors
Martyn Smith's avatar
Martyn Smith committed
6
 *
Francois Marier's avatar
Francois Marier committed
7
8
9
10
 * 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 3 of the License, or
 * (at your option) any later version.
Martyn Smith's avatar
Martyn Smith committed
11
 *
Francois Marier's avatar
Francois Marier committed
12
13
14
15
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
Martyn Smith's avatar
Martyn Smith committed
16
 *
Francois Marier's avatar
Francois Marier committed
17
18
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
Martyn Smith's avatar
Martyn Smith committed
19
20
21
 *
 * @package    mahara
 * @subpackage core
22
 * @author     Catalyst IT Ltd
Martyn Smith's avatar
Martyn Smith committed
23
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
24
 * @copyright  (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
Martyn Smith's avatar
Martyn Smith committed
25
26
27
28
 *
 */

define('INTERNAL', 1);
Martyn Smith's avatar
Martyn Smith committed
29
define('JSON', 1);
30
define('INSTITUTIONALADMIN', 1);
Martyn Smith's avatar
Martyn Smith committed
31
32
33
34
35
36

require(dirname(dirname(dirname(__FILE__))) . '/init.php');

$action = param_variable('action');

if ($action == 'search') {
37
    require_once('searchlib.php');
Martyn Smith's avatar
Martyn Smith committed
38

39
    $params = new StdClass;
40
    $params->query       = trim(param_variable('query', ''));
41
    $params->institution = param_alphanum('institution', null);
42
43
    $params->f           = param_alpha('f', null);
    $params->l           = param_alpha('l', null);
44
    $params->institution_requested = param_alphanum('institution_requested', null);
45
46
47
48
49

    $offset  = param_integer('offset', 0);
    $limit   = param_integer('limit', 10);
    $sortby  = param_alpha('sortby', 'firstname');
    $sortdir = param_alpha('sortdir', 'asc');
Martyn Smith's avatar
Martyn Smith committed
50
51

    json_headers();
52
53
54
55
56
    if (param_boolean('raw', false)) {
        $data = get_admin_user_search_results($params, $offset, $limit, $sortby, $sortdir);
    } else {
        $data['data'] = build_admin_user_search_results($params, $offset, $limit, $sortby, $sortdir);
    }
Martyn Smith's avatar
Martyn Smith committed
57
    $data['error'] = false;
58
    $data['message'] = null;
Martyn Smith's avatar
Martyn Smith committed
59
60
61
62
63
    echo json_encode($data);
    exit;
}

?>