/[scire]/trunk/scire/job.php
Gentoo

Diff of /trunk/scire/job.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 351 Revision 352
97} 97}
98 98
99##################################################### 99#####################################################
100#Deal with submitted forms. 100#Deal with submitted forms.
101 101
102if ($_POST['ADD']) {
103 check_action_access("Add Job");
104 if ($_POST['script']) {
105 $script = get_scire_script($_POST['script']);
106 if ($_POST['permission']) {
107 $permission = $_POST['permission'];
108 $permission = get_scire_permission_by_name($permission);
109 $permission = $permission['permid'];
110 # print "Permission is: $permission";
111 } else {
112 $permission = $script['permission'];
113 }
114 if ($_POST['priority']) {
115 $priority = $_POST['priority'];
116 } else {
117 $priority = $script['priority'];
118 }
119 } else { $status .= "ERROR: No script selected!"; }
120 if ($_POST['description']) {
121 $description = $_POST['description'];
122 } else {
123 $description = "No description provided.";
124 }
125 $pending = sizeof($_POST['clients']) + sizeof($_POST['clientgroups']);
126
127 if (!$status and ($pending or $_POST['clientgroups'])) { #We have a script and clients;
128 # Get the schedule! All fields are required or else you're SOL
129 $scheduleComplete = $_POST["minute1"] and $_POST["hour1"] and
130 $_POST["day1"] and $_POST["month1"] and $_POST["weekday1"];
131 if ($scheduleComplete) {
132 $str = implode(" ", array($_POST["minute1"], $_POST["hour1"],
133 $_POST["day1"], $_POST["month1"], $_POST["weekday1"]));
134 } else {
135 $str = "";
136 }
137# pre_var_dump($_POST);
138# pre_var_dump($scheduleComplete);
139 pre_var_dump($str);
140
141 try {
142 $result = scire_add_job($_POST['script'], $priority, $_SESSION['userid'], $permission, $description, $pending, $_POST['clients'], $_POST['clientgroups'], $dependency, $str, $_POST['validity_period']);
143
144 if (!$result) {
145 $status .= "Job successfully added.";
146 } else {
147 $status .= "Error occurred during job addition. $result";
148 }
149 } catch (CronException $e) { print_r($e); }
150
151 }
152}
153
102############################################### 154###############################################
103#Adding a client to clientgroups.
104// if ($_POST['addgroup_confirm']) {
105// $ingroups = $acl->get_object_groups($_POST['clientid'],'AXO');
106// $clientdata = $acl->get_object_data($_POST['clientid'], 'AXO');
107// $newgroups = $_POST['addgroupid'];
108// #remove first.
109// foreach ($ingroups as $ingroup) {
110// if (!in_array($ingroup, $newgroups)) {
111// $acl->del_group_object($ingroup, $clientdata[0][0], $clientdata[0][1], 'AXO');
112// }
113// }
114// foreach ($newgroups as $newgroup) {
115// print "newgroup: $newgroup";
116// $acl->add_group_object($newgroup, $clientdata[0][0], $clientdata[0][1], 'AXO');
117// }
118// $_GET['Action'] = "edit";
119// $_GET['clientid'] = $_POST['clientid'];
120// }
121 155
122###############################################
123# Adding a client.
124// if ($_POST['addhostname']) {
125// if ($_POST['addhostname'] and $_POST['ip'] and $_POST['mac']) {
126// check_action_access("Add Client");#Access check
127// #First just incase, we need to check if the object already exists (so we don't make duplicates)
128// $obj_id = "";
129// if ($acl->get_object_id("clients", $_POST['addhostname'], 'AXO') ) { #client already exists
130// $obj_id = $acl->get_object_id("clients", $_POST['addhostname'], 'AXO');
131// $status .= "Found existing object with objectid $obj_id <br>";
132// } else {
133// $obj_id = $acl->add_object("clients", $_POST['addhostname'], $_POST['addhostname'], 1, 0, 'AXO');
134// $status .= "Object id: $obj_id <BR>";
135// }
136// $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']);
137// if ($result == 1) {
138// $status .= "Client Addition successfull<br>";
139// } else {
140// $status .= "Error during addition!: $result <br>";
141// }
142 156
143// if ($_POST['groups']) {
144// $status .= "Adding client to groups ".$_POST['groups'];
145// foreach( $_POST['groups'] as $group) {
146// $worked = $acl->add_group_object($group, "clients", $_POST['addhostname'], 'AXO');
147// if ($worked) {
148// $status .= "Group $group Addition successfull.<br>";
149// } else {
150// $status .= "ERROR adding group $group <br>";
151// }
152// }
153// }
154// } else {
155// $status = "Error required fields are not filled!";
156// }
157// #header('Location: ' . $baseurl . 'clients.php');
158// }
159############################################### 157###############################################
160# Editing a job's information. 158# Editing a job's information.
161if ($_POST['editpriority']) { 159if ($_POST['EditJobSubmit']) {
162 check_action_access("Edit Job"); 160 check_action_access("Edit Job");
163 $jobinfo = get_scire_job($_GET['jobid']); 161 $jobinfo = get_scire_job($_GET['jobid']);
164 $smarty->assign('job', $jobinfo); 162 $smarty->assign('job', $jobinfo);
165 163
166 if (isset($_POST['editpriority']) and ($_POST['editpriority'] != $jobinfo['priority'])) { 164 if (isset($_POST['editpriority']) and ($_POST['editpriority'] != $jobinfo['priority'])) {
196 $_GET['Action'] = "edit"; 194 $_GET['Action'] = "edit";
197 $_GET['jobid'] = $_POST['jobid']; 195 $_GET['jobid'] = $_POST['jobid'];
198} 196}
199 197
200############################################### 198###############################################
201# Delete a client. 199# Delete a job.
202// if ($_POST['delete_confirm']) { 200if ($_POST['delete_confirm']) {
203// check_action_access("Delete Client"); 201 check_action_access("Delete Job");
204// $status = scire_del_client($_POST['clientid']); 202# $status = scire_del_job($_POST['jobid']);
205// $acl->del_object($_POST['clientid'], 'AXO', TRUE); #True means erase referencing objects.
206// header('Location: ' . $baseurl . 'clients.php'); 203 header('Location: ' . $baseurl . 'jobs.php');
207// } 204}
205if ($_POST['delete_cancel']) {
206 header('Location: ' . $baseurl . 'jobs.php');
207}
208 208
209switch($_GET['Action']) { 209switch($_GET['Action']) {
210// case "addgroup":
211// $smarty->assign('desc', "Add a client to a client group.");
212// $smarty->assign('clientid', $_GET['clientid']);
213// $smarty->assign('groups', $acl->format_groups($acl->sort_groups('AXO'), TEXT));
214// $ingroups = array();
215// $ingroups = $acl->get_object_groups($_GET['clientid'],'AXO');
216// var_dump($ingroups);
217// $smarty->assign('ingroups', $ingroups);
218// case "create": 210 case "create":
219// check_action_access("Add Client");#Access check 211 check_action_access("Add Job"); #Access check
220// $smarty->assign('desc', "Add a client."); 212 add_leftbar($leftbar_menu, "&#171;&#171;Cancel", "jobs.php");
221// $smarty->assign('groups', $acl->format_groups($acl->sort_groups('AXO'), TEXT)); 213
222// $smarty->assign('gli_profiles', get_scire_gli_profiles());
223// $smarty->assign('oss', get_scire_oss());
224// $smarty->assign('users', get_scire_users('username', 'desc'));
225// break; 214 break;
226 case "edit": 215 case "edit":
227 check_action_access("Edit Job");#Access check 216 check_action_access("Edit Job");#Access check
228 $acls = array(); 217 $acls = array();
229 #make the topbar look good 218 #make the topbar look good
230 $smarty->assign('desc', "Edit client information."); 219 $smarty->assign('desc', "Edit client information.");
273 } 262 }
274 } 263 }
275 } 264 }
276 $smarty->assign('groups', $clientgroups); 265 $smarty->assign('groups', $clientgroups);
277 266
278// $ugroups = $acl->format_groups($acl->sort_groups('aro'), 'ARRAY');
279// $smarty->assign('ugroups', $ugroups);
280
281// #Format of search: aco_section, aco_value, aro_section, aro_value, aro_group_name, axo_section, axo_value, axo_group_name, return_value
282// $result_acl_ids = $acl->search_acl(FALSE,FALSE,
283// FALSE,FALSE,FALSE,
284// 'clients',$clientinfo['hostname'],FALSE,FALSE);
285// foreach ($result_acl_ids as $acl_id) {
286// array_push($acls, $acl->get_acl($acl_id));
287// }
288// #pre_var_dump($acls);
289// $smarty->assign('acls',$acls);
290// break;
291// case "delete": 267 case "delete":
292// check_action_access("Delete Client");#Access check 268 check_action_access("Delete Job");#Access check
293// $clientinfo = get_scire_client($_GET['jobid']); 269 $jobinfo = get_scire_job($_GET['jobid']);
294// $smarty->assign('client', $clientinfo); 270 $smarty->assign('job', $jobinfo);
271 #pre_var_dump($jobinfo);
295// $smarty->assign('jobid', $_GET['jobid']); 272 $smarty->assign('jobid', $_GET['jobid']);
296// break; 273 break;
297} 274}
298 275
299 276
300$smarty->assign('leftbar_menu', $leftbar_menu); 277$smarty->assign('leftbar_menu', $leftbar_menu);
301$smarty->assign('Action', $_GET['Action']); 278$smarty->assign('Action', $_GET['Action']);

Legend:
Removed from v.351  
changed lines
  Added in v.352

  ViewVC Help
Powered by ViewVC 1.1.20