-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathclass.ajax.php
More file actions
54 lines (42 loc) · 1.45 KB
/
class.ajax.php
File metadata and controls
54 lines (42 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/*********************************************************************
class.ajax.php
AjaxController class that is an extension of the ApiController class. It
will be used to provide functionality common to all Ajax API calls
Jared Hancock
Copyright (c) 2006-2013 osTicket
http://www.osticket.com
Released under the GNU General Public License WITHOUT ANY WARRANTY.
See LICENSE.TXT for details.
vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
require_once (INCLUDE_DIR.'class.api.php');
/**
* AjaxController Class
* A simple extension of the ApiController class that will assist in
* providing functionality common to all Ajax call controllers. Any Ajax
* call controller should inherit from this class in order to maintain
* consistency.
*/
class AjaxController extends ApiController {
function staffOnly() {
global $thisstaff;
if (!$thisstaff || !$thisstaff->isValid()) {
$this->exerr(401, sprintf('%s (%s)',
__('Access Denied'), $_SERVER['REMOTE_ADDR']));
}
return true;
}
/**
* Convert a PHP array into a JSON-encoded string
*/
function json_encode($what) {
return Format::json_encode($what);
}
function encode($what) {
return $this->json_encode($what);
}
function get($var, $default=null) {
return $_GET[$var] ?: $default;
}
}