diff options
-rwxr-xr-x | scire/.lib/DB_functions.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/scire/.lib/DB_functions.php b/scire/.lib/DB_functions.php index 3b1f1aa..3d806bb 100755 --- a/scire/.lib/DB_functions.php +++ b/scire/.lib/DB_functions.php @@ -76,6 +76,7 @@ function scire_add_client($clientid, $digest, $hostname, $mac, $ip, $profileid, #clientid, assetid, digest, cert, hostname, mac, ip, gli_profile, osid, status, contact, installtime if (!$installtime) {$installtime = "NOW()"; } global $db; + #we need to add the client to the axo table first and then to the clients $result = $db->insert('clients', array('clientid' => $clientid, 'digest' => $digest, 'hostname' => $hostname, 'mac' => $mac, 'ip' => $ip, 'gli_profile' => $profileid, 'osid' => $osid, 'contact' => $contact, 'status' => $status, 'installtime' => $installtime, 'assetid' => $assetid)); if ($result) { return true; @@ -400,6 +401,46 @@ function get_scire_jobs($orderby, $direction, $status='Pending') { } } +function get_scire_job($jobid) { + global $db; + # Falta el job history y el job clients + $result = $db->select('SELECT j.jobid, j.priority, j.script, j.description, u.username as creator, p.name as permission, jc.validity_period, jc.run_schedule ' . + 'FROM jobs AS j '. + 'JOIN users AS u ON (j.creator=u.userid) '. + 'LEFT JOIN job_conditions AS jc ON (j.jobid=jc.jobid) '. + 'LEFT JOIN permissions AS p ON (j.permission=p.permid)'); + if ($result && count($result) > 0) { + return $result[0]; + } else { + return false; + } +} + +function scire_edit_job($jobid, $fields) { + global $db; + $jobConditions = array(); + if (isset($fields["run_schedule"])) { + $jobConditions["run_schedule"] = $fields["run_schedule"]; + unset($fields["run_schedule"]); + } + if (isset($fields["validity_period"])) { + $jobConditions["validity_period"] = $fields["validity_period"]; + unset($fields["validity_period"]); + } + $result = $db->update('jobs', $fields, '`jobid` = \'' . $jobid . '\''); + + if (count($jobConditions) > 0) { + $result = $result && $db->update('job_conditions', $jobConditions, '`jobid` = \'' . $jobid . '\''); + } + + if ($result) { + return true; + } else { + return $db->error; + } +} + + function scire_add_script($name, $desc, $location, $script_data, $log_location, $success_code, $run_as, $priority, $permission, $pp_location, $pp_script_data) { global $db; $result = $db->insert('scripts', array('name' => $name, 'description' => $desc, 'location' => $location, 'script_data' => $script_data, 'log_location' => $log_location, 'success_code' => $success_code, 'run_as' => $run_as, 'priority' => $priority, 'permission' => $permission, 'pp_location' => $pp_location, 'pp_script_data' => $pp_script_data )); |