From: hickert Date: Thu, 24 Sep 2009 07:36:31 +0000 (+0000) Subject: renamed again X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=80203424e675d237af75cd220d5d4e51c1853ce2;p=gosa.git renamed again git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14336 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_licensePoolGeneric.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_licensePoolGeneric.inc new file mode 100644 index 000000000..e7ff0ae7b --- /dev/null +++ b/gosa-plugins/opsi/admin/opsiLicenses/class_licensePoolGeneric.inc @@ -0,0 +1,271 @@ +config = $config; + $this->dn = $this->orig_dn = $dn; + + $this->si = new opsiLicenceHandler($this->config); + + $this->is_account=TRUE; + if($this->dn == "new"){ + $this->initially_was_account = FALSE; + }else{ + $this->initially_was_account = TRUE; + $this->cn = $this->orig_cn = preg_replace("/^opsi:cn=([^,]*),.*$/","\\1",$dn); + } + + // Extract pool name out of the fake dn. + $this->init(); + } + + + function init() + { + // Load local Boot Products + $res = $this->si->get_local_products(); + if($this->si->is_error()){ + $this->init_successfull = FALSE; + return(FALSE); + } + $this->availableProductIds=array_keys($res); + + // Load Pool + if(!$this->initially_was_account){ + $this->init_successfull = TRUE; + }else{ + + $res = $this->si->getPool($this->cn); + if($this->si->is_error()){ + $this->init_successfull = FALSE; + return(FALSE); + }else{ + $this->data = $this->orig_data = $res; + $this->description = $this->data['description'][0]; + + // Load software IDs + $this->softwareIds = array(); + if(isset($this->data['softwareId'])){ + for($i = 0; $i < $this->data['softwareId']['count']; $i++){ + $this->softwareIds[] = $this->data['softwareId'][$i]; + } + } + + // Load product IDs + $this->productIds = array(); + if(isset($this->data['productId'])){ + for($i = 0; $i < $this->data['productId']['count']; $i++){ + $this->productIds[] = $this->data['productId'][$i]; + } + } + $this->init_successfull = TRUE; + return; + } + } + } + + + function execute() + { + // Handle initialization failures. + if(isset($_POST['retry_init'])) $this->init(); + if(!$this->init_successfull){ + $smarty = get_smarty(); + $smarty->assign("init_successfull", $this->init_successfull); + return($smarty->fetch(get_template_path('licenseGeneric.tpl',TRUE,dirname(__FILE__)))); + } + + $smarty = get_smarty(); + + // Assign ACls + $plInfo = $this->plInfo(); + foreach($plInfo['plProvidedAcls'] as $name => $desc){ + $smarty->assign("{$name}ACL",$this->getacl($name)); + } + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + + $smarty->assign("init_successfull", $this->init_successfull); + $smarty->assign("availableProductIds", array_diff( $this->availableProductIds, $this->productIds)); + $smarty->assign("productIds", $this->productIds); + $smarty->assign("softwareIds", $this->softwareIds); + $smarty->assign("licenses", $this->getLicenseList()); + $smarty->assign("initially_was_account", $this->initially_was_account); + return($smarty->fetch(get_template_path('licenseGeneric.tpl',TRUE,dirname(__FILE__)))); + } + + + function getLicenseList() + { + $list = new divSelectBox("test"); + $list->setHeight(100); + + + + return($list->DrawList()); + } + + + /* Save HTML inputs + */ + function save_object() + { + if(isset($_POST['opsiLicensesPosted'])){ + plugin::save_object(); + + // Restore license cn, to avoid creating a copy... + if($this->initially_was_account) $this->cn = $this->orig_cn; + + // We've to add prodcuts here + if(isset($_POST['availableProduct']) && isset($_POST['addProduct'])){ + $pro = get_post('availableProduct'); + if(isset($this->availableProductIds[$pro]) && !in_array($this->availableProductIds[$pro], $this->productIds)){ + $this->productIds[] =$this->availableProductIds[$pro]; + } + } + + // We've to remove products here + if(isset($_POST['productIds']) && isset($_POST['removeProduct'])){ + foreach($_POST['productIds'] as $key){ + if(isset($this->productIds[$key])){ + unset($this->productIds[$key]); + } + } + } + + // We've to add software here + if(isset($_POST['newSoftwareId']) && isset($_POST['addSoftware'])){ + $soft = trim(get_post('newSoftwareId')); + if(!empty($soft) && !in_array($soft, $this->softwareIds)){ + $this->softwareIds[] = $soft; + } + } + + // We've to remove software Ids here + if(isset($_POST['softwareIds']) && isset($_POST['removeSoftware'])){ + foreach($_POST['softwareIds'] as $key){ + if(isset($this->softwareIds[$key])){ + unset($this->softwareIds[$key]); + } + } + } + } + } + + + /* Check user input and return a list of 'invalid input' messages. + */ + function check() + { + $message = plugin::check(); + return($message); + } + + + + /* Removes the object from the opsi database + */ + function remove_from_parent() + { + $this->si->deletePool($this->orig_cn); + if($this->si->is_error()){ + msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG); + }else{ + + // Trigger remove signal + $this->handle_post_events("remove"); + } + + new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$this->si->get_error()); + } + + + /* Saves object modifications + */ + function save() + { + plugin::save(); + + // Send modify/add events + $mode = "modify"; + if($this->orig_dn == "new"){ + $mode = "add"; + } + + $this->si->createPool($this->cn, $this->description,$this->productIds,$this->softwareIds);# + if($this->si->is_error()){ + msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG); + }else{ + $this->handle_post_events($mode); + } + + // Log action + if($mode == "modify"){ + new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$this->si->get_error()); + }else{ + new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$this->si->get_error()); + } + + return 0; + } + + static function plInfo() + { + return (array( + "plShortName" => _("Generic"), + "plDescription" => _("License generic"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 1, + "plSection" => array("administration"), + "plCategory" => array("opsi"), + "plProvidedAcls"=> array( + "cn" => _("Name"), + "description" => _("Description")) + )); + } +} + + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_poolGeneric.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_poolGeneric.inc deleted file mode 100644 index e7ff0ae7b..000000000 --- a/gosa-plugins/opsi/admin/opsiLicenses/class_poolGeneric.inc +++ /dev/null @@ -1,271 +0,0 @@ -config = $config; - $this->dn = $this->orig_dn = $dn; - - $this->si = new opsiLicenceHandler($this->config); - - $this->is_account=TRUE; - if($this->dn == "new"){ - $this->initially_was_account = FALSE; - }else{ - $this->initially_was_account = TRUE; - $this->cn = $this->orig_cn = preg_replace("/^opsi:cn=([^,]*),.*$/","\\1",$dn); - } - - // Extract pool name out of the fake dn. - $this->init(); - } - - - function init() - { - // Load local Boot Products - $res = $this->si->get_local_products(); - if($this->si->is_error()){ - $this->init_successfull = FALSE; - return(FALSE); - } - $this->availableProductIds=array_keys($res); - - // Load Pool - if(!$this->initially_was_account){ - $this->init_successfull = TRUE; - }else{ - - $res = $this->si->getPool($this->cn); - if($this->si->is_error()){ - $this->init_successfull = FALSE; - return(FALSE); - }else{ - $this->data = $this->orig_data = $res; - $this->description = $this->data['description'][0]; - - // Load software IDs - $this->softwareIds = array(); - if(isset($this->data['softwareId'])){ - for($i = 0; $i < $this->data['softwareId']['count']; $i++){ - $this->softwareIds[] = $this->data['softwareId'][$i]; - } - } - - // Load product IDs - $this->productIds = array(); - if(isset($this->data['productId'])){ - for($i = 0; $i < $this->data['productId']['count']; $i++){ - $this->productIds[] = $this->data['productId'][$i]; - } - } - $this->init_successfull = TRUE; - return; - } - } - } - - - function execute() - { - // Handle initialization failures. - if(isset($_POST['retry_init'])) $this->init(); - if(!$this->init_successfull){ - $smarty = get_smarty(); - $smarty->assign("init_successfull", $this->init_successfull); - return($smarty->fetch(get_template_path('licenseGeneric.tpl',TRUE,dirname(__FILE__)))); - } - - $smarty = get_smarty(); - - // Assign ACls - $plInfo = $this->plInfo(); - foreach($plInfo['plProvidedAcls'] as $name => $desc){ - $smarty->assign("{$name}ACL",$this->getacl($name)); - } - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - - $smarty->assign("init_successfull", $this->init_successfull); - $smarty->assign("availableProductIds", array_diff( $this->availableProductIds, $this->productIds)); - $smarty->assign("productIds", $this->productIds); - $smarty->assign("softwareIds", $this->softwareIds); - $smarty->assign("licenses", $this->getLicenseList()); - $smarty->assign("initially_was_account", $this->initially_was_account); - return($smarty->fetch(get_template_path('licenseGeneric.tpl',TRUE,dirname(__FILE__)))); - } - - - function getLicenseList() - { - $list = new divSelectBox("test"); - $list->setHeight(100); - - - - return($list->DrawList()); - } - - - /* Save HTML inputs - */ - function save_object() - { - if(isset($_POST['opsiLicensesPosted'])){ - plugin::save_object(); - - // Restore license cn, to avoid creating a copy... - if($this->initially_was_account) $this->cn = $this->orig_cn; - - // We've to add prodcuts here - if(isset($_POST['availableProduct']) && isset($_POST['addProduct'])){ - $pro = get_post('availableProduct'); - if(isset($this->availableProductIds[$pro]) && !in_array($this->availableProductIds[$pro], $this->productIds)){ - $this->productIds[] =$this->availableProductIds[$pro]; - } - } - - // We've to remove products here - if(isset($_POST['productIds']) && isset($_POST['removeProduct'])){ - foreach($_POST['productIds'] as $key){ - if(isset($this->productIds[$key])){ - unset($this->productIds[$key]); - } - } - } - - // We've to add software here - if(isset($_POST['newSoftwareId']) && isset($_POST['addSoftware'])){ - $soft = trim(get_post('newSoftwareId')); - if(!empty($soft) && !in_array($soft, $this->softwareIds)){ - $this->softwareIds[] = $soft; - } - } - - // We've to remove software Ids here - if(isset($_POST['softwareIds']) && isset($_POST['removeSoftware'])){ - foreach($_POST['softwareIds'] as $key){ - if(isset($this->softwareIds[$key])){ - unset($this->softwareIds[$key]); - } - } - } - } - } - - - /* Check user input and return a list of 'invalid input' messages. - */ - function check() - { - $message = plugin::check(); - return($message); - } - - - - /* Removes the object from the opsi database - */ - function remove_from_parent() - { - $this->si->deletePool($this->orig_cn); - if($this->si->is_error()){ - msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG); - }else{ - - // Trigger remove signal - $this->handle_post_events("remove"); - } - - new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$this->si->get_error()); - } - - - /* Saves object modifications - */ - function save() - { - plugin::save(); - - // Send modify/add events - $mode = "modify"; - if($this->orig_dn == "new"){ - $mode = "add"; - } - - $this->si->createPool($this->cn, $this->description,$this->productIds,$this->softwareIds);# - if($this->si->is_error()){ - msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG); - }else{ - $this->handle_post_events($mode); - } - - // Log action - if($mode == "modify"){ - new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$this->si->get_error()); - }else{ - new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$this->si->get_error()); - } - - return 0; - } - - static function plInfo() - { - return (array( - "plShortName" => _("Generic"), - "plDescription" => _("License generic"), - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 1, - "plSection" => array("administration"), - "plCategory" => array("opsi"), - "plProvidedAcls"=> array( - "cn" => _("Name"), - "description" => _("Description")) - )); - } -} - - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?>