summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 99b73ad)
raw | patch | inline | side by side (parent: 99b73ad)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 22 Aug 2007 06:35:22 +0000 (06:35 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 22 Aug 2007 06:35:22 +0000 (06:35 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7092 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/plugins/addons/gotomasses/class_goto_task.inc b/plugins/addons/gotomasses/class_goto_task.inc
index 6631e0dab0dc61f74a550ae38d50cfcdbbaee2f8..f67fd7f115a6a6b7e4a23d47dfbc5d1252218d2a 100644 (file)
var $OGroup = "keep_current";
var $OGroups = array();
var $Target = array();
+ var $Initial_Target = array();
var $Actions = array();
var $new = FALSE;
- var $attributes = array("OGroup","Minute","Hour","Day","Month","Weekday","Action","Comment","Target");
+ var $attributes = array("OGroup","Minute","Hour","Day","Month","Weekday","Action","Comment","Target","Initial_Target");
function goto_task($config,$parent,$data = array())
}
}
- /* Add target */
- if(isset($_POST['add_target']) && !empty($_POST['target_text'])){
- $target = get_post("target_text");
- if($this->is_valid_target($target) && !in_array($target,$this->Target)){
- $this->Target[] = $target;
+ if($this->Action != "initial_install"){
+
+ /* Add target */
+ if(isset($_POST['add_target']) && !empty($_POST['target_text'])){
+ $target = get_post("target_text");
+ if($this->is_valid_target($target) && !in_array($target,$this->Target)){
+ $this->Target[] = $target;
+ }
+ }
+ }else{
+
+ /* Add target */
+ if(isset($_POST['add_target']) && !empty($_POST['task_MAC'])){
+ $MAC = $_POST['task_MAC'];
+ $NAME= "";
+ $IP = "";
+ if(isset($_POST['task_Name'])){
+ $NAME = $_POST['task_Name'];
+ }
+ if(isset($_POST['task_IP']) && is_ip($_POST['task_IP'])){
+ $IP = $_POST['task_IP'];
+ }
+ if(is_mac($MAC)){
+ $this->Initial_Target[] = array("MAC"=>$MAC,"IP"=>$IP,"NAME"=>$NAME);
+ }
}
}
-
+
+ /* Add via csv */
+ if(isset($_FILES['import_file'])){
+ $file = $_FILES['import_file']['tmp_name'];
+ if(file_exists($file) && is_readable($file)){
+ $str ="";
+ $fp = fopen($file,"r");
+ while(!feof($fp)){
+ $line = fgets($fp,512);
+ $tmp = preg_split("/(,|;)/",$line);
+
+ $MAC = $IP = $NAME = "";
+ if(isset($tmp[0])){
+ $MAC = $tmp[0];
+ }
+ if(isset($tmp[1])){
+ $IP = $tmp[1];
+ }
+ if(isset($tmp[2])){
+ $NAME = $tmp[2];
+ }
+ if(is_mac($MAC)){
+ $this->Initial_Target[] = array("MAC"=>$MAC,"IP"=>$IP,"NAME"=>$NAME);
+ }
+ }
+ }
+ }
+
/********
* Add target from list
********/
********/
$divlist = new divlist("goto_task");
- //$divlist->SetWidth("600");
$divlist->SetHeight("160");
$divlist->SetEntriesPerPage(0);
- $divlist->SetHeader(array(
+ $acl_target = $this->parent->getacl("Target");
+ if(preg_match("/w/i",$acl_target)){
+ $field_del = array("string" => "<input type='image' src='images/edittrash.png' name='remove_%KEY%'>" ,
+ "attach" => "style='width:44px;border-right:0px;'");
+ }else{
+ $field_del = array("string" => "",
+ "attach" => "style='width:44px;border-right:0px;'");
+ }
+
+ /* Add entries to divlist */
+ if($this->Action == "initial_install"){
+ $divlist->SetHeader(array(
+ array("string" => "Target"),
+ array("string" => "IP" , "attach" => "style='width:90px;'"),
+ array("string" => "Name" , "attach" => "style='width:150px;'"),
+ array("string" => "Actions" , "attach" => "style='width:44px;border-right:0px;text-align:right;'")));
+ foreach($this->Initial_Target as $key => $target){
+ $field1 = array("string" => $target['MAC'] );
+ $field2 = array("string" => $target['IP'] ,"attach" => "style='width:90px;'");
+ $field3 = array("string" => $target['NAME'] ,"attach" => "style='width:150px;'");
+ $divlist->AddEntry(array($field1,$field2,$field3,preg_replace("/%KEY%/",$key,$field_del)));
+ }
+ }else{
+ $divlist->SetHeader(array(
array("string" => "Target", "attach" => "style=''"),
array("string" => "Actions" , "attach" => "style='width:44px;border-right:0px;text-align:right;'")));
-
- $acl_target = $this->parent->getacl("Target");
- foreach($this->Target as $key => $target){
- $field1 = array("string" => $target, "attach" => "style:''");
- if(preg_match("/w/i",$acl_target)){
- $field2 = array("string" => "<input type='image' src='images/edittrash.png' name='remove_".$key."'>" ,
- "attach" => "style='width:44px;border-right:0px;'");
- }else{
- $field2 = array("string" => "",
- "attach" => "style='width:44px;border-right:0px;'");
- }
- $divlist->AddEntry(array($field1,$field2));
- }
+ foreach($this->Target as $key => $target){
+ $field1 = array("string" => $target);
+ $divlist->AddEntry(array($field1,preg_replace("/%KEY%/",$key,$field_del)));
+ }
+ }
$smarty = get_smarty();
foreach($this->attributes as $attr){
}
$tmp = $this->get_array_values();
+ $smarty->assign("JS" , $_SESSION['js']);
$smarty->assign("Minutes" , $tmp['Minute']);
$smarty->assign("Hours" , $tmp['Hour']);
$smarty->assign("Days" , $tmp['Day']);
"OGroup" => _("Object group") ,"Minute" => _("Minute"),
"Hour" => _("Hour") ,"Day" => _("Day"),
"Month" => _("Month") ,"Weekday"=> _("Week day"),
- "Action" => _("Action") ,"Comment"=> _("Description"),
- "Target" => _("Target objects"));
+ "Action" => _("Action") ,"Comment"=> _("Description"));
foreach($tmp as $name => $desc){
if(empty($this->$name)){
$message[] = sprintf(_("The given value for attribute '%s' is invalid."),$desc);
}
}
+ if(count($this->Target) == 0 && $this->Action != "initial_install"){
+ $message[] = sprintf(_("You must specify at least one traget"));
+ }
+ if(count($this->Initial_Target) == 0 && $this->Action == "initial_install"){
+ $message[] = sprintf(_("You must specify at least one traget"));
+ }
return($message);
}
diff --git a/plugins/addons/gotomasses/class_gotomasses.inc b/plugins/addons/gotomasses/class_gotomasses.inc
index c1850155b38bbc4c112acf682547180cae1a6357..b908533926bf6e65569bec8ce3eba8b7b10771ac 100644 (file)
$divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&sort=schedule'>"._("Schedule")."</a>",
"attach"=>"style='width:100px;'"));
$divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&sort=action'>"._("Type")."</a>",
- "attach"=>"style='width:60px;'"));
+ "attach"=>"style='width:80px;'"));
$divlist->AddHeader(array("string"=>_("Action"),
"attach"=>"style='border-right:0px;width:40px;'"));
}
$field1 = array("string" => "<div style='width:100%;overflow:hidden;'><nobr>".$this->target_to_string($task)."</nobr></div>");
$field2 = array("string" => $this->time_to_string($task),"attach" => "style='width:100px;'");
- $field3 = array("string" => $this->action_to_string($task),"attach" => "style='width:60px;'");
+ $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));
}
function target_to_string($data)
{
$ret = "";
- foreach($data['Target'] as $target){
- $ret .= $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));
}
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"));
}
}
$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;
}
$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*/
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"),
index 3dd8a97c7569983cd197e810c3671b0548ec544b..c50798aa1b7028b8b126418b0434e47c4736079f 100644 (file)
</td>
<td>
{render acl=$ActionACL}
- <select name="Action">
+ <select name="Action" onChange="document.mainform.submit();">
{html_options options=$Actions selected=$Action}
</select>
{/render}
+ {if !$JS}
+ <input type='image' src='images/list_reload.png' class='center'>
+ {/if}
</td>
</tr>
</table>
</td>
</tr>
</table>
+{if $Action == "initial_install"}
+<p class='seperator'> </p>
+<table style='width:100%;'>
+ <tr>
+ <td colspan="2" style='padding-top:5px;'>
+ <h2><img alt="" src="images/select_workstation.png" class="center" align="middle"> {t}Target systems{/t}</h2>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <table summary="" style="border:1px solid #B0B0B0;width:100%; " id="t_test_scrolltable" cellspacing=0 cellpadding=0>
+ <tr>
+ <td>
+ {render acl=$TargetACL}
+ {$Target_list}
+ {/render}
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td style="width:50%; border-right: 1px solid #A0A0A0;">
+ <table>
+ <tr>
+ <td>{t}MAC address{/t}*
+ </td>
+ <td><input type="text" name="task_MAC" value="">
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Name{/t}
+ </td>
+ <td><input type="text" name="task_Name" value="">
+ </td>
+ </tr>
+ <tr>
+ <td>{t}IP address{/t}
+ </td>
+ <td><input type="text" name="task_IP" value="">
+ {render acl=$TargetACL}
+ <input type="submit" name="add_target" value="{t}Add{/t}">
+ {/render}
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td>
+ <table>
+ <tr>
+ <td>
+ <input type="hidden" name="MAX_FILE_SIZE" value="2000000">
+ <input name="import_file" type="file" size="20" maxlength="255" accept="*.csv">
+ </td>
+ </tr>
+ <tr><td> </td></tr>
+ <tr>
+ <td>
+ {render acl=$TargetACL}
+ <input type="submit" name="add_import" value="{t}Add{/t}">
+ {/render}
+ </td>
+ </tr>
+ </table>
+ </tr>
+ </tr>
+</table>
+
+{else}
<p class='seperator'> </p>
<table style='width:100%;'>
<tr>
</td>
</tr>
</table>
+{/if}
<input type='hidden' name='goto_task_posted' value='1'>
<p style="text-align:right">
<input type='submit' name='save_goto_task' value='{t}Ok{/t}'>