summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dc28141)
raw | patch | inline | side by side (parent: dc28141)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 23 Jul 2010 14:02:41 +0000 (14:02 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 23 Jul 2010 14:02:41 +0000 (14:02 +0000) |
-Fixed code indentation
-Updated post handling
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19089 594d385d-05f5-0310-b6e9-bd551577e9d8
-Updated post handling
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19089 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-plugins/opsi/admin/opsi/class_opsi.inc b/gosa-plugins/opsi/admin/opsi/class_opsi.inc
index 0dd5b04baad50b0e63d03de8fce793bcaf18b8cd..4f592740e14bf6f1de23fd91e1dc5a66ec9c160a 100644 (file)
*/
class opsi extends gosaSupportDaemon
{
- private $config = NULL;
- protected $use_alternative_xml_parse_method = TRUE;
- protected $target = "";
-
- /*! \brief Create opsi object.
- @param
- @return
- */
- public function __construct($config)
- {
- $this->config = $config;
- gosaSupportDaemon::__construct($config);
+ private $config = NULL;
+ protected $use_alternative_xml_parse_method = TRUE;
+ protected $target = "";
- /* Detect the target opsi host
+ /*! \brief Create opsi object.
+ @param
+ @return
*/
- if($this->config->pluginEnabled("faiManagement")){
- $opsi_hosts = $this->get_hosts_with_module("opsi_com");
-
- /* Just use the first result of the opsi hosts
- */
- if(count($opsi_hosts) == 1 && isset($opsi_hosts[0])){
- $this->target = $opsi_hosts[0];
- }elseif(count($opsi_hosts) > 1){
- $this->target = $opsi_hosts[0];
- msg_dialog::display(_("Opsi"),sprintf(_("More than one Opsi server were found, using the first result '%s'."),$this->target));
- }
+ public function __construct($config)
+ {
+ $this->config = $config;
+ gosaSupportDaemon::__construct($config);
+
+ /* Detect the target opsi host
+ */
+ if($this->config->pluginEnabled("faiManagement")){
+ $opsi_hosts = $this->get_hosts_with_module("opsi_com");
+
+ /* Just use the first result of the opsi hosts
+ */
+ if(count($opsi_hosts) == 1 && isset($opsi_hosts[0])){
+ $this->target = $opsi_hosts[0];
+ }elseif(count($opsi_hosts) > 1){
+ $this->target = $opsi_hosts[0];
+ msg_dialog::display(_("Opsi"),sprintf(_("More than one Opsi server were found, using the first result '%s'."),$this->target));
+ }
+ }
}
- }
-
- public function enabled()
- {
- return($this->config->pluginEnabled('faiManagement') && !empty($this->target));
- }
+ public function enabled()
+ {
+ return($this->config->pluginEnabled('faiManagement') && !empty($this->target));
+ }
- /******************
- Opsi handling
- ******************/
- function get_hosts_for_system_management()
- {
- $res = $this->list_clients();
- $data = array();
- $ui = get_userinfo();
- foreach($res as $entry){
- if(!isset($entry['MAC'][0]['VALUE'])) $entry['MAC'][0]['VALUE'] = "";
- $obj = array(
- "dn" => "opsi:=".$entry['NAME'][0]['VALUE'].",".get_ou("wingeneric", "sambaMachineAccountRDN").$this->config->current['BASE'],
- "objectClass" => array("gosa_opsi_client"),
- "cn" => array(0 => $entry['NAME'][0]['VALUE']),
- "macAddress" => array(0 => $entry['MAC'][0]['VALUE']),
- "opsi_notes" => array(0 => $entry['NOTES'][0]['VALUE']));
-
- /* Check permissions */
- $opsi_acl = $ui->get_permissions($obj['dn'],"opsi/opsiGeneric");
- if(preg_match("/r/",$opsi_acl)){
- if(!empty($entry['DESCRIPTION'][0]['VALUE'])){
- $obj["description"]= array();
- $obj["description"][0]= $entry['DESCRIPTION'][0]['VALUE'];
+ /******************
+ Opsi handling
+ ******************/
+
+ function get_hosts_for_system_management()
+ {
+ $res = $this->list_clients();
+ $data = array();
+ $ui = get_userinfo();
+ foreach($res as $entry){
+ if(!isset($entry['MAC'][0]['VALUE'])) $entry['MAC'][0]['VALUE'] = "";
+ $obj = array(
+ "dn" => "opsi:=".$entry['NAME'][0]['VALUE'].",".get_ou("wingeneric", "sambaMachineAccountRDN").$this->config->current['BASE'],
+ "objectClass" => array("gosa_opsi_client"),
+ "cn" => array(0 => $entry['NAME'][0]['VALUE']),
+ "macAddress" => array(0 => $entry['MAC'][0]['VALUE']),
+ "opsi_notes" => array(0 => $entry['NOTES'][0]['VALUE']));
+
+ /* Check permissions */
+ $opsi_acl = $ui->get_permissions($obj['dn'],"opsi/opsiGeneric");
+ if(preg_match("/r/",$opsi_acl)){
+ if(!empty($entry['DESCRIPTION'][0]['VALUE'])){
+ $obj["description"]= array();
+ $obj["description"][0]= $entry['DESCRIPTION'][0]['VALUE'];
+ }
+ $data[] = $obj;
+ }
}
- $data[] = $obj;
- }
- }
- return($data);
- }
+ return($data);
+ }
- /*! \brief Maps all xml to array conversion to an alternative method
- then used in the parent class 'gosaSupportDaemon'.
- The alternative method is able to handle more complex data.
- */
- private function xml_to_array($xml,$alternative_method = FALSE)
- {
- return(gosaSupportDaemon::xml_to_array($xml,TRUE));
- }
+ /*! \brief Maps all xml to array conversion to an alternative method
+ then used in the parent class 'gosaSupportDaemon'.
+ The alternative method is able to handle more complex data.
+ */
+ private function xml_to_array($xml,$alternative_method = FALSE)
+ {
+ return(gosaSupportDaemon::xml_to_array($xml,TRUE));
+ }
- /*! \brief Trigger an event like wake or install for a specific hostId.
- */
- public function send_action($type,$hostId,$mac)
- {
- switch($type){
- case 'install' : $this->job_opsi_install_client($hostId,$mac); break;
- default : trigger_error('Unknown type '.$type.'.');
+ /*! \brief Trigger an event like wake or install for a specific hostId.
+ */
+ public function send_action($type,$hostId,$mac)
+ {
+ switch($type){
+ case 'install' : $this->job_opsi_install_client($hostId,$mac); break;
+ default : trigger_error('Unknown type '.$type.'.');
+ }
}
- }
-
-
- public function job_opsi_activate_client($id,$mac)
- {
- $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
- $o_queue = new gosaSupportDaemon();
- if(isset($events['TRIGGERED']['DaemonEvent_activate'])){
- $evt = $events['TRIGGERED']['DaemonEvent_activate'];
- $tmp = new $evt['CLASS_NAME']($this->config);
- $tmp->set_type(TRIGGERED_EVENT);
- $tmp->add_targets(array($mac));
- if(!$o_queue->append($tmp)){
- msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
- }
+
+
+ public function job_opsi_activate_client($id,$mac)
+ {
+ $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
+ $o_queue = new gosaSupportDaemon();
+ if(isset($events['TRIGGERED']['DaemonEvent_activate'])){
+ $evt = $events['TRIGGERED']['DaemonEvent_activate'];
+ $tmp = new $evt['CLASS_NAME']($this->config);
+ $tmp->set_type(TRIGGERED_EVENT);
+ $tmp->add_targets(array($mac));
+ if(!$o_queue->append($tmp)){
+ msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
+ }
+ }
}
- }
- /******************
- SI Communication functions
- ******************/
+ /******************
+ SI Communication functions
+ ******************/
- /*! \brief Returns a list of all opsi clients.
- @param
- @return
- */
- public function list_clients( $hostId = "")
- {
- $data = array();
- $res = $this->send_data("gosa_opsi_list_clients",$this->target,$data,TRUE);
- $items = array();
- if(isset($res['XML'][0]['ITEM'])){
- $items = $res['XML'][0]['ITEM'];
+ /*! \brief Returns a list of all opsi clients.
+ @param
+ @return
+ */
+ public function list_clients( $hostId = "")
+ {
+ $data = array();
+ $res = $this->send_data("gosa_opsi_list_clients",$this->target,$data,TRUE);
+ $items = array();
+ if(isset($res['XML'][0]['ITEM'])){
+ $items = $res['XML'][0]['ITEM'];
+ }
+ return($items);
}
- return($items);
- }
- /*! \brief Adds a new opsi client.
- @param
- @return
- */
- public function add_client($hostId,$macaddress,$notes,$description)
- {
- $data = array("hostId" => $hostId,"macaddress" => $macaddress);
+ /*! \brief Adds a new opsi client.
+ @param
+ @return
+ */
+ public function add_client($hostId,$macaddress,$notes,$description)
+ {
+ $data = array("hostId" => $hostId,"macaddress" => $macaddress);
- if(empty($hostId)){
- trigger_error("No valid host id given, check parameter 1.");
- return;
- }
-
- /* Add optional attributes */
- foreach(array("notes","description") as $attr) {
- if(!empty($$attr)){
- $data[$attr] = $$attr;
- }
+ if(empty($hostId)){
+ trigger_error("No valid host id given, check parameter 1.");
+ return;
+ }
+
+ /* Add optional attributes */
+ foreach(array("notes","description") as $attr) {
+ if(!empty($$attr)){
+ $data[$attr] = $$attr;
+ }
+ }
+
+ /* Query SI server */
+ $res = $this->send_data("gosa_opsi_add_client",$this->target,$data,TRUE);
}
- /* Query SI server */
- $res = $this->send_data("gosa_opsi_add_client",$this->target,$data,TRUE);
- }
+ /*! \brief Modify an opsi client.
+ @param
+ @return
+ */
+ public function modify_client($hostId,$mac,$notes,$description)
+ {
+ $data = array("hostId" => $hostId,"mac" => $mac);
- /*! \brief Modify an opsi client.
- @param
- @return
- */
- public function modify_client($hostId,$mac,$notes,$description)
- {
- $data = array("hostId" => $hostId,"mac" => $mac);
+ if(empty($hostId)){
+ trigger_error("No valid host id given, check parameter 1.");
+ return;
+ }
- if(empty($hostId)){
- trigger_error("No valid host id given, check parameter 1.");
- return;
- }
-
- /* Add optional attributes */
- foreach(array("notes","description") as $attr) {
- $data[$attr] = $$attr;
- }
+ /* Add optional attributes */
+ foreach(array("notes","description") as $attr) {
+ $data[$attr] = $$attr;
+ }
- /* Query SI server */
- $res = $this->send_data("gosa_opsi_modify_client",$this->target,$data,TRUE);
- }
+ /* Query SI server */
+ $res = $this->send_data("gosa_opsi_modify_client",$this->target,$data,TRUE);
+ }
- /*! \brief Returns a list of netboot products.
- @param
- @return
- */
- public function get_netboot_products($host = "")
- {
- /* Append host attribute to query data
+ /*! \brief Returns a list of netboot products.
+ @param
+ @return
*/
- $data = array();
- if(!empty($host)){
- $data['hostId'] = trim($host);
- }
+ public function get_netboot_products($host = "")
+ {
+ /* Append host attribute to query data
+ */
+ $data = array();
+ if(!empty($host)){
+ $data['hostId'] = trim($host);
+ }
- $res = $this->send_data("gosa_opsi_get_netboot_products",$this->target,$data,TRUE);
- $items = array();
- if(isset($res['XML'][0]['ITEM'])){
- foreach($res['XML'][0]['ITEM'] as $entry){
- $e = array("DESC" => $entry['DESCRIPTION'][0]['VALUE'],
- "NAME" => $entry['PRODUCTID'][0]['VALUE']);
- $items[$entry['PRODUCTID'][0]['VALUE']] = $e;
- }
+ $res = $this->send_data("gosa_opsi_get_netboot_products",$this->target,$data,TRUE);
+ $items = array();
+ if(isset($res['XML'][0]['ITEM'])){
+ foreach($res['XML'][0]['ITEM'] as $entry){
+ $e = array("DESC" => $entry['DESCRIPTION'][0]['VALUE'],
+ "NAME" => $entry['PRODUCTID'][0]['VALUE']);
+ $items[$entry['PRODUCTID'][0]['VALUE']] = $e;
+ }
+ }
+ return($items);
}
- return($items);
- }
- /*! \brief Returns a list of all local products.
- @param
- @return
- */
- public function get_local_products($host = "")
- {
- /* Append host attribute to query data
+ /*! \brief Returns a list of all local products.
+ @param
+ @return
*/
- $data = array();
- if(!empty($host)){
- $data['hostId'] = trim($host);
- }
+ public function get_local_products($host = "")
+ {
+ /* Append host attribute to query data
+ */
+ $data = array();
+ if(!empty($host)){
+ $data['hostId'] = trim($host);
+ }
- $res = $this->send_data("gosa_opsi_get_local_products",$this->target,$data,TRUE);
- $items = array();
- if(isset($res['XML'][0]['ITEM'])){
- foreach($res['XML'][0]['ITEM'] as $entry){
- $e = array("DESC" => $entry['DESCRIPTION'][0]['VALUE'],
- "NAME" => $entry['PRODUCTID'][0]['VALUE']);
- $items[$entry['PRODUCTID'][0]['VALUE']] = $e;
- }
+ $res = $this->send_data("gosa_opsi_get_local_products",$this->target,$data,TRUE);
+ $items = array();
+ if(isset($res['XML'][0]['ITEM'])){
+ foreach($res['XML'][0]['ITEM'] as $entry){
+ $e = array("DESC" => $entry['DESCRIPTION'][0]['VALUE'],
+ "NAME" => $entry['PRODUCTID'][0]['VALUE']);
+ $items[$entry['PRODUCTID'][0]['VALUE']] = $e;
+ }
+ }
+ return($items);
}
- return($items);
- }
- /*! \brief Returns a list of netboot products.
- @param
- @return
- */
- public function get_full_product_host_information($host = "")
- {
- /* Append host attribute to query data
+ /*! \brief Returns a list of netboot products.
+ @param
+ @return
*/
- $data = array();
- if(!empty($host)){
- $data['hostId'] = trim($host);
- }
-
- $res = $this->send_data("gosa_opsi_get_full_product_host_information",$this->target,$data,TRUE);
- $items = array();
- $attrs = array("TYPE","PRIORITY","ONCESCRIPT","LICENSEREQUIRED","PACKAGEVERSION","PRODUCTVERSION",
- "ADVICE","SETUPSCRIPT","WINDOWSSOFTWAREIDS","PXECONFIGTEMPLATE","NAME","CREATIONTIMESTAMP", "TYPE",
- "ALWAYSSCRIPT","PRODUCTID","DESCRIPTION","UNINSTALLSCRIPT","UPDATESCRIPT","PRODUCTCLASSNAMES");
-
- if(isset($res['XML'][0]['ITEM'])){
- foreach($res['XML'][0]['ITEM'] as $entry){
- $e = array();
- foreach($attrs as $attr){
- if(isset($entry[$attr])){
- foreach($entry[$attr] as $key => $value){
- if(isset($value['VALUE'])){
- $e['data'][$attr] = $value['VALUE'];
- }elseif($value['ELEMENT']){
- foreach($value['ELEMENT'] as $element){
- $e['data'][$attr][] = $element['VALUE'];
- }
- }
- }
- }
+ public function get_full_product_host_information($host = "")
+ {
+ /* Append host attribute to query data
+ */
+ $data = array();
+ if(!empty($host)){
+ $data['hostId'] = trim($host);
}
- $e["configurable"] = FALSE;
- if(isset($entry['PROPERTIES']) && count($entry['PROPERTIES'])){
- $e["configurable"] = TRUE;
- $p_data = array();
-
- foreach($entry['PROPERTIES'][0] as $p_name => $p_values){
- if(empty($p_values)) continue;
- $p_data[$p_name]= array();
- foreach(array('CURRENT','DEFAULT','DESCRIPTION') as $p_tmp){
- if(isset($p_values[0][$p_tmp])){
- if(isset($p_values[0][$p_tmp][0]['VALUE'])){
- $p_data[$p_name][$p_tmp] = $p_values[0][$p_tmp][0]['VALUE'];
+ $res = $this->send_data("gosa_opsi_get_full_product_host_information",$this->target,$data,TRUE);
+ $items = array();
+ $attrs = array("TYPE","PRIORITY","ONCESCRIPT","LICENSEREQUIRED","PACKAGEVERSION","PRODUCTVERSION",
+ "ADVICE","SETUPSCRIPT","WINDOWSSOFTWAREIDS","PXECONFIGTEMPLATE","NAME","CREATIONTIMESTAMP", "TYPE",
+ "ALWAYSSCRIPT","PRODUCTID","DESCRIPTION","UNINSTALLSCRIPT","UPDATESCRIPT","PRODUCTCLASSNAMES");
+
+ if(isset($res['XML'][0]['ITEM'])){
+ foreach($res['XML'][0]['ITEM'] as $entry){
+ $e = array();
+ foreach($attrs as $attr){
+ if(isset($entry[$attr])){
+ foreach($entry[$attr] as $key => $value){
+ if(isset($value['VALUE'])){
+ $e['data'][$attr] = $value['VALUE'];
+ }elseif($value['ELEMENT']){
+ foreach($value['ELEMENT'] as $element){
+ $e['data'][$attr][] = $element['VALUE'];
+ }
+ }
+ }
+ }
}
- }
- }
-
- if(isset($p_values[0]['VALUES'][0]['ELEMENT'])){
- foreach($p_values[0]['VALUES'][0]['ELEMENT'] as $val){
- $p_data[$p_name]['VALUE'][] = $val['VALUE'];
- }
- $p_data[$p_name]['VALUE_CNT'] = count($p_data[$p_name]['VALUE']);
- }
- }
- $e["data"]['PROPERTIES'] = $p_data;
- }
+ $e["configurable"] = FALSE;
+ if(isset($entry['PROPERTIES']) && count($entry['PROPERTIES'])){
+ $e["configurable"] = TRUE;
+ $p_data = array();
+
+ foreach($entry['PROPERTIES'][0] as $p_name => $p_values){
+ if(empty($p_values)) continue;
+ $p_data[$p_name]= array();
+ foreach(array('CURRENT','DEFAULT','DESCRIPTION') as $p_tmp){
+ if(isset($p_values[0][$p_tmp])){
+ if(isset($p_values[0][$p_tmp][0]['VALUE'])){
+ $p_data[$p_name][$p_tmp] = $p_values[0][$p_tmp][0]['VALUE'];
+ }
+ }
+ }
+
+ if(isset($p_values[0]['VALUES'][0]['ELEMENT'])){
+ foreach($p_values[0]['VALUES'][0]['ELEMENT'] as $val){
+ $p_data[$p_name]['VALUE'][] = $val['VALUE'];
+ }
+ $p_data[$p_name]['VALUE_CNT'] = count($p_data[$p_name]['VALUE']);
+ }
+ }
+
+ $e["data"]['PROPERTIES'] = $p_data;
+ }
- $e["installed"] = FALSE;
- if(isset($entry['ACTIONREQUEST'])){
- $e["installed"] = TRUE;
- }
+ $e["installed"] = FALSE;
+ if(isset($entry['ACTIONREQUEST'])){
+ $e["installed"] = TRUE;
+ }
- $e["requires_licence"] = FALSE;
- if(isset($e['data']['LICENSEREQUIRED']) && preg_match("/true/i",$e['data']['LICENSEREQUIRED'])){
- $e["requires_licence"] = TRUE;
+ $e["requires_licence"] = FALSE;
+ if(isset($e['data']['LICENSEREQUIRED']) && preg_match("/true/i",$e['data']['LICENSEREQUIRED'])){
+ $e["requires_licence"] = TRUE;
+ }
+ $items[$entry['PRODUCTID'][0]['VALUE']] = $e;
+ }
}
- $items[$entry['PRODUCTID'][0]['VALUE']] = $e;
- }
+ return($items);
}
- return($items);
- }
-
- /*! \brief Returns a list of all product properties. \
- . Additionally you can specify the host parameter to \
- . get host specific product properties
- @param
- @return
- */
- public function get_product_properties($productId,$hostId = "")
- {
- $data = array("productId" => $productId);
- /* Append host attribute to query data
+ /*! \brief Returns a list of all product properties. \
+ . Additionally you can specify the host parameter to \
+ . get host specific product properties
+ @param
+ @return
*/
- if(!empty($hostId)){
- $data['hostId'] = trim($hostId);
- }
-
- /* Check parameter */
- if(empty($productId)){
- trigger_error("No valid product id given, check parameter 1.");
- return(array());
- }
+ public function get_product_properties($productId,$hostId = "")
+ {
+ $data = array("productId" => $productId);
+
+ /* Append host attribute to query data
+ */
+ if(!empty($hostId)){
+ $data['hostId'] = trim($hostId);
+ }
- /* Query SI server */
- $res = $this->send_data("gosa_opsi_get_product_properties",$this->target,$data,TRUE);
- $items = array();
- if(isset($res['XML'][0]['ITEM'])){
- foreach($res['XML'][0]['ITEM'] as $entry){
- foreach($entry as $name => $val){
-
- foreach(array("DESCRIPTION","CURRENT") as $attr){
- $items[$name][$attr] = "";
- if(isset($val[0][$attr])){
- $items[$name][$attr] = $val[0][$attr][0]['VALUE'];
- }
- }
- $items[$name]['VALUE'] = array();
- if(isset($val['0']['VALUE'])){
- foreach($val['0']['VALUE'] as $value){
- $items[$name]['VALUE'][] = $value['VALUE'];
+ /* Check parameter */
+ if(empty($productId)){
+ trigger_error("No valid product id given, check parameter 1.");
+ return(array());
+ }
+
+ /* Query SI server */
+ $res = $this->send_data("gosa_opsi_get_product_properties",$this->target,$data,TRUE);
+ $items = array();
+ if(isset($res['XML'][0]['ITEM'])){
+ foreach($res['XML'][0]['ITEM'] as $entry){
+ foreach($entry as $name => $val){
+
+ foreach(array("DESCRIPTION","CURRENT") as $attr){
+ $items[$name][$attr] = "";
+ if(isset($val[0][$attr])){
+ $items[$name][$attr] = $val[0][$attr][0]['VALUE'];
+ }
+ }
+ $items[$name]['VALUE'] = array();
+ if(isset($val['0']['VALUE'])){
+ foreach($val['0']['VALUE'] as $value){
+ $items[$name]['VALUE'][] = $value['VALUE'];
+ }
+ }
+ $items[$name]['VALUE_CNT'] = count($items[$name]['VALUE']);
+ }
}
- }
- $items[$name]['VALUE_CNT'] = count($items[$name]['VALUE']);
}
- }
+ return($items);
}
- return($items);
- }
- /*! \brief Set product properties, globally or per host.
- @param
- @return
- */
- public function set_product_properties($productId,$cfg,$hostId = "")
- {
- $data = array("productId" => $productId);
-
- /* Append host attribute to query data
+ /*! \brief Set product properties, globally or per host.
+ @param
+ @return
*/
- if(!empty($hostId)){
- $data['hostId'] = trim($hostId);
- }
-
- /* Check parameter */
- if(empty($productId)){
- trigger_error("No valid product id given, check parameter 1.");
- return(array());
- }
-
- if(!count($cfg)) return;
-
- /* Add properties */
- $data['item'] = array();
- foreach($cfg as $name => $value){
- $data['item'][] = "<name>".$name."</name><value>".$value['CURRENT']."</value>";
- }
+ public function set_product_properties($productId,$cfg,$hostId = "")
+ {
+ $data = array("productId" => $productId);
+
+ /* Append host attribute to query data
+ */
+ if(!empty($hostId)){
+ $data['hostId'] = trim($hostId);
+ }
- /* Query SI server */
- $res = $this->send_data("gosa_opsi_set_product_properties",$this->target,$data,TRUE);
- }
+ /* Check parameter */
+ if(empty($productId)){
+ trigger_error("No valid product id given, check parameter 1.");
+ return(array());
+ }
+ if(!count($cfg)) return;
- /*! \brief Adds a given product to a client.
- @param
- @return
- */
- public function add_product_to_client($productId,$hostId)
- {
- $data = array("productId" => $productId,"hostId" => $hostId);
+ /* Add properties */
+ $data['item'] = array();
+ foreach($cfg as $name => $value){
+ $data['item'][] = "<name>".$name."</name><value>".$value['CURRENT']."</value>";
+ }
- /* Check parameter */
- if(empty($productId)){
- trigger_error("No valid product id given, check parameter 1.");
- return;
- }
- if(empty($hostId)){
- trigger_error("No valid host id given, check parameter 2.");
- return;
+ /* Query SI server */
+ $res = $this->send_data("gosa_opsi_set_product_properties",$this->target,$data,TRUE);
}
- /* Query SI server */
- $res = $this->send_data("gosa_opsi_add_product_to_client",$this->target,$data,TRUE);
- }
+ /*! \brief Adds a given product to a client.
+ @param
+ @return
+ */
+ public function add_product_to_client($productId,$hostId)
+ {
+ $data = array("productId" => $productId,"hostId" => $hostId);
+
+ /* Check parameter */
+ if(empty($productId)){
+ trigger_error("No valid product id given, check parameter 1.");
+ return;
+ }
+ if(empty($hostId)){
+ trigger_error("No valid host id given, check parameter 2.");
+ return;
+ }
- /*! \brief Removes a given product from a client.
- @param
- @return
- */
- public function del_product_from_client($productId,$hostId)
- {
- $data = array("productId" => $productId,"hostId" => $hostId);
-
- /* Check parameter */
- if(empty($productId)){
- trigger_error("No valid product id given, check parameter 1.");
- return;
+ /* Query SI server */
+ $res = $this->send_data("gosa_opsi_add_product_to_client",$this->target,$data,TRUE);
}
- if(empty($hostId)){
- trigger_error("No valid host id given, check parameter 2.");
- return;
- }
-
- /* Query SI server */
- $res = $this->send_data("gosa_opsi_del_product_from_client",$this->target,$data,TRUE);
- }
- /*! \brief Returns the clients hardware setup.
- @param
- @return
- */
- public function get_client_hardware($hostId)
- {
- $data = array("hostId" => $hostId);
-
- /* Check parameter */
- if(empty($hostId)){
- trigger_error("No valid host id given, check parameter 1.");
- return;
- }
+ /*! \brief Removes a given product from a client.
+ @param
+ @return
+ */
+ public function del_product_from_client($productId,$hostId)
+ {
+ $data = array("productId" => $productId,"hostId" => $hostId);
+
+ /* Check parameter */
+ if(empty($productId)){
+ trigger_error("No valid product id given, check parameter 1.");
+ return;
+ }
+ if(empty($hostId)){
+ trigger_error("No valid host id given, check parameter 2.");
+ return;
+ }
- /* Query SI server */
- $res = $this->send_data("gosa_opsi_get_client_hardware",$this->target,$data,TRUE);
- if(isset($res['XML'][0]['ITEM'])){
- return($res['XML'][0]['ITEM']);
+ /* Query SI server */
+ $res = $this->send_data("gosa_opsi_del_product_from_client",$this->target,$data,TRUE);
}
- return(array());
- }
- /*! \brief Returns the clients software setup.
- @param
- @return
- */
- public function get_client_software($hostId)
- {
- $data = array("hostId" => $hostId);
+ /*! \brief Returns the clients hardware setup.
+ @param
+ @return
+ */
+ public function get_client_hardware($hostId)
+ {
+ $data = array("hostId" => $hostId);
+
+ /* Check parameter */
+ if(empty($hostId)){
+ trigger_error("No valid host id given, check parameter 1.");
+ return;
+ }
- /* Check parameter */
- if(empty($hostId)){
- trigger_error("No valid host id given, check parameter 1.");
- return;
+ /* Query SI server */
+ $res = $this->send_data("gosa_opsi_get_client_hardware",$this->target,$data,TRUE);
+ if(isset($res['XML'][0]['ITEM'])){
+ return($res['XML'][0]['ITEM']);
+ }
+ return(array());
}
- /* Query SI server */
- $res = $this->send_data("gosa_opsi_get_client_software",$this->target,$data,TRUE);
- if(isset($res['XML'][0]['ITEM'])){
- return($res['XML'][0]['ITEM']);
- }
- return(array());
- }
+ /*! \brief Returns the clients software setup.
+ @param
+ @return
+ */
+ public function get_client_software($hostId)
+ {
+ $data = array("hostId" => $hostId);
+
+ /* Check parameter */
+ if(empty($hostId)){
+ trigger_error("No valid host id given, check parameter 1.");
+ return;
+ }
+ /* Query SI server */
+ $res = $this->send_data("gosa_opsi_get_client_software",$this->target,$data,TRUE);
+ if(isset($res['XML'][0]['ITEM'])){
+ return($res['XML'][0]['ITEM']);
+ }
+ return(array());
+ }
- /*! \brief Deletes the given opsi client.
- @param
- @return
- */
- public function del_client($hostId)
- {
- $data = array("hostId" => $hostId);
- /* Check parameter */
- if(empty($hostId)){
- trigger_error("No valid host id given, check parameter 1.");
- return;
- }
- /* Query SI server */
- $res = $this->send_data("gosa_opsi_del_client",$this->target,$data,TRUE);
- if(isset($res['XML'][0]['ITEM'])){
- return($res['XML'][0]['ITEM']);
+ /*! \brief Deletes the given opsi client.
+ @param
+ @return
+ */
+ public function del_client($hostId)
+ {
+ $data = array("hostId" => $hostId);
+
+ /* Check parameter */
+ if(empty($hostId)){
+ trigger_error("No valid host id given, check parameter 1.");
+ return;
+ }
+
+ /* Query SI server */
+ $res = $this->send_data("gosa_opsi_del_client",$this->target,$data,TRUE);
+ if(isset($res['XML'][0]['ITEM'])){
+ return($res['XML'][0]['ITEM']);
+ }
+ return(array());
}
- return(array());
- }
- /*! \brief Triggers install/reinstall of an opsi client.
- @param
- @return
- */
- public function job_opsi_install_client($hostId,$mac)
- {
- $data = array("hostId" => $hostId,"macaddress"=>$mac);
+ /*! \brief Triggers install/reinstall of an opsi client.
+ @param
+ @return
+ */
+ public function job_opsi_install_client($hostId,$mac)
+ {
+ $data = array("hostId" => $hostId,"macaddress"=>$mac);
+
+ /* Check parameter */
+ if(empty($hostId)){
+ trigger_error("No valid host id given, check parameter 1.");
+ return;
+ }
- /* Check parameter */
- if(empty($hostId)){
- trigger_error("No valid host id given, check parameter 1.");
- return;
+ /* Query SI server */
+ $this->send_data("job_opsi_install_client",$this->target,$data,TRUE);
}
-
- /* Query SI server */
- $this->send_data("job_opsi_install_client",$this->target,$data,TRUE);
- }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
diff --git a/gosa-plugins/opsi/admin/opsi/class_opsiProperties.inc b/gosa-plugins/opsi/admin/opsi/class_opsiProperties.inc
index 02a0da95a057f6708d3f72f91a7c72ef3d8ad56c..ec82412996271a5fcc064486bcb44e53a52f2a65 100644 (file)
*/
class opsiProperties extends plugin
{
- private $product;
- private $cfg;
- private $hostId;
- public $config;
+ private $product;
+ private $cfg;
+ private $hostId;
+ public $config;
- /*! \brief Initializes the class.
+ /*! \brief Initializes the class.
@param Object The gosa configuration object
@param String The product name.
@param Array The product config (e.g. aray('attr' => 'value'))
@param String The host id if necessary
- */
- public function __construct($config,$product,$cfg = array() ,$hostId = "")
- {
- $this->config = $config;
- $this->product = $product;
- $this->cfg = $cfg;
- $this->hostId = $hostId;
- }
-
-
- /*! \brief Display html dialog which allows to
- configure the properties
+ */
+ public function __construct($config,$product,$cfg = array() ,$hostId = "")
+ {
+ $this->config = $config;
+ $this->product = $product;
+ $this->cfg = $cfg;
+ $this->hostId = $hostId;
+ }
+
+
+ /*! \brief Display html dialog which allows to
+ configure the properties
@return String HTML content
- */
- public function execute()
- {
- plugin::execute();
- $ui =get_userinfo();
- $acl = $ui->get_permissions($this->config->current['BASE'],"opsi/opsiProperties","");
- $smarty = get_smarty();
- $smarty->assign("ACL",$acl);
- $smarty->assign("cfg",set_post($this->cfg));
- $smarty->assign("cfg_count",count($this->cfg));
- return($smarty->fetch(get_template_path("properties.tpl",TRUE,dirname(__FILE__))));
- }
-
-
- /*! \brief Save the posted property updates
- */
- public function save_object()
- {
- $ui =get_userinfo();
- $acl = $ui->get_permissions($this->config->current['BASE'],"opsi/opsiProperties","");
- if(preg_match("/w/",$acl)){
- foreach($this->cfg as $name => $value){
- if(isset($_POST['value_'.$name])){
- $this->cfg[$name]['CURRENT'] = validate(get_post('value_'.$name));
+ */
+ public function execute()
+ {
+ plugin::execute();
+ $ui =get_userinfo();
+ $acl = $ui->get_permissions($this->config->current['BASE'],"opsi/opsiProperties","");
+ $smarty = get_smarty();
+ $smarty->assign("ACL",$acl);
+ $smarty->assign("cfg",set_post($this->cfg));
+ $smarty->assign("cfg_count",count($this->cfg));
+ return($smarty->fetch(get_template_path("properties.tpl",TRUE,dirname(__FILE__))));
+ }
+
+
+ /*! \brief Save the posted property updates
+ */
+ public function save_object()
+ {
+ $ui =get_userinfo();
+ $acl = $ui->get_permissions($this->config->current['BASE'],"opsi/opsiProperties","");
+ if(preg_match("/w/",$acl)){
+ foreach($this->cfg as $name => $value){
+ if(isset($_POST['value_'.$name])){
+ $this->cfg[$name]['CURRENT'] = get_post('value_'.$name);
+ }
+ }
}
- }
}
- }
- /*! \brief Sets the current config array.
- */
- public function set_cfg($cfg)
- {
- $this->cfg = $cfg;
- }
+ /*! \brief Sets the current config array.
+ */
+ public function set_cfg($cfg)
+ {
+ $this->cfg = $cfg;
+ }
- /*! \brief Returns the current product config
+ /*! \brief Returns the current product config
@return Array.
- */
- public function get_cfg()
- {
- return($this->cfg);
- }
-
-
- /*! \brief Returns the ID of the product.
+ */
+ public function get_cfg()
+ {
+ return($this->cfg);
+ }
+
+
+ /*! \brief Returns the ID of the product.
@param String Product ID
- */
- public function get_product()
- {
- return($this->product);
- }
-
-
- /*! \brief Sets the current product ID,
- The name is only used to remember the currently edited product.
- */
- public function set_product($name)
- {
- $this->product = $name;
- }
-
-
- /*! \brief Retuns the hostId.
- */
- public function get_hostId()
- {
- return($this->hostId);
- }
-
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Products"),
- "plDescription" => _("Product properties"),
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 10,
- "plSection" => array("administration"),
- "plCategory" => array("opsi"),
- "plProvidedAcls"=> array(
- )
- ));
- }
+ */
+ public function get_product()
+ {
+ return($this->product);
+ }
+
+
+ /*! \brief Sets the current product ID,
+ The name is only used to remember the currently edited product.
+ */
+ public function set_product($name)
+ {
+ $this->product = $name;
+ }
+
+
+ /*! \brief Retuns the hostId.
+ */
+ public function get_hostId()
+ {
+ return($this->hostId);
+ }
+
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Products"),
+ "plDescription" => _("Product properties"),
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 10,
+ "plSection" => array("administration"),
+ "plCategory" => array("opsi"),
+ "plProvidedAcls"=> array(
+ )
+ ));
+ }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
diff --git a/gosa-plugins/opsi/admin/opsi/class_opsigeneric.inc b/gosa-plugins/opsi/admin/opsi/class_opsigeneric.inc
index 2bbee6c17aa02fb6008e72e22aab830225bf73fe..462685927d267b600febf446460242573fe537a9 100644 (file)
/*! \brief The opsi client base class.
- This class can be implemented in tow different ways:
- * as standalone opsi client
- * as part of the samba tabs
- both types will be detected automatically.
+ This class can be implemented in tow different ways:
+ * as standalone opsi client
+ * as part of the samba tabs
+ both types will be detected automatically.
- This class allows to edit the properties of an opsi client
- and its products.
+ This class allows to edit the properties of an opsi client
+ and its products.
*/
class opsiGeneric extends plugin
{
- /* Contains a list of all available netboot products
- */
- private $a_availableNetbootProducts = array();
- private $a_initial_availableNetbootProducts = array();
- private $s_selectedNetbootProduct = "";
- private $s_initial_selectedNetbootProduct = "";
-
- /* Contains a list of all available local products
- */
- private $a_availableLocalProducts = array();
- private $a_selectedLocalProducts = array();
- private $a_initial_selectedLocalProducts = array();
-
- /* Internal veriables
- */
- private $opsi; // The opsi handle
- public $parent = NULL; // The parent object (in case of samba)
-
- public $hostId = ""; // The host Id of the currently edit opsi host
- public $mac = ""; // The hosts mac address
- public $note = ""; // A note
- public $description = ""; // The client description
-
- public $initial_mac = "";
- public $initial_note = "";
- public $initial_description = "";
-
- private $init_failed = FALSE; // Is true if the opsi communication failed
- private $standalone = TRUE; // Is true if this is a standlone plugin. (Not samba)
- private $is_installed= FALSE; // Is true is the hast is already installed.
-
- public $attributes = array("mac","note","description");
-
- public $netConfigDNS = NULL;
-
- /*! \brief Initialize this class
+ /* Contains a list of all available netboot products
+ */
+ private $a_availableNetbootProducts = array();
+ private $a_initial_availableNetbootProducts = array();
+ private $s_selectedNetbootProduct = "";
+ private $s_initial_selectedNetbootProduct = "";
+
+ /* Contains a list of all available local products
+ */
+ private $a_availableLocalProducts = array();
+ private $a_selectedLocalProducts = array();
+ private $a_initial_selectedLocalProducts = array();
+
+ /* Internal veriables
+ */
+ private $opsi; // The opsi handle
+ public $parent = NULL; // The parent object (in case of samba)
+
+ public $hostId = ""; // The host Id of the currently edit opsi host
+ public $mac = ""; // The hosts mac address
+ public $note = ""; // A note
+ public $description = ""; // The client description
+
+ public $initial_mac = "";
+ public $initial_note = "";
+ public $initial_description = "";
+
+ private $init_failed = FALSE; // Is true if the opsi communication failed
+ private $standalone = TRUE; // Is true if this is a standlone plugin. (Not samba)
+ private $is_installed= FALSE; // Is true is the hast is already installed.
+
+ public $attributes = array("mac","note","description");
+
+ public $netConfigDNS = NULL;
+
+ /*! \brief Initialize this class
@param Object The GOsa base config.
@param String The Id of the host that we want to edit.
@param Object The parent object. (in case of samba)
- */
- public function __construct(&$config,$hostId,&$parent = NULL)
- {
- /* Create opsi handle
- */
- $this->opsi = new opsi($config);
- $this->config = $config;
-
- /* Check if we are are part of a windows workstation
*/
- $this->parent = $parent;
- if($parent instanceof wingeneric){
- $this->standalone = FALSE;
- }
+ public function __construct(&$config,$hostId,&$parent = NULL)
+ {
+ /* Create opsi handle
+ */
+ $this->opsi = new opsi($config);
+ $this->config = $config;
- /* Get hostId
- */
- if($hostId != "new"){
- if(preg_match("/^opsi:/",$hostId)){
- $this->hostId = preg_replace("/^opsi:=([^,]*),.*$/","\\1",$hostId);
- }elseif($this->parent instanceof wingeneric){
- $this->hostId = $this->parent->cn;
- $this->hostId = preg_replace('/\$$/',"",$this->hostId);
- }
- }
+ /* Check if we are are part of a windows workstation
+ */
+ $this->parent = $parent;
+ if($parent instanceof wingeneric){
+ $this->standalone = FALSE;
+ }
- /* Try to plugin */
- $this->init();
-
- // Prepare lists
- $this->selectedList = new sortableListing();
- $this->selectedList->setDeleteable(false);
- $this->selectedList->setEditable(false);
- $this->selectedList->setWidth("100%");
- $this->selectedList->setHeight("200px");
- $this->selectedList->setColspecs(array('*','*','40px'));
- $this->selectedList->setHeader(array(_("Name"),_("Description")));
- $this->selectedList->setDefaultSortColumn(1);
- $this->selectedList->setAcl('rwcdm'); // All ACLs, we filter on our own here.
-
- // Prepare lists
- $this->availableList = new sortableListing();
- $this->availableList->setDeleteable(false);
- $this->availableList->setEditable(false);
- $this->availableList->setWidth("100%");
- $this->availableList->setHeight("200px");
- $this->availableList->setColspecs(array('20px','*','*'));
- $this->availableList->setHeader(array("",_("Name"),_("Description")));
- $this->availableList->setDefaultSortColumn(1);
- }
-
-
- /*! \brief Try to load opsi client informations from the
- gosa support daemon.
- */
- private function init()
- {
- $err = FALSE;
- $this->init_failed = FALSE;
- $this->initially_was_account = FALSE;
-
- /* We are a standalone plugin.
+ /* Get hostId
+ */
+ if($hostId != "new"){
+ if(preg_match("/^opsi:/",$hostId)){
+ $this->hostId = preg_replace("/^opsi:=([^,]*),.*$/","\\1",$hostId);
+ }elseif($this->parent instanceof wingeneric){
+ $this->hostId = $this->parent->cn;
+ $this->hostId = preg_replace('/\$$/',"",$this->hostId);
+ }
+ }
+
+ /* Try to plugin */
+ $this->init();
+
+ // Prepare lists
+ $this->selectedList = new sortableListing();
+ $this->selectedList->setDeleteable(false);
+ $this->selectedList->setEditable(false);
+ $this->selectedList->setWidth("100%");
+ $this->selectedList->setHeight("200px");
+ $this->selectedList->setColspecs(array('*','*','40px'));
+ $this->selectedList->setHeader(array(_("Name"),_("Description")));
+ $this->selectedList->setDefaultSortColumn(1);
+ $this->selectedList->setAcl('rwcdm'); // All ACLs, we filter on our own here.
+
+ // Prepare lists
+ $this->availableList = new sortableListing();
+ $this->availableList->setDeleteable(false);
+ $this->availableList->setEditable(false);
+ $this->availableList->setWidth("100%");
+ $this->availableList->setHeight("200px");
+ $this->availableList->setColspecs(array('20px','*','*'));
+ $this->availableList->setHeader(array("",_("Name"),_("Description")));
+ $this->availableList->setDefaultSortColumn(1);
+ }
+
+
+ /*! \brief Try to load opsi client informations from the
+ gosa support daemon.
*/
- if($this->standalone ) {
- $this->is_account = TRUE;
- }
+ private function init()
+ {
+ $err = FALSE;
+ $this->init_failed = FALSE;
+ $this->initially_was_account = FALSE;
+ /* We are a standalone plugin.
+ */
+ if($this->standalone ) {
+ $this->is_account = TRUE;
+ }
- /* Try to load client infos from the gosa support daemon
- */
- if(!empty($this->hostId)){
- $list = $this->opsi->list_clients($this->hostId);
- $err |= $this->opsi->is_error();
-
- /* Walk through all returned opsi clients and try to detect
- one that matches our hostId.
- #FIXME Implement an opsi method which returns infos for only one opsi client, not all.
- */
- foreach($list as $entry){
- if(preg_match("/^".preg_quote($this->hostId, '/')."$/i",$entry['NAME'][0]['VALUE'])){
- $this->initially_was_account = TRUE;
- $this->is_account = TRUE;
- foreach(array(
- "is_installed" => "LASTSEEN",
- "description" => "DESCRIPTION",
- "mac" => "MAC",
- "note" => "NOTES") as $des => $src){
- $des2 = "initial_".$des;
- $this->$des2 = $this->$des = $entry[$src][0]['VALUE'];
- }
- break;
- }
- }
- }
- // Get package info
- $list = array();
- $list = $this->opsi->get_full_product_host_information($this->hostId);
- $err |= $this->opsi->is_error();
+ /* Try to load client infos from the gosa support daemon
+ */
+ if(!empty($this->hostId)){
+ $list = $this->opsi->list_clients($this->hostId);
+ $err |= $this->opsi->is_error();
+
+ /* Walk through all returned opsi clients and try to detect
+ one that matches our hostId.
+#FIXME Implement an opsi method which returns infos for only one opsi client, not all.
+ */
+ foreach($list as $entry){
+ if(preg_match("/^".preg_quote($this->hostId, '/')."$/i",$entry['NAME'][0]['VALUE'])){
+ $this->initially_was_account = TRUE;
+ $this->is_account = TRUE;
+ foreach(array(
+ "is_installed" => "LASTSEEN",
+ "description" => "DESCRIPTION",
+ "mac" => "MAC",
+ "note" => "NOTES") as $des => $src){
+ $des2 = "initial_".$des;
+ $this->$des2 = $this->$des = $entry[$src][0]['VALUE'];
+ }
+ break;
+ }
+ }
+ }
- /* Read informations about available netboot products.
- If not already done, before.
- */
- if(!$err){
- foreach($list as $key => $entry){
+ // Get package info
+ $list = array();
+ $list = $this->opsi->get_full_product_host_information($this->hostId);
+ $err |= $this->opsi->is_error();
- $tmp = array('DESC'=>$entry['data']['DESCRIPTION'],'NAME'=>$key);
- if($entry['configurable']){
- $tmp['CFG'] = $entry['data']['PROPERTIES'];
- }
+ /* Read informations about available netboot products.
+ If not already done, before.
+ */
+ if(!$err){
+ foreach($list as $key => $entry){
+
+ $tmp = array('DESC'=>$entry['data']['DESCRIPTION'],'NAME'=>$key);
+ if($entry['configurable']){
+ $tmp['CFG'] = $entry['data']['PROPERTIES'];
+ }
+
+ if($entry['data']['TYPE'] == "localboot"){
+ if(!$entry['installed']){
+ $this->a_availableLocalProducts[$key] = $tmp;
+ }else{
+ $this->a_selectedLocalProducts[$key] = $tmp;
+ }
+ }else{
+ $this->a_availableNetbootProducts[$key] = $tmp;
+ if($entry['installed']){
+ $this->s_selectedNetbootProduct= $key;
+ }
+ }
+ }
+ }
+
+ /* Check if everything went fine else reset everything and display a retry button
+ */
+ if($err){
+ $this->init_failed = TRUE;
- if($entry['data']['TYPE'] == "localboot"){
- if(!$entry['installed']){
- $this->a_availableLocalProducts[$key] = $tmp;
- }else{
- $this->a_selectedLocalProducts[$key] = $tmp;
- }
}else{
- $this->a_availableNetbootProducts[$key] = $tmp;
- if($entry['installed']){
- $this->s_selectedNetbootProduct= $key;
- }
- }
- }
- }
- /* Check if everything went fine else reset everything and display a retry button
- */
- if($err){
- $this->init_failed = TRUE;
-
- }else{
-
- /* Remember initial settings */
- $this->a_initial_selectedLocalProducts = $this->a_selectedLocalProducts;
- $this->s_initial_selectedNetbootProduct = $this->s_selectedNetbootProduct;
- $this->a_initial_availableNetbootProducts = $this->a_availableNetbootProducts;
-
- /* Ensure that a valid netboot is selected product is.
- */
- if(empty($this->s_selectedNetbootProduct)){
- $this->s_selectedNetbootProduct = key($this->a_availableNetbootProducts);
- }
-
- // Now fake a valid ldap entry ... this is necessary to avoid
- // modifications in the dns/dhcp classes
-
- // First fake cn
- $this->attrs['hostId'][0] = $this->hostId;
- $this->attrs['cn'][0] = $this->hostId;
-
- // Second detect DNS settings.
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
- $strippedHostId = preg_replace("/\..*$/","",$this->hostId);
- $ldap->search("(&(objectClass=dNSZone)(|(relativeDomainName=".$this->hostId.")(relativeDomainName=".$strippedHostId."))(aRecord=*))",array("aRecord"));
- if($ldap->count()){
- $attrs = $ldap->fetch();
- $this->attrs['ipHostNumber']['count'] = 0;
- $this->attrs['ipHostNumber'][0] = $attrs['aRecord'][0];
- }
-
- $this->attrs['macAddress']['count'] = 1;
- $this->attrs['macAddress'][0] = &$this->mac;
-
- // Initialize DHCP and DNS
- $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses, FALSE, "hostId");
- $this->netConfigDNS->set_acl_category("opsi");
- $this->netConfigDNS->set_acl_base($this->config->current['BASE']);
- $this->netConfigDNS->IPisMust = FALSE;
- $this->netConfigDNS->MACisMust = FALSE;
- }
- }
+ /* Remember initial settings */
+ $this->a_initial_selectedLocalProducts = $this->a_selectedLocalProducts;
+ $this->s_initial_selectedNetbootProduct = $this->s_selectedNetbootProduct;
+ $this->a_initial_availableNetbootProducts = $this->a_availableNetbootProducts;
+ /* Ensure that a valid netboot is selected product is.
+ */
+ if(empty($this->s_selectedNetbootProduct)){
+ $this->s_selectedNetbootProduct = key($this->a_availableNetbootProducts);
+ }
- /*! \brief Check given data.
- @return Array Returns an array with all issues.
- */
- public function check()
- {
-
- // In case of initialization problem, we do not save anything.
- // We can skip checks here, the date isn't usable.
- if($this->init_failed){
- return;
- };
-
- $messages = plugin::check();
- $messages= array_merge($messages, $this->netConfigDNS->check());
-
- if(empty($this->hostId)){
- $messages[] = msgPool::required(_("Name"));
- }elseif(!preg_match("/\./",$this->hostId)){
-
- /* The hostId must contain a domain part
- */
- $messages[] = msgPool::invalid(_("Name"),$this->hostId,"",
- _("The field 'Name' must contain a domain part!"));
- }elseif(preg_match("/[^a-z0-9\.\-_]/",$this->hostId)){
- $messages[] = msgPool::invalid(_("Name"),$this->hostId,"/[a-z0-9\.\-_]/");
+ // Now fake a valid ldap entry ... this is necessary to avoid
+ // modifications in the dns/dhcp classes
+
+ // First fake cn
+ $this->attrs['hostId'][0] = $this->hostId;
+ $this->attrs['cn'][0] = $this->hostId;
+
+ // Second detect DNS settings.
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $strippedHostId = preg_replace("/\..*$/","",$this->hostId);
+ $ldap->search("(&(objectClass=dNSZone)(|(relativeDomainName=".$this->hostId.")(relativeDomainName=".$strippedHostId."))(aRecord=*))",array("aRecord"));
+ if($ldap->count()){
+ $attrs = $ldap->fetch();
+ $this->attrs['ipHostNumber']['count'] = 0;
+ $this->attrs['ipHostNumber'][0] = $attrs['aRecord'][0];
+ }
+
+ $this->attrs['macAddress']['count'] = 1;
+ $this->attrs['macAddress'][0] = &$this->mac;
+
+ // Initialize DHCP and DNS
+ $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses, FALSE, "hostId");
+ $this->netConfigDNS->set_acl_category("opsi");
+ $this->netConfigDNS->set_acl_base($this->config->current['BASE']);
+ $this->netConfigDNS->IPisMust = FALSE;
+ $this->netConfigDNS->MACisMust = FALSE;
+ }
}
- /* Ensure that the mac address is valid
+
+ /*! \brief Check given data.
+ @return Array Returns an array with all issues.
*/
- if(!tests::is_mac($this->mac) || empty($this->mac)){
- $messages[] = msgPool::invalid(_("MAC address"),$this->mac,"","00:0C:7F:31:33:F1");
+ public function check()
+ {
+
+ // In case of initialization problem, we do not save anything.
+ // We can skip checks here, the date isn't usable.
+ if($this->init_failed){
+ return;
+ };
+
+ $messages = plugin::check();
+ $messages= array_merge($messages, $this->netConfigDNS->check());
+
+ if(empty($this->hostId)){
+ $messages[] = msgPool::required(_("Name"));
+ }elseif(!preg_match("/\./",$this->hostId)){
+
+ /* The hostId must contain a domain part
+ */
+ $messages[] = msgPool::invalid(_("Name"),$this->hostId,"",
+ _("The field 'Name' must contain a domain part!"));
+ }elseif(preg_match("/[^a-z0-9\.\-_]/",$this->hostId)){
+ $messages[] = msgPool::invalid(_("Name"),$this->hostId,"/[a-z0-9\.\-_]/");
+ }
+
+ /* Ensure that the mac address is valid
+ */
+ if(!tests::is_mac($this->mac) || empty($this->mac)){
+ $messages[] = msgPool::invalid(_("MAC address"),$this->mac,"","00:0C:7F:31:33:F1");
+ }
+ return($messages);
}
- return($messages);
- }
- /*! \brief Create the html ui of this plugin
+ /*! \brief Create the html ui of this plugin
@return String HTML content.
- */
- public function execute()
- {
- plugin::execute();
- $display ="";
-
- /* The pluign initialization failed due to communication problems with the gosa daemon.
- A retry button will be displayed here.
- */
- if($this->init_failed){
- $smarty = get_smarty();
- $smarty->assign("standalone ", $this->standalone );
- $smarty->assign("init_failed",TRUE);
- $smarty->assign("message",$this->opsi->get_error());
- return($smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
- }
-
-
- /* If we are not a stand alone opsi client, we must be a samba client
- which has the opsi tab enabled.
- Check if the opsi is added or removed and display state buttons.
- */
- if(!$this->standalone ){
-
- /* Do we need to flip is_account state? */
- if(isset($_POST['modify_state'])){
- if($this->is_account && $this->acl_is_removeable()){
- $this->is_account= FALSE;
- }elseif(!$this->is_account && $this->acl_is_createable()){
- $this->is_account= TRUE;
- }
- }
- if($this->is_account){
- $display = $this->show_disable_header(msgPool::removeFeaturesButton(_("OPSI")),
- msgPool::featuresEnabled(_("OPSI")));
- }else{
- $display = $this->show_enable_header(msgPool::addFeaturesButton(_("OPSI")),
- msgPool::featuresDisabled(_("OPSI")));
- return($display);
- }
- }
-
- /* Check if we have a sub dialog opened
*/
- if(is_object($this->dialog)){
- $this->dialog->save_object();
- return($this->dialog->execute());
- }
+ public function execute()
+ {
+ plugin::execute();
+ $display ="";
- /* Create HTML output of this plugin
- */
- $smarty = get_smarty();
- $smarty->assign("standalone", $this->standalone );
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
- }
+ /* The pluign initialization failed due to communication problems with the gosa daemon.
+ A retry button will be displayed here.
+ */
+ if($this->init_failed){
+ $smarty = get_smarty();
+ $smarty->assign("standalone ", $this->standalone );
+ $smarty->assign("init_failed",TRUE);
+ $smarty->assign("message",$this->opsi->get_error());
+ return($smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
+ }
+
+
+ /* If we are not a stand alone opsi client, we must be a samba client
+ which has the opsi tab enabled.
+ Check if the opsi is added or removed and display state buttons.
+ */
+ if(!$this->standalone ){
+
+ /* Do we need to flip is_account state? */
+ if(isset($_POST['modify_state'])){
+ if($this->is_account && $this->acl_is_removeable()){
+ $this->is_account= FALSE;
+ }elseif(!$this->is_account && $this->acl_is_createable()){
+ $this->is_account= TRUE;
+ }
+ }
+ if($this->is_account){
+ $display = $this->show_disable_header(msgPool::removeFeaturesButton(_("OPSI")),
+ msgPool::featuresEnabled(_("OPSI")));
+ }else{
+ $display = $this->show_enable_header(msgPool::addFeaturesButton(_("OPSI")),
+ msgPool::featuresDisabled(_("OPSI")));
+ return($display);
+ }
+ }
- /* Assign ACLs */
- $tmp = $this->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $translated){
- $smarty->assign($name."ACL",$this->getacl($name));
- }
+ /* Check if we have a sub dialog opened
+ */
+ if(is_object($this->dialog)){
+ $this->dialog->save_object();
+ return($this->dialog->execute());
+ }
- $smarty->assign("is_installed", $this->is_installed);
- $smarty->assign("init_failed",FALSE);
+ /* Create HTML output of this plugin
+ */
+ $smarty = get_smarty();
+ $smarty->assign("standalone", $this->standalone );
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,$this->$attr);
+ }
- /* Create list of available local products
- */
- $data = $lData=array();
- foreach($this->a_availableLocalProducts as $name => $data){
- if(isset($this->a_selectedLocalProducts[$name])) continue;
- $add_tab = "";
- if($this->acl_is_writeable("localProduct")){
- $add_tab = image('images/back.png','add_lp_'.$name);
- }
- $data[$name] = $name;
- $lData[$name] = array('data' => array($add_tab,$name,$data['DESC']));
- }
- $this->availableList->setAcl($this->getacl("localProduct"));
- $this->availableList->setListData($data,$lData);
- $this->availableList->update();
+ /* Assign ACLs */
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translated){
+ $smarty->assign($name."ACL",$this->getacl($name));
+ }
- /* Create list of selected local products
- */
- $data = $lData=array();
- foreach($this->a_selectedLocalProducts as $name => $data){
- $edit = image('images/empty.png');
- if(count($data['CFG'])){
- $edit = image('images/lists/edit.png','edit_lp_'.$name);
- }
- $del = image('images/lists/trash.png','del_lp_'.$name);
- $data[$name] = $name;
- $lData[$name] = array('data' => array( $name,$data['DESC'],$edit.$del));
- }
- $this->selectedList->setAcl($this->getacl("localProduct"));
- $this->selectedList->setListData($data,$lData);
- $this->selectedList->update();
+ $smarty->assign("is_installed", $this->is_installed);
+ $smarty->assign("init_failed",FALSE);
- /* Check if netboot product is configurable
- */
- $cfg_able =FALSE;
- if(isset($this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'])){
- $cfg_able = count($this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG']);
- $cfg_able &= $this->acl_is_readable("netbootProduct");
- }
+ /* Create list of available local products
+ */
+ $data = $lData=array();
+ foreach($this->a_availableLocalProducts as $name => $data){
+ if(isset($this->a_selectedLocalProducts[$name])) continue;
+ $add_tab = "";
+ if($this->acl_is_writeable("localProduct")){
+ $add_tab = image('images/back.png','add_lp_'.$name);
+ }
+ $data[$name] = $name;
+ $lData[$name] = array('data' => array($add_tab,$name,$data['DESC']));
+ }
+ $this->availableList->setAcl($this->getacl("localProduct"));
+ $this->availableList->setListData($data,$lData);
+ $this->availableList->update();
- // Get net config template
- $str = $this->netConfigDNS->execute();
- if(is_object($this->netConfigDNS->dialog)){
- return($str);
- }
- $smarty->assign("netconfig", $str);
-
- $smarty->assign("netboot_configurable",$cfg_able);
- $smarty->assign("hostId", $this->hostId);
- $smarty->assign("divSLP", $this->selectedList->render());
- $smarty->assign("divALP", $this->availableList->render());
- $smarty->assign("SNP", $this->s_selectedNetbootProduct);
- $smarty->assign("ANP", $this->a_availableNetbootProducts);
- return($display.$smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
- }
-
-
- /*! \brief Save modifications using the gosa support daemon.
- */
- public function save()
- {
- if($this->init_failed){
- return;
+ /* Create list of selected local products
+ */
+ $data = $lData=array();
+ foreach($this->a_selectedLocalProducts as $name => $data){
+ $edit = image('images/empty.png');
+ if(count($data['CFG'])){
+ $edit = image('images/lists/edit.png','edit_lp_'.$name);
+ }
+ $del = image('images/lists/trash.png','del_lp_'.$name);
+ $data[$name] = $name;
+ $lData[$name] = array('data' => array( $name,$data['DESC'],$edit.$del));
+ }
+ $this->selectedList->setAcl($this->getacl("localProduct"));
+ $this->selectedList->setListData($data,$lData);
+ $this->selectedList->update();
+
+ /* Check if netboot product is configurable
+ */
+ $cfg_able =FALSE;
+ if(isset($this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'])){
+ $cfg_able = count($this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG']);
+ $cfg_able &= $this->acl_is_readable("netbootProduct");
+ }
+
+ // Get net config template
+ $str = $this->netConfigDNS->execute();
+ if(is_object($this->netConfigDNS->dialog)){
+ return($str);
+ }
+ $smarty->assign("netconfig", $str);
+
+ $smarty->assign("netboot_configurable",$cfg_able);
+ $smarty->assign("hostId", $this->hostId);
+ $smarty->assign("divSLP", $this->selectedList->render());
+ $smarty->assign("divALP", $this->availableList->render());
+ $smarty->assign("SNP", $this->s_selectedNetbootProduct);
+ $smarty->assign("ANP", $this->a_availableNetbootProducts);
+ return($display.$smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
}
-
- /* Check if we have to create a new opsi client
- or just have to save client modifications.
+
+
+ /*! \brief Save modifications using the gosa support daemon.
*/
- if(!$this->initially_was_account && $this->is_account){
- $res = $this->opsi->add_client($this->hostId,$this->mac,$this->note,$this->description);
- if($this->opsi->is_error()){
- msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
- return;
- }
- }else{
-
- /* Update client modifcations.
- -Only if necessary
- */
- if($this->note != $this->initial_note ||
- $this->description != $this->initial_description ||
- $this->mac != $this->initial_mac){
- $this->opsi->modify_client($this->hostId,$this->mac,$this->note,$this->description);
- if($this->opsi->is_error()){
- msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
- return;
+ public function save()
+ {
+ if($this->init_failed){
+ return;
}
- }
- }
+ /* Check if we have to create a new opsi client
+ or just have to save client modifications.
+ */
+ if(!$this->initially_was_account && $this->is_account){
+ $res = $this->opsi->add_client($this->hostId,$this->mac,$this->note,$this->description);
+ if($this->opsi->is_error()){
+ msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
+ return;
+ }
+ }else{
+
+ /* Update client modifcations.
+ -Only if necessary
+ */
+ if($this->note != $this->initial_note ||
+ $this->description != $this->initial_description ||
+ $this->mac != $this->initial_mac){
+ $this->opsi->modify_client($this->hostId,$this->mac,$this->note,$this->description);
+ if($this->opsi->is_error()){
+ msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
+ return;
+ }
+ }
+ }
- /***********
- Detect local netboot product changes
- - Check which products were removed.
- - Check which products were added.
- ***********/
+ /***********
+ Detect local netboot product changes
+ - Check which products were removed.
+ - Check which products were added.
+ ***********/
- /* Detect which products were removed an which added.
- */
- $del = array_diff_assoc($this->a_initial_selectedLocalProducts,$this->a_selectedLocalProducts);
- $add = array_diff_assoc($this->a_selectedLocalProducts,$this->a_initial_selectedLocalProducts);
- /* Remove products from client
- */
- foreach($del as $name => $data){
- $this->opsi->del_product_from_client($name,$this->hostId);
- if($this->opsi->is_error()){
- msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
- return;
- }
- }
-
- /* Add products to client
- And set the product properties.
- */
- foreach($add as $name => $data){
- $this->opsi->add_product_to_client($name,$this->hostId);
- if($this->opsi->is_error()){
- msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
- return;
- }
- if(!empty($data['CFG'])){
- $this->opsi->set_product_properties($name,$data['CFG'],$this->hostId);
- if($this->opsi->is_error()){
- msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
- return;
+ /* Detect which products were removed an which added.
+ */
+ $del = array_diff_assoc($this->a_initial_selectedLocalProducts,$this->a_selectedLocalProducts);
+ $add = array_diff_assoc($this->a_selectedLocalProducts,$this->a_initial_selectedLocalProducts);
+
+ /* Remove products from client
+ */
+ foreach($del as $name => $data){
+ $this->opsi->del_product_from_client($name,$this->hostId);
+ if($this->opsi->is_error()){
+ msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
+ return;
+ }
}
- }
- }
- /* Save local product properties
- */
- foreach($this->a_selectedLocalProducts as $name => $data){
- if(isset($del[$name]) || isset($add[$name])) continue;
-
- /* Update product properties if there are changes
- */
- $diffs = $this->get_config_changes($data['CFG'],$this->a_initial_selectedLocalProducts[$name]['CFG']);
- if(count($diffs)){
- $this->opsi->set_product_properties($name,$diffs,$this->hostId);
- if($this->opsi->is_error()){
- msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
- return;
+ /* Add products to client
+ And set the product properties.
+ */
+ foreach($add as $name => $data){
+ $this->opsi->add_product_to_client($name,$this->hostId);
+ if($this->opsi->is_error()){
+ msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
+ return;
+ }
+ if(!empty($data['CFG'])){
+ $this->opsi->set_product_properties($name,$data['CFG'],$this->hostId);
+ if($this->opsi->is_error()){
+ msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
+ return;
+ }
+ }
}
- }
- }
- /*********
- Detect Netboot product changes
- - Check if another netboot product was selected.
- - Check if the product properties were changes.
- *********/
+ /* Save local product properties
+ */
+ foreach($this->a_selectedLocalProducts as $name => $data){
+ if(isset($del[$name]) || isset($add[$name])) continue;
+
+ /* Update product properties if there are changes
+ */
+ $diffs = $this->get_config_changes($data['CFG'],$this->a_initial_selectedLocalProducts[$name]['CFG']);
+ if(count($diffs)){
+ $this->opsi->set_product_properties($name,$diffs,$this->hostId);
+ if($this->opsi->is_error()){
+ msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
+ return;
+ }
+ }
+ }
- /* Update used netboot product.
- */
- if($this->s_selectedNetbootProduct != $this->s_initial_selectedNetbootProduct){
- if(!empty($this->s_initial_selectedNetbootProduct)){
- $this->opsi->del_product_from_client($this->s_initial_selectedNetbootProduct,$this->hostId);
- if($this->opsi->is_error()){
- msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
- return;
- }
- }
- $this->opsi->add_product_to_client($this->s_selectedNetbootProduct,$this->hostId);
- if($this->opsi->is_error()){
- msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
- return;
- }
- }
+ /*********
+ Detect Netboot product changes
+ - Check if another netboot product was selected.
+ - Check if the product properties were changes.
+ *********/
- /* Check if we have to update the netboot product properties
- This is the case, if this product is newly selected.
- Or if there was at least one configuration attribute modified.
- */
- $cfg_1 = $cfg_2 = array();
- if(isset($this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'])){
- $cfg_1 = $this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'];
- }
- if(isset($this->a_initial_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'])){
- $cfg_2 = $this->a_initial_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'];
- }
- $diffs = $this->get_config_changes($cfg_1,$cfg_2);
- $to_update = array();
- if( !$this->initially_was_account ||
- $this->s_selectedNetbootProduct != $this->s_initial_selectedNetbootProduct){
- $to_update = $this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'];
- }elseif(count($diffs)){
- $to_update = $diffs;
- }
+ /* Update used netboot product.
+ */
+ if($this->s_selectedNetbootProduct != $this->s_initial_selectedNetbootProduct){
+ if(!empty($this->s_initial_selectedNetbootProduct)){
+ $this->opsi->del_product_from_client($this->s_initial_selectedNetbootProduct,$this->hostId);
+ if($this->opsi->is_error()){
+ msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
+ return;
+ }
+ }
+ $this->opsi->add_product_to_client($this->s_selectedNetbootProduct,$this->hostId);
+ if($this->opsi->is_error()){
+ msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
+ return;
+ }
+ }
- if(count($to_update)){
- $name = $this->s_selectedNetbootProduct;
- $this->opsi->set_product_properties($name,$to_update,$this->hostId);
- if($this->opsi->is_error()){
- msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
- return;
- }
- }
+ /* Check if we have to update the netboot product properties
+ This is the case, if this product is newly selected.
+ Or if there was at least one configuration attribute modified.
+ */
+ $cfg_1 = $cfg_2 = array();
+ if(isset($this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'])){
+ $cfg_1 = $this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'];
+ }
+ if(isset($this->a_initial_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'])){
+ $cfg_2 = $this->a_initial_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'];
+ }
+ $diffs = $this->get_config_changes($cfg_1,$cfg_2);
+ $to_update = array();
+ if( !$this->initially_was_account ||
+ $this->s_selectedNetbootProduct != $this->s_initial_selectedNetbootProduct){
+ $to_update = $this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'];
+ }elseif(count($diffs)){
+ $to_update = $diffs;
+ }
- $this->netConfigDNS->cn = $this->hostId;
- $this->netConfigDNS->save();
- }
+ if(count($to_update)){
+ $name = $this->s_selectedNetbootProduct;
+ $this->opsi->set_product_properties($name,$to_update,$this->hostId);
+ if($this->opsi->is_error()){
+ msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
+ return;
+ }
+ }
-
- public function get_config_changes($c1,$c2)
- {
- /* Get key which are not present in both entries
- */
- $res = array();
- foreach($c2 as $name => $value){
- if(!isset($c1[$name]) || $c1[$name]['CURRENT'] != $c2[$name]['CURRENT']){
- $res[$name] = $c2[$name];
- }
- }
- foreach($c1 as $name => $value){
- if(!isset($c2[$name]) || $c2[$name]['CURRENT'] != $c1[$name]['CURRENT']){
- $res[$name] = $c1[$name];
- }
+ $this->netConfigDNS->cn = $this->hostId;
+ $this->netConfigDNS->save();
}
- return($res);
- }
- /*! \brief Removes the opsi client
- */
- public function remove_from_parent()
- {
- if($this->init_failed){
- return;
+ public function get_config_changes($c1,$c2)
+ {
+ /* Get key which are not present in both entries
+ */
+ $res = array();
+ foreach($c2 as $name => $value){
+ if(!isset($c1[$name]) || $c1[$name]['CURRENT'] != $c2[$name]['CURRENT']){
+ $res[$name] = $c2[$name];
+ }
+ }
+ foreach($c1 as $name => $value){
+ if(!isset($c2[$name]) || $c2[$name]['CURRENT'] != $c1[$name]['CURRENT']){
+ $res[$name] = $c1[$name];
+ }
+ }
+ return($res);
}
- $this->netConfigDNS->remove_from_parent();
- $this->opsi->del_client($this->hostId);
- if($this->opsi->is_error()){
- msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
- return;
- }
- }
+ /*! \brief Removes the opsi client
+ */
+ public function remove_from_parent()
+ {
+ if($this->init_failed){
+ return;
+ }
+ $this->netConfigDNS->remove_from_parent();
- /*! \brief Save html posts
- */
- public function save_object()
- {
- /* Init failed; reinit is triggered here.
- */
- if(isset($_POST['reinit']) && $this->init_failed){
- $this->init();
+ $this->opsi->del_client($this->hostId);
+ if($this->opsi->is_error()){
+ msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
+ return;
+ }
}
- /* Property are currently edited, close the dialog.
- */
- if(isset($_POST['cancel_properties']) && is_object($this->dialog)){
- $this->dialog = NULL;
- }
-
- /* Save product property changes
- */
- if(isset($_POST['save_properties']) && ($this->dialog instanceof opsiProperties)){
- $this->dialog->save_object();
- $pro = $this->dialog->get_product();
- $CFG = $this->dialog->get_cfg();
- if(isset($this->a_selectedLocalProducts[$pro])){
- if($this->acl_is_writeable("localProduct")){
- $this->a_selectedLocalProducts[$pro]['CFG'] = $CFG;
- }
- $this->dialog = NULL;
- }elseif($this->s_selectedNetbootProduct == $pro){
- if($this->acl_is_writeable("netbootProduct")){
- $this->a_availableNetbootProducts[$pro]['CFG'] = $CFG;
- }
- $this->dialog = NULL;
- }else{
- trigger_error("Fatal, unknown product was configured.");
- }
- }
- /* Save html post
+ /*! \brief Save html posts
*/
- if(isset($_POST['opsiGeneric_posted'])){
-
- plugin::save_object();
- $this->netConfigDNS->save_object();
- $this->mac = $this->netConfigDNS->macAddress;
-
- /* Get hostId
- */
- if(isset($_POST['hostId']) && $this->standalone && $this->acl_is_writeable("hostId")){
- $this->hostId = get_post('hostId');
- }
-
- /* Send actions like 'install' or 'wake' to the si server
- */
- if($this->acl_is_writeable("triggerAction") &&
- isset($_POST['opsi_action']) &&
- isset($_POST['opsi_trigger_action']) &&
- $this->standalone ){
- $action = $_POST['opsi_action'];
- if($action == "install"){
- $this->install_client();
- }
- if($action == "wake"){
- $this->wake_client();
- }
- }
-
- /* Get selected netboot product.
- */
- if(isset($_POST['opsi_netboot_product']) && $this->acl_is_writeable("netbootProduct")){
- $SNP = trim($_POST['opsi_netboot_product']);
- if(isset($this->a_availableNetbootProducts[$SNP])){
- if(!isset($this->a_availableNetbootProducts[$SNP]['CFG'])){
- $CFG = $this->opsi->get_product_properties($SNP);
- $this->a_availableNetbootProducts[$SNP]['CFG'] = $CFG;
- if($this->opsi->is_error()){
- $this->init_failed = TRUE;
- return;
- }
- }
- $this->s_selectedNetbootProduct = $SNP;
+ public function save_object()
+ {
+ /* Init failed; reinit is triggered here.
+ */
+ if(isset($_POST['reinit']) && $this->init_failed){
+ $this->init();
}
- }
-
- /* Add/remove/edit local products
- */
- foreach($_POST as $name => $value){
- /* Check if netboot product configuration is requested
+ /* Property are currently edited, close the dialog.
*/
- if(preg_match("/^configure_netboot/",$name) && $this->acl_is_readable("netbootProduct")){
- $pro = $this->s_selectedNetbootProduct;
- $cfg = $this->a_availableNetbootProducts[$pro]['CFG'];
- $this->dialog = new opsiProperties($this->config,$pro,$cfg,$this->hostId);
- break;
- }
-
- /* Add product
+ if(isset($_POST['cancel_properties']) && is_object($this->dialog)){
+ $this->dialog = NULL;
+ }
+
+ /* Save product property changes
*/
- if(preg_match("/^add_lp_/",$name) && $this->acl_is_writeable("localProduct")){
- $product = preg_replace("/^add_lp_(.*)$/","\\1",$name);
- if(isset($this->a_availableLocalProducts[$product]) && !isset($this->a_selectedLocalProducts[$product])){
- $this->a_selectedLocalProducts[$product] = $this->a_availableLocalProducts[$product];
- $CFG = $this->opsi->get_product_properties($product);
- if($this->opsi->is_error()){
- $this->init_failed = TRUE;
- return;
+ if(isset($_POST['save_properties']) && ($this->dialog instanceof opsiProperties)){
+ $this->dialog->save_object();
+ $pro = $this->dialog->get_product();
+ $CFG = $this->dialog->get_cfg();
+ if(isset($this->a_selectedLocalProducts[$pro])){
+ if($this->acl_is_writeable("localProduct")){
+ $this->a_selectedLocalProducts[$pro]['CFG'] = $CFG;
+ }
+ $this->dialog = NULL;
+ }elseif($this->s_selectedNetbootProduct == $pro){
+ if($this->acl_is_writeable("netbootProduct")){
+ $this->a_availableNetbootProducts[$pro]['CFG'] = $CFG;
+ }
+ $this->dialog = NULL;
+ }else{
+ trigger_error("Fatal, unknown product was configured.");
}
- $this->a_selectedLocalProducts[$product]['CFG'] = $CFG;
- }
- break;
}
-
- /* Delete product
- */
- if(preg_match("/^del_lp_/",$name) && $this->acl_is_writeable("localProduct")){
- $product = preg_replace("/^del_lp_(.*)$/","\\1",$name);
- if(isset($this->a_selectedLocalProducts[$product])){
- unset($this->a_selectedLocalProducts[$product]);
- }
- break;
- }
-
- /* Edit a product
+
+ /* Save html post
*/
- if(preg_match("/^edit_lp_/",$name) && $this->acl_is_readable("localProduct")){
- $product = preg_replace("/^edit_lp_(.*)$/","\\1",$name);
- $this->dialog = new opsiProperties($this->config,
- $product,$this->a_selectedLocalProducts[$product]['CFG'],$this->hostId);
- break;
+ if(isset($_POST['opsiGeneric_posted'])){
+
+ plugin::save_object();
+ $this->netConfigDNS->save_object();
+ $this->mac = $this->netConfigDNS->macAddress;
+
+ /* Get hostId
+ */
+ if(isset($_POST['hostId']) && $this->standalone && $this->acl_is_writeable("hostId")){
+ $this->hostId = get_post('hostId');
+ }
+
+ /* Send actions like 'install' or 'wake' to the si server
+ */
+ if($this->acl_is_writeable("triggerAction") &&
+ isset($_POST['opsi_action']) &&
+ isset($_POST['opsi_trigger_action']) &&
+ $this->standalone ){
+ $action = get_post('opsi_action');
+ if($action == "install"){
+ $this->install_client();
+ }
+ if($action == "wake"){
+ $this->wake_client();
+ }
+ }
+
+ /* Get selected netboot product.
+ */
+ if(isset($_POST['opsi_netboot_product']) && $this->acl_is_writeable("netbootProduct")){
+ $SNP = get_post('opsi_netboot_product');
+ if(isset($this->a_availableNetbootProducts[$SNP])){
+ if(!isset($this->a_availableNetbootProducts[$SNP]['CFG'])){
+ $CFG = $this->opsi->get_product_properties($SNP);
+ $this->a_availableNetbootProducts[$SNP]['CFG'] = $CFG;
+ if($this->opsi->is_error()){
+ $this->init_failed = TRUE;
+ return;
+ }
+ }
+ $this->s_selectedNetbootProduct = $SNP;
+ }
+ }
+
+ /* Add/remove/edit local products
+ */
+ foreach($_POST as $name => $value){
+
+ /* Check if netboot product configuration is requested
+ */
+ if(preg_match("/^configure_netboot/",$name) && $this->acl_is_readable("netbootProduct")){
+ $pro = $this->s_selectedNetbootProduct;
+ $cfg = $this->a_availableNetbootProducts[$pro]['CFG'];
+ $this->dialog = new opsiProperties($this->config,$pro,$cfg,$this->hostId);
+ break;
+ }
+
+ /* Add product
+ */
+ if(preg_match("/^add_lp_/",$name) && $this->acl_is_writeable("localProduct")){
+ $product = preg_replace("/^add_lp_(.*)$/","\\1",$name);
+ if(isset($this->a_availableLocalProducts[$product]) && !isset($this->a_selectedLocalProducts[$product])){
+ $this->a_selectedLocalProducts[$product] = $this->a_availableLocalProducts[$product];
+ $CFG = $this->opsi->get_product_properties($product);
+ if($this->opsi->is_error()){
+ $this->init_failed = TRUE;
+ return;
+ }
+ $this->a_selectedLocalProducts[$product]['CFG'] = $CFG;
+ }
+ break;
+ }
+
+ /* Delete product
+ */
+ if(preg_match("/^del_lp_/",$name) && $this->acl_is_writeable("localProduct")){
+ $product = preg_replace("/^del_lp_(.*)$/","\\1",$name);
+ if(isset($this->a_selectedLocalProducts[$product])){
+ unset($this->a_selectedLocalProducts[$product]);
+ }
+ break;
+ }
+
+ /* Edit a product
+ */
+ if(preg_match("/^edit_lp_/",$name) && $this->acl_is_readable("localProduct")){
+ $product = preg_replace("/^edit_lp_(.*)$/","\\1",$name);
+ $this->dialog = new opsiProperties($this->config,
+ $product,$this->a_selectedLocalProducts[$product]['CFG'],$this->hostId);
+ break;
+ }
+ }
}
- }
}
- }
- /* Triggers client installation
- */
- function install_client()
- {
- $this->opsi->send_action("install",$this->hostId,$this->mac);
- if($this->opsi->is_error()){
- msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
+ /* Triggers client installation
+ */
+ function install_client()
+ {
+ $this->opsi->send_action("install",$this->hostId,$this->mac);
+ if($this->opsi->is_error()){
+ msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
+ }
}
- }
- /* Wake up client
- */
- function wake_client()
- {
- /* Check if we are able to communicate with the GOsa supprot daemon
+ /* Wake up client
*/
- if(class_available("gosaSupportDaemon")){
- $o = new gosaSupportDaemon();
- if($o->connect() && class_available("DaemonEvent_wakeup")){
- $evt = new DaemonEvent_wakeup($this->config);
- $evt->add_targets(array($this->mac));
- $o->append($evt);
- }
+ function wake_client()
+ {
+ /* Check if we are able to communicate with the GOsa supprot daemon
+ */
+ if(class_available("gosaSupportDaemon")){
+ $o = new gosaSupportDaemon();
+ if($o->connect() && class_available("DaemonEvent_wakeup")){
+ $evt = new DaemonEvent_wakeup($this->config);
+ $evt->add_targets(array($this->mac));
+ $o->append($evt);
+ }
+ }
+ }
+
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Generic"),
+ "plDescription" => _("OPSI generic"),
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 1,
+ "plSection" => array("administration"),
+ "plCategory" => array("opsi" => array("description" => _("Opsi"))),
+
+ "plProvidedAcls"=> array(
+ "hostId" => _("Name"),
+ "mac" => _("MAC address"),
+ "description" => _("Description"),
+ "note" => _("Note"),
+ "netbootProduct" => _("Netboot product"),
+ "localProduct" => _("Local product"),
+ "triggerAction" => _("Action"))
+ ));
}
- }
-
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Generic"),
- "plDescription" => _("OPSI generic"),
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 1,
- "plSection" => array("administration"),
- "plCategory" => array("opsi" => array("description" => _("Opsi"))),
-
- "plProvidedAcls"=> array(
- "hostId" => _("Name"),
- "mac" => _("MAC address"),
- "description" => _("Description"),
- "note" => _("Note"),
- "netbootProduct" => _("Netboot product"),
- "localProduct" => _("Local product"),
- "triggerAction" => _("Action"))
- ));
- }
}
diff --git a/gosa-plugins/opsi/admin/opsi/class_opsiware.inc b/gosa-plugins/opsi/admin/opsi/class_opsiware.inc
index fc9c0ee0149040f937d66deb2a3dddb0f4d259dd..f57403611bf6830593c37af44b31b6d8d0eda2b5 100644 (file)
class opsiSoftware extends opsiWare
{
- protected $type = 0;
+ protected $type = 0;
}
class opsiHardware extends opsiWare
{
- protected $type = 1;
+ protected $type = 1;
}
class opsiWare extends plugin
{
- private $opsi;
- private $hostId;
- private $init_failed = FALSE;
- private $info;
- protected $type = 0;
-
- public function __construct($config,$hostId)
- {
- $this->config = $config;
- $this->opsi = new opsi($config);
- $this->hostId = preg_replace("/^opsi:=([^,]*),.*$/","\\1",$hostId);
- $this->init();
- }
-
- private function init()
- {
- if($this->type == 0){
- $this->info = $this->opsi->get_client_hardware($this->hostId);
- $err = $this->opsi->is_error();
- }else{
- $this->info = $this->opsi->get_client_software($this->hostId);
- $err = $this->opsi->is_error();
+ private $opsi;
+ private $hostId;
+ private $init_failed = FALSE;
+ private $info;
+ protected $type = 0;
+
+ public function __construct($config,$hostId)
+ {
+ $this->config = $config;
+ $this->opsi = new opsi($config);
+ $this->hostId = preg_replace("/^opsi:=([^,]*),.*$/","\\1",$hostId);
+ $this->init();
+ }
+
+ private function init()
+ {
+ if($this->type == 0){
+ $this->info = $this->opsi->get_client_hardware($this->hostId);
+ $err = $this->opsi->is_error();
+ }else{
+ $this->info = $this->opsi->get_client_software($this->hostId);
+ $err = $this->opsi->is_error();
+ }
+ $this->init_failed = $err;
}
- $this->init_failed = $err;
- }
- public function execute()
- {
- plugin::execute();
- if(isset($_POST['reinit']) && $this->init_failed){
- $this->init();
+ public function execute()
+ {
+ plugin::execute();
+ if(isset($_POST['reinit']) && $this->init_failed){
+ $this->init();
+ }
+ $smarty = get_smarty();
+ $smarty->assign("init_failed",$this->init_failed);
+ if($this->init_failed){
+ $smarty->assign("type", $this->type);
+ $smarty->assign("message",$this->opsi->get_error());
+ return($smarty->fetch(get_template_path("opsiware.tpl",TRUE,dirname(__FILE__))));
+ }
+ $smarty->assign("type", $this->type);
+ $smarty->assign("info", $this->info);
+ return($smarty->fetch(get_template_path("opsiware.tpl",TRUE,dirname(__FILE__))));
}
- $smarty = get_smarty();
- $smarty->assign("init_failed",$this->init_failed);
- if($this->init_failed){
- $smarty->assign("type", $this->type);
- $smarty->assign("message",$this->opsi->get_error());
- return($smarty->fetch(get_template_path("opsiware.tpl",TRUE,dirname(__FILE__))));
- }
- $smarty->assign("type", $this->type);
- $smarty->assign("info", $this->info);
- return($smarty->fetch(get_template_path("opsiware.tpl",TRUE,dirname(__FILE__))));
- }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>