Newer
Older
<?php
include_once("include/db.php");
function getAdminRealms($params) {
# Filters and sorts are the same here
$filtersorts = array(
'ID' => 'realms.ID',
'Name' => 'realms.Name',
'Disabled' => 'realms.Disabled'
);
$res = DBSelectSearch("SELECT ID, Name, Disabled FROM realms",$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;
}
while ($row = $sth->fetchObject()) {
$item = array();
$item['Name'] = htmlspecialchars($row->name);
return array($resultArray,$numResults);
# Return specific realm row
function getAdminRealm($params) {
$res = DBSelect("SELECT ID, Name, Disabled FROM realms WHERE ID = ?",array($params[0]));
if (!is_object($res)) {
return $res;
}
$resultArray = array();
$row = $res->fetchObject();
$resultArray['ID'] = $row->id;
$resultArray['Name'] = htmlspecialchars($row->name);
$resultArray['Disabled'] = $row->disabled;
return $resultArray;
}
# Remove admin realm
function removeAdminRealm($params) {
# Begin transaction
DBBegin();
$res = DBDo("DELETE FROM realm_attributes WHERE RealmID = ?",array($params[0]));
if ($res !== FALSE) {
$res = DBDo("DELETE FROM realms WHERE ID = ?",array($params[0]));
}
# Commit and return if successful
# Else rollback database
} else {
DBRollback();
}
return NULL;
}
# Add admin realm
function createAdminRealm($params) {
$res = DBDo("INSERT INTO realms (Name) VALUES (?)",array($params[0]['Name']));
return $res;
}
return NULL;
}
# Edit admin realm
function updateAdminRealm($params) {
$res = DBDo("UPDATE realms SET Name = ? WHERE ID = ?",array($params[0]['Name'],$params[0]['ID']));
return $res;
}
return NULL;
}