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

Contents of /trunk/scire/add_job.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 308 - (show annotations) (download)
Wed Jan 2 01:11:15 2008 UTC (10 years ago) by codeman
File size: 3507 byte(s)
get rid of that dependency thing.

1 <?php
2 include('.lib/common.php');
3 include('cron2.php');
4
5 $smarty->assign('leftbar', "on");
6 $leftbar_menu = array();
7
8 add_leftbar($leftbar_menu, "&#171;&#171;Cancel", "jobs.php");
9
10 $status = "";
11
12 #####################################################
13 #Deal with submitted forms.
14 if ($_POST['ADD']) {
15 if ($_POST['script']) {
16 $script = get_scire_script($_POST['script']);
17 if ($_POST['permission']) {
18 $permission = $_POST['permission'];
19 $permission = get_scire_permission_by_name($permission);
20 $permission = $permission['permid'];
21 # print "Permission is: $permission";
22 } else {
23 $permission = $script['permission'];
24 }
25 if ($_POST['priority']) {
26 $priority = $_POST['priority'];
27 } else {
28 $priority = $script['priority'];
29 }
30 } else { $status .= "ERROR: No script selected!"; }
31 if ($_POST['description']) {
32 $description = $_POST['description'];
33 } else {
34 $description = "No description provided.";
35 }
36 $pending = sizeof($_POST['clients']);
37 if (!$status and ($pending or $_POST['clientgroups'])) { #We have a script and clients;
38 # Get the schedule!
39 $scheduleComplete = $_POST["minute1"] and $_POST["hour1"] and
40 $_POST["day1"] and $_POST["month1"] and $_POST["weekday1"];
41 if ($scheduleComplete) {
42 $str = implode(" ", array($_POST["minute1"], $_POST["hour1"],
43 $_POST["day1"], $_POST["month1"], $_POST["weekday1"]));
44 } else {
45 $str = "";
46 }
47
48 #$dependency = 1;
49
50 try {
51 $result = scire_add_job($_POST['script'], $priority, $_SESSION['userid'], $permission, $description, $pending, $_POST['clients'], $_POST['clientgroups'], $dependency, $str, $_POST['validity_period']);
52
53 if (!$result) {
54 $status .= "Job successfully added.";
55 } else {
56 $status .= "Error occurred during job addition. $result";
57 }
58 } catch (CronException $e) { print_r($e); }
59
60 }
61 }
62
63
64 ########################################################
65 if ($_GET['scriptid']) {
66 $_GET['scriptid'] = (int) $_GET['scriptid'];
67 $script = get_scire_script($_GET['scriptid']);
68 $smarty->assign('script', $script);
69 # print $script['script_data'];
70 preg_match_all('/%%(.*?)%%/', $script['script_data'], $matches);
71 $smarty->assign('dyn_tags', $matches[1]);
72 foreach ($matches[1] as $tag) {
73 $tag_values[$tag] = get_dyn_tag_value($_GET['scriptid'],$tag);
74 }
75 $smarty->assign('tag_values', $tag_values);
76
77 pre_var_dump($tag_values);
78 }
79
80 if ($_GET['clientid']) {
81 $_GET['clientid'] = (int) $_GET['clientid'];
82 $client = get_scire_client($_GET['clientid']);
83 #$id = $acl->get_object_id("clients",$client['hostname'],'AXO'
84
85 $smarty->assign('client', $client);
86 }
87 ########################################################
88
89 $permissions = array();
90 $all_permissions = $acl->get_objects(NULL, 1, 'ACO');
91 foreach ($all_permissions as $categoryname => $cat) {
92 #print "Perm: $perm<br>Permname: $permname<br>";
93 if ($categoryname != $scire_ui_section) {
94 foreach ($cat as $perm) {
95 array_push($permissions, $perm);
96 }
97 }
98 }
99 $smarty->assign('perms', $permissions);
100 #pre_var_dump($permissions);
101 $smarty->assign('priorities', get_priorities());
102
103
104 $scripts = get_scire_scripts();
105 $smarty->assign('scripts', $scripts);
106
107 $smarty->assign('cgroups', $acl->format_groups($acl->sort_groups('AXO'), TEXT));
108 $clients = get_scire_clients('hostname', 'asc');
109 $smarty->assign('clients', $clients);
110
111 $smarty->assign('get', $_GET);
112 $smarty->assign('leftbar_menu', $leftbar_menu);
113 $smarty->assign('Action', $_GET['Action']);
114 $smarty->assign('status', $status);
115 $smarty->display('add_job.tpl');
116 #var_dump($clients);
117 ?>

  ViewVC Help
Powered by ViewVC 1.1.20