Newer
Older
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
include_once("include/db.php");
# Add user attribute
function addAdminRealmAttribute($params) {
global $db;
$res = DBDo("INSERT INTO realm_attributes (RealmID,Name) VALUES (?,?)",array($params[0]['RealmID'],$params[0]['Name']));
if (!is_numeric($res)) {
return $res;
}
return NULL;
}
# Remove user attribute
function removeAdminRealmAttribute($params) {
global $db;
$res = DBDo("DELETE FROM realm_attributes WHERE ID = ?",array($params[0]));
if (!is_numeric($res)) {
return $res;
}
return NULL;
}
# Edit attribute
function updateAdminRealmAttribute($params) {
global $db;
$res = DBDo("UPDATE realm_attributes SET Name = ? WHERE ID = ?",array($params[0]['Name'],$params[0]['ID']));
if (!is_numeric($res)) {
return $res;
}
return NULL;
}
# Return specific attribute row
function getAdminRealmAttribute($params) {
global $db;
$res = DBSelect("SELECT ID, Name FROM realm_attributes WHERE ID = ?",array($params[0]));
if (!is_object($res)) {
return $res;
}
$resultArray = array();
$row = $res->fetchObject();
$resultArray['ID'] = $row->id;
$resultArray['Name'] = $row->name;
return $resultArray;
}
# Return list of attributes
function getAdminRealmAttributes($params) {
global $db;
# Filters and sorts are the same here
$filtersorts = array(
'ID' => 'realm_attributes.ID',
'Name' => 'realm_attributes.Name',
'Operator' => 'realm_attributes.Operator',
'Value' => 'realm_attributes.Value',
'Disabled' => 'realm_attributes.Disabled'
);
$res = DBSelectSearch("
SELECT
ID, Name, Operator, Value, Disabled
FROM
realm_attributes
WHERE
RealmID = ".DBQuote($params[0])."
",$params[1],$filtersorts,$filtersorts);
$sth = $res[0]; $numResults = $res[1];
# If STH is blank, return the error back to whoever requested the data
if (!isset($sth)) {
return $res;
}
$resultArray = array();
# loop through rows
while ($row = $sth->fetchObject()) {
$item = array();
$item['ID'] = $row->id;
$item['Name'] = $row->name;
$item['Operator'] = $row->operator;
$item['Value'] = $row->value;
$item['Disabled'] = $row->disabled;
# push this row onto array
array_push($resultArray,$item);
}
return array($resultArray,$numResults);
}
?>