From fa4fd578c045bc12db9483a63a50f8f1e43dc014 Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 21 Sep 2009 13:13:09 +0000 Subject: [PATCH] Use american spelling licen(c|s)es git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14301 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../opsiLicences/class_licenceGeneric.inc | 2 +- .../opsiLicences/class_opsiLicenceHandler.inc | 138 +++++ .../admin/opsiLicences/class_opsiLicences.inc | 470 +----------------- gosa-plugins/opsi/admin/opsiLicences/main.inc | 20 +- 4 files changed, 163 insertions(+), 467 deletions(-) create mode 100644 gosa-plugins/opsi/admin/opsiLicences/class_opsiLicenceHandler.inc diff --git a/gosa-plugins/opsi/admin/opsiLicences/class_licenceGeneric.inc b/gosa-plugins/opsi/admin/opsiLicences/class_licenceGeneric.inc index 61d47eea2..b7b7cbd20 100644 --- a/gosa-plugins/opsi/admin/opsiLicences/class_licenceGeneric.inc +++ b/gosa-plugins/opsi/admin/opsiLicences/class_licenceGeneric.inc @@ -3,7 +3,7 @@ * This code is part of GOsa (http://www.gosa-project.org) * Copyright (C) 2003-2008 GONICUS GmbH * -* ID: $$Id: class_roleManagement.inc 13520 2009-03-09 14:54:13Z hickert $$ +* ID: $$Id: class_opsiLicenses.inc 13520 2009-03-09 14:54:13Z hickert $$ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/gosa-plugins/opsi/admin/opsiLicences/class_opsiLicenceHandler.inc b/gosa-plugins/opsi/admin/opsiLicences/class_opsiLicenceHandler.inc new file mode 100644 index 000000000..b8ce0afd2 --- /dev/null +++ b/gosa-plugins/opsi/admin/opsiLicences/class_opsiLicenceHandler.inc @@ -0,0 +1,138 @@ +opsi_getLicensePools_listOfHashes". + "GOSA". + "GOSA"; + $res = $this->_send($data, TRUE); + + } + + + /* @brief Create a license pool at Opsi server. + * @param licensePoolId The name of the pool (optional). + * @param description The description of the pool (optional). + * @param productIds A list of assigned porducts of the pool (optional). + * @param windowsSoftwareIds A list of windows software IDs associated to the pool (optional). + */ + function opsi_createLicensePool() + { + + } + + /* + * @brief + * Delete licnese pool by license pool ID. + * A pool can only be deleted if there are no software licenses bound to the pool. + * The fixed parameter deleteLicenses=True specifies that + * all software licenses bound to the pool are being deleted. + * @param licensePoolId The name of the pool. + */ + function opsi_deleteLicensePool() + { + + } + + + /* + * @brief + * Create a license contract, create a software + * license and add the software license to the license pool + * @param licensePoolId The name of the pool the license should be assigned. + * @param licenseKey The license key. + * @param partner Name of the license partner (optional). + * @param conclusionDate Date of conclusion of license contract (optional) + * @param notificationDate Date of notification that license is running out soon (optional). + * @param notes This is the place for some notes (optional) + * @param softwareLicenseId Identificator of a license (optional). + * @param licenseTyp Typ of a licnese, either "OEM", "VOLUME" or "RETAIL" (optional). + * @param maxInstallations The number of clients use this license (optional). + * @param boundToHost The name of the client the license is bound to (optional). + * @param expirationDate The date when the license is running down (optional). + */ + function opsi_createLicense() + { + + } + + + /* + * @brief Assign a software license to a host + * @param hostid Something like client_1.intranet.mydomain.de + * @param licensePoolId The name of the pool. + */ + function opsi_assignSoftwareLicenseToHost() + { + + } + + + /* + * @brief Unassign a software license from a host. + * @param hostid Something like client_1.intranet.mydomain.de + * @param licensePoolId The name of the pool. + */ + function opsi_unassignSoftwareLicenseFromHost() + {} + + + /* + * @brief Unassign all software licenses from a host + * @param hostid Something like client_1.intranet.mydomain.de + */ + function opsi_unassignAllSoftwareLicensesFromHost() + {} + + + /* + * @brief Returns expirationDate, boundToHost, maxInstallation, licenseTyp, licensePoolIds and licenseKeys for a given softwareLicense ID. + * @param softwareLicenseId Identificator of a license. + */ + function opsi_getSoftwareLicense_hash() + {} + + + /* + * @brief Return productIds, windowsSoftwareIds and description for a given licensePoolId + * @param licensePoolId The name of the pool. + */ + function opsi_getLicensePool_hash() + {} + + + /* + * @brief Returns softwareLicenseId, notes, licenseKey, hostId and licensePoolId for optional given licensePoolId and hostId + * @param hostid Something like client_1.intranet.mydomain.de (optional). + * @param licensePoolId The name of the pool (optional). + */ + function opsi_getSoftwareLicenseUsages_listOfHashes() + {} + + + /* + * @brief Return licensePoolId, description, productIds and windowsSoftwareIds for all found license pools. + */ + function opsi_getLicensePools_listOfHashes() + {} + + + /* @brief + * Returns the assigned licensePoolId and licenses, + * how often the product is installed and at which host + * and the number of max and remaining installations for a given OPSI product. + * @param productId Identificator of an OPSI product. + */ + function opsi_getLicenseInformationForProduct() + {} + + + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/opsi/admin/opsiLicences/class_opsiLicences.inc b/gosa-plugins/opsi/admin/opsiLicences/class_opsiLicences.inc index 2ad9c2ec0..e210b3c37 100644 --- a/gosa-plugins/opsi/admin/opsiLicences/class_opsiLicences.inc +++ b/gosa-plugins/opsi/admin/opsiLicences/class_opsiLicences.inc @@ -3,7 +3,7 @@ * This code is part of GOsa (http://www.gosa-project.org) * Copyright (C) 2003-2008 GONICUS GmbH * -* ID: $$Id: class_roleManagement.inc 13520 2009-03-09 14:54:13Z hickert $$ +* ID: $$Id: class_opsiLicenses.inc 13520 2009-03-09 14:54:13Z hickert $$ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,469 +20,27 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -class opsiLicences extends plugin +class opsiLicenses extends management { - /* Definitions */ - var $plHeadline= "Roles"; - var $plDescription= "Manage roles"; - - // Copy and paste handler - var $CopyPasteHandler = NULL; - - // The headpage list handler. - var $DivListRoles = NULL; - - // A list of currently visible roles - var $roles = array(); - - // A list of currently edited/removed/aso roles. - var $dns = array(); - - // Permission modules to use. - var $acl_module = array("roles"); - - // Internal: Is truw while objects are pasted. - var $start_pasting_copied_objects = FALSE; - - - // Construct and initialize the plugin - function __construct (&$config, $dn= NULL) - { - // Include config object - $this->config= &$config; - $this->ui= get_userinfo(); - - // Copy & Paste enabled ? - if ($this->config->get_cfg_value("copyPaste") == "true"){ - $this->CopyPasteHandler = new CopyPasteHandler($this->config); - } - - // Initialize the corresponding list class. - $this->DivListRoles = new divListRole($this->config,$this); - } - - + var $plHeadline= "Opsi"; + var $plDescription= "Opsi licenses"; + + var $ignore_account = TRUE; + function execute() { - // Call parent execute - plugin::execute(); - - // Variables to restore after 'entry locked' warning was displayed - session::set('LOCK_VARS_TO_USE',array('/^copy/','/^cut/','/^role_/','/^act/', - '/^id/','/^menu_action/','/^item/')); - - $smarty = get_smarty(); - - /*************** - * Handle _POST/_GET variables - ***************/ + $this->ignore_account = TRUE; + $si = new opsiLicenceHandler(); + $res = $si->listLicenses(); + print_a($res); - // Get entry related posts - $s_action = ""; - $s_entry = ""; - foreach($_POST as $name => $value){ - if(preg_match("/^cut_/",$name)){ - $s_action = "cut"; - $s_entry = preg_replace("/^cut_([0-9]*)_.*$/","\\1",$name); - break; - } - if(preg_match("/^copy_/",$name)){ - $s_action = "copy"; - $s_entry = preg_replace("/^copy_([0-9]*)_.*$/","\\1",$name); - break; - } - if(preg_match("/^role_edit_/",$name)){ - $s_action = "edit"; - $s_entry = preg_replace("/^role_edit_([0-9]*)_.*$/","\\1",$name); - break; - } - if(preg_match("/^role_del_/",$name)){ - $s_action = "remove"; - $s_entry = preg_replace("/^role_del_([0-9]*)_.*$/","\\1",$name); - break; - } - } - - if(isset($_GET['act']) && $_GET['act'] == "edit_entry" && isset($_GET['id'])){ - $id = $_GET['id']; - if(isset($this->roles[$id])){ - $s_action = "edit"; - $s_entry = $id; - } - } - - // Get menu related posts - if(isset($_POST['menu_action'])) { - if($_POST['menu_action'] == "editPaste"){ - $s_action = "editPaste"; - }elseif($_POST['menu_action'] == "role_new"){ - $s_action = "new"; - }elseif($_POST['menu_action'] == "remove_multiple_roles"){ - $s_action = "remove_multiple"; - } - } - - /*************** - * Copy & Paste handling - ***************/ - - /* Display the copy & paste dialog, if it is currently open */ - $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry); - if($ret){ - return($ret); - } - - - /*************** - * Remove handling - ***************/ - - if($s_action == "remove_multiple" || $s_action == "remove"){ - - if($s_action == "remove_multiple"){ - $ids = $this->list_get_selected_items(); - }else{ - $ids = array($s_entry); - } - - if(count($ids)){ - $this->dns = array(); - $disallowed = array(); - foreach($ids as $id){ - $dn = $this->roles[$id]['dn']; - $acl = $this->ui->get_permissions($dn, "roles/roleGeneric"); - if(preg_match("/d/",$acl)){ - $this->dns[$id] = $dn; - }else{ - $disallowed[] = $dn; - } - } - - if(count($disallowed)){ - msg_dialog::display(_("Permission"),msgPool::permDelete($disallowed),INFO_DIALOG); - } - - - if(count($this->dns)){ - if ($user= get_multiple_locks($this->dns)){ - return(gen_locked_message($user,$this->dns)); - } - $dns_names = array(); - foreach($this->dns as $dn){ - $dns_names[] = LDAP::fix($dn); - } - - /* Lock the current entry, so nobody will edit it during deletion */ - add_lock ($this->dns, $this->ui->dn); - - $smarty->assign("info", msgPool::deleteInfo($dns_names,_("Role"))); - $smarty->assign("multiple", true); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); - } - } + if($si->is_error()){ + echo $si->get_error(); } - - /* Remove lock */ - if(isset($_POST['delete_multiple_roles_cancel'])){ - - /* Remove lock file after successfull deletion */ - $this->remove_lock(); - $this->dns = array(); - } - - - /* Confirmation for deletion has been passed. Users should be deleted. */ - if (isset($_POST['delete_multiple_roles_confirm'])){ - - /* Remove user by user and check acls before removeing them */ - foreach($this->dns as $key => $dn){ - - $acl = $this->ui->get_permissions($dn, "roles/roleGeneric"); - if (preg_match('/d/', $acl)){ - - /* Delete request is permitted, perform LDAP action */ - $this->dialog= new roletabs($this->config,$this->config->data['TABS']['ROLETABS'], $dn); - $this->dialog->delete(); - $this->dialog= NULL; - } else { - - /* Normally this shouldn't be reached, send some extra - logs to notify the administrator */ - msg_dialog::display(_("Permission error"), msgPool::permDelete(), INFO_DIALOG); - new log("security","roles/".get_class($this),$dn,array(),"Tried to trick deletion."); - } - } - - /* Remove lock file after successfull deletion */ - $this->remove_lock(); - $this->dns = array(); - } - - - /*************** - * New handling - ***************/ - - if($s_action == "new" && !$this->dialog instanceOf tabs){ - $this->dialog = new roletabs($this->config, $this->config->data['TABS']['ROLETABS'], "new"); - $this->dialog->set_acl_base($this->DivListRoles->selectedBase); - } - - /*************** - * Edit handling - ***************/ - - if($s_action == "edit" && !$this->dialog instanceOf tabs){ - if(!isset($this->roles[$s_entry])){ - trigger_error("Unknown entry!"); - }else{ - - $entry = $this->roles[$s_entry]; - $this->dn = $entry['dn']; - - /* Check locking, save current plugin in 'back_plugin', so - the dialog knows where to return. */ - if (($user= get_lock($this->dn)) != ""){ - return(gen_locked_message ($user, $this->dn,TRUE)); - } - - /* Lock the current entry, so everyone will get the above dialog */ - add_lock ($this->dn, $this->ui->dn); - - /* Open the dialog */ - $this->dialog = new roletabs($this->config, $this->config->data['TABS']['ROLETABS'], - $entry['dn'], "roles"); - $this->dialog->set_acl_base($this->dn); - set_object_info($this->dn); - } - } - - - /*************** - * Dialog handling - ***************/ - - if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && $this->dialog instanceOf tabs){ - $this->dialog->save_object(); - $msgs = $this->dialog->check(); - if(count($msgs)){ - msg_dialog::displayChecks($msgs); - }else{ - $this->dialog->save(); - if (!isset($_POST['edit_apply'])){ - $this->remove_lock(); - $this->dialog= NULL; - set_object_info(); - }else{ - $this->dialog->re_init(); - } - } - } - - if (isset($_POST['edit_cancel']) && $this->dialog instanceOf tabs){ - $this->remove_lock(); - $this->dialog= NULL; - set_object_info(); - } - - if($this->dialog instanceOf tabs){ - $display= $this->dialog->execute(); - - $dialog_opened = ($this->dialog->by_object[$this->dialog->current]->dialog instanceOf plugin); - - if(!$dialog_opened){ - if($this->dialog->read_only == TRUE){ - $display.= "

- -

"; - }else{ - - $display.= "

\n"; - $display.= "\n"; - $display.= " \n"; - if ($this->dn != "new"){ - $display.= "\n"; - $display.= " \n"; - } - $display.= "\n"; - $display.= "

"; - } - } - return ($display); - } - - - /*************** - * List handling - ***************/ - - // Check if there is a snapshot dialog open - $base = $this->DivListRoles->selectedBase; - if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){ - return($str); - } - - // Display dialog with group list - $this->DivListRoles->parent = $this; - $this->DivListRoles->execute(); - - // Add departments if subsearch is disabled - if(!$this->DivListRoles->SubSearch){ - $this->DivListRoles->AddDepartments($this->DivListRoles->selectedBase,3,1); - } - $this->reload (); - $this->DivListRoles->setEntries($this->roles); - return($this->DivListRoles->Draw()); - } - - - // Refreshes the list of known role objects. - function reload() - { - - // Get current ldap base and filter settings. - $base = $this->DivListRoles->selectedBase; - $Regex = $this->DivListRoles->Regex; - - // Search and fetch all matching role objects. - $this->roles = array(); - $ldap = $this->config->get_ldap_link(); - $filter= "(&(objectClass=organizationalRole)(cn=$Regex))"; - $attrs = array("cn","description","objectClass"); - - if($this->DivListRoles->SubSearch){ - $res= get_sub_list($filter, "roles",array(), $base, $attrs, GL_SIZELIMIT | GL_SUBSEARCH); - }else{ - $res= get_sub_list($filter, "roles",get_ou('roleRDN'), get_ou('roleRDN').$base, $attrs, GL_SIZELIMIT ); - } - - $tmp = array(); - foreach($res as $attrs){ - $tmp[$attrs['cn'][0].$attrs['dn']] = $attrs; - } - - uksort($tmp, 'strnatcasecmp'); - $this->roles = array_values($tmp); - } - - - /* \brief Returns a list of selected entry ids. - * E.g. remove multiple entries. - * @return Array A list of entry IDs - */ - function list_get_selected_items() - { - $ids = array(); - foreach($_POST as $name => $value){ - if(preg_match("/^item_selected_[0-9]*$/",$name)){ - $id = preg_replace("/^item_selected_/","",$name); - $ids[$id] = $id; - } - } - return($ids); - } - - - function remove_lock() - { - if (isset($this->dialog->dn)){ - del_lock ($this->dialog->dn); - }elseif(isset($this->dn) && !empty($this->dn) && $this->dn != "new"){ - del_lock($this->dn); - } - if(isset($this->dns) && is_array($this->dns) && count($this->dns)){ - del_lock($this->dns); - } } - - /* Return departments, that will be included within snapshot detection - */ - function get_used_snapshot_bases() - { - return(array(get_ou('roleRDN').$this->DivListRoles->selectedBase)); - } - - - function copyPasteHandling_from_queue($s_action,$s_entry) - { - /* Check if Copy & Paste is disabled */ - if(!is_object($this->CopyPasteHandler)){ - return(""); - } - - $ui = get_userinfo(); - - /* Add a single entry to queue */ - if($s_action == "cut" || $s_action == "copy"){ - - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - $dn = $this->roles[$s_entry]['dn']; - if($s_action == "copy" && $ui->is_copyable($dn,"roles","roleGeneric")){ - $this->CopyPasteHandler->add_to_queue($dn,$s_action,"roletabs","ROLETABS","roles"); - } - if($s_action == "cut" && $ui->is_cutable($dn,"roles","roleGeneric")){ - $this->CopyPasteHandler->add_to_queue($dn,$s_action,"roletabs","ROLETABS","roles"); - } - } - - /* Add entries to queue */ - if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ - - /* Cleanup object queue */ - $this->CopyPasteHandler->cleanup_queue(); - - /* Add new entries to CP queue */ - foreach($this->list_get_selected_items() as $id){ - $dn = $this->roles[$id]['dn']; - - if($s_action == "copy_multiple" && $ui->is_copyable($dn,"roles","roleGeneric")){ - $this->CopyPasteHandler->add_to_queue($dn,"copy","roletabs","ROLETABS","roles"); - } - if($s_action == "cut_multiple" && $ui->is_cutable($dn,"roles","roleGeneric")){ - $this->CopyPasteHandler->add_to_queue($dn,"cut","roletabs","ROLETABS","roles"); - } - } - } - - /* Start pasting entries */ - if($s_action == "editPaste"){ - $this->start_pasting_copied_objects = TRUE; - } - - /* Return C&P dialog */ - if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ - - /* Get dialog */ - $this->CopyPasteHandler->SetVar("base",$this->DivListRoles->selectedBase); - $data = $this->CopyPasteHandler->execute(); - - /* Return dialog data */ - if(!empty($data)){ - return($data); - } - } - /* Automatically disable status for pasting */ - if(!$this->CopyPasteHandler->entries_queued()){ - $this->start_pasting_copied_objects = FALSE; - } - return(""); - } - - - function save_object() - { - $this->DivListRoles->save_object(); - if(is_object($this->CopyPasteHandler)){ - $this->CopyPasteHandler->save_object(); - } - } + function remove_lock() {} } - // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?> diff --git a/gosa-plugins/opsi/admin/opsiLicences/main.inc b/gosa-plugins/opsi/admin/opsiLicences/main.inc index 90906cc07..03a0f1c5c 100644 --- a/gosa-plugins/opsi/admin/opsiLicences/main.inc +++ b/gosa-plugins/opsi/admin/opsiLicences/main.inc @@ -23,8 +23,8 @@ // Remove locks created by this plugin if ($remove_lock){ - if(session::is_set('roleManagement')){ - $macl = session::get('roleManagement'); + if(session::is_set('opsiLicenses')){ + $macl = session::get('opsiLicenses'); $macl->remove_lock(); } } @@ -32,20 +32,20 @@ if ($remove_lock){ /* Remove this plugin from session */ if ( $cleanup ){ - $macl = session::get('roleManagement'); + $macl = session::get('opsiLicenses'); $macl->remove_lock(); - session::un_set('roleManagement'); + session::un_set('opsiLicenses'); }else{ /* Create object object on demand */ - if (!session::is_set('roleManagement')){ - session::set('roleManagement',new roleManagement($config)); + if (!session::is_set('opsiLicenses')){ + session::set('opsiLicenses',new opsiLicenses($config)); } - $roleManagement = session::get('roleManagement'); + $opsiLicenses = session::get('opsiLicenses'); /* Execute formular */ - $roleManagement->save_object(); - $output= $roleManagement->execute (); + $opsiLicenses->save_object(); + $output= $opsiLicenses->execute (); /* Page header*/ if (get_object_info() != ""){ @@ -60,7 +60,7 @@ if ( $cleanup ){ $display.= $output; /* Store changes in session */ - session::set('roleManagement',$roleManagement); + session::set('opsiLicenses',$opsiLicenses); } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -- 2.30.2