From: cajus Date: Fri, 15 Feb 2008 14:47:36 +0000 (+0000) Subject: Moved gotomasses to gosa-plugins/goto X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=078065b234902c6ab076e8a571372832dd0f261a;p=gosa.git Moved gotomasses to gosa-plugins/goto git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8933 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/plugins/addons/gotomasses/class_goto_task.inc b/gosa-core/plugins/addons/gotomasses/class_goto_task.inc deleted file mode 100644 index e6f0eb2be..000000000 --- a/gosa-core/plugins/addons/gotomasses/class_goto_task.inc +++ /dev/null @@ -1,130 +0,0 @@ -parent = &$parent; - $this->data = $data; - - /* Intialize plugin */ - $this->config = &$config; - } - - - function execute() - { - $smarty = get_smarty(); - $smarty->assign("Actions",$this->parent->get_actions()); - foreach($this->attributes as $attr){ - if(isset($this->data[$attr])){ - $smarty->assign($attr,$this->data[$attr]); - }else{ - $smarty->assign($attr,""); - } - } - - $year = substr($this->data['TIMESTAMP'],0,4); - $month = substr($this->data['TIMESTAMP'],4,2); - $day = substr($this->data['TIMESTAMP'],6,2); - - $hour = substr($this->data['TIMESTAMP'],8,2); - $minute = substr($this->data['TIMESTAMP'],10,2); - $second = substr($this->data['TIMESTAMP'],12,2); - - $years = array(); - for($i = date("Y",time()); $i <= 2037 ;$i ++){ - $years[$i] = $i; - } - $months = array(); - for($i = 1; $i <= 12; $i ++){ - $e = str_pad($i,2,"0",STR_PAD_LEFT); - $months[$e] = $e; - } - $days = array(); - for($i = 1; $i <= cal_days_in_month(CAL_GREGORIAN,$month,$year); $i ++){ - $e = str_pad($i,2,"0",STR_PAD_LEFT); - $days[$e] = $e; - } - $hours = array(); - for($i = 0; $i < 24; $i ++){ - $e = str_pad($i,2,"0",STR_PAD_LEFT); - $hours[$e] = $e; - } - $minutes = array(); - for($i = 0; $i < 60; $i ++){ - $e = str_pad($i,2,"0",STR_PAD_LEFT); - $minutes[$e] = $e; - } - $seconds = array(); - for($i = 0; $i < 60; $i ++){ - $e = str_pad($i,2,"0",STR_PAD_LEFT); - $seconds[$e] = $e; - } - - $smarty->assign("years", $years); - $smarty->assign("months", $months); - $smarty->assign("days", $days); - $smarty->assign("hours", $hours); - $smarty->assign("minutes", $minutes); - $smarty->assign("seconds", $seconds); - - $smarty->assign("time_year",$year); - $smarty->assign("time_month",$month); - $smarty->assign("time_day",$day); - $smarty->assign("time_hour",$hour); - $smarty->assign("time_minute",$minute); - $smarty->assign("time_second",$second); - - return ($smarty->fetch (get_template_path('goto_task.tpl', TRUE))); - } - - - function save_object() - { - if(isset($_POST['HeaderTag'])){ - $possible_tags = $this->parent->get_actions(); - $tag = $_POST['HeaderTag']; - if(isset($possible_tags[$tag])){ - $this->data['HEADERTAG'] = $tag; - } - } - foreach(array("status","macaddress") as $attr){ - if(isset($_POST[$attr])){ - $this->data[strtoupper($attr)] = $_POST[$attr]; - } - } - $date = ""; - foreach(array("time_year","time_month","time_day","time_hour","time_minute","time_second") as $attr){ - if(isset($_POST[$attr])){ - $date .= $_POST[$attr]; - } - } - if(strlen($date) == 14){ - $this->data['TIMESTAMP'] = $date; - } - } - - function save() - { - $tmp = array(); - foreach(array("STATUS","MACADDRESS","HEADERTAG","TIMESTAMP") as $attr){ - if(isset($this->data[$attr])){ - $tmp[$attr] = $this->data[$attr]; - } - } - return($tmp); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-core/plugins/addons/gotomasses/class_gotomasses.inc b/gosa-core/plugins/addons/gotomasses/class_gotomasses.inc deleted file mode 100644 index 75b40f62f..000000000 --- a/gosa-core/plugins/addons/gotomasses/class_gotomasses.inc +++ /dev/null @@ -1,485 +0,0 @@ -config= &$config; - $this->o_queue = new gosaSupportDaemon(TRUE,10); - } - - - function execute() - { - $smarty = get_smarty(); - - /************ - * Handle posts - ************/ - - $s_entry = $s_action = ""; - $arr = array( - "/^stop_/" => "stop", - "/^stop_all/" => "stop_all", - "/^start_/" => "start", - "/^start_all/" => "start_all", - - "/^edit_task_/" => "edit", - "/^remove_task_/" => "remove", - "/^new_task_/" => "new_task", - "/^remove_multiple_task_/" => "remove_multiple"); - - foreach($arr as $regex => $action){ - foreach($_POST as $name => $value){ - if(preg_match($regex,$name)){ - $s_action = $action; - $s_entry = preg_replace($regex,"",$name); - $s_entry = preg_replace("/_(x|y)$/","",$s_entry); - } - } - } - - /* Edit posted from list link */ - if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id']) && isset($this->tasks[$_GET['id']])){ - $s_action = "edit"; - $s_entry = $_GET['id']; - } - - - /************ - * Handle Priority modifications - ************/ - - if(preg_match("/^start/",$s_action) || preg_match("/^stop/",$s_action)){ - - switch($s_action){ - case 'start_all' : $this->start_queue_entries($this->list_get_selected_items());break; - case 'start' : $this->start_queue_entries(array($s_entry));break; - case 'stop_all' : $this->stop_queue_entries ($this->list_get_selected_items());break; - case 'stop' : $this->stop_queue_entries (array($s_entry));break; - default : trigger_error("Undefined priority setting used."); - } - if($this->o_queue->is_error()){ - msg_dialog::display(_("Error"), $this->o_queue->get_error(), ERROR_DIALOG); - } - } - - /************ - * REMOVE - ************/ - - /* Remove multiple */ - if($s_action == "remove_multiple" || $s_action == "remove"){ - - if(!$this->acl_is_removeable()){ - msg_dialog::display(_("Permission error"), _("You have no permission to delete this entry!"), ERROR_DIALOG); - }else{ - - if($s_action == "remove"){ - $ids = array($s_entry); - }else{ - $ids = $this->list_get_selected_items(); - } - if(count($ids)){ - $this->ids_to_remove = $ids; - $ret = $this->o_queue->ids_exist($this->ids_to_remove); - $ret = $this->o_queue->get_entries_by_id($ret); - - $tmp = ""; - foreach($ret as $task){ - $tmp.= "\n".$task['ID']." - ".$task['HEADERTAG']." ".$task['MACADDRESS']; - } - $smarty->assign("multiple", TRUE); - $smarty->assign("info",sprintf(_("Your are about to delete the following tasks: %s"),"
".$tmp."
")); - $this->current = $s_entry; - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } - } - } - - /* Remove specified tasks */ - if(count($this->ids_to_remove) && isset($_POST['delete_multiple_confirm'])){ - $this->o_queue->remove_entries($this->ids_to_remove); - $this->save(); - } - - /* Remove aborted */ - if(isset($_POST['delete_cancel'])){ - $this->ids_to_remove = array();; - } - - - /************ - * EDIT - ************/ - - /* Edit selected entry */ - if($s_action == "edit"){ - $entry = $this->o_queue->get_entry_by_id($s_entry); - if($entry){ - $this->dialog = new goto_task($this->config,$this,$entry); - $this->current = $s_entry; - } - } - - /* New entry */ - if($s_action== "new_task" && $this->acl_is_createable()){ - $this->dialog = new goto_task($this->config,$this); - $this->current = -1; - } - - /* Close dialog */ - if(isset($_POST['close_goto_task'])){ - $this->dialog = FALSE; - $this->current = -1; - } - - /* Close 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)){ - foreach($msgs as $msg){ - msg_dialog::display(_("Error"), $msg, ERROR_DIALOG); - } - }else{ - - if($this->o_queue->id_exists($this->current)){ - $this->o_queue->update_entries(array($this->current),$this->dialog->save()); - }else{ - $tmp = $this->dialog->save(); - $tmp2= array(); - $targets =$tmp['Target']; - foreach($targets as $target){ - $tmp['Target'] = array($target); - $tmp2[] = $tmp; - } - if(!$this->o_queue->add_multiple($tmp2)){ - msg_dialog::display(_("Error"), $this->o_queue->get_error(), ERROR_DIALOG); - } - } - 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(); - return($this->dialog->execute()); - } - - /************ - * Handle Divlist - ************/ - - $divlist = new MultiSelectWindow($this->config,"gotoMasses",array("gotomasses")); - $divlist->SetInformation(_("This menu allows you to remove and change the properties of GOsa deamon tasks.")); - $divlist->SetSummary(_("List of queued deamon jobs.")); - $divlist->EnableCloseButton(FALSE); - $divlist->EnableSaveButton(FALSE); - $divlist->SetHeadpageMode(); - - if($this->sort_dir == "up"){ - $sort_img = "/\"; - }else{ - $sort_img = "\/"; - } - - if($this->sort_by == "TargetName"){ $sort_img_1 = $sort_img; } else { $sort_img_1 = "" ;} - if($this->sort_by == "TaskID"){ $sort_img_2 = $sort_img; } else { $sort_img_2 = "" ;} - if($this->sort_by == "Schedule"){ $sort_img_3 = $sort_img; } else { $sort_img_3 = "" ;} - if($this->sort_by == "Action"){ $sort_img_4 = $sort_img; } else { $sort_img_4 = "" ;} - - /* Display add button if allowed */ - $header = "
"; - if($this->acl_is_removeable()){ - $header .= " "; - } - if(preg_match("/w/",$this->getacl(""))){ - $header .= " "; - $header .= " "; - } - $header .= "
"; - - /* Create divlist */ - $divlist->SetListHeader($header); - - $plug = $_GET['plug']; - $chk = ""; - - /* set Page header */ - $divlist->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); - $divlist->AddHeader(array("string"=>""._("Target").$sort_img_1." / ". - ""._("Task").$sort_img_2."")); - $divlist->AddHeader(array("string"=>""._("Schedule").$sort_img_3."", - "attach"=>"style='width:100px;'")); - $divlist->AddHeader(array("string"=>""._("Status").$sort_img_4."", - "attach"=>"style='width:80px;'")); - $divlist->AddHeader(array("string"=>_("Action"), - "attach"=>"style='border-right:0px;width:120px;'")); - - - $entries = $this->get_queued_entries(); - - foreach($entries as $key => $task){ - - $prio_actions = " "; - $prio_actions.= " "; - - $action = ""; - - if($this->acl_is_removeable()){ - $action.= ""; - } - - $color = ""; - $display = $task['MACADDRESS']; - $display2= $task['HEADERTAG']; - - /* Create each field */ - $field0 = array("string" => "" , - "attach" => "style='width:20px;".$color."'"); - $field1 = array("string" => $display, - "attach" => "style='".$color."'"); - $field1a= array("string" => $display2, - "attach" => "style='".$color.";width:80px;'"); - $field2 = array("string" => date("d.m.Y H:i:s",strtotime($task['TIMESTAMP'])),"attach" => "style='".$color.";width:100px;'"); - $field3 = array("string" => $task['STATUS'],"attach" => "style='".$color.";width:80px;'"); - $field4 = array("string" => $prio_actions.$action,"attach" => "style='".$color.";text-align:right;width:120px;border-right:0px;'"); - $divlist->AddElement(array($field0,$field1,$field1a,$field2,$field3,$field4)); - } - - - $smarty = get_smarty(); - $smarty->assign("start",$this->start); - $smarty->assign("start_real", ($this->start + 1)); - $smarty->assign("ranges", array("10" => "10", - "20" => "20", - "25" => "25", - "50" => "50", - "100"=> "100", - "200"=> "200", - "9999" => "*")); - - $count = $this->o_queue->number_of_queued_entries(); - $smarty->assign("range_selector", range_selector($count, $this->start, $this->range,"range")); - $smarty->assign("range",$this->range); - $smarty->assign("div",$divlist->Draw()); - return($smarty->fetch (get_template_path('gotomasses.tpl', TRUE, dirname(__FILE__)))); - } - - - /*! \brief Force queue job to be done as far as possible. - * @return Boolean TRUE in case of success, else FALSE. - */ - private function start_queue_entries($ids) - { - if(!count($ids)){ - return; - } - - $data = array("timestamp" => date("YmdHis"), - "status" => "-"); - if(!$this->o_queue->update_entries($ids,$data)){ - msg_dialog::display(_("Error"), sprintf(_("Could not update queue entry: %s"),$id) , ERROR_DIALOG); - return(FALSE); - } - return(TRUE); - } - - - /*! \brief Stops the specified queue entry from execution. - * @return Boolean TRUE in case of success, else FALSE. - */ - private function stop_queue_entries($ids) - { - if(!count($ids)){ - return; - } - $data = array("timestamp" => "20490101010101", - "status" => "Stoppped"); - if(!$this->o_queue->update_entries($ids,$data)){ - msg_dialog::display(_("Error"), sprintf(_("Could not update queue entry: %s"),$id) , ERROR_DIALOG); - return(FALSE); - } - return(TRUE); - } - - - /*! \brief Request list of queued jobs. - * @return Returns an array of all queued jobs. - */ - function get_queued_entries() - { - $map = array( - "QueuePosition" => "id", - "Action" => "status", - "TaskID" => "headertag", - "TargetName" => "macaddress", - "Schedule" => "timestamp"); - - if(!isset($map[$this->sort_by])){ - $sort = "id DESC"; - }else{ - $sort = $map[$this->sort_by]; - if($this->sort_dir == "up"){ - $sort.= " ASC"; - }else{ - $sort.= " DESC"; - } - } - - $start = $this->start; - $stop = $this->range; - $entries = $this->o_queue->get_queued_entries($start,$stop,$sort); - if(!is_array($entries) || !isset($entries['XML']) || !is_array($entries['XML'])){ - if ($this->o_queue->get_error()){ - msg_dialog::display(_("Error"), sprintf(_("Cannot load queue entries: %s"), "

".$this->o_queue->get_error()), ERROR_DIALOG); - } - return(array()); - } - - $ret = array(); - foreach($entries['XML'] as $entry){ - $task = $entry['ID']; - $ret[]= $entry; - } - return($ret); - } - - - /*! \brief Handle post jobs, like sorting. - */ - function save_object() - { - $sort_vals = array("Action","QueuePosition","TargetName","Schedule","TaskID"); - if(isset($_GET['sort']) && in_array($_GET['sort'],$sort_vals)){ - $sort = $_GET['sort']; - if($this->sort_by == $sort){ - if($this->sort_dir == "up"){ - $this->sort_dir = "down"; - }else{ - $this->sort_dir = "up"; - } - } - $this->sort_by = $sort; - } - if(isset($_POST['range']) && is_numeric($_POST['range'])){ - $this->range = $_POST['range']; - } - if(isset($_GET['start'])){ - $start = $_GET['start']; - if(is_numeric($start) || $start == 0){ - $this->start = $start; - } - } - - /* Check start stop and reset if necessary */ - $count = $this->o_queue->number_of_queued_entries(); - if($this->start >= $count){ - $this->start = $count -1; - } - if($this->start < 0){ - $this->start = 0; - } - } - - - /* Return list of object groups */ - function get_object_groups() - { - $ret = array(); - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=gosaGroupOfNames)(cn=*))",array("cn")); - while($attrs = $ldap->fetch()){ - $ret[$attrs['cn'][0]] = $attrs['cn'][0]; - } - return($ret); - } - - - function save() - { - // We do not save anything here. - } - - - /*! \brief Return a list of all selected items. - @return Array Returns an array containing all selected item ids. - */ - function list_get_selected_items() - { - $ids = array(); - foreach($_POST as $name => $value){ - if(preg_match("/^item_selected_[0-9]*$/",$name)){ - $id = preg_replace("/^item_selected_/","",$name); - $ids[$id] = $id; - } - } - return($ids); - } - - - function get_actions() - { - /* Prepare list of available actions */ - $actions = array( - "gosa_ping" => _("GOsa ping"), - "ping" => _("Ping"), - "sayHello" => _("Say hello")); - return($actions); - } - - - static function plInfo() - { - return (array( - "plShortName" => _("System mass deployment"), - "plDescription" => _("Provide a mechanism to automatically activate a set of systems"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 0, - "plSection" => array("addon"), - "plCategory" => array("gotomasses" => array("objectClass" => "none", "description" => _("System mass deployment"))), - "plProvidedAcls" => array("Comment" => _("Description"), - "Action" => _("Action"), - "Day" => _("Day"), - "Minute" => _("Minute"), - "Hour" => _("Hour"), - "Month" => _("Month"), - "Weekday" => _("Week day"), - "Target" => _("Target")) - )); - } -} -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-core/plugins/addons/gotomasses/class_target_list.inc b/gosa-core/plugins/addons/gotomasses/class_target_list.inc deleted file mode 100644 index 2cf1a24e1..000000000 --- a/gosa-core/plugins/addons/gotomasses/class_target_list.inc +++ /dev/null @@ -1,303 +0,0 @@ -AddCheckBox */ - var $ogroups ; - var $servers ; - var $workstations ; - - - /* Subsearch checkbox */ - var $SubSearch ; - var $IPMatch ; - var $parent ; - var $ui ; - - - function target_list(&$config,$Targets_used) - { - MultiSelectWindow::MultiSelectWindow($config, "Targetselection", array("ogroup","gotomasses")); - - $this->Targets_used = $Targets_used; - - $this->SetInformation( _("Select the target objects for your scheduled action.")); - $this->SetTitle( _("Available targets")); - $this->SetSummary( _("Available targets")); - $this->SetHeadpageMode(FALSE); - - /* set Page header */ - $chk = ""; - $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); - - $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); - $this->AddHeader(array("string" => _("Object name"), "attach" => "style=''")); - - /* Text ,Value, Name, Is selected */ - $this->AddCheckBox("ogroups", _("Select to see object groups"), _("Show object groups"), true); - $this->AddCheckBox("servers", _("Select to see servers") , _("Show servers"), true); - $this->AddCheckBox("workstations", _("Select to see workstations"),_("Show workstations"), true); - - /* Add SubSearch checkbox */ - $this->AddCheckBox(SEPERATOR); - $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); - $this->AddCheckBox("IPMatch", _("Select to search for a specific IP range only"), _("Match IP range"), false); - - /* Name,Text,Default , Connect with alphabet */ - $this->AddRegex ("Regex", _("Regular expression for matching group names"), "*" , true); - $this->AddRegex ("IP_start", _("IP range start"), "0.0.0.0" , true); - $this->AddRegex ("IP_end", _("IP range end"), "255.255.255.255" , true); - $this->EnableAplhabet(TRUE); - } - - - function GenHeader() - { - $options= ""; - - /* Get all departments within this subtree */ - $ui= get_userinfo(); - $first = ""; - $found = FALSE; - $base = $this->config->current['BASE']; - - /* Add base */ - $tmp = array(); - $tmp[] = array("dn"=>$this->config->current['BASE']); - $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, - array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); - - $deps = array(); - foreach($tmp as $tm){ - $deps[$tm['dn']] = $tm['dn']; - } - - /* Load possible departments */ - $ui= get_userinfo(); - $tdeps= $ui->get_module_departments("ogroups"); - $ids = $this->config->idepartments; - $first = ""; - $found = FALSE; - foreach($ids as $dep => $name){ - if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ - - /* Keep first base dn in mind, we could need this - * info if no valid base was found - */ - if(empty($first)) { - $first = $dep['dn']; - } - - $value = $ids[$dep]; - if ($this->selectedBase == $dep){ - $found = TRUE; - $options.= ""; - } else { - $options.= ""; - } - } - } - - /* The currently used base is not visible with your acl setup. - * Set base to first useable base. - */ - if(!$found){ - $this->selectedBase = $first; - } - - /* Get copy & paste icon */ - $acls = $ui->get_permissions($this->selectedBase,"ogroups/ogroup"); - $acl_all= $ui->has_complete_category_acls($this->selectedBase,"ogroups"); - - /* Add default header */ - $listhead = MultiSelectWindow::get_default_header(); - - /* Add department selector */ - $listhead .= _("Base")." ". - "  "; - $listhead .=""; - - $this->SetListHeader($listhead); - } - - - function execute() - { - $this->ClearElementsList(); - $this->GenHeader(); - $this->reload(); - $this->SetEntries($this->list); - return($this->Draw()); - } - - - function SetEntries($list) - { - /* Add Copy & Paste buttons if copy&paste is enabled - */ - // Defining Links - $linkopen = "%s"; - $editlink = "%s"; - - $ui = get_userinfo(); - - // Assigning ogroups - foreach($list as $key => $val){ - - if(in_array($val['cn'][0],$this->Targets_used) || - isset($val['macAddress'][0]) && in_array($val['macAddress'][0],$this->Targets_used)) continue; - - $title = "title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"; - if(!isset($val['description'][0])){ - $desc = ""; - }else{ - $desc = " - [ ".$val['description'][0]." ]"; - } - if(!isset($val['ipHostNumber'][0])){ - $desc.= ""; - }else{ - $desc.= " - ".$val['ipHostNumber'][0].""; - } - - - $img ="Hmm"; - if(in_array("goServer",$val['objectClass'])){ - $img = ""._("Server").""; - }elseif(in_array("gotoWorkstation",$val['objectClass'])){ - $img = ""._("Workstation").""; - }elseif(in_array("gosaGroupOfNames",$val['objectClass'])){ - $img = ""._("Object group").""; - } - - /* Create each field */ - $field0 = array("string" => "" , - "attach" => "style='width:20px;'"); - $field1 = array("string" => $img, - "attach" => "style='text- align:center;width: 20px;'"); - $field2 = array("string" => $val['cn'][0].$desc, - "attach" => "style='border-right:0px;' ".$title); - - $this->AddElement(array($field0,$field1,$field2)); - } - } - - - function save() - { - $ret = array(); - $items = $this->list_get_selected_items(); - foreach($items as $item){ - $ret[] = $this->list[$item]; - } - return($ret); - } - - - function save_object() - { - MultiSelectWindow::save_object(); - } - - - function reload() - { - /* Set base for all searches && initialise some vars */ - $this->list= array(); - $base = $this->selectedBase; - $filter = ""; - $Regex = $this->Regex; - $IP_start = $this->IP_start; - $IP_end = $this->IP_end; - - if($this->IPMatch){ - if(!tests::is_ip($IP_start)){ - msg_dialog::display(_("Error"), _("IP range is invalid!"), ERROR_DIALOG); - return; - } - if(!tests::is_ip($IP_end)){ - msg_dialog::display(_("Error"), _("IP range is invalid!"), ERROR_DIALOG); - return; - } - } - - - $chk = array( - "ogroups" => "(&(objectClass=gosaGroupOfNames)(|(gosaGroupObjects=*S*)(gosaGroupObjects=*W*)))" , - "servers" => "(objectClass=goServer)" , - "workstations" => "(objectClass=gotoWorkstation)"); - - /* Create filter */ - foreach($chk as $chkBox => $FilterPart){ - if($this->$chkBox){ - $filter .= $FilterPart; - } - } - $filter= "(&(cn=".$Regex.")(|".$filter."))"; - - if($this->SubSearch){ - $res= get_list($filter, array("ogroups","workstations","servers"), $base, - array("cn","objectClass","gosaGroupObjects","ipHostNumber","description"), GL_SIZELIMIT | GL_SUBSEARCH); - }else{ - $res= get_list($filter, "ogroups", get_groups_ou().$base, - array("cn","objectClass","ipHostNumber","description"), GL_SIZELIMIT ); - $res= array_merge($res,get_list($filter, "workstation", get_ou('workstationou').$base, - array("cn","objectClass","ipHostNumber","description"), GL_SIZELIMIT )); - $res= array_merge($res,get_list($filter, "server", get_ou('serverou').$base, - array("cn","objectClass","ipHostNumber","description"), GL_SIZELIMIT )); - } - - $this->list= $res; - ksort ($this->list); - reset ($this->list); - $tmp=array(); - foreach($this->list as $tkey => $val ){ - - if($this->IPMatch){ - if(isset($val['ipHostNumber'][0])){ - if(tests::is_ip_range($IP_start,$val['ipHostNumber'][0]) && tests::is_ip_range($val['ipHostNumber'][0],$IP_end)){ - $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val; - } - } - }else{ - $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val; - } - } - ksort($tmp); - $this->list=array(); - foreach($tmp as $val){ - $this->list[]=$val; - } - reset ($this->list); - } - - function list_get_selected_items() - { - $ids = array(); - foreach($_POST as $name => $value){ - if(preg_match("/^item_selected_[0-9]*$/",$name)){ - $id = preg_replace("/^item_selected_/","",$name); - $ids[$id] = $id; - } - } - return($ids); - } -} - - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-core/plugins/addons/gotomasses/goto_task.tpl b/gosa-core/plugins/addons/gotomasses/goto_task.tpl deleted file mode 100644 index 61220bd45..000000000 --- a/gosa-core/plugins/addons/gotomasses/goto_task.tpl +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - - - -
-

{t}Job details{/t}

-
- - - - - - - - - - - - - -
{t}Job ID{/t}{$ID}
- {t}Header Tag{/t} - - - -
  -
- {t}Schedule Execution{/t} - - - - - - - - - - - - - - - - - - -
{t}Jahr{/t}{t}Monat{/t}{t}Tag{/t}{t}Stunde{/t}{t}Minute{/t}{t}Sekunde{/t}
-   - -   - -   - -   - -   - - -
-
-
- -{if $HEADERTAG == "ping"} - - -{elseif $HEADERTAG == "sayHello"} - - -{else} - -{/if} -
{t}Status{/t}
{t}Mac{/t}
{t}Status{/t}
{t}Mac{/t}
{t}Job type not implented{/t}
-
- -

 

- -

- - -

diff --git a/gosa-core/plugins/addons/gotomasses/gotomasses.tpl b/gosa-core/plugins/addons/gotomasses/gotomasses.tpl deleted file mode 100644 index 844cdebf6..000000000 --- a/gosa-core/plugins/addons/gotomasses/gotomasses.tpl +++ /dev/null @@ -1,4 +0,0 @@ -{$div} -
-{$range_selector} -
diff --git a/gosa-core/plugins/addons/gotomasses/main.inc b/gosa-core/plugins/addons/gotomasses/main.inc deleted file mode 100644 index 7a517fecd..000000000 --- a/gosa-core/plugins/addons/gotomasses/main.inc +++ /dev/null @@ -1,54 +0,0 @@ -set_acl_category("gotomasses"); - - /* Check root dn and user dn for acl informations */ - $gotomasses->set_acl_base($config->current['BASE']); - if($gotomasses->getacl("") == ""){ - $gotomasses->set_acl_base($ui->dn); - } - - /* Check if we have acl on our own base */ - if($gotomasses->getacl("") == ""){ - $gotomasses->set_acl_base(dn2base($ui->dn)); - } - session::set("gotomasses",$gotomasses); - } - $gotomasses = session::get('gotomasses'); - - /* Execute formular */ - $display= $gotomasses->save_object(); - if(isset($_POST['save_gotomass_changes'])){ - $gotomasses->save(); - } - $display= $gotomasses->execute (); - - /* Page header*/ - $display= print_header(get_template_path('images/system.png'), _("System deployment")).$display; - - /* Store changes in session */ - session::set('gotomasses',$gotomasses); -} diff --git a/gosa-core/plugins/addons/gotomasses/remove.tpl b/gosa-core/plugins/addons/gotomasses/remove.tpl deleted file mode 100644 index 023142f97..000000000 --- a/gosa-core/plugins/addons/gotomasses/remove.tpl +++ /dev/null @@ -1,21 +0,0 @@ -
-  {t}Warning{/t} -
-

- {$info} - {t}This includes all account data, system access rules, imap settings, etc. for this user. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} -

- -

- {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} -

- -

-{if $multiple} - -{else} - -{/if} - -

- diff --git a/gosa-plugins/goto/addons/gotomasses/class_goto_task.inc b/gosa-plugins/goto/addons/gotomasses/class_goto_task.inc new file mode 100644 index 000000000..e6f0eb2be --- /dev/null +++ b/gosa-plugins/goto/addons/gotomasses/class_goto_task.inc @@ -0,0 +1,130 @@ +parent = &$parent; + $this->data = $data; + + /* Intialize plugin */ + $this->config = &$config; + } + + + function execute() + { + $smarty = get_smarty(); + $smarty->assign("Actions",$this->parent->get_actions()); + foreach($this->attributes as $attr){ + if(isset($this->data[$attr])){ + $smarty->assign($attr,$this->data[$attr]); + }else{ + $smarty->assign($attr,""); + } + } + + $year = substr($this->data['TIMESTAMP'],0,4); + $month = substr($this->data['TIMESTAMP'],4,2); + $day = substr($this->data['TIMESTAMP'],6,2); + + $hour = substr($this->data['TIMESTAMP'],8,2); + $minute = substr($this->data['TIMESTAMP'],10,2); + $second = substr($this->data['TIMESTAMP'],12,2); + + $years = array(); + for($i = date("Y",time()); $i <= 2037 ;$i ++){ + $years[$i] = $i; + } + $months = array(); + for($i = 1; $i <= 12; $i ++){ + $e = str_pad($i,2,"0",STR_PAD_LEFT); + $months[$e] = $e; + } + $days = array(); + for($i = 1; $i <= cal_days_in_month(CAL_GREGORIAN,$month,$year); $i ++){ + $e = str_pad($i,2,"0",STR_PAD_LEFT); + $days[$e] = $e; + } + $hours = array(); + for($i = 0; $i < 24; $i ++){ + $e = str_pad($i,2,"0",STR_PAD_LEFT); + $hours[$e] = $e; + } + $minutes = array(); + for($i = 0; $i < 60; $i ++){ + $e = str_pad($i,2,"0",STR_PAD_LEFT); + $minutes[$e] = $e; + } + $seconds = array(); + for($i = 0; $i < 60; $i ++){ + $e = str_pad($i,2,"0",STR_PAD_LEFT); + $seconds[$e] = $e; + } + + $smarty->assign("years", $years); + $smarty->assign("months", $months); + $smarty->assign("days", $days); + $smarty->assign("hours", $hours); + $smarty->assign("minutes", $minutes); + $smarty->assign("seconds", $seconds); + + $smarty->assign("time_year",$year); + $smarty->assign("time_month",$month); + $smarty->assign("time_day",$day); + $smarty->assign("time_hour",$hour); + $smarty->assign("time_minute",$minute); + $smarty->assign("time_second",$second); + + return ($smarty->fetch (get_template_path('goto_task.tpl', TRUE))); + } + + + function save_object() + { + if(isset($_POST['HeaderTag'])){ + $possible_tags = $this->parent->get_actions(); + $tag = $_POST['HeaderTag']; + if(isset($possible_tags[$tag])){ + $this->data['HEADERTAG'] = $tag; + } + } + foreach(array("status","macaddress") as $attr){ + if(isset($_POST[$attr])){ + $this->data[strtoupper($attr)] = $_POST[$attr]; + } + } + $date = ""; + foreach(array("time_year","time_month","time_day","time_hour","time_minute","time_second") as $attr){ + if(isset($_POST[$attr])){ + $date .= $_POST[$attr]; + } + } + if(strlen($date) == 14){ + $this->data['TIMESTAMP'] = $date; + } + } + + function save() + { + $tmp = array(); + foreach(array("STATUS","MACADDRESS","HEADERTAG","TIMESTAMP") as $attr){ + if(isset($this->data[$attr])){ + $tmp[$attr] = $this->data[$attr]; + } + } + return($tmp); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/goto/addons/gotomasses/class_gotomasses.inc b/gosa-plugins/goto/addons/gotomasses/class_gotomasses.inc new file mode 100644 index 000000000..75b40f62f --- /dev/null +++ b/gosa-plugins/goto/addons/gotomasses/class_gotomasses.inc @@ -0,0 +1,485 @@ +config= &$config; + $this->o_queue = new gosaSupportDaemon(TRUE,10); + } + + + function execute() + { + $smarty = get_smarty(); + + /************ + * Handle posts + ************/ + + $s_entry = $s_action = ""; + $arr = array( + "/^stop_/" => "stop", + "/^stop_all/" => "stop_all", + "/^start_/" => "start", + "/^start_all/" => "start_all", + + "/^edit_task_/" => "edit", + "/^remove_task_/" => "remove", + "/^new_task_/" => "new_task", + "/^remove_multiple_task_/" => "remove_multiple"); + + foreach($arr as $regex => $action){ + foreach($_POST as $name => $value){ + if(preg_match($regex,$name)){ + $s_action = $action; + $s_entry = preg_replace($regex,"",$name); + $s_entry = preg_replace("/_(x|y)$/","",$s_entry); + } + } + } + + /* Edit posted from list link */ + if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id']) && isset($this->tasks[$_GET['id']])){ + $s_action = "edit"; + $s_entry = $_GET['id']; + } + + + /************ + * Handle Priority modifications + ************/ + + if(preg_match("/^start/",$s_action) || preg_match("/^stop/",$s_action)){ + + switch($s_action){ + case 'start_all' : $this->start_queue_entries($this->list_get_selected_items());break; + case 'start' : $this->start_queue_entries(array($s_entry));break; + case 'stop_all' : $this->stop_queue_entries ($this->list_get_selected_items());break; + case 'stop' : $this->stop_queue_entries (array($s_entry));break; + default : trigger_error("Undefined priority setting used."); + } + if($this->o_queue->is_error()){ + msg_dialog::display(_("Error"), $this->o_queue->get_error(), ERROR_DIALOG); + } + } + + /************ + * REMOVE + ************/ + + /* Remove multiple */ + if($s_action == "remove_multiple" || $s_action == "remove"){ + + if(!$this->acl_is_removeable()){ + msg_dialog::display(_("Permission error"), _("You have no permission to delete this entry!"), ERROR_DIALOG); + }else{ + + if($s_action == "remove"){ + $ids = array($s_entry); + }else{ + $ids = $this->list_get_selected_items(); + } + if(count($ids)){ + $this->ids_to_remove = $ids; + $ret = $this->o_queue->ids_exist($this->ids_to_remove); + $ret = $this->o_queue->get_entries_by_id($ret); + + $tmp = ""; + foreach($ret as $task){ + $tmp.= "\n".$task['ID']." - ".$task['HEADERTAG']." ".$task['MACADDRESS']; + } + $smarty->assign("multiple", TRUE); + $smarty->assign("info",sprintf(_("Your are about to delete the following tasks: %s"),"
".$tmp."
")); + $this->current = $s_entry; + return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + } + } + } + + /* Remove specified tasks */ + if(count($this->ids_to_remove) && isset($_POST['delete_multiple_confirm'])){ + $this->o_queue->remove_entries($this->ids_to_remove); + $this->save(); + } + + /* Remove aborted */ + if(isset($_POST['delete_cancel'])){ + $this->ids_to_remove = array();; + } + + + /************ + * EDIT + ************/ + + /* Edit selected entry */ + if($s_action == "edit"){ + $entry = $this->o_queue->get_entry_by_id($s_entry); + if($entry){ + $this->dialog = new goto_task($this->config,$this,$entry); + $this->current = $s_entry; + } + } + + /* New entry */ + if($s_action== "new_task" && $this->acl_is_createable()){ + $this->dialog = new goto_task($this->config,$this); + $this->current = -1; + } + + /* Close dialog */ + if(isset($_POST['close_goto_task'])){ + $this->dialog = FALSE; + $this->current = -1; + } + + /* Close 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)){ + foreach($msgs as $msg){ + msg_dialog::display(_("Error"), $msg, ERROR_DIALOG); + } + }else{ + + if($this->o_queue->id_exists($this->current)){ + $this->o_queue->update_entries(array($this->current),$this->dialog->save()); + }else{ + $tmp = $this->dialog->save(); + $tmp2= array(); + $targets =$tmp['Target']; + foreach($targets as $target){ + $tmp['Target'] = array($target); + $tmp2[] = $tmp; + } + if(!$this->o_queue->add_multiple($tmp2)){ + msg_dialog::display(_("Error"), $this->o_queue->get_error(), ERROR_DIALOG); + } + } + 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(); + return($this->dialog->execute()); + } + + /************ + * Handle Divlist + ************/ + + $divlist = new MultiSelectWindow($this->config,"gotoMasses",array("gotomasses")); + $divlist->SetInformation(_("This menu allows you to remove and change the properties of GOsa deamon tasks.")); + $divlist->SetSummary(_("List of queued deamon jobs.")); + $divlist->EnableCloseButton(FALSE); + $divlist->EnableSaveButton(FALSE); + $divlist->SetHeadpageMode(); + + if($this->sort_dir == "up"){ + $sort_img = "/\"; + }else{ + $sort_img = "\/"; + } + + if($this->sort_by == "TargetName"){ $sort_img_1 = $sort_img; } else { $sort_img_1 = "" ;} + if($this->sort_by == "TaskID"){ $sort_img_2 = $sort_img; } else { $sort_img_2 = "" ;} + if($this->sort_by == "Schedule"){ $sort_img_3 = $sort_img; } else { $sort_img_3 = "" ;} + if($this->sort_by == "Action"){ $sort_img_4 = $sort_img; } else { $sort_img_4 = "" ;} + + /* Display add button if allowed */ + $header = "
"; + if($this->acl_is_removeable()){ + $header .= " "; + } + if(preg_match("/w/",$this->getacl(""))){ + $header .= " "; + $header .= " "; + } + $header .= "
"; + + /* Create divlist */ + $divlist->SetListHeader($header); + + $plug = $_GET['plug']; + $chk = ""; + + /* set Page header */ + $divlist->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); + $divlist->AddHeader(array("string"=>""._("Target").$sort_img_1." / ". + ""._("Task").$sort_img_2."")); + $divlist->AddHeader(array("string"=>""._("Schedule").$sort_img_3."", + "attach"=>"style='width:100px;'")); + $divlist->AddHeader(array("string"=>""._("Status").$sort_img_4."", + "attach"=>"style='width:80px;'")); + $divlist->AddHeader(array("string"=>_("Action"), + "attach"=>"style='border-right:0px;width:120px;'")); + + + $entries = $this->get_queued_entries(); + + foreach($entries as $key => $task){ + + $prio_actions = " "; + $prio_actions.= " "; + + $action = ""; + + if($this->acl_is_removeable()){ + $action.= ""; + } + + $color = ""; + $display = $task['MACADDRESS']; + $display2= $task['HEADERTAG']; + + /* Create each field */ + $field0 = array("string" => "" , + "attach" => "style='width:20px;".$color."'"); + $field1 = array("string" => $display, + "attach" => "style='".$color."'"); + $field1a= array("string" => $display2, + "attach" => "style='".$color.";width:80px;'"); + $field2 = array("string" => date("d.m.Y H:i:s",strtotime($task['TIMESTAMP'])),"attach" => "style='".$color.";width:100px;'"); + $field3 = array("string" => $task['STATUS'],"attach" => "style='".$color.";width:80px;'"); + $field4 = array("string" => $prio_actions.$action,"attach" => "style='".$color.";text-align:right;width:120px;border-right:0px;'"); + $divlist->AddElement(array($field0,$field1,$field1a,$field2,$field3,$field4)); + } + + + $smarty = get_smarty(); + $smarty->assign("start",$this->start); + $smarty->assign("start_real", ($this->start + 1)); + $smarty->assign("ranges", array("10" => "10", + "20" => "20", + "25" => "25", + "50" => "50", + "100"=> "100", + "200"=> "200", + "9999" => "*")); + + $count = $this->o_queue->number_of_queued_entries(); + $smarty->assign("range_selector", range_selector($count, $this->start, $this->range,"range")); + $smarty->assign("range",$this->range); + $smarty->assign("div",$divlist->Draw()); + return($smarty->fetch (get_template_path('gotomasses.tpl', TRUE, dirname(__FILE__)))); + } + + + /*! \brief Force queue job to be done as far as possible. + * @return Boolean TRUE in case of success, else FALSE. + */ + private function start_queue_entries($ids) + { + if(!count($ids)){ + return; + } + + $data = array("timestamp" => date("YmdHis"), + "status" => "-"); + if(!$this->o_queue->update_entries($ids,$data)){ + msg_dialog::display(_("Error"), sprintf(_("Could not update queue entry: %s"),$id) , ERROR_DIALOG); + return(FALSE); + } + return(TRUE); + } + + + /*! \brief Stops the specified queue entry from execution. + * @return Boolean TRUE in case of success, else FALSE. + */ + private function stop_queue_entries($ids) + { + if(!count($ids)){ + return; + } + $data = array("timestamp" => "20490101010101", + "status" => "Stoppped"); + if(!$this->o_queue->update_entries($ids,$data)){ + msg_dialog::display(_("Error"), sprintf(_("Could not update queue entry: %s"),$id) , ERROR_DIALOG); + return(FALSE); + } + return(TRUE); + } + + + /*! \brief Request list of queued jobs. + * @return Returns an array of all queued jobs. + */ + function get_queued_entries() + { + $map = array( + "QueuePosition" => "id", + "Action" => "status", + "TaskID" => "headertag", + "TargetName" => "macaddress", + "Schedule" => "timestamp"); + + if(!isset($map[$this->sort_by])){ + $sort = "id DESC"; + }else{ + $sort = $map[$this->sort_by]; + if($this->sort_dir == "up"){ + $sort.= " ASC"; + }else{ + $sort.= " DESC"; + } + } + + $start = $this->start; + $stop = $this->range; + $entries = $this->o_queue->get_queued_entries($start,$stop,$sort); + if(!is_array($entries) || !isset($entries['XML']) || !is_array($entries['XML'])){ + if ($this->o_queue->get_error()){ + msg_dialog::display(_("Error"), sprintf(_("Cannot load queue entries: %s"), "

".$this->o_queue->get_error()), ERROR_DIALOG); + } + return(array()); + } + + $ret = array(); + foreach($entries['XML'] as $entry){ + $task = $entry['ID']; + $ret[]= $entry; + } + return($ret); + } + + + /*! \brief Handle post jobs, like sorting. + */ + function save_object() + { + $sort_vals = array("Action","QueuePosition","TargetName","Schedule","TaskID"); + if(isset($_GET['sort']) && in_array($_GET['sort'],$sort_vals)){ + $sort = $_GET['sort']; + if($this->sort_by == $sort){ + if($this->sort_dir == "up"){ + $this->sort_dir = "down"; + }else{ + $this->sort_dir = "up"; + } + } + $this->sort_by = $sort; + } + if(isset($_POST['range']) && is_numeric($_POST['range'])){ + $this->range = $_POST['range']; + } + if(isset($_GET['start'])){ + $start = $_GET['start']; + if(is_numeric($start) || $start == 0){ + $this->start = $start; + } + } + + /* Check start stop and reset if necessary */ + $count = $this->o_queue->number_of_queued_entries(); + if($this->start >= $count){ + $this->start = $count -1; + } + if($this->start < 0){ + $this->start = 0; + } + } + + + /* Return list of object groups */ + function get_object_groups() + { + $ret = array(); + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=gosaGroupOfNames)(cn=*))",array("cn")); + while($attrs = $ldap->fetch()){ + $ret[$attrs['cn'][0]] = $attrs['cn'][0]; + } + return($ret); + } + + + function save() + { + // We do not save anything here. + } + + + /*! \brief Return a list of all selected items. + @return Array Returns an array containing all selected item ids. + */ + function list_get_selected_items() + { + $ids = array(); + foreach($_POST as $name => $value){ + if(preg_match("/^item_selected_[0-9]*$/",$name)){ + $id = preg_replace("/^item_selected_/","",$name); + $ids[$id] = $id; + } + } + return($ids); + } + + + function get_actions() + { + /* Prepare list of available actions */ + $actions = array( + "gosa_ping" => _("GOsa ping"), + "ping" => _("Ping"), + "sayHello" => _("Say hello")); + return($actions); + } + + + static function plInfo() + { + return (array( + "plShortName" => _("System mass deployment"), + "plDescription" => _("Provide a mechanism to automatically activate a set of systems"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("addon"), + "plCategory" => array("gotomasses" => array("objectClass" => "none", "description" => _("System mass deployment"))), + "plProvidedAcls" => array("Comment" => _("Description"), + "Action" => _("Action"), + "Day" => _("Day"), + "Minute" => _("Minute"), + "Hour" => _("Hour"), + "Month" => _("Month"), + "Weekday" => _("Week day"), + "Target" => _("Target")) + )); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/goto/addons/gotomasses/class_target_list.inc b/gosa-plugins/goto/addons/gotomasses/class_target_list.inc new file mode 100644 index 000000000..2cf1a24e1 --- /dev/null +++ b/gosa-plugins/goto/addons/gotomasses/class_target_list.inc @@ -0,0 +1,303 @@ +AddCheckBox */ + var $ogroups ; + var $servers ; + var $workstations ; + + + /* Subsearch checkbox */ + var $SubSearch ; + var $IPMatch ; + var $parent ; + var $ui ; + + + function target_list(&$config,$Targets_used) + { + MultiSelectWindow::MultiSelectWindow($config, "Targetselection", array("ogroup","gotomasses")); + + $this->Targets_used = $Targets_used; + + $this->SetInformation( _("Select the target objects for your scheduled action.")); + $this->SetTitle( _("Available targets")); + $this->SetSummary( _("Available targets")); + $this->SetHeadpageMode(FALSE); + + /* set Page header */ + $chk = ""; + $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'")); + + $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'")); + $this->AddHeader(array("string" => _("Object name"), "attach" => "style=''")); + + /* Text ,Value, Name, Is selected */ + $this->AddCheckBox("ogroups", _("Select to see object groups"), _("Show object groups"), true); + $this->AddCheckBox("servers", _("Select to see servers") , _("Show servers"), true); + $this->AddCheckBox("workstations", _("Select to see workstations"),_("Show workstations"), true); + + /* Add SubSearch checkbox */ + $this->AddCheckBox(SEPERATOR); + $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Search in subtrees"), false); + $this->AddCheckBox("IPMatch", _("Select to search for a specific IP range only"), _("Match IP range"), false); + + /* Name,Text,Default , Connect with alphabet */ + $this->AddRegex ("Regex", _("Regular expression for matching group names"), "*" , true); + $this->AddRegex ("IP_start", _("IP range start"), "0.0.0.0" , true); + $this->AddRegex ("IP_end", _("IP range end"), "255.255.255.255" , true); + $this->EnableAplhabet(TRUE); + } + + + function GenHeader() + { + $options= ""; + + /* Get all departments within this subtree */ + $ui= get_userinfo(); + $first = ""; + $found = FALSE; + $base = $this->config->current['BASE']; + + /* Add base */ + $tmp = array(); + $tmp[] = array("dn"=>$this->config->current['BASE']); + $tmp= array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, + array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH)); + + $deps = array(); + foreach($tmp as $tm){ + $deps[$tm['dn']] = $tm['dn']; + } + + /* Load possible departments */ + $ui= get_userinfo(); + $tdeps= $ui->get_module_departments("ogroups"); + $ids = $this->config->idepartments; + $first = ""; + $found = FALSE; + foreach($ids as $dep => $name){ + if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){ + + /* Keep first base dn in mind, we could need this + * info if no valid base was found + */ + if(empty($first)) { + $first = $dep['dn']; + } + + $value = $ids[$dep]; + if ($this->selectedBase == $dep){ + $found = TRUE; + $options.= ""; + } else { + $options.= ""; + } + } + } + + /* The currently used base is not visible with your acl setup. + * Set base to first useable base. + */ + if(!$found){ + $this->selectedBase = $first; + } + + /* Get copy & paste icon */ + $acls = $ui->get_permissions($this->selectedBase,"ogroups/ogroup"); + $acl_all= $ui->has_complete_category_acls($this->selectedBase,"ogroups"); + + /* Add default header */ + $listhead = MultiSelectWindow::get_default_header(); + + /* Add department selector */ + $listhead .= _("Base")." ". + "  "; + $listhead .=""; + + $this->SetListHeader($listhead); + } + + + function execute() + { + $this->ClearElementsList(); + $this->GenHeader(); + $this->reload(); + $this->SetEntries($this->list); + return($this->Draw()); + } + + + function SetEntries($list) + { + /* Add Copy & Paste buttons if copy&paste is enabled + */ + // Defining Links + $linkopen = "%s"; + $editlink = "%s"; + + $ui = get_userinfo(); + + // Assigning ogroups + foreach($list as $key => $val){ + + if(in_array($val['cn'][0],$this->Targets_used) || + isset($val['macAddress'][0]) && in_array($val['macAddress'][0],$this->Targets_used)) continue; + + $title = "title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'"; + if(!isset($val['description'][0])){ + $desc = ""; + }else{ + $desc = " - [ ".$val['description'][0]." ]"; + } + if(!isset($val['ipHostNumber'][0])){ + $desc.= ""; + }else{ + $desc.= " - ".$val['ipHostNumber'][0].""; + } + + + $img ="Hmm"; + if(in_array("goServer",$val['objectClass'])){ + $img = ""._("Server").""; + }elseif(in_array("gotoWorkstation",$val['objectClass'])){ + $img = ""._("Workstation").""; + }elseif(in_array("gosaGroupOfNames",$val['objectClass'])){ + $img = ""._("Object group").""; + } + + /* Create each field */ + $field0 = array("string" => "" , + "attach" => "style='width:20px;'"); + $field1 = array("string" => $img, + "attach" => "style='text- align:center;width: 20px;'"); + $field2 = array("string" => $val['cn'][0].$desc, + "attach" => "style='border-right:0px;' ".$title); + + $this->AddElement(array($field0,$field1,$field2)); + } + } + + + function save() + { + $ret = array(); + $items = $this->list_get_selected_items(); + foreach($items as $item){ + $ret[] = $this->list[$item]; + } + return($ret); + } + + + function save_object() + { + MultiSelectWindow::save_object(); + } + + + function reload() + { + /* Set base for all searches && initialise some vars */ + $this->list= array(); + $base = $this->selectedBase; + $filter = ""; + $Regex = $this->Regex; + $IP_start = $this->IP_start; + $IP_end = $this->IP_end; + + if($this->IPMatch){ + if(!tests::is_ip($IP_start)){ + msg_dialog::display(_("Error"), _("IP range is invalid!"), ERROR_DIALOG); + return; + } + if(!tests::is_ip($IP_end)){ + msg_dialog::display(_("Error"), _("IP range is invalid!"), ERROR_DIALOG); + return; + } + } + + + $chk = array( + "ogroups" => "(&(objectClass=gosaGroupOfNames)(|(gosaGroupObjects=*S*)(gosaGroupObjects=*W*)))" , + "servers" => "(objectClass=goServer)" , + "workstations" => "(objectClass=gotoWorkstation)"); + + /* Create filter */ + foreach($chk as $chkBox => $FilterPart){ + if($this->$chkBox){ + $filter .= $FilterPart; + } + } + $filter= "(&(cn=".$Regex.")(|".$filter."))"; + + if($this->SubSearch){ + $res= get_list($filter, array("ogroups","workstations","servers"), $base, + array("cn","objectClass","gosaGroupObjects","ipHostNumber","description"), GL_SIZELIMIT | GL_SUBSEARCH); + }else{ + $res= get_list($filter, "ogroups", get_groups_ou().$base, + array("cn","objectClass","ipHostNumber","description"), GL_SIZELIMIT ); + $res= array_merge($res,get_list($filter, "workstation", get_ou('workstationou').$base, + array("cn","objectClass","ipHostNumber","description"), GL_SIZELIMIT )); + $res= array_merge($res,get_list($filter, "server", get_ou('serverou').$base, + array("cn","objectClass","ipHostNumber","description"), GL_SIZELIMIT )); + } + + $this->list= $res; + ksort ($this->list); + reset ($this->list); + $tmp=array(); + foreach($this->list as $tkey => $val ){ + + if($this->IPMatch){ + if(isset($val['ipHostNumber'][0])){ + if(tests::is_ip_range($IP_start,$val['ipHostNumber'][0]) && tests::is_ip_range($val['ipHostNumber'][0],$IP_end)){ + $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val; + } + } + }else{ + $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val; + } + } + ksort($tmp); + $this->list=array(); + foreach($tmp as $val){ + $this->list[]=$val; + } + reset ($this->list); + } + + function list_get_selected_items() + { + $ids = array(); + foreach($_POST as $name => $value){ + if(preg_match("/^item_selected_[0-9]*$/",$name)){ + $id = preg_replace("/^item_selected_/","",$name); + $ids[$id] = $id; + } + } + return($ids); + } +} + + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/goto/addons/gotomasses/goto_task.tpl b/gosa-plugins/goto/addons/gotomasses/goto_task.tpl new file mode 100644 index 000000000..61220bd45 --- /dev/null +++ b/gosa-plugins/goto/addons/gotomasses/goto_task.tpl @@ -0,0 +1,99 @@ + + + + + + + + +
+

{t}Job details{/t}

+
+ + + + + + + + + + + + + +
{t}Job ID{/t}{$ID}
+ {t}Header Tag{/t} + + + +
  +
+ {t}Schedule Execution{/t} + + + + + + + + + + + + + + + + + + +
{t}Jahr{/t}{t}Monat{/t}{t}Tag{/t}{t}Stunde{/t}{t}Minute{/t}{t}Sekunde{/t}
+   + +   + +   + +   + +   + + +
+
+
+ +{if $HEADERTAG == "ping"} + + +{elseif $HEADERTAG == "sayHello"} + + +{else} + +{/if} +
{t}Status{/t}
{t}Mac{/t}
{t}Status{/t}
{t}Mac{/t}
{t}Job type not implented{/t}
+
+ +

 

+ +

+ + +

diff --git a/gosa-plugins/goto/addons/gotomasses/gotomasses.tpl b/gosa-plugins/goto/addons/gotomasses/gotomasses.tpl new file mode 100644 index 000000000..844cdebf6 --- /dev/null +++ b/gosa-plugins/goto/addons/gotomasses/gotomasses.tpl @@ -0,0 +1,4 @@ +{$div} +
+{$range_selector} +
diff --git a/gosa-plugins/goto/addons/gotomasses/main.inc b/gosa-plugins/goto/addons/gotomasses/main.inc new file mode 100644 index 000000000..7a517fecd --- /dev/null +++ b/gosa-plugins/goto/addons/gotomasses/main.inc @@ -0,0 +1,54 @@ +set_acl_category("gotomasses"); + + /* Check root dn and user dn for acl informations */ + $gotomasses->set_acl_base($config->current['BASE']); + if($gotomasses->getacl("") == ""){ + $gotomasses->set_acl_base($ui->dn); + } + + /* Check if we have acl on our own base */ + if($gotomasses->getacl("") == ""){ + $gotomasses->set_acl_base(dn2base($ui->dn)); + } + session::set("gotomasses",$gotomasses); + } + $gotomasses = session::get('gotomasses'); + + /* Execute formular */ + $display= $gotomasses->save_object(); + if(isset($_POST['save_gotomass_changes'])){ + $gotomasses->save(); + } + $display= $gotomasses->execute (); + + /* Page header*/ + $display= print_header(get_template_path('images/system.png'), _("System deployment")).$display; + + /* Store changes in session */ + session::set('gotomasses',$gotomasses); +} diff --git a/gosa-plugins/goto/addons/gotomasses/remove.tpl b/gosa-plugins/goto/addons/gotomasses/remove.tpl new file mode 100644 index 000000000..023142f97 --- /dev/null +++ b/gosa-plugins/goto/addons/gotomasses/remove.tpl @@ -0,0 +1,21 @@ +
+  {t}Warning{/t} +
+

+ {$info} + {t}This includes all account data, system access rules, imap settings, etc. for this user. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t} +

+ +

+ {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t} +

+ +

+{if $multiple} + +{else} + +{/if} + +

+