summaryrefslogtreecommitdiff
path: root/scire
diff options
context:
space:
mode:
authorPreston Cody <codeman@gentoo.org>2007-06-16 17:44:09 +0000
committerPreston Cody <codeman@gentoo.org>2007-06-16 17:44:09 +0000
commitbc05f52ef6e5f0d8b155f6a17911e3c3aad2e8b6 (patch)
tree7da143505c882cab620ed0cc344f5e64d7317c42 /scire
parentcommitting some changes from Rodrigo Lazo for google SoC: (diff)
downloadscire-bc05f52ef6e5f0d8b155f6a17911e3c3aad2e8b6.tar.gz
scire-bc05f52ef6e5f0d8b155f6a17911e3c3aad2e8b6.tar.bz2
scire-bc05f52ef6e5f0d8b155f6a17911e3c3aad2e8b6.zip
some excellent updates from Rodrigo Lazo:
UI DB functions have been modified to work with the new job_status model. svn path=/; revision=220
Diffstat (limited to 'scire')
-rwxr-xr-xscire/.lib/DB_functions.php21
1 files changed, 16 insertions, 5 deletions
diff --git a/scire/.lib/DB_functions.php b/scire/.lib/DB_functions.php
index 0966e7d..3b1f1aa 100755
--- a/scire/.lib/DB_functions.php
+++ b/scire/.lib/DB_functions.php
@@ -45,16 +45,16 @@ function get_scire_clients($orderby, $direction, $status='Active') {
if ($status == "All") {
$where = ""; #Don't filter on status.
} elseif ($status) {
- $where = " WHERE c.status='$status' ";
+ $where = " WHERE cs.statusname='$status' ";
} else {
- $where = " WHERE c.status='Active' ";
+ $where = " WHERE cs.statusname='Active' ";
}
if ($orderby) {
$where .= "ORDER BY `$orderby` $direction";
} else {
$where .= '';
}
- $result = $db->select('SELECT c.clientid, c.assetid, c.digest, c.hostname, c.mac, c.ip, c.status, c.installtime, p.profile_name, o.osname, u.username FROM clients AS c LEFT JOIN GLI_profiles AS p ON (c.gli_profile=p.profileid) LEFT JOIN os AS o ON (c.osid=o.osid) LEFT JOIN users AS u ON (c.contact=u.userid) '.$where);
+ $result = $db->select('SELECT c.clientid, c.assetid, c.digest, c.hostname, c.mac, c.ip, cs.statusname as status, c.installtime, p.profile_name, o.osname, u.username FROM clients AS c LEFT JOIN GLI_profiles AS p ON (c.gli_profile=p.profileid) LEFT JOIN os AS o ON (c.osid=o.osid) LEFT JOIN users AS u ON (c.contact=u.userid) LEFT JOIN client_status AS cs ON (c.status=cs.statusid) '.$where);
if ($result && count($result) > 0) {
return $result;
} else {
@@ -86,6 +86,14 @@ function scire_add_client($clientid, $digest, $hostname, $mac, $ip, $profileid,
function scire_edit_client($clientid, $fields) {
global $db;
+ if (isset($fields['status'])) {
+ $res = $db->select(array('statusid'), 'client_status', '`statusname` = \'' . $fields['status'] . '\'');
+ var_dump($res);
+ if ($res && count($res)>0)
+ $fields['status'] = $res[0]['statusid'];
+ else
+ unset($fields['status']);
+ }
$result = $db->update('clients', $fields, "`clientid` = $clientid");
if ($result) {
return true;
@@ -298,8 +306,10 @@ function scire_add_setting($userid, $name, $value) {
function scire_approve_client($clientid) {
global $db;
$clientid = (int) $clientid;
+ $res = $db->select(array('statusid'), 'client_status', '`statusname` = \'Active\'');
+
if ($clientid) {
- $result = $db->update('clients',array('status' => "Active"), "`clientid` = '$clientid'");
+ $result = $db->update('clients',array('status' => $res[0]['statusid']), "`clientid` = '$clientid'");
if ($result) {
return true;
} else {
@@ -313,8 +323,9 @@ function scire_approve_client($clientid) {
function scire_reject_client($clientid) {
global $db;
if (int($clientid) != $clientid) {return false;}
+ $res = $db->select(array('statusid'), 'client_status', '`statusname` = \'Rejected\'');
- $result = $db->update('clients',array('status' => "Rejected"), "`clientid` = '$clientid'");
+ $result = $db->update('clients',array('status' => $res[0]['statusid']), "`clientid` = '$clientid'");
if ($result) {
return true;
} else {