config = $config; $this->data = $license; $this->si = new opsiLicenceHandler($this->config); $this->opsiHosts = $hosts; // Detect account state. if(count($this->data) == 0){ $this->initially_was_account = FALSE; }else{ $this->initially_was_account = TRUE; } $this->is_account = TRUE; // Extract pool name out of the fake dn. $this->init(); } function init() { $this->boundToHost = array('0'=>""); $this->usedByHost = array('0'=>""); $this->licenseKey = array('0'=>""); if($this->initially_was_account){ foreach($this->attributes as $attr){ $this->$attr = $this->data[$attr]; } } $this->orig_cn = $this->cn; $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("licenseModels",array( "RETAIL" => _("Retail"), "OEM"=>_("OEM"), "VOLUME" => _("Volume"), "CONCURRENT" => _("Concurrent"))); $smarty->assign("init_successfull", $this->init_successfull); $smarty->assign("initially_was_account", $this->initially_was_account); $smarty->assign("hosts", $this->getHosts()); $smarty->assign("notUsedHosts", array_diff($this->getHosts(), $this->usedByHost)); $smarty->assign("boundToHost", $this->boundToHost[0]); $smarty->assign("licenseKey", $this->licenseKey[0]); return($smarty->fetch(get_template_path('licenseGeneric.tpl',TRUE,dirname(__FILE__)))); } function getHosts() { $ret = array(); foreach($this->opsiHosts as $host){ $cn = $host['NAME'][0]['VALUE']; $ret[$cn] = $cn; } return($ret); } /* Save HTML inputs */ function save_object() { if(isset($_POST['opsiLicensesPosted'])){ plugin::save_object(); // Force licenseKey to be of type array. $this->licenseKey = array($this->licenseKey); // BoundToHost maybe multiple too, later. $this->boundToHost = array($this->boundToHost); if($this->initially_was_account){ $this->cn = $this->orig_cn; } } } /* 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() { echo "missing remove."; # $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() { $data = array(); foreach($this->attributes as $target){ $data[$target] = $this->$target; } return($data); } 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: ?>