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

Contents of /trunk/scire/add_job.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 338 - (show annotations) (download)
Sun Jan 6 21:59:21 2008 UTC (6 years, 8 months ago) by codeman
File size: 3647 byte(s)
adding recurring_jobs_clients to hold the information for recurring jobs.

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']) + sizeof($_POST['clientgroups']);
37
38 if (!$status and ($pending or $_POST['clientgroups'])) { #We have a script and clients;
39 # Get the schedule! All fields are required or else you're SOL
40 $scheduleComplete = $_POST["minute1"] and $_POST["hour1"] and
41 $_POST["day1"] and $_POST["month1"] and $_POST["weekday1"];
42 if ($scheduleComplete) {
43 $str = implode(" ", array($_POST["minute1"], $_POST["hour1"],
44 $_POST["day1"], $_POST["month1"], $_POST["weekday1"]));
45 } else {
46 $str = "";
47 }
48 # pre_var_dump($_POST);
49 # pre_var_dump($scheduleComplete);
50 pre_var_dump($str);
51
52 try {
53 $result = scire_add_job($_POST['script'], $priority, $_SESSION['userid'], $permission, $description, $pending, $_POST['clients'], $_POST['clientgroups'], $dependency, $str, $_POST['validity_period']);
54
55 if (!$result) {
56 $status .= "Job successfully added.";
57 } else {
58 $status .= "Error occurred during job addition. $result";
59 }
60 } catch (CronException $e) { print_r($e); }
61
62 }
63 }
64
65
66 ########################################################
67 if ($_GET['scriptid']) {
68 $_GET['scriptid'] = (int) $_GET['scriptid'];
69 $script = get_scire_script($_GET['scriptid']);
70 $smarty->assign('script', $script);
71 # print $script['script_data'];
72 preg_match_all('/%%(.*?)%%/', $script['script_data'], $matches);
73 $smarty->assign('dyn_tags', $matches[1]);
74 foreach ($matches[1] as $tag) {
75 $tag_values[$tag] = get_dyn_tag_value($_GET['scriptid'],$tag);
76 }
77 $smarty->assign('tag_values', $tag_values);
78
79 pre_var_dump($tag_values);
80 }
81
82 if ($_GET['clientid']) {
83 $_GET['clientid'] = (int) $_GET['clientid'];
84 $client = get_scire_client($_GET['clientid']);
85 #$id = $acl->get_object_id("clients",$client['hostname'],'AXO'
86
87 $smarty->assign('client', $client);
88 }
89 ########################################################
90
91 $permissions = array();
92 $all_permissions = $acl->get_objects(NULL, 1, 'ACO');
93 foreach ($all_permissions as $categoryname => $cat) {
94 #print "Perm: $perm<br>Permname: $permname<br>";
95 if ($categoryname != $scire_ui_section) {
96 foreach ($cat as $perm) {
97 array_push($permissions, $perm);
98 }
99 }
100 }
101 $smarty->assign('perms', $permissions);
102 #pre_var_dump($permissions);
103 $smarty->assign('priorities', get_priorities());
104
105
106 $scripts = get_scire_scripts();
107 $smarty->assign('scripts', $scripts);
108
109 $smarty->assign('cgroups', $acl->format_groups($acl->sort_groups('AXO'), TEXT));
110 $clients = get_scire_clients('hostname', 'asc');
111 $smarty->assign('clients', $clients);
112
113 $smarty->assign('get', $_GET);
114 $smarty->assign('leftbar_menu', $leftbar_menu);
115 $smarty->assign('Action', $_GET['Action']);
116 $smarty->assign('status', $status);
117 $smarty->display('add_job.tpl');
118 #var_dump($clients);
119 ?>

  ViewVC Help
Powered by ViewVC 1.1.20