Newer
Older
<?php
include_once("include/db.php");
function addAdminRealmAttribute($params) {
$res = DBDo("
INSERT INTO
realm_attributes (RealmID,Name,Operator,Value,Disabled)
VALUES
(?,?,?,?,?)",
array( $params[0]['RealmID'],
$params[0]['Name'],
$params[0]['Operator'],
$params[0]['Value'],
$params[0]['Disabled'])
);
# Return result
if (is_bool($res)) {
return $res;
}
return NULL;
}
function removeAdminRealmAttribute($params) {
$res = DBDo("DELETE FROM realm_attributes WHERE ID = ?",array($params[0]));
# Return result
if (is_bool($res)) {
return $res;
}
return NULL;
}
function updateAdminRealmAttribute($params) {
$res = DBDo("UPDATE realm_attributes SET Name = ?, Operator = ?, Value = ?, Disabled = ? WHERE ID = ?",
array($params[0]['Name'],
$params[0]['Operator'],
$params[0]['Value'],
$params[0]['Disabled'],
$params[0]['ID'])
);
# Return result
if (is_bool($res)) {
return $res;
}
return NULL;
}
# Return specific attribute row
function getAdminRealmAttribute($params) {
$res = DBSelect("SELECT ID, Name, Operator, Value, Disabled 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;
$resultArray['Operator'] = $row->operator;
$resultArray['Value'] = $row->value;
$resultArray['Disabled'] = $row->disabled;
return $resultArray;
}
# Return list of attributes
function getAdminRealmAttributes($params) {
# 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();
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;
array_push($resultArray,$item);
}
return array($resultArray,$numResults);
}