From b5291aacd3983c6fb611064c7a1c6082d6ae4bfb Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 21 Jan 2008 11:16:00 +0000 Subject: [PATCH] Updated gotomasses. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8518 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_gosaSupportDaemon.inc | 68 +++-- .../addons/gotomasses/class_divListMasses.inc | 8 +- .../addons/gotomasses/class_gotomasses.inc | 234 +++++++++--------- 3 files changed, 173 insertions(+), 137 deletions(-) diff --git a/gosa-core/include/class_gosaSupportDaemon.inc b/gosa-core/include/class_gosaSupportDaemon.inc index 6cf229188..0b2e3e83f 100644 --- a/gosa-core/include/class_gosaSupportDaemon.inc +++ b/gosa-core/include/class_gosaSupportDaemon.inc @@ -22,6 +22,9 @@ class gosaSupportDaemon $this->i_port = $port; $this->f_timeout = $timeout; $this->s_encryption_key = $key; + if($connect){ + $this->connect(); + } } public function connect() @@ -44,9 +47,11 @@ class gosaSupportDaemon public function __reload() { - echo "Reload"; $this->entries = array(); $this->pointer = 0; + $this->b_error = FALSE; + $this->s_error = ""; + $xml_msg = "
gosa_query_jobdb
*
"; $this->connect(); if($this->is_connected){ @@ -54,8 +59,6 @@ class gosaSupportDaemon $str = trim($this->o_sock->read()); $entries = $this->xml_to_array($str); if(!isset($entries['XML'])){ - print_a($entries); - echo htmlentities($str); $this->set_error("Couldn't parse xml."); $this->disconnect(); return(FALSE); @@ -63,7 +66,6 @@ class gosaSupportDaemon $ret = array_values($entries['XML']); } $this->entries = $ret; - $this->disconnect(); return(TRUE); } $this->set_error("Could not establish socket connection."); @@ -140,22 +142,18 @@ class gosaSupportDaemon public function decrease_entry_priority($id) { - echo $id; } public function increase_entry_priority($id) { - echo $id; } public function max_entry_priority($id) { - echo $id; } public function min_entry_priority($id) { - echo $id; } public function id_exists($id) @@ -165,11 +163,36 @@ class gosaSupportDaemon public function get_entry($id) { - foreach($this->entries as $entry){ - if($entry['ID'] == $id){ - return($entry); + if(!is_numeric($id)){ + trigger_error("gosaSupportDaemon::get_entry() requires an integer value as ID parameter."); + return; + } + + $this->b_error = FALSE; + $this->s_error = ""; + + $xml_msg = " +
gosa_query_jobdb
+ id + ".$id." +
"; + + $this->connect(); + if($this->is_connected){ + $this->o_sock->write($xml_msg); + $str = trim($this->o_sock->read()); + $entries = $this->xml_to_array($str); + if(!isset($entries['XML']['ANSWER1'])){ + $this->set_error("Entry with id (".$id.") not found."); + $this->disconnect(); + return(FALSE); + }else{ + $ret = array_values($entries['XML']['ANSWER1']); + return($ret); } } + $this->set_error("Could not establish socket connection."); + return(FALSE); } public function update_entry($id,$entry) @@ -177,10 +200,10 @@ class gosaSupportDaemon $xml_msg = ""; if($this->is_connected){ - $this->o_sock->write($xml_msg); - $str = trim($this->o_sock->read()); - $entries = $this->xml_to_array($str); - $this->disconnect(); + #$this->o_sock->write($xml_msg); + #$str = trim($this->o_sock->read()); + #$entries = $this->xml_to_array($str); + #$this->disconnect(); return(TRUE); } $this->set_error("Could not establish socket connection."); @@ -193,6 +216,21 @@ class gosaSupportDaemon public function remove_entry($id) { + $this->b_error = FALSE; + $this->s_error = ""; + + $xml_msg = " +
gosa_delete_jobdb_entry
+ id + ".$id." +
"; + $this->connect(); + if($this->is_connected){ + $this->o_sock->write($xml_msg); + return(TRUE); + } + $this->set_error("Could not establish socket connection."); + return(FALSE); } } diff --git a/gosa-core/plugins/addons/gotomasses/class_divListMasses.inc b/gosa-core/plugins/addons/gotomasses/class_divListMasses.inc index c02d3c012..cc1dc8865 100644 --- a/gosa-core/plugins/addons/gotomasses/class_divListMasses.inc +++ b/gosa-core/plugins/addons/gotomasses/class_divListMasses.inc @@ -58,10 +58,10 @@ class divListMasses extends MultiSelectWindow # $header .= " "; # } -# /* Display remove button if allowed */ -# if($this->parent->acl_is_removeable()){ -# $header .= " "; -# } + /* Display remove button if allowed */ + if($this->parent->acl_is_removeable()){ + $header .= " "; + } /* Add priority options */ if(preg_match("/w/",$this->parent->getacl(""))){ diff --git a/gosa-core/plugins/addons/gotomasses/class_gotomasses.inc b/gosa-core/plugins/addons/gotomasses/class_gotomasses.inc index b40fdc1b8..e727422aa 100644 --- a/gosa-core/plugins/addons/gotomasses/class_gotomasses.inc +++ b/gosa-core/plugins/addons/gotomasses/class_gotomasses.inc @@ -24,7 +24,7 @@ class gotomasses extends plugin /* Include config object */ $this->config= &$config; $this->divlist = new divListMasses($this->config,$this); - $this->o_queue = new gosaSupportDaemon("10.3.67.111","20082","secret-gosa-password",FALSE,0.2); + $this->o_queue = new gosaSupportDaemon("10.3.67.111","20081","secret-gosa-password",TRUE,0.2); } @@ -38,20 +38,20 @@ class gotomasses extends plugin $s_entry = $s_action = ""; $arr = array( - "/^prio_top_/" => "prio_top", - "/^prio_increase_/" => "prio_increase", - "/^prio_decrease_/" => "prio_decrease", - "/^prio_bottom_/" => "prio_bottom", + "/^prio_top_/" => "prio_top", + "/^prio_increase_/" => "prio_increase", + "/^prio_decrease_/" => "prio_decrease", + "/^prio_bottom_/" => "prio_bottom", - "/^multiple_prio_top_/" => "mprio_top", - "/^multiple_prio_increase_/" => "mprio_increase", - "/^multiple_prio_decrease_/" => "mprio_decrease", - "/^multiple_prio_bottom_/" => "mprio_bottom", + "/^multiple_prio_top_/" => "mprio_top", + "/^multiple_prio_increase_/" => "mprio_increase", + "/^multiple_prio_decrease_/" => "mprio_decrease", + "/^multiple_prio_bottom_/" => "mprio_bottom", - "/^edit_task_/" => "edit", - "/^remove_task_/" => "remove", - "/^new_task_/" => "new_task", - "/^remove_multiple_task_/" => "remove_multiple"); + "/^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){ @@ -69,10 +69,11 @@ class gotomasses extends plugin $s_entry = $_GET['id']; } + /************ - * REMOVE + * Handle Priority modifications ************/ - + if(preg_match("/^mprio_/",$s_action) || preg_match("/^prio_/",$s_action)){ switch($s_action){ @@ -99,7 +100,7 @@ class gotomasses extends plugin default : trigger_error("Undefined priority setting used."); } if($this->o_queue->is_error()){ - msg_dialog::display(_("Error"), $this->o_queue->get_error(), ERROR_DIALOG); + msg_dialog::display(_("Error"), $this->o_queue->get_error(), ERROR_DIALOG); } } @@ -111,7 +112,7 @@ class gotomasses extends plugin 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); + msg_dialog::display(_("Permission error"), _("You have no permission to delete this entry!"), ERROR_DIALOG); }else{ if($s_action == "remove"){ @@ -119,14 +120,13 @@ class gotomasses extends plugin }else{ $ids = $this->list_get_selected_items(); } - $this->ids_to_remove = $ids; $tmp = ""; foreach($this->ids_to_remove as $key => $id){ if($this->o_queue->id_exists($id)){ $task = $this->o_queue->get_entry($id); - $tmp.= "\n".$task['ID']; + $tmp.= "\n".$task['5']." ".$task['3']; }else{ unset($this->ids_to_remove[$key]); } @@ -141,9 +141,7 @@ class gotomasses extends plugin /* Remove specified tasks */ if(count($this->ids_to_remove) && isset($_POST['delete_multiple_confirm'])){ foreach($this->ids_to_remove as $id){ - if($this->o_queue->id_exists($id)){ - $this->o_queue->remove_entry($id); - } + $this->o_queue->remove_entry($id); } $this->save(); } @@ -154,68 +152,68 @@ class gotomasses extends plugin } - /************ - * EDIT - ************/ - - /* Edit selected entry */ - if($s_action == "edit"){ - $entry = $this->o_queue->get_entry($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_entry($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()); - } + /************ + * EDIT + ************/ + + /* Edit selected entry */ + if($s_action == "edit"){ + $entry = $this->o_queue->get_entry($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_entry($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 @@ -227,7 +225,7 @@ class gotomasses extends plugin return($this->divlist->Draw()); } - + /*! \brief Request list of queued jobs. * @return Returns an array of all queued jobs. */ @@ -244,10 +242,10 @@ class gotomasses extends plugin $ret[]= $entry; } $map = array("QueuePosition" => "ID", - "Action" => "STATUS", - "TaskID" => "HEADERTAG", - "TargetName" => "MACADDRESS", - "Schedule" => "TIMESTAMP"); + "Action" => "STATUS", + "TaskID" => "HEADERTAG", + "TargetName" => "MACADDRESS", + "Schedule" => "TIMESTAMP"); $sort_tmp = array(); foreach($ret as $entry_id => $entry){ $sort_tmp[$entry_id] = $entry[$map[$this->sort_by]]; @@ -274,9 +272,9 @@ class gotomasses extends plugin $sort = $_GET['sort']; if($this->sort_by == $sort){ if($this->sort_dir == "up"){ - $this->sort_dir = "down"; + $this->sort_dir = "down"; }else{ - $this->sort_dir = "up"; + $this->sort_dir = "up"; } } $this->sort_by = $sort; @@ -297,7 +295,7 @@ class gotomasses extends plugin return($ret); } - + function save() { // We do not save anything here. @@ -305,7 +303,7 @@ class gotomasses extends plugin /*! \brief Return a list of all selected items. - @return Array Returns an array containing all selected item ids. + @return Array Returns an array containing all selected item ids. */ function list_get_selected_items() { @@ -320,36 +318,36 @@ class gotomasses extends plugin } - function get_actions() - { - /* Prepare list of available actions */ - $actions = array( - "gosa_ping" => _("GOsa ping"), - "ping" => _("Ping"), - "sayHello" => _("Say hello")); - return($actions); - } + 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")) - )); + "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: -- 2.30.2