-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathorgadmin_check.php
75 lines (66 loc) · 2.4 KB
/
orgadmin_check.php
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle 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.
//
// Moodle 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.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Orgadmin filter
* @package block_vxg_orgs
* @copyright Veloxnet
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/user/filters/checkbox.php');
/**
* Filter based on organisation admins.
* @package block_vxg_orgs
* @copyright Veloxnet
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class block_vxg_orgs_orgadmin_check extends user_filter_checkbox
{
/**
* Retrieves data from the form data
*
* @param object $formdata data submited with the form
* @return mixed array filter data or false when filter not set
*/
public function check_data($formdata) {
$field = $this->_name;
// Check if disable if options are set. if yes then don't add this..
if (!empty($this->disableelements) && is_array($this->disableelements)) {
foreach ($this->disableelements as $disableelement) {
if (property_exists($formdata, $field)) {
return false;
}
}
}
if (property_exists($formdata, $field) and $formdata->$field !== '') {
return array('value' => (string)$formdata->$field, 'orgid' => $formdata->orgid);
}
return false;
}
/**
* Returns the condition to be used with SQL where
*
* @param array $data filter settings
* @return array sql string and $params
*/
public function get_sql_filter($data) {
$field = $this->field;
$sql = "id IN (SELECT userid
FROM {block_vxg_orgs_right} r
WHERE r.objecttype = 'org' AND objectid = {$data['orgid']})";
return array($sql, array());
}
}