X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=plugins%2Faddons%2Fgotomasses%2Fclass_gotomasses.inc;h=dc2bb580ed7f0e843595837c1fd5797729f52536;hb=e1dbbb4a55cb759059cdd8b0f83a5ca0428b7d2a;hp=ce1b6395c4ae57ebebf1e240ec1be53851a791eb;hpb=d957b1ca30adf46ddeae723edc7489b53ee1b0e2;p=gosa.git
diff --git a/plugins/addons/gotomasses/class_gotomasses.inc b/plugins/addons/gotomasses/class_gotomasses.inc
index ce1b6395c..dc2bb580e 100644
--- a/plugins/addons/gotomasses/class_gotomasses.inc
+++ b/plugins/addons/gotomasses/class_gotomasses.inc
@@ -3,7 +3,7 @@
class gotomasses extends plugin
{
/* Definitions */
- var $plHeadline = "System mass deployment";
+ var $plHeadline = "System deployment";
var $plDescription = "This does something";
/* attribute list for save action */
@@ -25,12 +25,10 @@ class gotomasses extends plugin
/* Include config object */
$this->config= $config;
-
$this->load_gotomasses_data();
}
-
function execute()
{
$smarty = get_smarty();
@@ -56,9 +54,13 @@ class gotomasses extends plugin
/* Remove entry from list */
if($s_action == "remove" && isset($this->tasks[$s_entry])){
- $smarty->assign("info",_("Your are about to delete a gotomasses task."));
- $this->current = $s_entry;
- return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
+ if(!$this->acl_is_removeable()){
+ print_red(_("You are not allowed to remove a task."));
+ }else{
+ $smarty->assign("info",_("Your are about to delete a gotomasses task."));
+ $this->current = $s_entry;
+ return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
+ }
}
/* Remove entry, remove is confirmed */
@@ -76,7 +78,7 @@ class gotomasses extends plugin
}
/* New entry */
- if($s_action== "new_task"){
+ if($s_action== "new_task" && $this->acl_is_createable()){
$this->dialog = new goto_task($this->config,$this);
$this->current = -1;
}
@@ -88,7 +90,7 @@ class gotomasses extends plugin
}
/* Close dialog */
- if(isset($_POST['save_goto_task']) && is_object($this->dialog)){
+ if((isset($_POST['save_goto_task']) || isset($_POST['apply_goto_task'])) && is_object($this->dialog) ){
$this->dialog->save_object();
$msgs = $this->dialog->check();
if(count($msgs)){
@@ -101,12 +103,14 @@ class gotomasses extends plugin
}else{
$this->tasks[] = $this->dialog->save();
}
- $this->dialog = FALSE;
- $this->current = -1;
+ if(!isset($_POST['apply_goto_task'])){
+ $this->dialog = FALSE;
+ $this->current = -1;
+ }
$this->save();
}
}
-
+
/* Display dialogs if currently opened */
if(is_object($this->dialog)){
$this->dialog->save_object();
@@ -125,31 +129,45 @@ class gotomasses extends plugin
$divlist->EnableCloseButton(FALSE);
$divlist->EnableSaveButton(FALSE);
$divlist->SetInformation(_("This menu allows you to add, remove and change the properties of gotomasses tasks."));
-
- $header = "
-
-
";
-
+
+ /* Display add button if allowed */
+ if($this->acl_is_createable()){
+ $header = "
+
+
";
+ }else{
+ $header = "";
+ }
+
+ /* Get Permissions */
+ $ui = get_userinfo();
+ $acls = $this->getacl("");
+ foreach($ui->get_module_departments("gotomasses") as $dep){
+ $acls .= $ui->get_category_permissions($dep,"gotomasses");
+ }
+
+ /* Create divlist */
$divlist->SetListHeader($header);
$divlist->AddHeader(array("string"=>""._("Target").""));
$divlist->AddHeader(array("string"=>""._("Schedule")."",
"attach"=>"style='width:100px;'"));
$divlist->AddHeader(array("string"=>""._("Type")."",
- "attach"=>"style='width:60px;'"));
+ "attach"=>"style='width:80px;'"));
$divlist->AddHeader(array("string"=>_("Action"),
"attach"=>"style='border-right:0px;width:40px;'"));
- foreach($this->tasks as $key => $task){
-
- $action = "";
- $action.= "";
-
- $field1 = array("string" => "".$this->target_to_string($task)."
");
- $field2 = array("string" => $this->time_to_string($task),"attach" => "style='width:100px;'");
- $field3 = array("string" => $this->action_to_string($task),"attach" => "style='width:60px;'");
- $field4 = array("string" => $action,"attach" => "style='width:40px;border-right:0px;'");
-
-
- $divlist->AddElement(array($field1,$field2,$field3,$field4));
+
+ if(!empty($acls)){
+ foreach($this->tasks as $key => $task){
+ $action = "";
+ if($this->acl_is_removeable()){
+ $action.= "";
+ }
+ $field1 = array("string" => "".$this->target_to_string($task)."
");
+ $field2 = array("string" => $this->time_to_string($task),"attach" => "style='width:100px;'");
+ $field3 = array("string" => $this->action_to_string($task),"attach" => "style='width:80px;'");
+ $field4 = array("string" => $action,"attach" => "style='text-align:right;width:40px;border-right:0px;'");
+ $divlist->AddElement(array($field1,$field2,$field3,$field4));
+ }
}
return($divlist->Draw());
@@ -159,9 +177,15 @@ class gotomasses extends plugin
function target_to_string($data)
{
$ret = "";
- foreach($data['Target'] as $target){
- $ret .= preg_replace("/^[^:]+:/i","",$target).", ";
- }
+ if($data['Action'] == "initial_install"){
+ foreach($data['Initial_Target'] as $target){
+ $ret .= $target['MAC'].", ";
+ }
+ }else{
+ foreach($data['Target'] as $target){
+ $ret .= $target.", ";
+ }
+ }
return(preg_replace("/, $/","",$ret));
}
@@ -174,13 +198,11 @@ class gotomasses extends plugin
function action_to_string($data)
{
- switch($data['Action']){
-
- case 'reinstall' : return("Reinstall");break;
- case 'install' : return("Install");break;
- case 'reboot' : return("Restart");break;
- case 'update' : return("Update");break;
- default : return("Unknown");
+ $tmp = $this->get_actions();
+ if(isset($tmp[$data['Action']])){
+ return($tmp[$data['Action']]);
+ }else{
+ return(_("Unknown"));
}
}
@@ -189,12 +211,13 @@ class gotomasses extends plugin
{
$ui = get_userinfo();
-
+ /* Check file existence */
if(!file_exists($this->data_file) || !is_readable($this->data_file)){
print_red(sprintf(_("Can't locate or read gotomasses storage file '%s'."),$this->data_file));
return(FALSE);
}
+ /* check if file is readable */
$fp = @fopen($this->data_file,"r");
if(!$fp){
print_red(sprintf(_("Can't read gotomasses storage file '%s'."),$this->data_file));
@@ -244,7 +267,17 @@ class gotomasses extends plugin
$entry['Weekday'] = $parts[4];
$entry['Action'] = $parts[5];
$entry['OGroup'] = $parts[6];
- $entry['Target'] = split(",",$parts[7]);
+ if($entry['Action'] == "initial_install"){
+ $tmp2 = split(";",$parts[7]);
+ foreach($tmp2 as $target){
+ $tmp = split(",",$target);
+ $entry['Initial_Target'][] = array("MAC" => $tmp[0],"IP"=>$tmp[1],"NAME" => $tmp[2]);
+ }
+ $entry['Target'] = array();
+ }else{
+ $entry['Initial_Target'] = array();
+ $entry['Target'] = split(";",$parts[7]);
+ }
$entry['Comment'] = $comment;
$this->tasks [] = $entry;
}
@@ -255,38 +288,47 @@ class gotomasses extends plugin
function save_gotomasses_data()
{
$str = "#GOsa generated file, please just modify if you realy know what you do.";
-
foreach($this->tasks as $task){
$str .= "\n#".trim($task['Comment']);
-
$str .= "\n";
- $str .= str_pad($task['Minute'] ,5," ")." ";
- $str .= str_pad($task['Hour'] ,5," ")." ";
- $str .= str_pad($task['Day'] ,5," ")." ";
- $str .= str_pad($task['Month'] ,5," ")." ";
- $str .= str_pad($task['Weekday'],5," ")." ";
+ if($task['Action'] == "initial_install"){
+ $str .= "* * * * * ";
+ }else{
+ $str .= str_pad($task['Minute'] ,5," ")." ";
+ $str .= str_pad($task['Hour'] ,5," ")." ";
+ $str .= str_pad($task['Day'] ,5," ")." ";
+ $str .= str_pad($task['Month'] ,5," ")." ";
+ $str .= str_pad($task['Weekday'],5," ")." ";
+ }
$str .= str_pad($task['Action'] ,5," ")." ";
$str .= str_pad($task['OGroup'] ,5," ")." ";
-
- foreach($task['Target'] as $target){
- $str .= $target.",";
+ if($task['Action'] == "initial_install"){
+ foreach($task['Initial_Target'] as $target){
+ $str .= $target['MAC'].",".$target['IP'].",".$target['NAME'].";";
+ }
+ }else{
+ foreach($task['Target'] as $target){
+ $str .= $target.";";
+ }
}
- $str = preg_replace("/,$/","",$str);
+ $str = preg_replace("/;$/","",$str);
}
+ /* check file existence*/
$ui = get_userinfo();
-
if(!file_exists($this->data_file) || !is_writeable($this->data_file)){
print_red(sprintf(_("Can't locate or write gotomasses storage file '%s'."),$this->data_file));
return(FALSE);
}
+ /* check permissions */
$fp = @fopen($this->data_file,"w");
if(!$fp){
print_red(sprintf(_("Can't read gotomasses storage file '%s'."),$this->data_file));
return(FALSE);
}
+ /* Write contents */
$str .= "\n";
fwrite($fp,$str);
fclose($fp);
@@ -295,8 +337,6 @@ class gotomasses extends plugin
function save_object()
{
- if(isset($_POST['gotomasses'])){
- }
}
@@ -323,12 +363,14 @@ class gotomasses extends plugin
function get_actions()
{
/* Prepare list of available actions */
- $actions = array( "reboot" => _("Reboot"),
+ $actions = array( "reboot" => _("Reboot"),
"localboot" => _("Localboot"),
"halt" => _("Halt system"),
+ "initial_install" => _("Initial installation"),
"update" => _("Update"),
"reinstall" => _("(Re)Install"),
"rescan" => _("Rescan"),
+ "wake" => _("Wake"),
"memcheck" => _("Memory check"));
return($actions);
}