diff options
author | 2008-01-16 02:46:18 +0000 | |
---|---|---|
committer | 2008-01-16 02:46:18 +0000 | |
commit | 8b242f0f19684d271cff0dfa4a5cf926615151b8 (patch) | |
tree | c75cc4d1fff120955509c23cee2efcd9be42ba18 | |
parent | adding calendar for use in setting the start and end ranges. (diff) | |
download | scire-8b242f0f19684d271cff0dfa4a5cf926615151b8.tar.gz scire-8b242f0f19684d271cff0dfa4a5cf926615151b8.tar.bz2 scire-8b242f0f19684d271cff0dfa4a5cf926615151b8.zip |
fixing up the jobs stuff. halfway there i'd say.
svn path=/trunk/; revision=352
-rwxr-xr-x | scire/.smarty/templates/add_job.tpl | 2 | ||||
-rw-r--r-- | scire/.smarty/templates/job.tpl | 6 | ||||
-rwxr-xr-x | scire/.smarty/templates/jobs.tpl | 2 | ||||
-rw-r--r-- | scire/job.php | 171 | ||||
-rwxr-xr-x | scire/jobs.php | 9 |
5 files changed, 88 insertions, 102 deletions
diff --git a/scire/.smarty/templates/add_job.tpl b/scire/.smarty/templates/add_job.tpl index 63c58f7..bee7e2f 100755 --- a/scire/.smarty/templates/add_job.tpl +++ b/scire/.smarty/templates/add_job.tpl @@ -345,7 +345,7 @@ Recurring stuff here. <b>You need to select all of them to get it to save the sc </table> <hr> Job dependency stuff here.<B>CODE ME</B><br> -Set notification email address: <input type="radio" name="notify_addr" value="{$useremail}">{$useremail}</input><input type="radio" name="notify_addr" value="new"><input type="text" name="notify_new"></input> +<!-- Set notification email address: <input type="radio" name="notify_addr" value="{$useremail}">{$useremail}</input><input type="radio" name="notify_addr" value="new"><input type="text" name="notify_new"></input> --> <input type="submit" name="ADD" value="ADD JOB!!!"> </form> {include file="footer.tpl"} diff --git a/scire/.smarty/templates/job.tpl b/scire/.smarty/templates/job.tpl index a26553e..124e03c 100644 --- a/scire/.smarty/templates/job.tpl +++ b/scire/.smarty/templates/job.tpl @@ -204,9 +204,9 @@ </table> {elseif $Action eq "delete"} <h1>DELETING</h1> -<b>Are you absolutely SURE you want to delete client {$client.hostname}?</b> -<input type="hidden" name="clientid" value="{$client.clientid}"> -<input type="submit" name="delete_confirm" value="Yes, get rid of the bastard!"><input type="submit" name="delete_cancel" value="No wait!"> +<b>Are you absolutely SURE you want to delete job {$jobid}:<br>Description:{$job.description}?</b> +<input type="hidden" name="jobid" value="{$jobid}"> +<input type="submit" name="delete_confirm" value="Yes, get rid of it!"><input type="submit" name="delete_cancel" value="No wait!"> {/if} {include file="footer.tpl"} diff --git a/scire/.smarty/templates/jobs.tpl b/scire/.smarty/templates/jobs.tpl index 0a85517..9f9b586 100755 --- a/scire/.smarty/templates/jobs.tpl +++ b/scire/.smarty/templates/jobs.tpl @@ -31,6 +31,8 @@ {/foreach} <td> <a href="job.php?jobid={$jobs[jobs].jobid}&Action=view">View Details</a> + <a href="job.php?jobid={$jobs[jobs].jobid}&Action=edit">Edit</a> + <a href="job.php?jobid={$jobs[jobs].jobid}&Action=delete">Delete</a> </td> </tr> diff --git a/scire/job.php b/scire/job.php index 48be507..81a10a1 100644 --- a/scire/job.php +++ b/scire/job.php @@ -99,66 +99,64 @@ function scheduleUIHelper($cronString) { ##################################################### #Deal with submitted forms. -############################################### -#Adding a client to clientgroups. -// if ($_POST['addgroup_confirm']) { -// $ingroups = $acl->get_object_groups($_POST['clientid'],'AXO'); -// $clientdata = $acl->get_object_data($_POST['clientid'], 'AXO'); -// $newgroups = $_POST['addgroupid']; -// #remove first. -// foreach ($ingroups as $ingroup) { -// if (!in_array($ingroup, $newgroups)) { -// $acl->del_group_object($ingroup, $clientdata[0][0], $clientdata[0][1], 'AXO'); -// } -// } -// foreach ($newgroups as $newgroup) { -// print "newgroup: $newgroup"; -// $acl->add_group_object($newgroup, $clientdata[0][0], $clientdata[0][1], 'AXO'); -// } -// $_GET['Action'] = "edit"; -// $_GET['clientid'] = $_POST['clientid']; -// } +if ($_POST['ADD']) { + check_action_access("Add Job"); + if ($_POST['script']) { + $script = get_scire_script($_POST['script']); + if ($_POST['permission']) { + $permission = $_POST['permission']; + $permission = get_scire_permission_by_name($permission); + $permission = $permission['permid']; + # print "Permission is: $permission"; + } else { + $permission = $script['permission']; + } + if ($_POST['priority']) { + $priority = $_POST['priority']; + } else { + $priority = $script['priority']; + } + } else { $status .= "ERROR: No script selected!"; } + if ($_POST['description']) { + $description = $_POST['description']; + } else { + $description = "No description provided."; + } + $pending = sizeof($_POST['clients']) + sizeof($_POST['clientgroups']); + + if (!$status and ($pending or $_POST['clientgroups'])) { #We have a script and clients; + # Get the schedule! All fields are required or else you're SOL + $scheduleComplete = $_POST["minute1"] and $_POST["hour1"] and + $_POST["day1"] and $_POST["month1"] and $_POST["weekday1"]; + if ($scheduleComplete) { + $str = implode(" ", array($_POST["minute1"], $_POST["hour1"], + $_POST["day1"], $_POST["month1"], $_POST["weekday1"])); + } else { + $str = ""; + } +# pre_var_dump($_POST); +# pre_var_dump($scheduleComplete); + pre_var_dump($str); + + try { + $result = scire_add_job($_POST['script'], $priority, $_SESSION['userid'], $permission, $description, $pending, $_POST['clients'], $_POST['clientgroups'], $dependency, $str, $_POST['validity_period']); + + if (!$result) { + $status .= "Job successfully added."; + } else { + $status .= "Error occurred during job addition. $result"; + } + } catch (CronException $e) { print_r($e); } + + } +} ############################################### -# Adding a client. -// if ($_POST['addhostname']) { -// if ($_POST['addhostname'] and $_POST['ip'] and $_POST['mac']) { -// check_action_access("Add Client");#Access check -// #First just incase, we need to check if the object already exists (so we don't make duplicates) -// $obj_id = ""; -// if ($acl->get_object_id("clients", $_POST['addhostname'], 'AXO') ) { #client already exists -// $obj_id = $acl->get_object_id("clients", $_POST['addhostname'], 'AXO'); -// $status .= "Found existing object with objectid $obj_id <br>"; -// } else { -// $obj_id = $acl->add_object("clients", $_POST['addhostname'], $_POST['addhostname'], 1, 0, 'AXO'); -// $status .= "Object id: $obj_id <BR>"; -// } -// $result = scire_add_client($obj_id, $_POST['digest'], $_POST['addhostname'], $_POST['mac'], $_POST['ip'], $_POST['gli_profile'], $_POST['osid'], $_POST['contact'], $_POST['status'], $_POST['installtime'], $_POST['assetid']); -// if ($result == 1) { -// $status .= "Client Addition successfull<br>"; -// } else { -// $status .= "Error during addition!: $result <br>"; -// } -// if ($_POST['groups']) { -// $status .= "Adding client to groups ".$_POST['groups']; -// foreach( $_POST['groups'] as $group) { -// $worked = $acl->add_group_object($group, "clients", $_POST['addhostname'], 'AXO'); -// if ($worked) { -// $status .= "Group $group Addition successfull.<br>"; -// } else { -// $status .= "ERROR adding group $group <br>"; -// } -// } -// } -// } else { -// $status = "Error required fields are not filled!"; -// } -// #header('Location: ' . $baseurl . 'clients.php'); -// } + ############################################### # Editing a job's information. -if ($_POST['editpriority']) { +if ($_POST['EditJobSubmit']) { check_action_access("Edit Job"); $jobinfo = get_scire_job($_GET['jobid']); $smarty->assign('job', $jobinfo); @@ -198,31 +196,22 @@ if ($_POST['editpriority']) { } ############################################### -# Delete a client. -// if ($_POST['delete_confirm']) { -// check_action_access("Delete Client"); -// $status = scire_del_client($_POST['clientid']); -// $acl->del_object($_POST['clientid'], 'AXO', TRUE); #True means erase referencing objects. -// header('Location: ' . $baseurl . 'clients.php'); -// } +# Delete a job. +if ($_POST['delete_confirm']) { + check_action_access("Delete Job"); +# $status = scire_del_job($_POST['jobid']); + header('Location: ' . $baseurl . 'jobs.php'); +} +if ($_POST['delete_cancel']) { + header('Location: ' . $baseurl . 'jobs.php'); +} switch($_GET['Action']) { -// case "addgroup": -// $smarty->assign('desc', "Add a client to a client group."); -// $smarty->assign('clientid', $_GET['clientid']); -// $smarty->assign('groups', $acl->format_groups($acl->sort_groups('AXO'), TEXT)); -// $ingroups = array(); -// $ingroups = $acl->get_object_groups($_GET['clientid'],'AXO'); -// var_dump($ingroups); -// $smarty->assign('ingroups', $ingroups); -// case "create": -// check_action_access("Add Client");#Access check -// $smarty->assign('desc', "Add a client."); -// $smarty->assign('groups', $acl->format_groups($acl->sort_groups('AXO'), TEXT)); -// $smarty->assign('gli_profiles', get_scire_gli_profiles()); -// $smarty->assign('oss', get_scire_oss()); -// $smarty->assign('users', get_scire_users('username', 'desc')); -// break; + case "create": + check_action_access("Add Job"); #Access check + add_leftbar($leftbar_menu, "««Cancel", "jobs.php"); + + break; case "edit": check_action_access("Edit Job");#Access check $acls = array(); @@ -275,25 +264,13 @@ switch($_GET['Action']) { } $smarty->assign('groups', $clientgroups); -// $ugroups = $acl->format_groups($acl->sort_groups('aro'), 'ARRAY'); -// $smarty->assign('ugroups', $ugroups); - -// #Format of search: aco_section, aco_value, aro_section, aro_value, aro_group_name, axo_section, axo_value, axo_group_name, return_value -// $result_acl_ids = $acl->search_acl(FALSE,FALSE, -// FALSE,FALSE,FALSE, -// 'clients',$clientinfo['hostname'],FALSE,FALSE); -// foreach ($result_acl_ids as $acl_id) { -// array_push($acls, $acl->get_acl($acl_id)); -// } -// #pre_var_dump($acls); -// $smarty->assign('acls',$acls); -// break; -// case "delete": -// check_action_access("Delete Client");#Access check -// $clientinfo = get_scire_client($_GET['jobid']); -// $smarty->assign('client', $clientinfo); -// $smarty->assign('jobid', $_GET['jobid']); -// break; + case "delete": + check_action_access("Delete Job");#Access check + $jobinfo = get_scire_job($_GET['jobid']); + $smarty->assign('job', $jobinfo); + #pre_var_dump($jobinfo); + $smarty->assign('jobid', $_GET['jobid']); + break; } diff --git a/scire/jobs.php b/scire/jobs.php index 7d06028..d54f674 100755 --- a/scire/jobs.php +++ b/scire/jobs.php @@ -7,6 +7,7 @@ $leftbar_submenu = array(); $template = "jobs.tpl"; $error_msg = ""; +check_action_access("View Jobs"); ############################################ ## Deal with submitted forms first. @@ -64,7 +65,13 @@ if ($_POST['searchfield']) { } #Gather groups of clients. it's a phpgacl command. - +$smarty->assign('leftbar_submenu_title', "Actions"); +if ( check_access("Add Job") ) { + add_leftbar($leftbar_submenu, "Add Job", "add_job.php"); +} $smarty->assign('client_groups', $client_groups); +$smarty->assign('leftbar_menu', $leftbar_menu); +$smarty->assign('leftbar_submenu', $leftbar_submenu); + $smarty->display('jobs.tpl'); ?> |