From: hickert Date: Tue, 21 Aug 2007 07:50:10 +0000 (+0000) Subject: Cleaned up code X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2dd0610553775a07cd552ccdcbbf650a18794a8c;p=gosa.git Cleaned up code git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7083 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/addons/gotomasses/class_goto_task.inc b/plugins/addons/gotomasses/class_goto_task.inc index 555231364..a4b540561 100644 --- a/plugins/addons/gotomasses/class_goto_task.inc +++ b/plugins/addons/gotomasses/class_goto_task.inc @@ -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" => "" , @@ -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); diff --git a/plugins/addons/gotomasses/class_gotomasses.inc b/plugins/addons/gotomasses/class_gotomasses.inc index 0399ec4fc..88a3e1b26 100644 --- a/plugins/addons/gotomasses/class_gotomasses.inc +++ b/plugins/addons/gotomasses/class_gotomasses.inc @@ -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'])){ - } }