summaryrefslogtreecommitdiff
path: root/scire
diff options
context:
space:
mode:
authorPreston Cody <codeman@gentoo.org>2007-07-22 22:04:49 +0000
committerPreston Cody <codeman@gentoo.org>2007-07-22 22:04:49 +0000
commit75ec931e54689e8f82a9812c11f52f3d49608ef1 (patch)
treedb7e9ed606e8f2acb8c3be431a749a9158374d76 /scire
parentsmall changes. for script, use the id and name of scripts, now passed in. (diff)
downloadscire-75ec931e54689e8f82a9812c11f52f3d49608ef1.tar.gz
scire-75ec931e54689e8f82a9812c11f52f3d49608ef1.tar.bz2
scire-75ec931e54689e8f82a9812c11f52f3d49608ef1.zip
lots of changes here.
adding dynamic tags submission to the script. implemented the continue button which parses the script looking for tags, and when the page reloads it shows the tags so you can set default values. add the perm id svn path=/; revision=240
Diffstat (limited to 'scire')
-rw-r--r--scire/script.php41
1 files changed, 37 insertions, 4 deletions
diff --git a/scire/script.php b/scire/script.php
index 502e2e3..859f9fb 100644
--- a/scire/script.php
+++ b/scire/script.php
@@ -60,13 +60,39 @@ if ($_POST['add_script']) {
$script['pp_script_data'] = $_POST['pps_data'];
}
}
+
+ #Look for tags.
+
+ foreach ($_POST as $name => $value) {
+ if (substr($name,0, 4) == "tag_" and $value) {
+ $temp = substr($name,4);
+ $script_tags[$temp] = $value;
+ }
+ }
#Ok, i think we got everything, now lets add it
- $result = scire_add_script($script['name'], $script['desc'], $script['location'], $script['script_data'], $script['log_location'], $script['success_code'], $script['run_as'], $script['priority'], $script['permission'], $script['pp_location'], $script['pp_script_data']);
- if ($result) { #success
+ $result = scire_add_script($script['name'], $script['desc'], $script['location'], $script['script_data'], $script['log_location'], $script['success_code'], $script['run_as'], $script['priority'], $script['permission'], $script['pp_location'], $script['pp_script_data'], $script_tags);
+ if (!$result) { #success
$status .= "Scipt addition successfull!";
} else {
$status .= "BAD BAD! Error during query. $result";
}
+} #/if add_script
+elseif ($_POST['continue']) {
+ #They pressed the continue button, so just repost the fields, and then add tags as we find them.
+ if ($_POST['addname']) { $smarty->assign('addname', $_POST['addname']); }
+ if ($_POST['desc']) { $smarty->assign('desc', $_POST['desc']); }
+ if ($_POST['runas_radio']) { $smarty->assign('runas', $_POST['runas_radio']); }
+ if ($_POST['runas']) { $smarty->assign('runas', $_POST['runas']); }
+ if ($_POST['priority']) { $smarty->assign('priority', $_POST['priority']); }
+ if ($_POST['permission']) { $smarty->assign('permission', $_POST['permission']); }
+ if ($_POST['script_data_manual']) { $script_data = $_POST['script_data_manual']; }
+ #if ($_POST['script_data_upload']) { $script_data = #FIXME some way get this file and parse it. potential security issue? }
+
+ preg_match_all('/%%(.*?)%%/', $script_data, $matches);
+# pre_var_dump($dyn_tag);
+# pre_var_dump($matches);
+ $smarty->assign('dyn_tags', $matches[1]);
+
}
$permissions = array();
@@ -77,11 +103,18 @@ foreach ($all_permissions as $categoryname => $cat) {
#print "Perm: $perm<br>Permname: $permname<br>";
if ($categoryname != $scire_ui_section) {
foreach ($cat as $perm) {
- array_push($permissions, $perm);
+ $tmp_perm[id] = $acl->get_object_id($categoryname,$perm,'ACO');
+ $tmp_perm[name] = $perm;
+ array_push($permissions, $tmp_perm);
}
array_push($perm_categories, $categoryname);
}
}
+if (!$script_data) {
+ $script_data = '#!/bin/bash' . "\n" . 'emerge sync';
+}
+$smarty->assign('script_data', $script_data);
+
$smarty->assign('perm_categories',$perm_categories);
$smarty->assign('perms', $permissions);
@@ -91,5 +124,5 @@ $smarty->assign('View', $_GET['View']);
$smarty->assign('Action', $_GET['Action']);
$smarty->assign('status', $status);
$smarty->display('script.tpl');
-var_dump($_POST);
+#var_dump($all_permissions);
?>