diff options
author | 2007-07-21 02:09:06 +0000 | |
---|---|---|
committer | 2007-07-21 02:09:06 +0000 | |
commit | d910131787280767ac8c5c3a14b4ec58bdd719ec (patch) | |
tree | d16badf950066310b280b78b946d93e610d6f65d /scire | |
parent | committing code from Rodrigo Lazo (rlazo) for Google SoC (diff) | |
download | scire-d910131787280767ac8c5c3a14b4ec58bdd719ec.tar.gz scire-d910131787280767ac8c5c3a14b4ec58bdd719ec.tar.bz2 scire-d910131787280767ac8c5c3a14b4ec58bdd719ec.zip |
adding changes from Rodrigo Lazo (rlazo) for Google SoC:
modified add_job.php to make use of the new scheduling logic, plus other minor changes
svn path=/; revision=233
Diffstat (limited to 'scire')
-rwxr-xr-x | scire/.lib/DB_functions.php | 12 | ||||
-rwxr-xr-x | scire/.smarty/templates/add_job.tpl | 5 | ||||
-rw-r--r-- | scire/add_job.php | 25 |
3 files changed, 34 insertions, 8 deletions
diff --git a/scire/.lib/DB_functions.php b/scire/.lib/DB_functions.php index 3d806bb..b8eca73 100755 --- a/scire/.lib/DB_functions.php +++ b/scire/.lib/DB_functions.php @@ -334,7 +334,7 @@ function scire_reject_client($clientid) { } } -function scire_add_job($script, $priority, $creator, $permission, $description, $pending, $clients, $clientgroups) { +function scire_add_job($script, $priority, $creator, $permission, $description, $pending, $clients, $clientgroups, $job_dependency, $run_schedule, $validity_period) { global $db; #First make the job $db->query('LOCK TABLES jobs WRITE'); #LOCK TABLE @@ -352,7 +352,12 @@ function scire_add_job($script, $priority, $creator, $permission, $description, } $db->query('UNLOCK TABLES'); #UNLOCK #Now add the conditions and recurrance - + + $result = $db->insert('job_conditions', array('jobid' => $jobid, 'job_dependency' => $job_dependency, 'run_schedule' => $run_schedule, 'validity_period' => $validity_period)); + if (!$result) { + return $db->error; + } + #Now add the clients. foreach ($clients as $client) { $result = $db->query('INSERT INTO `jobs_clients` (jobid, clientid) '. @@ -408,7 +413,8 @@ function get_scire_job($jobid) { '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)'); + 'LEFT JOIN permissions AS p ON (j.permission=p.permid) '. + ' WHERE j.jobid=\'' . (int) $jobid . '\''); if ($result && count($result) > 0) { return $result[0]; } else { diff --git a/scire/.smarty/templates/add_job.tpl b/scire/.smarty/templates/add_job.tpl index bf4a997..d352b8a 100755 --- a/scire/.smarty/templates/add_job.tpl +++ b/scire/.smarty/templates/add_job.tpl @@ -36,7 +36,7 @@ </tr> {if !isset($get.scriptid)} <tr> - <td colspan="2">Or just type in the ID of the script: <input type="text" name="script" ></td> + <td colspan="2">Or just type in the ID of the script: <input type="text" name="scriptID" ></td> </tr> {/if} <tr> @@ -301,6 +301,9 @@ Recurring stuff here.<br> <option value=6> Saturday </select> </td></tr> +<tr><td> +<label for="validity_period">Validity Period: </label><input type="text" name="validity_period" /> +</td></tr> </table> <hr> Job dependency stuff here.<br> diff --git a/scire/add_job.php b/scire/add_job.php index 29d9905..afc9494 100644 --- a/scire/add_job.php +++ b/scire/add_job.php @@ -1,5 +1,6 @@ <?php include('.lib/common.php'); +include('cron2.php'); $smarty->assign('leftbar', "on"); $leftbar_menu = array(); @@ -34,12 +35,28 @@ if ($_POST['ADD']) { } $pending = sizeof($_POST['clients']); if (!$status and ($pending or $_POST['clientgroups'])) { #We have a script and clients; - $result = scire_add_job($_POST['script'], $priority, $_SESSION['userid'], $permission, $description, $pending, $_POST['clients'], $_POST['clientgroups']); - if (!$result) { - $status .= "Job successfully added."; + # Get the schedule! + $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 { - $status .= "Error occurred during job addition. $result"; + $str = ""; } + + $dependency = 1; + + try { + $cron = new CronParser($str); + $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) {} + } } |