Code

Cleaned up code
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 21 Aug 2007 07:50:10 +0000 (07:50 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 21 Aug 2007 07:50:10 +0000 (07:50 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7083 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/addons/gotomasses/class_goto_task.inc
plugins/addons/gotomasses/class_gotomasses.inc

index 5552313648fc54523e77fe8ccad74acab29f6661..a4b540561b1477cc5a525677a534f5536841e712 100644 (file)
@@ -16,11 +16,10 @@ class goto_task extends plugin
   var $Weekday  = "*";
   var $Action   = "install";
   var $Comment  = "";
+  var $OGroup   = "keep_current";
+  var $OGroups  = array();
   var $Target   = array();
-
   var $Actions  = array();
-  var $OGroup   = "";
-  var $OGroups  = array();
   var $new      = FALSE;
   var $attributes     = array("OGroup","Minute","Hour","Day","Month","Weekday","Action","Comment","Target");
 
@@ -85,7 +84,6 @@ class goto_task extends plugin
       }
     }
  
     /********
      * Add target from list 
      ********/
@@ -116,7 +114,6 @@ class goto_task extends plugin
       return($this->dialog->execute());
     }
 
-
     /********
      * Display this plugin  
      ********/
@@ -132,7 +129,6 @@ class goto_task extends plugin
 
     $acl_target = $this->parent->getacl("Target");
     foreach($this->Target as $key => $target){
-
       $field1 = array("string" => $target);
       if(preg_match("/w/i",$acl_target)){
         $field2 = array("string" => "<input type='image' src='images/edittrash.png' name='remove_".$key."'>" , 
@@ -141,12 +137,10 @@ class goto_task extends plugin
         $field2 = array("string" => "",
                                     "attach" => "style='width:40px;border-right:0px;'");
       }
-
       $divlist->AddEntry(array($field1,$field2));
     } 
 
     $smarty = get_smarty();
-
     foreach($this->attributes as $attr){
       $smarty->assign($attr."ACL", $this->parent->getacl($attr));
       $smarty->assign($attr,$this->$attr);
@@ -158,10 +152,8 @@ class goto_task extends plugin
     $smarty->assign("Days"    , $tmp['Day']);
     $smarty->assign("Months"  , $tmp['Month']);
     $smarty->assign("Weekdays", $tmp['Weekday']);
-
-    $smarty->assign("OGroups"  , $this->OGroups);
+    $smarty->assign("OGroups" , $this->OGroups);
     $smarty->assign("Expert"  , $this->Expert);
-
     $smarty->assign("Actions"     , $this->Actions);
     $smarty->assign("Target_list" , $divlist->DrawList());
     $smarty->assign("new"      , $this->new);
index 0399ec4fc187e0b11e70c59b50680846b000b607..88a3e1b267762c9eb51f6cce5e1e85adb0854ab4 100644 (file)
@@ -56,7 +56,6 @@ class gotomasses extends plugin
 
     /* Remove entry from list */
     if($s_action == "remove" && isset($this->tasks[$s_entry])){
-
       if(!$this->acl_is_removeable()){
         print_red(_("You are not allowed to remove a task."));
       }else{
@@ -181,7 +180,7 @@ class gotomasses extends plugin
   {
     $ret = "";
     foreach($data['Target'] as $target){
-      $ret .= preg_replace("/^[^:]+:/i","",$target).", ";
+      $ret .= $target.", ";
     } 
     return(preg_replace("/, $/","",$ret));
   }
@@ -210,12 +209,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));
@@ -276,10 +276,8 @@ 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," ")." ";
@@ -288,26 +286,27 @@ class gotomasses extends plugin
       $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.",";
       }
       $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);
@@ -316,8 +315,6 @@ class gotomasses extends plugin
 
   function save_object()
   {
-    if(isset($_POST['gotomasses'])){
-    }
   }