From: cajus
Date: Mon, 10 Dec 2007 13:12:09 +0000 (+0000)
Subject: Updated directory layout
X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=838f59fe8f774d17e0d283a78ac24dce72f81aad;p=gosa.git
Updated directory layout
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8073 594d385d-05f5-0310-b6e9-bd551577e9d8
---
diff --git a/include/class_location.inc b/include/class_location.inc
index 4d6383443..dc17ec0be 100644
--- a/include/class_location.inc
+++ b/include/class_location.inc
@@ -172,83 +172,83 @@ $class_mapping= array(
"divListGroup" => "plugins/admin/groups/class_divListGroup.inc",
"groupManagement" => "plugins/admin/groups/class_groupManagement.inc",
"appgroup" => "plugins/admin/groups/class_groupApplication.inc",
- "glpiAttachmentPool" => "plugins/admin/systems/class_glpiAttachmentPool.inc",
- "gosaLogServer" => "plugins/admin/systems/class_gosaLogServer.inc",
- "servdnseditZone" => "plugins/admin/systems/class_servDNSeditZone.inc",
- "goTerminalServer" => "plugins/admin/systems/class_goTerminalServer.inc",
- "goService" => "plugins/admin/systems/class_goService.inc",
"workstartup" => "plugins/admin/systems/class_workstationStartup.inc",
- "dhcpSharedNetwork" => "plugins/admin/systems/class_dhcpSharedNetwork.inc",
- "govirusserver" => "plugins/admin/systems/class_goVirusServer.inc",
"termtabs" => "plugins/admin/systems/tabs_terminal.inc",
"phonetabs" => "plugins/admin/systems/tabs_phone.inc",
"servtabs" => "plugins/admin/systems/tabs_server.inc",
- "dhcpAdvanced" => "plugins/admin/systems/class_dhcpAdvanced.inc",
- "servdns" => "plugins/admin/systems/class_servDNS.inc",
"workgeneric" => "plugins/admin/systems/class_workstationGeneric.inc",
- "gospamserver" => "plugins/admin/systems/class_goSpamServer.inc",
- "dhcpNetwork" => "plugins/admin/systems/class_dhcpNetwork.inc",
- "dhcpPool" => "plugins/admin/systems/class_dhcpPool.inc",
"selectUserToPrinterDialog" => "plugins/admin/systems/class_selectUserToPrinterDialog.inc",
"wintabs" => "plugins/admin/systems/tabs_winstation.inc",
- "goCupsServer" => "plugins/admin/systems/class_goCupsServer.inc",
"phoneGeneric" => "plugins/admin/systems/class_phoneGeneric.inc",
- "glpiPrinterAccount" => "plugins/admin/systems/class_glpiPrinterAccount.inc",
- "goMailServer" => "plugins/admin/systems/class_goMailServer.inc",
"ArpNewDevice" => "plugins/admin/systems/class_ArpNewDevice.inc",
- "dhcpSubnet" => "plugins/admin/systems/class_dhcpSubnet.inc",
- "goLogDBServer" => "plugins/admin/systems/class_goLogDBServer.inc",
+ "gosaLogServer" => "plugins/admin/systems/services/log/class_gosaLogServer.inc",
+ "servdnseditZone" => "plugins/admin/systems/services/dns/class_servDNSeditZone.inc",
+ "servdns" => "plugins/admin/systems/services/dns/class_servDNS.inc",
+ "termDNS" => "plugins/admin/systems/services/dns/class_termDNS.inc",
+ "servDNSeditZoneEntries" => "plugins/admin/systems/services/dns/class_servDNSeditZoneEntries.inc",
+ "glpiAttachmentPool" => "plugins/admin/systems/services/glpi/class_glpiAttachmentPool.inc",
+ "glpiPrinterAccount" => "plugins/admin/systems/services/glpi/class_glpiPrinterAccount.inc",
+ "glpiDeviceManagement" => "plugins/admin/systems/services/glpi/class_glpiDeviceManagement.inc",
+ "glpiSelectUser" => "plugins/admin/systems/services/glpi/class_glpiSelectUser.inc",
+ "goGlpiServer" => "plugins/admin/systems/services/glpi/class_goGlpiServer.inc",
+ "glpiPrinterCartridges" => "plugins/admin/systems/services/glpi/class_glpiPrinterCartridges.inc",
+ "glpiManufacturer" => "plugins/admin/systems/services/glpi/class_glpiManufacturer.inc",
+ "glpiAccount" => "plugins/admin/systems/services/glpi/class_glpiAccount.inc",
+ "glpiPrinterCartridgesEdit" => "plugins/admin/systems/services/glpi/class_glpiPrinterCartridgesEdit.inc",
+ "goLdapServer" => "plugins/admin/systems/services/ldap/class_goLdapServer.inc",
+ "servnfs" => "plugins/admin/systems/services/nfs/class_servNfs.inc",
+ "goService" => "plugins/admin/systems/services/class_goService.inc",
+ "goMailServer" => "plugins/admin/systems/services/mail/class_goMailServer.inc",
+ "goFonServer" => "plugins/admin/systems/services/gofon/class_goFonServer.inc",
+ "gospamserver" => "plugins/admin/systems/services/spam/class_goSpamServer.inc",
+ "goSpamServerRule" => "plugins/admin/systems/services/spam/class_goSpamServerRule.inc",
+ "goImapServer" => "plugins/admin/systems/services/imap/class_goImapServer.inc",
+ "goNtpServer" => "plugins/admin/systems/services/ntp/class_goNtpServer.inc",
+ "goShareServer" => "plugins/admin/systems/services/shares/class_goShareServer.inc",
+ "goFaxServer" => "plugins/admin/systems/services/gofax/class_goFaxServer.inc",
+ "govirusserver" => "plugins/admin/systems/services/virus/class_goVirusServer.inc",
+ "dhcpSharedNetwork" => "plugins/admin/systems/services/dhcp/class_dhcpSharedNetwork.inc",
+ "dhcpAdvanced" => "plugins/admin/systems/services/dhcp/class_dhcpAdvanced.inc",
+ "dhcpNetwork" => "plugins/admin/systems/services/dhcp/class_dhcpNetwork.inc",
+ "dhcpPool" => "plugins/admin/systems/services/dhcp/class_dhcpPool.inc",
+ "dhcpSubnet" => "plugins/admin/systems/services/dhcp/class_dhcpSubnet.inc",
+ "dhcpGroup" => "plugins/admin/systems/services/dhcp/class_dhcpGroup.inc",
+ "dhcpHost" => "plugins/admin/systems/services/dhcp/class_dhcpHost.inc",
+ "dhcpNewSectionDialog" => "plugins/admin/systems/services/dhcp/class_dhcpNewSectionDialog.inc",
+ "dhcpService" => "plugins/admin/systems/services/dhcp/class_dhcpService.inc",
+ "servdhcp" => "plugins/admin/systems/services/dhcp/class_servDHCP.inc",
+ "ServiceAddDialog" => "plugins/admin/systems/services/class_ServiceAddDialog.inc",
+ "goLogDBServer" => "plugins/admin/systems/services/syslog/class_goLogDBServer.inc",
+ "goSyslogServer" => "plugins/admin/systems/services/syslog/class_goSyslogServer.inc",
+ "servkolab" => "plugins/admin/systems/services/kolab/class_servKolab.inc",
+ "goCupsServer" => "plugins/admin/systems/services/cups/class_goCupsServer.inc",
+ "goTerminalServer" => "plugins/admin/systems/services/terminal/class_goTerminalServer.inc",
+ "goKioskService" => "plugins/admin/systems/services/kiosk/class_goKioskService.inc",
+ "servRepositorySetup" => "plugins/admin/systems/services/repository/class_servRepositorySetup.inc",
+ "servrepository" => "plugins/admin/systems/services/repository/class_servRepository.inc",
+ "goKrbServer" => "plugins/admin/systems/services/kerberos/class_goKrbServer.inc",
"baseSelectDialog" => "plugins/admin/systems/class_baseSelectDialog.inc",
- "dhcpGroup" => "plugins/admin/systems/class_dhcpGroup.inc",
- "glpiDeviceManagement" => "plugins/admin/systems/class_glpiDeviceManagement.inc",
"systems" => "plugins/admin/systems/class_systemManagement.inc",
- "goNtpServer" => "plugins/admin/systems/class_goNtpServer.inc",
- "goKrbServer" => "plugins/admin/systems/class_goKrbServer.inc",
- "ServiceAddDialog" => "plugins/admin/systems/class_ServiceAddDialog.inc",
- "goSyslogServer" => "plugins/admin/systems/class_goSyslogServer.inc",
- "servRepositorySetup" => "plugins/admin/systems/class_servRepositorySetup.inc",
- "goLdapServer" => "plugins/admin/systems/class_goLdapServer.inc",
- "dhcpHost" => "plugins/admin/systems/class_dhcpHost.inc",
"divListSystem" => "plugins/admin/systems/class_divListSystem.inc",
"servgeneric" => "plugins/admin/systems/class_servGeneric.inc",
"worktabs" => "plugins/admin/systems/tabs_workstation.inc",
- "goKioskService" => "plugins/admin/systems/class_goKioskService.inc",
"termservice" => "plugins/admin/systems/class_terminalService.inc",
"divListSystemService" => "plugins/admin/systems/class_divListSystemService.inc",
- "goShareServer" => "plugins/admin/systems/class_goShareServer.inc",
"componentGeneric" => "plugins/admin/systems/class_componentGeneric.inc",
- "goImapServer" => "plugins/admin/systems/class_goImapServer.inc",
- "glpiSelectUser" => "plugins/admin/systems/class_glpiSelectUser.inc",
"workservice" => "plugins/admin/systems/class_workstationService.inc",
"termgeneric" => "plugins/admin/systems/class_terminalGeneric.inc",
- "servrepository" => "plugins/admin/systems/class_servRepository.inc",
"printtabs" => "plugins/admin/systems/tabs_printers.inc",
"ArpNewDeviceTabs" => "plugins/admin/systems/tabs_arpnewdevice.inc",
- "printerPPDDialog" => "plugins/admin/systems/class_printerPPDDialog.inc",
- "dhcpNewSectionDialog" => "plugins/admin/systems/class_dhcpNewSectionDialog.inc",
"componenttabs" => "plugins/admin/systems/tabs_component.inc",
- "goGlpiServer" => "plugins/admin/systems/class_goGlpiServer.inc",
- "servkolab" => "plugins/admin/systems/class_servKolab.inc",
"divListRepository" => "plugins/admin/systems/class_divListRepositories.inc",
- "goFonServer" => "plugins/admin/systems/class_goFonServer.inc",
- "servnfs" => "plugins/admin/systems/class_servNfs.inc",
+ "printerPPDDialog" => "plugins/admin/systems/ppd/class_printerPPDDialog.inc",
+ "printerPPDSelectionDialog" => "plugins/admin/systems/ppd/class_printerPPDSelectionDialog.inc",
"wingeneric" => "plugins/admin/systems/class_winGeneric.inc",
- "glpiPrinterCartridges" => "plugins/admin/systems/class_glpiPrinterCartridges.inc",
- "glpiManufacturer" => "plugins/admin/systems/class_glpiManufacturer.inc",
- "termDNS" => "plugins/admin/systems/class_termDNS.inc",
"termstartup" => "plugins/admin/systems/class_terminalStartup.inc",
"terminfo" => "plugins/admin/systems/class_terminalInfo.inc",
"printgeneric" => "plugins/admin/systems/class_printGeneric.inc",
- "goFaxServer" => "plugins/admin/systems/class_goFaxServer.inc",
- "printerPPDSelectionDialog" => "plugins/admin/systems/class_printerPPDSelectionDialog.inc",
- "dhcpService" => "plugins/admin/systems/class_dhcpService.inc",
- "servdhcp" => "plugins/admin/systems/class_servDHCP.inc",
- "glpiAccount" => "plugins/admin/systems/class_glpiAccount.inc",
"ServerService" => "plugins/admin/systems/class_serverService.inc",
"SelectDeviceType" => "plugins/admin/systems/class_SelectDeviceType.inc",
- "glpiPrinterCartridgesEdit" => "plugins/admin/systems/class_glpiPrinterCartridgesEdit.inc",
- "servDNSeditZoneEntries" => "plugins/admin/systems/class_servDNSeditZoneEntries.inc",
- "goSpamServerRule" => "plugins/admin/systems/class_goSpamServerRule.inc",
"aclroletab" => "plugins/admin/acl/tabs_acl_role.inc",
"acltab" => "plugins/admin/acl/tabs_acl.inc",
"aclManagement" => "plugins/admin/acl/class_aclManagement.inc",
diff --git a/plugins/admin/systems/ServiceAddDialog.tpl b/plugins/admin/systems/ServiceAddDialog.tpl
deleted file mode 100755
index f055f33c1..000000000
--- a/plugins/admin/systems/ServiceAddDialog.tpl
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
- {t}Adding a new service to the current server{/t}
-
-
-
-{t}This dialog allows you to add new services to the currenty edited server object. The box below shows all available but not already used services.{/t}
-
-
-
-{if $Services}
-
- {t}Service to add{/t}
-
-
- {html_options options=$Services }
-
-{else}
-
- {t}All available services are already in use.{/t}
-
-{/if}
-
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/class_ServiceAddDialog.inc b/plugins/admin/systems/class_ServiceAddDialog.inc
deleted file mode 100644
index 47e97012d..000000000
--- a/plugins/admin/systems/class_ServiceAddDialog.inc
+++ /dev/null
@@ -1,34 +0,0 @@
-"Config object" , "dn"=>"Object dn");
-
- /* This plugin does not have any ocs */
- var $objectclasses = array();
- var $parent = NULL;
-
- function ServiceAddDialog(&$config,$dn,$parent)
- {
- plugin::plugin($config);
- $this->parent = $parent;
- }
-
- function execute()
- {
- $smarty = get_smarty();
- $services = $this->parent->getAllUnusedServices();
- natcasesort($services);
- $smarty->assign("Services",$services);
- return($smarty->fetch(get_template_path("ServiceAddDialog.tpl", TRUE,dirname(__FILE__))));
- }
-
- function check(){ return array();}
- function save_object(){;}
- function save(){}
-
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_dhcpAdvanced.inc b/plugins/admin/systems/class_dhcpAdvanced.inc
deleted file mode 100644
index 43f583152..000000000
--- a/plugins/admin/systems/class_dhcpAdvanced.inc
+++ /dev/null
@@ -1,146 +0,0 @@
-is_account= TRUE;
- $this->setAutoStatements();
- $this->setAutoOptions();
- }
-
- function execute()
- {
- /* Check for interaction */
- if (isset($_POST['add_statement']) && $_POST['addstatement'] != ""){
- $key= preg_replace('/^([a-z0-9-]+)\s(.*)$/', '\\1', get_post('addstatement'));
- $val= preg_replace("/^$key\s*/", '', get_post('addstatement'));
- $this->statements[$key]= $val;
- }
- if (isset($_POST['delete_statement']) && isset($_POST['dhcpstatements'])){
- $key= preg_replace('/([a-z0-9-]+)\s(.*)$/', '\\1', get_post('dhcpstatements'));
- if (in_array($key, $this->autoStatements)){
- print_red(_("Can't delete automatic statements. Please use the fields above."));
- } else {
- unset($this->statements[$key]);
- }
- }
- if (isset($_POST['add_option']) && $_POST['addoption'] != ""){
- $key= preg_replace('/^([a-z0-9-]+)\s(.*)$/', '\\1', get_post('addoption'));
- $val= preg_replace("/^$key\s*/", '', get_post('addoption'));
- $this->options[$key]= $val;
- }
- if (isset($_POST['delete_option']) && isset($_POST['dhcpoptions'])){
- $key= preg_replace('/([a-z0-9-]+)\s(.*)$/', '\\1', get_post('dhcpoptions'));
- if (in_array($key, $this->autoOptions)){
- print_red(_("Can't delete automatic options. Please use the fields above."));
- } else {
- unset($this->options[$key]);
- }
- }
-
- $smarty= get_smarty();
-
- /* Assign arrays */
- $statements= array();
- foreach ($this->statements as $key => $val){
- if (in_array($key, $this->autoStatements)){
- $statements[$key]= "$key $val ["._("automatic")."]";
- } else {
- $statements[$key]= "$key $val";
- }
- }
- $smarty->assign("dhcpstatements", $statements);
- $options= array();
- foreach ($this->options as $key => $val){
- if (in_array($key, $this->autoOptions)){
- $options[$key]= "$key $val ["._("automatic")."]";
- } else {
- $options[$key]= "$key $val";
- }
- }
- $smarty->assign("dhcpoptions", $options);
-
- /* Show main page */
- $smarty->assign("show_advanced", $this->show_advanced);
- return ($smarty->fetch (get_template_path('dhcp_advanced.tpl', TRUE,dirname(__FILE__))));
- }
-
- function remove_from_parent()
- {
- }
-
-
- /* Save data to object */
- function save_object()
- {
- if (isset($_POST['show_advanced'])){
- $this->show_advanced= TRUE;
- }
- if (isset($_POST['hide_advanced'])){
- $this->show_advanced= FALSE;
- }
- }
-
-
- /* Check values */
- function check()
- {
- /* Nothing to check here */
- $message= array();
- return $message;
- }
-
-
- /* Save to LDAP */
- function save()
- {
- }
-
-
- function setAutoOptions($addopt= array())
- {
- $options= array("routers", "domain-name", "domain-name-servers", "subnet-mask", "broadcast-address");
- $this->autoOptions= array_merge($options, $addopt);
- }
-
-
- function setAutoStatements($addstat= array())
- {
- $statements= array("filename", "next-server", "get-lease-hostnames", "use-host-decl-names");
- $this->autoStatements= array_merge($statements, $addstat);
- }
-
-}
-
-?>
diff --git a/plugins/admin/systems/class_dhcpGroup.inc b/plugins/admin/systems/class_dhcpGroup.inc
deleted file mode 100644
index cbe987da8..000000000
--- a/plugins/admin/systems/class_dhcpGroup.inc
+++ /dev/null
@@ -1,126 +0,0 @@
-assign("cn", $this->cn);
-
- /* Show main page */
- $display= $smarty->fetch (get_template_path('dhcp_group.tpl', TRUE)).$this->network->execute();
-
- /* Merge arrays for advanced view */
- $this->fix_options();
- foreach (array("options", "statements") as $type){
- $this->advanced->$type= $this->$type + $this->network->$type;
- }
-
- $display.= $this->advanced->execute();
-
- /* Merge back for removals */
- foreach (array("options", "statements") as $type){
- $this->$type= $this->advanced->$type;
- $this->network->$type= $this->advanced->$type;
- }
-
- /* Add footer */
- $display.= " ".
- "
";
-
-
- return ($display);
- }
-
-
- function remove_from_parent()
- {
- }
-
-
- /* Save data to object */
- function save_object()
- {
- /* Save cn */
- if (isset($_POST['cn'])){
- $this->cn= validate(get_post('cn'));
- }
-
- /* Handle global saving */
- dhcpPlugin::save_object();
- }
-
-
- /* Check values */
- function check()
- {
- $message= array();
-
- $cache = $this->parent->dhcpObjectCache;
-
- /* All required fields are set? */
- if ($this->cn == ""){
- $message[]= _("Required field 'Name' is not filled.");
- }
- if (!preg_match('/^[a-z0-9_-]*$/i', $this->cn)){
- $message[]= _("Field 'Name' contains illegal characters.");
- }
-
- /* cn already used? */
- if ($this->orig_cn != $this->cn || $this->new){
-
- foreach($cache as $dn => $dummy){
- if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){
- $message[]= _("The name for this host section is already used!");
- break;
- }
- }
- }
-
- /* Check external plugins */
- $net= $this->network->check();
- $adv= $this->advanced->check();
- $message= array_merge($message, $net, $adv);
-
- return $message;
- }
-
-
- /* Save to LDAP */
- function save()
- {
- dhcpPlugin::save();
- return ($this->attrs);
- }
-
-
-}
-
-?>
diff --git a/plugins/admin/systems/class_dhcpHost.inc b/plugins/admin/systems/class_dhcpHost.inc
deleted file mode 100644
index e8aab5c95..000000000
--- a/plugins/admin/systems/class_dhcpHost.inc
+++ /dev/null
@@ -1,181 +0,0 @@
-new){
- $this->dhcpHWAddress= $attrs['dhcpHWAddress'][0];
- }
-
- $this->advanced->setAutoOptions(array("host-name"));
- $this->advanced->setAutoStatements(array("fixed-address"));
-
- $this->realGosaHost = $host_exists_in_gosa;
- }
-
- function execute()
- {
- $smarty= get_smarty();
- $smarty->assign("cn", $this->cn);
- $smarty->assign("dhcpHWAddress", preg_replace('/^[^ ]+ /', '', $this->dhcpHWAddress));
- $smarty->assign("realGosaHost",$this->realGosaHost);
-
- /* Create fixed address */
- if (isset($this->statements['fixed-address'])){
- $smarty->assign("fixedaddr", $this->statements['fixed-address']);
- } else {
- $smarty->assign("fixedaddr", "");
- }
-
- /* Prepare hw type selector */
- $hwtype= preg_replace('/\s.*$/', '', $this->dhcpHWAddress);
- $smarty->assign("hwtype", $hwtype);
- $smarty->assign("hwtypes", array("ethernet" => _("Ethernet"),
- "fddi" => _("FDDI"),
- "token-ring" => _("Token Ring")));
- /* Show main page */
- $display= $smarty->fetch(get_template_path('dhcp_host.tpl', TRUE,dirname(__FILE__))).$this->network->execute();
-
- /* Merge arrays for advanced view */
- $this->fix_options();
- foreach (array("options", "statements") as $type){
- $this->advanced->$type= $this->$type + $this->network->$type;
- }
- $display.= $this->advanced->execute();
-
- /* Merge back for removals */
- foreach (array("options", "statements") as $type){
- $this->$type= $this->advanced->$type;
- $this->network->$type= $this->advanced->$type;
- }
-
- /* Add footer */
- $display.= " ".
- "
";
-
-
- return ($display);
- }
-
-
- function remove_from_parent()
- {
- }
-
-
- /* Save data to object */
- function save_object()
- {
- /* Save remaining attributes */
- if (isset($_POST['dhcp_host_posted'])){
-
- /* Assemble hwAddress */
- if (isset($_POST['dhcpHWAddress'])){
- $this->dhcpHWAddress= get_post('hwtype')." ".get_post('dhcpHWAddress');
- }
-
- if(!$this->realGosaHost){
- $this->cn= validate(get_post('cn'));
- }
-
- /* Save fixed address */
- if(!$this->realGosaHost){
- if ($_POST['fixedaddr'] != ""){
- $this->statements['fixed-address']= get_post('fixedaddr');
- } else {
- unset ($this->statements['fixed-address']);
- }
- }
- $this->options['host-name']= $this->cn;
- }
-
- dhcpPlugin::save_object();
- }
-
-
- /* Check values */
- function check()
- {
- $message= array();
-
- $cache = array();
- if(isset($this->parent)){
- $cache = $this->parent->dhcpObjectCache;
- }
-
- /* All required fields are set? */
- if ($this->cn == ""){
- $message[]= _("Required field 'Name' is not filled.");
- }
-
- /* cn already used? */
- if ($this->orig_cn != $this->cn || $this->new){
-
- foreach($cache as $dn => $dummy){
- if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){
- $message[]= _("The name for this host section is already used!");
- break;
- }
- }
- }
-
- /* Check syntax of MAC address */
- $check= preg_replace('/^[^\s]*\s/', '', $this->dhcpHWAddress);
- if (!preg_match('/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/', $check)){
- $message[]= _("The hardware address specified by you is not valid!");
- }
-
- /* Check external plugins */
- $net= $this->network->check();
- $adv= $this->advanced->check();
- $message= array_merge($message, $net, $adv);
-
- return $message;
- }
-
-
- /* Save to LDAP */
- function save()
- {
- dhcpPlugin::save();
- if ($this->dhcpHWAddress != ""){
- $this->attrs['dhcpHWAddress']= array($this->dhcpHWAddress);
- } else {
- $this->attrs['dhcpHWAddress']= array();
- }
-
- return ($this->attrs);
- }
-
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_dhcpNetwork.inc b/plugins/admin/systems/class_dhcpNetwork.inc
deleted file mode 100644
index 1c3ced065..000000000
--- a/plugins/admin/systems/class_dhcpNetwork.inc
+++ /dev/null
@@ -1,226 +0,0 @@
-is_account= TRUE;
- }
-
- function execute()
- {
- /* Check for iteraction */
- if (isset($_POST['add_dns']) && $_POST['addserver'] != ""){
- if (!preg_match('/^[0-9a-z.-]+$/', get_post('addserver'))){
- print_red(_("The name of the DNS server your're going to add is not valid!"));
- } else {
- $servers= array();
- if (isset($this->options['domain-name-servers'])){
- foreach(split(",", $this->options['domain-name-servers']) as $val){
- $servers[$val]= $val;
- }
- }
- $servers[get_post('addserver')]= get_post('addserver');
-
- $tmp= "";
- foreach($servers as $val){
- $tmp.= $val.",";
- }
- $this->options['domain-name-servers']= preg_replace('/,$/', '', $tmp);
- }
- }
- if (isset($_POST['delete_dns']) && isset($_POST['dnsserver'])){
- $tmp= preg_replace("/(\s*,\s*)?".get_post('dnsserver')."/i", '',
- $this->options['domain-name-servers']);
- $tmp= preg_replace("/(\s*)?,(\s*)?$/", '', $tmp);
- if ($tmp != ""){
- $this->options['domain-name-servers']= $tmp;
- } else {
- unset($this->options['domain-name-servers']);
- }
- }
-
- /* Show main page */
- $smarty= get_smarty();
-
- /*
- * Assemble options
- */
-
- /* Router */
- if (isset($this->options['routers'])){
- $smarty->assign("routers", $this->options['routers']);
- } else {
- $smarty->assign("routers", "");
- }
-
- /* DNS */
- if (isset($this->options['domain-name'])){
- $smarty->assign("domain", trim($this->options['domain-name'], '"'));
- } else {
- $smarty->assign("domain", "");
- }
- if (isset($this->options['domain-name-servers'])){
- $servers= array();
- foreach(split(",", $this->options['domain-name-servers']) as $val){
- $servers[$val]= $val;
- }
- $smarty->assign("dnsservers", $servers);
- } else {
- $smarty->assign("dnsservers", "");
- }
-
- /* Netmask / Broadcast */
- if (isset($this->options['subnet-mask'])){
- $this->options['subnet-mask']= normalize_netmask($this->options['subnet-mask']);
- $smarty->assign("subnet_mask", $this->options['subnet-mask']);
- } else {
- $smarty->assign("subnet_mask", "");
- }
- if (isset($this->options['broadcast-address'])){
- $smarty->assign("broadcast_address", $this->options['broadcast-address']);
- } else {
- $smarty->assign("broadcast_address", "");
- }
-
- /* Boot stuff */
- if (isset($this->statements['filename'])){
- $smarty->assign("filename", trim($this->statements['filename'], '"'));
- } else {
- $smarty->assign("filename", "");
- }
- if (isset($this->statements['next-server'])){
- $smarty->assign("nextserver", $this->statements['next-server']);
- } else {
- $smarty->assign("nextserver", "");
- }
-
- /* Set flags */
- $smarty->assign("autohost", "");
- if (isset($this->statements['get-lease-hostnames'])){
- if (preg_match('/^(true|on|yes)$/', $this->statements['get-lease-hostnames'])){
- $smarty->assign("autohost", "checked");
- }
- }
- $smarty->assign("autohostdecl", "");
- if (isset($this->statements['use-host-decl-names'])){
- if (preg_match('/^(true|on|yes)$/', $this->statements['use-host-decl-names'])){
- $smarty->assign("autohostdecl", "checked");
- }
- }
-
- return $smarty->fetch(get_template_path('dhcp_network.tpl', TRUE,dirname(__FILE__)));
- }
-
- function remove_from_parent()
- {
- }
-
-
- /* Save data to object */
- function save_object()
- {
- /* Only save, if we are "active" */
- if (isset($_POST['routers'])){
-
- /*
- * Assemble options
- */
-
- /* Options */
- foreach (array("routers" => "routers", "domain-name" => "domain", "subnet-mask" => "subnet_mask",
- "broadcast-address" => "broadcast_address") as $key => $val){
-
- if ($_POST["$val"] == ''){
- unset($this->options["$key"]);
- } else {
- $this->options["$key"]= get_post("$val");
- }
- }
-
- /* Statements */
- foreach (array("filename" => "filename", "next-server" => "nextserver") as $key => $val){
- if ($_POST["$val"] == ''){
- unset($this->statements["$key"]);
- } else {
-
- /* Only quote filename values */
- if(in_array($key,array("filename"))){
- $this->statements["$key"]= '"'.get_post("$val").'"';
- }else{
- $this->statements["$key"]= get_post("$val");
- }
- }
- }
-
- /* Flags */
- if (isset ($_POST['autohost'])){
- $this->statements['get-lease-hostnames']= "true";
- } else {
- unset($this->statements['get-lease-hostnames']);
- }
- if (isset ($_POST['autohostdecl'])){
- $this->statements['use-host-decl-names']= "on";
- } else {
- unset($this->statements['use-host-decl-names']);
- }
- }
- }
-
-
- /* Check values */
- function check()
- {
- $message= array();
-
- /* Check netmask and broadcast */
- foreach(array("subnet-mask" => _("Netmask"), "broadcast-address" => _("Broadcast")) as $key => $typ){
- if (!isset($this->options["$key"])){
- continue;
- }
- $tmp= preg_replace('/^[^\s]+\s/', '', $this->options["$key"]);
-
- if (!is_ip($tmp)){
- $message[]= sprintf(_("Error in definition of '%s'!"), $typ);
- }
- }
-
- return $message;
- }
-
-
- /* Save to LDAP */
- function save()
- {
- }
-
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_dhcpNewSectionDialog.inc b/plugins/admin/systems/class_dhcpNewSectionDialog.inc
deleted file mode 100644
index 756a97893..000000000
--- a/plugins/admin/systems/class_dhcpNewSectionDialog.inc
+++ /dev/null
@@ -1,80 +0,0 @@
- array("dhcpSharedNetwork", "dhcpSubnet", "dhcpGroup", "dhcpHost" /*, "dhcpClass"*/),
- #"dhcpClass" => array("dhcpSubClass"),
- "dhcpSubClass" => array(),
- "dhcpHost" => array(),
- "dhcpGroup" => array("dhcpHost"),
- "dhcpPool" => array(),
- "dhcpSubnet" => array("dhcpPool", "dhcpGroup", "dhcpHost" /*, "dhcpClass"*/),
- "dhcpSharedNetwork" => array("dhcpSubnet", "dhcpPool"));
-
-
-
- function dhcpNewSectionDialog($type)
- {
- $this->types= array( "dhcpService" => _("Global options"),
- /*"dhcpClass" => _("Class"),*/
- "dhcpSubClass" => _("Subclass"),
- "dhcpHost" => _("Host"),
- "dhcpGroup" => _("Group"),
- "dhcpPool" => _("Pool"),
- "dhcpSubnet" => _("Subnet"),
- "dhcpSharedNetwork" => _("Shared network"));
-
- $this->classtype= $type;
- }
-
- function execute()
- {
- /* Fill templating stuff */
- $smarty = get_smarty();
- $display= "";
-
- $sections= $this->sectionMap[$this->classtype];
- $t_sections= array();
- foreach ($sections as $section){
- $t_sections[$section]= $this->types[$section];
- }
- asort($t_sections);
- $ui = get_userinfo();
- $smarty->assign("sections", $t_sections);
- $display.= $smarty->fetch(get_template_path('dhcpNewSection.tpl', TRUE));
- return($display);
- }
-
- /* Get posts and set class name
- */
- function save_object()
- {
- }
-
- /* Check given class name */
- function check()
- {
- /* Call common method to give check the hook */
- $message= "";
-
- return ($message);
- }
-
-
- /* Return the class name */
- function save()
- {
- }
-
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_dhcpPool.inc b/plugins/admin/systems/class_dhcpPool.inc
deleted file mode 100644
index 9e9821e8a..000000000
--- a/plugins/admin/systems/class_dhcpPool.inc
+++ /dev/null
@@ -1,191 +0,0 @@
-new){
- $this->dhcpRange= $attrs['dhcpRange'][0];
- list($this->range_start, $this->range_stop)= preg_split('/\s+/', $this->dhcpRange);
- }
-
- $this->advanced->setAutoOptions(array("host-name"));
- $this->advanced->setAutoStatements(array("fixed-address"));
- }
-
- function execute()
- {
- $smarty= get_smarty();
- $smarty->assign("cn", $this->cn);
- $smarty->assign("range_start", $this->range_start);
- $smarty->assign("range_stop", $this->range_stop);
-
- /* Show main page */
- $display= $smarty->fetch(get_template_path('dhcp_pool.tpl', TRUE)).$this->network->execute();
-
- /* Merge arrays for advanced view */
- $this->fix_options();
- foreach (array("options", "statements") as $type){
- $this->advanced->$type= $this->$type + $this->network->$type;;
- }
-
- $display.= $this->advanced->execute();
-
- /* Merge back for removals */
- foreach (array("options", "statements") as $type){
- $this->$type= $this->advanced->$type;
- $this->network->$type= $this->advanced->$type;
- }
-
- /* Add footer */
- $display.= " ".
- "
";
-
- return ($display);
- }
-
- function remove_from_parent()
- {
- }
-
-
- /* Save data to object */
- function save_object()
- {
- if (isset($_POST['cn'])){
- $this->cn= validate(get_post('cn'));
- $this->range_start= validate(get_post('range_start'));
- $this->range_stop= validate(get_post('range_stop'));
- }
-
- dhcpPlugin::save_object();
-
- /* Move range to internal variable */
- $this->dhcpRange= $this->range_start." ".$this->range_stop;
- }
-
-
- /* Check values */
- function check()
- {
- $message= array();
-
- $cache = $this->parent->dhcpObjectCache;
-
- /* All required fields are set? */
- if ($this->cn == ""){
- $message[]= _("Required field 'Name' is not filled.");
- }
-
- /* cn already used? */
- if ($this->orig_cn != $this->cn || $this->new){
-
- foreach($cache as $dn => $dummy){
- if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){
- $message[]= _("The name for this section is already used!");
- break;
- }
- }
- }
-
- if ($this->dhcpRange == ""){
- $message[]= _("Required field 'Range' is not filled.");
- }
-
- if (!is_ip($this->range_start) || !is_ip($this->range_stop)){
- $message[]= _("Field 'Range' contains invalid IP addresses.");
- }
-
- if(!is_ip_range($this->range_start,$this->range_stop)){
- $message[] = _("Field 'Range' contains invalid IP range.");
- }
-
- /* Check if range is in the network */
- $dn= $this->dn;
- while (preg_match('/,/', $dn)){
- $type= $this->objectType($cache, $dn);
-
- /* Check for subnet */
- if ($type == 'dhcpSubnet'){
- $network= $cache[$dn]['cn'][0];
- $netmask= normalize_netmask($cache[$dn]['dhcpNetMask'][0]);
- if (!is_in_network($network, $netmask, $this->range_start) ||
- !is_in_network($network, $netmask, $this->range_stop)){
- $message[] = _("'Range' is not inside the configured network.");
- }
- }
-
- /* Stop if we've examined the service base object */
- if ($type == 'dhcpService'){
- break;
- }
- $dn= preg_replace('/^[^,]+,/', '', $dn);
- }
-
- /* Check external plugins */
- $net= $this->network->check();
- $adv= $this->advanced->check();
- $message= array_merge($message, $net, $adv);
-
- return $message;
- }
-
- /* Save to LDAP */
- function save()
- {
- dhcpPlugin::save();
- $this->attrs['dhcpRange']= array($this->dhcpRange);
-
- return ($this->attrs);
- }
-
-
- function objectType($cache, $dn)
- {
- $type= "";
- $types= array("dhcpService", "dhcpClass", "dhcpSubClass", "dhcpHost",
- "dhcpGroup", "dhcpPool", "dhcpSubnet", "dhcpSharedNetwork");
-
- foreach ($cache[$dn]['objectClass'] as $oc){
- if (in_array($oc, $types)){
- $type= $oc;
- break;
- }
- }
-
- return ($type);
- }
-
-
-}
-
-?>
diff --git a/plugins/admin/systems/class_dhcpService.inc b/plugins/admin/systems/class_dhcpService.inc
deleted file mode 100644
index 57f76cc9e..000000000
--- a/plugins/admin/systems/class_dhcpService.inc
+++ /dev/null
@@ -1,181 +0,0 @@
-new){
- /* Load attributes */
- $this->dhcpPrimaryDN= $attrs['dhcpPrimaryDN'][0];
- } else {
- /* We keep the parent dn here if it's new */
- $this->statements['default-lease-time']= 600;
- $this->statements['max-lease-time']= 1700;
- $this->statements['authoritative']= TRUE;
- $this->statements['ddns-update-style']= 'none';
- }
-
- $this->advanced->setAutoStatements(array("default-lease-time", "max-lease-time", "authoritative", "server-identifier", "ddns-update-style"));
- $this->advanced->setAutoOptions(array("server-name"));
-
- /* Save for later action */
- $this->orig_dhcpPrimaryDN= $this->dhcpPrimaryDN;
- }
-
-
- function execute()
- {
- /* Show main page */
- $smarty= get_smarty();
-
- $smarty->assign('ddns_styles', $this->ddns_styles);
- foreach (array('max_lease_time', 'default_lease_time', 'ddns_update_style') as $value){
- if (isset($this->statements[preg_replace('/_/', '-', $value)])){
- $smarty->assign("$value", $this->statements[preg_replace('/_/', '-', $value)]);
- } else {
- $smarty->assign("$value", "");
- }
- }
-
- if (isset($this->statements['authoritative'])){
- $smarty->assign("authoritative", "checked");
- } else {
- $smarty->assign("authoritative", "");
- }
-
- /* Show main page */
- $display= $smarty->fetch(get_template_path('dhcp_service.tpl', TRUE)).$this->network->execute();
-
- /* Merge arrays for advanced view */
- $this->fix_options();
- foreach (array("options", "statements") as $type){
- $this->advanced->$type= $this->$type + $this->network->$type;;
- }
-
- $display.= $this->advanced->execute();
-
- /* Merge back for removals */
- foreach (array("options", "statements") as $type){
- $this->$type= $this->advanced->$type;
- $this->network->$type= $this->advanced->$type;
- }
-
- /* Add footer */
- $display.= " ".
- "
";
-
-
- return ($display);
-
- }
-
- function remove_from_parent()
- {
- }
-
-
- /* Save data to object */
- function save_object()
- {
- /* No need to save in the first time */
- if (!isset($_POST['ddns_update_style'])){
- return;
- }
-
- /* Save remaining attributes */
- foreach (array('max_lease_time', 'default_lease_time', 'ddns_update_style') as $val){
- $tval= preg_replace('/_/', '-', $val);
- if ($_POST[$val] != ""){
- $this->statements[$tval]= validate(get_post($val));
- } else {
- unset ($this->statements[$tval]);
- }
- }
- if (isset($_POST['authoritative'])){
- $this->statements['authoritative']= "";
- } else {
- unset($this->statements['authoritative']);
- }
-
- dhcpPlugin::save_object();
- }
-
-
- /* Check values */
- function check()
- {
- $message= array();
-
- if (!is_id($this->statements['default-lease-time'])){
- $message[]= _('Default lease time needs to be numeric.');
- }
- if (!is_id($this->statements['max-lease-time'])){
- $message[]= _('Maximum lease time needs to be numeric.');
- }
- if ($this->statements['default-lease-time'] > $this->statements['max-lease-time']){
- $message[]= _('Default lease time needs to smaller than the maximum lease time.');
- }
-
- /* Check external plugins */
- $net= $this->network->check();
- $adv= $this->advanced->check();
- $message= array_merge($message, $net, $adv);
-
- return $message;
- }
-
-
- /* Save to LDAP */
- function save()
- {
- global $config;
- $this->attrs= array();
-
- /* Get and set server name */
- $ldap= $config->get_ldap_link();
- $ldap->cat($this->dhcpPrimaryDN, array('cn'));
- $res= $ldap->fetch();
- $server_name= $res['cn'][0];
-
- dhcpPlugin::save();
-
- $this->attrs['dhcpPrimaryDN']= array($this->dhcpPrimaryDN);
- $this->removeOption('server-name');
-# $this->attrs['dhcpOption'][]= "server-name $server_name";
-
- return ($this->attrs);
- }
-
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_dhcpSharedNetwork.inc b/plugins/admin/systems/class_dhcpSharedNetwork.inc
deleted file mode 100644
index 6e55b75d6..000000000
--- a/plugins/admin/systems/class_dhcpSharedNetwork.inc
+++ /dev/null
@@ -1,188 +0,0 @@
-advanced->setAutoStatements(array("server-identifier", "default-lease-time",
- "max-lease-time", "min-lease-time", "authoritative", "deny-unknown-clients",
- "deny-bootp", "deny-booting"));
- }
-
-
- function execute()
- {
- $smarty= get_smarty();
-
- /* Fill template */
- $smarty->assign ("cn", $this->cn);
- foreach (array("server-identifier", "default-lease-time", "max-lease-time", "min-lease-time") as $attr){
- if (isset($this->statements[$attr])){
- $smarty->assign(preg_replace('/-/', '_', $attr), $this->statements[$attr]);
- } else {
- $smarty->assign(preg_replace('/-/', '_', $attr), "");
- }
- }
- if (isset($this->statements["authoritative"])){
- $smarty->assign("authoritative", "checked");
- } else {
- $smarty->assign("authoritative", "");
- }
- if (!isset($this->statements["deny unknown-clients"])){
- $smarty->assign("allow_unknown_state", "checked");
- } else {
- $smarty->assign("allow_unknown_state", "");
- }
- if (!isset($this->statements["deny bootp"])){
- $smarty->assign("allow_bootp_state", "checked");
- } else {
- $smarty->assign("allow_bootp_state", "");
- }
- if (!isset($this->statements["deny booting"])){
- $smarty->assign("allow_booting_state", "checked");
- } else {
- $smarty->assign("allow_booting_state", "");
- }
-
- /* Show main page */
- $display= $smarty->fetch(get_template_path('dhcp_sharedNetwork.tpl', TRUE)).$this->network->execute();
-
- /* Merge arrays for advanced view */
- $this->fix_options();
- foreach (array("options", "statements") as $type){
- $this->advanced->$type= $this->$type + $this->network->$type;
- }
-
- $display.= $this->advanced->execute();
-
- /* Merge back for removals */
- foreach (array("options", "statements") as $type){
- $this->$type= $this->advanced->$type;
- $this->network->$type= $this->advanced->$type;
- }
-
- /* Add footer */
- $display.= " ".
- "
";
-
-
- return ($display);
- }
-
-
- function remove_from_parent()
- {
- }
-
-
- /* Save data to object */
- function save_object()
- {
- if (isset($_POST['cn'])){
- $this->cn= validate(get_post('cn'));
- dhcpPlugin::save_object();
-
- foreach (array("server-identifier", "default-lease-time",
- "max-lease-time", "min-lease-time") as $attr){
- if (isset($_POST[$attr]) && $_POST[$attr] != ""){
- $this->statements[$attr]= get_post($attr);
- } else {
- unset($this->statements[$attr]);
- }
- }
-
- if (isset($_POST["authoritative"])){
- $this->statements["authoritative"]= "";
- } else {
- unset ($this->statements["authoritative"]);
- }
-
- foreach(array("unknown-clients", "bootp", "booting") as $name){
- if (isset($_POST[$name])){
- $this->statements["allow $name"]= "";
- unset($this->statements["deny $name"]);
- } else {
- $this->statements["deny $name"]= "";
- unset($this->statements["allow $name"]);
- }
- }
- }
- }
-
-
- /* Check values */
- function check()
- {
- $message= array();
-
- $cache = $this->parent->dhcpObjectCache;
-
- /* All required fields are set? */
- if ($this->cn == ""){
- $message[]= _("Required field 'Name' is not filled.");
- }
-
- /* Check lease times */
- foreach (array("default-lease-time" => _("Default lease time"),
- "max-lease-time" => _("Max. lease time"),
- "min-lease-time" => _("Min. lease time")) as $key => $val){
- if (isset($this->statements[$key]) && $this->statements[$key] != "" &&
- !is_id($this->statements[$key])){
- $message[]= sprintf(_("The value specified as '%s' is not numeric!"), $val);
- }
- }
-
- /* cn already used? */
- if ($this->orig_cn != $this->cn || $this->new){
-
- foreach($cache as $dn => $dummy){
- if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){
- $message[]= _("The name for this host section is already used!");
- break;
- }
- }
- }
-
- /* Check external plugins */
- $net= $this->network->check();
- $adv= $this->advanced->check();
- $message= array_merge($message, $net, $adv);
-
- return $message;
- }
-
-
- /* Save to LDAP */
- function save()
- {
- dhcpPlugin::save();
-
- return ($this->attrs);
- }
-
-}
-
-?>
diff --git a/plugins/admin/systems/class_dhcpSubnet.inc b/plugins/admin/systems/class_dhcpSubnet.inc
deleted file mode 100644
index 8c2da41de..000000000
--- a/plugins/admin/systems/class_dhcpSubnet.inc
+++ /dev/null
@@ -1,200 +0,0 @@
-new){
- /* Load attributes */
- foreach (array("dhcpNetMask", "dhcpRange") as $attr){
- if (isset($attrs[$attr][0])){
- $this->$attr= $attrs[$attr][0];
- }
- }
- if (isset($attrs['dhcpRange']) && count($attrs['dhcpRange'])){
- $this->use_range= TRUE;
- list($this->range_start, $this->range_stop)= preg_split('/\s+/', $this->dhcpRange);
- }
- }
-
- $this->dhcpNetMask= normalize_netmask($this->dhcpNetMask);
- }
-
-
- function execute()
- {
- $smarty= get_smarty();
- $smarty->assign("cn", $this->cn);
- $smarty->assign("dhcp_netmask", $this->dhcpNetMask);
-
- /* Prepare range */
- if ($this->use_range){
- $smarty->assign("use_range", "checked");
- $smarty->assign("range_disabled", "");
- } else {
- $smarty->assign("use_range", "");
- $smarty->assign("range_disabled", "disabled");
- }
- $smarty->assign("range_start", $this->range_start);
- $smarty->assign("range_stop", $this->range_stop);
-
- /* Show main page */
- $display= $smarty->fetch(get_template_path('dhcp_subnet.tpl', TRUE)).$this->network->execute();
-
- /* Merge arrays for advanced view */
- $this->fix_options();
- foreach (array("options", "statements") as $type){
- $this->advanced->$type= $this->$type + $this->network->$type;
- }
-
- $display.= $this->advanced->execute();
-
- /* Merge back for removals */
- foreach (array("options", "statements") as $type){
- $this->$type= $this->advanced->$type;
- $this->network->$type= $this->advanced->$type;
- }
-
- /* Add footer */
- $display.= " ".
- "
";
-
- /* Show main page */
- return $display;
- }
-
-
- function remove_from_parent()
- {
- }
-
-
- /* Save data to object */
- function save_object()
- {
- if(isset($_POST['dhcp_subnet_posted'])){
- if (isset($_POST['cn'])){
- $this->cn= validate(get_post('cn'));
- }
- if (isset($_POST['dhcp_netmask'])){
- $this->dhcpNetMask= validate(get_post('dhcp_netmask'));
- }
- if (isset($_POST['use_range'])){
- $this->use_range= TRUE;
- $this->range_start= validate(get_post('range_start'));
- $this->range_stop= validate(get_post('range_stop'));
- } else {
- $this->use_range= FALSE;
- }
-
- /* Move range to internal variable */
- $this->dhcpRange= $this->range_start." ".$this->range_stop;
- dhcpPlugin::save_object();
- }
- }
-
-
- /* Check values */
- function check()
- {
- $message= array();
-
- $cache = $this->parent->dhcpObjectCache;
-
- /* All required fields are set? */
- if ($this->cn == ""){
- $message[]= _("Required field 'Network address' is not filled.");
- }
- if ($this->dhcpNetMask == ""){
- $message[]= _("Required field 'Netmask' is not filled.");
- }
-
- /* cn already used? */
- if ($this->orig_cn != $this->cn || $this->new){
-
- foreach($cache as $dn => $dummy){
- if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){
- $message[]= _("The name for this section is already used!");
- break;
- }
- }
- }
-
- /* IP's? */
- foreach(array('dhcpNetMask' => _("Netmask"), 'cn' => _("Network address"), 'range_start' => _("Range"), 'range_stop' => _("Range")) as $attr => $str){
- if ($this->$attr != "" && !is_ip($this->$attr)){
- $message[]= sprintf(_("The field '%s' contains an invalid IP address"), $str);
- }
- }
-
- /* Check ip range */
- if ($this->use_range){
- if(!is_ip_range($this->range_start,$this->range_stop)){
- $message[] = _("Field 'Range' contains invalid IP range.");
- }
-
- /* Check if range is in the network */
- if (!is_in_network($this->cn, $this->dhcpNetMask, $this->range_start) ||
- !is_in_network($this->cn, $this->dhcpNetMask, $this->range_stop)){
- $message[] = _("'Range' is not inside the configured network.");
- }
- }
-
- /* Check external plugins */
- $net= $this->network->check();
- $adv= $this->advanced->check();
- $message= array_merge($message, $net, $adv);
-
- return $message;
- }
-
-
- /* Save to LDAP */
- function save()
- {
- dhcpPlugin::save();
-
- /* Move dn to the result */
- $this->attrs['dhcpNetMask']= array(netmask_to_bits($this->dhcpNetMask));
- if ($this->use_range && !empty($this->dhcpRange)){
- $this->attrs['dhcpRange']= array($this->range_start." ".$this->range_stop);
- } else {
- $this->attrs['dhcpRange']= array();
- }
-
- return ($this->attrs);
- }
-
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_glpiAccount.inc b/plugins/admin/systems/class_glpiAccount.inc
deleted file mode 100644
index e6411087a..000000000
--- a/plugins/admin/systems/class_glpiAccount.inc
+++ /dev/null
@@ -1,806 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* attribute list for save action */
- var $ignore_account= FALSE;
- var $attributes= array("ID","name","contact",
- "tech_num","comments","date_mod","os","location","domain","network","contact_num",
- "model","type","is_template","FK_glpi_enterprise","deleted");
-
- var $ID ; // Is set if this entry is edited
- var $name = ""; // This should be the dn of this entry
- var $contact = ""; // Empty
-
- var $comments = ""; // Comment
-
- var $contact_num = ""; // Contact person
- var $tech_num = ""; // Technical responsible person
-
- var $addUser = ""; // This is used to remember if a dialog was opened for tech_num or contact_num
-
- var $date_mod = ""; // Modification timestamp
- var $os = 0; // Operating system
- var $location = 0; // Not used yet
- var $domain = 0; // ? Set to 0
- var $network = 0; // ? Set to 0
-
- var $model = 0; // ? Can't remember this, it isn't used in GOsa
- var $type = 0; // System type id
- var $is_template = 0; // Used as template ?
- var $FK_glpi_enterprise = 0; // Manufacturer id
- var $deleted = "N"; // Deleted entries should have this set to Y
-
- var $renameTypeDialog = false;
- var $renameOSDialog = false;
- var $select_type ;
- var $view_logged = FALSE;
-
- /* Not necessary, cause we use mysql databse */
- var $objectclasses= array("whatever");
-
- /* Used to remember if this was an account (simply: is this an edited entry) */
- var $initially_was_account = false;
-
- /* Remember current dialog */
- var $edit_type = false;
- var $edit_os = false;
-
- var $data;
- var $handle = NULL; // Glpi class handle used to query database
-
- var $cur_dialog = NULL; // This contains the sub dialog handle
-
- var $orig_dn; // To check if dn, has changed
- var $ui; // Some GOsa specific user informations
-
- var $usedDevices = array(); // Which devices are currently selected
- var $usedAttachments = array(); // Used Attachments
-
- /* Contructor
- Sets default values and checks if we already have an existing glpi account
- */
- function glpiAccount (&$config, $dn= NULL, $parent= NULL)
- {
- plugin::plugin ($config, $dn, $parent);
- $this->ui= get_userinfo();
-
- /* Abort class construction, if no db is defined */
- if(!isset($this->config->data['SERVERS']['GLPI'])){
- return;
- }
-
- // Get informations about databse connection
- $this->data = $this->config->data['SERVERS']['GLPI'];
-
- // Abort if mysql extension is missing
- if(!is_callable("mysql_connect")){
- return;
- }
-
- // Create handle of glpi class, and check if database connection is established
- $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
-
- if(!$this->handle->is_connected){
- return;
- }
-
- // If this dn is already used in database, then get all informations for this entry
- if($this->handle->is_account($this->dn)){
- $this->is_account = true;
- $tmp = ($this->handle->getComputerInformations($this->dn));
-
- foreach(array("tech_num","os","FK_glpi_enterprise","type","comments","contact_num") as $attr){
- $this->$attr = $tmp[0][$attr];
- }
- $this->usedDevices = $this->handle->getUsedDevices($tmp[0]['ID']);
- $atts = $this->handle->getAssignAttachments($tmp[0]['ID']);
- foreach($atts as $attachment){
-
- $this->usedAttachments[$attachment['FK_doc']]=$attachment['FK_doc'];
- }
- }else{
- $this->is_account = false;
- }
-
- /* set defaults */
- $this->name = $this->dn;
- $this->orig_dn = $this->dn;
- $this->initially_was_account = $this->is_account;
- }
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","all/".get_class($this),$this->dn);
- }
-
- /* Fill templating stuff */
- $smarty= get_smarty();
- $display= "";
-
- /* Assign smarty defaults
- To avoid undefined indexes, if there is an error with the glpi db
- */
- foreach(array("SystemTypes","SystemTypeKeys","Manufacturers",
- "OSs","TechnicalResponsibles","InstalledDevices","Attachments","AttachmentKeys",
- "OSKeys","OSs","ManufacturerKeys","InstalledDeviceKeys") as $attr){
- $smarty->assign($attr,array());
- }
- foreach(array("type","FK_glpi_enterprise","os","tech_num","comments","contact_num","AttachmentsDiv") as $attr){
- $smarty->assign($attr,"");
- }
-
- $tmp = $this->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $translation) {
- $smarty->assign($name."ACL",$this->getacl($name));
- }
-
- /* Check if there is a glpi database server defined
- */
- if(!isset($this->config->data['SERVERS']['GLPI'])){
- print_red(_("There is no server with valid glpi database service."));
- return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
- }
-
- $this->data = $this->config->data['SERVERS']['GLPI'];
-
- /* Check if we can call mysql_connect
- If we can't, there is no the mysql-php extension
- */
- if(!is_callable("mysql_connect")){
- print_red(_("Can't connect to glpi database, the php-mysql extension is missing."));
- return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
- }
-
- $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
-
- /* If handle == false, abort
- Seems that the server, username and or password is wrong
- */
- if(!$this->handle->is_connected){
- print_red(_("Can't connect to glpi database, check configuration twice."));
- return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
- }
-
- /* All checks are ok
- Lets handle Posts, templates etc below ...
- */
-
- $users = $this->handle->getUsers();
- $ldap= $this->config->get_ldap_link();
-
- /* Check for Trading button Post
- */
- if(isset($_POST['Trading'])){
- print_red(_("This feature is not implemented yet."));
- }
-
- /* Check for Software button Post
- */
- if(isset($_POST['Software'])){
- print_red(_("This feature is not implemented yet."));
- }
-
- /* Check for Contract button Post
- */
- if(isset($_POST['Contracts'])){
- print_red(_("This feature is not implemented yet."));
- }
-
- /* Add Device was requested, open new dialog
- */
- if((isset($_POST['AddDevice'])) && ($this->acl_is_writeable("Devices"))){
- $this->dialog =true;
- $this->cur_dialog = new glpiDeviceManagement($this->config,$this->dn,$this->usedDevices);
- }
-
- /* Attachment pool was closed with use
- */
- if(isset($_POST['UseAttachment']) && ($this->acl_is_writeable("Attachments"))){
- if(count($this->cur_dialog->check())){
- foreach($this->cur_dialog->check() as $msg){
- print_red($msg);
- }
- }else{
- $this->cur_dialog->save_object();
- $this->usedAttachments = $this->cur_dialog->save();
- $this->cur_dialog = false;
- $this->edit_type = false;
- }
- }
-
- /* Attachment pool was closed with abort
- */
- if(isset($_POST['AbortAttachment'])){
- $this->cur_dialog = false;
- $this->edit_type = false;
- }
-
- /* Open Attachment pool to add/edit Attachments
- */
- if(isset($_POST['AddAttachment']) && ($this->acl_is_writeable("Attachments"))){
- $this->cur_dialog = new glpiAttachmentPool($this->config,$this->dn,$this->usedAttachments);
- $this->dialog = true;
- }
-
- /* Remove Attachment fro this tab
- */
- $once = true;
- foreach($_POST as $name => $value){
- if((preg_match("/^delAttachment_/",$name))&&($once) && $this->acl_is_writeable("Attachments")){
- $once= false;
- $name = preg_replace("/^delAttachment_/","",$name);
- $entry = preg_replace("/_.*$/","",$name);
- if(isset($this->usedAttachments[$entry])){
- unset($this->usedAttachments[$entry]);
- }
- }
- }
- if((isset($_POST['RemoveAttachment']))&&(isset($_POST['Attachments'])) && ($this->acl_is_writeable("Attachments"))){
- foreach($_POST['Attachments'] as $entry){
- if(isset($this->usedAttachments[$entry])){
- unset($this->usedAttachments[$entry]);
- }
- }
- }
-
- /* We have selected some devices and pressed use button
- */
- if(isset($_POST['SelectDeviceSave']) && $this->acl_is_writeable("Devices")){
- $this->cur_dialog->save_object();
- $this->usedDevices= ($this->cur_dialog->getSelected());
- $this->cur_dialog = false;
- $this->dialog = false;
- $this->edit_type=false;
- }
-
- /* Aborted Device selction
- */
- if(isset($_POST['SelectDeviceCancel']) && ($this->acl_is_writeable("Devices"))){
- $this->dialog = false;
- $this->cur_dialog = false;
- $this->edit_type=false;
- }
-
- /* System type management
- */
- if(isset($_POST['edit_type']) && $this->acl_is_writeable("type")){
- $this->dialog = true;
- $this->edit_type=true;
- }
-
- /* This closes the system type editing dialog
- */
- if(isset($_POST['close_edit_type']) && ($this->acl_is_writeable("type"))){
- $this->edit_type=false;
- $this->dialog = false;
- }
-
- if(isset($_POST['Rename_Cancel'])){
- $this->renameTypeDialog = false;
- $this->renameOSDialog = false;
- }
-
- /* This appends a new system to our sytem types
- */
- if((isset($_POST['add_type']))&&(!empty($_POST['type_string'])) && $this->acl_is_writeable("type")){
- $attr = $this->handle->getSystemTypes();
- if(in_array(trim($_POST['type_string']),$attr)){
- print_red(_("Adding new sytem type failed, this system type name is already used.")) ;
- }else{
- $this->handle->addSystemType(trim($_POST['type_string']));
- }
- }
-
- /* Remove selected type from our system types list
- */
- if((isset($_POST['del_type']))&&(!empty($_POST['select_type'])) && $this->acl_is_writeable("type")){
- $tmp = $this->handle->is_systemTypeUsed($_POST['select_type']);
- if(count($tmp)){
- $names = "";
- foreach($tmp as $name){
- $names .= ", ".$name;
- }
- $names = preg_replace("/^, /","",$names);
- $names = trim($names);
- if(count($tmp) == 3){
- $names .= " ...";
- }
- print_red(sprintf(_("You can't delete this system type, it is still in use by these system(s) '%s'"),$names));
- }else{
- $this->handle->removeSystemType($_POST['select_type']);
- }
- }
-
- /* Rename selected system type to given string
- */
- if(isset($_POST['Rename_type_OK'])){
- $attr = $this->handle->getSystemTypes();
- if(in_array(trim($_POST['string']),$attr)){
- print_red(_("Rename failed, this system type name is already used.")) ;
- }else{
- $this->renameTypeDialog = false;
- $this->handle->updateSystemType($_POST['string'],trim($this->select_type));
- }
- }
-
-
- if((isset($_POST['rename_type'])&&(!empty($_POST['select_type'])))||($this->renameTypeDialog)){
- if(isset($_POST['select_type'])){
- $this->select_type = $_POST['select_type'];
- }
- $this->renameTypeDialog = true;
- $tmp = $this->handle->getSystemTypes();
-
- $smarty->assign("string",$tmp[$this->select_type]);
- if(isset($_POST['string'])){
- $smarty->assign("string",$_POST['string']);
- }
- $smarty->assign("Method","rename");
- $display= $smarty->fetch(get_template_path('glpi_edit_type.tpl', TRUE));
- return($display);
- }
-
-
-
- /* Someone wants to edit the system types ...
- So, lets open a new dialog which provides some buttons to edit the types
- */
- if($this->edit_type){
- $smarty->assign("Method","edit");
- $smarty->assign("SystemTypes", $this->handle->getSystemTypes());
- $smarty->assign("SystemTypeKeys", array_flip($this->handle->getSystemTypes()));
- $display= $smarty->fetch(get_template_path('glpi_edit_type.tpl', TRUE));
- return($display);
- }
-
- /* System os management
- */
- if(isset($_POST['edit_os']) && $this->acl_is_writeable("os")){
- $this->dialog = true;
- $this->edit_os=true;
- }
-
- /* Close Operating system dialog
- */
- if(isset($_POST['close_edit_os'])){
- $this->edit_os=false;
- $this->dialog = false;
- }
-
- /* Add new os to the db
- */
- if((isset($_POST['add_os']))&&(!empty($_POST['is_string'])) && $this->acl_is_writeable("os")){
- $attr = $this->handle->getOSTypes();
- if(in_array(trim($_POST['is_string']),$attr)){
- print_red(_("Adding new operating system failed, specifed name is already used.")) ;
- }else{
- $this->handle->addOS(trim($_POST['is_string']));
- }
- }
-
- /* Delete selected os from list and db
- */
- if((isset($_POST['del_os']))&&(!empty($_POST['select_os'])) && $this->acl_is_writeable("os")){
- $tmp = $this->handle->is_osUsed($_POST['select_os']);
-
- if(count($tmp)){
-
- $names = "";
- foreach($tmp as $name){
- $names .= ", ".$name;
- }
- $names = preg_replace("/^, /","",$names);
- $names = trim($names);
- if(count($tmp) == 3){
- $names .= " ...";
- }
- print_red(sprintf(_("You can't delete this operating system, it is still in use by these system(s) '%s'"),$names));
-
- }else{
- $this->handle->removeOS_byID($_POST['select_os']);
- }
- }
-
- /* Rename selected os to given string
- */
- if(isset($_POST['Rename_os_OK']) && $this->acl_is_writeable("os")){
- $attr = $this->handle->getOSTypes();
- if(in_array(trim($_POST['string']),$attr)){
- print_red(_("Updating operating system failed, specifed name is already used.")) ;
- }else{
- $this->handle->updateOS($_POST['string'],$this->select_type);
- $this->renameOSDialog = false;
- }
- }
- if((isset($_POST['rename_os'])&&(!empty($_POST['select_os'])))||($this->renameOSDialog)){
- if(isset($_POST['select_os'])){
- $this->select_type = $_POST['select_os'];
- }
- $this->renameOSDialog = true;
- $tmp = $this->handle->getOSTypes();
-
- $smarty->assign("string",$tmp[$this->select_type]);
- if(isset($_POST['string'])){
- $smarty->assign("string",$_POST['string']);
- }
- $smarty->assign("Method","rename");
- $display= $smarty->fetch(get_template_path('glpi_edit_os.tpl', TRUE));
- return($display);
- }
-
- /* Open dialog to edit os types
- */
- if($this->edit_os){
- $smarty->assign("Method","edit");
- $smarty->assign("OSs", $this->handle->getOSTypes());
- $smarty->assign("OSKeys", array_flip($this->handle->getOSTypes()));
- $display= $smarty->fetch(get_template_path('glpi_edit_os.tpl', TRUE));
- return($display);
- }
-
-
-
- /* Show dialog to select a new contact person
- * Select a contact person
- */
- if(isset($_POST['SelectContactPerson']) && $this->acl_is_writeable("contact_num")){
- $this->addUser = "contact";
- $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
- $this->cur_dialog->set_acl_category(preg_replace("/\//","",$this->acl_category));
- $this->cur_dialog->set_acl_base($this->dn);
-
- }
-
- /* Open dialog which allows to edit the manufacturers
- */
- if(isset($_POST['edit_manufacturer']) && $this->acl_is_writeable("FK_glpi_enterprise")){
- $this->cur_dialog = new glpiManufacturer($this->config,$this->dn);
- $this->dialog = true;
- }
-
- /* Close manufacturer editing dialog
- */
- if(isset($_POST['close_edit_manufacturer'])){
- $this->dialog = false;
- $this->cur_dialog = false;
- }
-
- /* Abort user selection
- */
- $smarty->assign("AbortSelectUser","SelectUserCancel");
- if(isset($_POST['SelectUserCancel'])){
- $this->dialog = false;
- $this->addUser ="";
- $this->cur_dialog = false;
- }
-
- /* Selecte technical responsible person
- */
- if(isset($_POST['SelectTechPerson']) && $this->acl_is_writeable("tech_num")){
- $this->addUser ="tech";
- $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
- $this->cur_dialog->set_acl_category(preg_replace("/\//","",$this->acl_category));
- $this->cur_dialog->set_acl_base($this->dn);
- }
-
- /* Technical responsible person selected*/
- if(isset($_GET['act'])&&($_GET['act']=="user_tech_num")&&(strlen($_GET['id']) > 100)){
- print_red(sprintf(_("Could not add the given user, the users dn is too long, only 100 characters are allowed here.")));
-
- }elseif(isset($_GET['act'])&&($_GET['act']=="user_tech_num") && strlen($_GET['id'])){
-
-
- /* Get posted id */
- $id = base64_decode($_GET['id']);
-
- /* Check if user is already created in glpi database */
- if(!in_array($id,$users)){
-
- /* If this user doesn't exists in glpi db, we must create him */
- $ldap->cat($id, array('cn', 'mail', 'telephoneNumber'));
- $atr = $ldap->fetch();
- $tmp = array();
- $use = array( "cn" =>"name",
- "mail" =>"email",
- "telephoneNumber" =>"phone");
-
- /* Create array */
- foreach($use as $gosa => $glpi){
- if(isset($atr[$gosa])){
- $tmp[$glpi]= $atr[$gosa][0];
- }
- }
-
- /* Add this user */
- $this->handle->addUser($tmp,$id);
- }
-
- /* Re-read users */
- $users = ($this->handle->getUsers());
-
- /* Get user */
- $tmp = array_flip($users);
- $id=$tmp[$id];
-
- /* Use user id, close dialog */
- if($this->addUser == "tech"){
- $this->tech_num = $id;
- }else{
- $this->contact_num = $id;
- }
- $this->cur_dialog = false;
- $this->dialog= false;
- }
-
- /* if( cur_dialog != false || cur_dialog != NULL)
- * There is a dialog which wants to be displayed
- */
- if(isset($this->cur_dialog) && is_object($this->cur_dialog)){
- $this->cur_dialog->save_object();
- $this->dialog=true;
- $this->cur_dialog->parent = &$this;
- return($this->cur_dialog->execute());
- }else{
- $this->dialog= false;
- }
-
- /* Assign smarty defaults */
- foreach(array("SystemTypes","SystemTypeKeys","Manufacturers","OSs","TechnicalResponsibles","InstalledDevices","Attachments") as $attr){
- $smarty->assign($attr,array());
- }
-
- /* Assign some vars to smarty
- */
- foreach(array("type","FK_glpi_enterprise","os","tech_num","contact_num","Attachments","InstalledDevices") as $attr){
- $smarty->assign($attr,"");
- }
-
- /* 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;
- }
- }
-
- /* Show tab dialog headers */
- if ($this->is_account){
- $display= $this->show_disable_header(_("Remove inventory"),
- _("This device has inventory informations enabled. You can disable them by clicking below."));
- } else {
- $display= $this->show_enable_header(_("Add inventory"),
- _("This device has inventory informations disabled. You can enable them by clicking below."));
- return ($display);
- }
-
- /* Assign system types
- */
- $smarty->assign("SystemTypeKeys", array_flip($this->handle->getSystemTypes()));
- $smarty->assign("SystemTypes", $this->handle->getSystemTypes());
- $smarty->assign("type", $this->type);
-
- /* Assign os types
- */
- $smarty->assign("OSKeys", array_flip($this->handle->getOSTypes()));
- $smarty->assign("OSs", $this->handle->getOSTypes());
- $smarty->assign("os", $this->os);
-
- /* Dispaly installed devices */
- $smarty->assign("InstalledDevices" ,$this->getDevices());
- $smarty->assign("InstalledDeviceKeys" ,array_flip($this->getDevices()));
-
- /* Append manufacturers
- */
- $smarty->assign("ManufacturerKeys", array_flip($this->handle->getEnterprises()));
- $smarty->assign("Manufacturers", $this->handle->getEnterprises());
- $smarty->assign("FK_glpi_enterprise", $this->FK_glpi_enterprise);
-
- /* Assign used Attachments
- */
-
- $divlist = new divSelectBox("glpiAttachmentsList");
- $divlist-> SetHeight(130);
- $atts = $this->getUsedAttachments(true);
- $downlink = "%s ";
- $del_link = " ";
- foreach($atts as $id => $attachment){
- $divlist->AddEntry
- (
- array(
- array("string"=>$attachment['name']),
- array("string"=>$attachment['mime']),
- array("string"=>sprintf($downlink,$id,$attachment['filename'])),
- array("string"=>sprintf($del_link,$attachment['ID']),"attach"=>"style='border-right:0px;'"),
- )
- );
- }
-
- $smarty->assign("AttachmentsDiv" ,$divlist->DrawList());
- /* Handle contact person
- Assign name ... to smarty, if set
- */
- if(isset($users[$this->contact_num])){
- $ldap->cat($users[$this->contact_num], array('givenName', 'sn', 'uid'));
- $tr = $ldap->fetch();
- $str = "";
- if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; }
- if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; }
- if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; }
- $smarty->assign("contact_num", $str);
- }else{
- $smarty->assign("contact_num", _("N/A"));
- }
-
- /* Handle tech person
- Assign name ... to smarty, if set
- */
- if(isset($users[$this->tech_num])){
- $tr = $ldap->cat($users[$this->tech_num], array('givenName', 'sn', 'uid'));
- $tr = $ldap->fetch();
- $str = "";
- if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; }
- if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; }
- if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; }
- $smarty->assign("tech_num", $str);
- }else{
- $smarty->assign("tech_num", _("N/A"));
- }
- $smarty->assign("comments", $this->comments);
-
- $display.= $smarty->fetch(get_template_path('glpi.tpl', TRUE));
- return($display);
- }
-
- function remove_from_parent()
- {
- /* Cancel if there's nothing to do here */
- if ((!$this->initially_was_account) || (!$this->acl_is_removeable())){
- return;
- }
- if(function_exists("mysql_pconnect")){
- $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
- if($this->initially_was_account){
- $this->handle->removeComputerInformations($this->dn);
- new log("remove","undefined/".get_class($this),$this->dn);
- }
- }else{
- print_red(_("Can't remove glpi account, while mysql extension is missing."));
- new log("remove","undefined/".get_class($this),$this->dn,array(),_("Can't remove glpi account, while mysql extension is missing."));
- }
-
- }
-
- function getDevices(){
- $ret = array();
- foreach($this->usedDevices as $type => $entries){
- foreach($entries as $ent){
- if(isset($ent['designation'])){
- $ret[] = $ent['designation']." [".$type."]";
- }else{
- $ret[] = $ent['name']." [".$type."]";
- }
- }
- }
- return($ret);
- }
-
-
- /* Save data to object */
- function save_object()
- {
- if(!isset($_POST['glpi_tpl_posted'])) {
- return ;
- }
- plugin::save_object();
- }
-
-
- /* Check supplied data */
- function check()
- {
- /* Call common method to give check the hook */
- $message= plugin::check();
-
- // if($this->TechnicalResponsible == ""){
- // $message[] = _("Please select a technical responsible person for this entry.");
- // }
-
- return ($message);
- }
-
-
- /* Save to LDAP */
- function save()
- {
- if($this->is_account){
- $attrs = array();
- $this->date_mod = date("Y-m-d H:i:s");
- foreach($this->attributes as $attr){
- $attrs[$attr] = $this->$attr;
- }
- $attrs['name'] = $this->dn;
- unset($attrs['ID']);
- $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
-
- /* check if we have to update, add */
- if($this->initially_was_account&&$this->is_account){
- $this->handle->updateComputerInformations($attrs,$this->orig_dn);
- new log("modify","undefined/".get_class($this),$this->dn);
- }elseif($this->is_account){
- $this->handle->addComputerInformations($attrs,$this->dn);
- new log("create","undefined/".get_class($this),$this->dn);
- }
- $tmp = $this->handle->getComputerInformations($this->dn);
- $this->handle->addDevicesToComputer($this->usedDevices,$tmp[0]['ID']);
- }
- }
-
-
- /* Return used attachments */
- function getUsedAttachments($divlist = false)
- {
- $atts =$this->handle->getAttachments();
- $ret = array();
- foreach($atts as $entry){
- if(in_array($entry['ID'],$this->usedAttachments)){
- if($divlist){
- $ret[$entry['ID']] = $entry;
- }else{
- $cm ="";
- if(isset($entry['comment'])){
- $cm=" [".$entry['comment']."]";
- }
- if(isset($entry['mime'])){
- $cm.=" -".$entry['mime']."";
- }
-
- $ret[$entry['ID']]= $entry['name'].$cm;
- }
- }
- }
- return($ret);
- }
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Glpi"),
- "plDescription" => _("Inventory extension"),
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 20,
- "plSection" => array("administration"),
- "plCategory" => array("workstation","terminal","component","server","phone") ,
- "plProvidedAcls"=> array(
-
- "tech_num" => _("Technical responsible"),
- "comments" => _("Comment"),
- "os" => _("Operating system"),
- "location" => _("Location"),
- "contact_num" => _("Contact person"),
- "model" => _("Model"),
- "type" => _("Type"),
- "FK_glpi_enterprise" => _("Manufacturer"),
- "Attachments" => _("Attachments"),
- "Devices" => _("Peripheral devices"))
- ));
- }
-
-
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_glpiAttachmentPool.inc b/plugins/admin/systems/class_glpiAttachmentPool.inc
deleted file mode 100644
index b50066029..000000000
--- a/plugins/admin/systems/class_glpiAttachmentPool.inc
+++ /dev/null
@@ -1,362 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* attribute list for save action */
- var $ignore_account = TRUE;
- var $attributes = array("name","comment","mime","filename","date_mod");
- var $objectclasses = array("whatever");
-
- var $parent;
- var $edit = false;
- var $entry = false;
- var $date_mod ="";
- var $name ="";
- var $comment ="";
- var $mime ="";
- var $filename ="";
-
- var $Selected = array();
-
- var $delAttach= "";
-
- function glpiAttachmentPool (&$config, $dn= NULL,$used=NULL)
- {
- plugin::plugin ($config, $dn);
- if(!isset($_SESSION['GlpiAttachmentFilter'])){
- $_SESSION['GlpiAttachmentFilter'] = array("filter"=>"*");
- }
-
- /* Assign used attributes */
- if($used !== NULL){
- $this->Selected = $used;
- }
- }
-
- function execute()
- {
- plugin::execute();
- $attach = $this->parent->handle->getAttachments();
- /* Fill templating stuff */
- $smarty = get_smarty();
- $display = "";
- $only_once = true;
-
- /* walk through all posted objects */
- foreach($_POST as $name => $value){
-
- /* Open dialog to create a new entry */
- if(preg_match("/new_attach/",$name)){
- $this->edit = true;
- $this->entry=array();
-
- /* Set default values */
- foreach($this->attributes as $attr) {
- $this->$attr = "";
- $this->entry[$attr]="";
- }
- }
-
- /* Remove attach*/
- if((preg_match("/^delAttach_/",$name))&&($only_once)){
- $only_once = false;
- $str = preg_replace("/^delAttach_/","",$name);
- $str = base64_decode(preg_replace("/_.*$/","",$str));
-
- /* remove attach from db */
- $this->delAttach = $str;
- $smarty->assign("warning", sprintf(_("You're about to delete the glpi attachment component '%s'."), $attach[$str]['name']));
- return($smarty->fetch(get_template_path('remove_glpi.tpl', TRUE)));
- }
-
- /* Start editing entry */
- if((preg_match("/^editAttach_/",$name))&&($only_once)){
- $only_once = false;
- $str = preg_replace("/^editAttach_/","",$name);
- $str = base64_decode(preg_replace("/_.*$/","",$str));
-
- /* Check if we have an attachment with given ID */
- foreach($attach as $att ){
- if($att['ID'] == $str ){
-
- /* Entry was found, show dialog */
- $this->edit = true;
- $this->entry = $att;
-
- foreach($att as $name => $value){
- $this->$name = $value;
- }
- }
- }
- }
- }
-
- if((isset($_POST['delete_glpi_confirm']))&&(isset($attach[$this->delAttach]))){
- if($this->parent->handle->is_attachmentUsed($this->delAttach)){
- $tmp = $this->parent->handle->is_attachmentUsed($this->delAttach);
-
- $names = "";
- foreach($tmp as $name){
- $names .= ", ".$name;
- }
- $names = preg_replace("/^, /","",$names);
- $names = trim($names);
- if(count($tmp) == 3){
- $names .= " ...";
- }
- print_red(sprintf(_("You can't delete this attachment, it is still in use by these system(s) '%s'"),$names));
-
- }else{
- $this->parent->handle->deleteAttachment($this->delAttach);
- @unlink(CONFIG_DIR."/glpi/".$this->filename);
- $attach = $this->parent->handle->getAttachments();
- }
- }
-
- /* Someone tries to upload a file */
- if(($this->edit == true)&&(isset($_POST['upload']))){
- if(!isset($_FILES['filename'])){
- print_red(_("There is no valid file uploaded."));
- }else{
- $FILE = $_FILES['filename'];
- if(!isset($FILE['name'])){
- print_red(_("There is no valid file uploaded."));
- }else{
- if($FILE['error']!=0) {
- print_red(_("Upload wasn't successfull."));
- }else{
- if(!is_dir(CONFIG_DIR."/glpi/")){
- print_red(sprintf(_("Missing directory '%s/glpi/' to store glpi uploads."),CONFIG_DIR));
- }else{
- $filen = CONFIG_DIR."/glpi/".$FILE['name'];
- if(file_exists($filen)){
- print_red(_("There is already a file with the same name uploaded."));
- }else{
- $fh = fopen($filen,"w");
- if(!$fh){
- print_red(sprintf(_("Can't create file '%s'."),$filen));
- }else{
- $str = file_get_contents($FILE['tmp_name']);
- fwrite($fh,$str,strlen($str));
- fclose($fh);
- $this->mime = $FILE['type'];
- $this->filename = $FILE['name'];
- }
- } // File already exists
- }
- } // Check if any error occurred
- } // check if valid filename was uploaded
- } // ende check if file was uploaded
- }// upload post
-
- /* save attachment*/
- if(($this->edit == true)&&(isset($_POST['SaveAttachment']))){
- if(count($this->check())==0){
- $this->date_mod = date("Y-m-d H:i:s");
- $this->save_entry();
- $this->edit= false;
- $this->entry = array();
- $attach = $this->parent->handle->getAttachments();
- }else{
- foreach($this->check() as $msg){
- print_red($msg);
- }
- }
- }
-
- /* Abort editing/adding attachment*/
- if(($this->edit == true)&&(isset($_POST['CancelAttachment']))){
- $this->edit = false;
- $this->entry = array();
- }
-
- /* If edit == true, we have to show a dialog to edit or add an attach
- */
- if($this->edit == true){
- foreach($this->attributes as $attr){
- $smarty->assign($attr,htmlentities(utf8_decode($this->$attr)));
- }
- if(!empty($this->filename)){
- if(is_readable(CONFIG_DIR."/glpi/".$this->filename)){
- $status =_("File is available.");
- }else{
- $status =_("File is not readable, possibly the file is missing.");
- }
- }else{
- $status = _("Currently no file uploaded.");
- }
- $smarty->assign("status",$status);
- return($smarty->fetch(get_template_path('glpiAttachmentEdit.tpl', TRUE)));
- }
-
- /* Create list with checkboxes to select / deselect some attachents */
- $divlist = new divlist("Attachment");
- $divlist->SetPluginMode();
- $divlist->SetHeader(array(
- array("string" => " ", "attach" => "style='text-align:center;width:20px;'"),
- array("string" => _("Name")),
- array("string" => _("Mime"),"attach"=>"style='width:200px;'"),
- array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" )));
-
- $divlist->SetSummary(_("This table displays all available attachments."));
- $divlist->SetEntriesPerPage(0);
-
- $editdel = " ";
- $editdel.= " ";
-
- /* Add all given attachments to divlist
- */
- foreach($attach as $entry){
-
- /* Create display name*/
- if((empty($entry['name']))||(empty($entry['comment']))){
-
- /* In glpi it is possible to add entries without name
- so i've added this block
- */
- if(empty($entry['name'])){
- $str1 = ""._("empty")." ";
- }else{
- $str1 = $entry['name'];
- }
-
- if(!empty($entry['comment'])){
- $str1.= " [".$entry['comment']."]";
- }
- }else{
- /* Both attributes given */
- $str1 = $entry['name']." [".$entry['comment']."]";
- }
-
- $edit = str_replace("%s",base64_encode($entry['ID']),$editdel);
- $str2 = $entry['mime']." ";
-
- $chkbox = " ".
- " ";
-
- if(in_array($entry['ID'],$this->Selected)){
- $chkbox = preg_replace("/%CHECKED%/"," checked ",$chkbox);
- }else {
- $chkbox = preg_replace("/%CHECKED%/"," ",$chkbox);
- }
- $chkbox = preg_replace("/%s/",$entry['ID'],$chkbox);
- $divlist->AddEntry(array(
- array("string" => $chkbox,
- "attach" => "style='text-align:center;width:20px;'"),
- array("string"=> $str1),
- array("string"=> $str2,"attach"=>"style='width:200px;'"),
- array("string"=> $edit ,"attach" => "style='width:60px;border-right:0px;text-align:right;'")
- ));
-
- }
-
- $listhead = "".
- " ".
- "
";
-
- $smarty->assign("attachments", $divlist->DrawList());
- $smarty->assign("attachmenthead", $listhead);
- $smarty->assign("search_image", get_template_path('images/search.png'));
- $smarty->assign("searchu_image", get_template_path('images/search_user.png'));
- $smarty->assign("tree_image", get_template_path('images/tree.png'));
- $smarty->assign("infoimage", get_template_path('images/info_small.png'));
- $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
- $smarty->assign("apply", apply_filter());
- $smarty->assign("alphabet", generate_alphabet());
- $smarty->assign("attachment_regex", $_SESSION['GlpiAttachmentFilter']['filter']);
-
- $display.= $smarty->fetch(get_template_path('glpiAttachmentPool.tpl', TRUE));
- return($display);
- }
-
- function save()
- {
- return($this->Selected);
- }
-
- /* Adds new or saves edited entries */
- function save_entry()
- {
- if($this->edit){
- $tmp = array();
- foreach($this->attributes as $attr){
- $tmp[$attr] = $this->$attr;
- }
- $id = -1;
- if(isset($this->entry['ID'])){
- $id = $this->entry['ID'];
- }
- $this->parent->handle->saveAttachments($tmp,$id);
- }
- }
-
- function save_object()
- {
- foreach($this->attributes as $attr){
- if(isset($_POST[$attr])){
- $this->$attr = $_POST[$attr];
- }
- }
-
- /* Checkboxes are only posted, if they are checked
- * To check if it was deselected, we check if wasOnPage
- * was posted with given name, so we can deselect this entry
- */
-
- foreach($_POST as $name => $value){
- if(preg_match("/wasOnPage_/",$name)){
- $id=preg_replace("/wasOnPage_/","",$name);
- if(isset($_POST["useMe_".$id])){
- $this->Selected[$id]=$id;
- }else{
- if(isset($this->Selected[$id])){
- unset($this->Selected[$id]);
- }
- }
- }
- }
- }
-
- /* Simple check */
- function check()
- {
- /* Call common method to give check the hook */
- $message= plugin::check();
-
- if($this->edit){
-
- /* check if given name is already in use */
- $att = $this->parent->handle->getAttachments();
- $ok = true;
- $this->name=trim($this->name);
-
- foreach($att as $val){
- if(!isset($this->entry['ID'])){
- if($val['name'] == $this->name){
- $ok = false;
- }
- }else{
- if(($val['name'] == $this->name)&&($this->entry['ID'] != $val['ID'])){
- $ok = false;
- }
- }
- }
- if(!$ok){
- $message[] = _("This name is already in use.");
- }
- if(empty($this->name)){
- $message[] = _("Please specify a valid name for this attachment.");
- }
- }
- return($message);
- }
-
-}// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_glpiDeviceManagement.inc b/plugins/admin/systems/class_glpiDeviceManagement.inc
deleted file mode 100644
index 0f24300d8..000000000
--- a/plugins/admin/systems/class_glpiDeviceManagement.inc
+++ /dev/null
@@ -1,427 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* attribute list for save action */
- var $ignore_account= TRUE;
- var $attributes= array();
- var $objectclasses= array("whatever");
-
- var $devices = array();
- var $ui;
-
- var $parent ;
- var $EditEntry;
- var $editMode =false;
-
- var $DeviceAttrs = array();
- var $AllowedDevices = array();
-
- var $Selected = array();
-
- var $delete = array();
-
- function glpiDeviceManagement (&$config, $dn= NULL,$used=NULL)
- {
- plugin::plugin ($config, $dn);
-
- if(!isset($_SESSION['glpiDeviceRegex'])){
- $tmp['device_regex'] = "*";
- $_SESSION['glpiDeviceRegex'] = $tmp;
- }
- $this->ui = get_userinfo();
-
- if(isset($used)){
- $this->Selected = $used;
- }
-
- /* Specify which vars are allowed for a sepcific type of device */
- $this->DeviceAttrs['case'] = array("designation","format","comment","FK_glpi_enterprise");
- $this->DeviceAttrs['moboard'] = array("designation","chipset","comment","FK_glpi_enterprise");
- $this->DeviceAttrs['processor'] = array("designation","frequence","comment","FK_glpi_enterprise","specif_default");
- $this->DeviceAttrs['iface'] = array("designation","bandwidth","comment","FK_glpi_enterprise","specif_default");
- $this->DeviceAttrs['ram'] = array("designation","frequence","comment","FK_glpi_enterprise","specif_default","type");
- $this->DeviceAttrs['hdd'] = array("designation","rpm","interface","cache","comment","FK_glpi_enterprise","specif_default");
- $this->DeviceAttrs['drive'] = array("designation","speed","interface","is_writer","comment","FK_glpi_enterprise","specif_default");
- $this->DeviceAttrs['control'] = array("designation","interface","raid","comment","FK_glpi_enterprise");
- $this->DeviceAttrs['gfxcard'] = array("designation","ram","interface","comment","FK_glpi_enterprise","specif_default");
- $this->DeviceAttrs['sndcard'] = array("designation","type","comment","FK_glpi_enterprise","specif_default");
- $this->DeviceAttrs['power'] = array("designation","power","comment","FK_glpi_enterprise","atx");
- $this->DeviceAttrs['pci'] = array("designation","comment","FK_glpi_enterprise","specif_default");
- $this->DeviceAttrs['monitor'] = array("name","comments","serial","otherserial","size",
- "flags_micro","flags_speaker","flags_subd","flags_bnc",
- "location","type","FK_glpi_enterprise","is_global","deleted","is_template","tplname");
-
- $this->AllowedDevices=array("case","moboard","sndcard","processor","iface","ram","hdd","drive","control","gfxcard","power","pci","monitor");
- }
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- /* Get all defined devices */
- $this->reload();
-
- /* Fill templating stuff */
- $smarty= get_smarty();
- $display= "";
-
- /* this var is used to ensure that every post is only performed once */
- $only_once = true;
-
- /* Check Post for some actions */
- foreach($_POST as $name => $value){
-
- /* If new_ then we should create an new device */
- if((preg_match("/^new_/",$name))&&($only_once)){
-
- /* don't do this twice */
- $only_once = false;
-
- /*extract device device_type */
- $deviceType = preg_replace("/_.*$/","",preg_replace("/^new_/","",$name));
-
- /* Check if type is allowed, and create empty entry */
- $tmp = array();
- if((!isset($this->DeviceAttrs[$deviceType]))||((!in_array($deviceType,$this->AllowedDevices)))){
- print_red(sprintf(_("Internal Error can't create device of type '%s'"),$deviceType));
- }else{
- foreach($this->DeviceAttrs[$deviceType] as $attr){
- $tmp[$attr] = "";
- }
- $tmp['device_type'] = $deviceType;
- $this->EditEntry = $tmp;
- $this->editMode =true;
- }
- }
- }
-
- /* delete was requested ... show dialog */
- if((isset($_GET['act']))&&($_GET['act']=="del_device")){
- $id = base64_decode($_GET['id']);
- $tmp = $this->devices[$id];
-
- $this->delete = $tmp;
-
- if(isset($tmp['name'])){
- $smarty->assign("warning", sprintf(_("You're about to delete the glpi device '%s'."), $tmp['name']));
- }elseif(isset($tmp['designation'])){
- $smarty->assign("warning", sprintf(_("You're about to delete the glpi device '%s'."), $tmp['designation']));
- }else{
- print_red(_("Can't detect object name."));
- }
-
- return($smarty->fetch(get_template_path('remove_glpi.tpl', TRUE)));
- }
-
- /* Delete entry, but check if this device is in currently in use */
- if(isset($_POST['delete_glpi_confirm'])){
- if(count($this->parent->handle->is_deviceUsed($this->delete))){
-
- $tmp = $this->parent->handle->is_deviceUsed($this->delete);
-
- $names = "";
- foreach($tmp as $name){
- $names .= ", ".$name;
- }
- $names = preg_replace("/^, /","",$names);
- $names = trim($names);
- if(count($tmp) == 3){
- $names .= " ...";
- }
- print_red(sprintf(_("You can't delete this device, it is still in use by these system(s) '%s'"),$names));
- }else{
- $this->parent->handle->deleteDevice($this->delete);
- $this->reload();
- }
- }
-
- /* Open entry for editing if requested */
- if((isset($_GET['act']))&&($_GET['act']=="edit_device")){
- $id = base64_decode($_GET['id']);
- $this->editMode =true;
- $this->EditEntry = $this->devices[$id];
- }
-
- /* Abort editing this entry */
- if(isset($_POST['AbortDeviceChanges'])){
- $this->EditEntry = array();
- $this->editMode = false;
- }
-
- /* Save all changes made on currently selected entry */
- if(isset($_POST['SaveDeviceChanges'])){
-
- /* First check if all changes made are allowed */
- if(count($this->check())==0){
- $this->save();
- $this->editMode = false;
- $this->reload();
- }else{
- foreach($this->check() as $msg){
- print_red($msg);
- }
- }
-
- }
-
- /* Check if we are currently editing something ? */
- if($this->editMode == true){
- return ($this->editDevice($this->EditEntry));
- }
-
- /* ENDE : GET / POST handling
- * Below, only output generation for headpage
- */
-
- $divlist = new divlist("glpi devices");
- $divlist->SetPluginMode();
- $divlist->SetEntriesPerPage(0);
- $divlist->SetHeader(array(
- array("string" => " ", "attach" => "style='text-align:center;width:20px;'"),
- array("string" => _("devices"), "attach" => "style=''"),
- array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" )));
-
- $edit = "%s ";
- $editdel = " ";
- $editdel.= " ";
-
- $useDevice = " ";
-
- foreach($this->devices as $key=>$user){
-
- if(isset($user['designation'])){
- $str = "designation";
- }else{
- $str = "name";
- }
-
- if(isset($this->Selected[$user['device_type']][$user[$str]])){
- $use = " checked ";
- }else{
- $use ="";
- }
-
- /* Dawn databse struckture ....*/
- if(empty($user['comment']) && isset($user['comments'])) {
- $user['comment'] = $user['comments'];
- }
-
- $field1 = array("string" => preg_replace("/%s/",base64_encode($key),preg_replace("/%USE%/",$use,$useDevice)), "attach" => "style='text-align:center;width:20px;'");
- $field2 = array("string" => sprintf($edit,base64_encode($key),$user[$str]." [".$user['comment']."]"), "attach" => "style=''");
- $field3 = array("string" => sprintf($editdel,base64_encode($key),base64_encode($key)),
- "attach" => "style='width:60px;border-right:0px;text-align:right;'");
- $divlist->AddEntry(array($field1,$field2,$field3));
-
- }
-
- $listhead = "".
- " ".
- " ".
- " ".
- " ".
- " ".
- " ".
- " ".
- " ".
- " ".
- " ".
- " ".
- " ".
- " ".
- "
";
-
- $filter= $_SESSION['glpiDeviceRegex'];
- $smarty->assign("devicehead", $listhead);
- $smarty->assign("devices", $divlist->DrawList());
- $smarty->assign("search_image", get_template_path('images/search.png'));
- $smarty->assign("searchu_image", get_template_path('images/search_user.png'));
- $smarty->assign("tree_image", get_template_path('images/tree.png'));
- $smarty->assign("infoimage", get_template_path('images/info_small.png'));
- $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
- $smarty->assign("apply", apply_filter());
- $smarty->assign("alphabet", generate_alphabet());
- $smarty->assign("device_regex", $filter['device_regex']);
-
- $display.= $smarty->fetch(get_template_path('glpiDeviceManagement.tpl', TRUE));
- return($display);
- }
-
- /* Save device to glpi database
- * If this is a new device, create a new entry, else update this entry
- */
- function save()
- {
- if($this->parent->handle->deviceExists($this->EditEntry)){
- $this->parent->handle->updateDevices($this->EditEntry);
- }else{
- $this->parent->handle->addDevice($this->EditEntry);
- }
-
- }
-
- /* this only gets all already defined devices */
- function reload()
- {
- $this->devices = $this->parent->handle->getDevices();
- ksort($this->devices);
- }
-
- /* This funtions saves all POST variables.
- The variable must be in the array $this->EditEntry
- */
- function save_object()
- {
- foreach($_POST as $name => $value){
-
- if(preg_match("/wasOnPage_/",$name)){
- $dN = base64_decode($value);
-
- $device = $this->devices[$dN];
- $type = $device['device_type'];
-
- if(isset($device['designation'])){
- $str = "designation";
- }else{
- $str = "name";
- }
-
- if(isset($_POST['useDevice_'.$value])){
- $this->Selected[$type][$device[$str]] = $device;
- }else{
- if(isset($this->Selected[$type][$device[$str]])){
- unset($this->Selected[$type][$device[$str]]);
- }
- }
- }
- }
-
- if(is_array($this->EditEntry)){
- foreach($this->EditEntry as $name => $value){
- if(isset($_POST[$name])){
- $this->EditEntry[$name] = $_POST[$name];
- }
-
- }
- }
- }
-
- /* returns the selected devices */
- function getSelected()
- {
- return($this->Selected);
- }
-
- /* This function checks all created devices.
- If you wan't to use device specific checks,
- use >>if($attr['device_type']=="moboard")<< to create a device type depending check
- */
- function check()
- {
- /* Call common method to give check the hook */
- $message= plugin::check();
-
- $attr = $this->EditEntry;
-
- if(isset($attr['designation'])){
- $str2 = "designation";
- }else{
- $str2 = "name";
- }
- if(empty($attr[$str2])){
- $message[]=(_("You have to specify a valid name for this device."));
- }
-
- /* Avoid same name twice */
- $devices = ($this->parent->handle->getDevices());
- foreach($devices as $dev){
-
- /* Some devices use designation some name for name
- */
- if(isset($dev['designation'])){
- $str = "designation";
- }else{
- $str = "name";
- }
-
- if($dev[$str]==$attr[$str2]){
-
- /* Entries with ['ID'] already exists, and are only edited, if ID is missing we are currently creating a new entry */
- if(isset($attr['ID'])){
- if(!(($dev['ID'] == $attr['ID'])&&($dev['device_type']==$attr['device_type']))){
- $message[] = _("This device name is already in use.");
- }
- }else{
- $message[] = _("This device name is already in use.");
- }
- }
- }
-
- return($message);
- }
-
- /* This functions displays the template for all available devices
- * This function is also used if we create a new device
- */
- function editDevice($entry)
- {
- $smarty = get_smarty();
-
- /* Transfer given data to smarty */
- foreach($this->EditEntry as $name => $value){
- $smarty->assign($name,htmlentities(utf8_decode($value)));
- }
-
- /* Set default select boxes, manufacturers ... */
- $smarty->assign("device_type",$entry['device_type']);
-
- $none = array(0 => _("none"));
- $manufacturer = array_merge($none,$this->parent->handle->getEnterprises());
-
- $ramtypes = $this->parent->handle->getRAMTypes();
-
- $smarty->assign("RAMtypes", $ramtypes);
- $smarty->assign("RAMtypeKeys", array_flip($ramtypes));
-
- $deviceControlTypes = array_merge($none,$this->parent->handle->getGlpiDeviceControlTypes());
-
- $smarty->assign("HDDInterfaceKeys",array_flip($deviceControlTypes));
- $smarty->assign("HDDInterfaces" , $deviceControlTypes);
-
- $gfxControlTypes = array("0"=>_("None"),"AGP"=>"AGP","PCI"=>"PCI","PCI-X"=>"PCI-X","Other"=>_("Other"));
-
- $smarty->assign("GFXInterfaceKeys",array_flip($gfxControlTypes));
- $smarty->assign("GFXInterfaces" , $gfxControlTypes);
-
- $smarty->assign("FK_glpi_enterpriseKeys",array_flip($manufacturer));
- $smarty->assign("FK_glpi_enterprises", $manufacturer);
-
- $smarty->assign("formats",array("Large","Medium","Micro"));
- $smarty->assign("formats",array("Large","Medium","Micro"));
-
- $smarty->assign("formats",array("Large","Medium","Micro"));
- $smarty->assign("formatKeys",array('Grand','Moyen','Micro'));
- return($smarty->fetch(get_template_path('glpi_devices.tpl', TRUE)));
- }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_glpiManufacturer.inc b/plugins/admin/systems/class_glpiManufacturer.inc
deleted file mode 100644
index 8e676d8ee..000000000
--- a/plugins/admin/systems/class_glpiManufacturer.inc
+++ /dev/null
@@ -1,170 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* attribute list for save action */
- var $ignore_account= TRUE;
- var $attributes= array("name","type","address","website","phonenumber","comments","deleted","fax","email");
- var $objectclasses= array("whatever");
-
- var $ui;
-
- var $editMode = false;
- var $Edit_Add = "edit";
-
- var $name ="";
- var $type ="";
- var $address ="";
- var $website ="";
- var $phonenumber="";
- var $comments ="";
- var $deleted ="";
- var $fax ="";
- var $email ="";
- var $ID =-1;
-
- function glpiManufacturer(&$config, $dn= NULL, $parent= NULL)
- {
- plugin::plugin ($config, $dn, $parent);
- $this->ui = get_userinfo();
- }
-
- function execute()
- {
- plugin::execute();
- $smarty = get_smarty();
- $display = "";
-
- /* Remove enterprise from db */
- if((isset($_POST['remove_manu']))&&(isset($_POST['manufacturer']))){
-
- $tmp = $this->parent->handle->is_manufacturerUsed($_POST['manufacturer']);
- if(count($tmp)){
-
- $names = "";
- foreach($tmp as $name){
- $names .= ", ".$name;
- }
- $names = preg_replace("/^, /","",$names);
- $names = trim($names);
- if(count($tmp) == 3){
- $names .= " ...";
- }
- print_red(sprintf(_("You can't delete this manufacturer, it is still in use by these system(s) '%s'"),$names));
- }else{
- $this->parent->handle->removeEnterprise($_POST['manufacturer']);
- }
- }
-
- /* Add new Manufactuer : Open dialog with empty fields */
- if(isset($_POST['add_manu'])){
- $this->editMode = true;
- $this->Edit_Add = "add";
- foreach($this->attributes as $atr){
- $this->$atr = "";
- }
- }
-
- /* Edit existing manuatctuerer data */
- if((isset($_POST['edit_manu']))&&(isset($_POST['manufacturer']))){
- $this->editMode = true;
- $this->Edit_Add = "edit";
- $tmp = $this->parent->handle->getEnterprise($_POST['manufacturer']);
- $tmp = $tmp[0];
- foreach($this->attributes as $atr){
- $this->$atr = "";
- }
- foreach($this->attributes as $atr){
- if(isset($tmp[$atr])){
- $this->$atr = $tmp[$atr];
- }
- }
- $this->ID = $_POST['manufacturer'];
- }
-
- /* close Dialog without saving */
- if(isset($_POST['close_manufacturer'])){
- $this->editMode=false;
- }
-
- /* close dialog an save all changes / adds */
- if(isset($_POST['save_manufacturer'])){
- $tmp = array();
- foreach($this->attributes as $attrs){
- $tmp[$attrs]=$this->$attrs;
- }
-
- $allok = true;
- if(empty($tmp['name'])){
- print_red(_("Please specify a name."));
- $allok = false;
- }
-
- $attr = $this->parent->handle->getEnterprises();
-
- if($this->ID == -1 ){
- if(in_array($tmp['name'],$attr)){
- $allok = false;
- print_red(_("Specified name is already in use, please choose another one."));
- }
- }else{
- unset($attr[$this->ID]);
- if(in_array($tmp['name'],$attr)){
- $allok = false;
- print_red(_("Specified name is already in use, please choose another one."));
- }
- }
-
- /* all checks are ok , so save changes */
- if($allok){
- if($this->Edit_Add == "add"){
- $this->parent->handle->addEnterprise($tmp);
- $this->editMode=false;
- }else{
- $this->parent->handle->updateEnterprise($tmp,$this->ID);
- $this->editMode=false;
- }
- }
- }
-
- /* As long as this war is true, we have to display the edit dialog */
- if($this->editMode == true){
- $this->save_object();
- foreach($this->attributes as $attrs){
- $smarty->assign($attrs,$this->$attrs);
- }
-
- $display.= $smarty->fetch(get_template_path('glpiManufacturerAdd.tpl', TRUE));
- return($display);
- }
-
-
- $smarty->assign("Manus", $this->parent->handle->getEnterprises());
- $smarty->assign("ManuKeys", array_flip($this->parent->handle->getEnterprises()));
- $display.= $smarty->fetch(get_template_path('glpiManufacturer.tpl', TRUE));
- return($display);
- }
-
- /* Save to LDAP */
- function save()
- {
- }
-
- function save_object()
- {
- foreach($this->attributes as $attr){
- if(isset($_POST[$attr])){
- $this->$attr = stripslashes($_POST[$attr]);
- }
- }
- }
-
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_glpiPrinterAccount.inc b/plugins/admin/systems/class_glpiPrinterAccount.inc
deleted file mode 100644
index 049249cd5..000000000
--- a/plugins/admin/systems/class_glpiPrinterAccount.inc
+++ /dev/null
@@ -1,807 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* attribute list for save action */
- var $ignore_account= FALSE;
- var $attributes= array("ID","name","contact","ramSize","flags_serial","flags_par","flags_usb",
- "tech_num","comments","date_mod","location","domain","network","contact_num","serial","otherserial",
- "type","is_template","FK_glpi_enterprise","deleted");
-
- var $ID ; // Is set if this entry is edited
- var $name = ""; // This should be the dn of this entry
- var $FK_glpi_enterprise = 0; // Manufacturer id
- var $tech_num = ""; // Technical responsible person
- var $contact_num = ""; // Contact person
-
- var $comments = ""; // Comment
-
- var $type = 0; // printer type id
- var $serial = "";
- var $otherserial = "";
- var $ramSize = 0;
- var $flags_serial = false;
- var $flags_par = false;
- var $flags_usb = false;
-
- var $date_mod = ""; // Modification timestamp
-
- var $location = 0; // Not used yet
- var $domain = 0; // ? Set to 0
- var $network = 0; // ? Set to 0
-
- var $is_template = 0; // Used as template ?
- var $contact = ""; // Empty
- var $deleted = "N"; // Deleted entries should have this set to Y
-
- var $rename = false;
- var $select_type ;
-
- var $editManufacturer = false;
-
- /* Not necessary, cause we use mysql databse */
- var $objectclasses= array("whatever");
-
- /* Used to remember if this was an account (simply: is this an edited entry) */
- var $initially_was_account = false;
-
- /* Remember current dialog */
- var $edit_type = false;
- var $edit_os = false;
-
- var $data;
- var $handle = NULL; // Glpi class handle used to query database
-
- var $cur_dialog = NULL; // This contains the sub dialog handle
-
- var $orig_dn; // To check if dn, has changed
- var $ui; // Some GOsa specific user informations
-
- var $usedDevices = array(); // Which devices are currently selected
- var $usedAttachments = array(); // Used Attachments
- var $usedCartridges = array(); // Used Cartridges
-
- var $view_logged = FALSE;
-
- /* Contructor
- Sets default values and checks if we already have an existing glpi account
- */
- function glpiPrinterAccount (&$config, $dn= NULL, $parent= NULL)
- {
- plugin::plugin ($config, $dn, $parent);
- $this->ui= get_userinfo();
-
- $this->is_account = false;
-
- /* Abort class construction, if no db is defined */
- if(!isset($this->config->data['SERVERS']['GLPI'])){
- return;
- }
-
- // Get informations about databse connection
- $this->data = $this->config->data['SERVERS']['GLPI'];
-
- // Abort if mysql extension is missing
- if(!is_callable("mysql_connect")){
- return;
- }
-
- // Create handle of glpi class, and check if database connection is established
- $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
-
- if(!$this->handle->is_connected){
- return;
- }
-
- // If this dn is already used in database, then get all informations for this entry
- if($this->handle->is_printer_account($this->dn)){
- $this->is_account = true;
- $tmp = ($this->handle->getPrinterInformations($this->dn));
-
- foreach(array("tech_num","FK_glpi_enterprise","type","comments","contact_num","flags_serial","flags_par","flags_usb","ramSize") as $attr){
- $this->$attr = $tmp[0][$attr];
- }
-
- $atts = $this->handle->getAssignPrinterAttachments($tmp[0]['ID']);
- foreach($atts as $attachment){
- $this->usedAttachments[$attachment['FK_doc']]=$attachment['FK_doc'];
- }
-
- $cart= $this->handle->getUsedCartridges($tmp[0]['ID']);
- foreach($cart as $key => $cartridge){
- $this->usedCartridges[$key]=$cartridge;
- $this->usedCartridges[$key]['status']="exists";
- }
-
-
- }else{
- $this->is_account = false;
- }
-
- /* set defaults */
- $this->name = $this->dn;
- $this->orig_dn = $this->dn;
- $this->initially_was_account = $this->is_account;
- }
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","printer/".get_class($this),$this->dn);
- }
-
- /* Fill templating stuff */
- $smarty= get_smarty();
- $display= "";
-
- $smarty->assign("CartridgesACL",$this->getacl("Cartridges"));
-
- /* Assign smarty defaults
- To avoid undefined indexes, if there is an error with the glpi db
- */
- foreach(array("PrinterTypeKeys","PrinterTypes","ManufacturerKeys","Manufacturers",
- "Attachments","AttachmentKeys","CartridgeKeys","Cartridges") as $attr){
- $smarty->assign($attr,array());
- }
- foreach(array("type","FK_glpi_enterprise","tech_num","contact_num","comments","flags_serial","flags_par","flags_usb","AttachmentsDiv") as $attr){
- $smarty->assign($attr,"");
- }
-
- /* Assign acls */
- $tmp = $this->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $translation){
- $smarty->assign($name."ACL",$this->getacl($name));
- }
-
- /* Check if there is a glpi database server defined
- */
- if(!isset($this->config->data['SERVERS']['GLPI'])){
- print_red(_("There is no server with valid glpi database service."));
- return($smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE)));
- }
-
- $this->data = $this->config->data['SERVERS']['GLPI'];
-
- /* Check if we can call mysql_connect
- If we can't, there is no the mysql-php extension
- */
- if(!is_callable("mysql_connect")){
- print_red(_("Can't connect to glpi database, the php-mysql extension is missing."));
- return($smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE)));
- }
-
- $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
-
- /* If handle == false, abort
- Seems that the server, username and or password is wrong
- */
- if(!$this->handle->is_connected){
- print_red(_("Can't connect to glpi database, check configuration twice."));
- return($smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE)));
- }
-
- /* All checks are ok
- Lets handle Posts, templates etc below ...
- */
-
- $users = $this->handle->getUsers();
- $ldap= $this->config->get_ldap_link();
-
-
- /* ##########################################################################
- * Some tab management
- */
-
- /* 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;
- }
- }
-
- /* Show tab dialog headers */
- if ($this->is_account){
- $display= $this->show_disable_header(_("Remove inventory"),
- _("This server has inventory features enabled. You can disable them by clicking below."));
- } else {
- $display= $this->show_enable_header(_("Add inventory"),
- _("This server has inventory features disabled. You can enable them by clicking below."));
- return ($display);
- }
-
-
- /* ##########################################################################
- * Printer type management
- * Dialog
- */
-
- /* Rename was requested */
- if(isset($_POST['Rename_PType_OK']) && $this->acl_is_writeable("type")){
- $tmp = $this->handle->getPrinterTypes();
- $allok = true;
- foreach($tmp as $id => $name){
- if(trim($name) == trim($_POST['string'])){
- $allok = false;
- }
- }
- if($allok){
- $this->handle->updatePrinterType($_POST['string'],$this->select_type);
- $this->rename = false;
- }else{
- print_red(sprintf(_("Can't rename given printer type to '%s', because this type name already exists."),$_POST['string']));
- }
- }
-
- /* abort rename
- */
- if(isset($_POST['Rename_Cancel'])){
- $this->rename = false;
- }
-
- /* Printer type management
- */
- if(isset($_POST['edit_type']) && $this->acl_is_writeable("type")){
- $this->dialog = true;
- $this->edit_type=true;
- }
-
- /* This closes the printer type editing dialog
- */
- if(isset($_POST['close_edit_type'])){
- $this->edit_type=false;
- $this->dialog = false;
- }
-
- /* This appends a new printer to our sytem types
- */
- if((isset($_POST['add_type']))&&(!empty($_POST['type_string'])) && $this->acl_is_writeable("type")){
-
- $tmp = $this->handle->getPrinterTypes();
- $allok = true;
- foreach($tmp as $id => $name){
- if(trim($name) == trim($_POST['type_string'])){
- $allok = false;
- }
- }
- if($allok){
- $this->handle->addPrinterType($_POST['type_string']);
- }else{
- print_red(sprintf(_("Can't rename given printer type to '%s', because this type name already exists."),$_POST['type_string']));
- }
- }
-
- /* Remove selected type from our printer types list
- */
- if((isset($_POST['del_type']))&&(!empty($_POST['select_type'])) && $this->acl_is_writeable("type")){
- $tmp = $this->handle->is_printerTypeUsed($_POST['select_type']);
- if(count($tmp)){
- $str = "";
- foreach($tmp as $id => $name){
- $str .= $name.", ";
- }
- $str = preg_replace("/, $/","",$str);
- print_red(sprintf(_("Can't delete printer type, it is still in use by '%s'."),$str));
- }else{
- $this->handle->removePrinterType($_POST['select_type']);
- }
- }
-
- /* Rename selected printer type to given string
- */
- if((isset($_POST['rename_type']))&&(!empty($_POST['select_type']))||($this->rename) && $this->acl_is_writeable("type")){
- $this->rename = true;
-
- $smarty->assign("Method","rename");
-
- $tmp = $this->handle->getPrinterTypes();
-
- if(isset($_POST['select_type'])){
- $this->select_type = $_POST['select_type'];
- }
- $smarty->assign("string",$tmp[$this->select_type]);
- if(isset($_POST['string'])){
- $smarty->assign("string",$_POST['string']);
- }
-
- $display= $smarty->fetch(get_template_path('glpi_edit_printer_type.tpl', TRUE));
- return($display);
- }
-
- /* Someone wants to edit the printer types ...
- So, lets open a new dialog which provides some buttons to edit the types
- */
- if($this->edit_type){
- $smarty->assign("Method","edit");
- $smarty->assign("PrinterTypes", $this->handle->getPrinterTypes());
- $smarty->assign("PrinterTypeKeys", array_flip($this->handle->getPrinterTypes()));
- $display= $smarty->fetch(get_template_path('glpi_edit_printer_type.tpl', TRUE));
- return($display);
- }
-
-
- /* ##########################################################################
- * Edit manufacturers
- * Dialog
- */
-
- /* Open dialog which allows to edit the manufacturers
- */
- if(isset($_POST['edit_manufacturer']) && $this->acl_is_writeable("FK_glpi_enterprise")){
- $this->cur_dialog = new glpiManufacturer($this->config,$this->dn);
- $this->dialog = true;
- $this->editManufacturer =true;
- }
-
- /* Close manufacturer editing dialog
- */
- if((isset($_POST['close_edit_manufacturer']))&&($this->editManufacturer)){
- $this->dialog = false;
- $this->cur_dialog = false;
- $this->editManufacturer=false;
- }
-
-
- /* ##########################################################################
- * Technical responsible person
- * Contact person
- * Dialog
- */
-
- /* Show dialog to select a new contact person
- * Select a contact person
- */
- if(isset($_POST['SelectContactPerson']) && $this->acl_is_writeable("contact_num")){
- $this->addUser = "contact";
- $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
- }
-
- /* Selecte technical responsible person
- */
- if(isset($_POST['SelectTechPerson']) && $this->acl_is_writeable("tech_num")){
- $this->addUser ="tech";
- $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
- }
-
- /* Abort user selection
- */
- $smarty->assign("AbortSelectUser","SelectUserCancel");
- if(isset($_POST['SelectUserCancel'])){
- $this->dialog = false;
- $this->addUser ="";
- $this->cur_dialog = false;
- }
-
- /* Technical responsible/contact person selected */
- if(isset($_GET['act'])&&($_GET['act']=="user_tech_num")){
-
- /* Get posted id */
- $id = base64_decode($_GET['id']);
-
- /* Check if user is already created in glpi database */
- if(!in_array($id,$users)){
-
- /* If this user doesn't exists in glpi db, we must create him */
- $ldap->cat($id, array('cn', 'mail', 'telephoneNumber'));
- $atr = $ldap->fetch();
- $tmp = array();
- $use = array( "cn" =>"name",
- "mail" =>"email",
- "telephoneNumber" =>"phone");
-
- /* Create array */
- foreach($use as $gosa => $glpi){
- if(isset($atr[$gosa])){
- $tmp[$glpi]= $atr[$gosa][0];
- }
- }
-
- /* Add this user */
- $this->handle->addUser($tmp,$id);
- }
-
- /* Re-read users */
- $users = ($this->handle->getUsers());
-
- /* Get user */
- $tmp = array_flip($users);
- $id=$tmp[$id];
-
- /* Use user id, close dialog */
- if($this->addUser == "tech"){
- $this->tech_num = $id;
- }else{
- $this->contact_num = $id;
- }
- $this->cur_dialog = false;
- $this->dialog= false;
- }
-
-
- /* ##########################################################################
- * Handle attachments
- */
-
- /* Attachment pool was closed with use
- */
- if(isset($_POST['UseAttachment']) && $this->acl_is_writeable("Attachments")){
- if(count($this->cur_dialog->check())){
- foreach($this->cur_dialog->check() as $msg){
- print_red($msg);
- }
- }else{
- $this->cur_dialog->save_object();
- $this->usedAttachments = $this->cur_dialog->save();
- $this->cur_dialog = false;
- $this->edit_type = false;
- }
- }
-
- /* Attachment pool was closed with abort
- */
- if(isset($_POST['AbortAttachment'])){
- $this->cur_dialog = false;
- $this->edit_type = false;
- }
-
- /* Open Attachment pool to add/edit Attachments
- */
- if(isset($_POST['AddAttachment']) && $this->acl_is_writeable("Attachments")){
- $this->cur_dialog = new glpiAttachmentPool($this->config,$this->dn,$this->usedAttachments);
- $this->dialog = true;
- }
-
- /* Remove Attachment from this tab
- */
- $once = true;
- foreach($_POST as $name => $value){
- if((preg_match("/^delAttachment_/",$name))&&($once) && $this->acl_is_writeable("Attachments")){
- $once= false;
- $name = preg_replace("/^delAttachment_/","",$name);
- $entry = preg_replace("/_.*$/","",$name);
- if(isset($this->usedAttachments[$entry])){
- unset($this->usedAttachments[$entry]);
- }
- }
- }
- if((isset($_POST['RemoveAttachment']))&&(isset($_POST['Attachments'])) && $this->acl_is_writeable("Attachments")){
- if(isset($this->usedAttachments[$_POST['Attachments']])){
- unset($this->usedAttachments[$_POST['Attachments']]);
- }
- }
-
- /* ##########################################################################
- * Printer Cartridge handling
- */
-
- /* Abort cartridge select dialog
- */
- if(isset($_POST['SelectCartridgeCancel'])){
- $this->cur_dialog = false;
- $this->edit_type = false;
- }
-
- /* Get selected cartridges and add them to our list
- */
- if(isset($_POST['SelectCartridgeSave'])){
- $this->cur_dialog->save_object();
- $carts = $this->cur_dialog->save();
- foreach($carts as $cart){
- $cart['status'] = "new";
- $this->usedCartridges[] = $cart;
- }
- $this->cur_dialog = false;
- $this->edit_type = false;
- }
-
- /* Remove cartridge
- */
- if((isset($_POST['RemoveCartridge']))&&(isset($_POST['Cartridges'])) && $this->acl_is_writeable("ManageCartridges")){
-
- foreach($_POST['Cartridges'] as $cartID){
-
- if(isset($this->usedCartridges[$cartID])){
- if($this->usedCartridges[$cartID]['status'] == "exists"){
- $this->usedCartridges[$cartID]['status'] = "deleted";
- }else{
- unset($this->usedCartridges[$cartID]);
- }
- }
- }
- }
-
- /* Open Attachment pool to add/edit Attachments
- */
- if(isset($_POST['AddCartridge']) && $this->acl_is_writeable("ManageCartridges")){
- $this->cur_dialog = new glpiPrinterCartridges($this->config,$this->dn,$this->type);
- $this->dialog = true;
- }
-
-
- /* ##########################################################################
- * Draw Dialogs
- */
- /* if( cur_dialog != false || cur_dialog != NULL)
- * There is a dialog which wants to be displayed
- */
- if($this->cur_dialog && is_object($this->cur_dialog)){
- $this->cur_dialog->save_object();
- $this->dialog=true;
- $this->cur_dialog->parent = &$this;
- return($this->cur_dialog->execute());
- }else{
- $this->dialog= false;
- }
-
-
- /* ##########################################################################
- * Assign listbox / checkbox .... values to smarty
- */
- /* Assign smarty defaults */
- foreach(array("PrinterTypes","PrinterTypeKeys","Manufacturers","TechnicalResponsibles","Attachments","Cartridges") as $attr){
- $smarty->assign($attr,array());
- }
-
- /* Assign some vars to smarty
- */
- foreach(array("type","FK_glpi_enterprise","tech_num","contact_num","flags_serial","flags_par","flags_usb") as $attr){
- $smarty->assign($attr,"");
- }
-
- $smarty->assign("comments", $this->comments);
- $smarty->assign("flags_serial", $this->flags_serial);
- $smarty->assign("flags_par", $this->flags_par);
- $smarty->assign("flags_usb", $this->flags_usb);
-
- /* Assign system types
- */
- $smarty->assign("PrinterTypes", $this->handle->getPrinterTypes());
- $smarty->assign("PrinterTypeKeys", array_flip($this->handle->getPrinterTypes()));
- $smarty->assign("type", $this->type);
-
- /* Append manufacturers
- */
- $smarty->assign("ManufacturerKeys", array_flip($this->handle->getEnterprises()));
- $smarty->assign("Manufacturers", $this->handle->getEnterprises());
- $smarty->assign("FK_glpi_enterprise", $this->FK_glpi_enterprise);
-
- /* Assign used Attachments
- */
-
- $divlist = new divSelectBox("glpiAttachmentsList");
- $divlist-> SetHeight(120);
- $atts = $this->getUsedAttachments(true);
- $downlink = "%s ";
- $del_link = " ";
- foreach($atts as $id => $attachment){
- $divlist->AddEntry
- (
- array(
- array("string"=>$attachment['name']),
- array("string"=>$attachment['mime']),
- array("string"=>sprintf($downlink,$id,$attachment['filename'])),
- array("string"=>sprintf($del_link,$attachment['ID']),"attach"=>"style='border-right:0px;'"),
- )
- );
- }
-
- $smarty->assign("AttachmentsDiv" ,$divlist->DrawList());
- $smarty->assign("Attachments", $this->getUsedAttachments());
- $smarty->assign("AttachmentKeys", array_flip($this->getUsedAttachments()));
-
- /* Assign Cartridges
- */
- $smarty->assign("Cartridges", $this->getUsedCartridges());
- $smarty->assign("CartridgeKeys", $this->getUsedCartridges(true));
-
- /* ##########################################################################
- * Assign contact and technical responsible person
- */
- if(isset($users[$this->contact_num])){
- $ldap->cat($users[$this->contact_num], array('givenName', 'sn', 'uid'));
- $tr = $ldap->fetch();
- $str = "";
- if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; }
- if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; }
- if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; }
- $smarty->assign("contact_num", $str);
- }else{
- $smarty->assign("contact_num", _("N/A"));
- }
-
- /* Handle tech person
- Assign name ... to smarty, if set
- */
- if(isset($users[$this->tech_num])){
- $ldap->cat($users[$this->tech_num], array('givenName', 'sn', 'uid'));
- $tr = $ldap->fetch();
- $str = "";
- if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; }
- if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; }
- if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; }
- $smarty->assign("tech_num", $str);
- }else{
- $smarty->assign("tech_num", _("N/A"));
- }
-
- /* If theres a cartridge selected, you can't change the printer type.
- */
- $disp = true;
-
- foreach($this->usedCartridges as $cart){
- if($cart['status'] != "deleted"){
- $disp = false;
- }
- }
- if($disp==false){
- $smarty->assign("typeACL", $this->getacl("type",true));
- }
-
- $display.= $smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE));
- return($display);
- }
-
- function remove_from_parent()
- {
- $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
- if($this->initially_was_account){
- $this->handle->removePrinterInformations($this->dn);
- new log("remove","printer/".get_class($this),$this->dn);
- }
- }
-
-
- /* Save data to object */
- function save_object()
- {
- if(isset($_POST['glpiPrinterFlagsPosted'])){
- plugin::save_object();
- foreach($this->attributes as $attrs){
- if(isset($_POST[$attrs])){
- $this->$attrs = $_POST[$attrs];
- }
- }
-
- if(isset($_POST['FK_glpi_enterprise']) && $this->acl_is_writeable("FKglpienterprise")){
- $this->FK_glpi_enterprise = $_POST['FK_glpi_enterprise'];
- }
-
- foreach(array("flags_serial","flags_par","flags_usb") as $checkboxes){
- if($this->acl_is_writeable($checkboxes)){
- if(isset($_POST[$checkboxes])){
- $this->$checkboxes = 1;
- }else{
- $this->$checkboxes = 0;
- }
- }
- }
- }
-
- }
-
-
- /* Check supplied data */
- function check()
- {
- /* Call common method to give check the hook */
- $message= plugin::check();
-
- // if($this->TechnicalResponsible == ""){
- // $message[] = _("Please select a technical responsible person for this entry.");
- // }
-
- return ($message);
- }
-
- /* Save to LDAP */
- function save()
- {
- if($this->is_account){
- $attrs = array();
- $this->date_mod = date("Y-m-d H:i:s");
- foreach($this->attributes as $attr){
- $attrs[$attr] = $this->$attr;
- }
- $attrs['name'] = $this->dn;
- unset($attrs['ID']);
- $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
- if($this->initially_was_account&&$this->is_account){
- $this->handle->updatePrinterInformations($attrs,$this->dn);
- new log("modify","printer/".get_class($this),$this->dn);
- }elseif($this->is_account){
- $this->handle->addPrinterInformations($attrs,$this->dn);
- new log("create","printer/".get_class($this),$this->dn);
- }
- $tmp = $this->handle->getPrinterInformations($this->dn);
- $this->handle->addAttachmentsToPrinter($this->usedAttachments,$tmp[0]['ID']);
-
- foreach($this->usedCartridges as $cart){
- if($cart['status'] == "deleted"){
- $this->handle->removeCartridgeFromPrinter($cart['ID']);
- }elseif($cart['status'] == "new"){
- $this->handle->addCartridgeFromPrinter($tmp[0]['ID'],$cart['type_ID']);
- }
- }
- }
- }
-
- /* Return used attachments */
- function getUsedAttachments($divlist = false)
- {
- $atts =$this->handle->getAttachments();
- $ret = array();
- foreach($atts as $entry){
- if(in_array($entry['ID'],$this->usedAttachments)){
- if($divlist){
- $ret[$entry['ID']] = $entry;
- }else{
- $cm ="";
- if(isset($entry['comment'])){
- $cm=" [".$entry['comment']."]";
- }
- if(isset($entry['mime'])){
- $cm.=" -".$entry['mime']."";
- }
-
- $ret[$entry['ID']]= $entry['name'].$cm;
- }
- }
- }
- return($ret);
- }
-
- function getUsedCartridges($flip = false)
- {
- $ret = array();
- foreach($this->usedCartridges as $key => $value){
- if($value['status'] == "deleted") continue;
- if($flip){
- $ret[$key] = $key;
- }else{
- $ret[$key] = $value['name']." [".$value['type_name']."] "._("since")." :".$value['date_use'];
- }
- }
- return($ret);
- }
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Glpi"),
- "plDescription" => _("Printer inventory extension"),
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 10,
- "plSection" => array("administration"),
- "plCategory" => array("printer"),
-
- "plProvidedAcls"=> array(
- "flags_serial" => _("Supports serial interface"),
- "flags_par" => _("Supports parallel interface"),
- "flags_usb" => _("Supports usb interface"),
- "tech_num" => _("Technical responsible"),
- "comments" => _("Comments"),
- "location" => _("Location"),
- "contact_num" => _("Contact person"),
- "type" => _("Type"),
- "FKglpienterprise" => _("Manufacturer"),
-
- "Attachments" => _("Attachments"),
-
- "ManageCartridges" => _("Cartridge settings"))
- ));
- }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_glpiPrinterCartridges.inc b/plugins/admin/systems/class_glpiPrinterCartridges.inc
deleted file mode 100644
index 3d9d63010..000000000
--- a/plugins/admin/systems/class_glpiPrinterCartridges.inc
+++ /dev/null
@@ -1,298 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* attribute list for save action */
- var $ignore_account = TRUE;
- var $attributes = array();
- var $objectclasses = array("whatever");
-
- var $parent = NULL; // Contains parent class, to access glpi db handle
- var $usedCartridges = array(); // IDs of used cartridges for this printer
- var $PrinterType = 0; // Specifies which cartridge types are available
-
- var $cur_dialog = false;
- var $cur_sub_dialog = false;
-
- var $editManufacturer = false;
- var $del = 0;
-
-
- function glpiPrinterCartridges (&$config,$dn,$type)
- {
- plugin::plugin ($config, $dn);
-
- /* Assign some basic settings */
- $this->ui = get_userinfo();
- if(!isset($_SESSION['glpiCartridgeRegex'])){
- $_SESSION['glpiCartridgeRegex'] = "*";
- }
-
- /* Only display cartridges for this type of printer */
- $this->PrinterType = $type;
- }
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
- $display ="";
- $smarty = get_smarty();
- $filter = $_SESSION['glpiCartridgeRegex'];
-
- /* Filter settings, remove double* */
- if(isset($_GET['search'])){
- $filter = preg_replace("/\*\**/","*",$_GET['search']."*");
- }elseif(isset($_POST['cartridge_regex'])){
- $filter = preg_replace("/\*\**/","*",$_POST['cartridge_regex']);
- }
- if(empty($filter)) {
- $filter = "*";
- }
- $_SESSION['glpiCartridgeRegex']= $filter;
-
- /* Open dialog which allows to edit the manufacturers
- */
- if(isset($_POST['edit_manufacturer_cartridges'])){
- $this->cur_sub_dialog = new glpiManufacturer($this->config,$this->dn);
- $this->dialog = true;
- $this->editManufacturer =true;
- }
-
- /* Close manufacturer editing dialog
- */
- if((isset($_POST['close_edit_manufacturer']))&&($this->editManufacturer)){
- $this->dialog = false;
- $this->cur_sub_dialog = false;
- $this->editManufacturer=false;
- }
-
- /* Check poted vars and do the requested job, but only once */
- $only_once = true;
- foreach($_POST as $name => $value){
-
- /* We have to create a new cartridge */
- if(preg_match("/^newcartridge/",$name)&&($only_once)){
- $this->cur_dialog = new glpiPrinterCartridgesEdit($this->config,$this->dn,$this->PrinterType);
- $only_once = false;
- }
- }
-
- /* Edit cartridge */
- if(isset($_GET['act'])&&$_GET['act']=="edit_cartridge"){
- $val = ($this->parent->handle->getCartridgeTypeInformations($_GET['id']));
- $this->cur_dialog = new glpiPrinterCartridgesEdit($this->config,$this->dn,$this->PrinterType,$val[$_GET['id']]);
- }
-
- /* remove cartridge */
- if(isset($_GET['act'])&&$_GET['act']=="del_cartridge"){
- /* remove attach from db */
- $this->del = $_GET['id'];
- $val = ($this->parent->handle->getCartridgeTypeInformations($_GET['id']));
- $smarty->assign("warning", sprintf(_("You're about to delete the glpi cartridge type '%s'."), $val[$this->del]['name']));
- return($smarty->fetch(get_template_path('remove_glpi.tpl', TRUE)));
- }
-
- if(isset($_POST['delete_cancel'])){
- $this->del = false;
- }
-
- /* Delete this entry */
- if(isset($_POST['delete_glpi_confirm'])&&($this->del)) {
- $tmp = $this->parent->handle->is_cartridgeTypeUsed($this->del);
- if(count($tmp)){
-
- $str = "";
- foreach($tmp as $id => $name){
- $str .= $name.", ";
- }
- $str = preg_replace("/, $/","",$str);
-
- print_red(sprintf(_("You can't delete this cartridge type, it is still in use by this printer(s) '%s'."),$str));
- }else{
- $val = ($this->parent->handle->getCartridgeTypeInformations($this->del));
- $this->cur_dialog = new glpiPrinterCartridgesEdit($this->config,$this->dn,$this->PrinterType,$val[$this->del]);
- $this->cur_dialog->parent = $this->parent;
- $this->cur_dialog->remove_from_parent();
- $this->cur_dialog= false;
- }
- }
-
- /* Abort edit / add dialog */
- if(isset($_POST['CancelCartridge'])){
- $this->cur_dialog = false;
- }
-
- /* Save changes if check is ok */
- if(isset($_POST['SaveCartridge'])){
- $this->cur_dialog->save_object();
- if(count($this->cur_dialog->check())) {
- foreach($this->cur_dialog->check() as $checks){
- print_red($checks);
- }
- }else{
- $this->cur_dialog->save();
- $this->cur_dialog = false;
- }
- }
-
- /* If we have a dialog open, display it */
- if($this->cur_sub_dialog){
- $this->cur_sub_dialog->parent = $this->parent;
- $this->cur_sub_dialog->save_object();
- return($this->cur_sub_dialog->execute());
- }
- /* If we have a dialog open, display it */
- if($this->cur_dialog){
- $this->cur_dialog->parent = $this->parent;
- $this->cur_dialog->save_object();
- return($this->cur_dialog->execute());
- }
-
- /* Create divlist */
- $divlist = new divlist("glpi devices");
- $divlist->SetPluginMode();
- $divlist->SetEntriesPerPage(0);
- $divlist->SetHeader(array(
- array("string" => " ", "attach" => "style='text-align:center;width:20px;'"),
- array("string" => _("Cartridges"), "attach" => "style=''"),
- array("string" => _("Action"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" )));
-
- /* Links for editing,adding.... */
- $edit = "%s ";
- $editdel = " ";
- $editdel.= " ";
-
- /* Checkbox for selection of some cartridges */
- $useCartridge = " ";
-
- /* Add cartridges */
- $cart = $this->getCartridgeTypes();
-
- /* Remove typically error possibilities */
- $f = str_replace("/","\/",$filter);
- $f = str_replace(".","\.",$f);
- $f = str_replace("*",".*",$f);
-
- /* Assign cartridges */
- foreach($cart as $key=>$cartr){
-
- /* Skip if filter doesn't match*/
- if(!preg_match("/^".$f."$/i",$cartr['cartridgeName'])){
- continue;
- }
-
- /* check if this cartridge is selected */
- $chk = "";
- if(isset($this->usedCartridges[$key])){
- $chk = " checked ";
- }
-
- /* Add fields */
- $field1 = array("string" => preg_replace("/%s/",($key),preg_replace("/%CHECKED%/",$chk,$useCartridge)),
- "attach" => "style='text-align:center;width:20px;'");
- $field2 = array("string" => sprintf($edit,($key),$cartr['cartridgeName']." [".$cartr['cartridgeTypeName']."]"),
- "attach" => "style=''");
- $field3 = array("string" => sprintf($editdel,($key),($key)),
- "attach" => "style='width:60px;border-right:0px;text-align:right;'");
-
- $divlist->AddEntry(array($field1,$field2,$field3));
-
- }
-
- /* Create list header */
- $listhead = "".
- " ".
- "
";
-
- /* Tell smarty some vars */
- $filter= $_SESSION['glpiCartridgeRegex'];
- $smarty->assign("devicehead", $listhead);
- $smarty->assign("devices", $divlist->DrawList());
- $smarty->assign("search_image", get_template_path('images/search.png'));
- $smarty->assign("searchu_image", get_template_path('images/search_user.png'));
- $smarty->assign("tree_image", get_template_path('images/tree.png'));
- $smarty->assign("infoimage", get_template_path('images/info_small.png'));
- $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
- $smarty->assign("apply", apply_filter());
- $smarty->assign("alphabet", generate_alphabet());
- $smarty->assign("cartridge_regex", $filter);
-
- $display.= $smarty->fetch(get_template_path('glpiPrinterCartridges.tpl', TRUE));
- return($display);
- }
-
- /* Save device to glpi database
- * If this is a new device, create a new entry, else update this entry
- */
- function save()
- {
- $carts = $this->getCartridgeTypes();
- $ret = array();
- foreach($this->usedCartridges as $key){
- $tmp =array();
- $tmp['date_use'] = date("Y-m-d");
- $tmp['ID'] = -1;
- $tmp['type_ID'] = $carts[$key]['cartridgeID'];
- $tmp['name'] = $carts[$key]['cartridgeName'];
- $tmp['FK_glpi_printers']= -1;
- $tmp['type_name'] = $carts[$key]['cartridgeTypeName'];
- $ret[$key] = $tmp;
- }
- return($ret);
- }
-
- /* this only gets all already defined devices */
- function reload()
- {
- $this->devices = $this->parent->handle->getDevices();
- ksort($this->devices);
- }
-
- /* This funtions saves all POST variables.
- The variable must be in the array $this->EditEntry
- */
- function save_object()
- {
- /* Checkbox handling
- * Check which checkbox is selected
- */
- foreach($_POST as $name => $value){
- if(preg_match("/wasOnPage/",$name)){
- $id = preg_replace("/wasOnPage_/","",$name);
- if(isset($_POST['useCartridge_'.$id])){
- $this->usedCartridges[$id]=$id;
- }else{
- unset($this->usedCartridges[$id]);
- }
- }
- }
- }
-
- /* This function cehck all created devices if you wan't to create device specific check
- use >>if($attr['device_type']=="moboard")<< to create a device type depending check
- */
- function check()
- {
- /* Call common method to give check the hook */
- $message= plugin::check();
-
- return($message);
- }
-
- /* Return cartriges for our divlist */
- function getCartridgeTypes()
- {
- $ret = array();
- $ret = $this->parent->handle->getAvailableCartridgeTypes($this->PrinterType);
- return($ret);
- }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_glpiPrinterCartridgesEdit.inc b/plugins/admin/systems/class_glpiPrinterCartridgesEdit.inc
deleted file mode 100644
index e1d86fcb6..000000000
--- a/plugins/admin/systems/class_glpiPrinterCartridgesEdit.inc
+++ /dev/null
@@ -1,337 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* attribute list for save action */
- var $ignore_account = TRUE;
- var $attributes = array("ID","name","ref","location","type","FK_glpi_enterprise","tech_num","deleted","comments","alarm");
- var $objectclasses = array("whatever");
-
- var $printer_type = 0;
-
- var $additional_printer= array();
- var $needToCatch = true;
-
- var $parent = NULL;
-
- var $ID = "";
- var $name = "";
- var $ref = "";
- var $location = "";
- var $type = "";
- var $FK_glpi_enterprise = "";
- var $tech_num = "";
- var $deleted = "";
- var $comments = "";
- var $alarm = "";
-
- var $cur_dialog = false;
- var $edit_type =false;
-
-
- function glpiPrinterCartridgesEdit (&$config, $dn,$printer_type,$values = NULL )
- {
- plugin::plugin ($config, $dn);
- foreach($this->attributes as $val){
- if(isset($values[$val])){
- $this->$val = $values[$val];
- }else{
- $this->$val = "";
- }
- }
- $this->needToCatch = true;
- $this->printer_type = $printer_type;
- }
-
- function remove_from_parent()
- {
- if($this->ID > 0){
- $this->parent->handle->removeCartridgeDropdownType($this->ID);
- }
- }
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- /* Fill templating stuff */
- $smarty= get_smarty();
- $display= "";
-
- /* Get all currently used/supported printer types for this cartridge type
- */
- if($this->needToCatch){
- $this->needToCatch = false;
- if(!empty($this->type)){
- $this->additional_printer= $this->parent->handle->getSupportedPrinterTypeIDsForCartridge($this->ID);
- }
- }
-
-
-
-
-
-
- /* Printer type management
- */
- if(isset($_POST['edit_type_cartridge'])){
- $this->dialog = true;
- $this->edit_type=true;
- }
-
- /* This closes the printer type editing dialog
- */
- if(isset($_POST['close_edit_type_cartridge'])){
- $this->edit_type=false;
- $this->dialog = false;
- }
-
- /* This appends a new printer to our sytem types
- */
- if((isset($_POST['add_cartridge_type']))&&(!empty($_POST['cartridge_type_string']))){
- print "Add";
- $this->parent->handle->addCartridgeDropdownType($_POST['cartridge_type_string']);
- }
-
- /* Remove selected type from our printer types list
- */
- if((isset($_POST['del_cartridge_type']))&&(!empty($_POST['select_type_cartridge']))){
- $used = $this->parent->handle->getUsedDropdownTypes($_POST['select_type_cartridge']);
- if(!count($used)){
- $this->parent->handle->removeCartridgeDropdownType($_POST['select_type_cartridge']);
- }else{
- print_red(_("Can't delete this entry, it is still in use."));
- }
- }
-
- /* Rename selected printer type to given string
- */
- /* Update*/
- if((isset($_POST['rename_cartridge_type']))&&(!empty($_POST['select_type_cartridge']))&&(!empty($_POST['cartridge_type_string']))){
- $this->parent->handle->updateCartridgeDropdownType($_POST['cartridge_type_string'],$_POST['select_type_cartridge']);
- }
-
- /* Someone wants to edit the printer types ...
- So, lets open a new dialog which provides some buttons to edit the types
- */
- if($this->edit_type){
- $smarty->assign("PrinterTypes", $this->parent->handle->getCartridgeTypes());
- $smarty->assign("PrinterTypeKeys", array_flip($this->parent->handle->getCartridgeTypes()));
- $display= $smarty->fetch(get_template_path('glpi_edit_cartridge_type.tpl', TRUE));
- return($display);
- }
-
- /* Assign attributes */
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
- }
-
- /* Selecte technical responsible person
- */
- if(isset($_POST['SelectCartridgeTechPerson'])){
- $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_cartridge_tech_num");
- }
-
- /* Abort user selection
- */
- $smarty->assign("AbortSelectUser","SelectCartridgeUserCancel");
- $smarty->assign("SaveSelectUser" ,"user_cartridge_tech_num");
- if(isset($_POST['SelectCartridgeUserCancel'])){
- $this->dialog = false;
- $this->addUser ="";
- $this->cur_dialog = false;
- }
-
- /* Start ldap, and get all glpiUsers */
- $ldap = $this->config->get_ldap_link();
- $users = ($this->parent->handle->getUsers());
-
- /* Technical responsible/contact person selected
- */
- if(isset($_GET['act'])&&($_GET['act']=="user_cartridge_tech_num")){
-
- /* Get posted id */
- $id = base64_decode($_GET['id']);
-
- /* Check if user is already created in glpi database */
- if(!in_array($id,$users)){
-
- /* If this user doesn't exists in glpi db, we must create him */
- $ldap->cat($id, array('cn', 'mail', 'telephoneNumber'));
- $atr = $ldap->fetch();
- $tmp = array();
- $use = array( "cn" =>"name",
- "mail" =>"email",
- "telephoneNumber" =>"phone");
-
- /* Create array */
- foreach($use as $gosa => $glpi){
- if(isset($atr[$gosa])){
- $tmp[$glpi]= $atr[$gosa][0];
- }
- }
-
- /* Add this user */
- $this->parent->handle->addUser($tmp,$id);
- }
-
- /* Re-read users */
- $users = ($this->parent->handle->getUsers());
-
- /* Get user */
- $tmp = array_flip($users);
- $id=$tmp[$id];
-
- /* Close dialog and use this user */
- $this->tech_num = $id;
- $this->cur_dialog = false;
- $this->dialog= false;
- }
-
- /* Execute dialog*/
- if($this->cur_dialog){
- $this->cur_dialog->save_object();
- $this->dialog=true;
- $this->cur_dialog->parent = &$this;
- return($this->cur_dialog->execute());
- }else{
- $this->dialog= false;
- }
-
- /* Create matrix with all possible printer types
- */
- $matrix = "";
-
- /* Append manufacturers
- */
- $smarty->assign("PrinterTypeMatrix", $matrix);
-
- $smarty->assign("ManufacturerKeys", array_flip($this->parent->handle->getEnterprises()));
- $smarty->assign("Manufacturers", $this->parent->handle->getEnterprises());
- $smarty->assign("FK_glpi_enterprise", $this->FK_glpi_enterprise);
-
- $smarty->assign("typeKeys", array_flip($this->parent->handle->getCartridgeTypes()));
- $smarty->assign("types", $this->parent->handle->getCartridgeTypes());
- $smarty->assign("type", $this->type);
-
- /* Handle tech person
- Assign name ... to smarty, if set
- */
- if(isset($users[$this->tech_num])){
- $ldap->cat($users[$this->tech_num], array('givenName', 'sn', 'uid'));
- $tr = $ldap->fetch();
- $str = "";
- if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; }
- if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; }
- if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; }
- $smarty->assign("tech_num", $str);
- }else{
- $smarty->assign("tech_num", _("N/A"));
- }
-
-
- $display.= $smarty->fetch(get_template_path('glpiPrinterCartridgesEdit.tpl', TRUE,dirname(__FILE__)));
- return($display);
- }
-
- /* Check given values */
- function check(){
- /* Call common method to give check the hook */
- $message= plugin::check();
-
- /* Avoid choosing an already used name */
- $types = $this->parent->handle->getCartridgeTypeInformations();
- foreach($types as $type){
- if($type['name'] == $this->name){
- if($type['ID'] != $this->ID){
- $message[]= _("The selected name is already in use.");
- }
- }
- }
- return $message;
- }
-
- /* Save Post data */
- function save_object()
- {
- foreach($this->attributes as $attr){
- if(isset($_POST[$attr])){
- $this->$attr= $_POST[$attr];
- }
- }
-
- /* Get selected checkboxes */
- foreach($_POST as $name => $value){
- if(preg_match("/wasOnPage_/",$name)){
- $id = preg_replace("/wasOnPage_/","",$name);
- if(isset($_POST['UsePrinterType_'.$id])){
- $this->additional_printer[$id]=$id;
- }else{
- if(isset($this->additional_printer[$id])){
- unset($this->additional_printer[$id]);
- }
- }
- }
- }
- }
-
- /* Create / Update database with this new infos */
- function save()
- {
- $tmp = array();
- foreach($this->attributes as $attr){
- $tmp[$attr] = $this-> $attr;
- }
- $types = array();
- $types = $this->additional_printer;
- $types[$this->printer_type]=$this->printer_type;
- $this->parent->handle->Add_UpdateCatrigdeType($tmp,$types);
- }
-
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_glpiSelectUser.inc b/plugins/admin/systems/class_glpiSelectUser.inc
deleted file mode 100644
index 7073b12a4..000000000
--- a/plugins/admin/systems/class_glpiSelectUser.inc
+++ /dev/null
@@ -1,285 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* attribute list for save action */
- var $ignore_account= TRUE;
- var $attributes= array();
- var $objectclasses= array("whatever");
-
- var $users = array();
- var $departments = array();
-
- var $ui;
-
- var $PostVarName = "";
-
- function glpiSelectUser (&$config, $dn= NULL,$postvar)
- {
- plugin::plugin ($config, $dn);
-
- $this->PostVarName = $postvar;
-
- if(!isset($_SESSION['glpi_user_filter'])){
- $tmp['users_regex'] = "*";
- $tmp['base'] = $this->config->current['BASE'];
- $_SESSION['glpi_user_filter'] = $tmp;
- }
-
- $this->ui = get_userinfo();
- }
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- if(isset($_POST['depselect'])){
- $_SESSION['glpi_user_filter']['base'] = $_POST['depselect'];
- }
-
- $filter = $_SESSION['glpi_user_filter'];
-
- /* Filter settings, remove double* */
- if(isset($_GET['search'])){
- $filter['users_regex'] = preg_replace("/\*\**/","*",$_GET['search']."*");
- }elseif(isset($_POST['regex'])){
- $filter['users_regex'] = preg_replace("/\*\**/","*",$_POST['regex']);
- }
- if(empty($filter['users_regex'])) {
- $filter = "*";
- }
-
-
- $s_action="";
- /* Test Posts */
- foreach($_POST as $key => $val){
- // Post for delete
- if(preg_match("/dep_back.*/i",$key)){
- $s_action="back";
- }elseif(preg_match("/user_new.*/",$key)){
- $s_action="new";
- }elseif(preg_match("/dep_home.*/i",$key)){
- $s_action="home";
- }
- }
-
- /* Homebutton is posted */
- if($s_action=="home"){
- $filter['base']=(preg_replace("/^[^,]+,/","",$this->ui->dn));
- $filter['base']=(preg_replace("/^[^,]+,/","",$filter['base']));
- }
-
- if($s_action=="root"){
- $filter['base']=($this->config->current['BASE']);
- }
-
-
- /* If Backbutton is Posted */
- if($s_action=="back"){
- $base_back = preg_replace("/^[^,]+,/","",$filter['base']);
- $base_back = convert_department_dn($base_back);
-
- if(isset($this->config->departments[trim($base_back)])){
- $filter['base']= $this->config->departments[trim($base_back)];
- }else{
- $filter['base']= $this->config->departments["/"];
- }
- }
-
- if((isset($_GET['act']))&&($_GET['act']=="dep_open")){
- $entry = base64_decode($_GET['dep_id']);
- $filter['base']= ($this->config->departments[$entry]);
- }
-
- $_SESSION['glpi_user_filter'] = $filter;
-
- $this->reload();
-
- /* Fill templating stuff */
- $smarty= get_smarty();
- $display= "";
-
- $divlist = new divlist("glpi users");
- $divlist->SetPluginMode();
- $divlist->SetEntriesPerPage(0);
- $divlist->SetHeader(array(
- array("string" => " ", "attach" => "style='text-align:center;width:20px;'"),
- array("string" => _("Users")." / "._("Departments"), "attach" => "style=''"),
- array("string" => _("Use"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" )));
- $linkopen = "%s ";
- foreach($this->departments as $key=> $val){
-
- if(!isset($this->config->departments[trim($key)])){
- $this->config->departments[trim($key)]="";
- }
-
- $non_empty="";
- $keys= str_replace("/","\/",$key);
- foreach($this->config->departments as $keyd=>$vald ){
- if(preg_match("/".$keys."\/.*/",$keyd)){
- $non_empty="full";
- }
- }
-
- $field1 = array("string" => " ", "attach" => "style='text-align:center;width:20px;'");
- $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style=''");
- $field3 = array("string" => " ", "attach" => "style='width:60px;border-right:0px;text-align:right;'");
- $divlist->AddEntry(array($field1,$field2,$field3));
- }
-
- $useruse = "PostVarName."&id=%s'>%s ";
-
- foreach($this->users as $key=>$user){
- $field1 = array("string" => " ", "attach" => "style='text-align:center;width:20px;'");
- $field2 = array("string" => sprintf($useruse,base64_encode($key),$user), "attach" => "style=''");
- $field3 = array("string" => sprintf($useruse,base64_encode($key)," "),
- "attach" => "style='width:60px;border-right:0px;text-align:right;'");
- $divlist->AddEntry(array($field1,$field2,$field3));
-
- }
-
- /* Prepare departments,
- which are shown in the listbox on top of the listbox
- */
-
-
- /* Get all departments within this subtree */
- $this->base = $_SESSION['glpi_user_filter']['base'];
- $options ="";
- $base = $this->config->current['BASE'];
- $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", "users", $base,
- array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH);
-
- /* Load possible departments */
- $ui= get_userinfo();
- $tdeps= $ui->get_module_departments("users");
- $ids = $this->config->idepartments;
- foreach($deps as $dep){
- if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){
- $value = $ids[$dep['dn']];
- if ($this->base == $dep['dn']){
- $options.= "$value ";
- } else {
- $options.= "$value ";
- }
- }
- }
-
- $listhead = "";
-
-
- $filter= $_SESSION['glpi_user_filter'];
- $smarty->assign("usershead", $listhead);
- $smarty->assign("users", $divlist->DrawList());
- $smarty->assign("search_image", get_template_path('images/search.png'));
- $smarty->assign("searchu_image", get_template_path('images/search_user.png'));
- $smarty->assign("tree_image", get_template_path('images/tree.png'));
- $smarty->assign("infoimage", get_template_path('images/info_small.png'));
- $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
- $smarty->assign("apply", apply_filter());
- $smarty->assign("alphabet", generate_alphabet());
- $smarty->assign("users_regex", $filter['users_regex']);
-
-
- $display.= $smarty->fetch(get_template_path('glpiSelectUser.tpl', TRUE));
- return($display);
- }
-
- /* Save to LDAP */
- function save()
- {
- plugin::save();
-
- /* Optionally execute a command after we're done */
-#$this->handle_post_events($mode);
- }
-
- function reload()
- {
-
- $filter= $_SESSION['glpi_user_filter'];
-
- $base = $filter['base'];
- $regex= $filter['users_regex'];
- /* NEW LIST MANAGMENT
- * We also need to search for the departments
- * So we are able to navigate like in konquerer
- */
-
- $res3= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))","users",
- $base, array("ou", "description"), GL_SIZELIMIT | GL_CONVERT);
-
- $this->departments= array();
- $tmp = array();
- foreach ($res3 as $value){
- $tmp[strtolower($value['dn']).$value['dn']]=$value;
- }
- ksort($tmp);
- foreach($tmp as $value){
- if(isset($value["description"][0])){
- $this->departments[$value['dn']]= get_sub_department($value['dn'])." - [".$value["description"][0]."]";
- }else{
- $this->departments[$value['dn']]= get_sub_department($value['dn']);//$value["description"][0];
- }
- }
-
- /* END NEW LIST MANAGMENT
- */
- $ou = get_people_ou();
-
- $res2= get_list("(&(|(cn=$regex)(sn=$regex))(objectClass=person))", "users",
- $ou.$base, array("cn", "sn", "uid", "givenName", "description"),
- GL_SUBSEARCH | GL_SIZELIMIT);
-
- $tmp = array();
-
- foreach($res2 as $val){
- $str = "";
- if(isset($val['givenName'][0])){
- $str .= $val['givenName'][0];
- }
- if(isset($val['sn'][0])){
- $str .= $val['sn'][0];
- }
- if(isset($val['uid'][0])){
- $str .= $val['uid'][0];
- }
-
- $tmp[$str] = $val;
- }
-
- ksort($tmp);
- $this->users = array();
- foreach($tmp as $value){
- if (isset($value["givenName"][0]) && isset($value["sn"][0])){
- $this->users[$value['dn']]= $value["sn"][0].", ".
- $value["givenName"][0].
- " [".$value["uid"][0]."]";
- } else {
- $this->users[$value["dn"]]= "[".$value["uid"][0]."]";
- }
- }
- }
-
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_goCupsServer.inc b/plugins/admin/systems/class_goCupsServer.inc
deleted file mode 100644
index 6fa572b9d..000000000
--- a/plugins/admin/systems/class_goCupsServer.inc
+++ /dev/null
@@ -1,85 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* This plugin only writes its objectClass */
- var $objectclasses = array("goCupsServer");
- var $attributes = array();
- var $StatusFlag = "goCupsServerStatus";
-
- /* This class can't be assigned twice so it conflicts with itsself */
- var $conflicts = array("goCupsServer");
-
- var $DisplayName = "";
- var $dn = NULL;
- var $acl;
- var $cn = "";
- var $goCupsServerStatus = "";
- var $view_logged =FALSE;
-
- function goCupsServer(&$config,$dn)
- {
- goService::goService($config,$dn);
- $this->DisplayName = _("Print service");
- }
-
-
- function execute()
- {
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","server/".get_class($this),$this->dn);
- }
-
- $smarty = get_smarty();
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
- }
- return($smarty->fetch(get_template_path("goCupsServer.tpl",TRUE,dirname(__FILE__))));
- }
-
- function getListEntry()
- {
- $fields = goService::getListEntry();
- $fields['Message'] = _("Print service");
- $fields['AllowEdit'] = false;
- return($fields);
- }
-
- function check()
- {
- $message = plugin::check();
- return($message);
- }
-
- function save_object()
- {
- plugin::save_object();
- }
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Cups"),
- "plDescription" => _("Print service")." ("._("Services").")",
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 100,
- "plSection" => array("administration"),
- "plCategory" => array("server"),
-
- "start" => _("Start"),
- "stop" => _("Stop"),
- "restart" => _("Restart"),
-
- "plProvidedAcls"=> array()
- ));
- }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_goFaxServer.inc b/plugins/admin/systems/class_goFaxServer.inc
deleted file mode 100644
index 1e5e04976..000000000
--- a/plugins/admin/systems/class_goFaxServer.inc
+++ /dev/null
@@ -1,103 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* This plugin only writes its objectClass */
- var $objectclasses = array("goFaxServer");
- var $attributes = array("goFaxAdmin", "goFaxPassword");
- var $StatusFlag = "goFaxServerStatus";
-
- /* This class can't be assigned twice so it conflicts with itsself */
- var $conflicts = array("goFaxServer");
-
- var $DisplayName = "";
- var $dn = NULL;
- var $acl;
-
- var $goFaxAdmin = "";
- var $goFaxPassword = "";
- var $goFaxServerStatus = "";
- var $cn = "";
- var $view_logged =FALSE;
-
- function goFaxServer(&$config,$dn)
- {
- goService::goService($config,$dn);
- $this->DisplayName = _("FAX database");
- }
-
-
- function execute()
- {
- $smarty = get_smarty();
-
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","server/".get_class($this),$this->dn);
- }
-
- /* Assign acls */
- $tmp = $this->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $translation ){
- $smarty->assign($name."ACL",$this->getacl($name));
- }
-
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
- }
- return($smarty->fetch(get_template_path("goFaxServer.tpl",TRUE,dirname(__FILE__))));
- }
-
-
- function getListEntry()
- {
- $fields = goService::getListEntry();
- $fields['Message'] = _("FAX database configuration");
- $fields['AllowEdit'] = true;
- return($fields);
- }
-
- function check()
- {
- $message = plugin::check();
- if (empty($this->goFaxAdmin)){
- $message[]= _("The attribute user is empty or contains invalid characters.");
- }
- if (empty($this->goFaxPassword)){
- $message[]= _("The attribute password is empty or contains invalid characters.");
- }
- return($message);
- }
-
-
- function save_object()
- {
- if(isset($_POST['goFaxServerPosted'])){
- plugin::save_object();
- }
- }
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Fax database"),
- "plDescription" => _("Fax database")." ("._("Services").")",
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 99,
- "plSection" => array("administration"),
- "plCategory" => array("server"),
-
- "plProvidedAcls"=> array(
- "goFaxAdmin" => _("Login name"),
- "goFaxPassword" => _("Password"))
- ));
- }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_goFonServer.inc b/plugins/admin/systems/class_goFonServer.inc
deleted file mode 100644
index 2e69a849d..000000000
--- a/plugins/admin/systems/class_goFonServer.inc
+++ /dev/null
@@ -1,182 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* This plugin only writes its objectClass */
- var $objectclasses = array("goFonServer");
- var $attributes = array("goFonAdmin", "goFonPassword","goFonAreaCode", "goFonCountryCode");
- var $StatusFlag = "goFonServerStatus";
-
- /* This class can't be assigned twice so it conflicts with itsself */
- var $conflicts = array("goFonServer");
-
- var $DisplayName = "";
- var $dn = NULL;
- var $cn ="";
- var $acl;
-
- var $goFonServerStatus = "";
- var $goFonPassword = "";
- var $goFonAdmin = "";
- var $goFonAreaCode = "";
- var $goFonCountryCode = "";
- var $view_logged =FALSE;
-
- var $orig_dn = "";
-
- function goFonServer(&$config,$dn)
- {
- goService::goService($config,$dn);
- $this->DisplayName = _("VoIP service");
-
- $this->orig_dn = $dn;
- }
-
-
- function execute()
- {
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","server/".get_class($this),$this->dn);
- }
-
- $smarty = get_smarty();
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
- }
-
- /* Assign acls */
- $tmp = $this->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $translation){
- $smarty->assign($name."ACL",$this->getacl($name));
- }
-
- return($smarty->fetch(get_template_path("goFonServer.tpl",TRUE,dirname(__FILE__))));
- }
-
-
- function getListEntry()
- {
- $fields = goService::getListEntry();
- $fields['Message'] = _("VoIP service - Asterisk management");
- $fields['AllowEdit'] = true;
- return($fields);
- }
-
- function check()
- {
- $message = plugin::check();
- if (empty($this->goFonAdmin)){
- $message[]= _("The attribute DB user is empty or contains invalid characters.");
- }
- if (empty($this->goFonPassword)){
- $message[]= _("The attribute password is empty or contains invalid characters.");
- }
- if (empty($this->goFonAreaCode)){
- $message[]= _("The attribute local dial prefix is empty or contains invalid characters.");
- }
- if (empty($this->goFonCountryCode)){
- $message[]= _("The attribute country dial prefix is empty or contains invalid characters.");
- }
- return($message);
- }
-
-
- function save_object()
- {
- if(isset($_POST['goFonServerPosted'])){
- plugin::save_object();
- }
- }
-
-
- function allow_remove()
- {
- /* Check if we are able to remove the asterisk database. If the database is still in use skip */
- if($this->is_account){
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
- $ldap->search("(&(goFonHomeServer=".$this->dn.")(|(uid=*)(cn=*)))",array("dn","uid","cn","goFonHomeServer"));
- if($ldap->count()){
-
- /* Number of entries shown in warning */
- $i = 3;
- $str = "";
- while(($attrs = $ldap->fetch()) && $i >= 0){
- $i --;
- if(isset($attrs['uid'][0])){
- $str .= $attrs['uid'][0]." ";
- }else{
- $str .= $attrs['cn'][0]." ";
- }
- }
-
- /* Some entries found */
- if($i != 3){
- return(sprintf(_("You can't remove the asterisk database extension, it is still in use by these objects '%s'."),trim($str)));
- }
- }
- }
- }
-
-
- function save()
- {
- goService::save();
- /* Update goFonAccounts if server was is renamed.
- Set attribute goFonHomeServer to current dn
- */
- if(in_array("goFonServer",$this->objectclasses)){
- if($this->orig_dn != "new" && $this->orig_dn != $this->dn){
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
- $ldap->search("(&(goFonHomeServer=".$this->orig_dn.")(|(objectClass=goFonAccount)(objectClass=goFonConference)))",array("goFonHomeServer"));
- $dns = array();
- while($attrs = $ldap->fetch()){
- $dns[] = $attrs['dn'];
- }
- foreach($dns as $dn){
- $ldap->cd($dn);
- $ldap->modify(array("goFonHomeServer" => $this->dn));
- show_ldap_error($ldap->get_error(),sprintf(_("Updating gofon home server failed for '%s'."),$dn));
- }
- }
-
- /* Updated config list of gofon servers */
- if($this->orig_dn == "new" || $this->orig_dn != $this->dn){
- $_SESSION['config']->load_servers();
- }
- }
- }
-
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("VoIP service"),
- "plDescription" => _("VoIP - asterisk management")." ("._("Services").")",
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 92,
- "plSection" => array("administration"),
- "plCategory" => array("server"),
-
- "plProvidedAcls"=> array(
- "start" => _("Start"),
- "stop" => _("Stop"),
- "restart" => _("Restart"),
-
- "goFonAdmin" => _("Admin"),
- "goFonPassword" => _("Password"),
- "goFonAreaCode" => _("Area code"),
- "goFonCountryCode"=> _("Country code"))
- ));
- }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_goGlpiServer.inc b/plugins/admin/systems/class_goGlpiServer.inc
deleted file mode 100644
index 07c07d427..000000000
--- a/plugins/admin/systems/class_goGlpiServer.inc
+++ /dev/null
@@ -1,109 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* This plugin only writes its objectClass */
- var $objectclasses = array("goGlpiServer");
- var $attributes = array("goGlpiAdmin","goGlpiDatabase","goGlpiPassword");
- var $StatusFlag = "goGlpiServerStatus";
-
- /* This class can't be assigned twice so it conflicts with itsself */
- var $conflicts = array("goGlpiServer");
-
- var $DisplayName = "";
- var $dn = NULL;
- var $cn = "";
- var $acl;
-
- var $goGlpiServerStatus ="";
- var $goGlpiAdmin ="";
- var $goGlpiDatabase ="";
- var $goGlpiPassword ="";
- var $view_logged =FALSE;
-
-
- function goGlpiServer(&$config,$dn)
- {
- goService::goService($config,$dn);
- $this->DisplayName = _("Inventory database");
- }
-
-
- function execute()
- {
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","server/".get_class($this),$this->dn);
- }
-
- $smarty = get_smarty();
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
- }
- $tmp = $this->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $translation ){
- $smarty->assign($name."ACL",$this->getacl($name));
- }
- return($smarty->fetch(get_template_path("goGlpiServer.tpl",TRUE,dirname(__FILE__))));
- }
-
-
- function getListEntry()
- {
- $fields = goService::getListEntry();
- $fields['Message'] = _("Inventory database service");
- $fields['AllowEdit'] = true;
- return($fields);
- }
-
- function check()
- {
- $message = plugin::check();
- if(empty($this->goGlpiAdmin)){
- $message[]= _("The attribute user is empty or contains invalid characters.");
- }
- if(empty($this->goGlpiDatabase)){
- $message[]= _("The attribute database is empty or contains invalid characters.");
- }
- return($message);
- }
-
-
- function save_object()
- {
- if(isset($_POST['goGlpiServer_posted'])){
- plugin::save_object();
- }
- }
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Inventory database"),
- "plDescription" => _("Inventory database")." ("._("Services").")" ,
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 93,
- "plSection" => array("administration"),
- "plCategory" => array("server"),
-
- "plProvidedAcls"=> array(
- "start" => _("Start"),
- "stop" => _("Stop"),
- "restart" => _("Restart"),
-
- "goGlpiAdmin" => _("Admin"),
- "goGlpiDatabase" => _("Database"),
- "goGlpiPassword" => _("Password"))
- ));
- }
-
-
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_goImapServer.inc b/plugins/admin/systems/class_goImapServer.inc
deleted file mode 100644
index e5681b942..000000000
--- a/plugins/admin/systems/class_goImapServer.inc
+++ /dev/null
@@ -1,187 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* This plugin only writes its objectClass */
- var $objectclasses = array("goImapServer");
-
- /* This class can't be assigned twice so it conflicts with itsself */
-
- var $DisplayName = "";
- var $dn = NULL;
- var $StatusFlag = "goImapServerStatus";
- var $attributes = array("goImapName","goImapConnect","goImapAdmin","goImapPassword",
- "goImapSieveServer","goImapSievePort",
- "cyrusImap","cyrusImapSSL","cyrusPop3","cyrusPop3SSL");
-
- var $cn = "";
-
- var $goImapName = "";
- var $goImapConnect = "";
- var $goImapAdmin = "";
- var $goImapPassword = "";
-
- var $goImapSieveServer = "";
- var $goImapSievePort = "";
-
- var $goImapServerStatus = "";
-
- var $cyrusImap = false;
- var $cyrusImapSSL = false;
- var $cyrusPop3 = false;
- var $cyrusPop3SSL = false;
- var $is_account = false;
- var $view_logged =FALSE;
-
- var $acl;
-
- var $Actions = array();
- var $conflicts = array("goImapServer","kolab");
-
- function goImapServer(&$config,$dn)
- {
- goService::goService($config,$dn);
-
- $this->DisplayName = _("IMAP/POP3 service");
-
- $this->Actions = array( SERVICE_STOPPED=>SERVICE_STOPPED,
- SERVICE_STARTED => SERVICE_STARTED,
- SERVICE_RESTARTED=>SERVICE_RESTARTED,
- "repair_database"=>_("Repair database"));
-
- }
-
- function execute()
- {
- $smarty = get_smarty();
-
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","server/".get_class($this),$this->dn);
- }
-
- /* set new status */
- if(isset($_POST['ExecAction'])){
- if(isset($this->Actions[$_POST['action']])){
-
- $tmp = $this->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $translation) {
- if(preg_match("/^".$_POST['action']."$/i",$name)){
- if($this->acl_is_writeable($name)){
- $this->setStatus($_POST['action']);
- }
- }
- }
-
- }
- }
-
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
- }
-
- $tmp = $this->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $translation){
- $smarty->assign($name."ACL",$this->getacl($name));
- }
- $smarty->assign("Actions",$this->Actions);
- $smarty->assign("is_new",$this->dn);
- $smarty->assign("is_acc",$this->initially_was_account);
- return($smarty->fetch(get_template_path("goImapServer.tpl",TRUE,dirname(__FILE__))));
- }
-
- function getListEntry()
- {
- $fields = goService::getListEntry();
- $fields['Message'] = _("IMAP/POP3 (Cyrus) service");
- $fields['AllowRemove']= true;
- $fields['AllowEdit'] = true;
- return($fields);
- }
-
- function check()
- {
- $message = plugin::check();
- if(empty($this->goImapName)){
- $message[] =_("Please specify a server identifier.");
- }
- if(empty($this->goImapConnect)){
- $message[] =_("Please specify a connect url.");
- }
- if(empty($this->goImapAdmin)){
- $message[] =_("Please specify an admin user.");
- }
- if(empty($this->goImapPassword)){
- $message[] =_("Please specify a password for the admin user.");
- }
-
- /* Check connect string */
- if (!preg_match('/^\{[^:]+:[0-9]+.*\}$/', $this->goImapConnect)){
- $message[]= sprintf(_("The imap connect string needs to be in the form '%s'."),
- '{server-name:port/options}');
- }
- if (!preg_match('/^[0-9]+$/', $this->goImapSievePort)){
- $message[]= _("The sieve port needs to be numeric.");
- }
-
- return ($message);
- }
-
-
- function save_object()
- {
- if(isset($_POST['goImapServerPosted'])){
- plugin::save_object();
-
- foreach(array("cyrusImap","cyrusImapSSL","cyrusPop3","cyrusPop3SSL") as $checkbox) {
-
- if($this->acl_is_writeable($checkbox)){
- if(!isset($_POST[$checkbox])){
- $this->$checkbox = false;
- }else{
- $this->$checkbox = true;
- }
- }
- }
- }
- }
-
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("IMAP/POP3"),
- "plDescription" => _("IMAP/POP3")." ("._("Services").")",
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 94,
- "plSection" => array("administration"),
- "plCategory" => array("server"),
-
- "plProvidedAcls"=> array(
-
- "start" => _("Start"),
- "stop" => _("Stop"),
- "restart" => _("Restart"),
- "repair_database" => _("Repair database"),
-
- "goImapName" =>_("Server identifier"),
- "goImapConnect" =>_("Connect URL"),
- "goImapAdmin" =>_("Admin user"),
- "goImapPassword" =>_("Admin password"),
- "goImapSievePort" =>_("Sieve port"),
- "cyrusImap" =>_("Start IMAP service"),
- "cyrusImapSSL" =>_("Start IMAP SSL service"),
- "cyrusPop3" =>_("Start POP3 service"),
- "cyrusPop3SSL" =>_("Start POP3 SSL service"))
- ));
- }
-
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_goKioskService.inc b/plugins/admin/systems/class_goKioskService.inc
deleted file mode 100644
index 287ed9e36..000000000
--- a/plugins/admin/systems/class_goKioskService.inc
+++ /dev/null
@@ -1,245 +0,0 @@
-DisplayName = _("Kiosk profile service");
- $this->baseDir = $this->config->search('environment', 'kioskpath',array('menu','tabs'));
- $this->server_path = preg_replace("/%cn/", $this->cn, $this->server_path);
-
- /* Load list of profiles and check if they still exists */
- if ($this->baseDir == ""){
- print_red(_("There is no KIOSKPATH defined in your gosa.conf. Can't manage kiosk profiles!"));
- }else{
- $this->gotoKioskProfiles = array();
- if(isset($this->attrs['gotoKioskProfile']) && is_array($this->attrs['gotoKioskProfile'])){
- for($i = 0 ; $i < $this->attrs['gotoKioskProfile']['count']; $i ++){
- $url = $this->attrs['gotoKioskProfile'][$i];
- $this->server_path = preg_replace("/\/[^\/]*$/","",$url);
- $name= preg_replace("/^.*\//","",$url);
- $this->gotoKioskProfiles[] = array('url' => $url ,
- 'name' => $name ,
- 'initial' =>TRUE,
- 'exists' => file_exists($this->baseDir."/".$name));
- }
- }
- }
- }
-
-
- function remove_from_parent()
- {
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
- $ldap->search("(&(objectClass=gotoEnvironment)(gotoKioskProfile=*/".$this->cn."/*))",array("cn"));
- $str ="";
- $cnt = 3;
- while($cnt && $attrs = $ldap->fetch()){
- $str .= $attrs['cn'][0].", ";
- $cnt --;
- }
- $str = preg_replace("/, $/","",$str);
- if($cnt != 3){
- print_red(sprintf(_("Can not remove kiosk profile service, it is currently in use by following user(s) : %s."),$str));
- }else{
- goService::remove_from_parent();
- }
- }
-
-
- function execute()
- {
- /* log actions */
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","server/".get_class($this),$this->dn);
- }
-
- /* Fill templating stuff */
- $smarty= get_smarty();
- $display= "";
-
- /* Add new kiosk profile
- * in profile directory ($this->baseDir);
- */
- if((isset($_POST['profileAdd']))&&(isset($_FILES['newProfile']))){
- $file = $_FILES['newProfile'];
- if(!file_exists($this->baseDir.$file['name'])){
- $tmp = array(
- 'url' => "" ,
- 'name' => $file['name'] ,
- 'initial' => FALSE,
- 'tmp_name'=> $file['tmp_name'],
- 'content' => file_get_contents($file['tmp_name']),
- 'exists' => TRUE);
- $this->gotoKioskProfiles[] = $tmp;
- }
- if(!is_writeable($this->baseDir)){
- print_red(sprintf(_("Can't save new kiosk profiles, possibly permission denied for folder: '%s'."),$this->baseDir));
- }
- }
-
- $only_once = true;
- foreach($_POST as $name => $value){
-
- if((preg_match("/^delkiosk_/",$name))&&($only_once)){
-
- /* Get id, name and path */
- $only_once = false;
- $id = preg_replace("/^delkiosk_/","",$name);
- $id = preg_replace("/_.*$/","",$id);
- $name = $this->gotoKioskProfiles[$id]['name'];
- $filename = $this->baseDir."/".$name;
-
- /* check if profile is still in use */
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
- $ldap->search("(&(objectClass=gotoEnvironment)(gotoKioskProfile=*".$name.")",array("cn","uid","gotoKioskProfile"));
- $used_by = "";
- $cnt = 3;
- while(($attrs = $ldap->fetch()) && ($cnt)){
- $cnt --;
- $check = preg_replace("/^.*\//i","",$attrs['gotoKioskProfile'][0]);
- if($check == $name){
- $used_by .= $attrs['cn'][0].", ";
- }
- }
- $used_by = preg_replace("/, $/","",$used_by);
- if(!empty($used_by)){
- print_red(sprintf(_("Can't remove kioks profile, it is still in use by the following objects '%s'."),$used_by));
- }else{
- if($this->gotoKioskProfiles[$id]['initial']){
- $res = @unlink($filename);
- if(!$res){
- if(!is_writeable($filename)){
- print_red(sprintf(_("Can't delete '%s'. Error was: permission denied."), $filename));
- }
- if(!file_exists($filename)){
- print_red(sprintf(_("Can't delete '%s'. Error was: file doesn't exist."), $filename));
- }
- }
- unset($this->gotoKioskProfiles[$id]);
- }
- }
- }
- }
-
- /* Display list of profiles */
- $divlist = new divSelectBox("KioskProfiles");
- $divlist -> SetHeight (300);
- foreach($this->gotoKioskProfiles as $key => $val ){
- $divlist->AddEntry(array(
- array("string"=>"".$val['name']." "),
- array("string"=>" " ,
- "attach"=>" style='border-right: 0px;width:24px; text-align:center;' ")
- ));
- }
-
- /* Assign all existing profiles to smarty */
- $smarty->assign("divlist",$divlist->DrawList());
- $smarty = get_smarty();
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
- }
- $smarty->assign("server_path",$this->server_path);
- return($smarty->fetch(get_template_path("goKioskService.tpl",TRUE,dirname(__FILE__))));
- }
-
- function getListEntry()
- {
- $fields = goService::getListEntry();
- $fields['Message'] = _("Kiosk profile service");
- $fields['AllowEdit'] = TRUE;
- $fields['AllowStart'] = false;
- $fields['AllowStop'] = false;
- $fields['AllowRestart'] = false;
- return($fields);
- }
-
- function check()
- {
- $message = plugin::check();
- return($message);
- }
-
- function save()
- {
- goService::save();
-
- $method = $this->server_path."/";
- $method = preg_replace("/\/\/*$/","/",$method);
- $this->attrs['gotoKioskProfile'] = array();
- foreach($this->gotoKioskProfiles as $profile){
- if(!$profile['initial']){
-
- $contents = $profile['content'];
- $path = $this->baseDir."/".$profile['name'];
- $fp = @fopen($path,"w");
- if(!$fp){
- print_red(_("Can't save new kiosk profiles, possibly permission denied for folder")." : ",$path);
- }else{
- fwrite($fp,$contents,strlen($contents));
- $this->attrs['gotoKioskProfile'][] = $method.$profile['name'];
- }
- @unlink($profile['tmp_name']);
- }else{
- $this->attrs['gotoKioskProfile'][] = $method.$profile['name'];
- }
- }
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
- $ldap->cd($this->dn);
- $ldap->modify($this->attrs);
- show_ldap_error($ldap->get_error(),_("Wohl kaum"));
- }
-
-
- function save_object()
- {
- if(isset($_POST['goKioskPosted'])){
- goService::save_object();
- if(isset($_POST['server_path'])){
- $this->server_path = get_post("server_path");
- }
- }
- }
-
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Kiosk"),
- "plDescription" => _("Kiosk profile management")." ("._("Services").")",
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 100,
- "plSection" => array("administration"),
- "plCategory" => array("server"),
-
- "plProvidedAcls"=> array()
- ));
- }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_goKrbServer.inc b/plugins/admin/systems/class_goKrbServer.inc
deleted file mode 100644
index 3eef127f4..000000000
--- a/plugins/admin/systems/class_goKrbServer.inc
+++ /dev/null
@@ -1,107 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* This plugin only writes its objectClass */
- var $objectclasses = array("goKrbServer");
- var $attributes = array("goKrbRealm", "goKrbAdmin","goKrbPassword");
- var $StatusFlag = "goKrbServerStatus";
-
- /* This class can't be assigned twice so it conflicts with itsself */
- var $conflicts = array("goKrbServer");
-
- var $DisplayName = "";
- var $dn = NULL;
- var $goKrbServerStatus= "";
- var $cn ="";
- var $goKrbRealm = "";
- var $goKrbAdmin = "";
- var $goKrbPassword ="";
- var $view_logged =FALSE;
-
- function goKrbServer(&$config,$dn)
- {
- goService::goService($config,$dn);
- $this->DisplayName = _("Kerberos service");
- }
-
-
- function execute()
- {
- $smarty = get_smarty();
-
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","server/".get_class($this),$this->dn);
- }
-
- $tmp = $this->plinfo();
- foreach($tmp['plProvidedAcls'] as $name => $translation){
- $smarty->assign($name."ACL",$this->getacl($name));
- }
-
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
- }
- return($smarty->fetch(get_template_path("goKrbServer.tpl",TRUE,dirname(__FILE__))));
- }
-
-
- function getListEntry()
- {
- $fields = goService::getListEntry();
- $fields['Message'] = _("Kerberos service (kadmin access informations)");
- $fields['AllowEdit'] = true;
- return($fields);
- }
-
- function check()
- {
- $message = plugin::check();
- /* goKrbPassword is a must field, if goKrbServer is used as objectClass */
- if (empty($this->goKrbPassword)){
- $message[]= sprintf(_("The specified kerberos password is empty."), $attr);
- }
- if (empty($this->goKrbAdmin)){
- $message[]= sprintf(_("The specified kerberos admin is empty."), $attr);
- }
- if (empty($this->goKrbRealm)){
- $message[]= sprintf(_("The specified kerberos realm is empty."), $attr);
- }
-
- return($message);
- }
-
-
- function save_object()
- {
- if(isset($_POST['goKrbServerPosted'])){
- plugin::save_object();
- }
- }
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Kerberos"),
- "plDescription" => _("Kerberos access information")." ("._("Services").")",
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 95,
- "plSection" => array("administration"),
- "plCategory" => array("server"),
-
- "plProvidedAcls"=> array(
- "goKrbRealm" => _("Realm"),
- "goKrbAdmin" => _("Admin"),
- "goKrbPassword" => _("Password"))
- ));
- }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_goLdapServer.inc b/plugins/admin/systems/class_goLdapServer.inc
deleted file mode 100644
index c16df0387..000000000
--- a/plugins/admin/systems/class_goLdapServer.inc
+++ /dev/null
@@ -1,97 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* This plugin only writes its objectClass */
- var $objectclasses = array("goLdapServer");
- var $attributes = array("goLdapBase");
- var $StatusFlag = "goLdapServerStatus";
-
- /* This class can't be assigned twice so it conflicts with itsself */
- var $conflicts = array("goLdapServer");
-
- var $DisplayName = "";
- var $dn = NULL;
- var $cn = "";
- var $goLdapServerStatus = "";
- var $goLdapBase = "";
- var $view_logged =FALSE;
-
- function goLdapServer(&$config,$dn)
- {
- goService::goService($config,$dn);
- $this->DisplayName = _("LDAP service");
- }
-
-
- function execute()
- {
-
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","server/".get_class($this),$this->dn);
- }
-
- $smarty = get_smarty();
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
- }
- $tmp = $this->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $translated){
- $smarty->assign($name."ACL",$this->getacl($name));
- }
- return($smarty->fetch(get_template_path("goLdapServer.tpl",TRUE,dirname(__FILE__))));
- }
-
-
- function getListEntry()
- {
- $fields = goService::getListEntry();
- $fields['Message'] = _("LDAP Service");
- $fields['AllowEdit'] = true;
- return($fields);
- }
-
-
-
- function check()
- {
- $message = plugin::check();
- if(empty($this->goLdapBase)){
- $message[] = _("The given base is empty or contains invalid characters.");
- }
- return($message);
- }
-
-
- function save_object()
- {
- if(isset($_POST['goLdapServerPosted'])){
- plugin::save_object();
- }
- }
-
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Ldap"),
- "plDescription" => _("Ldap")." ("._("Services").")",
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 96,
- "plSection" => array("administration"),
- "plCategory" => array("server"),
-
- "plProvidedAcls"=> array(
- "goLdapBase" => _("Ldap base"))
- ));
- }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_goLogDBServer.inc b/plugins/admin/systems/class_goLogDBServer.inc
deleted file mode 100644
index 3a193dbf2..000000000
--- a/plugins/admin/systems/class_goLogDBServer.inc
+++ /dev/null
@@ -1,106 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* This plugin only writes its objectClass */
- var $objectclasses = array("goLogDBServer");
- var $attributes = array("goLogAdmin", "goLogPassword");
- var $StatusFlag = "goLogDBServerStatus";
-
- /* This class can't be assigned twice so it conflicts with itsself */
- var $conflicts = array("goLogDBServer");
-
- var $DisplayName = "";
- var $dn = NULL;
- var $acl;
- var $cn = "";
- var $goLogDBServerStatus = "";
- var $goLogAdmin = "";
- var $goLogPassword = "";
- var $view_logged =FALSE;
-
-
- function goLogDBServer(&$config,$dn)
- {
- goService::goService($config,$dn);
- $this->DisplayName = _("Syslog service database");
- }
-
-
- function execute()
- {
- $smarty = get_smarty();
-
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","server/".get_class($this),$this->dn);
- }
-
- $tmp = $this->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $translation){
- $smarty->assign($name."ACL",$this->getacl($name));
- }
-
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
- }
- return($smarty->fetch(get_template_path("goLogDBServer.tpl",TRUE,dirname(__FILE__))));
- }
-
-
- function getListEntry()
- {
- $fields = goService::getListEntry();
- $fields['Message'] = _("Syslog service database");
- $fields['AllowEdit'] = true;
- return($fields);
- }
-
-
- function check()
- {
- $message = plugin::check();
- if (empty($this->goLogAdmin)){
- $message[]= sprintf_("The attribute user is empty or contains invalid characters.");
- }
- if (empty($this->goLogPassword)){
- $message[]= sprintf_("The attribute password is empty or contains invalid characters.");
- }
- return($message);
- }
-
-
- function save_object()
- {
- if(isset($_POST['goLogDBServerPosted'])){
- plugin::save_object();
- }
- }
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Logging database"),
- "plDescription" => _("Logging database")." ("._("Services").")",
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 97,
- "plSection" => array("administration"),
- "plCategory" => array("server"),
-
- "plProvidedAcls"=> array(
- "start" => _("Start"),
- "stop" => _("Stop"),
- "restart" => _("Restart"),
- "goLogAdmin" => _("Admin"),
- "goLogPassword" => _("Password"))
- ));
- }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_goMailServer.inc b/plugins/admin/systems/class_goMailServer.inc
deleted file mode 100644
index 742249ef7..000000000
--- a/plugins/admin/systems/class_goMailServer.inc
+++ /dev/null
@@ -1,725 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* This plugin only writes its objectClass */
- var $objectclasses = array("goMailServer");
-
- /* This class can't be assigned twice so it conflicts with itsself */
- var $DisplayName = "";
- var $dn = NULL;
- var $StatusFlag = "goMailServerStatus";
- var $attributes = array("description","postfixHeaderSizeLimit",
- "postfixMailboxSizeLimit","postfixMessageSizeLimit",
- "postfixMyDestinations","postfixMyDomain","postfixMyhostname",
- "postfixMyNetworks","postfixRelayhost","postfixTransportTable",
- "postfixSenderRestrictions","postfixRecipientRestrictions");
-
- var $goMailServerStatus ;
- var $postfixHeaderSizeLimit = 0;
- var $postfixMailboxSizeLimit = 0;
- var $postfixMessageSizeLimit = 0;
- var $postfixMyDestinations = array();
- var $postfixMyDomain = "";
- var $postfixMyhostname = "";
- var $postfixMyNetworks = array();
- var $postfixRelayhost = "";
- var $postfixTransportTable = array();
- var $postfixSenderRestrictions = array();
- var $postfixRecipientRestrictions = array();
- var $description = "";
- var $RestrictionFilters = array();
- var $TransportProtocols = array();
- var $Actions = array();
- var $cn = "";
- var $conflicts = array("goMailServer","kolab");
- var $view_logged =FALSE;
-
- function goMailServer(&$config,$dn)
- {
- goService::goService($config,$dn);
- $this->DisplayName = _("Mail smtp service (Postfix)");
-
- $this->Actions = array( SERVICE_STOPPED=>SERVICE_STOPPED,
- SERVICE_STARTED => SERVICE_STARTED,
- SERVICE_RESTARTED=>SERVICE_RESTARTED);
-
- /* Fill RestrictionFilters TransportProtocols from external hooks */
- $str = $this->config->data['TABS']['SERVERSERVICE'];
- $this->TransportProtocols =array("smtp"=>"SMTP");
- $this->RestrictionFilters = array("FILTER"=>"FILTER");
- foreach(array("ADDITIONALRESTRICTIONFILTERS"=>"RestrictionFilters",
- "ADDITIONALPROTOCOLLS" =>"TransportProtocols") as $file => $var){
- if(isset($this->config->data['MAIN'][$file])){
- $file = $this->config->data['MAIN'][$file];
- if((isset($file)) && is_readable($file)){
- $tmp = file_get_contents($file);
- $tmp2= split("\n",$tmp);
- foreach($tmp2 as $entry){
- if(empty($entry)) continue;
- if(preg_match("/:/",$entry)){
- $tmp3 = split(":",$entry);
- $r = $this->$var;
- $r[$tmp3[0]]=$tmp3[1];
- $this->$var = $r;
- }else{
- $r = $this->$var;
- $r[$entry] =$entry;
- $this->$var = $r;
- }
- }
- }
- }
- }
-
-
- /* Get postfix my networks */
- $this->postfixMyNetworks = array();
- $tmp = array();
- if(isset($this->attrs['postfixMyNetworks'][0])){
- $tmp = split(",",$this->attrs['postfixMyNetworks'][0]);
- foreach($tmp as $str){
- if(!empty($str)){
- $this->postfixMyNetworks[base64_encode($str)] = $str;
- }
- }
- }
-
-
- /* Create full name */
- if(isset($this->attrs['postfixMyDomain'][0])){
- $this->postfixMyhostname .= ".".$this->attrs['postfixMyDomain'][0];
- }
-
-
- /* Get postfix my domains */
- $this->postfixMyDestinations = array();
- if(isset($this->attrs['postfixMyDestinations'][0])){
- unset($this->attrs['postfixMyDestinations']['count']);
- foreach($this->attrs['postfixMyDestinations'] as $str){
- $this->postfixMyDestinations[base64_encode($str)] = $str;
- }
- }
-
-
- /* Get transport tables */
- $tmp = array();
- $this->postfixTransportTable = array();
- if(isset($this->attrs['postfixTransportTable'])){
- $tmp = array();
- unset($this->attrs['postfixTransportTable']['count']);
- foreach($this->attrs['postfixTransportTable'] as $entry){
-
- //0: offshore.vip.ms-europa.lhsystems.com smtp:172.28.0.2
-
- $Number = preg_replace('/^([^:]+):.*$/', '\\1', $entry);
- $Rest = trim(preg_replace("/^[0-9]*:/","",$entry));
-
- $Protocol_Destination = preg_replace("/^.*\ /","",$Rest);
- $Source = preg_replace("/\ .*$/","",$Rest);
-
- $Protocol = preg_replace ('/^([^:]+):.*$/', '\\1' ,trim($Protocol_Destination));
- $Destination = preg_replace ('/^[^:]+:(.*)$/', '\\1' ,trim($Protocol_Destination));
-
- $Destination = preg_replace ("/[\[\]]/","",$Destination);
-
- $tmp[$Number]['src'] = $Source;
- $tmp[$Number]['dst'] = $Destination;
- $tmp[$Number]['prt'] = $Protocol;
- }
- ksort($tmp);
- foreach($tmp as $entry){
- $this->postfixTransportTable[] = $entry;
- }
- }
-
-
- /* Get sender restrictions */
- $tmp = array();
- $this->postfixSenderRestrictions = array();
- if(isset($this->attrs['postfixSenderRestrictions'])){
- unset($this->attrs['postfixSenderRestrictions']['count']);
- foreach($this->attrs['postfixSenderRestrictions'] as $entry){
- $nr = preg_replace("/:.*$/","",$entry);
- $rest= trim(preg_replace("/^[^:]+:/","",$entry));
- $src = preg_replace("/ .*$/","",$rest);
- $rest= preg_replace("/^[^ ]+ /","",$rest);
- $dst = preg_replace("/^.* /","",$rest);
- $prt = preg_replace("/ .*$/","",$rest);
-
- $tmp[$nr]['src'] = $src;
- $tmp[$nr]['dst'] = $dst;
- $tmp[$nr]['filter'] = $prt;
- }
- ksort($tmp);
- foreach($tmp as $entry){
- $this->postfixSenderRestrictions[] = $entry;
- }
- }
-
-
- /* Get sender restrictions */
- $tmp = array();
- $this->postfixRecipientRestrictions = array();
- if(isset($this->attrs['postfixRecipientRestrictions'])){
- unset($this->attrs['postfixRecipientRestrictions']['count']);
- foreach($this->attrs['postfixRecipientRestrictions'] as $entry){
- $nr = preg_replace("/:.*$/","",$entry);
- $rest= trim(preg_replace("/^[^:]+:/","",$entry));
- $src = preg_replace("/ .*$/","",$rest);
- $rest= preg_replace("/^[^ ]+ /","",$rest);
- $dst = preg_replace("/^.* /","",$rest);
- $prt = preg_replace("/ .*$/","",$rest);
-
- $tmp[$nr]['src'] = $src;
- $tmp[$nr]['dst'] = $dst;
- $tmp[$nr]['filter'] = $prt;
- }
- ksort($tmp);
- foreach($tmp as $entry){
- $this->postfixRecipientRestrictions[] = $entry;
- }
- }
-
- }
-
- function execute()
- {
- $smarty = get_smarty();
-
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","server/".get_class($this),$this->dn);
- }
-
- $tmp = $this->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $translation){
- $smarty->assign($name."ACL",$this->getacl($name));
- }
-
- $delAr = array(
- "TranslationDel_"=>"TranslationDel",
- "SenderRestrictDel_"=>"SenderRestrictDel",
- "RecipientRestrictDel_"=>"RecipientRestrictDel");
-
- $once = true;
- $s_action = "";
- $s_entry = "";
-
- /* Check posts for some intruductions */
- foreach($_POST as $name => $value){
- foreach($delAr as $preg => $type){
- if((preg_match("/^".$preg."/",$name)) && ($once)){
- $once = false;
- $s_action = $type;
- $s_entry = preg_replace("/^".$preg."/","",$name);
- $s_entry = preg_replace("/_[xy]$/","",$s_entry);
- }
- }
-
-
- if(preg_match("/^TranslationUp_/",$name) && $once && ($this->acl_is_writeablei("postfixTransportTableACL"))){
- $once = false;
- $key = preg_replace("/^TranslationUp_/","",$name);
- $key = preg_replace("/_[xy]$/","",$key);
- $this->postfixTransportTable = $this->ArrayUp($key,$this->postfixTransportTable) ;
- }
- if(preg_match("/^TranslationDown_/",$name) && $once && ($this->acl_is_writeable("postfixTransportTableACL"))){
- $once = false;
- $key = preg_replace("/^TranslationDown_/","",$name);
- $key = preg_replace("/_[xy]$/","",$key);
- $this->postfixTransportTable = $this->ArrayDown($key,$this->postfixTransportTable) ;
- }
- if(preg_match("/^SenderRestrictUp_/",$name) && $once && ($this->acl_is_writeable("postfixSenderRestrictionsACL"))){
- $once = false;
- $key = preg_replace("/^SenderRestrictUp_/","",$name);
- $key = preg_replace("/_[xy]$/","",$key);
- $this->postfixSenderRestrictions = $this->ArrayUp($key,$this->postfixSenderRestrictions) ;
- }
- if(preg_match("/^SenderRestrictDown_/",$name) && $once && ($this->acl_is_writeable("postfixSenderRestrictionsACL"))){
- $once = false;
- $key = preg_replace("/^SenderRestrictDown_/","",$name);
- $key = preg_replace("/_[xy]$/","",$key);
- $this->postfixSenderRestrictions = $this->ArrayDown($key,$this->postfixSenderRestrictions) ;
- }
- if(preg_match("/^RecipientRestrictUp_/",$name) && $once && ($this->acl_is_writeable("postfixRecipientRestrictionsACL"))){
- $once = false;
- $key = preg_replace("/^RecipientRestrictUp_/","",$name);
- $key = preg_replace("/_[xy]$/","",$key);
- $this->postfixRecipientRestrictions = $this->ArrayUp($key,$this->postfixRecipientRestrictions) ;
- }
- if(preg_match("/^RecipientRestrictDown_/",$name) && $once && ($this->acl_is_writeable("postfixRecipientRestrictionsACL"))){
- $once = false;
- $key = preg_replace("/^RecipientRestrictDown_/","",$name);
- $key = preg_replace("/_[xy]$/","",$key);
- $this->postfixRecipientRestrictions = $this->ArrayDown($key,$this->postfixRecipientRestrictions) ;
- }
- }
-
-
- /* Add delete my network entry */
- if((isset($_POST['AddpostfixMyNetworks'])) && (!empty($_POST['NewString_postfixMyNetworks']))){
- $str = $_POST['NewString_postfixMyNetworks'];
- $this->postfixMyNetworks[base64_encode($str)] = $str;
- }
-
- if((isset($_POST['DelpostfixMyNetworks'])) && isset($_POST['Select_postfixMyNetworks']) &&(count($_POST['Select_postfixMyNetworks']))){
- foreach($_POST['Select_postfixMyNetworks'] as $str ){
- unset($this->postfixMyNetworks[$str]);
- }
- }
-
-
- /* Add delete my domain entry */
- if($this->acl_is_writeable("postfixMyDestinations")){
- if((isset($_POST['AddpostfixMyDestinations'])) && (!empty($_POST['NewString_postfixMyDestinations']))){
- $str = $_POST['NewString_postfixMyDestinations'];
- $this->postfixMyDestinations[base64_encode($str)] = $str;
- }
-
- if((isset($_POST['DelpostfixMyDestinations'])) && isset($_POST['Select_postfixMyDestinations']) &&(count($_POST['Select_postfixMyDestinations']))){
- foreach($_POST['Select_postfixMyDestinations'] as $str ){
- unset($this->postfixMyDestinations[$str]);
- }
- }
- }
-
-
- /* Add sender restriction */
- if($this->acl_is_writeable("postfixSenderRestrictions")){
- if(($s_action == "SenderRestrictDel") && (isset($this->postfixSenderRestrictions[$s_entry]))){
- unset($this->postfixSenderRestrictions[$s_entry]);
- }
-
- if(isset($_POST['AddpostfixSenderRestrictions'])){
- $src = $_POST['Source_postfixSenderRestrictions'];
- $dst = $_POST['Destination_postfixSenderRestrictions'];
- $Filter = $_POST['SenderRestrictionFilter'];
- $tmp['src'] = $src;
- $tmp['dst'] = $dst;
- $tmp['filter'] = $Filter;
- $this->postfixSenderRestrictions[] = $tmp;
- }
- }
-
-
- /* Add sender restriction */
- if($this->acl_is_writeable("postfixRecipientRestrictions")){
- if(($s_action == "RecipientRestrictDel") && (isset($this->postfixRecipientRestrictions[$s_entry]))){
- unset($this->postfixRecipientRestrictions[$s_entry]);
- }
-
- if(isset($_POST['AddpostfixRecipientRestrictions'])){
- $src = $_POST['Source_postfixRecipientRestrictions'];
- $dst = $_POST['Destination_postfixRecipientRestrictions'];
- $Filter = $_POST['RecipientRestrictionFilter'];
- $tmp['src'] = $src;
- $tmp['dst'] = $dst;
- $tmp['filter'] = $Filter;
- $this->postfixRecipientRestrictions[] = $tmp;
- }
- }
-
- /* Handle transports */
- if($this->acl_is_writeable("postfixTransportTable")){
- if(($s_action == "TranslationDel") && (isset($this->postfixTransportTable[$s_entry]))){
- unset($this->postfixTransportTable[$s_entry]);
- }
-
- if(isset($_POST['AddpostfixTransportTable'])){
- $src = trim($_POST['Source_postfixTransportTable']);
- $dst = trim($_POST['Destination_postfixTransportTable']);
- $prt = trim($_POST['TransportProtocol']);
-
- if((!empty($src)) && (!empty($dst))){
- if(preg_match("/:/",$dst)){
- $tmp = split("\:",$dst);
- $port = trim($tmp[1]);
- $ip = trim($tmp[0]);
-
- if((is_ip($ip)) && (is_numeric($port))){
- $dst = "[".$ip."]:".$port;
- }
- }
- if(is_ip($dst)){
- $dst = "[".$dst."]";
- }
- $tmp2 ['src'] = $src;
- $tmp2 ['dst'] = $dst;
- $tmp2 ['prt'] = $prt;
-
- $this->postfixTransportTable[] = $tmp2;
- }
- }
- }
-
- /* Set attributes */
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
- }
-
-
- /* Create divList for translation tables */
- $divTranslation = new divSelectBox("TransportProtocols");
- $divTranslation->SetHeight(90);
- foreach($this->postfixTransportTable as $key => $entry){
- $img = "";
-
- if($key != 0 && $this->acl_is_writeable("postfixTransportTable")){
- $img.= " ";
- }else{
- $img.= " ";
- }
- if(($key+1) < count($this->postfixTransportTable) && $this->acl_is_writeable("postfixTransportTable")){
- $img.= " ";
- }else{
- $img.= " ";
- }
-
- if($this->acl_is_writeable("postfixTransportTable")){
- $img.= " ";
- }
- $field1 = array("string"=> $entry['src']);
- $field2 = array("string"=> $entry['dst']);
- $field3 = array("string"=> $entry['prt'],"attach"=>"style='width:120px;'");
- $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
- $divTranslation->AddEntry(array($field1,$field2,$field3,$field4,));
- }
- $smarty->assign("Div_postfixTransportTable" ,$divTranslation->DrawList());
-
-
- /* Create divList for sender restrictions */
- $DivSenderRestrict = new divSelectBox("postfixSenderRestrictions");
- $DivSenderRestrict->SetHeight(90);
- foreach($this->postfixSenderRestrictions as $key => $entry){
- $img ="";
-
- if($key != 0 && $this->acl_is_writeable("postfixSenderRestrictions")){
- $img.= " ";
- }else{
- $img.= " ";
- }
- if(($key+1) < count($this->postfixSenderRestrictions) && $this->acl_is_writeable("postfixSenderRestrictions")){
- $img.= " ";
- }else{
- $img.= " ";
- }
-
- if($this->acl_is_writeable("postfixSenderRestrictions")){
- $img.= " ";
- }
-
- $field1 = array("string"=> $entry['src']);
- $field2 = array("string"=> $entry['dst']);
- $field3 = array("string"=> $entry['filter'],"attach"=>"style='width:100px;'");
- $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
- $DivSenderRestrict->AddEntry(array($field1,$field2,$field3,$field4,));
- }
- $smarty->assign("Div_postfixSenderRestrictions" ,$DivSenderRestrict->DrawList());
-
-
- /* Create divList for translation tables */
- $DivRecipientRestrict = new divSelectBox("postfixRecipientRestrictions");
- $DivRecipientRestrict->SetHeight(90);
-
- foreach($this->postfixRecipientRestrictions as $key => $entry){
- $img = "";
- if($key != 0 && $this->acl_is_writeable("postfixRecipientRestrictions")){
- $img.= " ";
- }else{
- $img.= " ";
- }
- if(($key+1) < count($this->postfixRecipientRestrictions) && $this->acl_is_writeable("postfixRecipientRestrictions")){
- $img.= " ";
- }else{
- $img.= " ";
- }
-
- if($this->acl_is_writeable("postfixRecipientRestrictions")){
- $img.= " ";
- }
- $field1 = array("string"=> $entry['src']);
- $field2 = array("string"=> $entry['dst']);
- $field3 = array("string"=> $entry['filter'],"attach"=>"style='width:100px;'");
- $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
- $DivRecipientRestrict->AddEntry(array($field1,$field2,$field3,$field4,));
- }
- $smarty->assign("Div_postfixRecipientRestrictions" ,$DivRecipientRestrict->DrawList());
-
-
- /* set new status */
- if(isset($_POST['ExecAction'])){
- if(isset($this->Actions[$_POST['action']])){
- $this->setStatus($_POST['action']);
- }
- }
-
-
- $smarty->assign("is_new", $this->dn);
- $smarty->assign("is_acc", $this->initially_was_account);
- $smarty->assign("TransportProtocols", $this->TransportProtocols);
- $smarty->assign("Actions", $this->Actions);
- $smarty->assign("RestrictionFilters", $this->RestrictionFilters);
- $smarty->assign("postfixTransportTable" , $this->getTransports());
- $smarty->assign("postfixSenderRestrictions" , $this->getSenderRestrictions());
- $smarty->assign("postfixRecipientRestrictions" ,$this->getRecipientRestrictions());
-
- return($smarty->fetch(get_template_path("goMailServer.tpl",TRUE,dirname(__FILE__))));
- }
-
-
- /* return transports formated for select box */
- function getTransports()
- {
- $ret = array();
- foreach($this->postfixTransportTable as $key => $vals){
- $ret[$key] = $vals['src']." -> ".$vals['prt'].":".$vals['dst'];
- }
- return($ret);
- }
-
-
- /* return sender restriction formated for select box */
- function getSenderRestrictions()
- {
- $ret = array();
- foreach($this->postfixSenderRestrictions as $key => $vals){
- $ret[$key] = $vals['src']." ".$vals['filter']." ".$vals['dst'];
- }
- return($ret);
- }
-
-
- /* return recipient restriction formated for select box */
- function getRecipientRestrictions()
- {
- $ret = array();
- foreach($this->postfixRecipientRestrictions as $key => $vals){
- $ret[$key] = $vals['src']." ".$vals['filter']." ".$vals['dst'];
- }
- return($ret);
- }
-
-
- /* Return list entry */
- function getListEntry()
- {
- $fields = goService::getListEntry();
- $fields['Message'] = _("Mail smtp service (Postfix)");
- $fields['AllowEdit'] = true;
- return($fields);
- }
-
-
- function save()
- {
- $this->postfixMyDomain = preg_replace("/^[^\.]+\./","",$this->postfixMyhostname);
- $this->postfixMyhostname = preg_replace("/\..*$/","",$this->postfixMyhostname);
-
- plugin::save();
-
- /* Fix transport table*/
- $i = 0 ;
- $this->attrs['postfixTransportTable'] = array();
- foreach($this->postfixTransportTable as $key => $entry){
- $this->attrs['postfixTransportTable'][] = $i.": ".$entry['src']." ".$entry['prt'].":".$entry['dst'];
- $i ++;
- }
-
-
- /* Fix sender restrictions */
- $i = 0;
- $this->attrs['postfixSenderRestrictions'] =array();
- foreach($this->postfixSenderRestrictions as $key => $entry){
- $this->attrs['postfixSenderRestrictions'][] = $i.": ".$entry['src']." ".$entry['filter']." ".$entry['dst'];
- $i ++;
- }
-
-
- /* Fix recipient restrictions */
- $i = 0;
- $this->attrs['postfixRecipientRestrictions'] =array();
- foreach($this->postfixRecipientRestrictions as $key => $entry){
- $this->attrs['postfixRecipientRestrictions'][] = $i.": ".$entry['src']." ".$entry['filter']." ".$entry['dst'];
- $i ++;
- }
-
-
- /* Fix mydomains */
- $this->attrs['postfixMyDestinations'] = array();
- foreach($this->postfixMyDestinations as $entry){
- $this->attrs['postfixMyDestinations'][] =$entry;
- }
-
-
- /* Fix mydomains */
- if(count($this->postfixMyNetworks)){
- $this->attrs['postfixMyNetworks'] = "";
- foreach($this->postfixMyNetworks as $entry){
- $this->attrs['postfixMyNetworks'] .=$entry.",";
- }
- $this->attrs['postfixMyNetworks'] = preg_replace("/,$/","",$this->attrs['postfixMyNetworks']);
- }else{
- $this->attrs['postfixMyNetworks'] = array();
- }
-
-
- /* Check if this is a new entry ... add/modify */
- $ldap = $this->config->get_ldap_link();
- $ldap->cat($this->dn,array("objectClass"));
- if($ldap->count()){
- $ldap->cd($this->dn);
- $ldap->modify($this->attrs);
- }else{
- $ldap->cd($this->dn);
- $ldap->add($this->attrs);
- }
- show_ldap_error($ldap->get_error(), sprintf(_("Saving server services/mail with dn '%s' failed."),$this->dn));
- if($this->initially_was_account){
- $this->handle_post_events("modify");
- new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- }else{
- $this->handle_post_events("add");
- new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- }
-
- }
-
-
- function check()
- {
- $message =plugin::check();
-
- if(!is_numeric($this->postfixHeaderSizeLimit)){
- $message[] = _("Please specify a numeric value for header size limit.");
- }
-
- if(!is_numeric($this->postfixMailboxSizeLimit)){
- $message[] = _("Please specify a numeric value for mailbox size limit.");
- }
-
- if(!is_numeric($this->postfixMessageSizeLimit)){
- $message[] = _("Please specify a numeric value for message size limit.");
- }
-
- return $message;
- }
-
-
- /* Combine new array */
- function combineArrays($ar0,$ar1,$ar2)
- {
- $ret = array();
- if(is_array($ar0))
- foreach($ar0 as $ar => $a){
- $ret[]=$a;
- }
- if(is_array($ar1))
- foreach($ar1 as $ar => $a){
- $ret[]=$a;
- }
- if(is_array($ar2))
- foreach($ar2 as $ar => $a){
- $ret[]=$a;
- }
- return($ret);
- }
-
-
- function getpos($atr,$attrs)
- {
- $i = 0;
- foreach($attrs as $attr => $name) {
- $i++;
- if($attr == $atr){
- return($i);
- }
- }
-
- return(-1);
- }
-
-
- /* TRansports the geiven Arraykey one position up*/
- function ArrayUp($atr,$attrs)
- {
- $ret = $attrs;
- $pos = $this->getpos($atr,$attrs) ;
- $cn = count($attrs);
- if(!(($pos == -1)||($pos == 1))){
- $before = array_slice($attrs,0,($pos-2));
- $mitte = array_reverse(array_slice($attrs,($pos-2),2));
- $unten = array_slice($attrs,$pos);
- $ret = array();
- $ret = $this->combineArrays($before,$mitte,$unten);
- }
- return($ret);
- }
-
-
- /* TRansports the geiven Arraykey one position up*/
- function ArrayDown($atr,$attrs)
- {
- $ret = $attrs;
- $pos = $this->getpos($atr,$attrs) ;
- $cn = count($attrs);
- if(!(($pos == -1)||($pos == $cn))){
- $before = array_slice($attrs,0,($pos-1));
- $mitte = array_reverse(array_slice($attrs,($pos-1),2));
- $unten = array_slice($attrs,($pos+1));
- $ret = array();
- $ret = $this->combineArrays($before,$mitte,$unten);
- }
- return($ret);
- }
-
- function save_object()
- {
- plugin::save_object();
- }
-
-
- function PrepareForCopyPaste($source)
- {
- plugin::PrepareForCopyPaste($source);
-
- $source_o = new goMailServer($this->config,$source['dn']);
- foreach(array("postfixMyDomain","postfixMyhostname","postfixMyNetworks","postfixTransportTable","postfixSenderRestrictions","postfixRecipientRestrictions","postfixMyDestinations") as $attr){
- $this->$attr = $source_o->$attr;
- }
- }
-
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Mail smtp (Postfix)"),
- "plDescription" => _("Mail smtp - Postfix")." ("._("Services").")",
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 98,
- "plSection" => array("administration"),
- "plCategory" => array("server"),
-
- "plProvidedAcls"=> array(
- "postfixMyhostname" => _("Visible full qualified hostname"),
- "description" => _("Description"),
- "postfixHeaderSizeLimit" => _("Header size limit"),
- "postfixMailboxSizeLimit" => _("Max mailbox size"),
- "postfixMessageSizeLimit" => _("Max message size"),
- "postfixMyDestinations" => _("Domains to accept mail for"),
- "postfixMyNetworks" => _("Local networks"),
- "postfixRelayhost" => _("Relay host"),
- "postfixTransportTable" => _("Transport table"),
- "postfixSenderRestrictions" => _("Restrictions for sender"),
- "postfixRecipientRestrictions"=> _("Restrictions for recipient"))
- ));
- }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_goNtpServer.inc b/plugins/admin/systems/class_goNtpServer.inc
deleted file mode 100644
index b179ae95b..000000000
--- a/plugins/admin/systems/class_goNtpServer.inc
+++ /dev/null
@@ -1,147 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* This plugin only writes its objectClass */
- var $objectclasses = array("goNtpServer");
- var $attributes = array("goTimeSource");
- var $StatusFlag = "goNtpServerStatus";
-
- /* This class can't be assigned twice so it conflicts with itsself */
- var $conflicts = array("goNtpServer");
-
- var $DisplayName = "";
- var $dn = NULL;
- var $goTimeSource = array();
- var $goNtpServerStatus= "";
- var $acl;
- var $cn = "";
- var $view_logged =FALSE;
-
- function goNtpServer(&$config,$dn)
- {
- goService::goService($config,$dn);
- $this->DisplayName = _("Time service (NTP)");
-
- /* Load arrays */
- $tmp = array();
- if (isset($this->attrs['goTimeSource'])){
- for ($i= 0; $i<$this->attrs['goTimeSource']['count']; $i++){
- $tmp[$this->attrs['goTimeSource'][$i]]= $this->attrs['goTimeSource'][$i];
- }
- }
- $this->goTimeSource= $tmp;
- }
-
-
- function execute()
- {
- $smarty = get_smarty();
-
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","server/".get_class($this),$this->dn);
- }
-
- /* Here we add a new entry */
- if(isset($_POST['NewNTPAdd']) && $_POST['NewNTPExport'] != "" && $this->acl_is_writeable("goTimeSource")) {
- $this->goTimeSource[$_POST['NewNTPExport']]= $_POST['NewNTPExport'];
- asort($this->goTimeSource);
- }
-
- /* Deleting an Entry, is a bit more complicated than adding one*/
- if((isset($_POST['DelNTPEnt'])) && (isset($_POST['goTimeSource'])) && $this->acl_is_writeable("goTimeSource")) {
- foreach ($_POST['goTimeSource'] as $entry){
- if (isset($this->goTimeSource[$entry])){
- unset($this->goTimeSource[$entry]);
- }
- }
- }
-
- $smarty->assign("goNtpServerACL", $this->getacl("goNtpServer")) ;
- $smarty->assign("goTimeSource" , $this->goTimeSource);
- return($smarty->fetch(get_template_path("goNtpServer.tpl",TRUE,dirname(__FILE__))));
- }
-
-
- function getListEntry()
- {
- $fields = goService::getListEntry();
- $fields['Message'] = _("Time service (NTP)");
- $fields['AllowEdit'] = true;
- return($fields);
- }
-
-
- function save()
- {
- plugin::save();
- $this->attrs['goTimeSource'] =array();
- foreach($this->goTimeSource as $entry){
- $this->attrs['goTimeSource'][] = $entry;
- }
- /* Check if this is a new entry ... add/modify */
- $ldap = $this->config->get_ldap_link();
- $ldap->cat($this->dn,array("objectClass"));
- if($ldap->count()){
- $ldap->cd($this->dn);
- $ldap->modify($this->attrs);
- }else{
- $ldap->cd($this->dn);
- $ldap->add($this->attrs);
- }
- show_ldap_error($ldap->get_error(), sprintf(_("Saving server services/goNtpServer with dn '%s' failed."),$this->dn));
- if($this->initially_was_account){
- $this->handle_post_events("modify");
- new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- }else{
- $this->handle_post_events("add");
- new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- }
- }
-
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Time service"),
- "plDescription" => _("Time service - NTP")." ("._("Services").")",
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 91,
- "plSection" => array("administration"),
- "plCategory" => array("server"),
-
- "plProvidedAcls"=> array(
- "goTimeSource" =>_("Ntp source"))
- ));
- }
-
-
- function PrepareForCopyPaste($source)
- {
- plugin::PrepareForCopyPaste($source);
-
- /* Load arrays */
- $tmp = array();
- if (isset($source['goTimeSource'])){
- for ($i= 0; $i<$source['goTimeSource']['count']; $i++){
- $tmp[$source['goTimeSource'][$i]]= $source['goTimeSource'][$i];
- }
- }
- $this->goTimeSource= $tmp;
-
-
- }
-
- function check(){ return array();}
-
- function save_object(){;}
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_goService.inc b/plugins/admin/systems/class_goService.inc
deleted file mode 100644
index edfd3d7d5..000000000
--- a/plugins/admin/systems/class_goService.inc
+++ /dev/null
@@ -1,238 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* This plugin only writes its objectClass */
- var $objectclasses = array();
- var $attributes = array();
- var $StatusFlag = "";
-
- /* This class can't be assigned twice so it conflicts with itsself */
- var $conflicts = array();
- var $dn = NULL;
- var $cn = "";
- var $DisplayName = "";
- var $view_logged =FALSE;
-
-
- /* Construcktion */
- function goService(&$config,$dn)
- {
- plugin::plugin($config,$dn);
- $this->DisplayName = _("Empty service");
- }
-
-
- /* Create content */
- function execute()
- {
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","server/".get_class($this),$this->dn);
- }
-
- $str ="".
- " ".
- " ".
- "
";
- return($str);
- }
-
-
- /* Get service information for serverService plugin */
- function getListEntry()
- {
-
- $this->updateStatusState();
-
- /* Assign status flag */
- if(!empty($this->StatusFlag)){
- $flag = $this->StatusFlag;
- $fields['Status'] = $this->$flag;
- }else{
- $fields['Status'] = "";
- }
-
- /* Name displayed in service overview */
- $fields['Message'] = _("Empty service");
-
- /* Allow/disallow some functions */
- $fields['AllowStart'] = $this->acl_is_writeable("start");
- $fields['AllowStop'] = $this->acl_is_writeable("stop");
- $fields['AllowRestart'] = $this->acl_is_writeable("restart");
- $fields['AllowRemove'] = $this->acl_is_removeable();
- $fields['AllowEdit'] = true;
- return($fields);
- }
-
-
- /* Remove service */
- function remove_from_parent()
- {
- if(!$this->initially_was_account || !$this->acl_is_removeable()){
- return;
- }
-
- plugin::remove_from_parent();
-
- /* Remove status flag, it is not a memeber of
- this->attributes, so ensure that it is deleted too */
- if(!empty($this->StatusFlag)){
- $this->attrs[$this->StatusFlag] = array();
- }
-
- /* Check if this is a new entry ... add/modify */
- $ldap = $this->config->get_ldap_link();
- $ldap->cat($this->dn,array("objectClass"));
- if($ldap->count()){
- $ldap->cd($this->dn);
- $ldap->modify($this->attrs);
- }else{
- $ldap->cd($this->dn);
- $ldap->add($this->attrs);
-
- }
-
- new log("remove","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-
- show_ldap_error($ldap->get_error(), sprintf(_("Removing of server services/".get_class($this)." - (".$this->DisplayName.") with dn '%s' failed."),$this->dn));
- $this->handle_post_events("remove");
- }
-
-
- /* Save service */
- function save()
- {
- plugin::save();
- /* Check if this is a new entry ... add/modify */
- $ldap = $this->config->get_ldap_link();
- $ldap->cat($this->dn,array("objectClass"));
- if($ldap->count()){
- $ldap->cd($this->dn);
- $ldap->modify($this->attrs);
- }else{
- $ldap->cd($this->dn);
- $ldap->add($this->attrs);
- }
- if($this->initially_was_account){
- new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- $this->handle_post_events("modify");
- }else{
- $this->handle_post_events("add");
- new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- }
- show_ldap_error($ldap->get_error(), sprintf(_("Saving of server services/".get_class($this)." - (".$this->DisplayName.") with dn '%s' failed."),$this->dn));
- }
-
-
- /* Directly save new status flag */
- function setStatus($value)
- {
- if($value == "none") return;
-
- /* Can't set status flag for new services (Object doesn't exists in ldap tree) */
- if(!$this->initially_was_account) return;
-
- /* Can't set status flag, if no flag is specified */
- if(empty($this->StatusFlag)){
- return;
- }
-
- /* Get object (server), update status flag and save changes */
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->dn);
- $ldap->cat($this->dn,array("objectClass"));
- if($ldap->count()){
-
- $tmp = $ldap->fetch();
- for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
- $attrs['objectClass'][] = $tmp['objectClass'][$i];
- }
- $flag = $this->StatusFlag;
- $attrs[$flag] = $value;
- $this->$flag = $value;
- $ldap->modify($attrs);
- show_ldap_error($ldap->get_error(), sprintf(_("Set status flag for server services/".get_class($this)." - (".$this->DisplayName.") with dn '%s' failed."),$this->dn));
- $this->action_hook();
- }
- }
-
-
- function check()
- {
- $message = plugin::check();
- return($message);
- }
-
-
- function save_object()
- {
- plugin::save_object();
- }
-
-
- function action_hook($add_attrs= array())
- {
- /* Find postcreate entries for this class */
- $command= $this->config->search(get_class($this), "ACTION_HOOK",array('menu','tabs'));
- if ($command != ""){
-
- /* Walk through attribute list */
- foreach ($this->attributes as $attr){
- if (!is_array($this->$attr)){
- $command= preg_replace("/%$attr/", $this->$attr, $command);
- }
- }
- $command= preg_replace("/%dn/", $this->dn, $command);
-
- /* Additional attributes */
- foreach ($add_attrs as $name => $value){
- $command= preg_replace("/%$name/", $value, $command);
- }
-
- /* If there are still some %.. in our command, try to fill these with some other class vars */
- if(preg_match("/%/",$command)){
- $attrs = get_object_vars($this);
- foreach($attrs as $name => $value){
- if(!is_string($value)) continue;
- $command= preg_replace("/%$name/", $value, $command);
- }
- }
-
- if (check_command($command)){
- @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
- $command, "Execute");
-
- exec($command);
- } else {
- $message= sprintf(_("Command '%s', specified as ACTION_HOOK for plugin '%s' doesn't seem to exist."), $command, get_class($this));
- print_red ($message);
- }
- }
- }
-
-
- /* Get updates for status flag */
- function updateStatusState()
- {
- if(empty($this->StatusFlag)) return;
-
- $attrs = array();
- $flag = $this->StatusFlag;
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->cn);
- $ldap->cat($this->dn,array($flag));
- if($ldap->count()){
- $attrs = $ldap->fetch();
- }
- if(isset($attrs[$flag][0])){
- $this->$flag = $attrs[$flag][0];
- }
- }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_goShareServer.inc b/plugins/admin/systems/class_goShareServer.inc
deleted file mode 100644
index 354d78037..000000000
--- a/plugins/admin/systems/class_goShareServer.inc
+++ /dev/null
@@ -1,409 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* This plugin only writes its objectClass */
- var $objectclasses = array("goShareServer");
- var $attributes = array("goExportEntry");
- var $StatusFlag = "goShareServerStatus";
-
- /* This class can't be assigned twice so it conflicts with itsself */
- var $conflicts = array("goShareServer");
-
- var $DisplayName = "";
- var $dn = NULL;
- var $cn = "";
- var $goShareServerStatus = "";
- var $goExportEntry = array();
- var $allow_mounts = false;
- var $mounts_to_remove = array();
- var $mounts_to_add = array();
- var $view_logged =FALSE;
-
- function goShareServer(&$config,$dn)
- {
- goService::goService($config,$dn);
-
- $this->DisplayName = _("File service");
-
- $tmp =array();
- if(isset($this->attrs['goExportEntry'])){
- if(isset($this->attrs['goExportEntry']['count'])){
- for($i= 0; $i<$this->attrs['goExportEntry']['count']; $i++){
- $entry= $this->attrs['goExportEntry'][$i];
- $tmp[preg_replace('/\|.*$/', '', $entry)]= $entry;
- }
- }
- }
- $this->goExportEntryList = $tmp;
-
- $ldap = $this->config->get_ldap_link();
- $avl_objectclasses = $ldap->get_objectclasses();
- if (isset($avl_objectclasses["mount"])) {
- $this->allow_mounts = true;
- }
- }
-
-
- function execute()
- {
- $smarty = get_smarty();
-
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","server/".get_class($this),$this->dn);
- }
-
-
- if((isset($_POST['DelNfsEnt']))&&(isset($_POST['goExportEntryList'])) && ($this->acl_is_writeable("name"))){
- if($this->allow_mounts){
- foreach($_POST['goExportEntryList'] as $entry){
- $this->deleteFromMountList($this->goExportEntryList[$entry]);
- }
- }
- foreach($_POST['goExportEntryList'] as $entry){
- $this->deleteFromList($entry);
- }
- }
-
- if(isset($_POST['NewNfsAdd']) && ($this->acl_is_writeable("name"))){
- $this->oldone = NULL;
- $this->o_subWindow = new servnfs($this->config, $this);
- $this->o_subWindow->set_acl_category("server");
- $this->o_subWindow->set_acl_base($this->dn);
- $this->dialog = true;
- }
-
- if((isset($_POST['NewNfsEdit']))&&(isset($_POST['goExportEntryList']))){
- $entry = $this->goExportEntryList[$_POST['goExportEntryList'][0]];
- $add_mount=isset($this->mounts_to_add[$entry]);
- $this->oldone=$entry;
- $this->o_subWindow = new servnfs($this->config,$this,$entry,$add_mount);
- $this->o_subWindow->set_acl_base($this->dn);
- $this->o_subWindow->set_acl_category("server");
- $this->dialog = true;
- }
- if(isset($this->o_subWindow)){
- $this->o_subWindow->save_object(TRUE);
- }
-
- /* Save NFS setup */
- if(isset($_POST['NFSsave']) && isset($this->o_subWindow) && is_object($this->o_subWindow)){
- if(count($this->o_subWindow->check())>0){
- foreach($this->o_subWindow->check() as $msg) {
- print_red($msg);
- }
- }else{
- $this->o_subWindow->save_object();
- $newone = $this->o_subWindow->save();
-
- $this->addToList($newone);
- if($this->allow_mounts){
- if($this->oldone != NULL) {
- $this->deleteFromMountList($this->oldone);
- }
- if ($this->o_subWindow->should_create_mount()) {
- $this->addToMountList($newone);
- }
- }
- unset($this->o_subWindow);
- $this->dialog = false;
- }
- }
-
- /* Cancel NFS setup */
- if(isset($_POST['NFScancel'])){
- $this->oldone = NULL;
- unset($this->o_subWindow);
- $this->dialog = false;
- }
-
- /* Execute NFS setup dialog*/
- if(isset($this->o_subWindow)){
- return $this->o_subWindow->execute();
- }
-
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
- }
-
- /* Set acls */
- $tmp = $this->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $translated){
- $smarty->assign($name."ACL",$this->getacl($name));
- }
- $smarty->assign("createable",$this->acl_is_createable());
- $smarty->assign("removeable",$this->acl_is_removeable());
-
- $tellSmarty= array();
- ksort($this->goExportEntryList);
- foreach($this->goExportEntryList as $name=>$values){
- $tmp = split("\|",$values);
- $tellSmarty[$name] = $tmp[0]." ".$tmp[4]." (".$tmp[2].")";
- }
- $smarty->assign("goExportEntry",array_keys($tellSmarty));
- $smarty->assign("goExportEntryKeys",($tellSmarty));
- return($smarty->fetch(get_template_path("goShareServer.tpl",TRUE,dirname(__FILE__))));
- }
-
-
- function getListEntry()
- {
- $fields = goService::getListEntry();
- $fields['Message'] = _("File service (Shares)");
- $fields['AllowEdit'] = true;
- return($fields);
- }
-
-
- function save()
- {
- plugin::save();
-
- /* Arrays */
- foreach (array("goExportEntryList"=>"goExportEntry") as $source => $destination){
- $this->attrs[$destination]= array();
- foreach ($this->$source as $element){
- $this->attrs[$destination][]= $element;
- }
- }
-
-
- /* Process netatalk mounts */
- if($this->allow_mounts) {
- $this->process_mounts();
- }
-
- /* Check if this is a new entry ... add/modify */
- $ldap = $this->config->get_ldap_link();
- $ldap->cat($this->dn,array("objectClass"));
- if($ldap->count()){
- $ldap->cd($this->dn);
- $ldap->modify($this->attrs);
- }else{
- $ldap->cd($this->dn);
- $ldap->add($this->attrs);
- }
- show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/shares with dn '%s' failed."),$this->dn));
- if($this->initially_was_account){
- $this->handle_post_events("modify");
- new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- }else{
- $this->handle_post_events("add");
- new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- }
- }
-
-
- function check()
- {
- $message = plugin::check();
- return($message);
- }
-
-
- function save_object()
- {
- if(isset($_POST['goShareServerPosted'])){
- plugin::save_object();
- }
- }
-
- function addToList($entry){
- $key = key($entry);
- $this->goExportEntryList[$key]=$entry[$key];
- }
-
- function deleteFromList($id)
- {
- /* Check if the share is used by someone */
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
- $ldap->search("(|(gotoProfileServer=*|$id)(gotoShare=*|$id|*||*))", array("cn"));
- $cnt= $ldap->count();
- if ($cnt){
- $msg= sprintf(_("The share can't be removed since it is still used by %d users:"), $cnt);
- $msg.= "";
- while ($attrs= $ldap->fetch()){
- $msg.= "".$attrs["cn"][0]." ";
- }
- $msg.= " "._("Please correct the share-/profile settings of these users");
- print_red($msg);
-
- } else {
- /* Finally remove it */
- unset($this->goExportEntryList[$id]);
- }
- }
-
- function process_mounts() {
-
- $clip = "cn=" . $this->cn . ",ou=servers,ou=systems,";
- $mountsdn = "cn=mounts," . substr($this->dn, strlen($clip));
-
- $mounts = array(
- "objectClass" => "container",
- "cn" => "mounts"
- );
-
- # load data from mounts container
- $ldap = $this->config->get_ldap_link();
- $ldap->cat($mountsdn, array('dn'));
- $attrs = $ldap->fetch();
-
- # mounts container not present yet, so we create it
- if (count($attrs) == 0) {
- $ldap->cd($mountsdn);
- $ldap->add($mounts);
- show_ldap_error($ldap->get_error(), sprintf(_("Creating system server/shares (mount container) with dn '%s' failed."),$this->dn));
- new log("modify","server/".get_class($this),$mountsdn,array_keys($mounts),$ldap->get_error());
- }
-
- # remove deleted mounts from the container
- foreach ($this->mounts_to_remove as $entry) {
- $mount=$this->returnMountEntry($entry);
- $mountdn = "cn=".$mount["cn"].","."$mountsdn";
-
- $ldap->cat($mountdn, array('dn'));
- $attrs = $ldap->fetch();
-
- if (count($attrs) != 0) {
- $ldap->rmdir($mountdn);
- show_ldap_error($ldap->get_error(), sprintf(_("Removing system server/shares (mount container) with dn '%s' failed."),$this->dn));
- new log("remove","server/".get_class($this),$mountdn,array_keys($mount),$ldap->get_error());
- }
- }
-
- # add new mounts to the container
- foreach ($this->mounts_to_add as $entry) {
- $mount=$this->returnMountEntry($entry);
- $mountdn = "cn=".$mount["cn"].","."$mountsdn";
- $ldap->cd($mountdn);
- $ldap->add($mount);
- show_ldap_error($ldap->get_error(), sprintf(_("Saving system server/shares (mount container) with dn '%s' failed."),$this->dn));
- new log("create","server/".get_class($this),$mountdn,array_keys($mount),$ldap->get_error());
- }
- }
-
- function addToMountList($entry)
- {
- if($this->acl_is_writeable("name")){
- $key = key($entry);
- $type = $this->get_share_type($entry[$key]);
- if (($type == "netatalk") || ($type == "NFS")) {
- $this->mounts_to_add[$entry[$key]] = $entry[$key];
- unset($this->mounts_to_remove[$entry[$key]]);
- }
- }
- }
-
- function deleteFromMountList($entry)
- {
- if($this->acl_is_writeable("name")){
- $type = $this->get_share_type($entry);
- if (($type == "netatalk") || ($type == "NFS")) {
- $this->mounts_to_remove[$entry] = $entry;
- unset($this->mounts_to_add[$entry]);
- }
- }
- }
-
- function get_share_type($share)
- {
- $tmp = split("\|", $share);
- return $tmp[2];
- }
-
- function returnMountEntry($entry)
- {
- $item = split("\|", $entry);
- $name = $item[0];
- $description = $item[1];
- $type = $item[2];
- $charset = $item[3];
- $path = $item[4];
- $options = $item[5];
-
- switch ($type) {
- case "netatalk" : {
- $mount = array(
- "mountDirectory" => "/Network/Servers/",
- "mountOption" => array(
- "net",
- "url==afp://;AUTH=NO%20USER%20AUTHENT@".$this->cn."/$name/"
- ),
- "mountType" => "url",
- "objectClass" => "mount",
- "cn" => $this->cn .":/".$name
- );
- break;
- }
- case "NFS" : {
- $mount = array(
- "mountDirectory" => "/Network/Servers/",
- "mountOption" => "net",
- "mountType" => "nfs",
- "objectClass" => "mount",
- "cn" => $this->cn .":".$path
- );
- break;
- }
- default : {
- continue;
- }
- }
- return $mount;
- }
-
-
- function PrepareForCopyPaste($source)
- {
- plugin::PrepareForCopyPaste($source);
-
- $tmp =array();
- if(isset($source['goExportEntry'])){
- if(isset($source['goExportEntry']['count'])){
- for($i= 0; $i<$source['goExportEntry']['count']; $i++){
- $entry= $source['goExportEntry'][$i];
- $tmp[preg_replace('/\|.*$/', '', $entry)]= $entry;
- }
- }
- }
- $this->goExportEntryList = $tmp;
- $this->goExportEntry = $tmp;
- }
-
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("File service (Shares)"),
- "plDescription" => _("File service - Shares")." ("._("Services").")",
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 90,
- "plSection" => array("administration"),
- "plCategory" => array("server"),
-
- "plProvidedAcls"=> array(
- "name" => _("Name"),
- "netatalkmount" => _("Apple mounts"),
- "description" => _("Description"),
- "type" => _("Type"),
- "charset" => _("Charset"),
- "path" => _("Path"),
- "option" => _("Option"),
- "volume" => _("Volume"))
-
- ));
- }
-
-
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_goSpamServer.inc b/plugins/admin/systems/class_goSpamServer.inc
deleted file mode 100644
index 82ff0fbaf..000000000
--- a/plugins/admin/systems/class_goSpamServer.inc
+++ /dev/null
@@ -1,357 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* This plugin only writes its objectClass */
- var $objectclasses = array("goSpamServer");
- var $attributes = array("saRewriteHeader","saTrustedNetworks","saRequiredScore","saFlags","saRule");
- var $StatusFlag = "saStatus";
-
- /* This class can't be assigned twice so it conflicts with itsself */
- var $conflicts = array("goSpamServer");
- var $Flags = array("B","b","C","R","D","P");
-
- var $DisplayName = "";
- var $dn = NULL;
- var $cn = "";
- var $saStatus = "";
-
- var $saRewriteHeader = "";
- var $saTrustedNetworks= array();
- var $TrustedNetworks = array();
- var $saRequiredScore = 0;
- var $saFlags = "";
- var $Rules = array();
- var $saRule = array();
-
- var $saFlagsB = false;
- var $saFlagsb = false;
- var $saFlagsC = false;
- var $saFlagsR = false;
- var $saFlagsD = false;
- var $saFlagsP = false;
-
- var $ui = NULL;
- var $acl = NULL;
- var $view_logged =FALSE;
-
- function gospamserver(&$config,$dn, $parent= NULL)
- {
- /* Init class */
- goService::goService($config,$dn, $parent);
- $this->DisplayName = _("Spamassassin");
-
- /* Get userinfo & acls */
- $this->ui = get_userinfo();
-
- /* Get Flags */
- foreach($this->Flags as $flag){
- $var = "saFlags".$flag;
- if(preg_match("/".$flag."/",$this->saFlags)){
- $this->$var = TRUE;
- }
- }
-
- /* Get trusted networks */
- $this->TrustedNetworks = array();
- if(isset($this->attrs['saTrustedNetworks']) && is_array($this->attrs['saTrustedNetworks'])){
- $var = $this->attrs['saTrustedNetworks'];
- for($i = 0 ; $i < $var['count'] ; $i ++ ){
- $var2 = $this->attrs['saTrustedNetworks'][$i];
- $this->TrustedNetworks[ $var2 ] = $var2;
- }
- }
-
- /* Get rules */
- $this->Rules = array();
- if(isset($this->attrs['saRule']) && is_array($this->attrs['saRule'])){
- $var = $this->attrs['saRule'];
- for($i = 0 ; $i < $var['count'] ; $i ++ ){
- $var2 = $this->attrs['saRule'][$i];
- $name = preg_replace("/:.*$/","",$var2);
- $value= base64_decode(preg_replace("/^.*:/","",$var2));
- $this->Rules[ $name ] = $value;
- }
- }
- }
-
-
- function execute()
- {
- $display ="";
- $smarty = get_smarty();
-
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","server/".get_class($this),$this->dn);
- }
-
- /* If displayed, it is ever true*/
- $this->is_account =true;
-
- /* Get acls */
- $tmp = $this->plinfo();
- foreach($tmp['plProvidedAcls'] as $name => $translation){
- $smarty->assign($name."ACL",$this->getacl($name));
- }
-
- /* Add new trusted network */
- if(isset($_POST['AddNewTrust']) && ($this->acl_is_writeable("saTrustedNetworks"))){
- $this->AddTrust($_POST['NewTrustName']);
- }
-
- /* Delete selected trusted network */
- if(isset($_POST['DelTrust']) && ($this->acl_is_writeable("saTrustedNetworks"))){
- $this->DelTrust($_POST['TrustedNetworks']);
- }
-
- /* Add a new rule */
- if(isset($_POST['AddRule']) && $this->acl_is_writeable("saRule")){
- $this->dialog = new goSpamServerRule($this->config,$this->dn);
- }
-
- /* Cancel adding/editing specified rule */
- if(isset($_POST['CancelRule'])){
- $this->dialog = FALSE;
- }
-
- /* Handle post to delete rules */
- $once = true;
- foreach($_POST as $name => $value){
- if(preg_match("/^editRule_/",$name) && $once && $this->acl_is_readable("saRule")){
- $once = false;
- $entry = preg_replace("/^editRule_/","",$name);
- $entry = preg_replace("/_(x|y)$/","",$entry);
- $rule = $this->Rules[$entry];
- $name = $entry;
- $this->dialog = new goSpamServerRule($this->config,$this->dn,$name,$rule);
- }
- if(preg_match("/^delRule_/",$name) && $once && $this->acl_is_writeable("saRule")){
- $once = false;
- $entry = preg_replace("/^delRule_/","",$name);
- $entry = preg_replace("/_(x|y)$/","",$entry);
- unset($this->Rules[$entry]);
- }
- }
-
- /* Save rules */
- if(isset($_POST['SaveRule'])){
- $this->dialog->save_object();
- $msgs = $this->dialog->check();
- if(count($msgs)){
- foreach($msgs as $msg){
- print_red($msg);
- }
- }elseif($this->acl_is_writeable("saRule")){
- $ret = $this->dialog->save();
- if((!empty($ret['orig_name'])) && isset($this->Rules[$ret['orig_name']])){
- unset($this->Rules[$ret['orig_name']]);
- }
- $this->Rules[$ret['name']] = $ret['rule'];
- $this->dialog = FALSE;
- }
- }
-
- /* Display dialog if available */
- if($this->dialog && $this->dialog->config){
- $this->dialog->save_object();
- return($this->dialog->execute());
- }
-
- /* Assign smarty vars */
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
- }
-
- /* Assign checkbox states */
- foreach($this->Flags as $Flag){
- $var = "saFlags".$Flag;
- $smarty->assign("saFlags".$Flag."ACL", $this->getacl($Flag));
- if($this->$var){
- $smarty->assign("saFlags".$Flag."CHK"," checked " );
- }else{
- $smarty->assign("saFlags".$Flag."CHK","");
- }
- }
-
- /* Create divlist */
- $DivRules = new divSelectBox("SpamRules");
- $DivRules->SetHeight(130);
-
- if($this->acl_is_writeable("saTrustedNetworks")){
- $actions = "";
- }else{
-
- $actions = " ";
- if($this->acl_is_writeable("saRule")){
- $actions.= " ";
- }
- }
-
- foreach($this->Rules as $key => $net){
- $field1 = array("string" => $key );
- $field2 = array("string" => sprintf($actions,$key,$key) , "attach" => "style='border-right:0px;width:36px;'");
- $DivRules->AddEntry(array($field1,$field2));
- }
- $smarty->assign("divRules",$DivRules->DrawList());
- $smarty->assign("TrustedNetworks",$this->TrustedNetworks);
-
- /* Create Spam score select box entries */
- $tmp = array();
- for($i = 0 ; $i <= 20 ; $i ++ ){
- $tmp[$i] = $i;
- }
- $smarty->assign("SpamScore",$tmp);
-
- return($display.$smarty->fetch(get_template_path("goSpamServer.tpl",TRUE,dirname(__FILE__))));
- }
-
-
- /* Add $post to list of configured trusted */
- function AddTrust($post)
- {
- if(!empty($post)){
- if(is_ip($post) || is_domain($post) || (is_ip_with_subnetmask($post))){
- $this->TrustedNetworks[$post] = $post;
- }else{
- print_red(_("Specified value is not a valid 'trusted network' value."));
- }
- }
- }
-
-
- /* Delete trusted network */
- function DelTrust($posts)
- {
- foreach($posts as $post){
- if(isset($this->TrustedNetworks[$post])){
- unset($this->TrustedNetworks[$post]);
- }
- }
- }
-
- function save()
- {
- if(!$this->is_account) return;
- plugin::save();
-
- /* Create Flags */
- $this->attrs['saFlags'] = array();
- foreach($this->Flags as $flag){
- $var = "saFlags".$flag;
- if($this->$var){
- $this->attrs['saFlags'].=$flag;
- }
- }
-
- /* Create trusted network entries */
- $this->attrs['saTrustedNetworks'] = array();
- foreach($this->TrustedNetworks as $net){
- $this->attrs['saTrustedNetworks'][] = $net;
- }
-
- /* Rules */
- $this->attrs['saRule'] = array();
- foreach($this->Rules as $name => $rule){
- $this->attrs['saRule'][] = $name.":".base64_encode($rule);
- }
-
- /* Check if this is a new entry ... add/modify */
- $ldap = $this->config->get_ldap_link();
- $ldap->cat($this->dn,array("objectClass"));
- if($ldap->count()){
- $ldap->cd($this->dn);
- $ldap->modify($this->attrs);
- }else{
- $ldap->cd($this->dn);
- $ldap->add($this->attrs);
- }
- if($this->initially_was_account){
- $this->handle_post_events("modify");
- new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- }else{
- $this->handle_post_events("add");
- new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- }
-
- show_ldap_error($ldap->get_error(), sprintf(_("Saving of server services/spamassassin with dn '%s' failed."),$this->dn));
- }
-
- function check()
- {
- $message = plugin::check();
-
- /* Check if required score is numeric */
- if(!is_numeric($this->saRequiredScore)){
- $message[] = _("Required score must be a numeric value.");
- }
-
- return($message);
- }
-
-
- function save_object()
- {
- if(isset($_POST['goSpamServer'])){
-
- plugin::save_object();
-
- /* Check flags */
- foreach($this->Flags as $flag){
- $var = "saFlags".$flag;
-
- if($this->acl_is_writeable($var)){
- if(isset($_POST[$var])){
- $this->$var = TRUE;
- }else{
- $this->$var = FALSE;
- }
- }
- }
- }
- }
-
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Spamassassin"),
- "plDescription" => _("Spamassassin")." ("._("Services").")",
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 89,
- "plSection" => array("administration"),
- "plCategory" => array("server"),
- "plProvidedAcls"=> array(
-
- "saRewriteHeader" => _("Rewrite header"),
- "saTrustedNetworks" => _("Trusted networks"),
- "saRequiredScore" => _("Required score"),
- "saRule" => _("Rules"),
-
- "saFlagB" => _("Enable use of bayes filtering"),
- "saFlagb" => _("Enabled bayes auto learning"),
- "saFlagC" => _("Enable RBL checks"),
- "saFlagR" => _("Enable use of Razor"),
- "saFlagD" => _("Enable use of DDC"),
- "saFlagP" => _("Enable use of Pyzor"))
- ));
- }
-
- /* For newer service management dialogs */
- function getListEntry()
- {
- $fields = goService::getListEntry();
- $fields['Message'] = _("Spamassassin");
- $fields['AllowEdit'] = true;
- return($fields);
- }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_goSpamServerRule.inc b/plugins/admin/systems/class_goSpamServerRule.inc
deleted file mode 100644
index c8eed5d4e..000000000
--- a/plugins/admin/systems/class_goSpamServerRule.inc
+++ /dev/null
@@ -1,61 +0,0 @@
-name = $this->orig_name= $name;
- $this->rule = $rule;
- }
-
-
- function execute()
- {
- $smarty = get_smarty();
-
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","server/".get_class($this),$this->dn);
- }
-
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
- }
- return($smarty->fetch(get_template_path("goSpamServerRule.tpl",TRUE,dirname(__FILE__))));
- }
-
- function save_object()
- {
- plugin::save_object();
- foreach($this->attributes as $attr){
- if(isset($_POST[$attr])){
- $this->$attr = $_POST[$attr];
- }
- }
- }
-
-
- function save()
- {
- $ret =array();
- $ret['orig_name'] = $this->orig_name;
- $ret['name'] = $this->name;
- $ret['rule'] = $this->rule;
- return($ret);
- }
-
- function check()
- {
- $messages = plugin::check();
- return($messages);
- }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_goSyslogServer.inc b/plugins/admin/systems/class_goSyslogServer.inc
deleted file mode 100644
index 9461977e2..000000000
--- a/plugins/admin/systems/class_goSyslogServer.inc
+++ /dev/null
@@ -1,83 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* This plugin only writes its objectClass */
- var $objectclasses = array("goSyslogServer");
- var $attributes = array();
- var $StatusFlag = "goSyslogServerStatus";
-
- /* This class can't be assigned twice so it conflicts with itsself */
- var $conflicts = array("goSyslogServer");
-
- var $DisplayName = "";
- var $dn = NULL;
- var $acl;
- var $cn = "";
- var $goSyslogServerStatus = "";
- var $view_logged =FALSE;
-
- function goSyslogServer(&$config,$dn)
- {
- goService::goService($config,$dn);
- $this->DisplayName = _("Syslog server");
- }
-
-
- function execute()
- {
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","server/".get_class($this),$this->dn);
- }
-
-
- $smarty = get_smarty();
- return($smarty->fetch(get_template_path("goSyslogServer.tpl",TRUE,dirname(__FILE__))));
- }
-
-
- function getListEntry()
- {
- $fields = goService::getListEntry();
- $fields['Message'] = _("Syslog server");
- $fields['AllowEdit'] = false;
- return($fields);
- }
-
- function check()
- {
- $message = plugin::check();
- return($message);
- }
-
-
- function save_object()
- {
- plugin::save_object();
- }
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Logging service"),
- "plDescription" => _("Logging service")." ("._("Services").")",
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 88,
- "plSection" => array("administration"),
- "plCategory" => array("server"),
-
- "plProvidedAcls"=> array()
- ));
- }
-
-
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_goTerminalServer.inc b/plugins/admin/systems/class_goTerminalServer.inc
deleted file mode 100644
index e832de04c..000000000
--- a/plugins/admin/systems/class_goTerminalServer.inc
+++ /dev/null
@@ -1,141 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* This plugin only writes its objectClass */
- var $objectclasses = array("goTerminalServer");
- var $attributes = array("goXdmcpIsEnabled", "goFontPath");
- var $StatusFlag = "goTerminalServerStatus";
-
- /* This class can't be assigned twice so it conflicts with itsself */
- var $conflicts = array("goTerminalServer");
-
- var $DisplayName = "";
- var $dn = NULL;
- var $acl;
- var $cn = "";
- var $goTerminalServerStatus = "";
- var $goXdmcpIsEnabled = false;
- var $goFontPath = "";
- var $view_logged =FALSE;
-
-
- function goTerminalServer(&$config,$dn)
- {
- goService::goService($config,$dn);
- $this->DisplayName = _("Terminal service");
- }
-
-
- function execute()
- {
- $smarty = get_smarty();
-
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","server/".get_class($this),$this->dn);
- }
-
-
- $tmp = $this->plinfo();
- foreach($tmp['plProvidedAcls'] as $name => $translation){
- $smarty->assign($name."ACL",$this->getacl($name));
- }
-
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
- }
- return($smarty->fetch(get_template_path("goTerminalServer.tpl",TRUE,dirname(__FILE__))));
- }
-
-
- function getListEntry()
- {
- $fields = goService::getListEntry();
- $fields['Message'] = _("Terminal service");
- $fields['AllowEdit'] = true;
- return($fields);
- }
-
-
- function save()
- {
- plugin::save();
-
- if(!$this->goXdmcpIsEnabled){
- $this->attrs['goXdmcpIsEnabled'] = "0";
- }
-
- /* Check if this is a new entry ... add/modify */
- $ldap = $this->config->get_ldap_link();
- $ldap->cat($this->dn,array("objectClass"));
- if($ldap->count()){
- $ldap->cd($this->dn);
- $ldap->modify($this->attrs);
- }else{
- $ldap->cd($this->dn);
- $ldap->add($this->attrs);
- }
- show_ldap_error($ldap->get_error(), sprintf(_("Saving server services/terminalServer with dn '%s' failed."),$this->dn));
- if($this->initially_was_account){
- $this->handle_post_events("modify");
- new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- }else{
- $this->handle_post_events("add");
- new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- }
- }
-
-
- function check()
- {
- $message = plugin::check();
- if(empty($this->goFontPath)){
- $message[]=_("Terminal server, must have fontpath specified.");
- }
-
- return($message);
- }
-
-
- function save_object()
- {
- if(isset($_POST['goTerminalServerPosted'])){
- plugin::save_object();
- if($this->acl_is_writeable("goXdmcpIsEnabled")){
- if(isset($_POST['goXdmcpIsEnabled'])){
- $this->goXdmcpIsEnabled = true;
- }else{
- $this->goXdmcpIsEnabled = false;
- }
- }
- }
- }
-
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Terminal service"),
- "plDescription" => _("Terminal service")." ("._("Services").")",
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 87,
- "plSection" => array("administration"),
- "plCategory" => array("server"),
-
- "plProvidedAcls"=> array(
- "goXdmcpIsEnabled" => _("Temporary disable login"),
- "goFontPath" => _("Font path"))
- ));
- }
-
-
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_goVirusServer.inc b/plugins/admin/systems/class_goVirusServer.inc
deleted file mode 100644
index f91c5f5ae..000000000
--- a/plugins/admin/systems/class_goVirusServer.inc
+++ /dev/null
@@ -1,248 +0,0 @@
-DisplayName = _("Anti virus");
-
- /* Get userinfo & acls */
- $this->ui = get_userinfo();
-
- /* Get Flags */
- foreach($this->Flags as $flag){
- $var = "avFlags".$flag;
- if(preg_match("/".$flag."/",$this->avFlags)){
- $this->$var = TRUE;
- }
- }
- }
-
-
- function execute()
- {
- $smarty = get_smarty();
-
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","server/".get_class($this),$this->dn);
- }
-
-
- /* Set acls */
- $tmp = $this->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $translation) {
- $smarty->assign($name."ACL",$this->getacl($name));
- }
-
- $display = "";
- $smarty->assign("servtabs",FALSE);
- $this->is_account = true;
-
- /* Assign smarty vars */
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
- }
-
- /* Assign checkbox states */
- foreach($this->Flags as $Flag){
- $var = "avFlags".$Flag;
- if($this->$var){
- $smarty->assign("avFlags".$Flag."CHK"," checked " );
- }else{
- $smarty->assign("avFlags".$Flag."CHK","");
- }
- }
-
- /* Assign value for max thread select box */
- $tmp = array();
- for($i = 1 ; $i <= 20 ; $i ++){
- $tmp[$i] = $i;
- }
- $smarty->assign("ThreadValues",$tmp);
-
- if($this->avFlagsA){
- $smarty->assign("avFlagsAState" , "" );
- }else{
- $smarty->assign("avFlagsAState" , " disabled " );
- }
-
- return($display.$smarty->fetch(get_template_path("goVirusServer.tpl",TRUE,dirname(__FILE__))));
- }
-
-
- function save()
- {
- if(!$this->is_account) return;
-
- /* Create Flags */
- $this->avFlags = "";
- foreach($this->Flags as $flag){
- $var = "avFlags".$flag;
- if($this->$var){
- $this->avFlags .=$flag;
- }
- }
-
- plugin::save();
-
- if(!$this->avFlagsA){
- $arr = array("avArchiveMaxFileSize","avArchiveMaxRecursion","avArchiveMaxCompressionRatio");
- foreach($arr as $attr){
- $this->attrs[$attr] = array();
- }
- $this->attrs['avFlags'] = preg_replace("/E/","",$this->attrs['avFlags']);
- }
-
- /* Check if this is a new entry ... add/modify */
- $ldap = $this->config->get_ldap_link();
- $ldap->cat($this->dn,array("objectClass"));
- if($ldap->count()){
- $ldap->cd($this->dn);
- $ldap->modify($this->attrs);
- }else{
- $ldap->cd($this->dn);
- $ldap->add($this->attrs);
- }
- if($this->initially_was_account){
- $this->handle_post_events("modify");
- new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- }else{
- $this->handle_post_events("add");
- new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- }
-
- show_ldap_error($ldap->get_error(), sprintf(_("Saving of server services/anti virus with dn '%s' failed."),$this->dn));
- }
-
- function check()
- {
- $message = plugin::check();
-
- $mustBeNumeric = array(
- "avMaxDirectoryRecursions" =>_("Maximum directory recursions"),
- "avMaxThreads" =>_("Maximum threads"),
- "avArchiveMaxFileSize" =>_("Maximum file size"),
- "avArchiveMaxRecursion" =>_("Maximum recursions"),
- "avArchiveMaxCompressionRatio" =>_("Maximum compression ratio"),
- "avChecksPerDay" =>_("Checks per day"));
-
- foreach($mustBeNumeric as $key => $trans){
- if(!is_numeric($this->$key)){
- $message[] = sprintf(_("The specified value for '%s' must be a numeric value."),$trans);
- }
- }
-
- foreach(array("avUser"=>_("Database user"),"avHttpProxyURL"=>_("Http proxy URL"),"avDatabaseMirror"=>_("Database mirror")) as $attr => $name){
- if(!preg_match("/^[a-z0-9:_\-\.\/]*$/",$this->$attr)){
- $message[] = sprintf(_("Please specify a valid value for '%s'."),$name);
- }
- }
-
- return($message);
- }
-
-
- function save_object()
- {
- if(isset($_POST['goVirusServer'])){
- plugin::save_object();
- foreach($this->Flags as $flag){
-
- $var = "avFlags".$flag;
- if($this->acl_is_writeable($var)){
- if(isset($_POST[$var])){
- $this->$var = TRUE;
- }else{
- $this->$var = FALSE;
- }
- }
- }
- }
- }
-
-
- /* For newer service management dialogs */
- function getListEntry()
- {
- $fields = goService::getListEntry();
- $fields['AllowEdit'] = true;
- $fields['Message'] = _("Anti virus");
- return($fields);
- }
-
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Anti virus"),
- "plDescription" => _("Anti virus")." ("._("Services").")",
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 96,
- "plSection" => array("administration"),
- "plCategory" => array("server"),
- "plProvidedAcls"=> array(
-
- "start" => _("Start"),
- "stop" => _("Stop"),
- "restart" => _("Restart"),
-
- "avFlagsD" =>_("Enable debugging"),
- "avFlagsS" =>_("Enable mail scanning"),
- "avFlagsA" =>_("Enable scanning of archives"),
- "avFlagsE" =>_("Block encrypted archives"),
-
- "avMaxThreads" =>_("Maximum threads"),
- "avMaxDirectoryRecursions" =>_("Maximum directory recursions"),
- "avUser" =>_("Anti virus user"),
- "avArchiveMaxFileSize" =>_("Maximum file size"),
- "avArchiveMaxRecursion" =>_("Maximum recursions"),
- "avArchiveMaxCompressionRatio" =>_("Maximum compression ratio"),
- "avDatabaseMirror" =>_("Database mirror"),
- "avChecksPerDay" =>_("Checks per day"),
- "avHttpProxyURL" =>_("Http proxy URL"))
- ));
- }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_gosaLogServer.inc b/plugins/admin/systems/class_gosaLogServer.inc
deleted file mode 100644
index cade0e243..000000000
--- a/plugins/admin/systems/class_gosaLogServer.inc
+++ /dev/null
@@ -1,108 +0,0 @@
-DisplayName = _("GOsa MySQL logging service");
- }
-
-
- function execute()
- {
- $smarty = get_smarty();
-
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","server/".get_class($this),$this->dn);
- }
-
- $tmp = $this->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $translation){
- $smarty->assign($name."ACL",$this->getacl($name));
- }
-
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
- }
- return($smarty->fetch(get_template_path("gosaLogServer.tpl",TRUE,dirname(__FILE__))));
- }
-
-
- function getListEntry()
- {
- $fields = goService::getListEntry();
- $fields['Message'] = _("GOsa MySQL logging service");
- $fields['AllowEdit'] = true;
- $fields['AllowStart'] = FALSE;
- $fields['AllowStop'] = FALSE;
- $fields['AllowRestart'] = FALSE;
- return($fields);
- }
-
-
- function check()
- {
- $message = plugin::check();
- if (empty($this->goLogDBUser)){
- $message[]= sprintf_("The attribute user is empty or contains invalid characters.");
- }
- if (empty($this->goLogDBPassword)){
- $message[]= sprintf_("The attribute password is empty or contains invalid characters.");
- }
- if (empty($this->goLogDB)){
- $message[]= sprintf_("The attribute database is empty or contains invalid characters.");
- }
- return($message);
- }
-
-
- function save_object()
- {
- if(isset($_POST['gosaLogServerPosted'])){
- plugin::save_object();
- }
- }
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("GOsa logging service"),
- "plDescription" => _("GOsa logging service")." ("._("Services").")",
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 98,
- "plSection" => array("administration"),
- "plCategory" => array("server"),
-
- "plProvidedAcls"=> array(
- "goLogDB" => _("Database"),
- "goLogDBUser" => _("User"),
- "goLogDBPassword" => _("Password"),
- "viewEntries" => _("Allow view of entries on this server"))
- ));
- }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_printerPPDDialog.inc b/plugins/admin/systems/class_printerPPDDialog.inc
deleted file mode 100644
index a93e91bb4..000000000
--- a/plugins/admin/systems/class_printerPPDDialog.inc
+++ /dev/null
@@ -1,546 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* attribute list for save action */
- var $ignore_account = TRUE;
- var $attributes = array("cn");
- var $objectclasses = array("whatever");
-
- /* PPD Handling */
- var $selectedPPD = false; // e.g. /vendor/device.ppd
- var $ppdManager = false; // new ppdManager;
- var $ppdConfig = false; // $this->ppdManager->loadProperties($this->selectedPPD['link']);
- var $ppdList = array(); // Contains all Printer models
- var $ppdListHeader = array(); // Contains all printer vendors
-
- /* Paths */
- var $pathToPPD = ""; // Base path, defined in gosa.conf e.g. "/var/spool/ppd/"
- var $pathToModified = "modified/"; // used to store the modified ppds
-
- /* Object Info */
- var $cn = "" ; // Used to tag the ppds modified by the printer object,
-
- /* If there is already a ppd file for the same type of printer,
- * remember the path to ppd file and display a dialog which allows
- * to overwrite the current ppd file.
- */
- var $add_ppd_later = "";
- var $add_later_msg_dialog = NULL;
-
- function printerPPDDialog (&$config, $dn= NULL, $ppdfile=NULL )
- {
- plugin::plugin ($config, $dn);
- $this->depselect = $this->config->current['BASE'];
-
- /* Get PPD path and remove double //, and add trailing / */
- if(isset($_SESSION['config']->data['MAIN']['PPD_PATH'])){
- $this->pathToPPD = $_SESSION['config']->data['MAIN']['PPD_PATH'];
- $this->pathToPPD= preg_replace("/\/\//", "/", $this->pathToPPD);
- if(!preg_match("/\/$/",$this->pathToPPD)){
- $this->pathToPPD = $this->pathToPPD."/";
- }
- }else{
- $this->pathToPPD = "";
- }
-
- /* It seams that we have an existing PPD path, so go on */
- if(!((!is_dir($this->pathToPPD))||(empty($this->pathToPPD)))){
-
- /* Load all available PPD files and sort them into an array */
- $this->ppdManager= new ppdManager($this->pathToPPD);
- $this->getPrinterReload ();
-
- /* The user has already a valid PPD assigned
- * Get some informations about this PPD
- * and set it as selected.
- * The ppdpath ['link'] should be relative from .../ppd/modified/
- * e.g. "/Compaq/Compaq-J1200.ppd" */
- if(($ppdfile!== NULL)&&(strlen($ppdfile)>0)){
- $ppdfile = preg_replace("#".$this->pathToModified."#","",$ppdfile);
- if(!file_exists($this->pathToPPD.$this->pathToModified.$ppdfile)){
- print_red(sprintf(_("Can't open '%s', ppd settings resetted."),$ppdfile));
- }else{
- $res = $this->ppdManager->loadDescription($this->pathToPPD.$this->pathToModified.$ppdfile);
- if($res){
- $tmp = split("\n",$res);
- $tmp3 = array();
- $tmp3['name'] = trim(preg_replace("/^\-/","",trim($tmp[1])));
- $tmp3['link'] = $ppdfile;
- $tmp3['ppd'] = $res;
- }
- $this->selectedPPD = $tmp3;
- }
- }
- }
- }
-
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- /* Fill templating stuff */
- $display= "";
- $smarty= get_smarty();
- $smarty->assign("ppdString", _("Can't get ppd informations."));
- $smarty->assign("showOptions", "");
-
- /* Check these paths */
- $paths = array($this->pathToPPD, $this->pathToPPD.$this->pathToModified);
-
- /* If one of our required paths is not available, stop here and display some info */
- foreach($paths as $path){
-
- /* Check if path is write/readable*/
- $is_r = @is_readable($path);
- if(((!is_dir($path))||(empty($path)) || (!$is_r)) && (!@mkdir($path))){
- print_red(sprintf(_("The specified path '%s' which results from PPD_PATH in your gosa.conf is invalid, can't read/write any ppd informations."),$path));
- /* Print out template */
- $display.= $smarty->fetch(get_template_path('printerPPDDialog.tpl', TRUE,dirname(__FILE__)));
- return($display);
- }
- }
-
- // PPD selection / upload / dialog handling
-
- /* Is there a new PPD file uploaded ? */
- if((isset($_FILES['NewPPDFile']))&&(isset($_POST['SubmitNewPPDFile']))){
- $file = ($_FILES['NewPPDFile']);
- if($file['size'] != 0 ){
- if($name = $this->AddPPD($file['tmp_name'])){
- $this->SelectPPD($name);
- }
- }else{
- print_red(_("Please specify a valid ppd file."));
- }
- }
-
- /* Overwrite existing PPD file and select it as currently used for this object */
- if(is_object($this->add_later_msg_dialog) && ($this->add_later_msg_dialog->is_confirmed()) && $this->add_ppd_later != ""){
- if($name = $this->AddPPD($this->add_ppd_later,TRUE)){
- $this->SelectPPD($name);
- }
- $this->add_ppd_later = "";
- $this->add_later_msg_dialog = NULL;
- }
-
- /* Open a dialog that allow us to select different PPDs */
- if(isset($_POST['SelectPPD'])){
- $this->dialog= new printerPPDSelectionDialog($this->config,$this->dn,$this->ppdList,$this->ppdListHeader,$this->selectedPPD);
- }
-
- /* The selection dialog fpr PPDs is canceled */
- if(isset($_POST['ClosePPDSelection'])){
- unset($this->dialog);
- $this->dialog=FALSE;
- }
-
- /* Div Selection */
- if((isset($_GET['act']))&&($_GET['act']=="use")){
- $this->SelectPPD(base64_decode($_GET['id']));
- unset($this->dialog);
- $this->dialog=FALSE;
-
- }
-
- /* if a dialog is open, print the dialog instead of this class */
- if(is_object($this->dialog)){
- $display = $this->dialog->execute();
- return($display);
- }
-
- // ENDE PPD selection / upload / dialog handling
-
- /* Give smarty the information it needs */
- $smarty->assign("ppdString" ,$this->getPPDInformation());
- $tmp= $this->generateProperties();
- if ($tmp == ""){
- $smarty->assign("showOptions", 0);
- } else {
- $smarty->assign("showOptions", 1);
- $smarty->assign("properties",$this->generateProperties());
- }
-
- /* Print out template */
- $display.= $smarty->fetch(get_template_path('printerPPDDialog.tpl', TRUE,dirname(__FILE__)));
- return($display);
- }
-
-
- /* Select PPD */
- function SelectPPD($name)
- {
- /* Replace base path we don't need it here
- The path we need looks like this : "/Vendor/ModellName.ppd";
- thats all */
- $name = preg_replace("#".$this->pathToPPD."#","",$name);
-
- /* Intialise some base vars */
- $AbsoluteSourceName = $this->pathToPPD.$name;
- $AbsoluteDestinationPath = $this->pathToPPD.$this->pathToModified;
- $Vendor = ""; // Vendor
- $Name = ""; // Name
- $Modell = ""; // Modell
- $PrinterName = ""; // The new name of the printer
- $PPDName = "";
-
- /* Force reload of config dialog */
- $this->ppdConfig = false;
- $this->selectedPPD['link'] = false;
-
- /* Get PPD informations and set vendor / modell / name */
- if((!file_exists($AbsoluteSourceName)) || (!is_readable($AbsoluteSourceName))){
- print_red(sprintf(_("Can't select PPD file '%s', the file is not readable"),$AbsoluteSourceName));
- return;
- }
- $res = $this->ppdManager->loadDescription($AbsoluteSourceName);
- if($res){
- $tmp = split("\n",$res);
- $Name = trim(preg_replace("/^\-/","",trim($tmp[1])));
- $Vendor = trim($tmp[0]);
- $Model = trim(preg_replace("/".$Vendor."/","",$Name));
- }
-
- $PrinterName = $this->cn."-".preg_replace("/[^a-z0-9-_\.]/i","_",$Name);
- $PPDName = $Vendor."/".$PrinterName.".ppd";
-
- /* Create the vendors path, if it doesn't exists already */
- if(!is_dir($AbsoluteDestinationPath.$Vendor)){
- if(!(@mkdir($AbsoluteDestinationPath.$Vendor))){
- print_red(sprintf(_("Can't create folder '%s' for the uploaded ppd file."),$AbsoluteDestinationPath.$Vendor));
- return(false);
- }
- }
-
- /* Create destination file handle */
- $fp = @fopen($AbsoluteDestinationPath.$PPDName,"w+");
- if(!$fp){
- print_red(sprintf(_("Can't create file '%s' to store modifed ppd informations."),$AbsoluteDestinationPath.$PPDName));
- return(false);
- }
-
- $str = file_get_contents($AbsoluteSourceName);
- fputs($fp,$str);
- @fclose($fp);
-
- //$this->ppdManager->updateAttribute($filename,"NO_SECTION","ModelName",$printerName);
-
- $tmp3['link'] =$PPDName;
- $this->selectedPPD = $tmp3;
- $this->getPrinterReload();
- return($PPDName);
- }
-
-
- /* This function adds a new ppd file to the list of available ppds.
- All required paths and files will be created
- $_PathOnHdd e.g. = /tmp/PHP_tmpfile213452 */
- function AddPPD($_PathOnHdd,$overwrite = FALSE)
- {
- /* Check if file exists && is readable */
- if((!is_file($_PathOnHdd)) || (!is_readable($_PathOnHdd))){
- print_red(sprintf(_("Can't add new ppd file, the source file '%s' is not accessible."),$_PathOnHdd));
- return(false);
- }
-
- /* Reload list to detect changes e.g. a file has been deleted */
- $this->getPrinterReload();
-
- /* Get Description from ppd, & parse out some informations */
- $res = @$this->ppdManager->loadDescription($_PathOnHdd);
- if($res){
- $tmp = split("\n",$res);
- $name = trim(preg_replace("/^\-/","",trim($tmp[1])));
- $vendor = trim($tmp[0]);
- $model = trim(preg_replace("/".$vendor."/","",$name));
- }
-
- /* Check if parse was successfull */
- if(empty($name) || empty($vendor)){
- print_red(sprintf(_("The given ppd file '%s' seams to be invalid, can't get any model or vendor informations."),$_PathOnHdd));
- return(false);
- }
-
- /* Prepare list of ppds */
- if(!isset($this->ppdList[$vendor])){
- $this->ppdList[$vendor] = array();
- }
-
- /* Create ppd file and fill in the source contents */
- $ppdname = $vendor."/".$name.".ppd";
- $filename = $this->pathToPPD.preg_replace("/[^a-z0-9-_\.\/]/i","_",$ppdname);
- $filename = $this->pathToPPD.$ppdname;
- $contents = file_get_contents($_PathOnHdd);
-
-
- /* Check if this ppd already exists */
- $found = false;
- foreach($this->ppdList[$vendor] as $key => $val){
- if(preg_match("/".$model.".*/i",$key)){
- $found = true;
- if(!$overwrite){
- if(!copy($_PathOnHdd,$_PathOnHdd."_back")){
- print_red(sprintf(_("Can't add new ppd file, the source file '%s' is not accessible."),$_PathOnHdd));
- }else{
- $this->add_ppd_later = $_PathOnHdd."_back";
- $this->add_later_msg_dialog = new msg_dialog(_("Overwrite existing PPD"),
- _("There is already a ppd file for this kind of printer. Do you want to overwrite it?"),CONFIRM_DIALOG);
- }
- return;
- }
- }
- }
-
- /* Create the vendors path, if it doesn't exists already */
- if(!is_dir($this->pathToPPD.$vendor)){
- if(!(@mkdir($this->pathToPPD.$vendor))){
- print_red(sprintf(_("Can't create folder '%s' for the uploaded ppd file."),$this->pathToPPD.$vendor));
- return(false);
- }
- }
-
- /* Open file handle */
- $fp = fopen($filename,"w+");
-
- /* Check file handle & contents */
- if(!$fp){
- print_red(sprintf(_("Can't save file '%s'."),$filename));
- return;
- }
- if(empty($contents)){
- print_red(_("Uploaded ppd file is empty, can't create new ppd file."));
- return;
- }
-
- /* Fille file with data */
- fputs($fp,$contents);
- @fclose($fp);
-
- /* Our job is done here */
- return($ppdname);
- }
-
-
- /* This function reloads the list of available printers/vendors
- $this->ppdListHeader
- Compaq => 1
- $this->ppdList
- Compaq => Compaq IJ1200 => name => Compaq IJ1200
- link => /var/spool/ppd/Compaq/Compaq-J1200.ppd
- ppd => Compaq - Co
- */
- function getPrinterReload()
- {
- if(is_readable($this->pathToPPD)){
- $tmp = @$this->ppdManager->getPrinterList(true);
-
- $this->ppdListHeader = $this->ppdList = array();
-
- /* Sort all available files, and create header (Vendor index) */
- foreach($tmp as $file=>$ppd){
-
- if(preg_match("#".$this->pathToModified."#",$file)) continue;
-
- $tmp2 = split("\n",$ppd);
- if(!isset($this->ppdListHeader[$tmp2[0]])){
- $this->ppdListHeader[$tmp2[0]]=0;
- }
- $tmp3['name'] =preg_replace("/^ -/","",$tmp2[1]." - ".$tmp2[2]);
- $tmp3['link'] =$file;
- $tmp3['ppd'] =$ppd;
- $this->ppdListHeader[$tmp2[0]]++;
- $this->ppdList[$tmp2[0]][preg_replace("/^ -/","",$tmp2[1]." - ".$tmp2[2])]=$tmp3;
- }
- }
- }
-
-
- /* Save all options posted from ppd dialog */
- function save_object()
- {
- if(!((isset($_POST['PPDDisSubmitted'])) && (is_array($this->ppdConfig)))){
- return;
- }
-
- foreach($this->ppdConfig as $cat => $obj){
- foreach($obj as $attr => $attributes){
- if(isset($_POST[base64_encode($attributes['_name'])])){
- $this->ppdConfig[$cat][$attr]['_default'] = $_POST[base64_encode($attributes['_name'])];
- }
- }
- }
- }
-
-
- /* Save modified ppd */
- function save_ppd()
- {
- if($this->ppdManager){
- $this->ppdManager->saveProperties($this->pathToPPD.$this->pathToModified.$this->selectedPPD['link'],$this->ppdConfig);
- }
- }
-
-
- /* Return selected ppd path, if none is selected then false */
- function save()
- {
- /* return the selected PPD, and in future the selected options too */
- return($this->pathToModified.$this->selectedPPD['link']);
- }
-
-
- /* Get Information for a single PPD entry
- * This will be shown on top of template
- */
- function getPPDInformation()
- {
- $str = "none";
- if(!empty($this->selectedPPD)){
- $str = $this->ppdManager->loadDescription($this->pathToPPD.$this->pathToModified.$this->selectedPPD['link']);
- }
- return($str) ;
- }
-
-
- /* Display all options from the selected ppd file */
- function generateProperties()
- {
- /* Set Headline */
- $str = "";
- $feed= "";
-
- $s_ppd = $this->pathToPPD.$this->pathToModified.$this->selectedPPD['link'];
-
- /* If ppd exists and is readable */
- if((!empty($this->selectedPPD['link']))&&(file_exists($s_ppd))){
-
- /* If there is no initial Configuration, load it */
- if($this->ppdConfig == false){
- $this->ppdConfig = $this->ppdManager->loadProperties($s_ppd);
- }
-
- /* Create a table */
- $str .= "";
-
- /* Input all data to the table */
- foreach($this->ppdConfig as $cat => $obj){
-
- /* Add new category */
- $str .= "$feed";
- if ($feed == ""){
- $feed= " ";
- }
- $str .= ""._("Section")." '".$cat."' ";
- $str .= " ";
-
- /* Add attributes of the current category */
- foreach($obj as $attr => $settings){
-
- /* Skip all entries beginning with _ */
- if($attr[0] == "_") continue;
-
- /* Prepare data */
- $values = array();
- $name = $settings['_name'];
-
- if (!isset($settings['_default'])){
- $default = "";
- } else {
- $default = $settings['_default'];
- }
-
- $type = $settings['_type'];
-
- /* Add name to table */
- $str .= "\n";
- $str .= $name." \n";
- $str .= " \n";
-
- /* Get all values */
- foreach( $settings as $vname => $value){
- if($vname[0] != "_"){
- $values[$vname]= $value;
- }
- }
-
- /* preparing Html output
- * Supported types are PickOne/Boolean
- */
-
- /* If type is PickOne, create a select box */
- if(($type == "PickOne")||(($type=="Boolean")&&(count($values)>1))){
-
- $str .= "\n";
- foreach($values as $optionKey => $value){
- $selected = "";
- if($optionKey == $default){
- $selected = " selected ";
- }
- $str .= "".$value." \n";
- }
- $str .= " \n";
-
- }elseif($type == "Boolean"){
-
- /* If type is Boolean & no values are given */
- $str .= "\n";
- if($default == "False"){
- $str .= ""._("True")." \n";
- $str .= ""._("False")." \n";
- }else{
- $str .= ""._("True")." \n";
- $str .= ""._("False")." \n";
- }
- $str .= " \n";
-
- }else{
- print_red(sprintf(_("Unsupported ppd type '%s' used for '%s' "),$type,$name));
- }
- $str .= " \n";
- }
- }
- $str .= "
\n";
- }
- return($str);
- }
-
- function removeModifiedPPD()
- {
- $path = $this->pathToPPD.$this->pathToModified.$this->selectedPPD['link'];
-
- if(file_exists($path)){
- if(is_writeable($path)){
- if(!@unlink($path)){
- print_red(sprintf(_("Removing old ppd file '%s' failed."),$path));
- }
- }else{
- print_red(sprintf(_("Removing old ppd file '%s' failed. File is not accessible."),$path));
- }
- }else{
- print_red(sprintf(_("Removing old ppd file '%s' failed. File does not exists or is not accessible."),$path));
- }
- }
-
- function update_ppd_url()
- {
- $this->SelectPPD("modified/".$this->selectedPPD['link']);
- }
-
- function check()
- {
- $message = plugin::check();
- if(empty($this->selectedPPD['link'])){
- $message[] = _("Please select a valid ppd file or use 'Cancel' to go back to printer configuration.");
- }
- return($message);
- }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_printerPPDSelectionDialog.inc b/plugins/admin/systems/class_printerPPDSelectionDialog.inc
deleted file mode 100644
index d4f5d16b8..000000000
--- a/plugins/admin/systems/class_printerPPDSelectionDialog.inc
+++ /dev/null
@@ -1,197 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* attribute list for save action */
- var $ignore_account = FALSE;
- var $attributes = array();
- var $objectclasses = array("whatever");
-
- var $list =array();
- var $header =array();
- var $current_del_id = "";
- var $Vendor = "";
-
- function printerPPDSelectionDialog (&$config, $dn= NULL,$list=false,$headers=false,$ppd=false)
- {
- plugin::plugin ($config, $dn);
- $this->list = $list;
- $this->header = $headers;
- $this->depselect = $this->config->current['BASE'];
-
- if(!isset($_SESSION['printerPPDSelectionDialog'])){
- $_SESSION['printerPPDSelectionDialog']['regex'] = "*";
- }
-
- /* Order the manufacturers index */
- ksort($this->header);
- }
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- /* Fill templating stuff */
- $smarty= get_smarty();
- $display= "";
- $s_action = "none";
-
- $regex = $_SESSION['printerPPDSelectionDialog']['regex'];
-
- if(isset($_GET['search'])){
- $regex = $_GET['search']."*";
- }
-
- if(isset($_POST['regex'])){
- $regex= $_POST['regex'];
- }
-
- $regex = str_replace("**","*",$regex);
- $_SESSION['printerPPDSelectionDialog']['regex'] = $regex;
-
-
- /* Delete requested, check if everything is ok and display confirmation dialog */
- if(isset($_GET['act']) && $_GET['act'] == "del"){
-
- /* Get id and check if id is valid */
- $id_to_del = base64_decode($_GET['id']);
- $found = "";
- foreach($this->list[$this->Vendor] as $key => $data){
- if($data['link'] == $id_to_del){
- $found = $key;
- break;
- }
- }
- if(!empty($found)){
- $this->current_del_id = $id_to_del;
-
- $smarty->assign("warning", sprintf(_("You're about to delete the ppd file '%s' at '%s'."), $found,$id_to_del));
- return($smarty->fetch(get_template_path('remove_ppd.tpl', TRUE)));
-
- }else{
- print_red(sprintf(_("Could not found specified ppd file '%s'."),$id_to_del));
- }
- }
-
- /* Deletion confirmed */
- if(isset($_POST['delete_ppd_confirm']) && !empty($this->current_del_id)){
-
- /* check if file is removeable */
- if(is_writeable($this->current_del_id)){
- $is_ok = @unlink($this->current_del_id);
-
- /* Update ppd list */
- if($is_ok){
- foreach($this->list as $vendor => $ppds){
- foreach($ppds as $ppd => $data){
- if($data['link'] == $this->current_del_id){
- unset($this->list[$vendor][$ppd]);
- }
- }
- }
- }
- }else{
- $is_ok = false;
- }
-
- if(!$is_ok){
- print_red(_("Something went wrong while trying to remove the ppd file from server, possibly we have no write access."));
- }
- }
-
-
- /** Added **/
- $list = array();
- foreach($this->list as $cat => $ppds){
- foreach($ppds as $ppd){
- if(preg_match("/^".str_replace("*",".*",$regex)."/i",$ppd['ppd'])){
- if(is_readable($ppd['link'])){
- $list[$ppd['link']] = $ppd;
- }
- }
- }
- }
-
- if((isset($_GET['act']))&&($_GET['act']=="open")) {
-
- if((!empty($_GET['id'])) && (!isset( $this->header[base64_decode($_GET['id'])]))){
- print_red(sprintf(_("Selected vendor '%s' does not exists in our list of ppds."),base64_decode($_GET['id'])));
- $this->Vendor = "";
- }else{
- $this->Vendor = base64_decode($_GET['id']);
- }
- }
-
- $div = new divSelectBox("printerPPDSelectionDialog");
- $div ->SetHeight(450);
- $div ->SetSummary(_("Printer ppd selection."));
-
- $linkopen = "
- %s
- ";
- $uselink = "%s ";
- $dellink = "
-
- ";
-
- if(empty($this->Vendor)){
- foreach($this-> header as $key => $entry){
- $div ->AddEntry (array(
- array("string"=>sprintf($linkopen,base64_encode($key),$key),"attach"=>"style='border-right:0px;'")
- ));
- }
- }else{
- $div ->AddEntry (array(
- array("string"=>sprintf($linkopen,"",".. ["._("back")."]"),"attach"=>"style='border-right:0px;'")
- ));
- foreach($list as $key => $ppd){
- if(preg_match("/^".$this->Vendor."/",$ppd['ppd'])){
-
- if(is_writeable($ppd['link'])){
- $del_str = sprintf($dellink,base64_encode($key));
- }else{
- $del_str = "";
- }
-
- $div ->AddEntry (array(
- array("string"=>sprintf($uselink,base64_encode($key),$ppd['ppd'])),
- array("string"=>$del_str,"attach"=>"style='border-right:0px;'")
-
- ));
- }
- }
- }
-
- $smarty->assign("List", $div -> DrawList());
- $smarty->assign("search_image", get_template_path('images/search.png'));
- $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
- $smarty->assign("tree_image", get_template_path('images/tree.png'));
- $smarty->assign("alphabet", generate_alphabet());
- $smarty->assign("apply", apply_filter());
- $smarty->assign("regex", $regex);
-
- $display.= $smarty->fetch(get_template_path('printerPPDSelectionDialog.tpl', TRUE,dirname(__FILE__)));
- return($display);
- }
-
- function save_object()
- {
- }
-
- function check(){
- }
-
- /* Save to LDAP */
- function save()
- {
- return $this->selectedPPD;
- }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_servDHCP.inc b/plugins/admin/systems/class_servDHCP.inc
deleted file mode 100644
index c804ec2bc..000000000
--- a/plugins/admin/systems/class_servDHCP.inc
+++ /dev/null
@@ -1,739 +0,0 @@
- array(),"FOR_LIST"=> array());
- var $take_over_id = -1;
- var $display_warning = TRUE;
-
- function servdhcp (&$config, $dn= NULL, $parent= NULL)
- {
- plugin::plugin ($config, $dn, $parent);
-
- $this->serviceDN = "cn=dhcp,".$dn;
- $this->orig_dn = $dn;
-
- $this->DisplayName = _("DHCP service");
-
- $this->types= array( "dhcpLog" => _("Logging"),
- "dhcpService" => _("Global options"),
- "dhcpClass" => _("Class"),
- "dhcpSubClass" => _("Subclass"),
- "dhcpHost" => _("Host"),
- "dhcpGroup" => _("Group"),
- "dhcpPool" => _("Pool"),
- "dhcpSubnet" => _("Subnet"),
- "dhcpFailOverPeer" => _("Failover peer"),
- "dhcpSharedNetwork" => _("Shared network"));
-
-
- /* Backport: PHP4 compatibility */
- foreach($this->types as $type => $translation){
- $this->types[strtolower($type)] = $translation;
- }
-
- /* Load information about available services */
- $this->reload();
- if (!count($this->dhcpSections)){
- $this->is_account= FALSE;
- $this->dhcp_server_list = $this->get_list_of_dhcp_servers();
- }
- }
-
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- /* Fill templating stuff */
- $smarty= get_smarty();
- $smarty->assign("dns_take_over",FALSE);
- $display= "";
-
-
- /*****************/
- /* Handle Take Over Actions
- /*****************/
-
- /* Give smarty the required informations */
- $smarty->assign("dhcp_server_list", $this->dhcp_server_list['FOR_LIST']);
- $smarty->assign("dhcp_server_list_cnt", count($this->dhcp_server_list['FOR_LIST']));
-
- /* Take over requested, save id */
- if(isset($_POST['take_over_src']) && isset($_POST['take_over'])){
- $id = $_POST['take_over_src'];
- if(isset($this->dhcp_server_list['ENTRIES'][$id])){
- $this->take_over_id = $id;
- }
- }
-
- /* Abort take over action */
- if(isset($_POST['cancel_take_over'])){
- $this->dialog =false;
- $this->take_over_id = -1;
- $this->dhcp_server_list = $this->get_list_of_dhcp_servers();
- }
-
- /* Display informartion about take over that will be started when saving this server
- * and hide default dhcp output
- */
- if($this->take_over_id != -1){
-
- $this->dialog = FALSE;
- $id = $this->take_over_id;
- $smarty->assign("dns_take_over",TRUE);
- $warning = sprintf(_("You are going to migrate the DHCP setup from server '%s'."),
- $this->dhcp_server_list['ENTRIES'][$id]['cn'][0]);
- $warning.= " "._("The migration will be started when you save this system. To cancel this action, use the cancel button below.");
-
- if($this->display_warning){
- print_red($warning);
- $this->display_warning = FALSE;
- }
- return($smarty->fetch(get_template_path('servdhcp.tpl', TRUE)));
- }
-
-
- /*****************/
- /* List handling
- /*****************/
-
- /* Section Creation? */
- if (isset($_POST['create_section']) && isset($_POST['section'])){
- $section= $_POST['section'];
- $tmp = new dhcpNewSectionDialog(NULL);
- if (isset($tmp->sectionMap[$section])){
- $this->dialog= new $section($this->current_object);
- $this->current_object= "";
- } else {
- $this->dialog= FALSE;
- }
- }
-
- /* Cancel section creation? */
- if (isset($_POST['cancel_section']) || isset($_POST['cancel_dhcp'])){
- $this->dialog= FALSE;
- }
-
- /* Save changes */
- if (isset($_POST['save_dhcp'])){
- $this->dialog->save_object();
- $messages= $this->dialog->check();
- if (count($messages)){
- show_errors($messages);
- } else {
- $dn= $this->dialog->dn;
- $class= get_class($this->dialog);
- $type= $this->types[$class];
- if(empty($this->serviceDN)){
- $indent= substr_count(preg_replace("/".$this->dn."/", '', $dn), ",") -1;
- }else{
- $indent= substr_count(preg_replace("/".$this->serviceDN."/", '', $dn), ",");
- }
- $spaces= "";
- for ($i= 0; $i<$indent; $i++){
- $spaces.= " ";
- }
- $data= $this->dialog->save();
- if ($this->current_object == ""){
- /* New object */
- $newsects= array();
- foreach ($this->dhcpSections as $key => $dsc){
- $newsects[$key]= $dsc;
- if ($key == $dn){
- $spaces.= " ";
- $newsects[$data['dn']]= "$spaces$type '".preg_replace('/^[^=]+=([^,]+),.*$/', '\1', $data['dn'])."'";
- }
- }
- $this->dhcpObjectCache[$data['dn']]= $data;
- $this->dhcpSections= $newsects;
- } else {
- if ($dn != $data['dn']){
- /* Old object, new name */
- $this->dhcpObjectCache[$dn]= array();
- $this->dhcpObjectCache[$data['dn']]= $data;
-
- /* If we renamed a section, we've to rename a couple of objects, too */
- foreach ($this->dhcpObjectCache as $key => $dsc){
- if (preg_match("/,$dn$/", $key)){
- $new_dn= preg_replace("/,$dn$/", ",".$data['dn'], $key);
- $dsc['MODIFIED']= TRUE;
- $this->dhcpObjectCache[$new_dn]= $dsc;
- unset($this->dhcpObjectCache[$key]);
- }
- }
- $newsects= array();
- foreach ($this->dhcpSections as $key => $dsc){
- if ($key == $dn){
- $newsects[$data['dn']]= "$spaces$type '".preg_replace('/^[^=]+=([^,]+),.*$/', '\1', $data['dn'])."'";
- continue;
- }
- if (preg_match("/,$dn$/", $key)){
- $new_dn= preg_replace("/,$dn$/", ",".$data['dn'], $key);
- $newsects[$new_dn]= $dsc;
- } else {
- $newsects[$key]= $dsc;
- }
- }
- $this->dhcpSections= $newsects;
-
- } else {
- /* Old object, old name */
- $this->dhcpObjectCache[$data['dn']]= $data;
- }
- }
- $this->dialog= FALSE;
- }
- }
-
- /* Remove section? */
- if (isset($_POST['delete_dhcp_confirm'])){
- if ($this->acl_is_removeable()){
- unset($this->dhcpSections[$this->current_object]);
- unset($this->dhcpObjectCache[$this->current_object]);
- $this->dhcpObjectCache[$this->current_object]= array();
- foreach ($this->dhcpSections as $key => $value){
- if (preg_match("/".$this->current_object."$/", $key)){
- unset($this->dhcpSections[$key]);
- unset($this->dhcpObjectCache[$key]);
- $this->dhcpObjectCache[$key]= array();
- }
- }
- } else {
- print_red(_("You're not allowed to remove DHCP sections!"));
- }
- $this->dialog= FALSE;
- }
-
- /* Look for post entries */
- foreach($_POST as $name => $value){
-
- /* Insert new section? */
- if (preg_match('/^insertDhcp_.*_x$/', $name)){
- $dn= base64_decode(preg_replace('/^insertDhcp_([^_]+)_x$/', '\1', $name));
- if (isset($this->dhcpObjectCache[$dn])){
- $this->dialog= new dhcpNewSectionDialog($this->objectType($dn));
- $this->current_object= $dn;
- $this->dialog->acl= $this->acl;
- }
- }
-
- /* Edit section? */
- if (preg_match('/^editDhcp_.*_x$/', $name)){
- $dn= base64_decode(preg_replace('/^editDhcp_([^_]+)_x$/', '\1', $name));
- if (isset($this->dhcpObjectCache[$dn])){
- $section= $this->objectType($dn);
- $this->current_object= $dn;
- $this->dialog= new $section($this->dhcpObjectCache[$dn]);
- }
- }
-
- /* Remove section? */
- if (preg_match('/^delDhcp_.*_x$/', $name)){
- $dn= base64_decode(preg_replace('/^delDhcp_([^_]+)_x$/', '\1', $name));
- if (isset($this->dhcpObjectCache[$dn])){
- $this->current_object= $dn;
- $this->dialog= 1;
- $smarty->assign("warning", sprintf(_("You're about to delete the DHCP section '%s'."), $dn));
- return($smarty->fetch(get_template_path('remove_dhcp.tpl', TRUE)));
- }
- }
-
- }
-
- if(isset($_GET['act']) && $_GET['act']=="edit" && isset($_GET['id'])){
- $dn = base64_decode($_GET['id']);
- if (isset($this->dhcpObjectCache[$dn])){
- $section= $this->objectType($dn);
- $this->current_object= $dn;
- $this->dialog= new $section($this->dhcpObjectCache[$dn]);
- }
- }
-
-
- if(isset($_GET['act']) && $_GET['act']=="edit" && isset($_GET['id'])){
- $dn = base64_decode($_GET['id']);
- if (isset($this->dhcpObjectCache[$dn])){
- $section= $this->objectType($dn);
- $this->current_object= $dn;
- $this->dialog= new $section($this->dhcpObjectCache[$dn]);
- }
- }
-
-
- /* Do we need to flip is_account state? */
- if (isset($_POST['modify_state'])){
- $this->is_account= !$this->is_account;
- }
-
- /* Show tab dialog headers */
- if ($this->is_account){
-# $display= $this->show_header(_("Remove DHCP service"),
-# _("This server has DHCP features enabled. You can disable them by clicking below."));
-
- if (!count($this->dhcpObjectCache)){
- $attrs= array();
- $attrs['dn']= 'cn=dhcp,'.$this->dn;
- $attrs['cn']= array('dhcp');
- $attrs['objectClass']= array('top', 'dhcpService');
- $attrs['dhcpPrimaryDN']= array($this->dn);
- $attrs['dhcpStatements']= array("default-lease-time 600",
- "max-lease-time 1200",
- "authoritative",
- "ddns-update-style none");
- $attrs['MODIFIED']= TRUE;
- $this->dhcpSections['cn=dhcp,'.$this->dn]= _("Global options");
- $this->dhcpObjectCache['cn=dhcp,'.$this->dn]= $attrs;
- }
-
- } else {
-# $display= $this->show_header(_("Add DHCP service"),
-
-# _("This server has DHCP features disabled. You can enable them by clicking below."));
- return ($display);
- }
-
-
- /* Show dialog
- */
- if(isset($this->dialog) && is_object($this->dialog)){
- $this->dialog->save_object();
- $this->dialog->parent = $this;
- return($this->dialog->execute());
- }
-
- /* Create Listbox with existing Zones
- */
- $DhcpList = new divSelectBox("dhcpSections");
- $DhcpList->SetHeight(400);
-
- /* Add entries to divlist
- */
- $editImgIns = " ".
- " ".
- " ";
- $editImgInsNoDel = " ".
- " ";
- $editImg = " ".
- " ";
-
- $tmp = new dhcpNewSectionDialog(NULL);
- foreach($this->dhcpSections as $section => $values ){
-
- $values = "".$values." ";
-
- if (count($tmp->sectionMap[$this->objectType($section)])){
- if ($this->objectType($section) == "dhcpService"){
- $DhcpList->AddEntry(array(
- array("string" => $values),
- array("string" => str_replace("%s",base64_encode($section),$editImgInsNoDel), "attach" => "style='text-align:right;'")
- ));
- } else {
- $DhcpList->AddEntry(array(
- array("string" => $values),
- array("string" => str_replace("%s",base64_encode($section),$editImgIns), "attach" => "style='text-align:right;'")
- ));
- }
- } else {
- $DhcpList->AddEntry(array(
- array("string" => $values),
- array("string" => str_replace("%s",base64_encode($section),$editImg), "attach" => "style='text-align:right;'")
- ));
- }
- }
-
- /* Display tempalte */
- $smarty->assign("DhcpList",$DhcpList->DrawList());
- $display.= $smarty->fetch(get_template_path('servdhcp.tpl', TRUE));
- return($display);
- }
-
-
- function remove_from_parent()
- {
- /* Cancel if there's nothing to do here */
- if (!$this->initially_was_account){
- return;
- }
-
- /* Remove subtrees */
- $ldap= $this->config->get_ldap_link();
- foreach ($this->dhcpObjectCache as $dn => $content){
- if ($this->objectType($dn) == 'dhcpService'){
- $ldap->rmdir_recursive($dn);
- show_ldap_error($ldap->get_error(), _("Removing DHCP entries failed"));
- }
- }
-
- /* Remove from self */
- $ldap= $this->config->get_ldap_link();
-
- /* Remove and write to LDAP */
- plugin::remove_from_parent();
-
- @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->attributes, "Save");
- $ldap->cd($this->dn);
- $this->cleanup();
- $ldap->modify ($this->attrs);
-
- show_ldap_error($ldap->get_error(), _("Removing DHCP entries failed"));
-
- /* Optionally execute a command after we're done */
- $this->handle_post_events("remove");
- }
-
-
- /* Save data to object */
- function save_object()
- {
- plugin::save_object();
- }
-
-
- /* Check supplied data */
- function check()
- {
- /* Call common method to give check the hook */
- $message= plugin::check();
-
- return ($message);
- }
-
-
- /* Save to LDAP */
- function save()
- {
- /* Take over handling
- * - Load servdhcp class and dhcpObjectCache for the source dhcp setup.
- * - Assign dhcpObjectCache to this configuration.
- * - Save this setup and remove source setup from ldap.
- */
- if($this->take_over_id != -1){
- $id = $this->take_over_id;
- $src = preg_replace("/cn=dhcp,/","",$this->dhcp_server_list['ENTRIES'][$id]['dn']);
- $tmp = new servdhcp ($this->config, $src);
- $this->orig_dn = $src;
- $this->dhcpObjectCache = $tmp->dhcpObjectCache;
- }
-
- /* Save dhcp setttings */
- $ldap= $this->config->get_ldap_link();
- foreach ($this->dhcpObjectCache as $dn => $data){
-
- if($this->dn != $this->orig_dn){
- $dn = preg_replace("/".normalizePreg($this->orig_dn)."$/i",$this->dn,$dn);
- }
-
- /* Remove entry? */
- if (count($data) == 0){
- /* Check if exists, then remove... */
- if($ldap->cat($dn)){
- $ldap->rmdir_recursive($dn);
- show_ldap_error($ldap->get_error(), _("Can't remove DHCP object!"));
- }
- continue;
- }
-
- /* Opdate dhcp option 'server-name' to actual server name */
- if($this->dn != $this->orig_dn){
- $fixed = FALSE;
- foreach(array("dhcpHost","dhcpSubnet","dhcpGroup","dhcpSharedNetwork") as $object){
- if(in_array($object,$data['objectClass']) && isset($data['dhcpOption'])){
- foreach($data['dhcpOption'] as $key => $option){
- if(preg_match("/^server-name /",$option)){
- $data['dhcpOption'][$key] = "server-name ".$this->cn;
- $data['MODIFIED'] = TRUE;
- break;
- }
- }
- }
-
- /* Skip next loops if entry is updated */
- if($fixed){
- break;
- }
- }
- }
-
- /* Modify existing entry? */
- if (isset($data['MODIFIED']) || $this->orig_dn != $this->dn){
-
- if($ldap->cat($dn)){
- $modify= TRUE;
- } else {
- $modify= FALSE;
- }
-
- /* Build new entry */
- $attrs= array();
- foreach ($data as $attribute => $values){
- if ($attribute == "MODIFIED" || $attribute == "dn"){
- continue;
- }
-
- if(in_array($attribute,array("dhcpPrimaryDN","dhcpSecondaryDN","dhcpServerDN","dhcpFailOverPeerDN"))){
- foreach($values as $v_key => $value){
- $values[$v_key] = preg_replace("/".normalizePreg($this->orig_dn)."$/i",$this->dn,$value);
- }
- }
-
- if (count($values)){
-
- if($attribute == "dhcpOption"){
- foreach($values as $key => $value){
- $option_name = trim(preg_replace("/[^ ]*$/","",$value));
- $option_value= trim(preg_replace("/^[^ ]*/","",$value));
- if(in_array($option_name,$this->quote_option)){
- $values[$key] = $option_name." \"".$option_value."\"";
- }
- }
- }
- if (count($values) == 1){
- $attrs[$attribute]= $values[0];
- } else {
- $attrs[$attribute]= $values;
- }
- } else {
- if ($modify){
- $attrs[$attribute]= array();
- }
- }
- }
-
- $ldap->cd($dn);
- if ($modify){
- $ldap->modify($attrs);
- show_ldap_error($ldap->get_error(), _("Can't save DHCP object!"));
-
- /* Optionally execute a command after we're done */
- $this->handle_post_events("modify");
- } else {
- $ldap->add($attrs);
- show_ldap_error($ldap->get_error(), _("Can't save DHCP object!"));
-
- /* Optionally execute a command after we're done */
- $this->handle_post_events("create");
- }
- }
- }
-
- $this->dhcpServiceDN= $this->serviceDN;
- if($this->dn != $this->orig_dn){
- $this->dhcpServiceDN= preg_replace("/".normalizePreg($this->orig_dn)."$/i",$this->dn,$this->dhcpServiceDN);
- }
-
- /* Replace 'new' dn */
- if(preg_match("/new$/",$this->dhcpServiceDN)){
- $this->dhcpServiceDN = preg_replace("/new$/",$this->dn,$this->dhcpServiceDN);
- }
-
- plugin::save();
-
- /* Save data to LDAP */
- $ldap->cd($this->dn);
- $this->cleanup();
- $ldap->modify ($this->attrs);
-
- show_ldap_error($ldap->get_error(), _("Saving DHCP service failed"));
-
- /* Optionally execute a command after we're done */
- if ($this->initially_was_account == $this->is_account){
- if ($this->is_modified){
- $this->handle_post_events("modify");
- }
- } else {
- $this->handle_post_events("add");
- }
-
- /* Take over handling
- * - Remove old dhcp config from source server
- */
- if($this->take_over_id != -1){
- $id = $this->take_over_id;
- $src = $this->dhcp_server_list['ENTRIES'][$id]['dn'];
- $tmp = new servdhcp ($this->config, $src);
- $tmp->remove_from_parent();
- }
- }
-
-
- function reload()
- {
- /* Init LDAP and load list */
- $ldap= $this->config->get_ldap_link();
- $ui= get_userinfo();
- $me= $this->dn;
-
- $filter = "(&(objectClass=dhcpService)(|(dhcpPrimaryDN=$me)(dhcpSecondaryDN=$me)(dhcpServerDN=$me)(dhcpFailOverPeerDN=$me)))";
-
- $list= get_list($filter, array("server"), $this->config->current['BASE'], array("cn"),GL_SIZELIMIT | GL_SUBSEARCH);
- $final= array();
-
- foreach ($list as $value){
-
- /* Set header */
- $sortpart= split(",", $value['dn']);
- $sortpart= array_reverse($sortpart);
- $tmp= implode(",", $sortpart);
-
- $final[$value['dn']]= $tmp."!"._("Global options");
-
- /* Read all sub entries to place here */
- $ldap->cd($value['dn']);
- $ldap->search("(|(objectClass=dhcpService)(objectClass=dhcpLog)(objectClass=dhcpClass)(objectClass=dhcpSubClass)(objectClass=dhcpHost)(objectClass=dhcpGroup)(objectClass=dhcpPool)(objectClass=dhcpSubnet)(objectClass=dhcpSharedNetwork)(objectClass=dhcpOptions)(objectClass=dhcpTSigKey)(objectClass=dhcpDnsZone)(objectClass=dhcpFailOverPeer))", array());
- $this->serviceDN= $value['dn'];
-
- while ($attrs= $ldap->fetch()){
- $sattrs= array();
- for ($i= 0; $i<$attrs['count']; $i++){
- $sattrs[$attrs[$i]]= $attrs[$attrs[$i]];
- unset($sattrs[$attrs[$i]]['count']);
- }
- $sattrs['dn']= $ldap->getDN();
-
- foreach($sattrs as $name => $values){
- if($name == "dhcpOption"){
- foreach($values as $key => $value){
- $value_name = trim(preg_replace("/[^ ]*$/","",$value));
- $value_value= trim(preg_replace("/^[^ ]*/","",$value));
- if(in_array($value_name,$this->quote_option)){
- $value_value = preg_replace("/^\"/","",$value_value);
- $value_value = preg_replace("/\"$/","",$value_value);
- $sattrs[$name][$key] = $value_name." ".$value_value;
- }
- }
- }
- }
-
- $this->dhcpObjectCache[$ldap->getDN()]= $sattrs;
- $tmp= preg_replace("/".$this->serviceDN."/", "", $ldap->getDN());
- $indent= substr_count($tmp, ",");
- $spaces= "";
- for ($i= 0; $i<$indent; $i++){
- $spaces.= " ";
- }
-
- foreach ($this->types as $key => $val){
- if (in_array("$key", $attrs['objectClass'])){
- $type= $val;
- break;
- }
- }
-
- /* Prepare for sorting... */
- $sortpart= split(",", $ldap->getDN());
- $sortpart= array_reverse($sortpart);
- $tmp= implode(",", $sortpart);
- $final[$ldap->getDN()]= $tmp."!".$spaces.$type." '".$attrs['cn'][0]."'";
- }
- }
-
- /* Sort it... */
- natsort($final);
- $this->dhcpSections= array();
- foreach ($final as $key => $val){
- $this->dhcpSections[$key]= preg_replace('/^[^!]+!(.*)$/', '\\1', $val);
- }
-
- }
-
-
- function objectType($dn)
- {
- $type= "";
- $types= array("dhcpService", "dhcpClass", "dhcpSubClass", "dhcpHost",
- "dhcpGroup", "dhcpPool", "dhcpSubnet", "dhcpSharedNetwork");
-
- foreach ($this->dhcpObjectCache[$dn]['objectClass'] as $oc){
- if (in_array($oc, $types)){
- $type= $oc;
- break;
- }
- }
-
- /* That should not happen... */
- if ($type == ""){
- print_red(_("DHCP configuration set is unknown. Please contact your system administrator."));
- }
-
- return ($type);
- }
-
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("DHCP service"),
- "plDescription" => _("DHCP service")." ("._("Services").")",
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 84,
- "plSection" => array("administration"),
- "plCategory" => array("server"),
-
- "plProvidedAcls"=> array(
-
- )
- ));
- }
-
-
- function take_over_service()
- {
-
- }
-
-
- function get_list_of_dhcp_servers()
- {
- $ret = array("ENTRIES"=> array(),"FOR_LIST"=> array());
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
- $ldap->search("(&(objectClass=goServer)(dhcpServiceDN=*))",array("dn","cn","dhcpServiceDN"));
- while($attrs = $ldap->fetch()){
-
- /* Skip own config */
- if($this->dn != "new" && preg_match("/".normalizePreg($this->dn)."$/",$attrs['dn'])){
- continue;
- }
-
- $ret['ENTRIES'][] = $attrs;
- }
- foreach($ret['ENTRIES'] as $key => $data){
- $ret['FOR_LIST'][$key] = $data['cn'][0];
- }
- return($ret);
- }
-
-
- function getListEntry()
- {
- $fields = goService::getListEntry();
- $fields['Message'] = _("DHCP service");
- $fields['AllowEdit'] = true;
- return($fields);
- }
-
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_servDNS.inc b/plugins/admin/systems/class_servDNS.inc
deleted file mode 100644
index 13e7a9317..000000000
--- a/plugins/admin/systems/class_servDNS.inc
+++ /dev/null
@@ -1,598 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* attribute list for save action */
- var $ignore_account = FALSE;
- var $attributes = array();
- var $objectclasses = array("whatever");
-
- var $RecordTypes = array();
- var $Zones = array();
-
- var $orig_dn = "";
-
- var $initially_was_account;
-
- /* ServerService tab vars */
- var $conflicts = array("servdns");
- var $DisplayName = "";
- var $StatusFlag = "";
- var $view_logged = FALSE;
-
- var $dns_server_list = array("ENTRIES"=> array(),"FOR_LIST"=> array());
- var $take_over_id = -1;
-
-
- function servdns (&$config, $dn= NULL, $parent= NULL)
- {
- plugin::plugin ($config, $dn, $parent);
-
- $this->DisplayName = _("DNS service");
-
- $this->orig_dn = $dn;
-
- /* Get record types for zones
- */
- $this->RecordTypes = getDnsRecordTypes(true);
-
- /* Get all zone Informations
- */
- $this->Zones = getDNSZoneEntries($config,$dn);
-
- /* If there is at least one entry in this -> types, we have DNS enabled
- */
- if(count($this->Zones) == 0){
- $this->is_account = false;
- $this->dns_server_list = $this->get_list_of_dns_servers();
- }else{
- $this->is_account = true;
- }
- $this->initially_was_account = $this->is_account;
- }
-
-
- function get_list_of_dns_servers()
- {
- $ret = array("ENTRIES"=> array(),"FOR_LIST"=> array());
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
- $ldap->search("(&(objectClass=dNSZone)(zoneName=*))",array("dn","zoneName"));
- $dns = array();
- while($attrs = $ldap->fetch()){
- /* Skip own config */
- if($this->dn != "new" && preg_match("/".normalizePreg($this->dn)."$/",$attrs['dn'])){
- continue;
- }
- $dn = preg_replace("/^zoneName=[^,]+,/","",$attrs['dn']);
- if(preg_match("/^cn=/",$dn) && !in_array($dn,$dns)){
- $dns[] = $dn;
- }
- }
- $i = 0;
- foreach($dns as $dn){
- $ldap->cat($dn,array('*'));
- if($ldap->count()){
- $i ++;
- $attrs = $ldap->fetch();
- $ret['ENTRIES'][$i] = $attrs;
- $ret['FOR_LIST'][$i] = $attrs['cn'][0];
- }
- }
- return($ret);
- }
-
-
- function get_dns_info_string($id)
- {
- $ret="";
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->dns_server_list['ENTRIES'][$id]['dn']);
- $ldap->search("(|(zoneName=*)(relativeDomainName=*))",array("dn"));
- while($attrs = $ldap->fetch()){
- $ret .= $attrs['dn']."\n";
- }
- return($ret);
- }
-
-
- function execute()
- {
- /* Call parent execute
- */
- plugin::execute();
-
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","server/".get_class($this),$this->dn);
- }
-
- /* Fill templating stuff
- */
- $smarty= get_smarty();
- $smarty->assign("dns_take_over",FALSE);
- $smarty->assign("is_createable",$this->acl_is_createable());
- $display= "";
-
-
- $this->initially_was_account= $this->is_account;
- /*****************/
- /* Handle Take Over Actions
- /*****************/
-
- /* Give smarty the required informations */
- $smarty->assign("dns_server_list", $this->dns_server_list['FOR_LIST']);
- $smarty->assign("dns_server_list_cnt", count($this->dns_server_list['FOR_LIST']));
-
- /* Take over requested, save id */
- if(isset($_POST['take_over_src']) && isset($_POST['take_over'])){
- $id = $_POST['take_over_src'];
- if(isset($this->dns_server_list['ENTRIES'][$id])){
- $this->take_over_id = $id;
- }
- }
-
- /* Abort take over action */
- if(isset($_POST['cancel_take_over'])){
- $this->dialog =false;
- $this->take_over_id = -1;
- $this->dns_server_list = $this->get_list_of_dns_servers();
- }
-
- /* Display informartion about take over that will be started when saving this server
- * and hide default dns output
- */
- if($this->take_over_id != -1){
- $this->dialog = FALSE;
- $id = $this->take_over_id;
- $info = $this->get_dns_info_string($id);
- $smarty->assign("dns_take_over",TRUE);
- $smarty->assign("info",$info);
- $warning = sprintf(_("You are going to migrate the DNS setup from server '%s'."),$this->dns_server_list['ENTRIES'][$id]['cn'][0]);
- $warning2 = _("The migration will be startet when you save this system. To cancel this action, use the cancel button below.");
- $smarty->assign("warning",$warning);
- $smarty->assign("warning2",$warning2);
- return($smarty->fetch(get_template_path('servdns.tpl', TRUE)));
- }
-
-
- /* Do we need to flip is_account state?
- */
- if (isset($_POST['modify_state'])){
- $this->is_account= !$this->is_account;
- }
-
- if ($this->is_account){
- $display= $this->show_disable_header(_("Remove DNS service"),
- _("This server has DNS features enabled. You can disable them by clicking below."));
- } else {
- $display= $this->show_enable_header(_("Add DNS service"),
- _("This server has DNS features disabled. You can enable them by clicking below."));
- return ($display);
- }
-
-
- /* Edited or Added zone
- */
- if(isset($_POST['SaveZoneChanges'])){
- $this->dialog->save_object();
-
- /* Check for errors
- */
- if(count($this->dialog->check())){
- foreach($this->dialog->check() as $msgs){
- print_red($msgs);
- }
- }else{
- /* add new/edited zone
- */
- $ret = $this->dialog->save();
- if(!$this->dialog->isNew){
- unset($this->Zones[$this->dialog->OldZoneName]);
- }
- $this->Zones[$ret['zoneName']] = $ret;
- $this->dialog = FALSE;
- }
- }
-
- /* Cancel zone edit / new
- */
- if(isset($_POST['CancelZoneChanges'])){
- $this->dialog = FALSE;
- }
-
- /* Add empty new zone
- */
- if(isset($_POST['AddZone'])){
- $this->dialog = new servdnseditZone($this->config,$this->dn);
- }
-
- /* Check for edit zone request
- */
- $once = false;
- foreach( $_POST as $name => $value){
-
- /* check all post for edit request
- */
- if(preg_match("/^editZone_/",$name)&&!$once){
- $once =true;
- $tmp = preg_replace("/^editZone_/","",$name);
- $tmp = base64_decode(preg_replace("/_.*$/","",$tmp));
- $this->dialog= new servdnseditZone($this->config,$this->dn,$this->Zones[$tmp]);
- }
-
- /* check posts for delete zone
- */
- if(preg_match("/^delZone_/",$name)&&!$once){
-
- $once =true;
- $tmp = preg_replace("/^delZone_/","",$name);
- $tmp = base64_decode(preg_replace("/_.*$/","",$tmp));
-
- /* Initiate deletion
- */
- $this->RemoveZone($tmp);
- }
- }
-
- if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id'])){
- $id = base64_decode($_GET['id']);
- if(isset($this->Zones[$id])){
- $this->dialog= new servdnseditZone($this->config,$this->dn,$this->Zones[$id]);
- }
- }
-
- if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id'])){
- $id = base64_decode($_GET['id']);
- if(isset($this->Zones[$id])){
- $this->dialog= new servdnseditZone($this->config,$this->dn,$this->Zones[$id]);
- }
- }
-
- /* Show dialog
- */
- if(is_object($this->dialog)){
- $this->dialog->save_object();
- $this->dialog->parent = $this;
- return($this->dialog->execute());
- }
-
- /* Create Listbox with existing Zones
- */
- $ZoneList = new divSelectBox("dNSZones");
- $ZoneList -> SetHeight(254);
-
- /* Add entries to divlist
- */
- $editImg = " ";
- if($this->acl_is_removeable()){
- $editImg.= " ";
- }
-
- $link = "%s ";
- foreach($this->Zones as $zone => $values ){
- $ZoneList->AddEntry(array(
- array("string" => sprintf($link,base64_encode($zone),($zone))),
- array("string" => sprintf($link,base64_encode($zone),_("Reverse zone")." : ".($values['ReverseZone']))),
- array("string" => _("TTL")." : ".$values['sOAttl']),
- array("string" => _("Class")." : ".$values['dNSClass']),
- array("string" =>str_replace("%s",base64_encode($zone),$editImg))
- ));
- }
-
- /* Display tempalte
- */
- $smarty->assign("ZoneList",$ZoneList->DrawList());
- $display.= $smarty->fetch(get_template_path('servdns.tpl', TRUE));
- return($display);
- }
-
-
- /* Delete specified zone
- */
- function RemoveZone($id)
- {
- $zones = $this->getUsedZoneNames();
-
- if(isset($this->Zones[$id]['InitialReverseZone'])){
- $rev = FlipIp($this->Zones[$id]['InitialReverseZone']);
- }else{
- $rev = FlipIp($this->Zones[$id]['ReverseZone']);
- }
-
- $zonename = "";
- if(isset($this->Zones[$id]['InitialzoneName'])){
- $zonename= $this->Zones[$id]['InitialzoneName'];
- }
-
- $used = array();
-
- /* Add Records which use this zoneName
- */
- if(isset($zones[$zonename])){
- $used = array_merge($used,$zones[$zonename]);
- }
-
- /* Add Records which uses this reverse zone
- */
- if(isset($zones[$rev.".in-addr.arpa"])){
- $used = array_merge($used,$zones[$rev.".in-addr.arpa"]);
- }
-
- /* There are still entries using this configuration
- * Abort deletion
- */
- if(count($used)){
- $i = 2;
- $str ="";
- foreach($used as $dn){
- if($i > 0 && !preg_match("/,relativeDomainName=/",$dn)){
- $i --;
- $name = preg_replace("/^[^=]+=([^,]*),.*$/","\\1",$dn);
- $zone = preg_replace("/^.*zoneName=([^,]*),.*$/","\\1",$dn);
- $str.= $name.".".$zone." ";
- }
- }
-
- /* Only show 2 dns in the error message
- */
- if(count($used)> 2) {
- $str .=" ... ";
- }
- print_red(sprintf(_("Can't delete the selected zone, because it is still in use by these entry/entries '%s'"),trim($str)));
- return(false);
- }else{
- unset($this->Zones[$id]);
- return(true);
- }
- }
-
-
- /* This funtion returns all used Zonenames
- */
- function getUsedZoneNames()
- {
- $ret = array();
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
- $ldap->search("(&(objectClass=dNSZone)(!(relativeDomainName=@))(zoneName=*))",array("zoneName","relativeDomainName"));
- while($attr = $ldap->fetch()){
- $ret[$attr['zoneName'][0]][] = $attr['dn'];
- }
- return($ret);
- }
-
-
- /* Remove dns service
- */
- function remove_from_parent()
- {
- if($this->initially_was_account){
- $bool = true;
- $this->is_account = FALSE;
- foreach($this->Zones as $key => $zone){
- $bool= $bool & $this->RemoveZone($key);
- }
-
- if($bool){
- $this->save();
- }
- return($bool);
- }
- }
-
-
- /* Save to LDAP */
- function save()
- {
-
- /* Take over handling
- * - Create list of zones managed by source server
- * - Copy ldap entries to destination server
- * - Remove old zone entries from source
- */
- if($this->take_over_id != -1){
- $del = array();
- $id = $this->take_over_id;
- $src = $this->dns_server_list['ENTRIES'][$id]['dn'];
- $ldap = $this->config->get_ldap_link();
- $ldap->ls("(objectClass=dnsZone)",$src,array('cn'));
- while($attrs = $ldap->fetch()){
- $src_zone = $attrs['dn'];
- $dst_zone = preg_replace("/".normalizePreg($src)."$/",$this->dn,$src_zone);
- $res = plugin::recursive_move($src_zone, $dst_zone);
-
- if($res){
- $del [] = $src_zone;
- }
- }
- foreach($del as $src_zone){
- $ldap->rmdir_recursive($src_zone);
- }
- return;
- }
-
- /* Save zone editor changes now */
- foreach($this->Zones as $name => $zone){
- if(isset($zone['zoneEditor'] ) && $zone['zoneEditor'] != NULL && is_object($zone['zoneEditor'])){
- $zone['zoneEditor']->save();
- unset($this->Zones[$name]['zoneEditor']);;
- }
- }
-
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
-
- /* Get differences
- */
- $old_dn = $this->orig_dn;
- if($old_dn == "new"){
- $old_dn = $this->dn;
- }
-
- $tmp = getDNSZoneEntriesDiff($this->config,$this->Zones,$old_dn);
-
- /* Update dns to current object dn */
- $tmp = getDNSZoneEntriesDiff($this->config,$this->Zones,$old_dn);
- $tmp2 = array();
- foreach($tmp as $key1 => $data1){
- $tmp2[$key1] = array();
- foreach($data1 as $key2 => $data2){
- $tmp2[$key1][preg_replace("/".normalizePreg($old_dn)."$/",$this->dn,$key2)] = $data2;
- }
- }
- $tmp = $tmp2;
-
- /* Updated zone entries if reverser or forward name has changed
- * Must be done before moving entries, else the given dn is invalid
- */
- if(isset($tmp['zoneUpdates'])){
- foreach($tmp['zoneUpdates'] as $dn => $attrs){
- $ldap->cd($dn);
- $ldap->modify($attrs);
- new log("modfiy","unknown/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- show_ldap_error($ldap->get_error(), sprintf(_("Updating of system server/dns with dn '%s' failed."),$this->dn));
- }
- }
-
- /* Delete dns
- */
- foreach($tmp['del'] as $dn => $del){
-
- $for = $del['InitialzoneName'];
- $rev = FlipIp($del['InitialReverseZone']).".in-addr.arpa";
-
- $ldap->cd($dn);
- $ldap->rmdir_recursive($dn);
- new log("remove","unknown/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- show_ldap_error($ldap->get_error(), sprintf(_("Removing of system server/dns with dn '%s' failed."),$this->dn));
-
- /* Handle Post events */
- if(preg_match("/^zoneName=/",$dn)){
-# $this->handle_post_events("remove",array("dn" => $dn,"zoneName" => $for));
-# $this->handle_post_events("remove",array("dn" => $dn,"zoneName" => $rev));
- }
- }
-
- /* move follwoing entries
- */
- foreach($tmp['move'] as $src => $dst){
- $this->recursive_move($src,$dst);
- }
-
- /* Add || Update new DNS entries
- */
- foreach($tmp['add'] as $dn => $attrs){
- $ldap->cd($dn);
- $ldap->cat($dn, array('dn'));
- if($ldap->fetch()){
- $ldap->cd($dn);
- $ldap->modify ($attrs);
- show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/dns with dn '%s' failed."),$this->dn));
-
- /* Handle Post events */
- if(preg_match("/^zoneName=/",$dn)){
-# $this->handle_post_events("modify",array("dn" => $dn,"zoneName" => $attrs['zoneName']));
- }
- }else{
- $ldap->cd($dn);
- $ldap->add($attrs);
- show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/dns with dn '%s' failed."),$this->dn));
-
- /* Handle Post events */
- if(preg_match("/^zoneName=/",$dn)){
-# $this->handle_post_events("add",array("dn" => $dn,"zoneName" => $attrs['zoneName']));
- }
- }
- }
- $this->handle_post_events("modify");
- }
-
-
- /* Directly save new status flag */
- function setStatus($value)
- {
- if($value == "none") return;
- if(!$this->initially_was_account) return;
- if(empty($this->StatusFlag)) return;
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->dn);
- $ldap->cat($this->dn,array("objectClass"));
- if($ldap->count()){
-
- $tmp = $ldap->fetch();
- for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
- $attrs['objectClass'][] = $tmp['objectClass'][$i];
- }
- $flag = $this->StatusFlag;
- $attrs[$flag] = $value;
- $this->$flag = $value;
- $ldap->modify($attrs);
- show_ldap_error($ldap->get_error(), sprintf(_("Set status flag for system server/dns with dn '%s' failed."),$this->dn));
- $this->action_hook();
- }
- }
-
-
- function getListEntry()
- {
- $fields = goService::getListEntry();
- $fields['Message'] = _("DNS service");
- $fields['AllowEdit'] = true;
- return($fields);
- }
-
-
- /* Get updates for status flag */
- function updateStatusState()
- {
- if(empty($this->StatusFlag)) return;
-
- $attrs = array();
- $flag = $this->StatusFlag;
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->cn);
- $ldap->cat($this->dn,array($flag));
- if($ldap->count()){
- $attrs = $ldap->fetch();
- }
- if(isset($attrs[$flag][0])){
- $this->$flag = $attrs[$flag][0];
- }
- }
-
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("DNS service"),
- "plDescription" => _("DNS service")." ("._("Services").")",
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 83,
- "plSection" => array("administration"),
- "plCategory" => array("server"),
-
- "plProvidedAcls"=> array(
- "zoneName" =>_("Zone name"),
- "ReverseZone" =>_("Reverse zone"),
- "sOAprimary" =>_("Primary dns server"),
- "sOAmail" =>_("Mail address"),
- "sOAserial" =>_("Serial"),
- "sOArefresh" =>_("Refresh"),
- "sOAretry" =>_("Retry"),
- "sOAexpire" =>_("Expire"),
- "sOAttl" =>_("TTL"),
- "zoneRecords" =>_("Zone records"))
- ));
- }
-
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_servDNSeditZone.inc b/plugins/admin/systems/class_servDNSeditZone.inc
deleted file mode 100644
index d5df0871d..000000000
--- a/plugins/admin/systems/class_servDNSeditZone.inc
+++ /dev/null
@@ -1,603 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* attribute list for save action */
- var $ignore_account= TRUE;
- var $attributes = array("zoneName","ReverseZone","dNSClass",
- "sOAprimary","sOAmail","sOAserial","sOArefresh","sOAretry","sOAexpire","sOAttl");
- var $objectclasses = array("whatever");
-
- var $RecordTypes = array();
-
- var $ReverseZone = "";
- var $zoneName = "";
- var $dNSClass = "IN";
-
- var $sOAprimary = "";
- var $sOAmail = "";
- var $sOAserial = "";
- var $sOArefresh = "3600";
- var $sOAretry = "1800";
- var $sOAexpire = "720000";
- var $sOAttl = "6400";
-
- var $Records = array();
- var $mXRecords = array();
-
- var $OldZoneName = ""; // To detect changes made with this edit
- var $OldReverseZone = "";
-
- var $InitialReverseZone = "";
- var $InitialzoneName = "";
- var $NetworkClass = "A" ; // One out of A,B,C
-
- var $dialog = false;
-
- var $zoneEditor = NULL;
-
- var $isNew = true;
-
- var $ZoneObject = array();
-
- function servdnseditZone (&$config, $dn= NULL,$attrs = array())
- {
- plugin::plugin ($config, $dn);
-
- /* All types with required attrs */
- $this->RecordTypes = getDnsRecordTypes(true);
-
- if(!count($attrs)){
- $this->OldZoneName = "";
- $this->OldReverseZone = "";
- $this->isNew = true;
- $this->sOAserial = date("Ymd")."1";
-
- $this->InitialzoneName = "";//$attrs['InitialzoneName'];
- $this->InitialReverseZone = "";//$attrs['InitialReverseZone'];
- }else{
- $this->ZoneObject = $attrs;
-
- if(isset($attrs['zoneEditor'])){
- $this->zoneEditor = $attrs['zoneEditor'];
- }
- $this->OldZoneName = $attrs['zoneName'];
- $this->OldReverseZone = $attrs['ReverseZone'];
-
- $this->InitialzoneName = $attrs['InitialzoneName'];
- $this->InitialReverseZone = $attrs['InitialReverseZone'];
-
- $this->isNew = false;
-
- foreach($this->attributes as $value){
- $this->$value = $attrs[$value];
- }
-
- $this->sOAmail = preg_replace("/\./","@",$this->sOAmail,1);
- $this->sOAmail = preg_replace("/\.$/","",$this->sOAmail);
- $this->sOAprimary = preg_replace("/\.$/","",$this->sOAprimary);
- $this->zoneName = preg_replace("/\.$/","",$this->zoneName);
-
- if(isset($attrs['RECORDS'])){
- $this->Records = $attrs['RECORDS'];
-
- $tmp2 = array();
- $usedPrio = array();
- foreach($this->Records as $key => $rec){
- if($rec['type'] == "mXRecord"){
- $tmp = split(" ",$rec['value']);
- $rec['value'] = $tmp[1];
- $tmp2[$tmp[0]] = $rec;
- unset($this->Records[$key]);
- }
- if($rec['type'] == "nSRecord"){
- unset($this->Records[$key]);
- }
- }
- if(count($tmp2) != 0){
- reset($tmp2);
- ksort($tmp2);
- }
- $this->mXRecords = $tmp2;
- }else{
- $this->mXRecords = array();
- $this->Records = array();
- }
-
- $str = date("Ymd");
- if(preg_match("/^".$str."/",$this->sOAserial)){
- $this->sOAserial = $this->sOAserial + 1;
- }else{
- $this->sOAserial = date("Ymd")."01";
- }
- }
-
- /* Detect Network class */
- if(!empty($this->ReverseZone)){
-
- $dots = count(split("\.",$this->ReverseZone));
- if($dots == 1){
- $this->NetworkClass = "A";
- $this->ReverseZone .= ".0.0.0";
- }elseif($dots == 2){
- $this->NetworkClass = "B";
- $this->ReverseZone .= ".0.0";
- }else{
- $this->NetworkClass = "C";
- $this->ReverseZone .= ".0";
- }
- }
- }
-
- /* TRansports the geiven Arraykey one position up*/
- function ArrayUp($atr,$attrs)
- {
- $ret = $attrs;
- $pos = $atr ;
- $cn = count($attrs);
- if(!(($pos == -1)||($pos == 1)||($pos >$cn))){
- $before = array_slice($attrs,0,($pos-2));
- $mitte = array_reverse(array_slice($attrs,($pos-2),2));
- $unten = array_slice($attrs,$pos);
- $ret = array();
- $ret = $this->combineArrays($before,$mitte,$unten);
- }
- return($ret);
- }
-
-
- /* TRansports the geiven Arraykey one position up*/
- function ArrayDown($atr,$attrs)
- {
- $ret = $attrs;
- $pos = $atr ;
- $cn = count($attrs);
- if(!(($pos == -1)||($pos == $cn))){
- $before = array_slice($attrs,0,($pos-1));
- $mitte = array_reverse(array_slice($attrs,($pos-1),2));
- $unten = array_slice($attrs,($pos+1));
- $ret = array();
- $ret = $this->combineArrays($before,$mitte,$unten);
- }
- return($ret);
- }
-
- /* Combine new array */
- function combineArrays($ar0,$ar1,$ar2)
- {
- $ret = array();
- if(is_array($ar0))
- foreach($ar0 as $ar => $a){
- $ret[]=$a;
- }
- if(is_array($ar1))
- foreach($ar1 as $ar => $a){
- $ret[]=$a;
- }
- if(is_array($ar2))
- foreach($ar2 as $ar => $a){
- $ret[]=$a;
- }
- return($ret);
- }
-
- function getpos($atr,$attrs)
- {
- $i = 0;
- foreach($attrs as $attr => $name) {
- $i++;
- if($attr == $atr){
- return($i);
- }
- }
- return(-1);
- }
-
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
-
-
- /* Fill templating stuff */
- $smarty= get_smarty();
- $ui = get_userinfo();
-
- $smarty->assign("ACLs",$this->parent->getacl(""));
- $display= "";
-
- /* Open Zone Entry Edit Dialog
- */
- if(!count($this->ZoneObject)){
- $smarty->assign("AllowZoneEdit" , false);
- }else{
- $smarty->assign("AllowZoneEdit" , true);
- if(isset($_POST['EditZoneEntries'])){
- if($this->zoneEditor == NULL){
- $this->zoneEditor= new servDNSeditZoneEntries($this->config,$this->dn,$this->ZoneObject);
- $this->zoneEditor->parent = $this;
- }
- $this->dialog = $this->zoneEditor;
- }
- }
-
- /* Save Zone Entry Edit Dialog
- */
- if(isset($_POST['SaveZoneEntryChanges'])){
- $this->dialog->save_object();
- if(count($this->dialog->check())){
- $msgs = $this->dialog->check();
- foreach($msgs as $msg){
- print_red($msg);
- }
- }else{
- $this->zoneEditor = clone $this->dialog;
- $this->dialog = FALSE;
-# $rev = FlipIp(getNameFromMix($this->InitialReverseZone)).".in-addr.arpa";
-# $for = getNameFromMix($this->InitialzoneName);
-#
-# $this->parent->handle_post_events("modify",array("dn" => $this->dn,"zoneName" => $rev));
-# $this->parent->handle_post_events("modify",array("dn" => $this->dn,"zoneName" => $for));
-# $this->dialog = false;
- }
- }
-
- /* Cancel Zone Entrie Edit Dialog
- */
- if(isset($_POST['CancelZoneEntryChanges'])){
- $this->dialog = false;
- }
-
- /* Display any type of open dialogs
- */
- if(is_object($this->dialog)){
- $this->dialog->save_object();
- return($this->dialog->execute());
- }
-
- $once =true;
- foreach($_POST as $name => $value){
- if((preg_match("/^MXup_/",$name)) && ($once)){
- $once = false;
-
- $id = preg_replace("/^MXup_/","",$name);
- $id = preg_replace("/_.*$/","",$id);
- $id = base64_decode($id);
-
- $this->mXRecords = $this->ArrayUp(($id+1),$this->mXRecords);
- }
- if((preg_match("/^MXdown_/",$name)) && ($once)){
- $once = false;
-
- $id = preg_replace("/^MXdown_/","",$name);
- $id = preg_replace("/_.*$/","",$id);
- $id = base64_decode($id);
-
- $this->mXRecords = $this->ArrayDown(($id+1),$this->mXRecords);
- }
- if((preg_match("/^MXdel_/",$name)) && ($once)){
- $once = false;
-
- $id = preg_replace("/^MXdel_/","",$name);
- $id = preg_replace("/_.*$/","",$id);
- $id = base64_decode($id);
-
- unset($this->mXRecords[$id]);
-
- $tmp =array();
- foreach($this->mXRecords as $entry){
- $tmp[] = $entry;
- }
-
- $this->mXRecords = $tmp;
- }
- }
-
- if((isset($_POST['AddMXRecord'])) && (!empty($_POST['StrMXRecord']))){
- $this->mXRecords[] = array("type"=>"mXRecord","value"=>trim($_POST['StrMXRecord']));
- }
-
- /* Handle Post events */
- $once = true;
- foreach($_POST as $name => $value){
-
- /* Delete record if requested */
- if((preg_match("/RemoveRecord_/",$name))&&($once)){
- $once = false;
- $id= preg_replace("/RemoveRecord_/","",$name);
- unset($this->Records[$id]);
- }
- }
-
- /* Add new Zonerecord */
- if(isset($_POST['AddNewRecord'])){
- $this->Records[] = array("type"=>"aRecord","value"=>"");
- }
-
- /* Fill in values */
- foreach($this->attributes as $name){
- $smarty->assign($name,$this->$name);
- }
-
-
- $div = new divSelectBox("MxRecords");
- $div->setHeight(120);
- $recs = $this->mXRecords;
-
- $oneup = " ";
- $onedown = " ";
- $onedel = "
- ";
-
- foreach($recs as $key => $rec){
- $div ->AddEntry(array(
- array("string"=>$rec['value']),
-/* array("string"=>$key,
- "attach"=>"style='width:20px;'"),*/
- array("string"=>str_replace("%s",base64_encode($key),$oneup.$onedown.$onedel),
- "attach"=>"style='width:70px;border-right:0px;'")
- ));
- }
-
- /* Assign records list */
- $smarty->assign("NotNew", false);
- $smarty->assign("Mxrecords", $div->DrawList());
- $smarty->assign("records" , $this->generateRecordsList());
- $smarty->assign("NetworkClass", $this->NetworkClass);
- $smarty->assign("NetworkClasses", array("A"=>"255.0.0.0 (Class A)","B"=>"255.255.0.0 (Class B)","C"=>"255.255.255.0 (Class C)"));
-
- /* Display tempalte */
- $display.= $smarty->fetch(get_template_path('servdnseditzone.tpl', TRUE));
- return($display);
- }
-
- function remove_from_parent()
- {
- }
-
- /* Save data to object */
- function save_object()
- {
- //plugin::save_object();
- foreach($this->attributes as $attr){
- if(isset($_POST[$attr])){
- $this->$attr = $_POST[$attr];
- }
- }
-
- foreach($this->Records as $id => $value){
- if(isset($_POST['RecordTypeSelectedFor_'.$id])){
- $this->Records[$id]['type'] = $_POST['RecordTypeSelectedFor_'.$id];
- }
- if(isset($_POST['RecordValue_'.$id])){
- $this->Records[$id]['value'] = $_POST['RecordValue_'.$id];
- }
- }
-
- if(isset($_POST['NetworkClass'])){
- $this->NetworkClass = $_POST['NetworkClass'];
- }
-
- }
-
-
- /* Check supplied data */
- function check()
- {
- /* Call common method to give check the hook */
- $message= plugin::check();
-
- /* Check if zoneName is already in use */
- $usedZones = $this->getUsedZoneNames();
- if(($this->isNew == true)||($this->zoneName != $this->InitialzoneName)||($this->ReverseZone != $this->InitialReverseZone)){
- /* if((isset($usedZones[$this->zoneName]))&&($this->zoneName != $this->InitialzoneName)){
- $message[] =_("This zoneName is already in use");
- }
- if((in_array($this->ReverseZone,$usedZones))&&($this->ReverseZone != $this->InitialReverseZone)){
- $message[] =_("This reverse zone is already in use");
- }*/
- }
-
- if(empty($this->zoneName)){
- $message[] =sprintf(_("Please choose a valid zone name."));
- }
-
- if(empty($this->ReverseZone)){
- $message[] =sprintf(_("Please choose a valid reverse zone name."));
- }
-
- if($this->zoneName != strtolower($this->zoneName)){
- $message[] = _("Only lowercase strings are allowed as zone name.");
- }
-
- if(!is_numeric($this->sOAserial)){
- $message[] = _("Please specify a numeric value for serial number.");
- }
-
- if(!is_numeric($this->sOArefresh)){
- $message[] = _("Please specify a numeric value for refresh.");
- }
-
- if(!is_numeric($this->sOAttl)){
- $message[] = _("Please specify a numeric value for ttl.");
- }
-
- if(!is_numeric($this->sOAexpire)){
- $message[] = _("Please specify a numeric value for expire.");
- }
-
- if(!is_numeric($this->sOAretry)){
- $message[] = _("Please specify a numeric value for retry.");
- }
-
- foreach($this->Records as $name => $values){
- /* only lower-case is allowed in record entries ... */
- if($values['value'] != strtolower($values['value'])){
- $message[] = sprintf(_("Only lowercase is allowed, please check your '%ss'."),$values['type']);
- }
- }
-
- /* Check class for given Zone Address */
- $addr = preg_replace("/^[^\/]*+\//","",$this->ReverseZone);
-
- /* Check for valid&complete IP address */
- if(!is_ip($addr)){
- $message[] = _("The given network address is not a valid, please specify a valid IP address.");
- }
-
- /* Check if given address matches selected network class */
- switch($this->NetworkClass){
- case 'A': {
- if(!preg_match("/^[0-9]*\.0\.0\.0$/",$addr)){
- $message[] = sprintf(_("The specified network address is not matching with the specified zone class, try it this way x.0.0.0"));
- }
- }
- break;
- case 'B': {
- if(!preg_match("/^[0-9]*\.[0-9]*\.0\.0$/",$addr)){
- $message[] = sprintf(_("The specified network address is not matching with the specified zone class, try it this way x.x.0.0"));
- }
- }
- break;
- case 'C': {
- if(!preg_match("/^[0-9]*\.[0-9]*\.[0-9]*\.0$/",$addr)){
- $message[] = sprintf(_("The specified network address is not matching with the specified zone class, try it this way x.x.x.0"));
- }
- }
- break;
- default : $message[] =sprintf(_("The given network class '%s' is not valid."),$this->NetworkClass);
- }
-
- return ($message);
- }
-
- /* This funtion returns all used Zonenames */
- function getUsedZoneNames()
- {
- $ret = array();
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
- $ldap->search("(&(objectClass=dNSZone)(relativeDomainName=@)(zoneName=*))",array("zoneName","tXTRecord"));
- while($attr = $ldap->fetch()){
- if(preg_match("/in-addr\.arpa/",$attr['zoneName'][0])){
- if(isset($attr['tXTRecord'][0])){
- $zn = preg_replace("/zoneName\=/","",$attr['tXTRecord'][0]);
- $ret[$zn] =FlipIp(preg_replace("/\.in-addr\.arpa/","",$attr['zoneName'][0]));
- }
- }else{
- $ret[$attr['zoneName'][0]]="";
- }
- }
- return($ret);
- }
-
- /* Save to LDAP */
- function save()
- {
- $ret =array();
- foreach($this->attributes as $name){
- $ret[$name] = $this->$name;
- }
-
- /* Create mx records
- */
- foreach($this->mXRecords as $key => $rec){
- $rec['value']= $key." ".$rec['value'];
- $this->Records [] = $rec;
- }
-
-
- $ret['RECORDS'] = $this->Records;
-
- switch($this->NetworkClass){
- case 'C' : $ret['ReverseZone']= preg_replace("/\.[0-9]*$/","",$this->ReverseZone);break;
- case 'B' : $ret['ReverseZone']= preg_replace("/\.[0-9]*\.[0-9]*$/","",$this->ReverseZone);break;
- case 'A' : $ret['ReverseZone']= preg_replace("/\.[0-9]*\.[0-9]*\.[0-9]*$/","",$this->ReverseZone);break;
- default : trigger_error("Invalid network class given '".$this->NetworkClass."'");
- }
-
- $ret['InitialReverseZone']= $this->InitialReverseZone;
- $ret['InitialzoneName'] = $this->InitialzoneName;
-
- $ret['sOAmail'] = preg_replace("/\@/",".",$this->sOAmail);
-
- foreach(array("sOAprimary","zoneName","sOAmail") as $attr){
- if(!preg_match("/\.$/",$ret[$attr])){
- if(!is_ip($ret[$attr])){
- $ret[$attr] = $ret[$attr].".";
- }
- }
- }
-
- $ret['RECORDS'][] = array("type" => "nSRecord","value" => $ret['sOAprimary']) ;
-
- $ret['zoneEditor'] = $this->zoneEditor;
- return($ret);
- }
-
-
- /* This function generate a table row for each used record.
- This table row displays the recordtype in a select box
- and the specified value for the record, and a remove button.
- The last element of the table also got an 'add' button.
- */
- function generateRecordsList($changeStateForRecords="")
- {
- $changeStateForRecords = "";
-
- $str = "";
- return($str);
- }
-
- /* This function generates a select box out of $this->RecordTypes options.
- The Parameter $selected is used to predefine an attribute.
- $name is used to specify a post name
- */
- function generateRecordListBox($selected,$name)
- {
- $str = "";
- foreach($this->RecordTypes as $type => $value){
-
- if(preg_match("/^mXRecord$/i",$value)) continue;
-
- $use = "";
- if($type == $selected){
- $use = " selected ";
- }
- $str.="\n ".strtoupper(preg_replace("/record/i","",$type))." ";
- }
- $str.=" ";
- return($str);
- }
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_servDNSeditZoneEntries.inc b/plugins/admin/systems/class_servDNSeditZoneEntries.inc
deleted file mode 100644
index 8453ae794..000000000
--- a/plugins/admin/systems/class_servDNSeditZoneEntries.inc
+++ /dev/null
@@ -1,498 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* attribute list for save action */
- var $ignore_account = TRUE;
- var $attributes = array();
- var $objectclasses = array("whatever");
-
- var $Devices = array();
-
- var $zoneName = ""; // ZoneName of currently edited Zone
- var $reverseName = ""; // ReverseZone of the currently edited Zone
-
- var $RecordTypes = array(); // Possible record type.
-
- var $disableDialog = false; // Dialog will be disabled, if this zone is new
-
- function servDNSeditZoneEntries (&$config,$dn, &$zoneObject)
- {
- plugin::plugin ($config, $dn);
-
- /* Initialise class
- */
- $this->RecordTypes = getDnsRecordTypes();
- $this->dn = "zoneName=".$zoneObject['InitialzoneName'].",".$dn;
- $this->zoneName = $zoneObject['InitialzoneName'];
- $this->reverseName = $zoneObject['InitialReverseZone'];
-
- /* Remove nSRecord from listed types */
- if(isset($this->RecordTypes['nSRecord'])){
- unset($this->RecordTypes['nSRecord']);
- }
- /* Remove nSRecord from listed types */
- if(isset($this->RecordTypes['pTRRecord'])){
- unset($this->RecordTypes['pTRRecord']);
- }
-
- /* Get ldap connection
- */
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
-
- /* Get zone content
- */
- $ldap->ls("(&(objectClass=dNSZone)(!(relativeDomainName=@)))",$this->dn,array("relativeDomainName"));
-
- while($attrs = $ldap->fetch()){
- $this->Devices[$attrs['relativeDomainName'][0]] = getDNSHostEntries($config,$attrs['relativeDomainName'][0],true);
- $this->Devices[$attrs['relativeDomainName'][0]]['OrigCn'] = $attrs['relativeDomainName'][0];
- }
-
- $ldap->cat($this->dn,array("objectClass"));
-
- $this->disableDialog = true;
- if(count($this->Devices)|| $ldap->count()){
- $this->disableDialog = false;
- }
- }
-
- function execute()
- {
- plugin::execute();
-
- /* Fill templating stuff */
- $smarty= get_smarty();
- $display= "";
-
- $table = "";
- foreach($this->Devices as $key => $dev){
- $table .= $this->generateRecordConfigurationRow($key);
- }
-
- $smarty->assign("disableDialog",$this->disableDialog);
- $smarty->assign("table",$table);;
- $display.= $smarty->fetch(get_template_path('servDNSeditZoneEntries.tpl', TRUE));
- return($display);
- }
-
-
- function save_object()
- {
- /* Check posts for operations ...
- */
- $once = true;
- $ptr_updates = array();
- foreach($_POST as $name => $value){
-
- /* Add a new Record in given object
- */
-
- $tmp = preg_replace("/^.*_(.*)_.*$/","\\1",$name);
- $tmp2 = split("\|",$tmp);
-
- /* Add new host entry
- */
- if((preg_match("/^UserRecord_?/",$name)) && ($once)){
- $once = false;
- $entry = getDNSHostEntries($this->config,"",true);
- $entry['exists'] = true;
- $entry['zoneName'] = strtoupper($this->attrs['cn'][0])."/".$this->zoneName;
- $entry['RECORDS'][] = array("type" => "aRecord" , "value"=>"");
- $this->Devices[_("New entry")] = $entry;
- }
-
- if(count($tmp2) != 2) continue;
-
- $Name = base64_decode($tmp2[0]);
- $RecordID = $tmp2[1];
-
- /* Add new REcord
- */
- if((preg_match("/^AddRecord_/",$name)) && ($once)){
- $once = false;
- $this->Devices[$Name]['RECORDS'][] = $this->Devices[$Name]['RECORDS'][$RecordID];
- }
-
- /* Remove record from given dn
- */
- if((preg_match("/^RemoveRecord_/",$name)) && ($once)){
- $once = false;
- if(isset($this->Devices[$Name]['RECORDS'][$RecordID])){
- unset($this->Devices[$Name]['RECORDS'][$RecordID]);
- }
-
- /* Check if there is at least one visible record. Else remove complete entry */
- $visible = false;
- foreach($this->Devices[$Name]['RECORDS'] as $rec){
- if(in_array($rec['type'],$this->RecordTypes)){
- $visible = true;
- break;
- }
- }
- if(!$visible && isset($this->Devices[$Name]['RECORDS'])){
- $this->Devices[$Name]['RECORDS'] = array();
- }
- }
- }
-
- /* Possible attributes posted
- */
- foreach($_POST as $name => $value){
-
- /* Extract informations out of post name
- */
- $tmp = preg_replace("/^.*_/","\\1",$name);
- $tmp2 = split("\|",$tmp);
-
- if(count($tmp2) != 2) continue;
-
- $Name = base64_decode($tmp2[0]);
- $RecordID = $tmp2[1];
-
- /* Check for value change
- */
- if(preg_match("/ValueSelection_/",$name)){
- if(isset($this->Devices[$Name]['RECORDS'][$RecordID])){
-
- /* Update value */
- $old = $this->Devices[$Name]['RECORDS'][$RecordID]['value'];
- $this->Devices[$Name]['RECORDS'][$RecordID]['value'] = $value;
-
- /* Handle pTRRecord */
- if(!isset($ptr_updates[$Name]) && $this->Devices[$Name]['RECORDS'][$RecordID]['type'] == "aRecord"){
-
- $found = false;
- $ip = $value;
- $match = preg_replace("/^[^\/]*+\//","",$this->reverseName);
- $ip = preg_replace("/^".normalizePreg($match)."/","",$ip);
- $ip = preg_replace("/^\./","",$ip);
-
- foreach($this->Devices[$Name]['RECORDS'] as $key => $dev){
- if($dev['type'] == "pTRRecord"){
- $ptr_updates[$Name] = $Name;
- $this->Devices[$Name]['RECORDS'][$key]['value'] = $ip;
- $found = true;
- break;
- }
- }
- if(!$found){
- $dev = array('type'=> 'pTRRecord', 'value' => $ip);
- $this->Devices[$Name]['RECORDS'][] = $dev;
- }
- }
- }
- }
-
- /* record type changed
- */
- if(preg_match("/^RecordTypeSelection_/",$name)){
- if(isset($this->Devices[$Name]['RECORDS'][$RecordID])){
- $this->Devices[$Name]['RECORDS'][$RecordID]['type'] = $value;
- }
- }
- }
-
- /* check for renamed entries
- */
- foreach($_POST as $name => $value){
-
- /* Extract informations out of post name
- */
- $tmp = preg_replace("/^.*_/","\\1",$name);
- $tmp2 = split("\|",$tmp);
-
- if(count($tmp2) != 2) continue;
-
- $Name = base64_decode($tmp2[0]);
- $RecordID = $tmp2[1];
-
- /* Host renamed
- */
- if(preg_match("/RenameHost_/",$name)){
- if((isset($this->Devices[$Name])) && ($Name != $value)){
-
- if(isset($this->Devices[$value])){
- print_red(sprintf(_("Can't rename '%s' to '%s' there is already an entry with the same name in our zone editing dialog."),$Name,$value));
- }else{
- $this->Devices[$value] = $this->Devices[$Name];
- unset($this->Devices[$Name]);
- }
- }
- }
- }
- }
-
-
- /* check something
- */
- function check()
- {
- /* Call common method to give check the hook */
- $message= plugin::check();
-
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
-
- $names = array();
- foreach($this->Devices as $DevName => $device){
-
- /* Don't need to check empty values ... */
- if(!count($device['RECORDS'])) continue;
-
- /* Checking entry name
- */
- if(!preg_match("/^[a-z0-9_\.-]+$/i", $DevName) || (empty($DevName))){
- $message[] = sprintf(_("Entry name '%s' contains invalid characters."), $DevName);
- }
-
- /* Renaming check for existing devices
- */
- if(isset($device['OrigCn']) && ($DevName != $device['OrigCn'] )){
- $ldap->cd($this->config->current['BASE']);
- $ldap->search("(relativeDomainName=".$DevName.")",array("relativeDomainName"));
- if($ldap->count()){
- $message[] = sprintf(_("Can not rename '%s' to '%s',the destination name already exists."),$device['OrigCn'],$DevName);
- }
- }elseif(!isset($device['OrigCn'])){
- $ldap->cd($this->config->current['BASE']);
- $ldap->search("(relativeDomainName=".$DevName.")",array("relativeDomainName"));
- if($ldap->count()){
- $message[] = sprintf(_("Can not create '%s',the destination name already exists."),$DevName);
- }
- }
-
- /* Check names
- */
- if(!isset($names[$DevName])){
- $names[$DevName] = "";
- }else{
- $message[] = sprintf(_("The name '%s' is used more than once."),$DevName);
- }
-
- /* Names should be written in lowercase
- */
-# if(strtolower($DevName) != $DevName){
-# $message[] = sprintf(_("The host name '%s' should be written in lowercase."), $DevName);
-# }
-
- /* Check records
- */
- $singleEntries = array("cNAMERecord","pTRRecord");
-
- $tmp = array();
- $tmp2 = array();
- foreach($device['RECORDS'] as $Num => $Rec){
-
- /* Check for multiple use of unique record types
- */
- if(in_array($Rec['type'],$singleEntries)){
- if(!isset($tmp[$Rec['type']])){
- $tmp[$Rec['type']] = "";
- }else{
- $message[] = sprintf(_("The record type '%s' is a unique type and can't be defined twice."),$Rec['type']);
- }
- }
-
- /* Check for empty / duplicate entries in record array
- */
- if(empty($Rec['value'])){
- $message[] = sprintf(_("There is an empty '%s' for host '%s'."),$Rec['type'],$DevName);
- }
-
- /* Check for duplicate record entries
- */
- if(!isset($tmp[$Rec['type']][$Rec['value']])){
- $tmp[$Rec['type']][$Rec['value']] = "";
- }else{
- $message[] = sprintf(_("There is a duplicate entry in '%s' for '%s'."),$Rec['type'],$DevName);
- }
- }
- }
- return ($message);
- }
-
- function save()
- {
- if($this->disableDialog) return;
-
- $todo = array();
-
-
-
- /* Create todolist
- */
- foreach($this->Devices as $name => $dev){
- if(isset($dev['OrigCn'])){
- if(count($dev['RECORDS'])){
- $todo[] = getDNSHostEntriesDiff($this->config,$dev['OrigCn'],$dev,$name);
- }else{
- $dev['exists'] = false;
- $todo[] = getDNSHostEntriesDiff($this->config,$dev['OrigCn'],$dev,$name);
- }
- }else{
- if(count($dev['RECORDS'])){
- $todo[] = getDNSHostEntriesDiff($this->config,"",$dev,$name);
- }else{
- $dev['exists'] = false;
- $todo[] = getDNSHostEntriesDiff($this->config,"",$dev,$name);
- }
- }
- }
-
- $tmp = array();
- $tmp['del'] = array();
- $tmp['add'] = array();
- $tmp['move'] = array();
- foreach($todo as $to){
- foreach($to as $type => $entries){
- $tmp[$type] = array_merge($tmp[$type],$entries);
- }
- }
-
- /* Get ldap link
- */
- $ldap = $this->config->get_ldap_link();
- $ldap->cd ($this->config->current['BASE']);
-
- /* move follwoing entries
- */
- foreach($tmp['move'] as $src => $dst){
- $this->recursive_move($src,$dst);
- }
-
- /* Delete dns */
- foreach($tmp['del'] as $dn => $del){
- $ldap->cd($dn);
- $ldap->rmdir_recursive($dn);
- if(is_object($this->parent->parent)){
- $this->parent->parent->handle_post_events("remove",array("dn" => $dn));
- }
- }
-
- /* Add || Update new DNS entries
- */
- foreach($tmp['add'] as $dn => $attrs){
- $ldap->cd($dn);
- $ldap->cat($dn, array('dn'));
- if(count($ldap->fetch())){
- $ldap->cd($dn);
- $ldap->modify ($attrs);
- if(is_object($this->parent->parent)){
- $this->parent->parent->handle_post_events("modify",array("dn" => $dn));
- }
- }else{
- $ldap->cd($dn);
- $ldap->add($attrs);
- if(is_object($this->parent->parent)){
- $this->parent->parent->handle_post_events("create",array("dn" => $dn));
- }
- }
- }
- }
-
-
- /* Create html table out of given entry
- */
- function generateRecordConfigurationRow($objKey){
-
- /* Get some basic informations
- */
- $obj = $this->Devices[$objKey];
- $objectName = $objKey;
-
- /* Abort if emtpy
- */
- if(count($obj['RECORDS']) == 0) return "";
-
- /* Set title
- */
- $str= " ";
-
- $hostNameOnce = true;
-
- /* Walk through all defined records
- */
- $str.= "";
- return($str);
- }
-
-
- /* Create selectbox with all available option types
- */
- function createRecordTypeSelection($id,$refID){
-
- $str = "\n";
- foreach($this->RecordTypes as $type => $atr) {
- if($id == $type){
- $str .="\n".strtoupper(preg_replace("/record/i","",$type))." ";
- }else{
- $str .="\n".strtoupper(preg_replace("/record/i","",$type))." ";
- }
- }
- $str.= "\n ";
- return($str);
- }
-
-
- function remove_from_parent()
- {
- }
-
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_servKolab.inc b/plugins/admin/systems/class_servKolab.inc
deleted file mode 100644
index 7d31ff58d..000000000
--- a/plugins/admin/systems/class_servKolab.inc
+++ /dev/null
@@ -1,415 +0,0 @@
-"Eins ist toll", "zwei"=>"Zwei ist noch besser");
-
- var $postfix_mydomain = "";
- var $cyrus_admins = "";
- var $postfix_mydestination = "";
- var $postfix_mynetworks = "127.0.0.1/8";
- var $postfix_enable_virus_scan = "TRUE";
- var $postfix_relayhost = "";
- var $postfix_mxrelayenabled = true;
- var $postfix_allow_unauthenticated = "FALSE";
- var $cyrus_quotawarn = "80";
- var $kolabFreeBusyFuture = "1";
- var $k = "kolab";
- var $cyrus_imap = "TRUE";
- var $cyrus_pop3 = "FALSE";
- var $cyrus_imaps = "TRUE";
- var $cyrus_pop3s = "TRUE";
- var $cyrus_sieve = "TRUE";
- var $apache_allow_unauthenticated_fb = "TRUE";
- var $proftpd_ftp = "FALSE";
- var $apache_http = "TRUE";
- var $kolabHost = array();
- var $orig_cn = "";
- var $view_logged = FALSE;
-
- var $attributes = array("postfix_mydomain", "postfix_mydestination", "proftpd_ftp", "k",
- "postfix_mynetworks", "postfix_enable_virus_scan", "postfix_relayhost", "apache_http",
- "postfix_allow_unauthenticated", "cyrus_admins", "cyrus_imap","kolabFreeBusyFuture",
- "cyrus_pop3", "cyrus_imaps", "cyrus_pop3s", "cyrus_sieve", "apache_allow_unauthenticated_fb",
- "cyrus_quotawarn");
- var $objectclasses = array("top", "kolab");
-
- /* Serverservice vars */
- var $conflicts = array("goImapServer","goMailServer");
- var $DisplayName = "Kolab mail service";
- var $StatusFlag = "";
-
- function servkolab(&$config, $dn = NULL, $parent= NULL)
- {
- /* Setting the hostname and tell this Plugin that we are the kolab extension*/
- $this->hostname = preg_replace('/^cn=([^,]+),.*$/', '\1', $dn);
- $this->dn = "k=kolab,".$config->current['BASE'];
-
- /* Load variables, if given*/
- plugin::plugin($config, $this->dn);
-
- /* Copy needed attributes */
- foreach($this->attributes as $val) {
- $name = preg_replace('/_/', '-', $val);
- if (isset($this->attrs["$name"][0])) {
- $this->$val = $this->attrs["$name"][0];
- }
- }
-
- /* Toggle relayhost */
- $this->postfix_mxrelayenabled = preg_match('/^\[/', $this->postfix_relayhost);
- $this->postfix_relayhost = preg_replace("/[\[\]]/","",$this->postfix_relayhost);
-
- /* Is this Server a member of the Kolab extension or not ?*/
- if(isset($this->attrs['kolabHost'])) {
- $this->kolabHost= $this->attrs['kolabHost'];
- unset($this->kolabHost['count']);
- }
- $this->is_account = false;
- $this->initially_was_account = false;
- foreach($this->kolabHost as $host){
- if($this->hostname == $host){
- $this->is_account = true;
- $this->initially_was_account = true;
- }
- }
- }
-
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","server/".get_class($this),$this->dn);
- }
-
- /***************
- Variable initialisation
- ***************/
-
- $smarty = get_smarty();
- $display = "";
- $ldap = $this->config->get_ldap_link();
-
-
- /* Assemble free/busy string */
- $edit = sprintf(' ',
- $this->kolabFreeBusyFuture);
- $fbfuture = sprintf(_("Include data from %s days in the past when creating free/busy lists"), $edit);
-
- /* Assemble quota string */
- $edit = sprintf(' ',
- $this->cyrus_quotawarn);
- $quotastr = sprintf(_("Warn users when using more than %s%% of their mail quota"), $edit);
-
- /***************
- Assign informations to smarty
- ***************/
-
- /* Set relayhost and if we have MX lookup enabled*/
- if($this->postfix_mxrelayenabled) {
- $smarty->assign("RelayMxSupportCheck"," checked ");
- } else {
- $smarty->assign("RelayMxSupportCheck","");
- }
-
- /* Set acls */
- $tmp = $this->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $translation){
- $smarty->assign($name."ACL",$this->getacl($name));
- }
-
- /* Initialize all attributes, that were submitted */
- foreach($this->attributes as $val)
- {
- /* Tell smarty which variables we are useing */
- $smarty->assign($val, $this->$val);
- if (($this->$val != "FALSE") && !empty($this->$val)){
- $smarty->assign($val."Check", "checked");
- } else {
- $smarty->assign($val."Check", "");
- }
- }
-
- $smarty->assign("fbfuture", $fbfuture);
- $smarty->assign("quotastr", $quotastr);
-
- /* Load Template */
- $display.=$smarty->fetch(get_template_path('servkolab.tpl', TRUE));
- return ($display);
- }
-
- function remove_from_parent()
- {
-
- /* Remove status flag, it is not a memeber of
- this->attributes, so ensure that it is deleted too */
- if(!empty($this->StatusFlag)){
- $this->attrs[$this->StatusFlag] = array();
- }
-
-
- /* Only walk through following code, if this host
- was a member of the kolab hosts, else skip this */
- if(!$this->initially_was_account){
- return;
- }
-
- /* !!! Don't use "cn" in this function
- hostname -> the initial name of the host
- cn -> is the new name of the host, in case that it was renamed.
- */
-
- $ldap = $this->config->get_ldap_link();
- $this->dn = "k=kolab,".$this->config->current['BASE'];
-
- /* We can't simply remove the whole entry, it is possible that there are
- some other hosts assigned to this object.
- So, first of all check if we are the last host entry within the host
- : Remove k=kolab entry
- if we aren't alone, only remove host name from hosts entry and save */
- /* Are we alone? Remove complete entry... */
-
- /* Check if we are definitly in kolabHosts */
- if(!in_array_ics($this->hostname,$this->kolabHost)) {
- return;
- }
-
- /* Integration check, not translated because they can't pop up at all, only for debug */
- if(count($this->kolabHost) == 0){
- print_red("Server - Kolab tab : This is not possible, we can't remove an account which doesn't exists.");
- return;
- }
- if(!isset($this->hostname) || (empty($this->hostname))){
- print_red("The required attribute hostname seams to empty.");
- }
-
- /* Our hostname is in kolabHosts and there is a only one entry
- = we are the last host entry, delete k=kolab entry */
- if (count($this->kolabHost) == 1){
-
- /* Remove complete entry */
- $ldap->rmdir ($this->dn);
- show_ldap_error($ldap->get_error(), sprintf(_("Removing host entry from system server/kolab with dn '%s' failed."),$this->dn));
- } else {
-
- /* Only modify kolabHost */
- $hosts= array();
- foreach ($this->kolabHost as $host){
- if($host != $this->hostname){
- $hosts[]= $host;
- }
- }
- $attrs= array('kolabHost' => $hosts);
- $ldap->cd($this->dn);
- $this->cleanup();
- $ldap->modify ($attrs);
- show_ldap_error($ldap->get_error(), sprintf(_("Removing host entry from system server/kolab with dn '%s' failed."),$this->dn));
- }
-
- new log("remove","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-
- /* Optionally execute a command after we're done */
- $this->handle_post_events("remove");
- }
-
-
- function save_object()
- {
- if (isset($_POST['kolabtab'])){
- plugin::save_object();
-
-
- foreach($this->attributes as $attr){
- if(($this->acl_is_writeable(preg_replace("/_/","",$attr))) && (isset($_POST[$attr]))){
- $this->$attr = $_POST[$attr];
- }
- }
-
- /* Save checkboxes */
- foreach (array( "postfix_enable_virus_scan", "postfix_allow_unauthenticated",
- "cyrus_imap", "cyrus_pop3", "cyrus_imaps",
- "cyrus_pop3s", "cyrus_sieve", "apache_allow_unauthenticated_fb",
- "proftpd_ftp", "apache_http") as $cb){
-
- if($this->acl_is_writeable(preg_replace("/_/","",$cb))){
- if (isset($_POST[$cb])){
- $this->$cb= "TRUE";
- } else {
- $this->$cb= "FALSE";
- }
- }
- }
-
- /* Toggell relay check */
- if($this->acl_is_writeable("postfixmxrelayenabled")){
- $this->postfix_mxrelayenabled= isset($_POST['RelayMxSupport']);
- }
- }
-
- }
-
-
- function check()
- {
- /* Call common method to give check the hook */
- $message= plugin::check();
-
- if(($this->kolabFreeBusyFuture=="")) {
- $message[] = _("Future days in Free/Busy settings must be set.");
- }elseif(!is_uid($this->kolabFreeBusyFuture) || $this->kolabFreeBusyFuture < 0){
- $message[] = _("Future days in Free/Busy settings must be a positive value.");
- }
-
- if(!is_int((int)($this->cyrus_quotawarn))) {
- $message[] = _("The given Quota settings value must be a number.");
- }elseif(!(($this->cyrus_quotawarn<=100)&&($this->cyrus_quotawarn>=0))){
- $message[] = _("Please choose a value between 1 and 100 for Quota settings.");
- }elseif(strcasecmp($this->cyrus_quotawarn,(int)$this->cyrus_quotawarn)){
- $message[] = _("Future days must be a value.");
- }
-
- if(empty($this->postfix_mynetworks)) {
- $message[] = _("No SMTP privileged networks set.");
- }
-
- /*if(empty($this->postfix_relayhost)) {
- $message[] = _("No SMTP smarthost/relayhost set.");
- }
- */
-
- return ($message);
- }
-
-
- /* Save to LDAP */
- function save()
- {
- /* Set ldap connection */
- $ldap = $this->config->get_ldap_link();
-
- /* Open current dn*/
- $this->dn = "k=kolab,".$this->config->current['BASE'];
-
- /* Adapt relayhost */
- $this->postfix_relayhost= preg_replace('/[\[\]]/', '', $this->postfix_relayhost);
- if ($this->postfix_mxrelayenabled && $this->postfix_relayhost != ""){
- $this->postfix_relayhost= "[".$this->postfix_relayhost."]";
- }
-
- /* Check if this server was renamed, in this case we have to remove old cn first*/
- if($this->hostname != $this->cn){
- $tmp = array();
- if(in_array_ics($this->hostname,$this->kolabHost)){
- foreach($this->kolabHost as $host){
- if($host != $this->hostname){
- $tmp[] = $host;
- }
- }
- $this->kolabHost = $tmp;
- }
- }
-
- /* Add ourselves to the list of kolabHost's if needed */
- if (!in_array_ics($this->cn,$this->kolabHost)){
- $this->kolabHost[]= $this->cn;
- }
-
- /* Call parents save to prepare $this->attrs */
- plugin::save();
-
- /* Save or modify? */
- $ldap->cat($this->dn, array('dn'));
- if (!$ldap->fetch()){
- $mode= "add";
- } else {
- $mode= "modify";
- }
-
- /* Do attribute conversion */
- foreach ($this->attrs as $key => $value){
- if (preg_match('/_/', $key)){
- $old_key= $key;
- $key= preg_replace('/_/', '-', $key);
- $this->attrs[$key]= $value;
- unset($this->attrs[$old_key]);
- }
- }
- /* Add kolab hosts */
- $this->attrs['kolabHost']= $this->kolabHost;
-
- /* Perform LDAP action */
- $ldap->cd($this->dn);
- $this->cleanup();;
- $ldap->$mode($this->attrs);
-
- if($mode == "add"){
- new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- }else{
- new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- }
-
- show_ldap_error($ldap->get_error(), sprintf(_("Saving system server/kolab with dn '%s' failed."),$this->dn));
-
- /* Optionally execute a command after we're done */
- if ($this->initially_was_account == $this->is_account) {
- if ($this->is_modified) {
- $this->handle_post_events("modify");
- }
- } else {
- $this->handle_post_events("add");
- }
- }
-
-
- function getListEntry()
- {
- $fields = goService::getListEntry();
- $fields['Message'] = _("Kolab mail service");
- $fields['AllowEdit'] = true;
- return($fields);
- }
-
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Kolab"),
- "plDescription" => _("Kolab mail service")." ("._("Services").")",
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 85,
- "plSection" => array("administration"),
- "plCategory" => array("server"),
-
- "plProvidedAcls"=> array(
- "postfixmydomain" => _("Postfix mydomain") ,
- "postfixmydestination" => _("My destination") ,
- "cyrusadmins" => _("Cyrus admins") ,
- "proftpdftp" => _("FTP FreeBusy service") ,
- "postfixmynetworks" => _("SMTP privileged networks") ,
- "postfixenablevirusscan" => _("Enable virus scan") ,
- "postfixrelayhost" => _("Relayhost") ,
- "postfixmxrelayenabled" => _("Enable MX lookup for relayhost"),
- "apachehttp" => _("HTTP FreeBusy service") ,
- "apacheallowunauthenticatedfb" => _("Allow unauthenticated free busy"),
- "postfixallowunauthenticated" => _("Accept Internet Mail") ,
- "cyrusimap" => _("IMAP service") ,
- "kolabFreeBusyFuture" => _("kolabFreeBusyFuture") ,
- "cyruspop3" => _("POP3 service") ,
- "cyrusimaps" => _("IMAP/SSL service") ,
- "cyruspop3s" => _("POP3/SSL service") ,
- "cyrussieve" => _("Sieve service") ,
- "cyrusquotawarn" => _("Quota settings"))
- ));
- }
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_servNfs.inc b/plugins/admin/systems/class_servNfs.inc
deleted file mode 100644
index 1386de1fc..000000000
--- a/plugins/admin/systems/class_servNfs.inc
+++ /dev/null
@@ -1,267 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* attribute list for save action */
- var $ignore_account = TRUE;
- var $attributes = array("description","type","charset","path","option", "volume");
- var $objectclasses = array("whatever");
- var $is_account = true;
-
- var $name =""; // Name of
- var $description =""; // description
- var $type =""; // Type FS/Samba/NCP
- var $charset =""; // charset
- var $host =""; // hostname
- var $types =array(); // Array Types NFS/Samba/NCP/netatalk
- var $charsets =array(); // Array with charsets
- var $path =""; // Path
- var $volume =""; // Volume
- var $option =""; // Options
- var $is_edit =false;
- var $create_mount_init = false; //mount entry set for this entry (while editing)?
- var $create_mount = false; //save mount entry
-
- var $parent = NULL;
- var $view_logged = FALSE;
-
- function servnfs (&$config, $parent,$entry= false,$mount =false)
- {
- $this->parent = $parent;
- $dn = $parent->dn;
- plugin::plugin ($config, $dn);
-
- $this->types = array("CIFS" => "CIFS", "NFS"=>"NFS","samba"=>"samba","netatalk"=>"netatalk","NCP"=>"NCP");
- if($dn){
- $this->host = substr($dn, 3, strpos($dn, ',')-3);
- }
-
- $this->charsets = array();
-
- if(!file_exists(CONFIG_DIR."/encodings")){
- print_red(sprintf(_("The file '%s/encodings' does not exist, can't get supported charsets."),CONFIG_DIR));
- }else{
- if(!is_readable(CONFIG_DIR."/encodings")){
- print_red(sprintf(_("Can't read '%s/encodings', please check permissions."),CONFIG_DIR));
- }else{
- $fp = fopen(CONFIG_DIR."/encodings","r");
- $i = 100;
- while(!feof($fp)&&$i){
- $i -- ;
- $str = trim(fgets($fp,256));
-
- /* Skip comments */
- if(!preg_match("/^#/",$str)){
- $arr = split("\=",$str);
- if(count($arr)==2){
- $this->charsets[$arr[0]]=$arr[1];
- }
- }
- }
- }
- }
-
- if($entry){
- list($this->name, $this->description, $this->type, $this->charset,
- $this->path, $this->option, $this->volume)= split("\|",$entry."|");
- $this->is_edit = true;
-
- }else{
- $this->attributes[] = "name";
- }
-
-
- $this->create_mount_init = $mount;
- }
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","server/".get_class($this),$this->dn);
- }
-
- /* Fill templating stuff */
- $smarty= get_smarty();
-
- $smarty->assign("charsets" ,$this->charsets);
- $smarty->assign("types" ,$this->types);
-
- /* attrs to smarty*/
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
- }
-
- $tmp = $this->parent->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $translation){
- $smarty->assign($name."ACL",$this->parent->getacl($name));
- }
-
- $smarty->assign("name",$this->name);
- if($this->is_edit){
- $smarty->assign("nameACL", preg_replace("/w/","",$this->parent->getacl("name")));
- }
- $smarty->assign("allow_mounts", $this->parent->allow_mounts);
- $smarty->assign("mount_checked", "");
-
- $smarty->assign("appleMountsACL", $this->getacl("appleMounts"));
-
- if (($this->type == "netatalk") || ($this->type == "NFS")) {
- if ($this->create_mount_init) {
- $smarty->assign("mount_checked", "checked");
- } else {
- $tmp = split(",", $this->dn);
- $clip = $tmp[0] . ",ou=servers,ou=systems,";
- $mountsdn = "cn=mounts," . substr($this->dn, strlen($clip));
- switch ($this->type) {
- case "netatalk" : {
- $mountdn = "cn=".$this->host.":/".$this->name.",".$mountsdn;
- break;
- }
- case "NFS" : {
- $mountdn = "cn=".$this->host.":".$this->path.",".$mountsdn;
- break;
- }
- default : {
- continue;
- }
- }
- $ldap = $this->config->get_ldap_link();
- $ldap->cat($mountdn, array('dn'));
- $attrs = $ldap->fetch();
- if (count($attrs) > 0) {
- $smarty->assign("mount_checked", "checked");
- }
- }
- }
-
- $display= $smarty->fetch(get_template_path('servnfs.tpl', TRUE));
- return($display);
- }
-
- function remove_from_parent()
- {
- /* This cannot be removed... */
- }
-
-
- /* Save data to object */
- function save_object()
- {
- if(isset($_POST['servnfs_posted'])){
-
- foreach($this->attributes as $name){
- if($this->parent->acl_is_writeable($name) && isset($_POST[$name])){
- $this->$name = $_POST[$name];
- }
- }
-
- if ((isset($_POST['netatalk_mount'])) && (($this->type == "netatalk") || ($this->type == "NFS"))) {
- $this->create_mount = true;
- } else {
- $this->create_mount = false;
- }
- }
- }
-
-
- /* Check supplied data */
- function check()
- {
- /* Call common method to give check the hook */
- $message= plugin::check();
-
- // fixme : a check for the path ? ?
- if(empty($this->path)){
- $message[]=_("Please specify a valid path for your setup.");
- }
-
- // only 0-9a-z
- if(!$this->is_edit){
- if(!preg_match("/^[a-z0-9\._äüö]*$/ui",$this->name)){
- $message[]=_("Please specify a valid name for your share.");
- }
- if(empty($this->name)){
- $message[]=_("Please specify a name for your share.");
- }
- }
-
- if(!empty($this->description) && preg_match("/^[^a-z0-9\._äüö\+ -]*$/ui",$this->description)){
- $message[]=_("Description contains invalid characters.");
- }
-
- if(!empty($this->volume) && preg_match("/^[^a-z0-9\._äüö\+ -]*$/ui",$this->volume)){
- $message[]=_("Volume contains invalid characters.");
- }
-
- if(preg_match("/\|/",$this->path)){
- $message[]=_("Path contains invalid characters.");
- }
-
- if(!empty($this->option) && preg_match("/^[^a-z0-9\._äüö,=\+ -]*$/ui",$this->option)){
- $message[]=_("Option contains invalid characters.");
- }
-
- /* remove a / at the end of the path, we neither need it there nor
- * do we want to check for it later.
- */
- if(substr($this->path, -1, 1) == '/') {
- $this->path=substr($this->path, 0, -1);
- }
-
- $ldap= $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
- $ldap->search("(objectClass=goShareServer)", array("goExportEntry"));
- while($test = $ldap->fetch()){
- if($test['dn']==$this->dn)
- continue;
- if(isset($test['goExportEntry'])){
- foreach($test['goExportEntry'] as $entry){
- $tmp = split("\|",$entry);
- if($tmp[0] == $this->name){
- $message[]="Name already in use";
- }
- }
- }
- }
- return ($message);
- }
-
-
- /* Save to LDAP */
- function save()
- {
- /* Everything seems perfect, lets
- generate an new export Entry
- */
-
- $s_return = "";
-
- $s_return.= $this->name."|";
- $s_return.= $this->description."|";
- $s_return.= $this->type."|";
- $s_return.= $this->charset."|";
- $s_return.= $this->path."|";
- $s_return.= $this->option."|";
- $s_return.= $this->volume;
-
- return(array($this->name=>$s_return));
- }
-
- function should_create_mount() {
- return $this->create_mount;
- }
-
-
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_servRepository.inc b/plugins/admin/systems/class_servRepository.inc
deleted file mode 100644
index 10321c024..000000000
--- a/plugins/admin/systems/class_servRepository.inc
+++ /dev/null
@@ -1,366 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* attribute list for save action */
- // var $ignore_account = TRUE;
- var $attributes = array("FAIrepository");
- var $objectclasses = array("FAIrepositoryServer");
-
- /* Repositories */
- var $repositories = array();
- var $FAIrepository = array();
- var $conflicts = array("FAIrepositoryServer");
- var $DisplayName = "";
- var $StatusFlag = "";
-
- var $view_logged = FALSE;
- var $fai_activated = FALSE;
-
- var $divlist = NULL;
-
- function servrepository (&$config, $dn= NULL, $parent= NULL)
- {
- plugin::plugin ($config, $dn, $parent);
-
- $this->DisplayName = _("Repository service");
-
- /* Skip this if fai is deactivated */
- $tmp= $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
- if(!empty($tmp)){
- $this->fai_activated = TRUE;
- }else{
- return;
- }
-
- $this->repositories = array();
- if(isset($this->attrs['FAIrepository'])){
- for($i = 0; $i < $this->attrs['FAIrepository']['count']; $i++){
- $tmp = split("\|",$this->attrs['FAIrepository'][$i]);
- $tmp2 = array();
- $tmp3 = array();
-
- if(isset($tmp[1])){
- $tmp2['ParentServer'] = $tmp[1];
- if(empty($tmp[1])){
- $tmp2['ParentServer'] = "none";
- }
- }else{
- $tmp2['ParentServer'] = "none";
- }
-
- if(isset($tmp[0])){
- $tmp2['Url'] = $tmp[0];
- }else{
- $tmp2['Url'] = "";
- }
-
- if(isset($tmp[2])){
- $tmp2['Release'] = $tmp[2];
- }else{
- $tmp2['Release'] = "";
- }
-
- if(isset($tmp[3])){
- $tmp3 = split(",",$tmp[3]);
- foreach($tmp3 as $sec){
- $tmp2['Sections'][$sec]=$sec;
- }
- }else{
- $tmp['Section']=array();
- }
-
- $this->repositories[$tmp[2]]=$tmp2;
- }
- }
-
-
- /* Create divlist */
- $this->divlist = new divListRepository($this->config,$this);
- }
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","server/".get_class($this),$this->dn);
- }
-
- if(!$this->fai_activated){
- $str = ""._("You can't use this plugin until FAI is activated.")." ";
- return $str;
- }
-
- /* Fill templating stuff */
- $smarty= get_smarty();
- $smarty->assign("is_createable",$this->acl_is_createable());
- $display= "";
-
- /* Show tab dialog headers */
- /*
- ADD / EDIT Repository
- Dialog Handling
- */
- $once = false;
- if(isset($_POST['servRepository'])){
- foreach($_POST as $name => $value){
-
- if(preg_match("/AddRepository/",$name) && $this->acl_is_createable()){
- $once = true;
- $this->dialog = new servRepositorySetup($this->config,$this->dn);
- $this->dialog->parent = $this;
- }
-
- if((preg_match("/^delete_/",$name)) && (!$once) && $this->acl_is_removeable()){
- $once = true;
- $value = preg_replace("/delete_/","",$name);
- $value = base64_decode(preg_replace("/_.*$/","",$value));
-
- $url = $this->repositories[$value]['Url'];
- $release = $this->repositories[$value]['Release'];
-
- $ldap = $this->config->get_ldap_link();
- $ldap->cd ($this->config->current['BASE']);
-
- $ldap->search("(&(objectClass=gotoWorkstation)(objectClass=FAIobject)(FAIdebianMirror=".$url."))",array("cn","FAIclass"));
-
- $found = false;
- $found_in = " ";
- while($attrs = $ldap->fetch()){
- foreach($attrs['FAIclass'] as $class){
- if(preg_match("/".str_replace("/","\/",$release)."$/i",$class)){
- $found = true;
- $found_in .= $attrs['cn'][0]." ";
- }
- }
- }
-
- if($found){
- print_red(sprintf(_("You can't delete this release, it is still used by these workstations [%s]. Please solve this dependencies first, to keep data base consistency."),$found_in));
- }else{
- if(isset($this->repositories[$value])){
- unset($this->repositories[$value]);
- }
- }
- }
-
- if((preg_match("/^edit_/",$name))&&(!$once)){
- $value = preg_replace("/edit_/","",$name);
- $value = base64_decode(preg_replace("/_.$/","",$value));
-
- if(isset($this->repositories[$value])){
-
- $ldap = $this->config->get_ldap_link();
- $ldap->cd ($this->config->current['BASE']);
-
- $url = $this->repositories[$value]['Url'];
- $release = $this->repositories[$value]['Release'];
-
- $ldap->search("(&(objectClass=gotoWorkstation)(objectClass=FAIobject)(FAIdebianMirror=".$url."))",array("cn","FAIclass"));
-
- $found = false;
- $found_in = " ";
- while($attrs = $ldap->fetch()){
- foreach($attrs['FAIclass'] as $class){
- if(preg_match("/".str_replace("/","\/",$release)."$/i",$class)){
- $found = true;
- $found_in .= $attrs['cn'][0]." ";
- }
- }
- }
-
- if($found){
- print_red(sprintf(_("Be careful editing this release, it is still used by these workstations [%s]."),$found_in));
- }
-
- if(isset($this->repositories[$value])){
- $once = true;
- $obj = $this->repositories[$value];
-
- /* to be able to detect if this was renamed */
- $obj['initialy_was'] = $obj['Release'];
- $this->dialog = new servRepositorySetup($this->config,$this->dn,$obj);
- $this->dialog->parent = $this;
- }
- }
- }
- }
- }
- if((isset($_GET['act']))&&($_GET['act']=="open_repository")&&(isset($_GET['id']))){
- $obj = $this->repositories[base64_decode($_GET['id'])];
- $obj['initialy_was'] = $obj['Release'];
- $this->dialog = new servRepositorySetup($this->config,$this->dn,$obj);
- $this->dialog->parent = $this;
- }
-
- if(isset($_POST['repository_setup_save']) && is_object($this->dialog)){
- $this->dialog->save_object();
- if(($this->dialog->is_new_name())&&(isset($this->repositories[$this->dialog->GetName()]))){
- print_red(_("This name is already in use."));
- }else
-
- if(count($this->dialog->check())!=0){
- foreach($this->dialog->check() as $msg){
- print_red($msg);
- }
- }else{
- $obj = $this->dialog->save();
- if($this->dialog->is_new_name()){
- $oldname = $this->dialog->initialy_was;
- $this->repositories[$obj['Release']]=$obj;
- unset($this->repositories[$oldname]);
- }else{
- $this->repositories[$obj['Release']]=$obj;
- }
- $this->dialog = FALSE;
- $this->is_dialog= false;
- }
- }
-
- if(isset($_POST['repository_setup_cancel'])){
- $this->dialog=FALSE;
- $this->is_dialog = false;
- }
-
- if(is_object($this->dialog)){
- $this->dialog->save_object();
- $this->is_dialog = true;
- return($this->dialog->execute());
- }
-
- /*
- Repository setup dialog handling /END
- */
-
-
- $link = "%s ";
- $edit = " ";
-
- /* Hide delete icon, if delete is not allowed */
- if($this->acl_is_removeable()){
- $delete = " ";
- }else{
- $delete = " ";
- }
-
- $this->divlist->execute();
- $this->divlist->setEntries($this->repositories);
- $smarty->assign("Repositories",$this->divlist->Draw());
- $display.= $smarty->fetch(get_template_path('servRepository.tpl', TRUE));
- return($display);
- }
-
-
- /* Save data to object */
- function save_object()
- {
- plugin::save_object();
- if(is_object($this->divlist)){
- $this->divlist->save_object();
- }
- }
-
-
- /* Check supplied data */
- function check()
- {
- /* Call common method to give check the hook */
- $message= plugin::check();
- return ($message);
- }
-
-
- /* Save to LDAP */
- function save()
- {
- if(!$this->fai_activated) return;
-
- plugin::save();
-
- $arr = array();
- foreach($this->repositories as $servername => $conf){
- $str = "";
- foreach($conf['Sections'] as $sec){
- $str.=$sec.",";
- }
- $str=preg_replace("/,$/","",$str);
-
- if($conf['ParentServer']=="none"){
- $conf['ParentServer'] ="";
- }
-
- $arr[]=$conf['Url']."|".$conf['ParentServer']."|".$conf['Release']."|".$str;
- }
- $this->attrs['FAIrepository'] = $arr;
-
- $ldap= $this->config->get_ldap_link();
- $ldap->cd ($this->config->current['BASE']);
-
- $ldap->cat($this->dn, array('dn'));
-
- if($ldap->count()){
- $ldap->cd($this->dn);
- $this->cleanup();
- $ldap->modify ($this->attrs);
-
- $this->handle_post_events("modify");
- }else{
- $ldap->cd ($this->config->current['BASE']);
- $ldap->create_missing_trees($this->dn);
- $ldap->cd($this->dn);
- $ldap->add($this->attrs);
- $this->handle_post_events("add");
- }
-
- if($this->initially_was_account){
- new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- }else{
- new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- }
- }
-
-
- function getListEntry()
- {
- $fields = goService::getListEntry();
- $fields['Message'] = _("Repository service");
- $fields['AllowEdit'] = true;
- $fields['AllowStart'] = $fields['AllowStop'] = $fields['AllowRestart'] = false;
- return($fields);
- }
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Repository"),
- "plDescription" => _("Repository service")." ("._("Services").")",
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 84,
- "plSection" => array("administration"),
- "plCategory" => array("server"),
-
- "plProvidedAcls"=> array(
- "cn" => _("Name"),
- "start" => _("Start"),
- "stop" => _("Stop"),
- "restart" => _("Restart"),
- "Release" => _("Releases"),
- "Section" => _("Sections"),
- "ParentServer" => _("Parent server"),
- "Url" => _("Url"))
- ));
- }
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_servRepositorySetup.inc b/plugins/admin/systems/class_servRepositorySetup.inc
deleted file mode 100644
index 40f37b062..000000000
--- a/plugins/admin/systems/class_servRepositorySetup.inc
+++ /dev/null
@@ -1,225 +0,0 @@
- "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* attribute list for save action */
- var $ignore_account = TRUE;
- var $attributes = array("Release","ParentServer","Url","cn");
- var $objectclasses = array("whatever");
-
- /* Attributes */
- var $Release = "";
- var $ParentServer = "";
- var $Url = "";
- var $Sections = array();
- var $ParentServers = "";
- var $initialy_was = false;
- var $cn = "";
- var $parent = "";
-
- function servRepositorySetup (&$config, $dn= NULL,$data = false)
- {
- plugin::plugin ($config, $dn);
- if($data != false){
- foreach(array("Sections","Release","Url","ParentServer","initialy_was") as $atr){
- if(isset($data[$atr])){
- $this->$atr = $data[$atr];
- }
- }
- }
- }
-
- function GetName()
- {
- return($this->Release);
- }
-
- function is_new_name()
- {
- if(!$this->initialy_was){
- return(true);
- }else{
- if($this->Release != $this->initialy_was){
- return(true);
- }
- }
- return(false);
- }
-
-
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- /* Fill templating stuff */
- $smarty= get_smarty();
-
- if((isset($_POST['AddSection']))&&(isset($_POST['SectionName']))&&(!empty($_POST['SectionName']))){
-
- /* Replace multiple spaces with a single, and cut of white spaces (trim)*/
- $val = preg_replace("/\ \ * /" , " ", trim($_POST['SectionName']));
-
- /* check if there are more than one entry given ( "section1 section2 )*/
- if(preg_match("/ /",$val)){
-
- /* Generate list of new section names */
- $vals = split(" ",$val);
-
- /* Add new entries */
- foreach($vals as $entry){
- $entry = trim($entry);
- $this->Sections[$entry]=$entry;
- }
- }else{
- $this->Sections[$val]=$val;
- }
- }
-
- foreach($_POST as $name => $value){
- if(preg_match("/^delete_/",$name)){
-
- $val = preg_replace("/^delete_/","",$name);
- $val = base64_decode(preg_replace("/_.*$/","",$val));
-
- if(isset($this->Sections[$val])){
- unset($this->Sections[$val]);
- }
- }
- }
-
- $divlist = new divSelectBox("servRepositorySetup");
- $divlist->setHeight("220");
-
- $dellink = " ";
-
- foreach($this->Sections as $sec){
- $divlist->AddEntry(array(
- array("string"=>$sec),
- array("string"=>sprintf($dellink,base64_encode($sec),$sec),"attach"=>"style='border-right:0px;width:20px;'")
- ));
- }
-
- $smarty->assign("Sections",$divlist->DrawList());
-
- /* Get && assign acls */
- $tmp = $this->parent->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $translated){
- $smarty->assign($name."ACL",$this->parent->getacl($name));
- }
-
- /* Assign values */
- foreach($this->attributes as $attr){
- $smarty->assign($attr ,$this->$attr);
- }
-
- $tmp = $this->getParentServers();
- $smarty->assign("ParentServers" ,$tmp);
- $smarty->assign("ParentServerKeys",array_flip($tmp));
-
- return($smarty->fetch(get_template_path('servRepositorySetup.tpl', TRUE)));
- }
-
- /* Save data to object */
- function save_object()
- {
- if(isset($_POST['servRepositorySetup_Posted'])) {
-
- foreach($this->attributes as $attr){
- if(($this->parent->acl_is_writeable($attr)) && (isset($_POST[$attr]))){
- $this->$attr = $_POST[$attr];
- }
- }
- }
- }
-
-
- /* Check supplied data */
- function check()
- {
- /* Call common method to give check the hook */
- $message= plugin::check();
-
- if(empty($this->Release)){
- $message[]=_("Please enter a value for 'release'.");
- }
-
- if(empty($this->Url)){
- $message[] = _("Please specify a valid value for 'url'.");
- }
-
- return ($message);
- }
-
-
- /* Save to LDAP */
- function save()
- {
- $tmp = array();
- $tmp['ParentServer'] = $this->ParentServer;
- $tmp['Url'] = $this->Url;
- $tmp['Release'] = $this->Release;
- $tmp['Sections'] = $this->Sections;
- return($tmp);
- }
-
- function getParentServers()
- {
- $ret = array();
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
- $ldap->search("(objectClass=FAIrepositoryServer)",array("*"));
- while($attr = $ldap->fetch()){
- if($attr['cn'][0] == $this->cn) continue;
- $ret[$attr['cn'][0]]= $attr['cn'][0];
- }
-
- $ret = array_merge($ret,$this->GetHookElements());
-
- $ret['none']= " ";
- asort($ret);
- return($ret);
- }
-
- /* this funtions calls a defined hook
- and parses all additional serverdata
- */
- function GetHookElements()
- {
- $ret = array();
- $cmd = $this->config->search("servrepository", "REPOSITORY_HOOK",array('tabs'));
- if(!empty($cmd)){
- $res = shell_exec($cmd);
- $res2 = trim($res);
- if(!$res){
- print_red(sprintf(_("Can't execute specified REPOSITORY_HOOK '%s'. Please check your gosa.conf."),$cmd));
- }elseif(empty($res2)){
- print_red(sprintf(_("The specified REPOSITORY_HOOK '%s', specified in your gosa.conf, returns an empty string."),$cmd));
- }else{
- $tmp = split("\n",$res);
- foreach($tmp as $hook){
- /* skip empty */
- if(empty($hook)) continue;
-
- if(preg_match("/;/",$hook)){
- $hookinfo = split(";",$hook);
- $ret[$hookinfo[0]] = $hookinfo[0];
- }else{
- $ret[$hook] = $hook;
- }
- }
- }
- }
- return($ret);
- }
-
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/class_termDNS.inc b/plugins/admin/systems/class_termDNS.inc
deleted file mode 100644
index 025933291..000000000
--- a/plugins/admin/systems/class_termDNS.inc
+++ /dev/null
@@ -1,1012 +0,0 @@
-parent = $parent;
- $this->objectclasses = $objectClasses;
- $this->IPisMust = $IPisMust;
-
- plugin::plugin ($config, $parent->dn);
-
- if(isset($this->attrs['cn'][0])){
- $this->OrigCn = preg_replace("/\\\$\$/","",$this->attrs['cn'][0]);
- $this->cn = preg_replace("/\\\$\$/","",$this->attrs['cn'][0]);
- }
-
-
- /************
- * DHCP
- ************/
-
- /* Hide all dhcp specific code, if dhcp plugin is not present in config */
- $dhcpEnabled = FALSE;
- if($this->config->search("servdhcp","class",array("tabs"))){
- $this->dhcpEnabled = TRUE;
- }
- if($this->dhcpEnabled){
- $this->dhcpParentNodes = $this->get_dhcp_parent_nodes();
- $this->dhcpParentNode = $this->get_dhcp_parent_node();
- if($this->dhcpParentNode){
- $this->dhcp_is_Account = TRUE;
- $this->initial_dhcp_is_Account = TRUE;
- $this->dhcpHostEntry = $this->get_dhcp_host_entry();
- }
- $this->initial_dhcpHostEntry = $this->dhcpHostEntry;
- $this->initial_dhcpParentNode= $this->dhcpParentNode;
- }
-
-
- /************
- * Autonetwork hook
- ************/
-
- /* Do we have autonet support? */
- if (isset($this->config->data['MAIN']['AUTO_NETWORK_HOOK'])){
- $this->autonet= true;
- }
-
-
- /************
- * DNS
- ************/
-
- /* Hide all dns specific code, if dns is not available
- */
- $DNSenabled = false;
- foreach($this->config->data['TABS']['SERVERSERVICE'] as $tab){
- if(preg_match("/^servdns$/",$tab['CLASS'])){
- $this->DNSenabled = true;
- }
- }
- if(!$this->DNSenabled){
- $this->DNS_is_account = false;
- return;
- }
-
- if($this->DNSenabled){
-
- /* Get Zones
- */
- $this->Zones = getAvailableZones($config);
-
- /* Get Entry
- */
- $this->dnsEntry = getDNSHostEntries($config,$this->OrigCn);
-
- /* Remove A record which equals $this->ipHostNumber
- */
- $ptr = $this->get_pTRRecord();
- foreach($this->dnsEntry['RECORDS'] as $key => $rec){
- if(($rec['type'] == "aRecord") && ($rec['value'] == $this->ipHostNumber)){
- unset($this->dnsEntry['RECORDS'][$key]);
- }
- if(($rec['type'] == "pTRRecord") && ($rec['value'] == $ptr)){
- unset($this->dnsEntry['RECORDS'][$key]);
- }
- }
-
- /* Get Record types
- */
- $this->RecordTypes = getDnsRecordTypes();
-
- /* If there is at least one entry in this -> types, we have DNS enabled
- */
- if($this->dnsEntry['exists']){
- $this->DNS_is_account = true;
- }else{
- $this->DNS_is_account = false;
- }
- }
-
- /* Create a list of used mac and ip addresses */
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
- $ldap->search("(|(macAddress=*)(ipHostNumber=*))",array("macAddress","ipHostNumber"));
- while($attrs = $ldap->fetch()){
- if(isset($attrs['ipHostNumber'][0])){
- $this->used_ip_mac["ip:".$attrs['ipHostNumber'][0]] = "ip:".$attrs['ipHostNumber'][0];
- }
- if(isset($attrs['macAddress'][0])){
- $this->used_ip_mac["mac:".$attrs['macAddress'][0]] = "mac:".$attrs['macAddress'][0];
- }
- }
-
- /* Save initial ip and mac values, to be able
- check if the used values are already in use */
- $this->orig_ipHostNumber = $this->ipHostNumber;
- $this->orig_macAddress = $this->macAddress;
-
- /* Store initally account settings
- */
- $this->initially_was_account = $this->DNS_is_account;
-
- if($this->DNS_is_account){
- new log("view","unknown/".get_class($this),$this->dn);
- }
- }
-
-
- function netmaskIsCoherent($idZone)
- {
- $netmask = FlipIp(str_replace(".in-addr.arpa","",getNameFromMix($idZone)));
- if(!strstr($this->ipHostNumber, $netmask)){
- return false;
- }else{
- return true;
- }
- }
-
-
- function getVarsForSaving($attrs)
- {
- foreach($this->attributes as $attr){
- if(!empty($this->$attr)){
- $attrs[$attr] = $this->$attr;
- }
- }
- return($attrs);
- }
-
- function execute()
- {
- /* Call parent execute */
- $smarty= get_smarty();
-
- $tmp = $this->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $translation){
- $smarty->assign($name."ACL",$this->getacl($name));
- }
-
- $display= "";
-
- $smarty->assign("staticAddress", "");
- $smarty->assign("autonet", $this->autonet);
-
- /* Check for autonet button */
- if ($this->autonet && isset($_POST['autonet'])){
- $cmd= $this->config->data['MAIN']['AUTO_NETWORK_HOOK'];
- if(!empty($cmd) && $this->cn != ""){
- $res = shell_exec($cmd." ".$this->cn);
- if(!$res){
- print_red(sprintf(_("Can't execute specified AUTO_NETWORK_HOOK '%s'. Please check your gosa.conf."),$cmd));
- } else {
- $res= split(';', trim($res));
- if (isset($res[0]) && $res[0] != ""){
- $this->ipHostNumber= $res[0];
- }
- if (isset($res[1]) && $res[1] != ""){
- $this->macAddress= $res[1];
- }
- }
- }
- }
-
-
- /**********
- * DHCP Handling
- **********/
-
- if(isset($_POST['dhcpEditOptions'])){
-
- if(count($this->dhcpHostEntry) == 0){
- $this->dialog = new dhcpHost($this->dhcpParentNode,TRUE);
- }else{
- $this->dialog = new dhcpHost($this->dhcpHostEntry,TRUE);
- }
- $this->dialog->cn = $this->cn;
- $this->dialog->dhcpHWAddress = "ethernet ".$this->macAddress;
- if(!empty($this->ipHostNumber)){
- $this->dialog->statements['fixed-address'] = $this->ipHostNumber;
- }
- }
-
- if(isset($_POST['cancel_dhcp'])){
- $this->dialog = FALSE;
- }
-
- if(isset($_POST['save_dhcp'])){
- $this->dialog->save_object();
-
- $msgs = $this->dialog->check(array());
- if(count($msgs)){
- foreach($msgs as $msg){
- print_red($msg);
- }
- }else{
- $this->dhcpHostEntry = $this->dialog->save();
- $this->dialog = FALSE;
- }
- }
-
- if(is_object($this->dialog)){
- $this->dialog->save_object();
- return($this->dialog->execute());
- }
-
- $smarty->assign("dhcpEnabled", $this->dhcpEnabled);
- $smarty->assign("dhcp_is_Account",$this->dhcp_is_Account);
- $smarty->assign("dhcpParentNode", $this->dhcpParentNode);
- $smarty->assign("dhcpParentNodes",$this->dhcpParentNodes);
- $smarty->assign("dhcpParentNodeCnt",count($this->dhcpParentNodes));
-
-
- /**********
- * DNS Handling
- **********/
-
- /* There is no dns available
- */
- if($this->DNSenabled == false){
-
- /* Is IP address must ? */
- $smarty->assign("DNS_is_account",false);
- $smarty->assign("IPisMust",(($this->IPisMust)||($this->DNS_is_account)));
-
- /* Assign smarty all non DNs attributes */
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
- }
- $smarty->assign("staticAddress","* ");
-
- $display.= $smarty->fetch(get_template_path('network.tpl', TRUE));
- }else{
- $smarty->assign("DNS_is_account",true);
-
- /* Add new empty array to our record list */
- if(isset($_POST['AddNewRecord'])){
- $this->dnsEntry['RECORDS'][] =array("type"=>"aRecord","value"=>"");
- }
-
- /* propose_ip */
- if(isset($_POST['propose_ip'])){
- foreach($this->Zones as $key => $name){
- if($name == $this->dnsEntry['zoneName']){
- $net = FlipIp(str_replace(".in-addr.arpa","",getNameFromMix($key)));
- $this->ipHostNumber = $this->generateRandomIp($net);
- }
- }
- }
-
- /* Handle all posts */
- $only_once =true;
- foreach($_POST as $name => $value){
-
- /* Check if we have to delete a record entry */
- if((preg_match("/RemoveRecord_/",$name))&&($only_once)) {
-
- /* Avoid performing this once again */
- $only_once = false;
-
- /* Extract id for specified entry */
- $id = preg_replace("/RemoveRecord_/","",$name);
- $id = preg_replace("/_.*$/","",$id);
-
- /* Delete this record, mark edited entries to be able to delete them */
- if(isset($this->dnsEntry['RECORDS'][$id])){
- unset($this->dnsEntry['RECORDS'][$id]);
- }
- }
- }
- /* Assign smarty all non DNs attributes */
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
- }
-
- /* Assign smarty all DNS attributes */
- foreach($this->DNSattributes as $attr){
- $smarty->assign($attr,$this->dnsEntry[$attr]);
- }
-
- /* Assign all needed vars */
- $smarty->assign("DNSAccount",$this->DNS_is_account);
- $smarty->assign("hide_dns_check_box",$this->hide_dns_check_box);
-
- $smarty->assign("Zones",$this->Zones);
- $smarty->assign("ZoneCnt",count($this->Zones));
- $smarty->assign("ZoneKeys",($this->Zones));
- $smarty->assign("IPisMust",(($this->IPisMust)||($this->DNS_is_account)));
-
- /* Create zone array */
- $idZones = array();
- foreach($this->Zones as $id => $zone){
- if($this->netmaskIsCoherent($id)) {
- $idZones[$id] = $zone;
- }else{
- $idZones[$id] = $zone." ("._("Not matching").")";
- }
- }
- $smarty->assign("Zones",$idZones);
- $smarty->assign("ZoneKeys", $this->Zones);
-
- $tmp = $this->generateRecordsList();
-
- $changeStateForRecords = $tmp['changeStateForRecords'];
-
- $smarty->assign("records",$tmp['str']);
- $smarty->assign("changeStateForRecords",$changeStateForRecords);
- $smarty->assign("staticAddress","* ");
-
- $display.= $smarty->fetch(get_template_path('network.tpl', TRUE));
- }
- return($display);
- }
-
-
- function remove_from_parent()
- {
- if($this->initially_was_account){
-
- $ldap = $this->config->get_ldap_link();
-
- $tmp = array();
- $this->dnsEntry['exists'] = false;
- $tmp = getDNSHostEntriesDiff($this->config,$this->OrigCn,$this->dnsEntry,$this->cn);
-
- /* Delete dns */
- foreach($tmp['del'] as $dn => $del){
- $ldap->cd($dn);
- $ldap->rmdir_recursive($dn);
- new log("remove","unknown/".get_class($this),$dn);
- }
- }
- }
-
-
- /* Save data to object */
- function save_object()
- {
-
- if(isset($_POST['network_tpl_posted'])){
-
- /* Save all posted vars */
- plugin::save_object();
-
- /* Handle DHCP Posts*/
- if($this->dhcpEnabled && isset($_POST['network_tpl_posted'])){
- foreach($this->dhcpAttributes as $attr){
- if(isset($_POST[$attr])){
- $this->$attr = $_POST[$attr];
- }
- }
- if(isset($_POST['dhcp_is_Account'])){
- $this->dhcp_is_Account = TRUE;
- }else{
- $this->dhcp_is_Account = FALSE;
- }
- }
-
- /* Ge all non dns attributes (IP/MAC)*/
- foreach($this->attributes as $attr){
- if(isset($_POST[$attr]) && $this->acl_is_writeable($attr)){
- $this->$attr = $_POST[$attr];
- }
- }
-
- /* Check if DNS should be enabled / disabled */
- if($this->DNS_is_account && $this->acl_is_removeable() && !isset($_POST['DNS_is_account'])){
- $this->DNS_is_account = false;
- }elseif(!$this->DNS_is_account && $this->acl_is_createable() && isset($_POST['DNS_is_account'])){
- $this->DNS_is_account = true;
- }
-
- /* Get dns attributes */
- if(($this->DNSenabled) && (isset($_POST['network_tpl_posted']))){
-
- /* Check for posted record changes */
- if(is_array($this->dnsEntry['RECORDS']) && $this->acl_is_writeable("Records")){
- foreach($this->dnsEntry['RECORDS'] as $key => $value){
-
- /* Check if type has changed */
- if(isset($_POST['RecordTypeSelectedFor_'.$key])){
- $this->dnsEntry['RECORDS'][$key]['type'] = $_POST['RecordTypeSelectedFor_'.$key];
- }
- /* Check if value has changed */
- if(isset($_POST['RecordValue_'.$key])){
- $this->dnsEntry['RECORDS'][$key]['value'] = $_POST['RecordValue_'.$key];
- }
- }
- }
- /* Get all basic DNS attributes (TTL, Clas ..)*/
- foreach($this->DNSattributes as $attr){
- if(isset($_POST[$attr]) && $this->acl_is_writeable($attr)){
- $this->dnsEntry[$attr] = $_POST[$attr];
- }
- }
-
-
- }
- if($this->hide_dns_check_box){
- $this->DNS_is_account = true;
- }
- }
- }
-
-
- /* Check supplied data */
- function check()
- {
- /* Call common method to give check the hook */
- $message= plugin::check();
-
- if($this->dhcpEnabled && $this->dhcp_is_Account && $this->dhcpParentNode != "" && count($this->dhcpHostEntry) == 0){
-# $message[] =_("You have not configured your dhcp settings yet.");
- }
-
- /* Check if mac and ip are already used */
- if(!empty($this->ipHostNumber) && $this->DNS_is_account &&
- $this->ipHostNumber != $this->orig_ipHostNumber &&
- in_array("ip:".$this->ipHostNumber,$this->used_ip_mac)){
- $message[] =_("The specified IP address is already in use.");
- }
- if(!empty($this->macAddress) && $this->dhcp_is_Account &&
- $this->macAddress != $this->orig_macAddress &&
- in_array("mac:".$this->macAddress,$this->used_ip_mac)){
- print_red(sprintf(_("The specified MAC address '%s' for this system '%s' is already in use."),$this->macAddress,$this->cn));
- }
-
- /* Check if ip must be given
- */
- if(($this->IPisMust)||($this->DNS_is_account)){
- if (empty($this->ipHostNumber)){
- $message[]= _("The required field 'IP-address' is not set.");
- }
-
- if (!is_ip($this->ipHostNumber)){
- $message[]= _("Wrong IP format in field IP-address.");
- }
- }
-
- /* Check if mac is empty
- */
- if ($this->macAddress == "" ){
- $message[]= _("The required field 'MAC-address' is not set.");
- }
- if(!is_mac($this->macAddress)){
- $message[]=(_("The given macaddress is invalid. There must be 6 2byte segments seperated by ':'."));
- }
-
- /* only perfrom this checks if this is a valid DNS account */
- if($this->DNS_is_account){
-
- $checkArray = array();
- $onlyOnce = array();
-
- // $onlyOnce['cNAMERecord'] = 0;
- $tmp = array_flip($this->Zones);
- $tmp2 = $tmp[$this->dnsEntry['zoneName']];
- if(!$this->netmaskIsCoherent($tmp2)){ //this->dnsEntry['zoneName'])){
- $tmp2 = preg_replace("/^.*\//","",$tmp2);
- $message[] =sprintf(_("The specified IP address '%s' is not matching the selected reverse zone entry '%s'."),$this->ipHostNumber,$tmp2);
- }
-
- /* Walk through all entries and detect duplicates or mismatches
- */
- foreach($this->dnsEntry['RECORDS'] as $name => $values){
-
- /* Count record values, to detect duplicate entries for a specific record
- */
- if(!isset($checkArray[$values['type']][$values['value']])){
- $checkArray[$values['type']][$values['value']] = 0;
- }else{
- $message[] = sprintf(_("Found duplicate value for record type '%s'."),$values['type']);
- }
-
- /* Check if given entries in $onlyOnce are used more than once
- */
- if(isset($onlyOnce[$values['type']])){
- $onlyOnce[$values['type']] ++;
- if($onlyOnce[$values['type']] > 1){
- $message[] = sprintf(_("Found more than one entry for the uniqe record type '%s'."),$values['type']);
- }
- }
-
- /* Skip txt record ...
- */
- if($values['type'] == "tXTRecord") continue;
-
- /* Check if there is an aRecord defined which uses the same IP as used in IPhostAddress
- */
- if(($values['type'] == "aRecord")&&($values['value'] == $this->ipHostNumber)){
- $message[]=sprintf(_("The device IP '%s' is added as 'A Record', this will be done automatically, please remove the record."),
- $this->ipHostNumber);
- }
-
- /* only lower-case is allowed in record entries ...
- */
- if($values['value'] != strtolower($values['value'])){
- $message[] = sprintf(_("Only lowercase is allowed, please check your '%ss'."),$values['type']);
- }
- }
- }
- return ($message);
- }
-
-
- /* Save to LDAP */
- function save()
- {
- $ldap= $this->config->get_ldap_link();
-
- $dn = $this->parent->dn;
-
- /*******************/
- /* IP-MAC HANDLING */
- /*******************/
-
- /* $dn was posted as parameter */
- $this->dn = $dn;
-
- /* Save DNS setting & ip/Mac*/
- plugin::save();
-
- /* Write back to ldap */
- $ldap->cd($this->dn);
- $this->cleanup();
- $ldap->modify ($this->attrs);
-
- /****************/
- /* DHCP HANDLING */
- /****************/
-
- /* New entry */
- if($this->dhcpEnabled){
-
- if(count($this->dhcpHostEntry) == 0){
- $this->dialog = new dhcpHost($this->dhcpParentNode,TRUE);
- $this->dialog->cn = $this->cn;
- $this->dialog->dhcpHWAddress = "ethernet ".$this->macAddress;
- if(!empty($this->ipHostNumber)){
- $this->dialog->statements['fixed-address'] = $this->ipHostNumber;
- }
- $this->dialog->execute();
- $this->dialog->save_object();
- $this->dhcpHostEntry = $this->dialog->save();
- if(count($this->dhcpHostEntry['dhcpOption']) == 0){
- $this->dhcpHostEntry['dhcpOption']= array("host-name ".$this->cn);
- }
- }
-
- if(count($this->dhcpHostEntry) == 0){
- $this->dialog = new dhcpHost($this->dhcpParentNode,TRUE);
- $this->dialog->cn = $this->cn;
- $this->dialog->dhcpHWAddress = "ethernet ".$this->macAddress;
- if(!empty($this->ipHostNumber)){
- $this->dialog->statements['fixed-address'] = $this->ipHostNumber;
- }
- $this->dialog->execute();
- $this->dialog->save_object();
- $this->dhcpHostEntry = $this->dialog->save();
- if(count($this->dhcpHostEntry['dhcpOption']) == 0){
- $this->dhcpHostEntry['dhcpOption']= array("host-name ".$this->cn);
- }
- }
-
- /* Write mac address to dhcp settings */
- if($this->dhcp_is_Account){
- if(!isset($this->dhcpHostEntry['dhcpHWAddress'][0]) ||
- !preg_match("/ethernet ".$this->macAddress."/",$this->dhcpHostEntry['dhcpHWAddress'][0])){
- $this->dhcpHostEntry['dhcpHWAddress'] = array("ethernet ".$this->macAddress);
- $this->dhcpHostEntry['MODIFIED'] = TRUE;
- }
- }
-
-
- /* Unset dhcpStatements if this attribute is empty */
- if(isset($this->dhcpHostEntry['dhcpStatements']) &&
- ($this->dhcpHostEntry['dhcpStatements'] == "" || count($this->dhcpHostEntry['dhcpStatements']) == 0) ){
- unset($this->dhcpHostEntry['dhcpStatements']);
- }
-
- /* DHCP removed */
- if($this->initial_dhcp_is_Account && !$this->dhcp_is_Account){
- $ldap->rmdir_recursive($this->dhcpHostEntry['dn']);
- show_ldap_error($ldap->get_error(),_("Removing dhcp entry for this object failed."));
-
- $tmp = new servdhcp($this->config,$this->dhcpParentNode);
- $tmp->handle_post_events("remove");
- }
-
- /* DHCP Added */
- if(!$this->initial_dhcp_is_Account && $this->dhcp_is_Account){
- $attrs = $this->dhcpHostEntry;
- unset($attrs['MODIFIED']);
- unset($attrs['dn']);
- $ldap->cd("cn=".$this->cn.",".$this->dhcpParentNode);
- $res = $ldap->add($attrs);
-
- $tmp = new servdhcp($this->config,$this->dhcpParentNode);
- $tmp->handle_post_events("add");
-
- show_ldap_error($ldap->get_error(),_("Tried to add new dhcp entry failed."));
- }
-
- /* DHCP still activated */
- if($this->initial_dhcp_is_Account && $this->dhcp_is_Account){
-
- /* DHCP node changed */
- if(($this->initial_dhcpParentNode != $this->dhcpParentNode) ||
- ($this->cn != $this->OrigCn)){
- $attrs = $this->dhcpHostEntry;
- $attrs['cn'] = $this->cn;
- unset($attrs['dn']);
- unset($attrs['MODIFIED']);
- $ldap->cd("cn=".$this->cn.",".$this->dhcpParentNode);
- $res = $ldap->add($attrs);
-
- $tmp = new servdhcp($this->config,$this->dhcpParentNode);
- $tmp->handle_post_events("modify");
-
- show_ldap_error($ldap->get_error(),_("Tried to add new dhcp entry failed."));
- if($res){
- $ldap->rmdir_recursive($this->dhcpHostEntry['dn']);
- show_ldap_error($ldap->get_error(),_("Removing old dhcp entry failed."));
- }
- }
-
- /* SAME node but modified */
- if(isset($this->dhcpHostEntry['MODIFIED']) && $this->dhcpHostEntry['MODIFIED'] == 1 &&
- $this->initial_dhcpParentNode == $this->dhcpParentNode){
- $attrs = $this->dhcpHostEntry;
- unset($attrs['dn']);
- unset($attrs['MODIFIED']);
- $ldap->cd($this->dhcpHostEntry['dn']);
- $ldap->modify($attrs);
-
- $tmp = new servdhcp($this->config,$this->dhcpParentNode);
- $tmp->handle_post_events("modify");
-
- show_ldap_error($ldap->get_error(),_("Modifying dhcp entry failed."));
- }
- }
- }
-
-
- /****************/
- /* DNS HANDLING */
- /****************/
-
- /* If isn't DNS account but initially was DNS account
- remove all DNS entries
- */
- if((!$this->DNSenabled) || ((!$this->DNS_is_account)&&(!$this->initially_was_account))){
- return;
- }else{
-
- /* Add ipHostNumber to aRecords
- */
- $backup_dnsEntry = $this->dnsEntry;
- if(!empty($this->ipHostNumber)){
- $this->dnsEntry['RECORDS'][] = array("type"=>"aRecord","value"=>$this->ipHostNumber);
- $ptr = $this->get_pTRRecord();
- if(!empty($ptr)){
- $this->dnsEntry['RECORDS'][] = array("type"=>"pTRRecord","value"=>$ptr);
- }
- }
-
- /* Create diff and follow instructions
- * If Account was disabled, remove account by setting exists to false
- */
- if((!$this->DNS_is_account)&&($this->initially_was_account)){
- $this->dnsEntry['exists'] = false;
- $tmp = getDNSHostEntriesDiff($this->config,$this->OrigCn,$this->dnsEntry,$this->cn);
- }else{
- $this->dnsEntry['exists'] = $this->DNS_is_account;
- $tmp = getDNSHostEntriesDiff($this->config,$this->OrigCn,$this->dnsEntry,$this->cn);
- }
-
- /* move follwoing entries
- */
- foreach($tmp['move'] as $src => $dst){
- $this->recursive_move($src,$dst);
- }
-
- /* Delete dns */
- foreach($tmp['del'] as $dn => $del){
- $ldap->cd($dn);
- $ldap->rmdir_recursive($dn);
- new log("modify","unknown/".get_class($this),$dn,array("*"),$ldap->get_error());
- }
-
- /* Add || Update new DNS entries
- */
- foreach($tmp['add'] as $dn => $attrs){
- $ldap->cd($dn);
- $ldap->cat($dn, array('dn'));
- if(count($ldap->fetch())){
- $ldap->cd($dn);
- $ldap->modify ($attrs);
- }else{
- $ldap->cd($dn);
- $ldap->add($attrs);
- }
- new log("modify","unknown/".get_class($this),$dn,array_keys($attrs),$ldap->get_error());
- }
-
-
- /* Display errors
- */
- if($ldap->get_error() != "Success"){
- show_ldap_error($ldap->get_error(), sprintf(_("Saving of terminal/dns account with dn '%s' failed."),$this->dn));
- }
-
- $tmp2 = new servdns($this->config,$this->dn);
- $tmp2->handle_post_events("modify");
-
- $this->dnsEntry = $backup_dnsEntry;
- }
- }
-
- /* Create html table with all used record types
- */
- function generateRecordsList()
- {
- $changeStateForRecords = "";
-
- if(!$this->DNS_is_account) {
- $str = " ";
- return(array("str" => $str, "changeStateForRecords"=> ""));
- }
-
- $str = "";
- $ret = array("str" => $str, "changeStateForRecords" => $changeStateForRecords);
- return($ret);
- }
-
-
- /* Create a html select box which allows us to select different types of records
- */
- function generateRecordListBox($selected,$name)
- {
- $str = "";
- foreach($this->RecordTypes as $type => $value){
- $use = "";
- if($type == $selected){
- $use = " selected ";
- }
- $str.="\n ".strtoupper(preg_replace("/record/i","",$type))." ";
- }
- $str.=" ";
- return($str);
- }
-
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- $tmp = array(
- "plShortName" => _("DNS"),
- "plDescription" => _("DNS settings"),
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 5,
- "plSection" => array("administration"),
- "plCategory" => array("workstation","terminal","phone","server","component","printer","winworkstation"),
-
- "plProvidedAcls"=> array(
- "ipHostNumber" => _("IP address"),
- "macAddress" => _("MAC address"))
- );
-
- /* Hide all dns specific code, if dns is not available
- */
- foreach($_SESSION['config']->data['TABS']['SERVERSERVICE'] as $tab){
- if(preg_match("/^servdns$/",$tab['CLASS'])){
- $tmp['plProvidedAcls']["Records"] = _("DNS records");
- $tmp['plProvidedAcls']["zoneName"] = _("Zone name");
- $tmp['plProvidedAcls']["dNSTTL"] = _("TTL");
- break;
- }
- }
- return($tmp);
- }
-
-
- function get_dhcp_host_entry()
- {
- $attrs = array();
- $dn = $this->get_dhcp_host_entry_dn();
- if($dn){
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
- $ldap->cat($dn,array("*"));
- if($ldap->count()){
- $attrs = $ldap->fetch();
- foreach($attrs as $key => $value){
- if(is_numeric($key) || ($key == "count")){
- unset($attrs[$key]);
- }
- if(is_array($value) && isset($value['count'])){
- unset($attrs[$key]['count']);
- }
- }
- }
- }
- return($attrs);
- }
-
-
- function get_dhcp_host_entry_dn()
- {
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
- $ldap->search ("(&(objectClass=dhcpHost)(cn=".$this->cn."))",array("cn","dn"));
-
- if($ldap->count()){
- $attr = $ldap->fetch();
- return($attr['dn']);
- }else{
- return("");
- }
- }
-
-
- function get_dhcp_parent_node()
- {
- return(preg_replace("/^cn=".normalizePreg($this->cn).",/","",$this->get_dhcp_host_entry_dn()));
- }
-
-
- function get_dhcp_parent_nodes()
- {
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
- $ldap->search("(objectClass=dhcpService)",array("dhcpPrimaryDN"));
-
- $dhcp_dns = array();
- while($attr = $ldap->fetch()){
- $dhcp_dns[$attr['dn']] = $attr['dhcpPrimaryDN'][0];
- }
-
- foreach($dhcp_dns as $key => $pri_dns){
- $ldap->cat($pri_dns,array("cn"));
- $tmp = $ldap->fetch();
- if(isset($tmp['cn'][0])){
- $dhcp_dns[$key] = $tmp['cn'][0];
- }else{
- unset($dhcp_dns[$key]);
- }
- }
-
- $tmp = $tmp2 = array();
- foreach($dhcp_dns as $dn => $cn){
- $ldap->cd($dn);
- $ldap->search("(|(objectClass=dhcpService)(objectClass=dhcpGroup)".
- "(objectClass=dhcpSubnet)(objectClass=dhcpSharedNetwork))",array("cn"));
- while($attr = $ldap->fetch()){
- $tmp[$attr['dn']] = $attr['cn'][0];
- }
- $tmp2 = array_merge($tmp2,$this->create_tree($tmp,preg_replace("/^[^,]+,/i","",$dn),"(".$cn.") "));
- }
- return($tmp2);
- }
-
-
- /* this function returns the default ptr record entry */
- function get_pTRRecord()
- {
- if(!empty($this->ipHostNumber) && isset($this->dnsEntry['zoneName']) && !empty($this->dnsEntry['zoneName'])){
- $ldap = $this->config->get_ldap_link();
- $ldap->cat(getDNSZoneDN($this->config,$this->dnsEntry['zoneName']));
- $attrs = $ldap->fetch();
- $tmp = array_flip($this->Zones);
- $tmp = preg_replace("/^[^\/]*+\//","",$tmp[$this->dnsEntry['zoneName']]);
- $tmp = trim(preg_replace("/\.in-addr.arpa$/","",$tmp));
- $ptr = preg_replace("/^".normalizePreg(FlipIp($tmp))."\./","",$this->ipHostNumber);
- return($ptr);
- }else{
- return(FALSE);
- }
- }
-
-
- function generateRandomIP($net = "")
- {
- $str = $net;
- $cnt = 4;
- while(substr_count($str,".") < 3 && $cnt > 0){
- $str .= ".".rand(0,255);
- $str = preg_replace("/\.\.*/",".",$str);
- $str = trim($str,". ");
- $cnt --;
- }
- return($str);
- }
-
-
- function create_tree($arr,$base,$current = "")
- {
- $ret = array();
- foreach($arr as $r => $name){
- $base_part = str_replace($base,"",$r);
- if(preg_match("/^[a-z]*=".normalizePreg($name)."(|,)$/i",$base_part)){
- $ret[$r] = $current.$name;
- $tmp = $this->create_tree($arr,$r,$current.". ");
- foreach($tmp as $sub_key => $sub_name){
- $ret[$sub_key] = $sub_name;
- }
- }
- }
- return($ret);
- }
-
- function force_dns()
- {
- if($this->DNSenabled){
- $this->DNS_is_account = TRUE;
- $this->hide_dns_check_box = TRUE;
- }
- }
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/plugins/admin/systems/dhcpNewSection.tpl b/plugins/admin/systems/dhcpNewSection.tpl
deleted file mode 100644
index 517c3b403..000000000
--- a/plugins/admin/systems/dhcpNewSection.tpl
+++ /dev/null
@@ -1,25 +0,0 @@
-
- {t}Create new DHCP section{/t}
-
-
-
-{t}Please choose one of the following DHCP section types.{/t}
-
-
-{t}Section{/t}
-
- {html_options options=$sections}
-
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/dhcp_advanced.tpl b/plugins/admin/systems/dhcp_advanced.tpl
deleted file mode 100644
index 5ce0e4600..000000000
--- a/plugins/admin/systems/dhcp_advanced.tpl
+++ /dev/null
@@ -1,46 +0,0 @@
-{* GOsa dhcp sharedNetwork - smarty template *}
-
-
-
-
-{if $show_advanced}
-
-
-
-
-
-{else}
-
-
-
-{/if}
-
diff --git a/plugins/admin/systems/dhcp_group.tpl b/plugins/admin/systems/dhcp_group.tpl
deleted file mode 100644
index 930fc05ee..000000000
--- a/plugins/admin/systems/dhcp_group.tpl
+++ /dev/null
@@ -1,22 +0,0 @@
-{* GOsa dhcp sharedNetwork - smarty template *}
-{t}Generic{/t}
-
-
-
-
-
-
diff --git a/plugins/admin/systems/dhcp_host.tpl b/plugins/admin/systems/dhcp_host.tpl
deleted file mode 100644
index 602c51255..000000000
--- a/plugins/admin/systems/dhcp_host.tpl
+++ /dev/null
@@ -1,52 +0,0 @@
-{* GOsa dhcp host - smarty template *}
-{t}Generic{/t}
-
-
-
-
-
-
diff --git a/plugins/admin/systems/dhcp_network.tpl b/plugins/admin/systems/dhcp_network.tpl
deleted file mode 100644
index 5645a63ac..000000000
--- a/plugins/admin/systems/dhcp_network.tpl
+++ /dev/null
@@ -1,90 +0,0 @@
-{* GOsa dhcp sharedNetwork - smarty template *}
-
-
-
- {t}Network configuration{/t}
-
-
-
- {t}Bootup{/t}
-
-
-
-
- {t}Domain Name Service{/t}
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/dhcp_pool.tpl b/plugins/admin/systems/dhcp_pool.tpl
deleted file mode 100644
index dcbd05c3d..000000000
--- a/plugins/admin/systems/dhcp_pool.tpl
+++ /dev/null
@@ -1,26 +0,0 @@
-{* GOsa dhcp sharedNetwork - smarty template *}
-{t}Generic{/t}
-
-
-
-
-
-
diff --git a/plugins/admin/systems/dhcp_service.tpl b/plugins/admin/systems/dhcp_service.tpl
deleted file mode 100644
index 6ca515e67..000000000
--- a/plugins/admin/systems/dhcp_service.tpl
+++ /dev/null
@@ -1,43 +0,0 @@
-{t}Generic{/t}
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/dhcp_sharedNetwork.tpl b/plugins/admin/systems/dhcp_sharedNetwork.tpl
deleted file mode 100644
index 374da3500..000000000
--- a/plugins/admin/systems/dhcp_sharedNetwork.tpl
+++ /dev/null
@@ -1,107 +0,0 @@
-{* GOsa dhcp sharedNetwork - smarty template *}
-{t}Generic{/t}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {t}Leases{/t}
-
-
-
-
-
- {t}Access control{/t}
-
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/dhcp_subnet.tpl b/plugins/admin/systems/dhcp_subnet.tpl
deleted file mode 100644
index 05425fbdc..000000000
--- a/plugins/admin/systems/dhcp_subnet.tpl
+++ /dev/null
@@ -1,41 +0,0 @@
-{* GOsa dhcp subnet - smarty template *}
-{t}Generic{/t}
-
-
-
-
-
-
diff --git a/plugins/admin/systems/glpi.tpl b/plugins/admin/systems/glpi.tpl
deleted file mode 100644
index 0d2f8db36..000000000
--- a/plugins/admin/systems/glpi.tpl
+++ /dev/null
@@ -1,138 +0,0 @@
-
-
-
-
-
- {t}Generic{/t}
-
-
-
-
- {t}Comment{/t}
-
-
-
-{render acl=$commentsACL}
-
-{/render}
-
-
-
-
-
-
-
-
-
-
- {t}Installed devices{/t}
-
-
-
-
- {t}Attachments{/t}
-
-
-
-
-
-
diff --git a/plugins/admin/systems/glpiAttachmentEdit.tpl b/plugins/admin/systems/glpiAttachmentEdit.tpl
deleted file mode 100644
index 7d91e50af..000000000
--- a/plugins/admin/systems/glpiAttachmentEdit.tpl
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
{t}Attachment{/t}
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/glpiAttachmentPool.tpl b/plugins/admin/systems/glpiAttachmentPool.tpl
deleted file mode 100644
index e3a73be8d..000000000
--- a/plugins/admin/systems/glpiAttachmentPool.tpl
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
-
-
-
- {t}List of attachments{/t}
-
-
-
- {$attachmenthead}
-
-
-
- {$attachments}
-
-
-
-
-
-
{t}Information{/t}
-
-
- {t}This dialog allow you to attach additional objects (like manuals, guides, etc.) to your currently edited computer.{/t}
-
-
-
-
{t}Filters{/t}
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/glpiDeviceManagement.tpl b/plugins/admin/systems/glpiDeviceManagement.tpl
deleted file mode 100644
index ab2baa740..000000000
--- a/plugins/admin/systems/glpiDeviceManagement.tpl
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
-
-
-
- {t}List of devices{/t}
-
-
-
- {$devicehead}
-
-
-
- {$devices}
-
-
-
-
-
-
{t}Information{/t}
-
-
- {t}This dialog allows you to attach a device to your currently edited computer.{/t}
-
-
-
-
{t}Filters{/t}
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/glpiManufacturer.tpl b/plugins/admin/systems/glpiManufacturer.tpl
deleted file mode 100644
index a15a29aa4..000000000
--- a/plugins/admin/systems/glpiManufacturer.tpl
+++ /dev/null
@@ -1,15 +0,0 @@
-{t}Manage manufacturers{/t}
-
- {html_options values=$ManuKeys output=$Manus}
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/glpiManufacturerAdd.tpl b/plugins/admin/systems/glpiManufacturerAdd.tpl
deleted file mode 100644
index c5b060d29..000000000
--- a/plugins/admin/systems/glpiManufacturerAdd.tpl
+++ /dev/null
@@ -1,89 +0,0 @@
-{t}Add/Edit manufacturer{/t}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/glpiPrinter.tpl b/plugins/admin/systems/glpiPrinter.tpl
deleted file mode 100644
index 46e344678..000000000
--- a/plugins/admin/systems/glpiPrinter.tpl
+++ /dev/null
@@ -1,159 +0,0 @@
-
-
-
-
-
- {t}Generic{/t}
-
-
-
- {t}Supported interfaces{/t}
-
-
-
-
-
-
-
-
-
- {t}Contacts{/t}
-
-
-
- {t}Attachments{/t}
-
-
-
-
-
-
-
-
- {t}Information{/t}
-
-
-
-{render acl=$commentsACL}
-
-{/render}
-
-
-
-
-
- {t}Installed cartridges{/t}
-
-
-
-
diff --git a/plugins/admin/systems/glpiPrinterCartridges.tpl b/plugins/admin/systems/glpiPrinterCartridges.tpl
deleted file mode 100644
index 5dcd2de13..000000000
--- a/plugins/admin/systems/glpiPrinterCartridges.tpl
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
-
-
-
- {t}List of available cartridge type for this type of printer{/t}
-
-
-
- {$devicehead}
-
-
-
- {$devices}
-
-
-
-
-
-
{t}Information{/t}
-
-
- {t}This dialog allows you to create new types of cartridges, and select one or more types for your printer. Cartridge types depends on the printer type you have selected. For each selected cartridge type there will be a new cartridge created, this allows you to select the same cartridge type for more then one printer.{/t}
-
-
-
-
{t}Filters{/t}
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/glpiPrinterCartridgesEdit.tpl b/plugins/admin/systems/glpiPrinterCartridgesEdit.tpl
deleted file mode 100644
index 6857efdb3..000000000
--- a/plugins/admin/systems/glpiPrinterCartridgesEdit.tpl
+++ /dev/null
@@ -1,83 +0,0 @@
-
-
-
- {t}Generic{/t}
-
-
- {t}Comments{/t}
-
-
- {t}Comment{/t}
-
-
-
-
-
-
-
-
- {t}Generic{/t}
-
-
- {$PrinterTypeMatrix}
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/glpiSelectUser.tpl b/plugins/admin/systems/glpiSelectUser.tpl
deleted file mode 100644
index 75bf351bd..000000000
--- a/plugins/admin/systems/glpiSelectUser.tpl
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-
-
-
- {t}List of users{/t}
-
-
-
- {$usershead}
-
-
-
- {$users}
-
-
-
-
-
-
{t}Information{/t}
-
-
- {t}This dialog allows you to select a user as technical responsible person.{/t}
-
-
-
-
{t}Filters{/t}
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/glpi_devices.tpl b/plugins/admin/systems/glpi_devices.tpl
deleted file mode 100644
index 44de4fa93..000000000
--- a/plugins/admin/systems/glpi_devices.tpl
+++ /dev/null
@@ -1,763 +0,0 @@
-{if $device_type=="monitor"}
- {t}Add/Edit monitor{/t}
-
-
-
-
-
-{elseif $device_type=="pci"}
-
- {t}Add/Edit other device{/t}
-
-
-
-
-
-
-
-
-
-
- {t}Manufacturer{/t}
-
-
-
- {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
-
-
-
-
-
-
-
-
-{elseif $device_type=="power"}
-
- {t}Add/Edit power supply{/t}
-
-
-
-{elseif $device_type=="gfxcard"}
-
- {t}Add/Edit graphic card{/t}
-
-
-
-{elseif $device_type=="control"}
-
- {t}Add/Edit controller{/t}
-
-
-
-
-{elseif $device_type=="drive"}
-
- {t}Add/Edit drive{/t}
-
-
-
-
-{elseif $device_type=="hdd"}
- {t}Add/Edit harddisk{/t}
-
-
-
-
-{elseif $device_type=="ram"}
-
- {t}Add/Edit memory{/t}
-
-
-
-
-{elseif $device_type=="sndcard"}
- {t}Add/Edit sound card{/t}
-
-
-
-{elseif $device_type=="iface"}
- {t}Add/Edit network interface{/t}
-
-
-
-
-{elseif $device_type=="processor"}
- {t}Add/Edit processor{/t}
-
-
-
-
-{elseif $device_type=="moboard"}
- {t}Add/Edit motherboard{/t}
-
-
-
-{elseif $device_type=="case"}
- {t}Add/Edit computer case{/t}
-
-
-
-
-
-
-
-
-
-
- {t}Manufacturer{/t}
-
-
-
- {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
-
-
-
-
- {t}format{/t}
-
-
-
- {html_options values=$formatKeys output=$formats selected=$format}
-
-
-
-
-
-
-
-{/if}
-
-
-
-
diff --git a/plugins/admin/systems/glpi_edit_cartridge_type.tpl b/plugins/admin/systems/glpi_edit_cartridge_type.tpl
deleted file mode 100644
index cbc91d95f..000000000
--- a/plugins/admin/systems/glpi_edit_cartridge_type.tpl
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
- {html_options values=$PrinterTypeKeys output=$PrinterTypes}
-
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/glpi_edit_os.tpl b/plugins/admin/systems/glpi_edit_os.tpl
deleted file mode 100644
index 8e3726451..000000000
--- a/plugins/admin/systems/glpi_edit_os.tpl
+++ /dev/null
@@ -1,39 +0,0 @@
-{t}Manage OS-types{/t}
-{if $Method == "edit"}
-
-
- {html_options values=$OSKeys output=$OSs}
-
-
-
-
-
-
-
-
-
-{else}
-{t}Please enter a new name{/t}
-
-
-
-
-
-
-
-
-{/if}
-
-
diff --git a/plugins/admin/systems/glpi_edit_printer_type.tpl b/plugins/admin/systems/glpi_edit_printer_type.tpl
deleted file mode 100644
index a63e9235e..000000000
--- a/plugins/admin/systems/glpi_edit_printer_type.tpl
+++ /dev/null
@@ -1,40 +0,0 @@
-
-{if $Method == "edit"}
-
- {html_options values=$PrinterTypeKeys output=$PrinterTypes}
-
-
-
-
-
-
-
-
-
-
-{else}
-
- {t}Please enter a new name{/t}
-
-
-
-
-
-
-
-
-
-{/if}
-
diff --git a/plugins/admin/systems/glpi_edit_type.tpl b/plugins/admin/systems/glpi_edit_type.tpl
deleted file mode 100644
index 14a4f5431..000000000
--- a/plugins/admin/systems/glpi_edit_type.tpl
+++ /dev/null
@@ -1,37 +0,0 @@
-{t}Manage System-types{/t}
-{if $Method == "edit"}
-
-
- {html_options values=$SystemTypeKeys output=$SystemTypes}
-
-
-
-
-
-
-
-
-
-{else}
-{t}Please enter a new name{/t}
-
-
-
-
-
-
-
-
-{/if}
diff --git a/plugins/admin/systems/goCupsServer.tpl b/plugins/admin/systems/goCupsServer.tpl
deleted file mode 100644
index e10bd2f67..000000000
--- a/plugins/admin/systems/goCupsServer.tpl
+++ /dev/null
@@ -1,9 +0,0 @@
-{t}Print Service{/t} {t}enabled{/t}
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/goFaxServer.tpl b/plugins/admin/systems/goFaxServer.tpl
deleted file mode 100644
index 27560b3f3..000000000
--- a/plugins/admin/systems/goFaxServer.tpl
+++ /dev/null
@@ -1,27 +0,0 @@
- {t}FAX database information{/t}
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/goFonServer.tpl b/plugins/admin/systems/goFonServer.tpl
deleted file mode 100644
index 14a1603b8..000000000
--- a/plugins/admin/systems/goFonServer.tpl
+++ /dev/null
@@ -1,43 +0,0 @@
- {t}VoIP database information{/t}
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/goGlpiServer.tpl b/plugins/admin/systems/goGlpiServer.tpl
deleted file mode 100644
index 36a2f2476..000000000
--- a/plugins/admin/systems/goGlpiServer.tpl
+++ /dev/null
@@ -1,36 +0,0 @@
- {t}GLPI database information{/t}
-
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/goImapServer.tpl b/plugins/admin/systems/goImapServer.tpl
deleted file mode 100644
index 17c40092d..000000000
--- a/plugins/admin/systems/goImapServer.tpl
+++ /dev/null
@@ -1,120 +0,0 @@
- {t}Generic{/t}
-
-
-
- Action
-{if $is_new == "new"}
- {t}The server must be saved before you can use the status flag.{/t}
-{elseif !$is_acc}
- {t}The service must be saved before you can use the status flag.{/t}
-{/if}
-
-
-
- {html_options options=$Actions}
-
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/goKioskService.tpl b/plugins/admin/systems/goKioskService.tpl
deleted file mode 100644
index f81230464..000000000
--- a/plugins/admin/systems/goKioskService.tpl
+++ /dev/null
@@ -1,24 +0,0 @@
- {t}Kiosk profile management{/t} LABEL>
-
-
-
-{t}Server path{/t}
-
-
-{$divlist}
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/goKrbServer.tpl b/plugins/admin/systems/goKrbServer.tpl
deleted file mode 100644
index a0234ebe1..000000000
--- a/plugins/admin/systems/goKrbServer.tpl
+++ /dev/null
@@ -1,34 +0,0 @@
- {t}Kerberos kadmin access{/t}
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/goLdapServer.tpl b/plugins/admin/systems/goLdapServer.tpl
deleted file mode 100644
index 24e181771..000000000
--- a/plugins/admin/systems/goLdapServer.tpl
+++ /dev/null
@@ -1,13 +0,0 @@
- {t}LDAP service{/t}
-{t}LDAP URI{/t}{$must}
-{render acl=$goLdapBaseACL}
-
-{/render}
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/goLogDBServer.tpl b/plugins/admin/systems/goLogDBServer.tpl
deleted file mode 100644
index 839507029..000000000
--- a/plugins/admin/systems/goLogDBServer.tpl
+++ /dev/null
@@ -1,27 +0,0 @@
- {t}Logging database information{/t}
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/goMailServer.tpl b/plugins/admin/systems/goMailServer.tpl
deleted file mode 100644
index a17d08f04..000000000
--- a/plugins/admin/systems/goMailServer.tpl
+++ /dev/null
@@ -1,225 +0,0 @@
- {t}Generic{/t}
-
-
-
-
-
-
-
-
-
-
-
-
- {t}Domains and routing{/t}
-
-
-
-
-
-
-
-
-
-
-
-
-
- {t}Restrictions{/t}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Action
-{if $is_new == "new"}
- {t}The server must be saved before you can use the status flag.{/t}
-{elseif !$is_acc}
- {t}The service must be saved before you can use the status flag.{/t}
-{/if}
-
-
-
- {html_options options=$Actions}
-
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/goNtpServer.tpl b/plugins/admin/systems/goNtpServer.tpl
deleted file mode 100644
index 25a91d432..000000000
--- a/plugins/admin/systems/goNtpServer.tpl
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
{t}Time server{/t}
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/goShareServer.tpl b/plugins/admin/systems/goShareServer.tpl
deleted file mode 100644
index 2c645c7f4..000000000
--- a/plugins/admin/systems/goShareServer.tpl
+++ /dev/null
@@ -1,33 +0,0 @@
-
{t}Shares{/t}
-
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/goSpamServer.tpl b/plugins/admin/systems/goSpamServer.tpl
deleted file mode 100644
index c8b58852f..000000000
--- a/plugins/admin/systems/goSpamServer.tpl
+++ /dev/null
@@ -1,129 +0,0 @@
-
-
- Spam tagging
-
-
-
-
- Trusted networks
-
-
-
-
-
-
-
-
-
-
-
-
- Flags
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Rules
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/goSpamServerRule.tpl b/plugins/admin/systems/goSpamServerRule.tpl
deleted file mode 100644
index 6448ab556..000000000
--- a/plugins/admin/systems/goSpamServerRule.tpl
+++ /dev/null
@@ -1,25 +0,0 @@
-
Edit spam rule
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/goSyslogServer.tpl b/plugins/admin/systems/goSyslogServer.tpl
deleted file mode 100644
index a7ed661a8..000000000
--- a/plugins/admin/systems/goSyslogServer.tpl
+++ /dev/null
@@ -1,9 +0,0 @@
-
{t}Syslog Service{/t} {t}enabled{/t}
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/goTerminalServer.tpl b/plugins/admin/systems/goTerminalServer.tpl
deleted file mode 100644
index 5fca2091f..000000000
--- a/plugins/admin/systems/goTerminalServer.tpl
+++ /dev/null
@@ -1,27 +0,0 @@
-
{t}Terminal service{/t}
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/goVirusServer.tpl b/plugins/admin/systems/goVirusServer.tpl
deleted file mode 100644
index af14a2b1c..000000000
--- a/plugins/admin/systems/goVirusServer.tpl
+++ /dev/null
@@ -1,172 +0,0 @@
-
-
-
-
- {t}Generic virus filtering{/t}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {t}Archive scanning{/t}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/gosaLogServer.tpl b/plugins/admin/systems/gosaLogServer.tpl
deleted file mode 100644
index 7dd032a36..000000000
--- a/plugins/admin/systems/gosaLogServer.tpl
+++ /dev/null
@@ -1,35 +0,0 @@
-
{t}GOsa logging database{/t}
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/ppd/class_printerPPDDialog.inc b/plugins/admin/systems/ppd/class_printerPPDDialog.inc
new file mode 100644
index 000000000..a93e91bb4
--- /dev/null
+++ b/plugins/admin/systems/ppd/class_printerPPDDialog.inc
@@ -0,0 +1,546 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account = TRUE;
+ var $attributes = array("cn");
+ var $objectclasses = array("whatever");
+
+ /* PPD Handling */
+ var $selectedPPD = false; // e.g. /vendor/device.ppd
+ var $ppdManager = false; // new ppdManager;
+ var $ppdConfig = false; // $this->ppdManager->loadProperties($this->selectedPPD['link']);
+ var $ppdList = array(); // Contains all Printer models
+ var $ppdListHeader = array(); // Contains all printer vendors
+
+ /* Paths */
+ var $pathToPPD = ""; // Base path, defined in gosa.conf e.g. "/var/spool/ppd/"
+ var $pathToModified = "modified/"; // used to store the modified ppds
+
+ /* Object Info */
+ var $cn = "" ; // Used to tag the ppds modified by the printer object,
+
+ /* If there is already a ppd file for the same type of printer,
+ * remember the path to ppd file and display a dialog which allows
+ * to overwrite the current ppd file.
+ */
+ var $add_ppd_later = "";
+ var $add_later_msg_dialog = NULL;
+
+ function printerPPDDialog (&$config, $dn= NULL, $ppdfile=NULL )
+ {
+ plugin::plugin ($config, $dn);
+ $this->depselect = $this->config->current['BASE'];
+
+ /* Get PPD path and remove double //, and add trailing / */
+ if(isset($_SESSION['config']->data['MAIN']['PPD_PATH'])){
+ $this->pathToPPD = $_SESSION['config']->data['MAIN']['PPD_PATH'];
+ $this->pathToPPD= preg_replace("/\/\//", "/", $this->pathToPPD);
+ if(!preg_match("/\/$/",$this->pathToPPD)){
+ $this->pathToPPD = $this->pathToPPD."/";
+ }
+ }else{
+ $this->pathToPPD = "";
+ }
+
+ /* It seams that we have an existing PPD path, so go on */
+ if(!((!is_dir($this->pathToPPD))||(empty($this->pathToPPD)))){
+
+ /* Load all available PPD files and sort them into an array */
+ $this->ppdManager= new ppdManager($this->pathToPPD);
+ $this->getPrinterReload ();
+
+ /* The user has already a valid PPD assigned
+ * Get some informations about this PPD
+ * and set it as selected.
+ * The ppdpath ['link'] should be relative from .../ppd/modified/
+ * e.g. "/Compaq/Compaq-J1200.ppd" */
+ if(($ppdfile!== NULL)&&(strlen($ppdfile)>0)){
+ $ppdfile = preg_replace("#".$this->pathToModified."#","",$ppdfile);
+ if(!file_exists($this->pathToPPD.$this->pathToModified.$ppdfile)){
+ print_red(sprintf(_("Can't open '%s', ppd settings resetted."),$ppdfile));
+ }else{
+ $res = $this->ppdManager->loadDescription($this->pathToPPD.$this->pathToModified.$ppdfile);
+ if($res){
+ $tmp = split("\n",$res);
+ $tmp3 = array();
+ $tmp3['name'] = trim(preg_replace("/^\-/","",trim($tmp[1])));
+ $tmp3['link'] = $ppdfile;
+ $tmp3['ppd'] = $res;
+ }
+ $this->selectedPPD = $tmp3;
+ }
+ }
+ }
+ }
+
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ /* Fill templating stuff */
+ $display= "";
+ $smarty= get_smarty();
+ $smarty->assign("ppdString", _("Can't get ppd informations."));
+ $smarty->assign("showOptions", "");
+
+ /* Check these paths */
+ $paths = array($this->pathToPPD, $this->pathToPPD.$this->pathToModified);
+
+ /* If one of our required paths is not available, stop here and display some info */
+ foreach($paths as $path){
+
+ /* Check if path is write/readable*/
+ $is_r = @is_readable($path);
+ if(((!is_dir($path))||(empty($path)) || (!$is_r)) && (!@mkdir($path))){
+ print_red(sprintf(_("The specified path '%s' which results from PPD_PATH in your gosa.conf is invalid, can't read/write any ppd informations."),$path));
+ /* Print out template */
+ $display.= $smarty->fetch(get_template_path('printerPPDDialog.tpl', TRUE,dirname(__FILE__)));
+ return($display);
+ }
+ }
+
+ // PPD selection / upload / dialog handling
+
+ /* Is there a new PPD file uploaded ? */
+ if((isset($_FILES['NewPPDFile']))&&(isset($_POST['SubmitNewPPDFile']))){
+ $file = ($_FILES['NewPPDFile']);
+ if($file['size'] != 0 ){
+ if($name = $this->AddPPD($file['tmp_name'])){
+ $this->SelectPPD($name);
+ }
+ }else{
+ print_red(_("Please specify a valid ppd file."));
+ }
+ }
+
+ /* Overwrite existing PPD file and select it as currently used for this object */
+ if(is_object($this->add_later_msg_dialog) && ($this->add_later_msg_dialog->is_confirmed()) && $this->add_ppd_later != ""){
+ if($name = $this->AddPPD($this->add_ppd_later,TRUE)){
+ $this->SelectPPD($name);
+ }
+ $this->add_ppd_later = "";
+ $this->add_later_msg_dialog = NULL;
+ }
+
+ /* Open a dialog that allow us to select different PPDs */
+ if(isset($_POST['SelectPPD'])){
+ $this->dialog= new printerPPDSelectionDialog($this->config,$this->dn,$this->ppdList,$this->ppdListHeader,$this->selectedPPD);
+ }
+
+ /* The selection dialog fpr PPDs is canceled */
+ if(isset($_POST['ClosePPDSelection'])){
+ unset($this->dialog);
+ $this->dialog=FALSE;
+ }
+
+ /* Div Selection */
+ if((isset($_GET['act']))&&($_GET['act']=="use")){
+ $this->SelectPPD(base64_decode($_GET['id']));
+ unset($this->dialog);
+ $this->dialog=FALSE;
+
+ }
+
+ /* if a dialog is open, print the dialog instead of this class */
+ if(is_object($this->dialog)){
+ $display = $this->dialog->execute();
+ return($display);
+ }
+
+ // ENDE PPD selection / upload / dialog handling
+
+ /* Give smarty the information it needs */
+ $smarty->assign("ppdString" ,$this->getPPDInformation());
+ $tmp= $this->generateProperties();
+ if ($tmp == ""){
+ $smarty->assign("showOptions", 0);
+ } else {
+ $smarty->assign("showOptions", 1);
+ $smarty->assign("properties",$this->generateProperties());
+ }
+
+ /* Print out template */
+ $display.= $smarty->fetch(get_template_path('printerPPDDialog.tpl', TRUE,dirname(__FILE__)));
+ return($display);
+ }
+
+
+ /* Select PPD */
+ function SelectPPD($name)
+ {
+ /* Replace base path we don't need it here
+ The path we need looks like this : "/Vendor/ModellName.ppd";
+ thats all */
+ $name = preg_replace("#".$this->pathToPPD."#","",$name);
+
+ /* Intialise some base vars */
+ $AbsoluteSourceName = $this->pathToPPD.$name;
+ $AbsoluteDestinationPath = $this->pathToPPD.$this->pathToModified;
+ $Vendor = ""; // Vendor
+ $Name = ""; // Name
+ $Modell = ""; // Modell
+ $PrinterName = ""; // The new name of the printer
+ $PPDName = "";
+
+ /* Force reload of config dialog */
+ $this->ppdConfig = false;
+ $this->selectedPPD['link'] = false;
+
+ /* Get PPD informations and set vendor / modell / name */
+ if((!file_exists($AbsoluteSourceName)) || (!is_readable($AbsoluteSourceName))){
+ print_red(sprintf(_("Can't select PPD file '%s', the file is not readable"),$AbsoluteSourceName));
+ return;
+ }
+ $res = $this->ppdManager->loadDescription($AbsoluteSourceName);
+ if($res){
+ $tmp = split("\n",$res);
+ $Name = trim(preg_replace("/^\-/","",trim($tmp[1])));
+ $Vendor = trim($tmp[0]);
+ $Model = trim(preg_replace("/".$Vendor."/","",$Name));
+ }
+
+ $PrinterName = $this->cn."-".preg_replace("/[^a-z0-9-_\.]/i","_",$Name);
+ $PPDName = $Vendor."/".$PrinterName.".ppd";
+
+ /* Create the vendors path, if it doesn't exists already */
+ if(!is_dir($AbsoluteDestinationPath.$Vendor)){
+ if(!(@mkdir($AbsoluteDestinationPath.$Vendor))){
+ print_red(sprintf(_("Can't create folder '%s' for the uploaded ppd file."),$AbsoluteDestinationPath.$Vendor));
+ return(false);
+ }
+ }
+
+ /* Create destination file handle */
+ $fp = @fopen($AbsoluteDestinationPath.$PPDName,"w+");
+ if(!$fp){
+ print_red(sprintf(_("Can't create file '%s' to store modifed ppd informations."),$AbsoluteDestinationPath.$PPDName));
+ return(false);
+ }
+
+ $str = file_get_contents($AbsoluteSourceName);
+ fputs($fp,$str);
+ @fclose($fp);
+
+ //$this->ppdManager->updateAttribute($filename,"NO_SECTION","ModelName",$printerName);
+
+ $tmp3['link'] =$PPDName;
+ $this->selectedPPD = $tmp3;
+ $this->getPrinterReload();
+ return($PPDName);
+ }
+
+
+ /* This function adds a new ppd file to the list of available ppds.
+ All required paths and files will be created
+ $_PathOnHdd e.g. = /tmp/PHP_tmpfile213452 */
+ function AddPPD($_PathOnHdd,$overwrite = FALSE)
+ {
+ /* Check if file exists && is readable */
+ if((!is_file($_PathOnHdd)) || (!is_readable($_PathOnHdd))){
+ print_red(sprintf(_("Can't add new ppd file, the source file '%s' is not accessible."),$_PathOnHdd));
+ return(false);
+ }
+
+ /* Reload list to detect changes e.g. a file has been deleted */
+ $this->getPrinterReload();
+
+ /* Get Description from ppd, & parse out some informations */
+ $res = @$this->ppdManager->loadDescription($_PathOnHdd);
+ if($res){
+ $tmp = split("\n",$res);
+ $name = trim(preg_replace("/^\-/","",trim($tmp[1])));
+ $vendor = trim($tmp[0]);
+ $model = trim(preg_replace("/".$vendor."/","",$name));
+ }
+
+ /* Check if parse was successfull */
+ if(empty($name) || empty($vendor)){
+ print_red(sprintf(_("The given ppd file '%s' seams to be invalid, can't get any model or vendor informations."),$_PathOnHdd));
+ return(false);
+ }
+
+ /* Prepare list of ppds */
+ if(!isset($this->ppdList[$vendor])){
+ $this->ppdList[$vendor] = array();
+ }
+
+ /* Create ppd file and fill in the source contents */
+ $ppdname = $vendor."/".$name.".ppd";
+ $filename = $this->pathToPPD.preg_replace("/[^a-z0-9-_\.\/]/i","_",$ppdname);
+ $filename = $this->pathToPPD.$ppdname;
+ $contents = file_get_contents($_PathOnHdd);
+
+
+ /* Check if this ppd already exists */
+ $found = false;
+ foreach($this->ppdList[$vendor] as $key => $val){
+ if(preg_match("/".$model.".*/i",$key)){
+ $found = true;
+ if(!$overwrite){
+ if(!copy($_PathOnHdd,$_PathOnHdd."_back")){
+ print_red(sprintf(_("Can't add new ppd file, the source file '%s' is not accessible."),$_PathOnHdd));
+ }else{
+ $this->add_ppd_later = $_PathOnHdd."_back";
+ $this->add_later_msg_dialog = new msg_dialog(_("Overwrite existing PPD"),
+ _("There is already a ppd file for this kind of printer. Do you want to overwrite it?"),CONFIRM_DIALOG);
+ }
+ return;
+ }
+ }
+ }
+
+ /* Create the vendors path, if it doesn't exists already */
+ if(!is_dir($this->pathToPPD.$vendor)){
+ if(!(@mkdir($this->pathToPPD.$vendor))){
+ print_red(sprintf(_("Can't create folder '%s' for the uploaded ppd file."),$this->pathToPPD.$vendor));
+ return(false);
+ }
+ }
+
+ /* Open file handle */
+ $fp = fopen($filename,"w+");
+
+ /* Check file handle & contents */
+ if(!$fp){
+ print_red(sprintf(_("Can't save file '%s'."),$filename));
+ return;
+ }
+ if(empty($contents)){
+ print_red(_("Uploaded ppd file is empty, can't create new ppd file."));
+ return;
+ }
+
+ /* Fille file with data */
+ fputs($fp,$contents);
+ @fclose($fp);
+
+ /* Our job is done here */
+ return($ppdname);
+ }
+
+
+ /* This function reloads the list of available printers/vendors
+ $this->ppdListHeader
+ Compaq => 1
+ $this->ppdList
+ Compaq => Compaq IJ1200 => name => Compaq IJ1200
+ link => /var/spool/ppd/Compaq/Compaq-J1200.ppd
+ ppd => Compaq - Co
+ */
+ function getPrinterReload()
+ {
+ if(is_readable($this->pathToPPD)){
+ $tmp = @$this->ppdManager->getPrinterList(true);
+
+ $this->ppdListHeader = $this->ppdList = array();
+
+ /* Sort all available files, and create header (Vendor index) */
+ foreach($tmp as $file=>$ppd){
+
+ if(preg_match("#".$this->pathToModified."#",$file)) continue;
+
+ $tmp2 = split("\n",$ppd);
+ if(!isset($this->ppdListHeader[$tmp2[0]])){
+ $this->ppdListHeader[$tmp2[0]]=0;
+ }
+ $tmp3['name'] =preg_replace("/^ -/","",$tmp2[1]." - ".$tmp2[2]);
+ $tmp3['link'] =$file;
+ $tmp3['ppd'] =$ppd;
+ $this->ppdListHeader[$tmp2[0]]++;
+ $this->ppdList[$tmp2[0]][preg_replace("/^ -/","",$tmp2[1]." - ".$tmp2[2])]=$tmp3;
+ }
+ }
+ }
+
+
+ /* Save all options posted from ppd dialog */
+ function save_object()
+ {
+ if(!((isset($_POST['PPDDisSubmitted'])) && (is_array($this->ppdConfig)))){
+ return;
+ }
+
+ foreach($this->ppdConfig as $cat => $obj){
+ foreach($obj as $attr => $attributes){
+ if(isset($_POST[base64_encode($attributes['_name'])])){
+ $this->ppdConfig[$cat][$attr]['_default'] = $_POST[base64_encode($attributes['_name'])];
+ }
+ }
+ }
+ }
+
+
+ /* Save modified ppd */
+ function save_ppd()
+ {
+ if($this->ppdManager){
+ $this->ppdManager->saveProperties($this->pathToPPD.$this->pathToModified.$this->selectedPPD['link'],$this->ppdConfig);
+ }
+ }
+
+
+ /* Return selected ppd path, if none is selected then false */
+ function save()
+ {
+ /* return the selected PPD, and in future the selected options too */
+ return($this->pathToModified.$this->selectedPPD['link']);
+ }
+
+
+ /* Get Information for a single PPD entry
+ * This will be shown on top of template
+ */
+ function getPPDInformation()
+ {
+ $str = "none";
+ if(!empty($this->selectedPPD)){
+ $str = $this->ppdManager->loadDescription($this->pathToPPD.$this->pathToModified.$this->selectedPPD['link']);
+ }
+ return($str) ;
+ }
+
+
+ /* Display all options from the selected ppd file */
+ function generateProperties()
+ {
+ /* Set Headline */
+ $str = "";
+ $feed= "";
+
+ $s_ppd = $this->pathToPPD.$this->pathToModified.$this->selectedPPD['link'];
+
+ /* If ppd exists and is readable */
+ if((!empty($this->selectedPPD['link']))&&(file_exists($s_ppd))){
+
+ /* If there is no initial Configuration, load it */
+ if($this->ppdConfig == false){
+ $this->ppdConfig = $this->ppdManager->loadProperties($s_ppd);
+ }
+
+ /* Create a table */
+ $str .= "
";
+
+ /* Input all data to the table */
+ foreach($this->ppdConfig as $cat => $obj){
+
+ /* Add new category */
+ $str .= "$feed";
+ if ($feed == ""){
+ $feed= " ";
+ }
+ $str .= ""._("Section")." '".$cat."' ";
+ $str .= " ";
+
+ /* Add attributes of the current category */
+ foreach($obj as $attr => $settings){
+
+ /* Skip all entries beginning with _ */
+ if($attr[0] == "_") continue;
+
+ /* Prepare data */
+ $values = array();
+ $name = $settings['_name'];
+
+ if (!isset($settings['_default'])){
+ $default = "";
+ } else {
+ $default = $settings['_default'];
+ }
+
+ $type = $settings['_type'];
+
+ /* Add name to table */
+ $str .= "\n";
+ $str .= $name." \n";
+ $str .= " \n";
+
+ /* Get all values */
+ foreach( $settings as $vname => $value){
+ if($vname[0] != "_"){
+ $values[$vname]= $value;
+ }
+ }
+
+ /* preparing Html output
+ * Supported types are PickOne/Boolean
+ */
+
+ /* If type is PickOne, create a select box */
+ if(($type == "PickOne")||(($type=="Boolean")&&(count($values)>1))){
+
+ $str .= "\n";
+ foreach($values as $optionKey => $value){
+ $selected = "";
+ if($optionKey == $default){
+ $selected = " selected ";
+ }
+ $str .= "".$value." \n";
+ }
+ $str .= " \n";
+
+ }elseif($type == "Boolean"){
+
+ /* If type is Boolean & no values are given */
+ $str .= "\n";
+ if($default == "False"){
+ $str .= ""._("True")." \n";
+ $str .= ""._("False")." \n";
+ }else{
+ $str .= ""._("True")." \n";
+ $str .= ""._("False")." \n";
+ }
+ $str .= " \n";
+
+ }else{
+ print_red(sprintf(_("Unsupported ppd type '%s' used for '%s' "),$type,$name));
+ }
+ $str .= " \n";
+ }
+ }
+ $str .= "
\n";
+ }
+ return($str);
+ }
+
+ function removeModifiedPPD()
+ {
+ $path = $this->pathToPPD.$this->pathToModified.$this->selectedPPD['link'];
+
+ if(file_exists($path)){
+ if(is_writeable($path)){
+ if(!@unlink($path)){
+ print_red(sprintf(_("Removing old ppd file '%s' failed."),$path));
+ }
+ }else{
+ print_red(sprintf(_("Removing old ppd file '%s' failed. File is not accessible."),$path));
+ }
+ }else{
+ print_red(sprintf(_("Removing old ppd file '%s' failed. File does not exists or is not accessible."),$path));
+ }
+ }
+
+ function update_ppd_url()
+ {
+ $this->SelectPPD("modified/".$this->selectedPPD['link']);
+ }
+
+ function check()
+ {
+ $message = plugin::check();
+ if(empty($this->selectedPPD['link'])){
+ $message[] = _("Please select a valid ppd file or use 'Cancel' to go back to printer configuration.");
+ }
+ return($message);
+ }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/ppd/class_printerPPDSelectionDialog.inc b/plugins/admin/systems/ppd/class_printerPPDSelectionDialog.inc
new file mode 100644
index 000000000..d4f5d16b8
--- /dev/null
+++ b/plugins/admin/systems/ppd/class_printerPPDSelectionDialog.inc
@@ -0,0 +1,197 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account = FALSE;
+ var $attributes = array();
+ var $objectclasses = array("whatever");
+
+ var $list =array();
+ var $header =array();
+ var $current_del_id = "";
+ var $Vendor = "";
+
+ function printerPPDSelectionDialog (&$config, $dn= NULL,$list=false,$headers=false,$ppd=false)
+ {
+ plugin::plugin ($config, $dn);
+ $this->list = $list;
+ $this->header = $headers;
+ $this->depselect = $this->config->current['BASE'];
+
+ if(!isset($_SESSION['printerPPDSelectionDialog'])){
+ $_SESSION['printerPPDSelectionDialog']['regex'] = "*";
+ }
+
+ /* Order the manufacturers index */
+ ksort($this->header);
+ }
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ /* Fill templating stuff */
+ $smarty= get_smarty();
+ $display= "";
+ $s_action = "none";
+
+ $regex = $_SESSION['printerPPDSelectionDialog']['regex'];
+
+ if(isset($_GET['search'])){
+ $regex = $_GET['search']."*";
+ }
+
+ if(isset($_POST['regex'])){
+ $regex= $_POST['regex'];
+ }
+
+ $regex = str_replace("**","*",$regex);
+ $_SESSION['printerPPDSelectionDialog']['regex'] = $regex;
+
+
+ /* Delete requested, check if everything is ok and display confirmation dialog */
+ if(isset($_GET['act']) && $_GET['act'] == "del"){
+
+ /* Get id and check if id is valid */
+ $id_to_del = base64_decode($_GET['id']);
+ $found = "";
+ foreach($this->list[$this->Vendor] as $key => $data){
+ if($data['link'] == $id_to_del){
+ $found = $key;
+ break;
+ }
+ }
+ if(!empty($found)){
+ $this->current_del_id = $id_to_del;
+
+ $smarty->assign("warning", sprintf(_("You're about to delete the ppd file '%s' at '%s'."), $found,$id_to_del));
+ return($smarty->fetch(get_template_path('remove_ppd.tpl', TRUE)));
+
+ }else{
+ print_red(sprintf(_("Could not found specified ppd file '%s'."),$id_to_del));
+ }
+ }
+
+ /* Deletion confirmed */
+ if(isset($_POST['delete_ppd_confirm']) && !empty($this->current_del_id)){
+
+ /* check if file is removeable */
+ if(is_writeable($this->current_del_id)){
+ $is_ok = @unlink($this->current_del_id);
+
+ /* Update ppd list */
+ if($is_ok){
+ foreach($this->list as $vendor => $ppds){
+ foreach($ppds as $ppd => $data){
+ if($data['link'] == $this->current_del_id){
+ unset($this->list[$vendor][$ppd]);
+ }
+ }
+ }
+ }
+ }else{
+ $is_ok = false;
+ }
+
+ if(!$is_ok){
+ print_red(_("Something went wrong while trying to remove the ppd file from server, possibly we have no write access."));
+ }
+ }
+
+
+ /** Added **/
+ $list = array();
+ foreach($this->list as $cat => $ppds){
+ foreach($ppds as $ppd){
+ if(preg_match("/^".str_replace("*",".*",$regex)."/i",$ppd['ppd'])){
+ if(is_readable($ppd['link'])){
+ $list[$ppd['link']] = $ppd;
+ }
+ }
+ }
+ }
+
+ if((isset($_GET['act']))&&($_GET['act']=="open")) {
+
+ if((!empty($_GET['id'])) && (!isset( $this->header[base64_decode($_GET['id'])]))){
+ print_red(sprintf(_("Selected vendor '%s' does not exists in our list of ppds."),base64_decode($_GET['id'])));
+ $this->Vendor = "";
+ }else{
+ $this->Vendor = base64_decode($_GET['id']);
+ }
+ }
+
+ $div = new divSelectBox("printerPPDSelectionDialog");
+ $div ->SetHeight(450);
+ $div ->SetSummary(_("Printer ppd selection."));
+
+ $linkopen = "
+ %s
+ ";
+ $uselink = "
%s ";
+ $dellink = "
+
+ ";
+
+ if(empty($this->Vendor)){
+ foreach($this-> header as $key => $entry){
+ $div ->AddEntry (array(
+ array("string"=>sprintf($linkopen,base64_encode($key),$key),"attach"=>"style='border-right:0px;'")
+ ));
+ }
+ }else{
+ $div ->AddEntry (array(
+ array("string"=>sprintf($linkopen,"",".. ["._("back")."]"),"attach"=>"style='border-right:0px;'")
+ ));
+ foreach($list as $key => $ppd){
+ if(preg_match("/^".$this->Vendor."/",$ppd['ppd'])){
+
+ if(is_writeable($ppd['link'])){
+ $del_str = sprintf($dellink,base64_encode($key));
+ }else{
+ $del_str = "";
+ }
+
+ $div ->AddEntry (array(
+ array("string"=>sprintf($uselink,base64_encode($key),$ppd['ppd'])),
+ array("string"=>$del_str,"attach"=>"style='border-right:0px;'")
+
+ ));
+ }
+ }
+ }
+
+ $smarty->assign("List", $div -> DrawList());
+ $smarty->assign("search_image", get_template_path('images/search.png'));
+ $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
+ $smarty->assign("tree_image", get_template_path('images/tree.png'));
+ $smarty->assign("alphabet", generate_alphabet());
+ $smarty->assign("apply", apply_filter());
+ $smarty->assign("regex", $regex);
+
+ $display.= $smarty->fetch(get_template_path('printerPPDSelectionDialog.tpl', TRUE,dirname(__FILE__)));
+ return($display);
+ }
+
+ function save_object()
+ {
+ }
+
+ function check(){
+ }
+
+ /* Save to LDAP */
+ function save()
+ {
+ return $this->selectedPPD;
+ }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/ppd/printerPPDDialog.tpl b/plugins/admin/systems/ppd/printerPPDDialog.tpl
new file mode 100644
index 000000000..761d00516
--- /dev/null
+++ b/plugins/admin/systems/ppd/printerPPDDialog.tpl
@@ -0,0 +1,24 @@
+
{t}Printer driver{/t}
+
+{if $showOptions eq 1}
+
+
{t}Options{/t}
+{$properties}
+{/if}
+
+
+
+
+
diff --git a/plugins/admin/systems/ppd/printerPPDSelectionDialog.tpl b/plugins/admin/systems/ppd/printerPPDSelectionDialog.tpl
new file mode 100644
index 000000000..b6cad00b8
--- /dev/null
+++ b/plugins/admin/systems/ppd/printerPPDSelectionDialog.tpl
@@ -0,0 +1,48 @@
+
+
+
+
+
+ {t}Select objects to add{/t}
+
+
+
+ {$List}
+
+
+
+
+
+
+
+ {t}Filters{/t}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/ppd/remove_ppd.tpl b/plugins/admin/systems/ppd/remove_ppd.tpl
new file mode 100644
index 000000000..6d28ba9ec
--- /dev/null
+++ b/plugins/admin/systems/ppd/remove_ppd.tpl
@@ -0,0 +1,15 @@
+
+
{t}Warning{/t}
+
+
+ {$warning}
+
+
+
+ {t}The ppd file will be removed from the server and can not be restored.{/t}
+
+
+
+
+
+
diff --git a/plugins/admin/systems/printerPPDDialog.tpl b/plugins/admin/systems/printerPPDDialog.tpl
deleted file mode 100644
index 761d00516..000000000
--- a/plugins/admin/systems/printerPPDDialog.tpl
+++ /dev/null
@@ -1,24 +0,0 @@
-
{t}Printer driver{/t}
-
-{if $showOptions eq 1}
-
-
{t}Options{/t}
-{$properties}
-{/if}
-
-
-
-
-
diff --git a/plugins/admin/systems/printerPPDSelectionDialog.tpl b/plugins/admin/systems/printerPPDSelectionDialog.tpl
deleted file mode 100644
index b6cad00b8..000000000
--- a/plugins/admin/systems/printerPPDSelectionDialog.tpl
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-
-
-
- {t}Select objects to add{/t}
-
-
-
- {$List}
-
-
-
-
-
-
-
- {t}Filters{/t}
-
-
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/remove_dhcp.tpl b/plugins/admin/systems/remove_dhcp.tpl
deleted file mode 100644
index 39fb19bb6..000000000
--- a/plugins/admin/systems/remove_dhcp.tpl
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
{t}Warning{/t}
-
-
- {$warning}
- {t}This includes 'all' DHCP subsections that are located within this section. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t}
-
-
-
- {t}Best thing to do before performing this action would be to save the current contents of your LDAP tree in a file. So - if you've done so - press 'Delete' to continue or 'Cancel' to abort.{/t}
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/remove_glpi.tpl b/plugins/admin/systems/remove_glpi.tpl
deleted file mode 100644
index 4106caf06..000000000
--- a/plugins/admin/systems/remove_glpi.tpl
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
{t}Warning{/t}
-
-
- {$warning}
- {t}Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t}
-
-
-
- {t}Best thing to do before performing this action would be to save the current contents of your MySql database in a file. So - if you've done so - press 'Delete' to continue or 'Cancel' to abort.{/t}
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/remove_ppd.tpl b/plugins/admin/systems/remove_ppd.tpl
deleted file mode 100644
index 6d28ba9ec..000000000
--- a/plugins/admin/systems/remove_ppd.tpl
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
{t}Warning{/t}
-
-
- {$warning}
-
-
-
- {t}The ppd file will be removed from the server and can not be restored.{/t}
-
-
-
-
-
-
diff --git a/plugins/admin/systems/servDNSeditZoneEntries.tpl b/plugins/admin/systems/servDNSeditZoneEntries.tpl
deleted file mode 100644
index 9c0428c29..000000000
--- a/plugins/admin/systems/servDNSeditZoneEntries.tpl
+++ /dev/null
@@ -1,27 +0,0 @@
-
{t}This dialog allows you to configure all components of this DNS zone on a single list.{/t}
-
-{if $disableDialog}
-
- {t}This dialog can't be used until the currently edited zone was saved or the zone entry exists in the ldap database.{/t}
-
-{else}
-
- {$table}
-
-
-{/if}
-
-
-
-
-
-
diff --git a/plugins/admin/systems/servRepository.tpl b/plugins/admin/systems/servRepository.tpl
deleted file mode 100644
index ca42710c1..000000000
--- a/plugins/admin/systems/servRepository.tpl
+++ /dev/null
@@ -1,9 +0,0 @@
-{$Repositories}
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/servRepositorySetup.tpl b/plugins/admin/systems/servRepositorySetup.tpl
deleted file mode 100644
index 29691ec44..000000000
--- a/plugins/admin/systems/servRepositorySetup.tpl
+++ /dev/null
@@ -1,58 +0,0 @@
-
{t}Repository{/t}
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/servdhcp.tpl b/plugins/admin/systems/servdhcp.tpl
deleted file mode 100644
index 846af22ff..000000000
--- a/plugins/admin/systems/servdhcp.tpl
+++ /dev/null
@@ -1,35 +0,0 @@
-{if $dns_take_over}
-
-
-
- {t}DHCP take over will take place when saving this entry. Choose 'Cancel' to abort.{/t}
-
-
-
-{else}
-
-{/if}
-
-
-
-
-
-
-
-
- {t}DNS take over initiated{/t}
- {$warning}
- {t}This includes 'all' DNS zones that are located within this server. Please double check if your really want to do this.{/t}
-
- {$warning2}
-
-
-
-
- {t}Following objects will be taken over{/t} :
-
-
-
{$info}
-
-
-
-
-{else}
-
-
-
-
-
-{/if}
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/servdnseditzone.tpl b/plugins/admin/systems/servdnseditzone.tpl
deleted file mode 100644
index 1136dba53..000000000
--- a/plugins/admin/systems/servdnseditzone.tpl
+++ /dev/null
@@ -1,177 +0,0 @@
-
{t}Generic{/t}
-
-
-
{t}SOA record{/t}
-
-
-
-
-
-
-
- {t}MxRecords{/t}
-
-
-
- {t}Global zone records{/t}
-{render acl=$ACLs}
- {$records}
-{/render}
-
-
-
-
-
diff --git a/plugins/admin/systems/services/ServiceAddDialog.tpl b/plugins/admin/systems/services/ServiceAddDialog.tpl
new file mode 100644
index 000000000..f055f33c1
--- /dev/null
+++ b/plugins/admin/systems/services/ServiceAddDialog.tpl
@@ -0,0 +1,32 @@
+
+
+ {t}Adding a new service to the current server{/t}
+
+
+
+{t}This dialog allows you to add new services to the currenty edited server object. The box below shows all available but not already used services.{/t}
+
+
+
+{if $Services}
+
+
{t}Service to add{/t}
+
+
+ {html_options options=$Services }
+
+{else}
+
+ {t}All available services are already in use.{/t}
+
+{/if}
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/class_ServiceAddDialog.inc b/plugins/admin/systems/services/class_ServiceAddDialog.inc
new file mode 100644
index 000000000..47e97012d
--- /dev/null
+++ b/plugins/admin/systems/services/class_ServiceAddDialog.inc
@@ -0,0 +1,34 @@
+"Config object" , "dn"=>"Object dn");
+
+ /* This plugin does not have any ocs */
+ var $objectclasses = array();
+ var $parent = NULL;
+
+ function ServiceAddDialog(&$config,$dn,$parent)
+ {
+ plugin::plugin($config);
+ $this->parent = $parent;
+ }
+
+ function execute()
+ {
+ $smarty = get_smarty();
+ $services = $this->parent->getAllUnusedServices();
+ natcasesort($services);
+ $smarty->assign("Services",$services);
+ return($smarty->fetch(get_template_path("ServiceAddDialog.tpl", TRUE,dirname(__FILE__))));
+ }
+
+ function check(){ return array();}
+ function save_object(){;}
+ function save(){}
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/class_goService.inc b/plugins/admin/systems/services/class_goService.inc
new file mode 100644
index 000000000..edfd3d7d5
--- /dev/null
+++ b/plugins/admin/systems/services/class_goService.inc
@@ -0,0 +1,238 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* This plugin only writes its objectClass */
+ var $objectclasses = array();
+ var $attributes = array();
+ var $StatusFlag = "";
+
+ /* This class can't be assigned twice so it conflicts with itsself */
+ var $conflicts = array();
+ var $dn = NULL;
+ var $cn = "";
+ var $DisplayName = "";
+ var $view_logged =FALSE;
+
+
+ /* Construcktion */
+ function goService(&$config,$dn)
+ {
+ plugin::plugin($config,$dn);
+ $this->DisplayName = _("Empty service");
+ }
+
+
+ /* Create content */
+ function execute()
+ {
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","server/".get_class($this),$this->dn);
+ }
+
+ $str ="
".
+ " ".
+ " ".
+ "
";
+ return($str);
+ }
+
+
+ /* Get service information for serverService plugin */
+ function getListEntry()
+ {
+
+ $this->updateStatusState();
+
+ /* Assign status flag */
+ if(!empty($this->StatusFlag)){
+ $flag = $this->StatusFlag;
+ $fields['Status'] = $this->$flag;
+ }else{
+ $fields['Status'] = "";
+ }
+
+ /* Name displayed in service overview */
+ $fields['Message'] = _("Empty service");
+
+ /* Allow/disallow some functions */
+ $fields['AllowStart'] = $this->acl_is_writeable("start");
+ $fields['AllowStop'] = $this->acl_is_writeable("stop");
+ $fields['AllowRestart'] = $this->acl_is_writeable("restart");
+ $fields['AllowRemove'] = $this->acl_is_removeable();
+ $fields['AllowEdit'] = true;
+ return($fields);
+ }
+
+
+ /* Remove service */
+ function remove_from_parent()
+ {
+ if(!$this->initially_was_account || !$this->acl_is_removeable()){
+ return;
+ }
+
+ plugin::remove_from_parent();
+
+ /* Remove status flag, it is not a memeber of
+ this->attributes, so ensure that it is deleted too */
+ if(!empty($this->StatusFlag)){
+ $this->attrs[$this->StatusFlag] = array();
+ }
+
+ /* Check if this is a new entry ... add/modify */
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cat($this->dn,array("objectClass"));
+ if($ldap->count()){
+ $ldap->cd($this->dn);
+ $ldap->modify($this->attrs);
+ }else{
+ $ldap->cd($this->dn);
+ $ldap->add($this->attrs);
+
+ }
+
+ new log("remove","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+
+ show_ldap_error($ldap->get_error(), sprintf(_("Removing of server services/".get_class($this)." - (".$this->DisplayName.") with dn '%s' failed."),$this->dn));
+ $this->handle_post_events("remove");
+ }
+
+
+ /* Save service */
+ function save()
+ {
+ plugin::save();
+ /* Check if this is a new entry ... add/modify */
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cat($this->dn,array("objectClass"));
+ if($ldap->count()){
+ $ldap->cd($this->dn);
+ $ldap->modify($this->attrs);
+ }else{
+ $ldap->cd($this->dn);
+ $ldap->add($this->attrs);
+ }
+ if($this->initially_was_account){
+ new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ $this->handle_post_events("modify");
+ }else{
+ $this->handle_post_events("add");
+ new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }
+ show_ldap_error($ldap->get_error(), sprintf(_("Saving of server services/".get_class($this)." - (".$this->DisplayName.") with dn '%s' failed."),$this->dn));
+ }
+
+
+ /* Directly save new status flag */
+ function setStatus($value)
+ {
+ if($value == "none") return;
+
+ /* Can't set status flag for new services (Object doesn't exists in ldap tree) */
+ if(!$this->initially_was_account) return;
+
+ /* Can't set status flag, if no flag is specified */
+ if(empty($this->StatusFlag)){
+ return;
+ }
+
+ /* Get object (server), update status flag and save changes */
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->dn);
+ $ldap->cat($this->dn,array("objectClass"));
+ if($ldap->count()){
+
+ $tmp = $ldap->fetch();
+ for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
+ $attrs['objectClass'][] = $tmp['objectClass'][$i];
+ }
+ $flag = $this->StatusFlag;
+ $attrs[$flag] = $value;
+ $this->$flag = $value;
+ $ldap->modify($attrs);
+ show_ldap_error($ldap->get_error(), sprintf(_("Set status flag for server services/".get_class($this)." - (".$this->DisplayName.") with dn '%s' failed."),$this->dn));
+ $this->action_hook();
+ }
+ }
+
+
+ function check()
+ {
+ $message = plugin::check();
+ return($message);
+ }
+
+
+ function save_object()
+ {
+ plugin::save_object();
+ }
+
+
+ function action_hook($add_attrs= array())
+ {
+ /* Find postcreate entries for this class */
+ $command= $this->config->search(get_class($this), "ACTION_HOOK",array('menu','tabs'));
+ if ($command != ""){
+
+ /* Walk through attribute list */
+ foreach ($this->attributes as $attr){
+ if (!is_array($this->$attr)){
+ $command= preg_replace("/%$attr/", $this->$attr, $command);
+ }
+ }
+ $command= preg_replace("/%dn/", $this->dn, $command);
+
+ /* Additional attributes */
+ foreach ($add_attrs as $name => $value){
+ $command= preg_replace("/%$name/", $value, $command);
+ }
+
+ /* If there are still some %.. in our command, try to fill these with some other class vars */
+ if(preg_match("/%/",$command)){
+ $attrs = get_object_vars($this);
+ foreach($attrs as $name => $value){
+ if(!is_string($value)) continue;
+ $command= preg_replace("/%$name/", $value, $command);
+ }
+ }
+
+ if (check_command($command)){
+ @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
+ $command, "Execute");
+
+ exec($command);
+ } else {
+ $message= sprintf(_("Command '%s', specified as ACTION_HOOK for plugin '%s' doesn't seem to exist."), $command, get_class($this));
+ print_red ($message);
+ }
+ }
+ }
+
+
+ /* Get updates for status flag */
+ function updateStatusState()
+ {
+ if(empty($this->StatusFlag)) return;
+
+ $attrs = array();
+ $flag = $this->StatusFlag;
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->cn);
+ $ldap->cat($this->dn,array($flag));
+ if($ldap->count()){
+ $attrs = $ldap->fetch();
+ }
+ if(isset($attrs[$flag][0])){
+ $this->$flag = $attrs[$flag][0];
+ }
+ }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/cups/class_goCupsServer.inc b/plugins/admin/systems/services/cups/class_goCupsServer.inc
new file mode 100644
index 000000000..6fa572b9d
--- /dev/null
+++ b/plugins/admin/systems/services/cups/class_goCupsServer.inc
@@ -0,0 +1,85 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* This plugin only writes its objectClass */
+ var $objectclasses = array("goCupsServer");
+ var $attributes = array();
+ var $StatusFlag = "goCupsServerStatus";
+
+ /* This class can't be assigned twice so it conflicts with itsself */
+ var $conflicts = array("goCupsServer");
+
+ var $DisplayName = "";
+ var $dn = NULL;
+ var $acl;
+ var $cn = "";
+ var $goCupsServerStatus = "";
+ var $view_logged =FALSE;
+
+ function goCupsServer(&$config,$dn)
+ {
+ goService::goService($config,$dn);
+ $this->DisplayName = _("Print service");
+ }
+
+
+ function execute()
+ {
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","server/".get_class($this),$this->dn);
+ }
+
+ $smarty = get_smarty();
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,$this->$attr);
+ }
+ return($smarty->fetch(get_template_path("goCupsServer.tpl",TRUE,dirname(__FILE__))));
+ }
+
+ function getListEntry()
+ {
+ $fields = goService::getListEntry();
+ $fields['Message'] = _("Print service");
+ $fields['AllowEdit'] = false;
+ return($fields);
+ }
+
+ function check()
+ {
+ $message = plugin::check();
+ return($message);
+ }
+
+ function save_object()
+ {
+ plugin::save_object();
+ }
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Cups"),
+ "plDescription" => _("Print service")." ("._("Services").")",
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 100,
+ "plSection" => array("administration"),
+ "plCategory" => array("server"),
+
+ "start" => _("Start"),
+ "stop" => _("Stop"),
+ "restart" => _("Restart"),
+
+ "plProvidedAcls"=> array()
+ ));
+ }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/cups/goCupsServer.tpl b/plugins/admin/systems/services/cups/goCupsServer.tpl
new file mode 100644
index 000000000..e10bd2f67
--- /dev/null
+++ b/plugins/admin/systems/services/cups/goCupsServer.tpl
@@ -0,0 +1,9 @@
+
{t}Print Service{/t} {t}enabled{/t}
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/dhcp/class_dhcpAdvanced.inc b/plugins/admin/systems/services/dhcp/class_dhcpAdvanced.inc
new file mode 100644
index 000000000..43f583152
--- /dev/null
+++ b/plugins/admin/systems/services/dhcp/class_dhcpAdvanced.inc
@@ -0,0 +1,146 @@
+is_account= TRUE;
+ $this->setAutoStatements();
+ $this->setAutoOptions();
+ }
+
+ function execute()
+ {
+ /* Check for interaction */
+ if (isset($_POST['add_statement']) && $_POST['addstatement'] != ""){
+ $key= preg_replace('/^([a-z0-9-]+)\s(.*)$/', '\\1', get_post('addstatement'));
+ $val= preg_replace("/^$key\s*/", '', get_post('addstatement'));
+ $this->statements[$key]= $val;
+ }
+ if (isset($_POST['delete_statement']) && isset($_POST['dhcpstatements'])){
+ $key= preg_replace('/([a-z0-9-]+)\s(.*)$/', '\\1', get_post('dhcpstatements'));
+ if (in_array($key, $this->autoStatements)){
+ print_red(_("Can't delete automatic statements. Please use the fields above."));
+ } else {
+ unset($this->statements[$key]);
+ }
+ }
+ if (isset($_POST['add_option']) && $_POST['addoption'] != ""){
+ $key= preg_replace('/^([a-z0-9-]+)\s(.*)$/', '\\1', get_post('addoption'));
+ $val= preg_replace("/^$key\s*/", '', get_post('addoption'));
+ $this->options[$key]= $val;
+ }
+ if (isset($_POST['delete_option']) && isset($_POST['dhcpoptions'])){
+ $key= preg_replace('/([a-z0-9-]+)\s(.*)$/', '\\1', get_post('dhcpoptions'));
+ if (in_array($key, $this->autoOptions)){
+ print_red(_("Can't delete automatic options. Please use the fields above."));
+ } else {
+ unset($this->options[$key]);
+ }
+ }
+
+ $smarty= get_smarty();
+
+ /* Assign arrays */
+ $statements= array();
+ foreach ($this->statements as $key => $val){
+ if (in_array($key, $this->autoStatements)){
+ $statements[$key]= "$key $val ["._("automatic")."]";
+ } else {
+ $statements[$key]= "$key $val";
+ }
+ }
+ $smarty->assign("dhcpstatements", $statements);
+ $options= array();
+ foreach ($this->options as $key => $val){
+ if (in_array($key, $this->autoOptions)){
+ $options[$key]= "$key $val ["._("automatic")."]";
+ } else {
+ $options[$key]= "$key $val";
+ }
+ }
+ $smarty->assign("dhcpoptions", $options);
+
+ /* Show main page */
+ $smarty->assign("show_advanced", $this->show_advanced);
+ return ($smarty->fetch (get_template_path('dhcp_advanced.tpl', TRUE,dirname(__FILE__))));
+ }
+
+ function remove_from_parent()
+ {
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ if (isset($_POST['show_advanced'])){
+ $this->show_advanced= TRUE;
+ }
+ if (isset($_POST['hide_advanced'])){
+ $this->show_advanced= FALSE;
+ }
+ }
+
+
+ /* Check values */
+ function check()
+ {
+ /* Nothing to check here */
+ $message= array();
+ return $message;
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ }
+
+
+ function setAutoOptions($addopt= array())
+ {
+ $options= array("routers", "domain-name", "domain-name-servers", "subnet-mask", "broadcast-address");
+ $this->autoOptions= array_merge($options, $addopt);
+ }
+
+
+ function setAutoStatements($addstat= array())
+ {
+ $statements= array("filename", "next-server", "get-lease-hostnames", "use-host-decl-names");
+ $this->autoStatements= array_merge($statements, $addstat);
+ }
+
+}
+
+?>
diff --git a/plugins/admin/systems/services/dhcp/class_dhcpGroup.inc b/plugins/admin/systems/services/dhcp/class_dhcpGroup.inc
new file mode 100644
index 000000000..cbe987da8
--- /dev/null
+++ b/plugins/admin/systems/services/dhcp/class_dhcpGroup.inc
@@ -0,0 +1,126 @@
+assign("cn", $this->cn);
+
+ /* Show main page */
+ $display= $smarty->fetch (get_template_path('dhcp_group.tpl', TRUE)).$this->network->execute();
+
+ /* Merge arrays for advanced view */
+ $this->fix_options();
+ foreach (array("options", "statements") as $type){
+ $this->advanced->$type= $this->$type + $this->network->$type;
+ }
+
+ $display.= $this->advanced->execute();
+
+ /* Merge back for removals */
+ foreach (array("options", "statements") as $type){
+ $this->$type= $this->advanced->$type;
+ $this->network->$type= $this->advanced->$type;
+ }
+
+ /* Add footer */
+ $display.= "
".
+ "
";
+
+
+ return ($display);
+ }
+
+
+ function remove_from_parent()
+ {
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ /* Save cn */
+ if (isset($_POST['cn'])){
+ $this->cn= validate(get_post('cn'));
+ }
+
+ /* Handle global saving */
+ dhcpPlugin::save_object();
+ }
+
+
+ /* Check values */
+ function check()
+ {
+ $message= array();
+
+ $cache = $this->parent->dhcpObjectCache;
+
+ /* All required fields are set? */
+ if ($this->cn == ""){
+ $message[]= _("Required field 'Name' is not filled.");
+ }
+ if (!preg_match('/^[a-z0-9_-]*$/i', $this->cn)){
+ $message[]= _("Field 'Name' contains illegal characters.");
+ }
+
+ /* cn already used? */
+ if ($this->orig_cn != $this->cn || $this->new){
+
+ foreach($cache as $dn => $dummy){
+ if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){
+ $message[]= _("The name for this host section is already used!");
+ break;
+ }
+ }
+ }
+
+ /* Check external plugins */
+ $net= $this->network->check();
+ $adv= $this->advanced->check();
+ $message= array_merge($message, $net, $adv);
+
+ return $message;
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ dhcpPlugin::save();
+ return ($this->attrs);
+ }
+
+
+}
+
+?>
diff --git a/plugins/admin/systems/services/dhcp/class_dhcpHost.inc b/plugins/admin/systems/services/dhcp/class_dhcpHost.inc
new file mode 100644
index 000000000..e8aab5c95
--- /dev/null
+++ b/plugins/admin/systems/services/dhcp/class_dhcpHost.inc
@@ -0,0 +1,181 @@
+new){
+ $this->dhcpHWAddress= $attrs['dhcpHWAddress'][0];
+ }
+
+ $this->advanced->setAutoOptions(array("host-name"));
+ $this->advanced->setAutoStatements(array("fixed-address"));
+
+ $this->realGosaHost = $host_exists_in_gosa;
+ }
+
+ function execute()
+ {
+ $smarty= get_smarty();
+ $smarty->assign("cn", $this->cn);
+ $smarty->assign("dhcpHWAddress", preg_replace('/^[^ ]+ /', '', $this->dhcpHWAddress));
+ $smarty->assign("realGosaHost",$this->realGosaHost);
+
+ /* Create fixed address */
+ if (isset($this->statements['fixed-address'])){
+ $smarty->assign("fixedaddr", $this->statements['fixed-address']);
+ } else {
+ $smarty->assign("fixedaddr", "");
+ }
+
+ /* Prepare hw type selector */
+ $hwtype= preg_replace('/\s.*$/', '', $this->dhcpHWAddress);
+ $smarty->assign("hwtype", $hwtype);
+ $smarty->assign("hwtypes", array("ethernet" => _("Ethernet"),
+ "fddi" => _("FDDI"),
+ "token-ring" => _("Token Ring")));
+ /* Show main page */
+ $display= $smarty->fetch(get_template_path('dhcp_host.tpl', TRUE,dirname(__FILE__))).$this->network->execute();
+
+ /* Merge arrays for advanced view */
+ $this->fix_options();
+ foreach (array("options", "statements") as $type){
+ $this->advanced->$type= $this->$type + $this->network->$type;
+ }
+ $display.= $this->advanced->execute();
+
+ /* Merge back for removals */
+ foreach (array("options", "statements") as $type){
+ $this->$type= $this->advanced->$type;
+ $this->network->$type= $this->advanced->$type;
+ }
+
+ /* Add footer */
+ $display.= "
".
+ "
";
+
+
+ return ($display);
+ }
+
+
+ function remove_from_parent()
+ {
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ /* Save remaining attributes */
+ if (isset($_POST['dhcp_host_posted'])){
+
+ /* Assemble hwAddress */
+ if (isset($_POST['dhcpHWAddress'])){
+ $this->dhcpHWAddress= get_post('hwtype')." ".get_post('dhcpHWAddress');
+ }
+
+ if(!$this->realGosaHost){
+ $this->cn= validate(get_post('cn'));
+ }
+
+ /* Save fixed address */
+ if(!$this->realGosaHost){
+ if ($_POST['fixedaddr'] != ""){
+ $this->statements['fixed-address']= get_post('fixedaddr');
+ } else {
+ unset ($this->statements['fixed-address']);
+ }
+ }
+ $this->options['host-name']= $this->cn;
+ }
+
+ dhcpPlugin::save_object();
+ }
+
+
+ /* Check values */
+ function check()
+ {
+ $message= array();
+
+ $cache = array();
+ if(isset($this->parent)){
+ $cache = $this->parent->dhcpObjectCache;
+ }
+
+ /* All required fields are set? */
+ if ($this->cn == ""){
+ $message[]= _("Required field 'Name' is not filled.");
+ }
+
+ /* cn already used? */
+ if ($this->orig_cn != $this->cn || $this->new){
+
+ foreach($cache as $dn => $dummy){
+ if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){
+ $message[]= _("The name for this host section is already used!");
+ break;
+ }
+ }
+ }
+
+ /* Check syntax of MAC address */
+ $check= preg_replace('/^[^\s]*\s/', '', $this->dhcpHWAddress);
+ if (!preg_match('/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/', $check)){
+ $message[]= _("The hardware address specified by you is not valid!");
+ }
+
+ /* Check external plugins */
+ $net= $this->network->check();
+ $adv= $this->advanced->check();
+ $message= array_merge($message, $net, $adv);
+
+ return $message;
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ dhcpPlugin::save();
+ if ($this->dhcpHWAddress != ""){
+ $this->attrs['dhcpHWAddress']= array($this->dhcpHWAddress);
+ } else {
+ $this->attrs['dhcpHWAddress']= array();
+ }
+
+ return ($this->attrs);
+ }
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/dhcp/class_dhcpNetwork.inc b/plugins/admin/systems/services/dhcp/class_dhcpNetwork.inc
new file mode 100644
index 000000000..1c3ced065
--- /dev/null
+++ b/plugins/admin/systems/services/dhcp/class_dhcpNetwork.inc
@@ -0,0 +1,226 @@
+is_account= TRUE;
+ }
+
+ function execute()
+ {
+ /* Check for iteraction */
+ if (isset($_POST['add_dns']) && $_POST['addserver'] != ""){
+ if (!preg_match('/^[0-9a-z.-]+$/', get_post('addserver'))){
+ print_red(_("The name of the DNS server your're going to add is not valid!"));
+ } else {
+ $servers= array();
+ if (isset($this->options['domain-name-servers'])){
+ foreach(split(",", $this->options['domain-name-servers']) as $val){
+ $servers[$val]= $val;
+ }
+ }
+ $servers[get_post('addserver')]= get_post('addserver');
+
+ $tmp= "";
+ foreach($servers as $val){
+ $tmp.= $val.",";
+ }
+ $this->options['domain-name-servers']= preg_replace('/,$/', '', $tmp);
+ }
+ }
+ if (isset($_POST['delete_dns']) && isset($_POST['dnsserver'])){
+ $tmp= preg_replace("/(\s*,\s*)?".get_post('dnsserver')."/i", '',
+ $this->options['domain-name-servers']);
+ $tmp= preg_replace("/(\s*)?,(\s*)?$/", '', $tmp);
+ if ($tmp != ""){
+ $this->options['domain-name-servers']= $tmp;
+ } else {
+ unset($this->options['domain-name-servers']);
+ }
+ }
+
+ /* Show main page */
+ $smarty= get_smarty();
+
+ /*
+ * Assemble options
+ */
+
+ /* Router */
+ if (isset($this->options['routers'])){
+ $smarty->assign("routers", $this->options['routers']);
+ } else {
+ $smarty->assign("routers", "");
+ }
+
+ /* DNS */
+ if (isset($this->options['domain-name'])){
+ $smarty->assign("domain", trim($this->options['domain-name'], '"'));
+ } else {
+ $smarty->assign("domain", "");
+ }
+ if (isset($this->options['domain-name-servers'])){
+ $servers= array();
+ foreach(split(",", $this->options['domain-name-servers']) as $val){
+ $servers[$val]= $val;
+ }
+ $smarty->assign("dnsservers", $servers);
+ } else {
+ $smarty->assign("dnsservers", "");
+ }
+
+ /* Netmask / Broadcast */
+ if (isset($this->options['subnet-mask'])){
+ $this->options['subnet-mask']= normalize_netmask($this->options['subnet-mask']);
+ $smarty->assign("subnet_mask", $this->options['subnet-mask']);
+ } else {
+ $smarty->assign("subnet_mask", "");
+ }
+ if (isset($this->options['broadcast-address'])){
+ $smarty->assign("broadcast_address", $this->options['broadcast-address']);
+ } else {
+ $smarty->assign("broadcast_address", "");
+ }
+
+ /* Boot stuff */
+ if (isset($this->statements['filename'])){
+ $smarty->assign("filename", trim($this->statements['filename'], '"'));
+ } else {
+ $smarty->assign("filename", "");
+ }
+ if (isset($this->statements['next-server'])){
+ $smarty->assign("nextserver", $this->statements['next-server']);
+ } else {
+ $smarty->assign("nextserver", "");
+ }
+
+ /* Set flags */
+ $smarty->assign("autohost", "");
+ if (isset($this->statements['get-lease-hostnames'])){
+ if (preg_match('/^(true|on|yes)$/', $this->statements['get-lease-hostnames'])){
+ $smarty->assign("autohost", "checked");
+ }
+ }
+ $smarty->assign("autohostdecl", "");
+ if (isset($this->statements['use-host-decl-names'])){
+ if (preg_match('/^(true|on|yes)$/', $this->statements['use-host-decl-names'])){
+ $smarty->assign("autohostdecl", "checked");
+ }
+ }
+
+ return $smarty->fetch(get_template_path('dhcp_network.tpl', TRUE,dirname(__FILE__)));
+ }
+
+ function remove_from_parent()
+ {
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ /* Only save, if we are "active" */
+ if (isset($_POST['routers'])){
+
+ /*
+ * Assemble options
+ */
+
+ /* Options */
+ foreach (array("routers" => "routers", "domain-name" => "domain", "subnet-mask" => "subnet_mask",
+ "broadcast-address" => "broadcast_address") as $key => $val){
+
+ if ($_POST["$val"] == ''){
+ unset($this->options["$key"]);
+ } else {
+ $this->options["$key"]= get_post("$val");
+ }
+ }
+
+ /* Statements */
+ foreach (array("filename" => "filename", "next-server" => "nextserver") as $key => $val){
+ if ($_POST["$val"] == ''){
+ unset($this->statements["$key"]);
+ } else {
+
+ /* Only quote filename values */
+ if(in_array($key,array("filename"))){
+ $this->statements["$key"]= '"'.get_post("$val").'"';
+ }else{
+ $this->statements["$key"]= get_post("$val");
+ }
+ }
+ }
+
+ /* Flags */
+ if (isset ($_POST['autohost'])){
+ $this->statements['get-lease-hostnames']= "true";
+ } else {
+ unset($this->statements['get-lease-hostnames']);
+ }
+ if (isset ($_POST['autohostdecl'])){
+ $this->statements['use-host-decl-names']= "on";
+ } else {
+ unset($this->statements['use-host-decl-names']);
+ }
+ }
+ }
+
+
+ /* Check values */
+ function check()
+ {
+ $message= array();
+
+ /* Check netmask and broadcast */
+ foreach(array("subnet-mask" => _("Netmask"), "broadcast-address" => _("Broadcast")) as $key => $typ){
+ if (!isset($this->options["$key"])){
+ continue;
+ }
+ $tmp= preg_replace('/^[^\s]+\s/', '', $this->options["$key"]);
+
+ if (!is_ip($tmp)){
+ $message[]= sprintf(_("Error in definition of '%s'!"), $typ);
+ }
+ }
+
+ return $message;
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ }
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/dhcp/class_dhcpNewSectionDialog.inc b/plugins/admin/systems/services/dhcp/class_dhcpNewSectionDialog.inc
new file mode 100644
index 000000000..756a97893
--- /dev/null
+++ b/plugins/admin/systems/services/dhcp/class_dhcpNewSectionDialog.inc
@@ -0,0 +1,80 @@
+ array("dhcpSharedNetwork", "dhcpSubnet", "dhcpGroup", "dhcpHost" /*, "dhcpClass"*/),
+ #"dhcpClass" => array("dhcpSubClass"),
+ "dhcpSubClass" => array(),
+ "dhcpHost" => array(),
+ "dhcpGroup" => array("dhcpHost"),
+ "dhcpPool" => array(),
+ "dhcpSubnet" => array("dhcpPool", "dhcpGroup", "dhcpHost" /*, "dhcpClass"*/),
+ "dhcpSharedNetwork" => array("dhcpSubnet", "dhcpPool"));
+
+
+
+ function dhcpNewSectionDialog($type)
+ {
+ $this->types= array( "dhcpService" => _("Global options"),
+ /*"dhcpClass" => _("Class"),*/
+ "dhcpSubClass" => _("Subclass"),
+ "dhcpHost" => _("Host"),
+ "dhcpGroup" => _("Group"),
+ "dhcpPool" => _("Pool"),
+ "dhcpSubnet" => _("Subnet"),
+ "dhcpSharedNetwork" => _("Shared network"));
+
+ $this->classtype= $type;
+ }
+
+ function execute()
+ {
+ /* Fill templating stuff */
+ $smarty = get_smarty();
+ $display= "";
+
+ $sections= $this->sectionMap[$this->classtype];
+ $t_sections= array();
+ foreach ($sections as $section){
+ $t_sections[$section]= $this->types[$section];
+ }
+ asort($t_sections);
+ $ui = get_userinfo();
+ $smarty->assign("sections", $t_sections);
+ $display.= $smarty->fetch(get_template_path('dhcpNewSection.tpl', TRUE));
+ return($display);
+ }
+
+ /* Get posts and set class name
+ */
+ function save_object()
+ {
+ }
+
+ /* Check given class name */
+ function check()
+ {
+ /* Call common method to give check the hook */
+ $message= "";
+
+ return ($message);
+ }
+
+
+ /* Return the class name */
+ function save()
+ {
+ }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/dhcp/class_dhcpPool.inc b/plugins/admin/systems/services/dhcp/class_dhcpPool.inc
new file mode 100644
index 000000000..9e9821e8a
--- /dev/null
+++ b/plugins/admin/systems/services/dhcp/class_dhcpPool.inc
@@ -0,0 +1,191 @@
+new){
+ $this->dhcpRange= $attrs['dhcpRange'][0];
+ list($this->range_start, $this->range_stop)= preg_split('/\s+/', $this->dhcpRange);
+ }
+
+ $this->advanced->setAutoOptions(array("host-name"));
+ $this->advanced->setAutoStatements(array("fixed-address"));
+ }
+
+ function execute()
+ {
+ $smarty= get_smarty();
+ $smarty->assign("cn", $this->cn);
+ $smarty->assign("range_start", $this->range_start);
+ $smarty->assign("range_stop", $this->range_stop);
+
+ /* Show main page */
+ $display= $smarty->fetch(get_template_path('dhcp_pool.tpl', TRUE)).$this->network->execute();
+
+ /* Merge arrays for advanced view */
+ $this->fix_options();
+ foreach (array("options", "statements") as $type){
+ $this->advanced->$type= $this->$type + $this->network->$type;;
+ }
+
+ $display.= $this->advanced->execute();
+
+ /* Merge back for removals */
+ foreach (array("options", "statements") as $type){
+ $this->$type= $this->advanced->$type;
+ $this->network->$type= $this->advanced->$type;
+ }
+
+ /* Add footer */
+ $display.= "
".
+ "
";
+
+ return ($display);
+ }
+
+ function remove_from_parent()
+ {
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ if (isset($_POST['cn'])){
+ $this->cn= validate(get_post('cn'));
+ $this->range_start= validate(get_post('range_start'));
+ $this->range_stop= validate(get_post('range_stop'));
+ }
+
+ dhcpPlugin::save_object();
+
+ /* Move range to internal variable */
+ $this->dhcpRange= $this->range_start." ".$this->range_stop;
+ }
+
+
+ /* Check values */
+ function check()
+ {
+ $message= array();
+
+ $cache = $this->parent->dhcpObjectCache;
+
+ /* All required fields are set? */
+ if ($this->cn == ""){
+ $message[]= _("Required field 'Name' is not filled.");
+ }
+
+ /* cn already used? */
+ if ($this->orig_cn != $this->cn || $this->new){
+
+ foreach($cache as $dn => $dummy){
+ if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){
+ $message[]= _("The name for this section is already used!");
+ break;
+ }
+ }
+ }
+
+ if ($this->dhcpRange == ""){
+ $message[]= _("Required field 'Range' is not filled.");
+ }
+
+ if (!is_ip($this->range_start) || !is_ip($this->range_stop)){
+ $message[]= _("Field 'Range' contains invalid IP addresses.");
+ }
+
+ if(!is_ip_range($this->range_start,$this->range_stop)){
+ $message[] = _("Field 'Range' contains invalid IP range.");
+ }
+
+ /* Check if range is in the network */
+ $dn= $this->dn;
+ while (preg_match('/,/', $dn)){
+ $type= $this->objectType($cache, $dn);
+
+ /* Check for subnet */
+ if ($type == 'dhcpSubnet'){
+ $network= $cache[$dn]['cn'][0];
+ $netmask= normalize_netmask($cache[$dn]['dhcpNetMask'][0]);
+ if (!is_in_network($network, $netmask, $this->range_start) ||
+ !is_in_network($network, $netmask, $this->range_stop)){
+ $message[] = _("'Range' is not inside the configured network.");
+ }
+ }
+
+ /* Stop if we've examined the service base object */
+ if ($type == 'dhcpService'){
+ break;
+ }
+ $dn= preg_replace('/^[^,]+,/', '', $dn);
+ }
+
+ /* Check external plugins */
+ $net= $this->network->check();
+ $adv= $this->advanced->check();
+ $message= array_merge($message, $net, $adv);
+
+ return $message;
+ }
+
+ /* Save to LDAP */
+ function save()
+ {
+ dhcpPlugin::save();
+ $this->attrs['dhcpRange']= array($this->dhcpRange);
+
+ return ($this->attrs);
+ }
+
+
+ function objectType($cache, $dn)
+ {
+ $type= "";
+ $types= array("dhcpService", "dhcpClass", "dhcpSubClass", "dhcpHost",
+ "dhcpGroup", "dhcpPool", "dhcpSubnet", "dhcpSharedNetwork");
+
+ foreach ($cache[$dn]['objectClass'] as $oc){
+ if (in_array($oc, $types)){
+ $type= $oc;
+ break;
+ }
+ }
+
+ return ($type);
+ }
+
+
+}
+
+?>
diff --git a/plugins/admin/systems/services/dhcp/class_dhcpService.inc b/plugins/admin/systems/services/dhcp/class_dhcpService.inc
new file mode 100644
index 000000000..57f76cc9e
--- /dev/null
+++ b/plugins/admin/systems/services/dhcp/class_dhcpService.inc
@@ -0,0 +1,181 @@
+new){
+ /* Load attributes */
+ $this->dhcpPrimaryDN= $attrs['dhcpPrimaryDN'][0];
+ } else {
+ /* We keep the parent dn here if it's new */
+ $this->statements['default-lease-time']= 600;
+ $this->statements['max-lease-time']= 1700;
+ $this->statements['authoritative']= TRUE;
+ $this->statements['ddns-update-style']= 'none';
+ }
+
+ $this->advanced->setAutoStatements(array("default-lease-time", "max-lease-time", "authoritative", "server-identifier", "ddns-update-style"));
+ $this->advanced->setAutoOptions(array("server-name"));
+
+ /* Save for later action */
+ $this->orig_dhcpPrimaryDN= $this->dhcpPrimaryDN;
+ }
+
+
+ function execute()
+ {
+ /* Show main page */
+ $smarty= get_smarty();
+
+ $smarty->assign('ddns_styles', $this->ddns_styles);
+ foreach (array('max_lease_time', 'default_lease_time', 'ddns_update_style') as $value){
+ if (isset($this->statements[preg_replace('/_/', '-', $value)])){
+ $smarty->assign("$value", $this->statements[preg_replace('/_/', '-', $value)]);
+ } else {
+ $smarty->assign("$value", "");
+ }
+ }
+
+ if (isset($this->statements['authoritative'])){
+ $smarty->assign("authoritative", "checked");
+ } else {
+ $smarty->assign("authoritative", "");
+ }
+
+ /* Show main page */
+ $display= $smarty->fetch(get_template_path('dhcp_service.tpl', TRUE)).$this->network->execute();
+
+ /* Merge arrays for advanced view */
+ $this->fix_options();
+ foreach (array("options", "statements") as $type){
+ $this->advanced->$type= $this->$type + $this->network->$type;;
+ }
+
+ $display.= $this->advanced->execute();
+
+ /* Merge back for removals */
+ foreach (array("options", "statements") as $type){
+ $this->$type= $this->advanced->$type;
+ $this->network->$type= $this->advanced->$type;
+ }
+
+ /* Add footer */
+ $display.= "
".
+ "
";
+
+
+ return ($display);
+
+ }
+
+ function remove_from_parent()
+ {
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ /* No need to save in the first time */
+ if (!isset($_POST['ddns_update_style'])){
+ return;
+ }
+
+ /* Save remaining attributes */
+ foreach (array('max_lease_time', 'default_lease_time', 'ddns_update_style') as $val){
+ $tval= preg_replace('/_/', '-', $val);
+ if ($_POST[$val] != ""){
+ $this->statements[$tval]= validate(get_post($val));
+ } else {
+ unset ($this->statements[$tval]);
+ }
+ }
+ if (isset($_POST['authoritative'])){
+ $this->statements['authoritative']= "";
+ } else {
+ unset($this->statements['authoritative']);
+ }
+
+ dhcpPlugin::save_object();
+ }
+
+
+ /* Check values */
+ function check()
+ {
+ $message= array();
+
+ if (!is_id($this->statements['default-lease-time'])){
+ $message[]= _('Default lease time needs to be numeric.');
+ }
+ if (!is_id($this->statements['max-lease-time'])){
+ $message[]= _('Maximum lease time needs to be numeric.');
+ }
+ if ($this->statements['default-lease-time'] > $this->statements['max-lease-time']){
+ $message[]= _('Default lease time needs to smaller than the maximum lease time.');
+ }
+
+ /* Check external plugins */
+ $net= $this->network->check();
+ $adv= $this->advanced->check();
+ $message= array_merge($message, $net, $adv);
+
+ return $message;
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ global $config;
+ $this->attrs= array();
+
+ /* Get and set server name */
+ $ldap= $config->get_ldap_link();
+ $ldap->cat($this->dhcpPrimaryDN, array('cn'));
+ $res= $ldap->fetch();
+ $server_name= $res['cn'][0];
+
+ dhcpPlugin::save();
+
+ $this->attrs['dhcpPrimaryDN']= array($this->dhcpPrimaryDN);
+ $this->removeOption('server-name');
+# $this->attrs['dhcpOption'][]= "server-name $server_name";
+
+ return ($this->attrs);
+ }
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/dhcp/class_dhcpSharedNetwork.inc b/plugins/admin/systems/services/dhcp/class_dhcpSharedNetwork.inc
new file mode 100644
index 000000000..6e55b75d6
--- /dev/null
+++ b/plugins/admin/systems/services/dhcp/class_dhcpSharedNetwork.inc
@@ -0,0 +1,188 @@
+advanced->setAutoStatements(array("server-identifier", "default-lease-time",
+ "max-lease-time", "min-lease-time", "authoritative", "deny-unknown-clients",
+ "deny-bootp", "deny-booting"));
+ }
+
+
+ function execute()
+ {
+ $smarty= get_smarty();
+
+ /* Fill template */
+ $smarty->assign ("cn", $this->cn);
+ foreach (array("server-identifier", "default-lease-time", "max-lease-time", "min-lease-time") as $attr){
+ if (isset($this->statements[$attr])){
+ $smarty->assign(preg_replace('/-/', '_', $attr), $this->statements[$attr]);
+ } else {
+ $smarty->assign(preg_replace('/-/', '_', $attr), "");
+ }
+ }
+ if (isset($this->statements["authoritative"])){
+ $smarty->assign("authoritative", "checked");
+ } else {
+ $smarty->assign("authoritative", "");
+ }
+ if (!isset($this->statements["deny unknown-clients"])){
+ $smarty->assign("allow_unknown_state", "checked");
+ } else {
+ $smarty->assign("allow_unknown_state", "");
+ }
+ if (!isset($this->statements["deny bootp"])){
+ $smarty->assign("allow_bootp_state", "checked");
+ } else {
+ $smarty->assign("allow_bootp_state", "");
+ }
+ if (!isset($this->statements["deny booting"])){
+ $smarty->assign("allow_booting_state", "checked");
+ } else {
+ $smarty->assign("allow_booting_state", "");
+ }
+
+ /* Show main page */
+ $display= $smarty->fetch(get_template_path('dhcp_sharedNetwork.tpl', TRUE)).$this->network->execute();
+
+ /* Merge arrays for advanced view */
+ $this->fix_options();
+ foreach (array("options", "statements") as $type){
+ $this->advanced->$type= $this->$type + $this->network->$type;
+ }
+
+ $display.= $this->advanced->execute();
+
+ /* Merge back for removals */
+ foreach (array("options", "statements") as $type){
+ $this->$type= $this->advanced->$type;
+ $this->network->$type= $this->advanced->$type;
+ }
+
+ /* Add footer */
+ $display.= "
".
+ "
";
+
+
+ return ($display);
+ }
+
+
+ function remove_from_parent()
+ {
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ if (isset($_POST['cn'])){
+ $this->cn= validate(get_post('cn'));
+ dhcpPlugin::save_object();
+
+ foreach (array("server-identifier", "default-lease-time",
+ "max-lease-time", "min-lease-time") as $attr){
+ if (isset($_POST[$attr]) && $_POST[$attr] != ""){
+ $this->statements[$attr]= get_post($attr);
+ } else {
+ unset($this->statements[$attr]);
+ }
+ }
+
+ if (isset($_POST["authoritative"])){
+ $this->statements["authoritative"]= "";
+ } else {
+ unset ($this->statements["authoritative"]);
+ }
+
+ foreach(array("unknown-clients", "bootp", "booting") as $name){
+ if (isset($_POST[$name])){
+ $this->statements["allow $name"]= "";
+ unset($this->statements["deny $name"]);
+ } else {
+ $this->statements["deny $name"]= "";
+ unset($this->statements["allow $name"]);
+ }
+ }
+ }
+ }
+
+
+ /* Check values */
+ function check()
+ {
+ $message= array();
+
+ $cache = $this->parent->dhcpObjectCache;
+
+ /* All required fields are set? */
+ if ($this->cn == ""){
+ $message[]= _("Required field 'Name' is not filled.");
+ }
+
+ /* Check lease times */
+ foreach (array("default-lease-time" => _("Default lease time"),
+ "max-lease-time" => _("Max. lease time"),
+ "min-lease-time" => _("Min. lease time")) as $key => $val){
+ if (isset($this->statements[$key]) && $this->statements[$key] != "" &&
+ !is_id($this->statements[$key])){
+ $message[]= sprintf(_("The value specified as '%s' is not numeric!"), $val);
+ }
+ }
+
+ /* cn already used? */
+ if ($this->orig_cn != $this->cn || $this->new){
+
+ foreach($cache as $dn => $dummy){
+ if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){
+ $message[]= _("The name for this host section is already used!");
+ break;
+ }
+ }
+ }
+
+ /* Check external plugins */
+ $net= $this->network->check();
+ $adv= $this->advanced->check();
+ $message= array_merge($message, $net, $adv);
+
+ return $message;
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ dhcpPlugin::save();
+
+ return ($this->attrs);
+ }
+
+}
+
+?>
diff --git a/plugins/admin/systems/services/dhcp/class_dhcpSubnet.inc b/plugins/admin/systems/services/dhcp/class_dhcpSubnet.inc
new file mode 100644
index 000000000..8c2da41de
--- /dev/null
+++ b/plugins/admin/systems/services/dhcp/class_dhcpSubnet.inc
@@ -0,0 +1,200 @@
+new){
+ /* Load attributes */
+ foreach (array("dhcpNetMask", "dhcpRange") as $attr){
+ if (isset($attrs[$attr][0])){
+ $this->$attr= $attrs[$attr][0];
+ }
+ }
+ if (isset($attrs['dhcpRange']) && count($attrs['dhcpRange'])){
+ $this->use_range= TRUE;
+ list($this->range_start, $this->range_stop)= preg_split('/\s+/', $this->dhcpRange);
+ }
+ }
+
+ $this->dhcpNetMask= normalize_netmask($this->dhcpNetMask);
+ }
+
+
+ function execute()
+ {
+ $smarty= get_smarty();
+ $smarty->assign("cn", $this->cn);
+ $smarty->assign("dhcp_netmask", $this->dhcpNetMask);
+
+ /* Prepare range */
+ if ($this->use_range){
+ $smarty->assign("use_range", "checked");
+ $smarty->assign("range_disabled", "");
+ } else {
+ $smarty->assign("use_range", "");
+ $smarty->assign("range_disabled", "disabled");
+ }
+ $smarty->assign("range_start", $this->range_start);
+ $smarty->assign("range_stop", $this->range_stop);
+
+ /* Show main page */
+ $display= $smarty->fetch(get_template_path('dhcp_subnet.tpl', TRUE)).$this->network->execute();
+
+ /* Merge arrays for advanced view */
+ $this->fix_options();
+ foreach (array("options", "statements") as $type){
+ $this->advanced->$type= $this->$type + $this->network->$type;
+ }
+
+ $display.= $this->advanced->execute();
+
+ /* Merge back for removals */
+ foreach (array("options", "statements") as $type){
+ $this->$type= $this->advanced->$type;
+ $this->network->$type= $this->advanced->$type;
+ }
+
+ /* Add footer */
+ $display.= "
".
+ "
";
+
+ /* Show main page */
+ return $display;
+ }
+
+
+ function remove_from_parent()
+ {
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ if(isset($_POST['dhcp_subnet_posted'])){
+ if (isset($_POST['cn'])){
+ $this->cn= validate(get_post('cn'));
+ }
+ if (isset($_POST['dhcp_netmask'])){
+ $this->dhcpNetMask= validate(get_post('dhcp_netmask'));
+ }
+ if (isset($_POST['use_range'])){
+ $this->use_range= TRUE;
+ $this->range_start= validate(get_post('range_start'));
+ $this->range_stop= validate(get_post('range_stop'));
+ } else {
+ $this->use_range= FALSE;
+ }
+
+ /* Move range to internal variable */
+ $this->dhcpRange= $this->range_start." ".$this->range_stop;
+ dhcpPlugin::save_object();
+ }
+ }
+
+
+ /* Check values */
+ function check()
+ {
+ $message= array();
+
+ $cache = $this->parent->dhcpObjectCache;
+
+ /* All required fields are set? */
+ if ($this->cn == ""){
+ $message[]= _("Required field 'Network address' is not filled.");
+ }
+ if ($this->dhcpNetMask == ""){
+ $message[]= _("Required field 'Netmask' is not filled.");
+ }
+
+ /* cn already used? */
+ if ($this->orig_cn != $this->cn || $this->new){
+
+ foreach($cache as $dn => $dummy){
+ if (preg_match("/^cn=".$this->cn.",/", $dn) && count($dummy)){
+ $message[]= _("The name for this section is already used!");
+ break;
+ }
+ }
+ }
+
+ /* IP's? */
+ foreach(array('dhcpNetMask' => _("Netmask"), 'cn' => _("Network address"), 'range_start' => _("Range"), 'range_stop' => _("Range")) as $attr => $str){
+ if ($this->$attr != "" && !is_ip($this->$attr)){
+ $message[]= sprintf(_("The field '%s' contains an invalid IP address"), $str);
+ }
+ }
+
+ /* Check ip range */
+ if ($this->use_range){
+ if(!is_ip_range($this->range_start,$this->range_stop)){
+ $message[] = _("Field 'Range' contains invalid IP range.");
+ }
+
+ /* Check if range is in the network */
+ if (!is_in_network($this->cn, $this->dhcpNetMask, $this->range_start) ||
+ !is_in_network($this->cn, $this->dhcpNetMask, $this->range_stop)){
+ $message[] = _("'Range' is not inside the configured network.");
+ }
+ }
+
+ /* Check external plugins */
+ $net= $this->network->check();
+ $adv= $this->advanced->check();
+ $message= array_merge($message, $net, $adv);
+
+ return $message;
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ dhcpPlugin::save();
+
+ /* Move dn to the result */
+ $this->attrs['dhcpNetMask']= array(netmask_to_bits($this->dhcpNetMask));
+ if ($this->use_range && !empty($this->dhcpRange)){
+ $this->attrs['dhcpRange']= array($this->range_start." ".$this->range_stop);
+ } else {
+ $this->attrs['dhcpRange']= array();
+ }
+
+ return ($this->attrs);
+ }
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/dhcp/class_servDHCP.inc b/plugins/admin/systems/services/dhcp/class_servDHCP.inc
new file mode 100644
index 000000000..c804ec2bc
--- /dev/null
+++ b/plugins/admin/systems/services/dhcp/class_servDHCP.inc
@@ -0,0 +1,739 @@
+ array(),"FOR_LIST"=> array());
+ var $take_over_id = -1;
+ var $display_warning = TRUE;
+
+ function servdhcp (&$config, $dn= NULL, $parent= NULL)
+ {
+ plugin::plugin ($config, $dn, $parent);
+
+ $this->serviceDN = "cn=dhcp,".$dn;
+ $this->orig_dn = $dn;
+
+ $this->DisplayName = _("DHCP service");
+
+ $this->types= array( "dhcpLog" => _("Logging"),
+ "dhcpService" => _("Global options"),
+ "dhcpClass" => _("Class"),
+ "dhcpSubClass" => _("Subclass"),
+ "dhcpHost" => _("Host"),
+ "dhcpGroup" => _("Group"),
+ "dhcpPool" => _("Pool"),
+ "dhcpSubnet" => _("Subnet"),
+ "dhcpFailOverPeer" => _("Failover peer"),
+ "dhcpSharedNetwork" => _("Shared network"));
+
+
+ /* Backport: PHP4 compatibility */
+ foreach($this->types as $type => $translation){
+ $this->types[strtolower($type)] = $translation;
+ }
+
+ /* Load information about available services */
+ $this->reload();
+ if (!count($this->dhcpSections)){
+ $this->is_account= FALSE;
+ $this->dhcp_server_list = $this->get_list_of_dhcp_servers();
+ }
+ }
+
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ /* Fill templating stuff */
+ $smarty= get_smarty();
+ $smarty->assign("dns_take_over",FALSE);
+ $display= "";
+
+
+ /*****************/
+ /* Handle Take Over Actions
+ /*****************/
+
+ /* Give smarty the required informations */
+ $smarty->assign("dhcp_server_list", $this->dhcp_server_list['FOR_LIST']);
+ $smarty->assign("dhcp_server_list_cnt", count($this->dhcp_server_list['FOR_LIST']));
+
+ /* Take over requested, save id */
+ if(isset($_POST['take_over_src']) && isset($_POST['take_over'])){
+ $id = $_POST['take_over_src'];
+ if(isset($this->dhcp_server_list['ENTRIES'][$id])){
+ $this->take_over_id = $id;
+ }
+ }
+
+ /* Abort take over action */
+ if(isset($_POST['cancel_take_over'])){
+ $this->dialog =false;
+ $this->take_over_id = -1;
+ $this->dhcp_server_list = $this->get_list_of_dhcp_servers();
+ }
+
+ /* Display informartion about take over that will be started when saving this server
+ * and hide default dhcp output
+ */
+ if($this->take_over_id != -1){
+
+ $this->dialog = FALSE;
+ $id = $this->take_over_id;
+ $smarty->assign("dns_take_over",TRUE);
+ $warning = sprintf(_("You are going to migrate the DHCP setup from server '%s'."),
+ $this->dhcp_server_list['ENTRIES'][$id]['cn'][0]);
+ $warning.= " "._("The migration will be started when you save this system. To cancel this action, use the cancel button below.");
+
+ if($this->display_warning){
+ print_red($warning);
+ $this->display_warning = FALSE;
+ }
+ return($smarty->fetch(get_template_path('servdhcp.tpl', TRUE)));
+ }
+
+
+ /*****************/
+ /* List handling
+ /*****************/
+
+ /* Section Creation? */
+ if (isset($_POST['create_section']) && isset($_POST['section'])){
+ $section= $_POST['section'];
+ $tmp = new dhcpNewSectionDialog(NULL);
+ if (isset($tmp->sectionMap[$section])){
+ $this->dialog= new $section($this->current_object);
+ $this->current_object= "";
+ } else {
+ $this->dialog= FALSE;
+ }
+ }
+
+ /* Cancel section creation? */
+ if (isset($_POST['cancel_section']) || isset($_POST['cancel_dhcp'])){
+ $this->dialog= FALSE;
+ }
+
+ /* Save changes */
+ if (isset($_POST['save_dhcp'])){
+ $this->dialog->save_object();
+ $messages= $this->dialog->check();
+ if (count($messages)){
+ show_errors($messages);
+ } else {
+ $dn= $this->dialog->dn;
+ $class= get_class($this->dialog);
+ $type= $this->types[$class];
+ if(empty($this->serviceDN)){
+ $indent= substr_count(preg_replace("/".$this->dn."/", '', $dn), ",") -1;
+ }else{
+ $indent= substr_count(preg_replace("/".$this->serviceDN."/", '', $dn), ",");
+ }
+ $spaces= "";
+ for ($i= 0; $i<$indent; $i++){
+ $spaces.= " ";
+ }
+ $data= $this->dialog->save();
+ if ($this->current_object == ""){
+ /* New object */
+ $newsects= array();
+ foreach ($this->dhcpSections as $key => $dsc){
+ $newsects[$key]= $dsc;
+ if ($key == $dn){
+ $spaces.= " ";
+ $newsects[$data['dn']]= "$spaces$type '".preg_replace('/^[^=]+=([^,]+),.*$/', '\1', $data['dn'])."'";
+ }
+ }
+ $this->dhcpObjectCache[$data['dn']]= $data;
+ $this->dhcpSections= $newsects;
+ } else {
+ if ($dn != $data['dn']){
+ /* Old object, new name */
+ $this->dhcpObjectCache[$dn]= array();
+ $this->dhcpObjectCache[$data['dn']]= $data;
+
+ /* If we renamed a section, we've to rename a couple of objects, too */
+ foreach ($this->dhcpObjectCache as $key => $dsc){
+ if (preg_match("/,$dn$/", $key)){
+ $new_dn= preg_replace("/,$dn$/", ",".$data['dn'], $key);
+ $dsc['MODIFIED']= TRUE;
+ $this->dhcpObjectCache[$new_dn]= $dsc;
+ unset($this->dhcpObjectCache[$key]);
+ }
+ }
+ $newsects= array();
+ foreach ($this->dhcpSections as $key => $dsc){
+ if ($key == $dn){
+ $newsects[$data['dn']]= "$spaces$type '".preg_replace('/^[^=]+=([^,]+),.*$/', '\1', $data['dn'])."'";
+ continue;
+ }
+ if (preg_match("/,$dn$/", $key)){
+ $new_dn= preg_replace("/,$dn$/", ",".$data['dn'], $key);
+ $newsects[$new_dn]= $dsc;
+ } else {
+ $newsects[$key]= $dsc;
+ }
+ }
+ $this->dhcpSections= $newsects;
+
+ } else {
+ /* Old object, old name */
+ $this->dhcpObjectCache[$data['dn']]= $data;
+ }
+ }
+ $this->dialog= FALSE;
+ }
+ }
+
+ /* Remove section? */
+ if (isset($_POST['delete_dhcp_confirm'])){
+ if ($this->acl_is_removeable()){
+ unset($this->dhcpSections[$this->current_object]);
+ unset($this->dhcpObjectCache[$this->current_object]);
+ $this->dhcpObjectCache[$this->current_object]= array();
+ foreach ($this->dhcpSections as $key => $value){
+ if (preg_match("/".$this->current_object."$/", $key)){
+ unset($this->dhcpSections[$key]);
+ unset($this->dhcpObjectCache[$key]);
+ $this->dhcpObjectCache[$key]= array();
+ }
+ }
+ } else {
+ print_red(_("You're not allowed to remove DHCP sections!"));
+ }
+ $this->dialog= FALSE;
+ }
+
+ /* Look for post entries */
+ foreach($_POST as $name => $value){
+
+ /* Insert new section? */
+ if (preg_match('/^insertDhcp_.*_x$/', $name)){
+ $dn= base64_decode(preg_replace('/^insertDhcp_([^_]+)_x$/', '\1', $name));
+ if (isset($this->dhcpObjectCache[$dn])){
+ $this->dialog= new dhcpNewSectionDialog($this->objectType($dn));
+ $this->current_object= $dn;
+ $this->dialog->acl= $this->acl;
+ }
+ }
+
+ /* Edit section? */
+ if (preg_match('/^editDhcp_.*_x$/', $name)){
+ $dn= base64_decode(preg_replace('/^editDhcp_([^_]+)_x$/', '\1', $name));
+ if (isset($this->dhcpObjectCache[$dn])){
+ $section= $this->objectType($dn);
+ $this->current_object= $dn;
+ $this->dialog= new $section($this->dhcpObjectCache[$dn]);
+ }
+ }
+
+ /* Remove section? */
+ if (preg_match('/^delDhcp_.*_x$/', $name)){
+ $dn= base64_decode(preg_replace('/^delDhcp_([^_]+)_x$/', '\1', $name));
+ if (isset($this->dhcpObjectCache[$dn])){
+ $this->current_object= $dn;
+ $this->dialog= 1;
+ $smarty->assign("warning", sprintf(_("You're about to delete the DHCP section '%s'."), $dn));
+ return($smarty->fetch(get_template_path('remove_dhcp.tpl', TRUE)));
+ }
+ }
+
+ }
+
+ if(isset($_GET['act']) && $_GET['act']=="edit" && isset($_GET['id'])){
+ $dn = base64_decode($_GET['id']);
+ if (isset($this->dhcpObjectCache[$dn])){
+ $section= $this->objectType($dn);
+ $this->current_object= $dn;
+ $this->dialog= new $section($this->dhcpObjectCache[$dn]);
+ }
+ }
+
+
+ if(isset($_GET['act']) && $_GET['act']=="edit" && isset($_GET['id'])){
+ $dn = base64_decode($_GET['id']);
+ if (isset($this->dhcpObjectCache[$dn])){
+ $section= $this->objectType($dn);
+ $this->current_object= $dn;
+ $this->dialog= new $section($this->dhcpObjectCache[$dn]);
+ }
+ }
+
+
+ /* Do we need to flip is_account state? */
+ if (isset($_POST['modify_state'])){
+ $this->is_account= !$this->is_account;
+ }
+
+ /* Show tab dialog headers */
+ if ($this->is_account){
+# $display= $this->show_header(_("Remove DHCP service"),
+# _("This server has DHCP features enabled. You can disable them by clicking below."));
+
+ if (!count($this->dhcpObjectCache)){
+ $attrs= array();
+ $attrs['dn']= 'cn=dhcp,'.$this->dn;
+ $attrs['cn']= array('dhcp');
+ $attrs['objectClass']= array('top', 'dhcpService');
+ $attrs['dhcpPrimaryDN']= array($this->dn);
+ $attrs['dhcpStatements']= array("default-lease-time 600",
+ "max-lease-time 1200",
+ "authoritative",
+ "ddns-update-style none");
+ $attrs['MODIFIED']= TRUE;
+ $this->dhcpSections['cn=dhcp,'.$this->dn]= _("Global options");
+ $this->dhcpObjectCache['cn=dhcp,'.$this->dn]= $attrs;
+ }
+
+ } else {
+# $display= $this->show_header(_("Add DHCP service"),
+
+# _("This server has DHCP features disabled. You can enable them by clicking below."));
+ return ($display);
+ }
+
+
+ /* Show dialog
+ */
+ if(isset($this->dialog) && is_object($this->dialog)){
+ $this->dialog->save_object();
+ $this->dialog->parent = $this;
+ return($this->dialog->execute());
+ }
+
+ /* Create Listbox with existing Zones
+ */
+ $DhcpList = new divSelectBox("dhcpSections");
+ $DhcpList->SetHeight(400);
+
+ /* Add entries to divlist
+ */
+ $editImgIns = "
".
+ "
".
+ "
";
+ $editImgInsNoDel = "
".
+ "
";
+ $editImg = "
".
+ "
";
+
+ $tmp = new dhcpNewSectionDialog(NULL);
+ foreach($this->dhcpSections as $section => $values ){
+
+ $values = "
".$values." ";
+
+ if (count($tmp->sectionMap[$this->objectType($section)])){
+ if ($this->objectType($section) == "dhcpService"){
+ $DhcpList->AddEntry(array(
+ array("string" => $values),
+ array("string" => str_replace("%s",base64_encode($section),$editImgInsNoDel), "attach" => "style='text-align:right;'")
+ ));
+ } else {
+ $DhcpList->AddEntry(array(
+ array("string" => $values),
+ array("string" => str_replace("%s",base64_encode($section),$editImgIns), "attach" => "style='text-align:right;'")
+ ));
+ }
+ } else {
+ $DhcpList->AddEntry(array(
+ array("string" => $values),
+ array("string" => str_replace("%s",base64_encode($section),$editImg), "attach" => "style='text-align:right;'")
+ ));
+ }
+ }
+
+ /* Display tempalte */
+ $smarty->assign("DhcpList",$DhcpList->DrawList());
+ $display.= $smarty->fetch(get_template_path('servdhcp.tpl', TRUE));
+ return($display);
+ }
+
+
+ function remove_from_parent()
+ {
+ /* Cancel if there's nothing to do here */
+ if (!$this->initially_was_account){
+ return;
+ }
+
+ /* Remove subtrees */
+ $ldap= $this->config->get_ldap_link();
+ foreach ($this->dhcpObjectCache as $dn => $content){
+ if ($this->objectType($dn) == 'dhcpService'){
+ $ldap->rmdir_recursive($dn);
+ show_ldap_error($ldap->get_error(), _("Removing DHCP entries failed"));
+ }
+ }
+
+ /* Remove from self */
+ $ldap= $this->config->get_ldap_link();
+
+ /* Remove and write to LDAP */
+ plugin::remove_from_parent();
+
+ @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->attributes, "Save");
+ $ldap->cd($this->dn);
+ $this->cleanup();
+ $ldap->modify ($this->attrs);
+
+ show_ldap_error($ldap->get_error(), _("Removing DHCP entries failed"));
+
+ /* Optionally execute a command after we're done */
+ $this->handle_post_events("remove");
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ plugin::save_object();
+ }
+
+
+ /* Check supplied data */
+ function check()
+ {
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+
+ return ($message);
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ /* Take over handling
+ * - Load servdhcp class and dhcpObjectCache for the source dhcp setup.
+ * - Assign dhcpObjectCache to this configuration.
+ * - Save this setup and remove source setup from ldap.
+ */
+ if($this->take_over_id != -1){
+ $id = $this->take_over_id;
+ $src = preg_replace("/cn=dhcp,/","",$this->dhcp_server_list['ENTRIES'][$id]['dn']);
+ $tmp = new servdhcp ($this->config, $src);
+ $this->orig_dn = $src;
+ $this->dhcpObjectCache = $tmp->dhcpObjectCache;
+ }
+
+ /* Save dhcp setttings */
+ $ldap= $this->config->get_ldap_link();
+ foreach ($this->dhcpObjectCache as $dn => $data){
+
+ if($this->dn != $this->orig_dn){
+ $dn = preg_replace("/".normalizePreg($this->orig_dn)."$/i",$this->dn,$dn);
+ }
+
+ /* Remove entry? */
+ if (count($data) == 0){
+ /* Check if exists, then remove... */
+ if($ldap->cat($dn)){
+ $ldap->rmdir_recursive($dn);
+ show_ldap_error($ldap->get_error(), _("Can't remove DHCP object!"));
+ }
+ continue;
+ }
+
+ /* Opdate dhcp option 'server-name' to actual server name */
+ if($this->dn != $this->orig_dn){
+ $fixed = FALSE;
+ foreach(array("dhcpHost","dhcpSubnet","dhcpGroup","dhcpSharedNetwork") as $object){
+ if(in_array($object,$data['objectClass']) && isset($data['dhcpOption'])){
+ foreach($data['dhcpOption'] as $key => $option){
+ if(preg_match("/^server-name /",$option)){
+ $data['dhcpOption'][$key] = "server-name ".$this->cn;
+ $data['MODIFIED'] = TRUE;
+ break;
+ }
+ }
+ }
+
+ /* Skip next loops if entry is updated */
+ if($fixed){
+ break;
+ }
+ }
+ }
+
+ /* Modify existing entry? */
+ if (isset($data['MODIFIED']) || $this->orig_dn != $this->dn){
+
+ if($ldap->cat($dn)){
+ $modify= TRUE;
+ } else {
+ $modify= FALSE;
+ }
+
+ /* Build new entry */
+ $attrs= array();
+ foreach ($data as $attribute => $values){
+ if ($attribute == "MODIFIED" || $attribute == "dn"){
+ continue;
+ }
+
+ if(in_array($attribute,array("dhcpPrimaryDN","dhcpSecondaryDN","dhcpServerDN","dhcpFailOverPeerDN"))){
+ foreach($values as $v_key => $value){
+ $values[$v_key] = preg_replace("/".normalizePreg($this->orig_dn)."$/i",$this->dn,$value);
+ }
+ }
+
+ if (count($values)){
+
+ if($attribute == "dhcpOption"){
+ foreach($values as $key => $value){
+ $option_name = trim(preg_replace("/[^ ]*$/","",$value));
+ $option_value= trim(preg_replace("/^[^ ]*/","",$value));
+ if(in_array($option_name,$this->quote_option)){
+ $values[$key] = $option_name." \"".$option_value."\"";
+ }
+ }
+ }
+ if (count($values) == 1){
+ $attrs[$attribute]= $values[0];
+ } else {
+ $attrs[$attribute]= $values;
+ }
+ } else {
+ if ($modify){
+ $attrs[$attribute]= array();
+ }
+ }
+ }
+
+ $ldap->cd($dn);
+ if ($modify){
+ $ldap->modify($attrs);
+ show_ldap_error($ldap->get_error(), _("Can't save DHCP object!"));
+
+ /* Optionally execute a command after we're done */
+ $this->handle_post_events("modify");
+ } else {
+ $ldap->add($attrs);
+ show_ldap_error($ldap->get_error(), _("Can't save DHCP object!"));
+
+ /* Optionally execute a command after we're done */
+ $this->handle_post_events("create");
+ }
+ }
+ }
+
+ $this->dhcpServiceDN= $this->serviceDN;
+ if($this->dn != $this->orig_dn){
+ $this->dhcpServiceDN= preg_replace("/".normalizePreg($this->orig_dn)."$/i",$this->dn,$this->dhcpServiceDN);
+ }
+
+ /* Replace 'new' dn */
+ if(preg_match("/new$/",$this->dhcpServiceDN)){
+ $this->dhcpServiceDN = preg_replace("/new$/",$this->dn,$this->dhcpServiceDN);
+ }
+
+ plugin::save();
+
+ /* Save data to LDAP */
+ $ldap->cd($this->dn);
+ $this->cleanup();
+ $ldap->modify ($this->attrs);
+
+ show_ldap_error($ldap->get_error(), _("Saving DHCP service failed"));
+
+ /* Optionally execute a command after we're done */
+ if ($this->initially_was_account == $this->is_account){
+ if ($this->is_modified){
+ $this->handle_post_events("modify");
+ }
+ } else {
+ $this->handle_post_events("add");
+ }
+
+ /* Take over handling
+ * - Remove old dhcp config from source server
+ */
+ if($this->take_over_id != -1){
+ $id = $this->take_over_id;
+ $src = $this->dhcp_server_list['ENTRIES'][$id]['dn'];
+ $tmp = new servdhcp ($this->config, $src);
+ $tmp->remove_from_parent();
+ }
+ }
+
+
+ function reload()
+ {
+ /* Init LDAP and load list */
+ $ldap= $this->config->get_ldap_link();
+ $ui= get_userinfo();
+ $me= $this->dn;
+
+ $filter = "(&(objectClass=dhcpService)(|(dhcpPrimaryDN=$me)(dhcpSecondaryDN=$me)(dhcpServerDN=$me)(dhcpFailOverPeerDN=$me)))";
+
+ $list= get_list($filter, array("server"), $this->config->current['BASE'], array("cn"),GL_SIZELIMIT | GL_SUBSEARCH);
+ $final= array();
+
+ foreach ($list as $value){
+
+ /* Set header */
+ $sortpart= split(",", $value['dn']);
+ $sortpart= array_reverse($sortpart);
+ $tmp= implode(",", $sortpart);
+
+ $final[$value['dn']]= $tmp."!"._("Global options");
+
+ /* Read all sub entries to place here */
+ $ldap->cd($value['dn']);
+ $ldap->search("(|(objectClass=dhcpService)(objectClass=dhcpLog)(objectClass=dhcpClass)(objectClass=dhcpSubClass)(objectClass=dhcpHost)(objectClass=dhcpGroup)(objectClass=dhcpPool)(objectClass=dhcpSubnet)(objectClass=dhcpSharedNetwork)(objectClass=dhcpOptions)(objectClass=dhcpTSigKey)(objectClass=dhcpDnsZone)(objectClass=dhcpFailOverPeer))", array());
+ $this->serviceDN= $value['dn'];
+
+ while ($attrs= $ldap->fetch()){
+ $sattrs= array();
+ for ($i= 0; $i<$attrs['count']; $i++){
+ $sattrs[$attrs[$i]]= $attrs[$attrs[$i]];
+ unset($sattrs[$attrs[$i]]['count']);
+ }
+ $sattrs['dn']= $ldap->getDN();
+
+ foreach($sattrs as $name => $values){
+ if($name == "dhcpOption"){
+ foreach($values as $key => $value){
+ $value_name = trim(preg_replace("/[^ ]*$/","",$value));
+ $value_value= trim(preg_replace("/^[^ ]*/","",$value));
+ if(in_array($value_name,$this->quote_option)){
+ $value_value = preg_replace("/^\"/","",$value_value);
+ $value_value = preg_replace("/\"$/","",$value_value);
+ $sattrs[$name][$key] = $value_name." ".$value_value;
+ }
+ }
+ }
+ }
+
+ $this->dhcpObjectCache[$ldap->getDN()]= $sattrs;
+ $tmp= preg_replace("/".$this->serviceDN."/", "", $ldap->getDN());
+ $indent= substr_count($tmp, ",");
+ $spaces= "";
+ for ($i= 0; $i<$indent; $i++){
+ $spaces.= " ";
+ }
+
+ foreach ($this->types as $key => $val){
+ if (in_array("$key", $attrs['objectClass'])){
+ $type= $val;
+ break;
+ }
+ }
+
+ /* Prepare for sorting... */
+ $sortpart= split(",", $ldap->getDN());
+ $sortpart= array_reverse($sortpart);
+ $tmp= implode(",", $sortpart);
+ $final[$ldap->getDN()]= $tmp."!".$spaces.$type." '".$attrs['cn'][0]."'";
+ }
+ }
+
+ /* Sort it... */
+ natsort($final);
+ $this->dhcpSections= array();
+ foreach ($final as $key => $val){
+ $this->dhcpSections[$key]= preg_replace('/^[^!]+!(.*)$/', '\\1', $val);
+ }
+
+ }
+
+
+ function objectType($dn)
+ {
+ $type= "";
+ $types= array("dhcpService", "dhcpClass", "dhcpSubClass", "dhcpHost",
+ "dhcpGroup", "dhcpPool", "dhcpSubnet", "dhcpSharedNetwork");
+
+ foreach ($this->dhcpObjectCache[$dn]['objectClass'] as $oc){
+ if (in_array($oc, $types)){
+ $type= $oc;
+ break;
+ }
+ }
+
+ /* That should not happen... */
+ if ($type == ""){
+ print_red(_("DHCP configuration set is unknown. Please contact your system administrator."));
+ }
+
+ return ($type);
+ }
+
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("DHCP service"),
+ "plDescription" => _("DHCP service")." ("._("Services").")",
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 84,
+ "plSection" => array("administration"),
+ "plCategory" => array("server"),
+
+ "plProvidedAcls"=> array(
+
+ )
+ ));
+ }
+
+
+ function take_over_service()
+ {
+
+ }
+
+
+ function get_list_of_dhcp_servers()
+ {
+ $ret = array("ENTRIES"=> array(),"FOR_LIST"=> array());
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(&(objectClass=goServer)(dhcpServiceDN=*))",array("dn","cn","dhcpServiceDN"));
+ while($attrs = $ldap->fetch()){
+
+ /* Skip own config */
+ if($this->dn != "new" && preg_match("/".normalizePreg($this->dn)."$/",$attrs['dn'])){
+ continue;
+ }
+
+ $ret['ENTRIES'][] = $attrs;
+ }
+ foreach($ret['ENTRIES'] as $key => $data){
+ $ret['FOR_LIST'][$key] = $data['cn'][0];
+ }
+ return($ret);
+ }
+
+
+ function getListEntry()
+ {
+ $fields = goService::getListEntry();
+ $fields['Message'] = _("DHCP service");
+ $fields['AllowEdit'] = true;
+ return($fields);
+ }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/dhcp/dhcpNewSection.tpl b/plugins/admin/systems/services/dhcp/dhcpNewSection.tpl
new file mode 100644
index 000000000..517c3b403
--- /dev/null
+++ b/plugins/admin/systems/services/dhcp/dhcpNewSection.tpl
@@ -0,0 +1,25 @@
+
+ {t}Create new DHCP section{/t}
+
+
+
+{t}Please choose one of the following DHCP section types.{/t}
+
+
+{t}Section{/t}
+
+ {html_options options=$sections}
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/dhcp/dhcp_advanced.tpl b/plugins/admin/systems/services/dhcp/dhcp_advanced.tpl
new file mode 100644
index 000000000..5ce0e4600
--- /dev/null
+++ b/plugins/admin/systems/services/dhcp/dhcp_advanced.tpl
@@ -0,0 +1,46 @@
+{* GOsa dhcp sharedNetwork - smarty template *}
+
+
+
+
+{if $show_advanced}
+
+
+
+
+
+{else}
+
+
+
+{/if}
+
diff --git a/plugins/admin/systems/services/dhcp/dhcp_group.tpl b/plugins/admin/systems/services/dhcp/dhcp_group.tpl
new file mode 100644
index 000000000..930fc05ee
--- /dev/null
+++ b/plugins/admin/systems/services/dhcp/dhcp_group.tpl
@@ -0,0 +1,22 @@
+{* GOsa dhcp sharedNetwork - smarty template *}
+
{t}Generic{/t}
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/dhcp/dhcp_host.tpl b/plugins/admin/systems/services/dhcp/dhcp_host.tpl
new file mode 100644
index 000000000..602c51255
--- /dev/null
+++ b/plugins/admin/systems/services/dhcp/dhcp_host.tpl
@@ -0,0 +1,52 @@
+{* GOsa dhcp host - smarty template *}
+
{t}Generic{/t}
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/dhcp/dhcp_network.tpl b/plugins/admin/systems/services/dhcp/dhcp_network.tpl
new file mode 100644
index 000000000..5645a63ac
--- /dev/null
+++ b/plugins/admin/systems/services/dhcp/dhcp_network.tpl
@@ -0,0 +1,90 @@
+{* GOsa dhcp sharedNetwork - smarty template *}
+
+
+
+ {t}Network configuration{/t}
+
+
+
+ {t}Bootup{/t}
+
+
+
+
+ {t}Domain Name Service{/t}
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/dhcp/dhcp_pool.tpl b/plugins/admin/systems/services/dhcp/dhcp_pool.tpl
new file mode 100644
index 000000000..dcbd05c3d
--- /dev/null
+++ b/plugins/admin/systems/services/dhcp/dhcp_pool.tpl
@@ -0,0 +1,26 @@
+{* GOsa dhcp sharedNetwork - smarty template *}
+
{t}Generic{/t}
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/dhcp/dhcp_service.tpl b/plugins/admin/systems/services/dhcp/dhcp_service.tpl
new file mode 100644
index 000000000..6ca515e67
--- /dev/null
+++ b/plugins/admin/systems/services/dhcp/dhcp_service.tpl
@@ -0,0 +1,43 @@
+
{t}Generic{/t}
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/dhcp/dhcp_sharedNetwork.tpl b/plugins/admin/systems/services/dhcp/dhcp_sharedNetwork.tpl
new file mode 100644
index 000000000..374da3500
--- /dev/null
+++ b/plugins/admin/systems/services/dhcp/dhcp_sharedNetwork.tpl
@@ -0,0 +1,107 @@
+{* GOsa dhcp sharedNetwork - smarty template *}
+
{t}Generic{/t}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {t}Leases{/t}
+
+
+
+
+
+ {t}Access control{/t}
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/dhcp/dhcp_subnet.tpl b/plugins/admin/systems/services/dhcp/dhcp_subnet.tpl
new file mode 100644
index 000000000..05425fbdc
--- /dev/null
+++ b/plugins/admin/systems/services/dhcp/dhcp_subnet.tpl
@@ -0,0 +1,41 @@
+{* GOsa dhcp subnet - smarty template *}
+
{t}Generic{/t}
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/dhcp/remove_dhcp.tpl b/plugins/admin/systems/services/dhcp/remove_dhcp.tpl
new file mode 100644
index 000000000..39fb19bb6
--- /dev/null
+++ b/plugins/admin/systems/services/dhcp/remove_dhcp.tpl
@@ -0,0 +1,17 @@
+
+
{t}Warning{/t}
+
+
+ {$warning}
+ {t}This includes 'all' DHCP subsections that are located within this section. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t}
+
+
+
+ {t}Best thing to do before performing this action would be to save the current contents of your LDAP tree in a file. So - if you've done so - press 'Delete' to continue or 'Cancel' to abort.{/t}
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/dhcp/servdhcp.tpl b/plugins/admin/systems/services/dhcp/servdhcp.tpl
new file mode 100644
index 000000000..846af22ff
--- /dev/null
+++ b/plugins/admin/systems/services/dhcp/servdhcp.tpl
@@ -0,0 +1,35 @@
+{if $dns_take_over}
+
+
+
+ {t}DHCP take over will take place when saving this entry. Choose 'Cancel' to abort.{/t}
+
+
+
+{else}
+
+{/if}
+
+
+
+
+
+
"Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account = FALSE;
+ var $attributes = array();
+ var $objectclasses = array("whatever");
+
+ var $RecordTypes = array();
+ var $Zones = array();
+
+ var $orig_dn = "";
+
+ var $initially_was_account;
+
+ /* ServerService tab vars */
+ var $conflicts = array("servdns");
+ var $DisplayName = "";
+ var $StatusFlag = "";
+ var $view_logged = FALSE;
+
+ var $dns_server_list = array("ENTRIES"=> array(),"FOR_LIST"=> array());
+ var $take_over_id = -1;
+
+
+ function servdns (&$config, $dn= NULL, $parent= NULL)
+ {
+ plugin::plugin ($config, $dn, $parent);
+
+ $this->DisplayName = _("DNS service");
+
+ $this->orig_dn = $dn;
+
+ /* Get record types for zones
+ */
+ $this->RecordTypes = getDnsRecordTypes(true);
+
+ /* Get all zone Informations
+ */
+ $this->Zones = getDNSZoneEntries($config,$dn);
+
+ /* If there is at least one entry in this -> types, we have DNS enabled
+ */
+ if(count($this->Zones) == 0){
+ $this->is_account = false;
+ $this->dns_server_list = $this->get_list_of_dns_servers();
+ }else{
+ $this->is_account = true;
+ }
+ $this->initially_was_account = $this->is_account;
+ }
+
+
+ function get_list_of_dns_servers()
+ {
+ $ret = array("ENTRIES"=> array(),"FOR_LIST"=> array());
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(&(objectClass=dNSZone)(zoneName=*))",array("dn","zoneName"));
+ $dns = array();
+ while($attrs = $ldap->fetch()){
+ /* Skip own config */
+ if($this->dn != "new" && preg_match("/".normalizePreg($this->dn)."$/",$attrs['dn'])){
+ continue;
+ }
+ $dn = preg_replace("/^zoneName=[^,]+,/","",$attrs['dn']);
+ if(preg_match("/^cn=/",$dn) && !in_array($dn,$dns)){
+ $dns[] = $dn;
+ }
+ }
+ $i = 0;
+ foreach($dns as $dn){
+ $ldap->cat($dn,array('*'));
+ if($ldap->count()){
+ $i ++;
+ $attrs = $ldap->fetch();
+ $ret['ENTRIES'][$i] = $attrs;
+ $ret['FOR_LIST'][$i] = $attrs['cn'][0];
+ }
+ }
+ return($ret);
+ }
+
+
+ function get_dns_info_string($id)
+ {
+ $ret="";
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->dns_server_list['ENTRIES'][$id]['dn']);
+ $ldap->search("(|(zoneName=*)(relativeDomainName=*))",array("dn"));
+ while($attrs = $ldap->fetch()){
+ $ret .= $attrs['dn']."\n";
+ }
+ return($ret);
+ }
+
+
+ function execute()
+ {
+ /* Call parent execute
+ */
+ plugin::execute();
+
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","server/".get_class($this),$this->dn);
+ }
+
+ /* Fill templating stuff
+ */
+ $smarty= get_smarty();
+ $smarty->assign("dns_take_over",FALSE);
+ $smarty->assign("is_createable",$this->acl_is_createable());
+ $display= "";
+
+
+ $this->initially_was_account= $this->is_account;
+ /*****************/
+ /* Handle Take Over Actions
+ /*****************/
+
+ /* Give smarty the required informations */
+ $smarty->assign("dns_server_list", $this->dns_server_list['FOR_LIST']);
+ $smarty->assign("dns_server_list_cnt", count($this->dns_server_list['FOR_LIST']));
+
+ /* Take over requested, save id */
+ if(isset($_POST['take_over_src']) && isset($_POST['take_over'])){
+ $id = $_POST['take_over_src'];
+ if(isset($this->dns_server_list['ENTRIES'][$id])){
+ $this->take_over_id = $id;
+ }
+ }
+
+ /* Abort take over action */
+ if(isset($_POST['cancel_take_over'])){
+ $this->dialog =false;
+ $this->take_over_id = -1;
+ $this->dns_server_list = $this->get_list_of_dns_servers();
+ }
+
+ /* Display informartion about take over that will be started when saving this server
+ * and hide default dns output
+ */
+ if($this->take_over_id != -1){
+ $this->dialog = FALSE;
+ $id = $this->take_over_id;
+ $info = $this->get_dns_info_string($id);
+ $smarty->assign("dns_take_over",TRUE);
+ $smarty->assign("info",$info);
+ $warning = sprintf(_("You are going to migrate the DNS setup from server '%s'."),$this->dns_server_list['ENTRIES'][$id]['cn'][0]);
+ $warning2 = _("The migration will be startet when you save this system. To cancel this action, use the cancel button below.");
+ $smarty->assign("warning",$warning);
+ $smarty->assign("warning2",$warning2);
+ return($smarty->fetch(get_template_path('servdns.tpl', TRUE)));
+ }
+
+
+ /* Do we need to flip is_account state?
+ */
+ if (isset($_POST['modify_state'])){
+ $this->is_account= !$this->is_account;
+ }
+
+ if ($this->is_account){
+ $display= $this->show_disable_header(_("Remove DNS service"),
+ _("This server has DNS features enabled. You can disable them by clicking below."));
+ } else {
+ $display= $this->show_enable_header(_("Add DNS service"),
+ _("This server has DNS features disabled. You can enable them by clicking below."));
+ return ($display);
+ }
+
+
+ /* Edited or Added zone
+ */
+ if(isset($_POST['SaveZoneChanges'])){
+ $this->dialog->save_object();
+
+ /* Check for errors
+ */
+ if(count($this->dialog->check())){
+ foreach($this->dialog->check() as $msgs){
+ print_red($msgs);
+ }
+ }else{
+ /* add new/edited zone
+ */
+ $ret = $this->dialog->save();
+ if(!$this->dialog->isNew){
+ unset($this->Zones[$this->dialog->OldZoneName]);
+ }
+ $this->Zones[$ret['zoneName']] = $ret;
+ $this->dialog = FALSE;
+ }
+ }
+
+ /* Cancel zone edit / new
+ */
+ if(isset($_POST['CancelZoneChanges'])){
+ $this->dialog = FALSE;
+ }
+
+ /* Add empty new zone
+ */
+ if(isset($_POST['AddZone'])){
+ $this->dialog = new servdnseditZone($this->config,$this->dn);
+ }
+
+ /* Check for edit zone request
+ */
+ $once = false;
+ foreach( $_POST as $name => $value){
+
+ /* check all post for edit request
+ */
+ if(preg_match("/^editZone_/",$name)&&!$once){
+ $once =true;
+ $tmp = preg_replace("/^editZone_/","",$name);
+ $tmp = base64_decode(preg_replace("/_.*$/","",$tmp));
+ $this->dialog= new servdnseditZone($this->config,$this->dn,$this->Zones[$tmp]);
+ }
+
+ /* check posts for delete zone
+ */
+ if(preg_match("/^delZone_/",$name)&&!$once){
+
+ $once =true;
+ $tmp = preg_replace("/^delZone_/","",$name);
+ $tmp = base64_decode(preg_replace("/_.*$/","",$tmp));
+
+ /* Initiate deletion
+ */
+ $this->RemoveZone($tmp);
+ }
+ }
+
+ if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id'])){
+ $id = base64_decode($_GET['id']);
+ if(isset($this->Zones[$id])){
+ $this->dialog= new servdnseditZone($this->config,$this->dn,$this->Zones[$id]);
+ }
+ }
+
+ if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id'])){
+ $id = base64_decode($_GET['id']);
+ if(isset($this->Zones[$id])){
+ $this->dialog= new servdnseditZone($this->config,$this->dn,$this->Zones[$id]);
+ }
+ }
+
+ /* Show dialog
+ */
+ if(is_object($this->dialog)){
+ $this->dialog->save_object();
+ $this->dialog->parent = $this;
+ return($this->dialog->execute());
+ }
+
+ /* Create Listbox with existing Zones
+ */
+ $ZoneList = new divSelectBox("dNSZones");
+ $ZoneList -> SetHeight(254);
+
+ /* Add entries to divlist
+ */
+ $editImg = "
";
+ if($this->acl_is_removeable()){
+ $editImg.= "
";
+ }
+
+ $link = "
%s ";
+ foreach($this->Zones as $zone => $values ){
+ $ZoneList->AddEntry(array(
+ array("string" => sprintf($link,base64_encode($zone),($zone))),
+ array("string" => sprintf($link,base64_encode($zone),_("Reverse zone")." : ".($values['ReverseZone']))),
+ array("string" => _("TTL")." : ".$values['sOAttl']),
+ array("string" => _("Class")." : ".$values['dNSClass']),
+ array("string" =>str_replace("%s",base64_encode($zone),$editImg))
+ ));
+ }
+
+ /* Display tempalte
+ */
+ $smarty->assign("ZoneList",$ZoneList->DrawList());
+ $display.= $smarty->fetch(get_template_path('servdns.tpl', TRUE));
+ return($display);
+ }
+
+
+ /* Delete specified zone
+ */
+ function RemoveZone($id)
+ {
+ $zones = $this->getUsedZoneNames();
+
+ if(isset($this->Zones[$id]['InitialReverseZone'])){
+ $rev = FlipIp($this->Zones[$id]['InitialReverseZone']);
+ }else{
+ $rev = FlipIp($this->Zones[$id]['ReverseZone']);
+ }
+
+ $zonename = "";
+ if(isset($this->Zones[$id]['InitialzoneName'])){
+ $zonename= $this->Zones[$id]['InitialzoneName'];
+ }
+
+ $used = array();
+
+ /* Add Records which use this zoneName
+ */
+ if(isset($zones[$zonename])){
+ $used = array_merge($used,$zones[$zonename]);
+ }
+
+ /* Add Records which uses this reverse zone
+ */
+ if(isset($zones[$rev.".in-addr.arpa"])){
+ $used = array_merge($used,$zones[$rev.".in-addr.arpa"]);
+ }
+
+ /* There are still entries using this configuration
+ * Abort deletion
+ */
+ if(count($used)){
+ $i = 2;
+ $str ="";
+ foreach($used as $dn){
+ if($i > 0 && !preg_match("/,relativeDomainName=/",$dn)){
+ $i --;
+ $name = preg_replace("/^[^=]+=([^,]*),.*$/","\\1",$dn);
+ $zone = preg_replace("/^.*zoneName=([^,]*),.*$/","\\1",$dn);
+ $str.= $name.".".$zone." ";
+ }
+ }
+
+ /* Only show 2 dns in the error message
+ */
+ if(count($used)> 2) {
+ $str .=" ... ";
+ }
+ print_red(sprintf(_("Can't delete the selected zone, because it is still in use by these entry/entries '%s'"),trim($str)));
+ return(false);
+ }else{
+ unset($this->Zones[$id]);
+ return(true);
+ }
+ }
+
+
+ /* This funtion returns all used Zonenames
+ */
+ function getUsedZoneNames()
+ {
+ $ret = array();
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(&(objectClass=dNSZone)(!(relativeDomainName=@))(zoneName=*))",array("zoneName","relativeDomainName"));
+ while($attr = $ldap->fetch()){
+ $ret[$attr['zoneName'][0]][] = $attr['dn'];
+ }
+ return($ret);
+ }
+
+
+ /* Remove dns service
+ */
+ function remove_from_parent()
+ {
+ if($this->initially_was_account){
+ $bool = true;
+ $this->is_account = FALSE;
+ foreach($this->Zones as $key => $zone){
+ $bool= $bool & $this->RemoveZone($key);
+ }
+
+ if($bool){
+ $this->save();
+ }
+ return($bool);
+ }
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+
+ /* Take over handling
+ * - Create list of zones managed by source server
+ * - Copy ldap entries to destination server
+ * - Remove old zone entries from source
+ */
+ if($this->take_over_id != -1){
+ $del = array();
+ $id = $this->take_over_id;
+ $src = $this->dns_server_list['ENTRIES'][$id]['dn'];
+ $ldap = $this->config->get_ldap_link();
+ $ldap->ls("(objectClass=dnsZone)",$src,array('cn'));
+ while($attrs = $ldap->fetch()){
+ $src_zone = $attrs['dn'];
+ $dst_zone = preg_replace("/".normalizePreg($src)."$/",$this->dn,$src_zone);
+ $res = plugin::recursive_move($src_zone, $dst_zone);
+
+ if($res){
+ $del [] = $src_zone;
+ }
+ }
+ foreach($del as $src_zone){
+ $ldap->rmdir_recursive($src_zone);
+ }
+ return;
+ }
+
+ /* Save zone editor changes now */
+ foreach($this->Zones as $name => $zone){
+ if(isset($zone['zoneEditor'] ) && $zone['zoneEditor'] != NULL && is_object($zone['zoneEditor'])){
+ $zone['zoneEditor']->save();
+ unset($this->Zones[$name]['zoneEditor']);;
+ }
+ }
+
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+
+ /* Get differences
+ */
+ $old_dn = $this->orig_dn;
+ if($old_dn == "new"){
+ $old_dn = $this->dn;
+ }
+
+ $tmp = getDNSZoneEntriesDiff($this->config,$this->Zones,$old_dn);
+
+ /* Update dns to current object dn */
+ $tmp = getDNSZoneEntriesDiff($this->config,$this->Zones,$old_dn);
+ $tmp2 = array();
+ foreach($tmp as $key1 => $data1){
+ $tmp2[$key1] = array();
+ foreach($data1 as $key2 => $data2){
+ $tmp2[$key1][preg_replace("/".normalizePreg($old_dn)."$/",$this->dn,$key2)] = $data2;
+ }
+ }
+ $tmp = $tmp2;
+
+ /* Updated zone entries if reverser or forward name has changed
+ * Must be done before moving entries, else the given dn is invalid
+ */
+ if(isset($tmp['zoneUpdates'])){
+ foreach($tmp['zoneUpdates'] as $dn => $attrs){
+ $ldap->cd($dn);
+ $ldap->modify($attrs);
+ new log("modfiy","unknown/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ show_ldap_error($ldap->get_error(), sprintf(_("Updating of system server/dns with dn '%s' failed."),$this->dn));
+ }
+ }
+
+ /* Delete dns
+ */
+ foreach($tmp['del'] as $dn => $del){
+
+ $for = $del['InitialzoneName'];
+ $rev = FlipIp($del['InitialReverseZone']).".in-addr.arpa";
+
+ $ldap->cd($dn);
+ $ldap->rmdir_recursive($dn);
+ new log("remove","unknown/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ show_ldap_error($ldap->get_error(), sprintf(_("Removing of system server/dns with dn '%s' failed."),$this->dn));
+
+ /* Handle Post events */
+ if(preg_match("/^zoneName=/",$dn)){
+# $this->handle_post_events("remove",array("dn" => $dn,"zoneName" => $for));
+# $this->handle_post_events("remove",array("dn" => $dn,"zoneName" => $rev));
+ }
+ }
+
+ /* move follwoing entries
+ */
+ foreach($tmp['move'] as $src => $dst){
+ $this->recursive_move($src,$dst);
+ }
+
+ /* Add || Update new DNS entries
+ */
+ foreach($tmp['add'] as $dn => $attrs){
+ $ldap->cd($dn);
+ $ldap->cat($dn, array('dn'));
+ if($ldap->fetch()){
+ $ldap->cd($dn);
+ $ldap->modify ($attrs);
+ show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/dns with dn '%s' failed."),$this->dn));
+
+ /* Handle Post events */
+ if(preg_match("/^zoneName=/",$dn)){
+# $this->handle_post_events("modify",array("dn" => $dn,"zoneName" => $attrs['zoneName']));
+ }
+ }else{
+ $ldap->cd($dn);
+ $ldap->add($attrs);
+ show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/dns with dn '%s' failed."),$this->dn));
+
+ /* Handle Post events */
+ if(preg_match("/^zoneName=/",$dn)){
+# $this->handle_post_events("add",array("dn" => $dn,"zoneName" => $attrs['zoneName']));
+ }
+ }
+ }
+ $this->handle_post_events("modify");
+ }
+
+
+ /* Directly save new status flag */
+ function setStatus($value)
+ {
+ if($value == "none") return;
+ if(!$this->initially_was_account) return;
+ if(empty($this->StatusFlag)) return;
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->dn);
+ $ldap->cat($this->dn,array("objectClass"));
+ if($ldap->count()){
+
+ $tmp = $ldap->fetch();
+ for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
+ $attrs['objectClass'][] = $tmp['objectClass'][$i];
+ }
+ $flag = $this->StatusFlag;
+ $attrs[$flag] = $value;
+ $this->$flag = $value;
+ $ldap->modify($attrs);
+ show_ldap_error($ldap->get_error(), sprintf(_("Set status flag for system server/dns with dn '%s' failed."),$this->dn));
+ $this->action_hook();
+ }
+ }
+
+
+ function getListEntry()
+ {
+ $fields = goService::getListEntry();
+ $fields['Message'] = _("DNS service");
+ $fields['AllowEdit'] = true;
+ return($fields);
+ }
+
+
+ /* Get updates for status flag */
+ function updateStatusState()
+ {
+ if(empty($this->StatusFlag)) return;
+
+ $attrs = array();
+ $flag = $this->StatusFlag;
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->cn);
+ $ldap->cat($this->dn,array($flag));
+ if($ldap->count()){
+ $attrs = $ldap->fetch();
+ }
+ if(isset($attrs[$flag][0])){
+ $this->$flag = $attrs[$flag][0];
+ }
+ }
+
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("DNS service"),
+ "plDescription" => _("DNS service")." ("._("Services").")",
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 83,
+ "plSection" => array("administration"),
+ "plCategory" => array("server"),
+
+ "plProvidedAcls"=> array(
+ "zoneName" =>_("Zone name"),
+ "ReverseZone" =>_("Reverse zone"),
+ "sOAprimary" =>_("Primary dns server"),
+ "sOAmail" =>_("Mail address"),
+ "sOAserial" =>_("Serial"),
+ "sOArefresh" =>_("Refresh"),
+ "sOAretry" =>_("Retry"),
+ "sOAexpire" =>_("Expire"),
+ "sOAttl" =>_("TTL"),
+ "zoneRecords" =>_("Zone records"))
+ ));
+ }
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/dns/class_servDNSeditZone.inc b/plugins/admin/systems/services/dns/class_servDNSeditZone.inc
new file mode 100644
index 000000000..d5df0871d
--- /dev/null
+++ b/plugins/admin/systems/services/dns/class_servDNSeditZone.inc
@@ -0,0 +1,603 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account= TRUE;
+ var $attributes = array("zoneName","ReverseZone","dNSClass",
+ "sOAprimary","sOAmail","sOAserial","sOArefresh","sOAretry","sOAexpire","sOAttl");
+ var $objectclasses = array("whatever");
+
+ var $RecordTypes = array();
+
+ var $ReverseZone = "";
+ var $zoneName = "";
+ var $dNSClass = "IN";
+
+ var $sOAprimary = "";
+ var $sOAmail = "";
+ var $sOAserial = "";
+ var $sOArefresh = "3600";
+ var $sOAretry = "1800";
+ var $sOAexpire = "720000";
+ var $sOAttl = "6400";
+
+ var $Records = array();
+ var $mXRecords = array();
+
+ var $OldZoneName = ""; // To detect changes made with this edit
+ var $OldReverseZone = "";
+
+ var $InitialReverseZone = "";
+ var $InitialzoneName = "";
+ var $NetworkClass = "A" ; // One out of A,B,C
+
+ var $dialog = false;
+
+ var $zoneEditor = NULL;
+
+ var $isNew = true;
+
+ var $ZoneObject = array();
+
+ function servdnseditZone (&$config, $dn= NULL,$attrs = array())
+ {
+ plugin::plugin ($config, $dn);
+
+ /* All types with required attrs */
+ $this->RecordTypes = getDnsRecordTypes(true);
+
+ if(!count($attrs)){
+ $this->OldZoneName = "";
+ $this->OldReverseZone = "";
+ $this->isNew = true;
+ $this->sOAserial = date("Ymd")."1";
+
+ $this->InitialzoneName = "";//$attrs['InitialzoneName'];
+ $this->InitialReverseZone = "";//$attrs['InitialReverseZone'];
+ }else{
+ $this->ZoneObject = $attrs;
+
+ if(isset($attrs['zoneEditor'])){
+ $this->zoneEditor = $attrs['zoneEditor'];
+ }
+ $this->OldZoneName = $attrs['zoneName'];
+ $this->OldReverseZone = $attrs['ReverseZone'];
+
+ $this->InitialzoneName = $attrs['InitialzoneName'];
+ $this->InitialReverseZone = $attrs['InitialReverseZone'];
+
+ $this->isNew = false;
+
+ foreach($this->attributes as $value){
+ $this->$value = $attrs[$value];
+ }
+
+ $this->sOAmail = preg_replace("/\./","@",$this->sOAmail,1);
+ $this->sOAmail = preg_replace("/\.$/","",$this->sOAmail);
+ $this->sOAprimary = preg_replace("/\.$/","",$this->sOAprimary);
+ $this->zoneName = preg_replace("/\.$/","",$this->zoneName);
+
+ if(isset($attrs['RECORDS'])){
+ $this->Records = $attrs['RECORDS'];
+
+ $tmp2 = array();
+ $usedPrio = array();
+ foreach($this->Records as $key => $rec){
+ if($rec['type'] == "mXRecord"){
+ $tmp = split(" ",$rec['value']);
+ $rec['value'] = $tmp[1];
+ $tmp2[$tmp[0]] = $rec;
+ unset($this->Records[$key]);
+ }
+ if($rec['type'] == "nSRecord"){
+ unset($this->Records[$key]);
+ }
+ }
+ if(count($tmp2) != 0){
+ reset($tmp2);
+ ksort($tmp2);
+ }
+ $this->mXRecords = $tmp2;
+ }else{
+ $this->mXRecords = array();
+ $this->Records = array();
+ }
+
+ $str = date("Ymd");
+ if(preg_match("/^".$str."/",$this->sOAserial)){
+ $this->sOAserial = $this->sOAserial + 1;
+ }else{
+ $this->sOAserial = date("Ymd")."01";
+ }
+ }
+
+ /* Detect Network class */
+ if(!empty($this->ReverseZone)){
+
+ $dots = count(split("\.",$this->ReverseZone));
+ if($dots == 1){
+ $this->NetworkClass = "A";
+ $this->ReverseZone .= ".0.0.0";
+ }elseif($dots == 2){
+ $this->NetworkClass = "B";
+ $this->ReverseZone .= ".0.0";
+ }else{
+ $this->NetworkClass = "C";
+ $this->ReverseZone .= ".0";
+ }
+ }
+ }
+
+ /* TRansports the geiven Arraykey one position up*/
+ function ArrayUp($atr,$attrs)
+ {
+ $ret = $attrs;
+ $pos = $atr ;
+ $cn = count($attrs);
+ if(!(($pos == -1)||($pos == 1)||($pos >$cn))){
+ $before = array_slice($attrs,0,($pos-2));
+ $mitte = array_reverse(array_slice($attrs,($pos-2),2));
+ $unten = array_slice($attrs,$pos);
+ $ret = array();
+ $ret = $this->combineArrays($before,$mitte,$unten);
+ }
+ return($ret);
+ }
+
+
+ /* TRansports the geiven Arraykey one position up*/
+ function ArrayDown($atr,$attrs)
+ {
+ $ret = $attrs;
+ $pos = $atr ;
+ $cn = count($attrs);
+ if(!(($pos == -1)||($pos == $cn))){
+ $before = array_slice($attrs,0,($pos-1));
+ $mitte = array_reverse(array_slice($attrs,($pos-1),2));
+ $unten = array_slice($attrs,($pos+1));
+ $ret = array();
+ $ret = $this->combineArrays($before,$mitte,$unten);
+ }
+ return($ret);
+ }
+
+ /* Combine new array */
+ function combineArrays($ar0,$ar1,$ar2)
+ {
+ $ret = array();
+ if(is_array($ar0))
+ foreach($ar0 as $ar => $a){
+ $ret[]=$a;
+ }
+ if(is_array($ar1))
+ foreach($ar1 as $ar => $a){
+ $ret[]=$a;
+ }
+ if(is_array($ar2))
+ foreach($ar2 as $ar => $a){
+ $ret[]=$a;
+ }
+ return($ret);
+ }
+
+ function getpos($atr,$attrs)
+ {
+ $i = 0;
+ foreach($attrs as $attr => $name) {
+ $i++;
+ if($attr == $atr){
+ return($i);
+ }
+ }
+ return(-1);
+ }
+
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+
+
+ /* Fill templating stuff */
+ $smarty= get_smarty();
+ $ui = get_userinfo();
+
+ $smarty->assign("ACLs",$this->parent->getacl(""));
+ $display= "";
+
+ /* Open Zone Entry Edit Dialog
+ */
+ if(!count($this->ZoneObject)){
+ $smarty->assign("AllowZoneEdit" , false);
+ }else{
+ $smarty->assign("AllowZoneEdit" , true);
+ if(isset($_POST['EditZoneEntries'])){
+ if($this->zoneEditor == NULL){
+ $this->zoneEditor= new servDNSeditZoneEntries($this->config,$this->dn,$this->ZoneObject);
+ $this->zoneEditor->parent = $this;
+ }
+ $this->dialog = $this->zoneEditor;
+ }
+ }
+
+ /* Save Zone Entry Edit Dialog
+ */
+ if(isset($_POST['SaveZoneEntryChanges'])){
+ $this->dialog->save_object();
+ if(count($this->dialog->check())){
+ $msgs = $this->dialog->check();
+ foreach($msgs as $msg){
+ print_red($msg);
+ }
+ }else{
+ $this->zoneEditor = clone $this->dialog;
+ $this->dialog = FALSE;
+# $rev = FlipIp(getNameFromMix($this->InitialReverseZone)).".in-addr.arpa";
+# $for = getNameFromMix($this->InitialzoneName);
+#
+# $this->parent->handle_post_events("modify",array("dn" => $this->dn,"zoneName" => $rev));
+# $this->parent->handle_post_events("modify",array("dn" => $this->dn,"zoneName" => $for));
+# $this->dialog = false;
+ }
+ }
+
+ /* Cancel Zone Entrie Edit Dialog
+ */
+ if(isset($_POST['CancelZoneEntryChanges'])){
+ $this->dialog = false;
+ }
+
+ /* Display any type of open dialogs
+ */
+ if(is_object($this->dialog)){
+ $this->dialog->save_object();
+ return($this->dialog->execute());
+ }
+
+ $once =true;
+ foreach($_POST as $name => $value){
+ if((preg_match("/^MXup_/",$name)) && ($once)){
+ $once = false;
+
+ $id = preg_replace("/^MXup_/","",$name);
+ $id = preg_replace("/_.*$/","",$id);
+ $id = base64_decode($id);
+
+ $this->mXRecords = $this->ArrayUp(($id+1),$this->mXRecords);
+ }
+ if((preg_match("/^MXdown_/",$name)) && ($once)){
+ $once = false;
+
+ $id = preg_replace("/^MXdown_/","",$name);
+ $id = preg_replace("/_.*$/","",$id);
+ $id = base64_decode($id);
+
+ $this->mXRecords = $this->ArrayDown(($id+1),$this->mXRecords);
+ }
+ if((preg_match("/^MXdel_/",$name)) && ($once)){
+ $once = false;
+
+ $id = preg_replace("/^MXdel_/","",$name);
+ $id = preg_replace("/_.*$/","",$id);
+ $id = base64_decode($id);
+
+ unset($this->mXRecords[$id]);
+
+ $tmp =array();
+ foreach($this->mXRecords as $entry){
+ $tmp[] = $entry;
+ }
+
+ $this->mXRecords = $tmp;
+ }
+ }
+
+ if((isset($_POST['AddMXRecord'])) && (!empty($_POST['StrMXRecord']))){
+ $this->mXRecords[] = array("type"=>"mXRecord","value"=>trim($_POST['StrMXRecord']));
+ }
+
+ /* Handle Post events */
+ $once = true;
+ foreach($_POST as $name => $value){
+
+ /* Delete record if requested */
+ if((preg_match("/RemoveRecord_/",$name))&&($once)){
+ $once = false;
+ $id= preg_replace("/RemoveRecord_/","",$name);
+ unset($this->Records[$id]);
+ }
+ }
+
+ /* Add new Zonerecord */
+ if(isset($_POST['AddNewRecord'])){
+ $this->Records[] = array("type"=>"aRecord","value"=>"");
+ }
+
+ /* Fill in values */
+ foreach($this->attributes as $name){
+ $smarty->assign($name,$this->$name);
+ }
+
+
+ $div = new divSelectBox("MxRecords");
+ $div->setHeight(120);
+ $recs = $this->mXRecords;
+
+ $oneup = "
";
+ $onedown = "
";
+ $onedel = "
+
";
+
+ foreach($recs as $key => $rec){
+ $div ->AddEntry(array(
+ array("string"=>$rec['value']),
+/* array("string"=>$key,
+ "attach"=>"style='width:20px;'"),*/
+ array("string"=>str_replace("%s",base64_encode($key),$oneup.$onedown.$onedel),
+ "attach"=>"style='width:70px;border-right:0px;'")
+ ));
+ }
+
+ /* Assign records list */
+ $smarty->assign("NotNew", false);
+ $smarty->assign("Mxrecords", $div->DrawList());
+ $smarty->assign("records" , $this->generateRecordsList());
+ $smarty->assign("NetworkClass", $this->NetworkClass);
+ $smarty->assign("NetworkClasses", array("A"=>"255.0.0.0 (Class A)","B"=>"255.255.0.0 (Class B)","C"=>"255.255.255.0 (Class C)"));
+
+ /* Display tempalte */
+ $display.= $smarty->fetch(get_template_path('servdnseditzone.tpl', TRUE));
+ return($display);
+ }
+
+ function remove_from_parent()
+ {
+ }
+
+ /* Save data to object */
+ function save_object()
+ {
+ //plugin::save_object();
+ foreach($this->attributes as $attr){
+ if(isset($_POST[$attr])){
+ $this->$attr = $_POST[$attr];
+ }
+ }
+
+ foreach($this->Records as $id => $value){
+ if(isset($_POST['RecordTypeSelectedFor_'.$id])){
+ $this->Records[$id]['type'] = $_POST['RecordTypeSelectedFor_'.$id];
+ }
+ if(isset($_POST['RecordValue_'.$id])){
+ $this->Records[$id]['value'] = $_POST['RecordValue_'.$id];
+ }
+ }
+
+ if(isset($_POST['NetworkClass'])){
+ $this->NetworkClass = $_POST['NetworkClass'];
+ }
+
+ }
+
+
+ /* Check supplied data */
+ function check()
+ {
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+
+ /* Check if zoneName is already in use */
+ $usedZones = $this->getUsedZoneNames();
+ if(($this->isNew == true)||($this->zoneName != $this->InitialzoneName)||($this->ReverseZone != $this->InitialReverseZone)){
+ /* if((isset($usedZones[$this->zoneName]))&&($this->zoneName != $this->InitialzoneName)){
+ $message[] =_("This zoneName is already in use");
+ }
+ if((in_array($this->ReverseZone,$usedZones))&&($this->ReverseZone != $this->InitialReverseZone)){
+ $message[] =_("This reverse zone is already in use");
+ }*/
+ }
+
+ if(empty($this->zoneName)){
+ $message[] =sprintf(_("Please choose a valid zone name."));
+ }
+
+ if(empty($this->ReverseZone)){
+ $message[] =sprintf(_("Please choose a valid reverse zone name."));
+ }
+
+ if($this->zoneName != strtolower($this->zoneName)){
+ $message[] = _("Only lowercase strings are allowed as zone name.");
+ }
+
+ if(!is_numeric($this->sOAserial)){
+ $message[] = _("Please specify a numeric value for serial number.");
+ }
+
+ if(!is_numeric($this->sOArefresh)){
+ $message[] = _("Please specify a numeric value for refresh.");
+ }
+
+ if(!is_numeric($this->sOAttl)){
+ $message[] = _("Please specify a numeric value for ttl.");
+ }
+
+ if(!is_numeric($this->sOAexpire)){
+ $message[] = _("Please specify a numeric value for expire.");
+ }
+
+ if(!is_numeric($this->sOAretry)){
+ $message[] = _("Please specify a numeric value for retry.");
+ }
+
+ foreach($this->Records as $name => $values){
+ /* only lower-case is allowed in record entries ... */
+ if($values['value'] != strtolower($values['value'])){
+ $message[] = sprintf(_("Only lowercase is allowed, please check your '%ss'."),$values['type']);
+ }
+ }
+
+ /* Check class for given Zone Address */
+ $addr = preg_replace("/^[^\/]*+\//","",$this->ReverseZone);
+
+ /* Check for valid&complete IP address */
+ if(!is_ip($addr)){
+ $message[] = _("The given network address is not a valid, please specify a valid IP address.");
+ }
+
+ /* Check if given address matches selected network class */
+ switch($this->NetworkClass){
+ case 'A': {
+ if(!preg_match("/^[0-9]*\.0\.0\.0$/",$addr)){
+ $message[] = sprintf(_("The specified network address is not matching with the specified zone class, try it this way x.0.0.0"));
+ }
+ }
+ break;
+ case 'B': {
+ if(!preg_match("/^[0-9]*\.[0-9]*\.0\.0$/",$addr)){
+ $message[] = sprintf(_("The specified network address is not matching with the specified zone class, try it this way x.x.0.0"));
+ }
+ }
+ break;
+ case 'C': {
+ if(!preg_match("/^[0-9]*\.[0-9]*\.[0-9]*\.0$/",$addr)){
+ $message[] = sprintf(_("The specified network address is not matching with the specified zone class, try it this way x.x.x.0"));
+ }
+ }
+ break;
+ default : $message[] =sprintf(_("The given network class '%s' is not valid."),$this->NetworkClass);
+ }
+
+ return ($message);
+ }
+
+ /* This funtion returns all used Zonenames */
+ function getUsedZoneNames()
+ {
+ $ret = array();
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(&(objectClass=dNSZone)(relativeDomainName=@)(zoneName=*))",array("zoneName","tXTRecord"));
+ while($attr = $ldap->fetch()){
+ if(preg_match("/in-addr\.arpa/",$attr['zoneName'][0])){
+ if(isset($attr['tXTRecord'][0])){
+ $zn = preg_replace("/zoneName\=/","",$attr['tXTRecord'][0]);
+ $ret[$zn] =FlipIp(preg_replace("/\.in-addr\.arpa/","",$attr['zoneName'][0]));
+ }
+ }else{
+ $ret[$attr['zoneName'][0]]="";
+ }
+ }
+ return($ret);
+ }
+
+ /* Save to LDAP */
+ function save()
+ {
+ $ret =array();
+ foreach($this->attributes as $name){
+ $ret[$name] = $this->$name;
+ }
+
+ /* Create mx records
+ */
+ foreach($this->mXRecords as $key => $rec){
+ $rec['value']= $key." ".$rec['value'];
+ $this->Records [] = $rec;
+ }
+
+
+ $ret['RECORDS'] = $this->Records;
+
+ switch($this->NetworkClass){
+ case 'C' : $ret['ReverseZone']= preg_replace("/\.[0-9]*$/","",$this->ReverseZone);break;
+ case 'B' : $ret['ReverseZone']= preg_replace("/\.[0-9]*\.[0-9]*$/","",$this->ReverseZone);break;
+ case 'A' : $ret['ReverseZone']= preg_replace("/\.[0-9]*\.[0-9]*\.[0-9]*$/","",$this->ReverseZone);break;
+ default : trigger_error("Invalid network class given '".$this->NetworkClass."'");
+ }
+
+ $ret['InitialReverseZone']= $this->InitialReverseZone;
+ $ret['InitialzoneName'] = $this->InitialzoneName;
+
+ $ret['sOAmail'] = preg_replace("/\@/",".",$this->sOAmail);
+
+ foreach(array("sOAprimary","zoneName","sOAmail") as $attr){
+ if(!preg_match("/\.$/",$ret[$attr])){
+ if(!is_ip($ret[$attr])){
+ $ret[$attr] = $ret[$attr].".";
+ }
+ }
+ }
+
+ $ret['RECORDS'][] = array("type" => "nSRecord","value" => $ret['sOAprimary']) ;
+
+ $ret['zoneEditor'] = $this->zoneEditor;
+ return($ret);
+ }
+
+
+ /* This function generate a table row for each used record.
+ This table row displays the recordtype in a select box
+ and the specified value for the record, and a remove button.
+ The last element of the table also got an 'add' button.
+ */
+ function generateRecordsList($changeStateForRecords="")
+ {
+ $changeStateForRecords = "";
+
+ $str = "
";
+ return($str);
+ }
+
+ /* This function generates a select box out of $this->RecordTypes options.
+ The Parameter $selected is used to predefine an attribute.
+ $name is used to specify a post name
+ */
+ function generateRecordListBox($selected,$name)
+ {
+ $str = "
";
+ foreach($this->RecordTypes as $type => $value){
+
+ if(preg_match("/^mXRecord$/i",$value)) continue;
+
+ $use = "";
+ if($type == $selected){
+ $use = " selected ";
+ }
+ $str.="\n ".strtoupper(preg_replace("/record/i","",$type))." ";
+ }
+ $str.=" ";
+ return($str);
+ }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/dns/class_servDNSeditZoneEntries.inc b/plugins/admin/systems/services/dns/class_servDNSeditZoneEntries.inc
new file mode 100644
index 000000000..8453ae794
--- /dev/null
+++ b/plugins/admin/systems/services/dns/class_servDNSeditZoneEntries.inc
@@ -0,0 +1,498 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account = TRUE;
+ var $attributes = array();
+ var $objectclasses = array("whatever");
+
+ var $Devices = array();
+
+ var $zoneName = ""; // ZoneName of currently edited Zone
+ var $reverseName = ""; // ReverseZone of the currently edited Zone
+
+ var $RecordTypes = array(); // Possible record type.
+
+ var $disableDialog = false; // Dialog will be disabled, if this zone is new
+
+ function servDNSeditZoneEntries (&$config,$dn, &$zoneObject)
+ {
+ plugin::plugin ($config, $dn);
+
+ /* Initialise class
+ */
+ $this->RecordTypes = getDnsRecordTypes();
+ $this->dn = "zoneName=".$zoneObject['InitialzoneName'].",".$dn;
+ $this->zoneName = $zoneObject['InitialzoneName'];
+ $this->reverseName = $zoneObject['InitialReverseZone'];
+
+ /* Remove nSRecord from listed types */
+ if(isset($this->RecordTypes['nSRecord'])){
+ unset($this->RecordTypes['nSRecord']);
+ }
+ /* Remove nSRecord from listed types */
+ if(isset($this->RecordTypes['pTRRecord'])){
+ unset($this->RecordTypes['pTRRecord']);
+ }
+
+ /* Get ldap connection
+ */
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+
+ /* Get zone content
+ */
+ $ldap->ls("(&(objectClass=dNSZone)(!(relativeDomainName=@)))",$this->dn,array("relativeDomainName"));
+
+ while($attrs = $ldap->fetch()){
+ $this->Devices[$attrs['relativeDomainName'][0]] = getDNSHostEntries($config,$attrs['relativeDomainName'][0],true);
+ $this->Devices[$attrs['relativeDomainName'][0]]['OrigCn'] = $attrs['relativeDomainName'][0];
+ }
+
+ $ldap->cat($this->dn,array("objectClass"));
+
+ $this->disableDialog = true;
+ if(count($this->Devices)|| $ldap->count()){
+ $this->disableDialog = false;
+ }
+ }
+
+ function execute()
+ {
+ plugin::execute();
+
+ /* Fill templating stuff */
+ $smarty= get_smarty();
+ $display= "";
+
+ $table = "";
+ foreach($this->Devices as $key => $dev){
+ $table .= $this->generateRecordConfigurationRow($key);
+ }
+
+ $smarty->assign("disableDialog",$this->disableDialog);
+ $smarty->assign("table",$table);;
+ $display.= $smarty->fetch(get_template_path('servDNSeditZoneEntries.tpl', TRUE));
+ return($display);
+ }
+
+
+ function save_object()
+ {
+ /* Check posts for operations ...
+ */
+ $once = true;
+ $ptr_updates = array();
+ foreach($_POST as $name => $value){
+
+ /* Add a new Record in given object
+ */
+
+ $tmp = preg_replace("/^.*_(.*)_.*$/","\\1",$name);
+ $tmp2 = split("\|",$tmp);
+
+ /* Add new host entry
+ */
+ if((preg_match("/^UserRecord_?/",$name)) && ($once)){
+ $once = false;
+ $entry = getDNSHostEntries($this->config,"",true);
+ $entry['exists'] = true;
+ $entry['zoneName'] = strtoupper($this->attrs['cn'][0])."/".$this->zoneName;
+ $entry['RECORDS'][] = array("type" => "aRecord" , "value"=>"");
+ $this->Devices[_("New entry")] = $entry;
+ }
+
+ if(count($tmp2) != 2) continue;
+
+ $Name = base64_decode($tmp2[0]);
+ $RecordID = $tmp2[1];
+
+ /* Add new REcord
+ */
+ if((preg_match("/^AddRecord_/",$name)) && ($once)){
+ $once = false;
+ $this->Devices[$Name]['RECORDS'][] = $this->Devices[$Name]['RECORDS'][$RecordID];
+ }
+
+ /* Remove record from given dn
+ */
+ if((preg_match("/^RemoveRecord_/",$name)) && ($once)){
+ $once = false;
+ if(isset($this->Devices[$Name]['RECORDS'][$RecordID])){
+ unset($this->Devices[$Name]['RECORDS'][$RecordID]);
+ }
+
+ /* Check if there is at least one visible record. Else remove complete entry */
+ $visible = false;
+ foreach($this->Devices[$Name]['RECORDS'] as $rec){
+ if(in_array($rec['type'],$this->RecordTypes)){
+ $visible = true;
+ break;
+ }
+ }
+ if(!$visible && isset($this->Devices[$Name]['RECORDS'])){
+ $this->Devices[$Name]['RECORDS'] = array();
+ }
+ }
+ }
+
+ /* Possible attributes posted
+ */
+ foreach($_POST as $name => $value){
+
+ /* Extract informations out of post name
+ */
+ $tmp = preg_replace("/^.*_/","\\1",$name);
+ $tmp2 = split("\|",$tmp);
+
+ if(count($tmp2) != 2) continue;
+
+ $Name = base64_decode($tmp2[0]);
+ $RecordID = $tmp2[1];
+
+ /* Check for value change
+ */
+ if(preg_match("/ValueSelection_/",$name)){
+ if(isset($this->Devices[$Name]['RECORDS'][$RecordID])){
+
+ /* Update value */
+ $old = $this->Devices[$Name]['RECORDS'][$RecordID]['value'];
+ $this->Devices[$Name]['RECORDS'][$RecordID]['value'] = $value;
+
+ /* Handle pTRRecord */
+ if(!isset($ptr_updates[$Name]) && $this->Devices[$Name]['RECORDS'][$RecordID]['type'] == "aRecord"){
+
+ $found = false;
+ $ip = $value;
+ $match = preg_replace("/^[^\/]*+\//","",$this->reverseName);
+ $ip = preg_replace("/^".normalizePreg($match)."/","",$ip);
+ $ip = preg_replace("/^\./","",$ip);
+
+ foreach($this->Devices[$Name]['RECORDS'] as $key => $dev){
+ if($dev['type'] == "pTRRecord"){
+ $ptr_updates[$Name] = $Name;
+ $this->Devices[$Name]['RECORDS'][$key]['value'] = $ip;
+ $found = true;
+ break;
+ }
+ }
+ if(!$found){
+ $dev = array('type'=> 'pTRRecord', 'value' => $ip);
+ $this->Devices[$Name]['RECORDS'][] = $dev;
+ }
+ }
+ }
+ }
+
+ /* record type changed
+ */
+ if(preg_match("/^RecordTypeSelection_/",$name)){
+ if(isset($this->Devices[$Name]['RECORDS'][$RecordID])){
+ $this->Devices[$Name]['RECORDS'][$RecordID]['type'] = $value;
+ }
+ }
+ }
+
+ /* check for renamed entries
+ */
+ foreach($_POST as $name => $value){
+
+ /* Extract informations out of post name
+ */
+ $tmp = preg_replace("/^.*_/","\\1",$name);
+ $tmp2 = split("\|",$tmp);
+
+ if(count($tmp2) != 2) continue;
+
+ $Name = base64_decode($tmp2[0]);
+ $RecordID = $tmp2[1];
+
+ /* Host renamed
+ */
+ if(preg_match("/RenameHost_/",$name)){
+ if((isset($this->Devices[$Name])) && ($Name != $value)){
+
+ if(isset($this->Devices[$value])){
+ print_red(sprintf(_("Can't rename '%s' to '%s' there is already an entry with the same name in our zone editing dialog."),$Name,$value));
+ }else{
+ $this->Devices[$value] = $this->Devices[$Name];
+ unset($this->Devices[$Name]);
+ }
+ }
+ }
+ }
+ }
+
+
+ /* check something
+ */
+ function check()
+ {
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+
+ $names = array();
+ foreach($this->Devices as $DevName => $device){
+
+ /* Don't need to check empty values ... */
+ if(!count($device['RECORDS'])) continue;
+
+ /* Checking entry name
+ */
+ if(!preg_match("/^[a-z0-9_\.-]+$/i", $DevName) || (empty($DevName))){
+ $message[] = sprintf(_("Entry name '%s' contains invalid characters."), $DevName);
+ }
+
+ /* Renaming check for existing devices
+ */
+ if(isset($device['OrigCn']) && ($DevName != $device['OrigCn'] )){
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(relativeDomainName=".$DevName.")",array("relativeDomainName"));
+ if($ldap->count()){
+ $message[] = sprintf(_("Can not rename '%s' to '%s',the destination name already exists."),$device['OrigCn'],$DevName);
+ }
+ }elseif(!isset($device['OrigCn'])){
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(relativeDomainName=".$DevName.")",array("relativeDomainName"));
+ if($ldap->count()){
+ $message[] = sprintf(_("Can not create '%s',the destination name already exists."),$DevName);
+ }
+ }
+
+ /* Check names
+ */
+ if(!isset($names[$DevName])){
+ $names[$DevName] = "";
+ }else{
+ $message[] = sprintf(_("The name '%s' is used more than once."),$DevName);
+ }
+
+ /* Names should be written in lowercase
+ */
+# if(strtolower($DevName) != $DevName){
+# $message[] = sprintf(_("The host name '%s' should be written in lowercase."), $DevName);
+# }
+
+ /* Check records
+ */
+ $singleEntries = array("cNAMERecord","pTRRecord");
+
+ $tmp = array();
+ $tmp2 = array();
+ foreach($device['RECORDS'] as $Num => $Rec){
+
+ /* Check for multiple use of unique record types
+ */
+ if(in_array($Rec['type'],$singleEntries)){
+ if(!isset($tmp[$Rec['type']])){
+ $tmp[$Rec['type']] = "";
+ }else{
+ $message[] = sprintf(_("The record type '%s' is a unique type and can't be defined twice."),$Rec['type']);
+ }
+ }
+
+ /* Check for empty / duplicate entries in record array
+ */
+ if(empty($Rec['value'])){
+ $message[] = sprintf(_("There is an empty '%s' for host '%s'."),$Rec['type'],$DevName);
+ }
+
+ /* Check for duplicate record entries
+ */
+ if(!isset($tmp[$Rec['type']][$Rec['value']])){
+ $tmp[$Rec['type']][$Rec['value']] = "";
+ }else{
+ $message[] = sprintf(_("There is a duplicate entry in '%s' for '%s'."),$Rec['type'],$DevName);
+ }
+ }
+ }
+ return ($message);
+ }
+
+ function save()
+ {
+ if($this->disableDialog) return;
+
+ $todo = array();
+
+
+
+ /* Create todolist
+ */
+ foreach($this->Devices as $name => $dev){
+ if(isset($dev['OrigCn'])){
+ if(count($dev['RECORDS'])){
+ $todo[] = getDNSHostEntriesDiff($this->config,$dev['OrigCn'],$dev,$name);
+ }else{
+ $dev['exists'] = false;
+ $todo[] = getDNSHostEntriesDiff($this->config,$dev['OrigCn'],$dev,$name);
+ }
+ }else{
+ if(count($dev['RECORDS'])){
+ $todo[] = getDNSHostEntriesDiff($this->config,"",$dev,$name);
+ }else{
+ $dev['exists'] = false;
+ $todo[] = getDNSHostEntriesDiff($this->config,"",$dev,$name);
+ }
+ }
+ }
+
+ $tmp = array();
+ $tmp['del'] = array();
+ $tmp['add'] = array();
+ $tmp['move'] = array();
+ foreach($todo as $to){
+ foreach($to as $type => $entries){
+ $tmp[$type] = array_merge($tmp[$type],$entries);
+ }
+ }
+
+ /* Get ldap link
+ */
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd ($this->config->current['BASE']);
+
+ /* move follwoing entries
+ */
+ foreach($tmp['move'] as $src => $dst){
+ $this->recursive_move($src,$dst);
+ }
+
+ /* Delete dns */
+ foreach($tmp['del'] as $dn => $del){
+ $ldap->cd($dn);
+ $ldap->rmdir_recursive($dn);
+ if(is_object($this->parent->parent)){
+ $this->parent->parent->handle_post_events("remove",array("dn" => $dn));
+ }
+ }
+
+ /* Add || Update new DNS entries
+ */
+ foreach($tmp['add'] as $dn => $attrs){
+ $ldap->cd($dn);
+ $ldap->cat($dn, array('dn'));
+ if(count($ldap->fetch())){
+ $ldap->cd($dn);
+ $ldap->modify ($attrs);
+ if(is_object($this->parent->parent)){
+ $this->parent->parent->handle_post_events("modify",array("dn" => $dn));
+ }
+ }else{
+ $ldap->cd($dn);
+ $ldap->add($attrs);
+ if(is_object($this->parent->parent)){
+ $this->parent->parent->handle_post_events("create",array("dn" => $dn));
+ }
+ }
+ }
+ }
+
+
+ /* Create html table out of given entry
+ */
+ function generateRecordConfigurationRow($objKey){
+
+ /* Get some basic informations
+ */
+ $obj = $this->Devices[$objKey];
+ $objectName = $objKey;
+
+ /* Abort if emtpy
+ */
+ if(count($obj['RECORDS']) == 0) return "";
+
+ /* Set title
+ */
+ $str= "
";
+
+ $hostNameOnce = true;
+
+ /* Walk through all defined records
+ */
+ $str.= "
";
+ return($str);
+ }
+
+
+ /* Create selectbox with all available option types
+ */
+ function createRecordTypeSelection($id,$refID){
+
+ $str = "\n
";
+ foreach($this->RecordTypes as $type => $atr) {
+ if($id == $type){
+ $str .="\n".strtoupper(preg_replace("/record/i","",$type))." ";
+ }else{
+ $str .="\n".strtoupper(preg_replace("/record/i","",$type))." ";
+ }
+ }
+ $str.= "\n ";
+ return($str);
+ }
+
+
+ function remove_from_parent()
+ {
+ }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/dns/class_termDNS.inc b/plugins/admin/systems/services/dns/class_termDNS.inc
new file mode 100644
index 000000000..025933291
--- /dev/null
+++ b/plugins/admin/systems/services/dns/class_termDNS.inc
@@ -0,0 +1,1012 @@
+parent = $parent;
+ $this->objectclasses = $objectClasses;
+ $this->IPisMust = $IPisMust;
+
+ plugin::plugin ($config, $parent->dn);
+
+ if(isset($this->attrs['cn'][0])){
+ $this->OrigCn = preg_replace("/\\\$\$/","",$this->attrs['cn'][0]);
+ $this->cn = preg_replace("/\\\$\$/","",$this->attrs['cn'][0]);
+ }
+
+
+ /************
+ * DHCP
+ ************/
+
+ /* Hide all dhcp specific code, if dhcp plugin is not present in config */
+ $dhcpEnabled = FALSE;
+ if($this->config->search("servdhcp","class",array("tabs"))){
+ $this->dhcpEnabled = TRUE;
+ }
+ if($this->dhcpEnabled){
+ $this->dhcpParentNodes = $this->get_dhcp_parent_nodes();
+ $this->dhcpParentNode = $this->get_dhcp_parent_node();
+ if($this->dhcpParentNode){
+ $this->dhcp_is_Account = TRUE;
+ $this->initial_dhcp_is_Account = TRUE;
+ $this->dhcpHostEntry = $this->get_dhcp_host_entry();
+ }
+ $this->initial_dhcpHostEntry = $this->dhcpHostEntry;
+ $this->initial_dhcpParentNode= $this->dhcpParentNode;
+ }
+
+
+ /************
+ * Autonetwork hook
+ ************/
+
+ /* Do we have autonet support? */
+ if (isset($this->config->data['MAIN']['AUTO_NETWORK_HOOK'])){
+ $this->autonet= true;
+ }
+
+
+ /************
+ * DNS
+ ************/
+
+ /* Hide all dns specific code, if dns is not available
+ */
+ $DNSenabled = false;
+ foreach($this->config->data['TABS']['SERVERSERVICE'] as $tab){
+ if(preg_match("/^servdns$/",$tab['CLASS'])){
+ $this->DNSenabled = true;
+ }
+ }
+ if(!$this->DNSenabled){
+ $this->DNS_is_account = false;
+ return;
+ }
+
+ if($this->DNSenabled){
+
+ /* Get Zones
+ */
+ $this->Zones = getAvailableZones($config);
+
+ /* Get Entry
+ */
+ $this->dnsEntry = getDNSHostEntries($config,$this->OrigCn);
+
+ /* Remove A record which equals $this->ipHostNumber
+ */
+ $ptr = $this->get_pTRRecord();
+ foreach($this->dnsEntry['RECORDS'] as $key => $rec){
+ if(($rec['type'] == "aRecord") && ($rec['value'] == $this->ipHostNumber)){
+ unset($this->dnsEntry['RECORDS'][$key]);
+ }
+ if(($rec['type'] == "pTRRecord") && ($rec['value'] == $ptr)){
+ unset($this->dnsEntry['RECORDS'][$key]);
+ }
+ }
+
+ /* Get Record types
+ */
+ $this->RecordTypes = getDnsRecordTypes();
+
+ /* If there is at least one entry in this -> types, we have DNS enabled
+ */
+ if($this->dnsEntry['exists']){
+ $this->DNS_is_account = true;
+ }else{
+ $this->DNS_is_account = false;
+ }
+ }
+
+ /* Create a list of used mac and ip addresses */
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(|(macAddress=*)(ipHostNumber=*))",array("macAddress","ipHostNumber"));
+ while($attrs = $ldap->fetch()){
+ if(isset($attrs['ipHostNumber'][0])){
+ $this->used_ip_mac["ip:".$attrs['ipHostNumber'][0]] = "ip:".$attrs['ipHostNumber'][0];
+ }
+ if(isset($attrs['macAddress'][0])){
+ $this->used_ip_mac["mac:".$attrs['macAddress'][0]] = "mac:".$attrs['macAddress'][0];
+ }
+ }
+
+ /* Save initial ip and mac values, to be able
+ check if the used values are already in use */
+ $this->orig_ipHostNumber = $this->ipHostNumber;
+ $this->orig_macAddress = $this->macAddress;
+
+ /* Store initally account settings
+ */
+ $this->initially_was_account = $this->DNS_is_account;
+
+ if($this->DNS_is_account){
+ new log("view","unknown/".get_class($this),$this->dn);
+ }
+ }
+
+
+ function netmaskIsCoherent($idZone)
+ {
+ $netmask = FlipIp(str_replace(".in-addr.arpa","",getNameFromMix($idZone)));
+ if(!strstr($this->ipHostNumber, $netmask)){
+ return false;
+ }else{
+ return true;
+ }
+ }
+
+
+ function getVarsForSaving($attrs)
+ {
+ foreach($this->attributes as $attr){
+ if(!empty($this->$attr)){
+ $attrs[$attr] = $this->$attr;
+ }
+ }
+ return($attrs);
+ }
+
+ function execute()
+ {
+ /* Call parent execute */
+ $smarty= get_smarty();
+
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translation){
+ $smarty->assign($name."ACL",$this->getacl($name));
+ }
+
+ $display= "";
+
+ $smarty->assign("staticAddress", "");
+ $smarty->assign("autonet", $this->autonet);
+
+ /* Check for autonet button */
+ if ($this->autonet && isset($_POST['autonet'])){
+ $cmd= $this->config->data['MAIN']['AUTO_NETWORK_HOOK'];
+ if(!empty($cmd) && $this->cn != ""){
+ $res = shell_exec($cmd." ".$this->cn);
+ if(!$res){
+ print_red(sprintf(_("Can't execute specified AUTO_NETWORK_HOOK '%s'. Please check your gosa.conf."),$cmd));
+ } else {
+ $res= split(';', trim($res));
+ if (isset($res[0]) && $res[0] != ""){
+ $this->ipHostNumber= $res[0];
+ }
+ if (isset($res[1]) && $res[1] != ""){
+ $this->macAddress= $res[1];
+ }
+ }
+ }
+ }
+
+
+ /**********
+ * DHCP Handling
+ **********/
+
+ if(isset($_POST['dhcpEditOptions'])){
+
+ if(count($this->dhcpHostEntry) == 0){
+ $this->dialog = new dhcpHost($this->dhcpParentNode,TRUE);
+ }else{
+ $this->dialog = new dhcpHost($this->dhcpHostEntry,TRUE);
+ }
+ $this->dialog->cn = $this->cn;
+ $this->dialog->dhcpHWAddress = "ethernet ".$this->macAddress;
+ if(!empty($this->ipHostNumber)){
+ $this->dialog->statements['fixed-address'] = $this->ipHostNumber;
+ }
+ }
+
+ if(isset($_POST['cancel_dhcp'])){
+ $this->dialog = FALSE;
+ }
+
+ if(isset($_POST['save_dhcp'])){
+ $this->dialog->save_object();
+
+ $msgs = $this->dialog->check(array());
+ if(count($msgs)){
+ foreach($msgs as $msg){
+ print_red($msg);
+ }
+ }else{
+ $this->dhcpHostEntry = $this->dialog->save();
+ $this->dialog = FALSE;
+ }
+ }
+
+ if(is_object($this->dialog)){
+ $this->dialog->save_object();
+ return($this->dialog->execute());
+ }
+
+ $smarty->assign("dhcpEnabled", $this->dhcpEnabled);
+ $smarty->assign("dhcp_is_Account",$this->dhcp_is_Account);
+ $smarty->assign("dhcpParentNode", $this->dhcpParentNode);
+ $smarty->assign("dhcpParentNodes",$this->dhcpParentNodes);
+ $smarty->assign("dhcpParentNodeCnt",count($this->dhcpParentNodes));
+
+
+ /**********
+ * DNS Handling
+ **********/
+
+ /* There is no dns available
+ */
+ if($this->DNSenabled == false){
+
+ /* Is IP address must ? */
+ $smarty->assign("DNS_is_account",false);
+ $smarty->assign("IPisMust",(($this->IPisMust)||($this->DNS_is_account)));
+
+ /* Assign smarty all non DNs attributes */
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,$this->$attr);
+ }
+ $smarty->assign("staticAddress","
* ");
+
+ $display.= $smarty->fetch(get_template_path('network.tpl', TRUE));
+ }else{
+ $smarty->assign("DNS_is_account",true);
+
+ /* Add new empty array to our record list */
+ if(isset($_POST['AddNewRecord'])){
+ $this->dnsEntry['RECORDS'][] =array("type"=>"aRecord","value"=>"");
+ }
+
+ /* propose_ip */
+ if(isset($_POST['propose_ip'])){
+ foreach($this->Zones as $key => $name){
+ if($name == $this->dnsEntry['zoneName']){
+ $net = FlipIp(str_replace(".in-addr.arpa","",getNameFromMix($key)));
+ $this->ipHostNumber = $this->generateRandomIp($net);
+ }
+ }
+ }
+
+ /* Handle all posts */
+ $only_once =true;
+ foreach($_POST as $name => $value){
+
+ /* Check if we have to delete a record entry */
+ if((preg_match("/RemoveRecord_/",$name))&&($only_once)) {
+
+ /* Avoid performing this once again */
+ $only_once = false;
+
+ /* Extract id for specified entry */
+ $id = preg_replace("/RemoveRecord_/","",$name);
+ $id = preg_replace("/_.*$/","",$id);
+
+ /* Delete this record, mark edited entries to be able to delete them */
+ if(isset($this->dnsEntry['RECORDS'][$id])){
+ unset($this->dnsEntry['RECORDS'][$id]);
+ }
+ }
+ }
+ /* Assign smarty all non DNs attributes */
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,$this->$attr);
+ }
+
+ /* Assign smarty all DNS attributes */
+ foreach($this->DNSattributes as $attr){
+ $smarty->assign($attr,$this->dnsEntry[$attr]);
+ }
+
+ /* Assign all needed vars */
+ $smarty->assign("DNSAccount",$this->DNS_is_account);
+ $smarty->assign("hide_dns_check_box",$this->hide_dns_check_box);
+
+ $smarty->assign("Zones",$this->Zones);
+ $smarty->assign("ZoneCnt",count($this->Zones));
+ $smarty->assign("ZoneKeys",($this->Zones));
+ $smarty->assign("IPisMust",(($this->IPisMust)||($this->DNS_is_account)));
+
+ /* Create zone array */
+ $idZones = array();
+ foreach($this->Zones as $id => $zone){
+ if($this->netmaskIsCoherent($id)) {
+ $idZones[$id] = $zone;
+ }else{
+ $idZones[$id] = $zone." ("._("Not matching").")";
+ }
+ }
+ $smarty->assign("Zones",$idZones);
+ $smarty->assign("ZoneKeys", $this->Zones);
+
+ $tmp = $this->generateRecordsList();
+
+ $changeStateForRecords = $tmp['changeStateForRecords'];
+
+ $smarty->assign("records",$tmp['str']);
+ $smarty->assign("changeStateForRecords",$changeStateForRecords);
+ $smarty->assign("staticAddress","
* ");
+
+ $display.= $smarty->fetch(get_template_path('network.tpl', TRUE));
+ }
+ return($display);
+ }
+
+
+ function remove_from_parent()
+ {
+ if($this->initially_was_account){
+
+ $ldap = $this->config->get_ldap_link();
+
+ $tmp = array();
+ $this->dnsEntry['exists'] = false;
+ $tmp = getDNSHostEntriesDiff($this->config,$this->OrigCn,$this->dnsEntry,$this->cn);
+
+ /* Delete dns */
+ foreach($tmp['del'] as $dn => $del){
+ $ldap->cd($dn);
+ $ldap->rmdir_recursive($dn);
+ new log("remove","unknown/".get_class($this),$dn);
+ }
+ }
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+
+ if(isset($_POST['network_tpl_posted'])){
+
+ /* Save all posted vars */
+ plugin::save_object();
+
+ /* Handle DHCP Posts*/
+ if($this->dhcpEnabled && isset($_POST['network_tpl_posted'])){
+ foreach($this->dhcpAttributes as $attr){
+ if(isset($_POST[$attr])){
+ $this->$attr = $_POST[$attr];
+ }
+ }
+ if(isset($_POST['dhcp_is_Account'])){
+ $this->dhcp_is_Account = TRUE;
+ }else{
+ $this->dhcp_is_Account = FALSE;
+ }
+ }
+
+ /* Ge all non dns attributes (IP/MAC)*/
+ foreach($this->attributes as $attr){
+ if(isset($_POST[$attr]) && $this->acl_is_writeable($attr)){
+ $this->$attr = $_POST[$attr];
+ }
+ }
+
+ /* Check if DNS should be enabled / disabled */
+ if($this->DNS_is_account && $this->acl_is_removeable() && !isset($_POST['DNS_is_account'])){
+ $this->DNS_is_account = false;
+ }elseif(!$this->DNS_is_account && $this->acl_is_createable() && isset($_POST['DNS_is_account'])){
+ $this->DNS_is_account = true;
+ }
+
+ /* Get dns attributes */
+ if(($this->DNSenabled) && (isset($_POST['network_tpl_posted']))){
+
+ /* Check for posted record changes */
+ if(is_array($this->dnsEntry['RECORDS']) && $this->acl_is_writeable("Records")){
+ foreach($this->dnsEntry['RECORDS'] as $key => $value){
+
+ /* Check if type has changed */
+ if(isset($_POST['RecordTypeSelectedFor_'.$key])){
+ $this->dnsEntry['RECORDS'][$key]['type'] = $_POST['RecordTypeSelectedFor_'.$key];
+ }
+ /* Check if value has changed */
+ if(isset($_POST['RecordValue_'.$key])){
+ $this->dnsEntry['RECORDS'][$key]['value'] = $_POST['RecordValue_'.$key];
+ }
+ }
+ }
+ /* Get all basic DNS attributes (TTL, Clas ..)*/
+ foreach($this->DNSattributes as $attr){
+ if(isset($_POST[$attr]) && $this->acl_is_writeable($attr)){
+ $this->dnsEntry[$attr] = $_POST[$attr];
+ }
+ }
+
+
+ }
+ if($this->hide_dns_check_box){
+ $this->DNS_is_account = true;
+ }
+ }
+ }
+
+
+ /* Check supplied data */
+ function check()
+ {
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+
+ if($this->dhcpEnabled && $this->dhcp_is_Account && $this->dhcpParentNode != "" && count($this->dhcpHostEntry) == 0){
+# $message[] =_("You have not configured your dhcp settings yet.");
+ }
+
+ /* Check if mac and ip are already used */
+ if(!empty($this->ipHostNumber) && $this->DNS_is_account &&
+ $this->ipHostNumber != $this->orig_ipHostNumber &&
+ in_array("ip:".$this->ipHostNumber,$this->used_ip_mac)){
+ $message[] =_("The specified IP address is already in use.");
+ }
+ if(!empty($this->macAddress) && $this->dhcp_is_Account &&
+ $this->macAddress != $this->orig_macAddress &&
+ in_array("mac:".$this->macAddress,$this->used_ip_mac)){
+ print_red(sprintf(_("The specified MAC address '%s' for this system '%s' is already in use."),$this->macAddress,$this->cn));
+ }
+
+ /* Check if ip must be given
+ */
+ if(($this->IPisMust)||($this->DNS_is_account)){
+ if (empty($this->ipHostNumber)){
+ $message[]= _("The required field 'IP-address' is not set.");
+ }
+
+ if (!is_ip($this->ipHostNumber)){
+ $message[]= _("Wrong IP format in field IP-address.");
+ }
+ }
+
+ /* Check if mac is empty
+ */
+ if ($this->macAddress == "" ){
+ $message[]= _("The required field 'MAC-address' is not set.");
+ }
+ if(!is_mac($this->macAddress)){
+ $message[]=(_("The given macaddress is invalid. There must be 6 2byte segments seperated by ':'."));
+ }
+
+ /* only perfrom this checks if this is a valid DNS account */
+ if($this->DNS_is_account){
+
+ $checkArray = array();
+ $onlyOnce = array();
+
+ // $onlyOnce['cNAMERecord'] = 0;
+ $tmp = array_flip($this->Zones);
+ $tmp2 = $tmp[$this->dnsEntry['zoneName']];
+ if(!$this->netmaskIsCoherent($tmp2)){ //this->dnsEntry['zoneName'])){
+ $tmp2 = preg_replace("/^.*\//","",$tmp2);
+ $message[] =sprintf(_("The specified IP address '%s' is not matching the selected reverse zone entry '%s'."),$this->ipHostNumber,$tmp2);
+ }
+
+ /* Walk through all entries and detect duplicates or mismatches
+ */
+ foreach($this->dnsEntry['RECORDS'] as $name => $values){
+
+ /* Count record values, to detect duplicate entries for a specific record
+ */
+ if(!isset($checkArray[$values['type']][$values['value']])){
+ $checkArray[$values['type']][$values['value']] = 0;
+ }else{
+ $message[] = sprintf(_("Found duplicate value for record type '%s'."),$values['type']);
+ }
+
+ /* Check if given entries in $onlyOnce are used more than once
+ */
+ if(isset($onlyOnce[$values['type']])){
+ $onlyOnce[$values['type']] ++;
+ if($onlyOnce[$values['type']] > 1){
+ $message[] = sprintf(_("Found more than one entry for the uniqe record type '%s'."),$values['type']);
+ }
+ }
+
+ /* Skip txt record ...
+ */
+ if($values['type'] == "tXTRecord") continue;
+
+ /* Check if there is an aRecord defined which uses the same IP as used in IPhostAddress
+ */
+ if(($values['type'] == "aRecord")&&($values['value'] == $this->ipHostNumber)){
+ $message[]=sprintf(_("The device IP '%s' is added as 'A Record', this will be done automatically, please remove the record."),
+ $this->ipHostNumber);
+ }
+
+ /* only lower-case is allowed in record entries ...
+ */
+ if($values['value'] != strtolower($values['value'])){
+ $message[] = sprintf(_("Only lowercase is allowed, please check your '%ss'."),$values['type']);
+ }
+ }
+ }
+ return ($message);
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ $ldap= $this->config->get_ldap_link();
+
+ $dn = $this->parent->dn;
+
+ /*******************/
+ /* IP-MAC HANDLING */
+ /*******************/
+
+ /* $dn was posted as parameter */
+ $this->dn = $dn;
+
+ /* Save DNS setting & ip/Mac*/
+ plugin::save();
+
+ /* Write back to ldap */
+ $ldap->cd($this->dn);
+ $this->cleanup();
+ $ldap->modify ($this->attrs);
+
+ /****************/
+ /* DHCP HANDLING */
+ /****************/
+
+ /* New entry */
+ if($this->dhcpEnabled){
+
+ if(count($this->dhcpHostEntry) == 0){
+ $this->dialog = new dhcpHost($this->dhcpParentNode,TRUE);
+ $this->dialog->cn = $this->cn;
+ $this->dialog->dhcpHWAddress = "ethernet ".$this->macAddress;
+ if(!empty($this->ipHostNumber)){
+ $this->dialog->statements['fixed-address'] = $this->ipHostNumber;
+ }
+ $this->dialog->execute();
+ $this->dialog->save_object();
+ $this->dhcpHostEntry = $this->dialog->save();
+ if(count($this->dhcpHostEntry['dhcpOption']) == 0){
+ $this->dhcpHostEntry['dhcpOption']= array("host-name ".$this->cn);
+ }
+ }
+
+ if(count($this->dhcpHostEntry) == 0){
+ $this->dialog = new dhcpHost($this->dhcpParentNode,TRUE);
+ $this->dialog->cn = $this->cn;
+ $this->dialog->dhcpHWAddress = "ethernet ".$this->macAddress;
+ if(!empty($this->ipHostNumber)){
+ $this->dialog->statements['fixed-address'] = $this->ipHostNumber;
+ }
+ $this->dialog->execute();
+ $this->dialog->save_object();
+ $this->dhcpHostEntry = $this->dialog->save();
+ if(count($this->dhcpHostEntry['dhcpOption']) == 0){
+ $this->dhcpHostEntry['dhcpOption']= array("host-name ".$this->cn);
+ }
+ }
+
+ /* Write mac address to dhcp settings */
+ if($this->dhcp_is_Account){
+ if(!isset($this->dhcpHostEntry['dhcpHWAddress'][0]) ||
+ !preg_match("/ethernet ".$this->macAddress."/",$this->dhcpHostEntry['dhcpHWAddress'][0])){
+ $this->dhcpHostEntry['dhcpHWAddress'] = array("ethernet ".$this->macAddress);
+ $this->dhcpHostEntry['MODIFIED'] = TRUE;
+ }
+ }
+
+
+ /* Unset dhcpStatements if this attribute is empty */
+ if(isset($this->dhcpHostEntry['dhcpStatements']) &&
+ ($this->dhcpHostEntry['dhcpStatements'] == "" || count($this->dhcpHostEntry['dhcpStatements']) == 0) ){
+ unset($this->dhcpHostEntry['dhcpStatements']);
+ }
+
+ /* DHCP removed */
+ if($this->initial_dhcp_is_Account && !$this->dhcp_is_Account){
+ $ldap->rmdir_recursive($this->dhcpHostEntry['dn']);
+ show_ldap_error($ldap->get_error(),_("Removing dhcp entry for this object failed."));
+
+ $tmp = new servdhcp($this->config,$this->dhcpParentNode);
+ $tmp->handle_post_events("remove");
+ }
+
+ /* DHCP Added */
+ if(!$this->initial_dhcp_is_Account && $this->dhcp_is_Account){
+ $attrs = $this->dhcpHostEntry;
+ unset($attrs['MODIFIED']);
+ unset($attrs['dn']);
+ $ldap->cd("cn=".$this->cn.",".$this->dhcpParentNode);
+ $res = $ldap->add($attrs);
+
+ $tmp = new servdhcp($this->config,$this->dhcpParentNode);
+ $tmp->handle_post_events("add");
+
+ show_ldap_error($ldap->get_error(),_("Tried to add new dhcp entry failed."));
+ }
+
+ /* DHCP still activated */
+ if($this->initial_dhcp_is_Account && $this->dhcp_is_Account){
+
+ /* DHCP node changed */
+ if(($this->initial_dhcpParentNode != $this->dhcpParentNode) ||
+ ($this->cn != $this->OrigCn)){
+ $attrs = $this->dhcpHostEntry;
+ $attrs['cn'] = $this->cn;
+ unset($attrs['dn']);
+ unset($attrs['MODIFIED']);
+ $ldap->cd("cn=".$this->cn.",".$this->dhcpParentNode);
+ $res = $ldap->add($attrs);
+
+ $tmp = new servdhcp($this->config,$this->dhcpParentNode);
+ $tmp->handle_post_events("modify");
+
+ show_ldap_error($ldap->get_error(),_("Tried to add new dhcp entry failed."));
+ if($res){
+ $ldap->rmdir_recursive($this->dhcpHostEntry['dn']);
+ show_ldap_error($ldap->get_error(),_("Removing old dhcp entry failed."));
+ }
+ }
+
+ /* SAME node but modified */
+ if(isset($this->dhcpHostEntry['MODIFIED']) && $this->dhcpHostEntry['MODIFIED'] == 1 &&
+ $this->initial_dhcpParentNode == $this->dhcpParentNode){
+ $attrs = $this->dhcpHostEntry;
+ unset($attrs['dn']);
+ unset($attrs['MODIFIED']);
+ $ldap->cd($this->dhcpHostEntry['dn']);
+ $ldap->modify($attrs);
+
+ $tmp = new servdhcp($this->config,$this->dhcpParentNode);
+ $tmp->handle_post_events("modify");
+
+ show_ldap_error($ldap->get_error(),_("Modifying dhcp entry failed."));
+ }
+ }
+ }
+
+
+ /****************/
+ /* DNS HANDLING */
+ /****************/
+
+ /* If isn't DNS account but initially was DNS account
+ remove all DNS entries
+ */
+ if((!$this->DNSenabled) || ((!$this->DNS_is_account)&&(!$this->initially_was_account))){
+ return;
+ }else{
+
+ /* Add ipHostNumber to aRecords
+ */
+ $backup_dnsEntry = $this->dnsEntry;
+ if(!empty($this->ipHostNumber)){
+ $this->dnsEntry['RECORDS'][] = array("type"=>"aRecord","value"=>$this->ipHostNumber);
+ $ptr = $this->get_pTRRecord();
+ if(!empty($ptr)){
+ $this->dnsEntry['RECORDS'][] = array("type"=>"pTRRecord","value"=>$ptr);
+ }
+ }
+
+ /* Create diff and follow instructions
+ * If Account was disabled, remove account by setting exists to false
+ */
+ if((!$this->DNS_is_account)&&($this->initially_was_account)){
+ $this->dnsEntry['exists'] = false;
+ $tmp = getDNSHostEntriesDiff($this->config,$this->OrigCn,$this->dnsEntry,$this->cn);
+ }else{
+ $this->dnsEntry['exists'] = $this->DNS_is_account;
+ $tmp = getDNSHostEntriesDiff($this->config,$this->OrigCn,$this->dnsEntry,$this->cn);
+ }
+
+ /* move follwoing entries
+ */
+ foreach($tmp['move'] as $src => $dst){
+ $this->recursive_move($src,$dst);
+ }
+
+ /* Delete dns */
+ foreach($tmp['del'] as $dn => $del){
+ $ldap->cd($dn);
+ $ldap->rmdir_recursive($dn);
+ new log("modify","unknown/".get_class($this),$dn,array("*"),$ldap->get_error());
+ }
+
+ /* Add || Update new DNS entries
+ */
+ foreach($tmp['add'] as $dn => $attrs){
+ $ldap->cd($dn);
+ $ldap->cat($dn, array('dn'));
+ if(count($ldap->fetch())){
+ $ldap->cd($dn);
+ $ldap->modify ($attrs);
+ }else{
+ $ldap->cd($dn);
+ $ldap->add($attrs);
+ }
+ new log("modify","unknown/".get_class($this),$dn,array_keys($attrs),$ldap->get_error());
+ }
+
+
+ /* Display errors
+ */
+ if($ldap->get_error() != "Success"){
+ show_ldap_error($ldap->get_error(), sprintf(_("Saving of terminal/dns account with dn '%s' failed."),$this->dn));
+ }
+
+ $tmp2 = new servdns($this->config,$this->dn);
+ $tmp2->handle_post_events("modify");
+
+ $this->dnsEntry = $backup_dnsEntry;
+ }
+ }
+
+ /* Create html table with all used record types
+ */
+ function generateRecordsList()
+ {
+ $changeStateForRecords = "";
+
+ if(!$this->DNS_is_account) {
+ $str = "
";
+ return(array("str" => $str, "changeStateForRecords"=> ""));
+ }
+
+ $str = "
";
+ $ret = array("str" => $str, "changeStateForRecords" => $changeStateForRecords);
+ return($ret);
+ }
+
+
+ /* Create a html select box which allows us to select different types of records
+ */
+ function generateRecordListBox($selected,$name)
+ {
+ $str = "
";
+ foreach($this->RecordTypes as $type => $value){
+ $use = "";
+ if($type == $selected){
+ $use = " selected ";
+ }
+ $str.="\n ".strtoupper(preg_replace("/record/i","",$type))." ";
+ }
+ $str.=" ";
+ return($str);
+ }
+
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ $tmp = array(
+ "plShortName" => _("DNS"),
+ "plDescription" => _("DNS settings"),
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 5,
+ "plSection" => array("administration"),
+ "plCategory" => array("workstation","terminal","phone","server","component","printer","winworkstation"),
+
+ "plProvidedAcls"=> array(
+ "ipHostNumber" => _("IP address"),
+ "macAddress" => _("MAC address"))
+ );
+
+ /* Hide all dns specific code, if dns is not available
+ */
+ foreach($_SESSION['config']->data['TABS']['SERVERSERVICE'] as $tab){
+ if(preg_match("/^servdns$/",$tab['CLASS'])){
+ $tmp['plProvidedAcls']["Records"] = _("DNS records");
+ $tmp['plProvidedAcls']["zoneName"] = _("Zone name");
+ $tmp['plProvidedAcls']["dNSTTL"] = _("TTL");
+ break;
+ }
+ }
+ return($tmp);
+ }
+
+
+ function get_dhcp_host_entry()
+ {
+ $attrs = array();
+ $dn = $this->get_dhcp_host_entry_dn();
+ if($dn){
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->cat($dn,array("*"));
+ if($ldap->count()){
+ $attrs = $ldap->fetch();
+ foreach($attrs as $key => $value){
+ if(is_numeric($key) || ($key == "count")){
+ unset($attrs[$key]);
+ }
+ if(is_array($value) && isset($value['count'])){
+ unset($attrs[$key]['count']);
+ }
+ }
+ }
+ }
+ return($attrs);
+ }
+
+
+ function get_dhcp_host_entry_dn()
+ {
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search ("(&(objectClass=dhcpHost)(cn=".$this->cn."))",array("cn","dn"));
+
+ if($ldap->count()){
+ $attr = $ldap->fetch();
+ return($attr['dn']);
+ }else{
+ return("");
+ }
+ }
+
+
+ function get_dhcp_parent_node()
+ {
+ return(preg_replace("/^cn=".normalizePreg($this->cn).",/","",$this->get_dhcp_host_entry_dn()));
+ }
+
+
+ function get_dhcp_parent_nodes()
+ {
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(objectClass=dhcpService)",array("dhcpPrimaryDN"));
+
+ $dhcp_dns = array();
+ while($attr = $ldap->fetch()){
+ $dhcp_dns[$attr['dn']] = $attr['dhcpPrimaryDN'][0];
+ }
+
+ foreach($dhcp_dns as $key => $pri_dns){
+ $ldap->cat($pri_dns,array("cn"));
+ $tmp = $ldap->fetch();
+ if(isset($tmp['cn'][0])){
+ $dhcp_dns[$key] = $tmp['cn'][0];
+ }else{
+ unset($dhcp_dns[$key]);
+ }
+ }
+
+ $tmp = $tmp2 = array();
+ foreach($dhcp_dns as $dn => $cn){
+ $ldap->cd($dn);
+ $ldap->search("(|(objectClass=dhcpService)(objectClass=dhcpGroup)".
+ "(objectClass=dhcpSubnet)(objectClass=dhcpSharedNetwork))",array("cn"));
+ while($attr = $ldap->fetch()){
+ $tmp[$attr['dn']] = $attr['cn'][0];
+ }
+ $tmp2 = array_merge($tmp2,$this->create_tree($tmp,preg_replace("/^[^,]+,/i","",$dn),"(".$cn.") "));
+ }
+ return($tmp2);
+ }
+
+
+ /* this function returns the default ptr record entry */
+ function get_pTRRecord()
+ {
+ if(!empty($this->ipHostNumber) && isset($this->dnsEntry['zoneName']) && !empty($this->dnsEntry['zoneName'])){
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cat(getDNSZoneDN($this->config,$this->dnsEntry['zoneName']));
+ $attrs = $ldap->fetch();
+ $tmp = array_flip($this->Zones);
+ $tmp = preg_replace("/^[^\/]*+\//","",$tmp[$this->dnsEntry['zoneName']]);
+ $tmp = trim(preg_replace("/\.in-addr.arpa$/","",$tmp));
+ $ptr = preg_replace("/^".normalizePreg(FlipIp($tmp))."\./","",$this->ipHostNumber);
+ return($ptr);
+ }else{
+ return(FALSE);
+ }
+ }
+
+
+ function generateRandomIP($net = "")
+ {
+ $str = $net;
+ $cnt = 4;
+ while(substr_count($str,".") < 3 && $cnt > 0){
+ $str .= ".".rand(0,255);
+ $str = preg_replace("/\.\.*/",".",$str);
+ $str = trim($str,". ");
+ $cnt --;
+ }
+ return($str);
+ }
+
+
+ function create_tree($arr,$base,$current = "")
+ {
+ $ret = array();
+ foreach($arr as $r => $name){
+ $base_part = str_replace($base,"",$r);
+ if(preg_match("/^[a-z]*=".normalizePreg($name)."(|,)$/i",$base_part)){
+ $ret[$r] = $current.$name;
+ $tmp = $this->create_tree($arr,$r,$current.". ");
+ foreach($tmp as $sub_key => $sub_name){
+ $ret[$sub_key] = $sub_name;
+ }
+ }
+ }
+ return($ret);
+ }
+
+ function force_dns()
+ {
+ if($this->DNSenabled){
+ $this->DNS_is_account = TRUE;
+ $this->hide_dns_check_box = TRUE;
+ }
+ }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/dns/servDNSeditZoneEntries.tpl b/plugins/admin/systems/services/dns/servDNSeditZoneEntries.tpl
new file mode 100644
index 000000000..9c0428c29
--- /dev/null
+++ b/plugins/admin/systems/services/dns/servDNSeditZoneEntries.tpl
@@ -0,0 +1,27 @@
+
{t}This dialog allows you to configure all components of this DNS zone on a single list.{/t}
+
+{if $disableDialog}
+
+ {t}This dialog can't be used until the currently edited zone was saved or the zone entry exists in the ldap database.{/t}
+
+{else}
+
+ {$table}
+
+
+{/if}
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/dns/servdns.tpl b/plugins/admin/systems/services/dns/servdns.tpl
new file mode 100644
index 000000000..6cfa50f09
--- /dev/null
+++ b/plugins/admin/systems/services/dns/servdns.tpl
@@ -0,0 +1,63 @@
+{if $dns_take_over}
+
+
+
+ {t}DNS take over initiated{/t}
+ {$warning}
+ {t}This includes 'all' DNS zones that are located within this server. Please double check if your really want to do this.{/t}
+
+ {$warning2}
+
+
+
+
+ {t}Following objects will be taken over{/t} :
+
+
+
{$info}
+
+
+
+
+{else}
+
+
+
+
+
+{/if}
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/dns/servdnseditzone.tpl b/plugins/admin/systems/services/dns/servdnseditzone.tpl
new file mode 100644
index 000000000..1136dba53
--- /dev/null
+++ b/plugins/admin/systems/services/dns/servdnseditzone.tpl
@@ -0,0 +1,177 @@
+
{t}Generic{/t}
+
+
+
{t}SOA record{/t}
+
+
+
+
+
+
+
+ {t}MxRecords{/t}
+
+
+
+ {t}Global zone records{/t}
+{render acl=$ACLs}
+ {$records}
+{/render}
+
+
+
+
+
diff --git a/plugins/admin/systems/services/glpi/class_glpiAccount.inc b/plugins/admin/systems/services/glpi/class_glpiAccount.inc
new file mode 100644
index 000000000..e6411087a
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/class_glpiAccount.inc
@@ -0,0 +1,806 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account= FALSE;
+ var $attributes= array("ID","name","contact",
+ "tech_num","comments","date_mod","os","location","domain","network","contact_num",
+ "model","type","is_template","FK_glpi_enterprise","deleted");
+
+ var $ID ; // Is set if this entry is edited
+ var $name = ""; // This should be the dn of this entry
+ var $contact = ""; // Empty
+
+ var $comments = ""; // Comment
+
+ var $contact_num = ""; // Contact person
+ var $tech_num = ""; // Technical responsible person
+
+ var $addUser = ""; // This is used to remember if a dialog was opened for tech_num or contact_num
+
+ var $date_mod = ""; // Modification timestamp
+ var $os = 0; // Operating system
+ var $location = 0; // Not used yet
+ var $domain = 0; // ? Set to 0
+ var $network = 0; // ? Set to 0
+
+ var $model = 0; // ? Can't remember this, it isn't used in GOsa
+ var $type = 0; // System type id
+ var $is_template = 0; // Used as template ?
+ var $FK_glpi_enterprise = 0; // Manufacturer id
+ var $deleted = "N"; // Deleted entries should have this set to Y
+
+ var $renameTypeDialog = false;
+ var $renameOSDialog = false;
+ var $select_type ;
+ var $view_logged = FALSE;
+
+ /* Not necessary, cause we use mysql databse */
+ var $objectclasses= array("whatever");
+
+ /* Used to remember if this was an account (simply: is this an edited entry) */
+ var $initially_was_account = false;
+
+ /* Remember current dialog */
+ var $edit_type = false;
+ var $edit_os = false;
+
+ var $data;
+ var $handle = NULL; // Glpi class handle used to query database
+
+ var $cur_dialog = NULL; // This contains the sub dialog handle
+
+ var $orig_dn; // To check if dn, has changed
+ var $ui; // Some GOsa specific user informations
+
+ var $usedDevices = array(); // Which devices are currently selected
+ var $usedAttachments = array(); // Used Attachments
+
+ /* Contructor
+ Sets default values and checks if we already have an existing glpi account
+ */
+ function glpiAccount (&$config, $dn= NULL, $parent= NULL)
+ {
+ plugin::plugin ($config, $dn, $parent);
+ $this->ui= get_userinfo();
+
+ /* Abort class construction, if no db is defined */
+ if(!isset($this->config->data['SERVERS']['GLPI'])){
+ return;
+ }
+
+ // Get informations about databse connection
+ $this->data = $this->config->data['SERVERS']['GLPI'];
+
+ // Abort if mysql extension is missing
+ if(!is_callable("mysql_connect")){
+ return;
+ }
+
+ // Create handle of glpi class, and check if database connection is established
+ $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
+
+ if(!$this->handle->is_connected){
+ return;
+ }
+
+ // If this dn is already used in database, then get all informations for this entry
+ if($this->handle->is_account($this->dn)){
+ $this->is_account = true;
+ $tmp = ($this->handle->getComputerInformations($this->dn));
+
+ foreach(array("tech_num","os","FK_glpi_enterprise","type","comments","contact_num") as $attr){
+ $this->$attr = $tmp[0][$attr];
+ }
+ $this->usedDevices = $this->handle->getUsedDevices($tmp[0]['ID']);
+ $atts = $this->handle->getAssignAttachments($tmp[0]['ID']);
+ foreach($atts as $attachment){
+
+ $this->usedAttachments[$attachment['FK_doc']]=$attachment['FK_doc'];
+ }
+ }else{
+ $this->is_account = false;
+ }
+
+ /* set defaults */
+ $this->name = $this->dn;
+ $this->orig_dn = $this->dn;
+ $this->initially_was_account = $this->is_account;
+ }
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","all/".get_class($this),$this->dn);
+ }
+
+ /* Fill templating stuff */
+ $smarty= get_smarty();
+ $display= "";
+
+ /* Assign smarty defaults
+ To avoid undefined indexes, if there is an error with the glpi db
+ */
+ foreach(array("SystemTypes","SystemTypeKeys","Manufacturers",
+ "OSs","TechnicalResponsibles","InstalledDevices","Attachments","AttachmentKeys",
+ "OSKeys","OSs","ManufacturerKeys","InstalledDeviceKeys") as $attr){
+ $smarty->assign($attr,array());
+ }
+ foreach(array("type","FK_glpi_enterprise","os","tech_num","comments","contact_num","AttachmentsDiv") as $attr){
+ $smarty->assign($attr,"");
+ }
+
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translation) {
+ $smarty->assign($name."ACL",$this->getacl($name));
+ }
+
+ /* Check if there is a glpi database server defined
+ */
+ if(!isset($this->config->data['SERVERS']['GLPI'])){
+ print_red(_("There is no server with valid glpi database service."));
+ return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
+ }
+
+ $this->data = $this->config->data['SERVERS']['GLPI'];
+
+ /* Check if we can call mysql_connect
+ If we can't, there is no the mysql-php extension
+ */
+ if(!is_callable("mysql_connect")){
+ print_red(_("Can't connect to glpi database, the php-mysql extension is missing."));
+ return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
+ }
+
+ $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
+
+ /* If handle == false, abort
+ Seems that the server, username and or password is wrong
+ */
+ if(!$this->handle->is_connected){
+ print_red(_("Can't connect to glpi database, check configuration twice."));
+ return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
+ }
+
+ /* All checks are ok
+ Lets handle Posts, templates etc below ...
+ */
+
+ $users = $this->handle->getUsers();
+ $ldap= $this->config->get_ldap_link();
+
+ /* Check for Trading button Post
+ */
+ if(isset($_POST['Trading'])){
+ print_red(_("This feature is not implemented yet."));
+ }
+
+ /* Check for Software button Post
+ */
+ if(isset($_POST['Software'])){
+ print_red(_("This feature is not implemented yet."));
+ }
+
+ /* Check for Contract button Post
+ */
+ if(isset($_POST['Contracts'])){
+ print_red(_("This feature is not implemented yet."));
+ }
+
+ /* Add Device was requested, open new dialog
+ */
+ if((isset($_POST['AddDevice'])) && ($this->acl_is_writeable("Devices"))){
+ $this->dialog =true;
+ $this->cur_dialog = new glpiDeviceManagement($this->config,$this->dn,$this->usedDevices);
+ }
+
+ /* Attachment pool was closed with use
+ */
+ if(isset($_POST['UseAttachment']) && ($this->acl_is_writeable("Attachments"))){
+ if(count($this->cur_dialog->check())){
+ foreach($this->cur_dialog->check() as $msg){
+ print_red($msg);
+ }
+ }else{
+ $this->cur_dialog->save_object();
+ $this->usedAttachments = $this->cur_dialog->save();
+ $this->cur_dialog = false;
+ $this->edit_type = false;
+ }
+ }
+
+ /* Attachment pool was closed with abort
+ */
+ if(isset($_POST['AbortAttachment'])){
+ $this->cur_dialog = false;
+ $this->edit_type = false;
+ }
+
+ /* Open Attachment pool to add/edit Attachments
+ */
+ if(isset($_POST['AddAttachment']) && ($this->acl_is_writeable("Attachments"))){
+ $this->cur_dialog = new glpiAttachmentPool($this->config,$this->dn,$this->usedAttachments);
+ $this->dialog = true;
+ }
+
+ /* Remove Attachment fro this tab
+ */
+ $once = true;
+ foreach($_POST as $name => $value){
+ if((preg_match("/^delAttachment_/",$name))&&($once) && $this->acl_is_writeable("Attachments")){
+ $once= false;
+ $name = preg_replace("/^delAttachment_/","",$name);
+ $entry = preg_replace("/_.*$/","",$name);
+ if(isset($this->usedAttachments[$entry])){
+ unset($this->usedAttachments[$entry]);
+ }
+ }
+ }
+ if((isset($_POST['RemoveAttachment']))&&(isset($_POST['Attachments'])) && ($this->acl_is_writeable("Attachments"))){
+ foreach($_POST['Attachments'] as $entry){
+ if(isset($this->usedAttachments[$entry])){
+ unset($this->usedAttachments[$entry]);
+ }
+ }
+ }
+
+ /* We have selected some devices and pressed use button
+ */
+ if(isset($_POST['SelectDeviceSave']) && $this->acl_is_writeable("Devices")){
+ $this->cur_dialog->save_object();
+ $this->usedDevices= ($this->cur_dialog->getSelected());
+ $this->cur_dialog = false;
+ $this->dialog = false;
+ $this->edit_type=false;
+ }
+
+ /* Aborted Device selction
+ */
+ if(isset($_POST['SelectDeviceCancel']) && ($this->acl_is_writeable("Devices"))){
+ $this->dialog = false;
+ $this->cur_dialog = false;
+ $this->edit_type=false;
+ }
+
+ /* System type management
+ */
+ if(isset($_POST['edit_type']) && $this->acl_is_writeable("type")){
+ $this->dialog = true;
+ $this->edit_type=true;
+ }
+
+ /* This closes the system type editing dialog
+ */
+ if(isset($_POST['close_edit_type']) && ($this->acl_is_writeable("type"))){
+ $this->edit_type=false;
+ $this->dialog = false;
+ }
+
+ if(isset($_POST['Rename_Cancel'])){
+ $this->renameTypeDialog = false;
+ $this->renameOSDialog = false;
+ }
+
+ /* This appends a new system to our sytem types
+ */
+ if((isset($_POST['add_type']))&&(!empty($_POST['type_string'])) && $this->acl_is_writeable("type")){
+ $attr = $this->handle->getSystemTypes();
+ if(in_array(trim($_POST['type_string']),$attr)){
+ print_red(_("Adding new sytem type failed, this system type name is already used.")) ;
+ }else{
+ $this->handle->addSystemType(trim($_POST['type_string']));
+ }
+ }
+
+ /* Remove selected type from our system types list
+ */
+ if((isset($_POST['del_type']))&&(!empty($_POST['select_type'])) && $this->acl_is_writeable("type")){
+ $tmp = $this->handle->is_systemTypeUsed($_POST['select_type']);
+ if(count($tmp)){
+ $names = "";
+ foreach($tmp as $name){
+ $names .= ", ".$name;
+ }
+ $names = preg_replace("/^, /","",$names);
+ $names = trim($names);
+ if(count($tmp) == 3){
+ $names .= " ...";
+ }
+ print_red(sprintf(_("You can't delete this system type, it is still in use by these system(s) '%s'"),$names));
+ }else{
+ $this->handle->removeSystemType($_POST['select_type']);
+ }
+ }
+
+ /* Rename selected system type to given string
+ */
+ if(isset($_POST['Rename_type_OK'])){
+ $attr = $this->handle->getSystemTypes();
+ if(in_array(trim($_POST['string']),$attr)){
+ print_red(_("Rename failed, this system type name is already used.")) ;
+ }else{
+ $this->renameTypeDialog = false;
+ $this->handle->updateSystemType($_POST['string'],trim($this->select_type));
+ }
+ }
+
+
+ if((isset($_POST['rename_type'])&&(!empty($_POST['select_type'])))||($this->renameTypeDialog)){
+ if(isset($_POST['select_type'])){
+ $this->select_type = $_POST['select_type'];
+ }
+ $this->renameTypeDialog = true;
+ $tmp = $this->handle->getSystemTypes();
+
+ $smarty->assign("string",$tmp[$this->select_type]);
+ if(isset($_POST['string'])){
+ $smarty->assign("string",$_POST['string']);
+ }
+ $smarty->assign("Method","rename");
+ $display= $smarty->fetch(get_template_path('glpi_edit_type.tpl', TRUE));
+ return($display);
+ }
+
+
+
+ /* Someone wants to edit the system types ...
+ So, lets open a new dialog which provides some buttons to edit the types
+ */
+ if($this->edit_type){
+ $smarty->assign("Method","edit");
+ $smarty->assign("SystemTypes", $this->handle->getSystemTypes());
+ $smarty->assign("SystemTypeKeys", array_flip($this->handle->getSystemTypes()));
+ $display= $smarty->fetch(get_template_path('glpi_edit_type.tpl', TRUE));
+ return($display);
+ }
+
+ /* System os management
+ */
+ if(isset($_POST['edit_os']) && $this->acl_is_writeable("os")){
+ $this->dialog = true;
+ $this->edit_os=true;
+ }
+
+ /* Close Operating system dialog
+ */
+ if(isset($_POST['close_edit_os'])){
+ $this->edit_os=false;
+ $this->dialog = false;
+ }
+
+ /* Add new os to the db
+ */
+ if((isset($_POST['add_os']))&&(!empty($_POST['is_string'])) && $this->acl_is_writeable("os")){
+ $attr = $this->handle->getOSTypes();
+ if(in_array(trim($_POST['is_string']),$attr)){
+ print_red(_("Adding new operating system failed, specifed name is already used.")) ;
+ }else{
+ $this->handle->addOS(trim($_POST['is_string']));
+ }
+ }
+
+ /* Delete selected os from list and db
+ */
+ if((isset($_POST['del_os']))&&(!empty($_POST['select_os'])) && $this->acl_is_writeable("os")){
+ $tmp = $this->handle->is_osUsed($_POST['select_os']);
+
+ if(count($tmp)){
+
+ $names = "";
+ foreach($tmp as $name){
+ $names .= ", ".$name;
+ }
+ $names = preg_replace("/^, /","",$names);
+ $names = trim($names);
+ if(count($tmp) == 3){
+ $names .= " ...";
+ }
+ print_red(sprintf(_("You can't delete this operating system, it is still in use by these system(s) '%s'"),$names));
+
+ }else{
+ $this->handle->removeOS_byID($_POST['select_os']);
+ }
+ }
+
+ /* Rename selected os to given string
+ */
+ if(isset($_POST['Rename_os_OK']) && $this->acl_is_writeable("os")){
+ $attr = $this->handle->getOSTypes();
+ if(in_array(trim($_POST['string']),$attr)){
+ print_red(_("Updating operating system failed, specifed name is already used.")) ;
+ }else{
+ $this->handle->updateOS($_POST['string'],$this->select_type);
+ $this->renameOSDialog = false;
+ }
+ }
+ if((isset($_POST['rename_os'])&&(!empty($_POST['select_os'])))||($this->renameOSDialog)){
+ if(isset($_POST['select_os'])){
+ $this->select_type = $_POST['select_os'];
+ }
+ $this->renameOSDialog = true;
+ $tmp = $this->handle->getOSTypes();
+
+ $smarty->assign("string",$tmp[$this->select_type]);
+ if(isset($_POST['string'])){
+ $smarty->assign("string",$_POST['string']);
+ }
+ $smarty->assign("Method","rename");
+ $display= $smarty->fetch(get_template_path('glpi_edit_os.tpl', TRUE));
+ return($display);
+ }
+
+ /* Open dialog to edit os types
+ */
+ if($this->edit_os){
+ $smarty->assign("Method","edit");
+ $smarty->assign("OSs", $this->handle->getOSTypes());
+ $smarty->assign("OSKeys", array_flip($this->handle->getOSTypes()));
+ $display= $smarty->fetch(get_template_path('glpi_edit_os.tpl', TRUE));
+ return($display);
+ }
+
+
+
+ /* Show dialog to select a new contact person
+ * Select a contact person
+ */
+ if(isset($_POST['SelectContactPerson']) && $this->acl_is_writeable("contact_num")){
+ $this->addUser = "contact";
+ $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
+ $this->cur_dialog->set_acl_category(preg_replace("/\//","",$this->acl_category));
+ $this->cur_dialog->set_acl_base($this->dn);
+
+ }
+
+ /* Open dialog which allows to edit the manufacturers
+ */
+ if(isset($_POST['edit_manufacturer']) && $this->acl_is_writeable("FK_glpi_enterprise")){
+ $this->cur_dialog = new glpiManufacturer($this->config,$this->dn);
+ $this->dialog = true;
+ }
+
+ /* Close manufacturer editing dialog
+ */
+ if(isset($_POST['close_edit_manufacturer'])){
+ $this->dialog = false;
+ $this->cur_dialog = false;
+ }
+
+ /* Abort user selection
+ */
+ $smarty->assign("AbortSelectUser","SelectUserCancel");
+ if(isset($_POST['SelectUserCancel'])){
+ $this->dialog = false;
+ $this->addUser ="";
+ $this->cur_dialog = false;
+ }
+
+ /* Selecte technical responsible person
+ */
+ if(isset($_POST['SelectTechPerson']) && $this->acl_is_writeable("tech_num")){
+ $this->addUser ="tech";
+ $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
+ $this->cur_dialog->set_acl_category(preg_replace("/\//","",$this->acl_category));
+ $this->cur_dialog->set_acl_base($this->dn);
+ }
+
+ /* Technical responsible person selected*/
+ if(isset($_GET['act'])&&($_GET['act']=="user_tech_num")&&(strlen($_GET['id']) > 100)){
+ print_red(sprintf(_("Could not add the given user, the users dn is too long, only 100 characters are allowed here.")));
+
+ }elseif(isset($_GET['act'])&&($_GET['act']=="user_tech_num") && strlen($_GET['id'])){
+
+
+ /* Get posted id */
+ $id = base64_decode($_GET['id']);
+
+ /* Check if user is already created in glpi database */
+ if(!in_array($id,$users)){
+
+ /* If this user doesn't exists in glpi db, we must create him */
+ $ldap->cat($id, array('cn', 'mail', 'telephoneNumber'));
+ $atr = $ldap->fetch();
+ $tmp = array();
+ $use = array( "cn" =>"name",
+ "mail" =>"email",
+ "telephoneNumber" =>"phone");
+
+ /* Create array */
+ foreach($use as $gosa => $glpi){
+ if(isset($atr[$gosa])){
+ $tmp[$glpi]= $atr[$gosa][0];
+ }
+ }
+
+ /* Add this user */
+ $this->handle->addUser($tmp,$id);
+ }
+
+ /* Re-read users */
+ $users = ($this->handle->getUsers());
+
+ /* Get user */
+ $tmp = array_flip($users);
+ $id=$tmp[$id];
+
+ /* Use user id, close dialog */
+ if($this->addUser == "tech"){
+ $this->tech_num = $id;
+ }else{
+ $this->contact_num = $id;
+ }
+ $this->cur_dialog = false;
+ $this->dialog= false;
+ }
+
+ /* if( cur_dialog != false || cur_dialog != NULL)
+ * There is a dialog which wants to be displayed
+ */
+ if(isset($this->cur_dialog) && is_object($this->cur_dialog)){
+ $this->cur_dialog->save_object();
+ $this->dialog=true;
+ $this->cur_dialog->parent = &$this;
+ return($this->cur_dialog->execute());
+ }else{
+ $this->dialog= false;
+ }
+
+ /* Assign smarty defaults */
+ foreach(array("SystemTypes","SystemTypeKeys","Manufacturers","OSs","TechnicalResponsibles","InstalledDevices","Attachments") as $attr){
+ $smarty->assign($attr,array());
+ }
+
+ /* Assign some vars to smarty
+ */
+ foreach(array("type","FK_glpi_enterprise","os","tech_num","contact_num","Attachments","InstalledDevices") as $attr){
+ $smarty->assign($attr,"");
+ }
+
+ /* 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;
+ }
+ }
+
+ /* Show tab dialog headers */
+ if ($this->is_account){
+ $display= $this->show_disable_header(_("Remove inventory"),
+ _("This device has inventory informations enabled. You can disable them by clicking below."));
+ } else {
+ $display= $this->show_enable_header(_("Add inventory"),
+ _("This device has inventory informations disabled. You can enable them by clicking below."));
+ return ($display);
+ }
+
+ /* Assign system types
+ */
+ $smarty->assign("SystemTypeKeys", array_flip($this->handle->getSystemTypes()));
+ $smarty->assign("SystemTypes", $this->handle->getSystemTypes());
+ $smarty->assign("type", $this->type);
+
+ /* Assign os types
+ */
+ $smarty->assign("OSKeys", array_flip($this->handle->getOSTypes()));
+ $smarty->assign("OSs", $this->handle->getOSTypes());
+ $smarty->assign("os", $this->os);
+
+ /* Dispaly installed devices */
+ $smarty->assign("InstalledDevices" ,$this->getDevices());
+ $smarty->assign("InstalledDeviceKeys" ,array_flip($this->getDevices()));
+
+ /* Append manufacturers
+ */
+ $smarty->assign("ManufacturerKeys", array_flip($this->handle->getEnterprises()));
+ $smarty->assign("Manufacturers", $this->handle->getEnterprises());
+ $smarty->assign("FK_glpi_enterprise", $this->FK_glpi_enterprise);
+
+ /* Assign used Attachments
+ */
+
+ $divlist = new divSelectBox("glpiAttachmentsList");
+ $divlist-> SetHeight(130);
+ $atts = $this->getUsedAttachments(true);
+ $downlink = "
%s ";
+ $del_link = "
";
+ foreach($atts as $id => $attachment){
+ $divlist->AddEntry
+ (
+ array(
+ array("string"=>$attachment['name']),
+ array("string"=>$attachment['mime']),
+ array("string"=>sprintf($downlink,$id,$attachment['filename'])),
+ array("string"=>sprintf($del_link,$attachment['ID']),"attach"=>"style='border-right:0px;'"),
+ )
+ );
+ }
+
+ $smarty->assign("AttachmentsDiv" ,$divlist->DrawList());
+ /* Handle contact person
+ Assign name ... to smarty, if set
+ */
+ if(isset($users[$this->contact_num])){
+ $ldap->cat($users[$this->contact_num], array('givenName', 'sn', 'uid'));
+ $tr = $ldap->fetch();
+ $str = "";
+ if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; }
+ if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; }
+ if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; }
+ $smarty->assign("contact_num", $str);
+ }else{
+ $smarty->assign("contact_num", _("N/A"));
+ }
+
+ /* Handle tech person
+ Assign name ... to smarty, if set
+ */
+ if(isset($users[$this->tech_num])){
+ $tr = $ldap->cat($users[$this->tech_num], array('givenName', 'sn', 'uid'));
+ $tr = $ldap->fetch();
+ $str = "";
+ if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; }
+ if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; }
+ if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; }
+ $smarty->assign("tech_num", $str);
+ }else{
+ $smarty->assign("tech_num", _("N/A"));
+ }
+ $smarty->assign("comments", $this->comments);
+
+ $display.= $smarty->fetch(get_template_path('glpi.tpl', TRUE));
+ return($display);
+ }
+
+ function remove_from_parent()
+ {
+ /* Cancel if there's nothing to do here */
+ if ((!$this->initially_was_account) || (!$this->acl_is_removeable())){
+ return;
+ }
+ if(function_exists("mysql_pconnect")){
+ $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
+ if($this->initially_was_account){
+ $this->handle->removeComputerInformations($this->dn);
+ new log("remove","undefined/".get_class($this),$this->dn);
+ }
+ }else{
+ print_red(_("Can't remove glpi account, while mysql extension is missing."));
+ new log("remove","undefined/".get_class($this),$this->dn,array(),_("Can't remove glpi account, while mysql extension is missing."));
+ }
+
+ }
+
+ function getDevices(){
+ $ret = array();
+ foreach($this->usedDevices as $type => $entries){
+ foreach($entries as $ent){
+ if(isset($ent['designation'])){
+ $ret[] = $ent['designation']." [".$type."]";
+ }else{
+ $ret[] = $ent['name']." [".$type."]";
+ }
+ }
+ }
+ return($ret);
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ if(!isset($_POST['glpi_tpl_posted'])) {
+ return ;
+ }
+ plugin::save_object();
+ }
+
+
+ /* Check supplied data */
+ function check()
+ {
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+
+ // if($this->TechnicalResponsible == ""){
+ // $message[] = _("Please select a technical responsible person for this entry.");
+ // }
+
+ return ($message);
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ if($this->is_account){
+ $attrs = array();
+ $this->date_mod = date("Y-m-d H:i:s");
+ foreach($this->attributes as $attr){
+ $attrs[$attr] = $this->$attr;
+ }
+ $attrs['name'] = $this->dn;
+ unset($attrs['ID']);
+ $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
+
+ /* check if we have to update, add */
+ if($this->initially_was_account&&$this->is_account){
+ $this->handle->updateComputerInformations($attrs,$this->orig_dn);
+ new log("modify","undefined/".get_class($this),$this->dn);
+ }elseif($this->is_account){
+ $this->handle->addComputerInformations($attrs,$this->dn);
+ new log("create","undefined/".get_class($this),$this->dn);
+ }
+ $tmp = $this->handle->getComputerInformations($this->dn);
+ $this->handle->addDevicesToComputer($this->usedDevices,$tmp[0]['ID']);
+ }
+ }
+
+
+ /* Return used attachments */
+ function getUsedAttachments($divlist = false)
+ {
+ $atts =$this->handle->getAttachments();
+ $ret = array();
+ foreach($atts as $entry){
+ if(in_array($entry['ID'],$this->usedAttachments)){
+ if($divlist){
+ $ret[$entry['ID']] = $entry;
+ }else{
+ $cm ="";
+ if(isset($entry['comment'])){
+ $cm=" [".$entry['comment']."]";
+ }
+ if(isset($entry['mime'])){
+ $cm.=" -".$entry['mime']."";
+ }
+
+ $ret[$entry['ID']]= $entry['name'].$cm;
+ }
+ }
+ }
+ return($ret);
+ }
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Glpi"),
+ "plDescription" => _("Inventory extension"),
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 20,
+ "plSection" => array("administration"),
+ "plCategory" => array("workstation","terminal","component","server","phone") ,
+ "plProvidedAcls"=> array(
+
+ "tech_num" => _("Technical responsible"),
+ "comments" => _("Comment"),
+ "os" => _("Operating system"),
+ "location" => _("Location"),
+ "contact_num" => _("Contact person"),
+ "model" => _("Model"),
+ "type" => _("Type"),
+ "FK_glpi_enterprise" => _("Manufacturer"),
+ "Attachments" => _("Attachments"),
+ "Devices" => _("Peripheral devices"))
+ ));
+ }
+
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/glpi/class_glpiAttachmentPool.inc b/plugins/admin/systems/services/glpi/class_glpiAttachmentPool.inc
new file mode 100644
index 000000000..b50066029
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/class_glpiAttachmentPool.inc
@@ -0,0 +1,362 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account = TRUE;
+ var $attributes = array("name","comment","mime","filename","date_mod");
+ var $objectclasses = array("whatever");
+
+ var $parent;
+ var $edit = false;
+ var $entry = false;
+ var $date_mod ="";
+ var $name ="";
+ var $comment ="";
+ var $mime ="";
+ var $filename ="";
+
+ var $Selected = array();
+
+ var $delAttach= "";
+
+ function glpiAttachmentPool (&$config, $dn= NULL,$used=NULL)
+ {
+ plugin::plugin ($config, $dn);
+ if(!isset($_SESSION['GlpiAttachmentFilter'])){
+ $_SESSION['GlpiAttachmentFilter'] = array("filter"=>"*");
+ }
+
+ /* Assign used attributes */
+ if($used !== NULL){
+ $this->Selected = $used;
+ }
+ }
+
+ function execute()
+ {
+ plugin::execute();
+ $attach = $this->parent->handle->getAttachments();
+ /* Fill templating stuff */
+ $smarty = get_smarty();
+ $display = "";
+ $only_once = true;
+
+ /* walk through all posted objects */
+ foreach($_POST as $name => $value){
+
+ /* Open dialog to create a new entry */
+ if(preg_match("/new_attach/",$name)){
+ $this->edit = true;
+ $this->entry=array();
+
+ /* Set default values */
+ foreach($this->attributes as $attr) {
+ $this->$attr = "";
+ $this->entry[$attr]="";
+ }
+ }
+
+ /* Remove attach*/
+ if((preg_match("/^delAttach_/",$name))&&($only_once)){
+ $only_once = false;
+ $str = preg_replace("/^delAttach_/","",$name);
+ $str = base64_decode(preg_replace("/_.*$/","",$str));
+
+ /* remove attach from db */
+ $this->delAttach = $str;
+ $smarty->assign("warning", sprintf(_("You're about to delete the glpi attachment component '%s'."), $attach[$str]['name']));
+ return($smarty->fetch(get_template_path('remove_glpi.tpl', TRUE)));
+ }
+
+ /* Start editing entry */
+ if((preg_match("/^editAttach_/",$name))&&($only_once)){
+ $only_once = false;
+ $str = preg_replace("/^editAttach_/","",$name);
+ $str = base64_decode(preg_replace("/_.*$/","",$str));
+
+ /* Check if we have an attachment with given ID */
+ foreach($attach as $att ){
+ if($att['ID'] == $str ){
+
+ /* Entry was found, show dialog */
+ $this->edit = true;
+ $this->entry = $att;
+
+ foreach($att as $name => $value){
+ $this->$name = $value;
+ }
+ }
+ }
+ }
+ }
+
+ if((isset($_POST['delete_glpi_confirm']))&&(isset($attach[$this->delAttach]))){
+ if($this->parent->handle->is_attachmentUsed($this->delAttach)){
+ $tmp = $this->parent->handle->is_attachmentUsed($this->delAttach);
+
+ $names = "";
+ foreach($tmp as $name){
+ $names .= ", ".$name;
+ }
+ $names = preg_replace("/^, /","",$names);
+ $names = trim($names);
+ if(count($tmp) == 3){
+ $names .= " ...";
+ }
+ print_red(sprintf(_("You can't delete this attachment, it is still in use by these system(s) '%s'"),$names));
+
+ }else{
+ $this->parent->handle->deleteAttachment($this->delAttach);
+ @unlink(CONFIG_DIR."/glpi/".$this->filename);
+ $attach = $this->parent->handle->getAttachments();
+ }
+ }
+
+ /* Someone tries to upload a file */
+ if(($this->edit == true)&&(isset($_POST['upload']))){
+ if(!isset($_FILES['filename'])){
+ print_red(_("There is no valid file uploaded."));
+ }else{
+ $FILE = $_FILES['filename'];
+ if(!isset($FILE['name'])){
+ print_red(_("There is no valid file uploaded."));
+ }else{
+ if($FILE['error']!=0) {
+ print_red(_("Upload wasn't successfull."));
+ }else{
+ if(!is_dir(CONFIG_DIR."/glpi/")){
+ print_red(sprintf(_("Missing directory '%s/glpi/' to store glpi uploads."),CONFIG_DIR));
+ }else{
+ $filen = CONFIG_DIR."/glpi/".$FILE['name'];
+ if(file_exists($filen)){
+ print_red(_("There is already a file with the same name uploaded."));
+ }else{
+ $fh = fopen($filen,"w");
+ if(!$fh){
+ print_red(sprintf(_("Can't create file '%s'."),$filen));
+ }else{
+ $str = file_get_contents($FILE['tmp_name']);
+ fwrite($fh,$str,strlen($str));
+ fclose($fh);
+ $this->mime = $FILE['type'];
+ $this->filename = $FILE['name'];
+ }
+ } // File already exists
+ }
+ } // Check if any error occurred
+ } // check if valid filename was uploaded
+ } // ende check if file was uploaded
+ }// upload post
+
+ /* save attachment*/
+ if(($this->edit == true)&&(isset($_POST['SaveAttachment']))){
+ if(count($this->check())==0){
+ $this->date_mod = date("Y-m-d H:i:s");
+ $this->save_entry();
+ $this->edit= false;
+ $this->entry = array();
+ $attach = $this->parent->handle->getAttachments();
+ }else{
+ foreach($this->check() as $msg){
+ print_red($msg);
+ }
+ }
+ }
+
+ /* Abort editing/adding attachment*/
+ if(($this->edit == true)&&(isset($_POST['CancelAttachment']))){
+ $this->edit = false;
+ $this->entry = array();
+ }
+
+ /* If edit == true, we have to show a dialog to edit or add an attach
+ */
+ if($this->edit == true){
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,htmlentities(utf8_decode($this->$attr)));
+ }
+ if(!empty($this->filename)){
+ if(is_readable(CONFIG_DIR."/glpi/".$this->filename)){
+ $status =_("File is available.");
+ }else{
+ $status =_("File is not readable, possibly the file is missing.");
+ }
+ }else{
+ $status = _("Currently no file uploaded.");
+ }
+ $smarty->assign("status",$status);
+ return($smarty->fetch(get_template_path('glpiAttachmentEdit.tpl', TRUE)));
+ }
+
+ /* Create list with checkboxes to select / deselect some attachents */
+ $divlist = new divlist("Attachment");
+ $divlist->SetPluginMode();
+ $divlist->SetHeader(array(
+ array("string" => " ", "attach" => "style='text-align:center;width:20px;'"),
+ array("string" => _("Name")),
+ array("string" => _("Mime"),"attach"=>"style='width:200px;'"),
+ array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" )));
+
+ $divlist->SetSummary(_("This table displays all available attachments."));
+ $divlist->SetEntriesPerPage(0);
+
+ $editdel = "
";
+ $editdel.= "
";
+
+ /* Add all given attachments to divlist
+ */
+ foreach($attach as $entry){
+
+ /* Create display name*/
+ if((empty($entry['name']))||(empty($entry['comment']))){
+
+ /* In glpi it is possible to add entries without name
+ so i've added this block
+ */
+ if(empty($entry['name'])){
+ $str1 = "
"._("empty")." ";
+ }else{
+ $str1 = $entry['name'];
+ }
+
+ if(!empty($entry['comment'])){
+ $str1.= " [".$entry['comment']."]";
+ }
+ }else{
+ /* Both attributes given */
+ $str1 = $entry['name']." [".$entry['comment']."]";
+ }
+
+ $edit = str_replace("%s",base64_encode($entry['ID']),$editdel);
+ $str2 = $entry['mime']." ";
+
+ $chkbox = "
".
+ "
";
+
+ if(in_array($entry['ID'],$this->Selected)){
+ $chkbox = preg_replace("/%CHECKED%/"," checked ",$chkbox);
+ }else {
+ $chkbox = preg_replace("/%CHECKED%/"," ",$chkbox);
+ }
+ $chkbox = preg_replace("/%s/",$entry['ID'],$chkbox);
+ $divlist->AddEntry(array(
+ array("string" => $chkbox,
+ "attach" => "style='text-align:center;width:20px;'"),
+ array("string"=> $str1),
+ array("string"=> $str2,"attach"=>"style='width:200px;'"),
+ array("string"=> $edit ,"attach" => "style='width:60px;border-right:0px;text-align:right;'")
+ ));
+
+ }
+
+ $listhead = "
".
+ " ".
+ "
";
+
+ $smarty->assign("attachments", $divlist->DrawList());
+ $smarty->assign("attachmenthead", $listhead);
+ $smarty->assign("search_image", get_template_path('images/search.png'));
+ $smarty->assign("searchu_image", get_template_path('images/search_user.png'));
+ $smarty->assign("tree_image", get_template_path('images/tree.png'));
+ $smarty->assign("infoimage", get_template_path('images/info_small.png'));
+ $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
+ $smarty->assign("apply", apply_filter());
+ $smarty->assign("alphabet", generate_alphabet());
+ $smarty->assign("attachment_regex", $_SESSION['GlpiAttachmentFilter']['filter']);
+
+ $display.= $smarty->fetch(get_template_path('glpiAttachmentPool.tpl', TRUE));
+ return($display);
+ }
+
+ function save()
+ {
+ return($this->Selected);
+ }
+
+ /* Adds new or saves edited entries */
+ function save_entry()
+ {
+ if($this->edit){
+ $tmp = array();
+ foreach($this->attributes as $attr){
+ $tmp[$attr] = $this->$attr;
+ }
+ $id = -1;
+ if(isset($this->entry['ID'])){
+ $id = $this->entry['ID'];
+ }
+ $this->parent->handle->saveAttachments($tmp,$id);
+ }
+ }
+
+ function save_object()
+ {
+ foreach($this->attributes as $attr){
+ if(isset($_POST[$attr])){
+ $this->$attr = $_POST[$attr];
+ }
+ }
+
+ /* Checkboxes are only posted, if they are checked
+ * To check if it was deselected, we check if wasOnPage
+ * was posted with given name, so we can deselect this entry
+ */
+
+ foreach($_POST as $name => $value){
+ if(preg_match("/wasOnPage_/",$name)){
+ $id=preg_replace("/wasOnPage_/","",$name);
+ if(isset($_POST["useMe_".$id])){
+ $this->Selected[$id]=$id;
+ }else{
+ if(isset($this->Selected[$id])){
+ unset($this->Selected[$id]);
+ }
+ }
+ }
+ }
+ }
+
+ /* Simple check */
+ function check()
+ {
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+
+ if($this->edit){
+
+ /* check if given name is already in use */
+ $att = $this->parent->handle->getAttachments();
+ $ok = true;
+ $this->name=trim($this->name);
+
+ foreach($att as $val){
+ if(!isset($this->entry['ID'])){
+ if($val['name'] == $this->name){
+ $ok = false;
+ }
+ }else{
+ if(($val['name'] == $this->name)&&($this->entry['ID'] != $val['ID'])){
+ $ok = false;
+ }
+ }
+ }
+ if(!$ok){
+ $message[] = _("This name is already in use.");
+ }
+ if(empty($this->name)){
+ $message[] = _("Please specify a valid name for this attachment.");
+ }
+ }
+ return($message);
+ }
+
+}// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/glpi/class_glpiDeviceManagement.inc b/plugins/admin/systems/services/glpi/class_glpiDeviceManagement.inc
new file mode 100644
index 000000000..0f24300d8
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/class_glpiDeviceManagement.inc
@@ -0,0 +1,427 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account= TRUE;
+ var $attributes= array();
+ var $objectclasses= array("whatever");
+
+ var $devices = array();
+ var $ui;
+
+ var $parent ;
+ var $EditEntry;
+ var $editMode =false;
+
+ var $DeviceAttrs = array();
+ var $AllowedDevices = array();
+
+ var $Selected = array();
+
+ var $delete = array();
+
+ function glpiDeviceManagement (&$config, $dn= NULL,$used=NULL)
+ {
+ plugin::plugin ($config, $dn);
+
+ if(!isset($_SESSION['glpiDeviceRegex'])){
+ $tmp['device_regex'] = "*";
+ $_SESSION['glpiDeviceRegex'] = $tmp;
+ }
+ $this->ui = get_userinfo();
+
+ if(isset($used)){
+ $this->Selected = $used;
+ }
+
+ /* Specify which vars are allowed for a sepcific type of device */
+ $this->DeviceAttrs['case'] = array("designation","format","comment","FK_glpi_enterprise");
+ $this->DeviceAttrs['moboard'] = array("designation","chipset","comment","FK_glpi_enterprise");
+ $this->DeviceAttrs['processor'] = array("designation","frequence","comment","FK_glpi_enterprise","specif_default");
+ $this->DeviceAttrs['iface'] = array("designation","bandwidth","comment","FK_glpi_enterprise","specif_default");
+ $this->DeviceAttrs['ram'] = array("designation","frequence","comment","FK_glpi_enterprise","specif_default","type");
+ $this->DeviceAttrs['hdd'] = array("designation","rpm","interface","cache","comment","FK_glpi_enterprise","specif_default");
+ $this->DeviceAttrs['drive'] = array("designation","speed","interface","is_writer","comment","FK_glpi_enterprise","specif_default");
+ $this->DeviceAttrs['control'] = array("designation","interface","raid","comment","FK_glpi_enterprise");
+ $this->DeviceAttrs['gfxcard'] = array("designation","ram","interface","comment","FK_glpi_enterprise","specif_default");
+ $this->DeviceAttrs['sndcard'] = array("designation","type","comment","FK_glpi_enterprise","specif_default");
+ $this->DeviceAttrs['power'] = array("designation","power","comment","FK_glpi_enterprise","atx");
+ $this->DeviceAttrs['pci'] = array("designation","comment","FK_glpi_enterprise","specif_default");
+ $this->DeviceAttrs['monitor'] = array("name","comments","serial","otherserial","size",
+ "flags_micro","flags_speaker","flags_subd","flags_bnc",
+ "location","type","FK_glpi_enterprise","is_global","deleted","is_template","tplname");
+
+ $this->AllowedDevices=array("case","moboard","sndcard","processor","iface","ram","hdd","drive","control","gfxcard","power","pci","monitor");
+ }
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ /* Get all defined devices */
+ $this->reload();
+
+ /* Fill templating stuff */
+ $smarty= get_smarty();
+ $display= "";
+
+ /* this var is used to ensure that every post is only performed once */
+ $only_once = true;
+
+ /* Check Post for some actions */
+ foreach($_POST as $name => $value){
+
+ /* If new_ then we should create an new device */
+ if((preg_match("/^new_/",$name))&&($only_once)){
+
+ /* don't do this twice */
+ $only_once = false;
+
+ /*extract device device_type */
+ $deviceType = preg_replace("/_.*$/","",preg_replace("/^new_/","",$name));
+
+ /* Check if type is allowed, and create empty entry */
+ $tmp = array();
+ if((!isset($this->DeviceAttrs[$deviceType]))||((!in_array($deviceType,$this->AllowedDevices)))){
+ print_red(sprintf(_("Internal Error can't create device of type '%s'"),$deviceType));
+ }else{
+ foreach($this->DeviceAttrs[$deviceType] as $attr){
+ $tmp[$attr] = "";
+ }
+ $tmp['device_type'] = $deviceType;
+ $this->EditEntry = $tmp;
+ $this->editMode =true;
+ }
+ }
+ }
+
+ /* delete was requested ... show dialog */
+ if((isset($_GET['act']))&&($_GET['act']=="del_device")){
+ $id = base64_decode($_GET['id']);
+ $tmp = $this->devices[$id];
+
+ $this->delete = $tmp;
+
+ if(isset($tmp['name'])){
+ $smarty->assign("warning", sprintf(_("You're about to delete the glpi device '%s'."), $tmp['name']));
+ }elseif(isset($tmp['designation'])){
+ $smarty->assign("warning", sprintf(_("You're about to delete the glpi device '%s'."), $tmp['designation']));
+ }else{
+ print_red(_("Can't detect object name."));
+ }
+
+ return($smarty->fetch(get_template_path('remove_glpi.tpl', TRUE)));
+ }
+
+ /* Delete entry, but check if this device is in currently in use */
+ if(isset($_POST['delete_glpi_confirm'])){
+ if(count($this->parent->handle->is_deviceUsed($this->delete))){
+
+ $tmp = $this->parent->handle->is_deviceUsed($this->delete);
+
+ $names = "";
+ foreach($tmp as $name){
+ $names .= ", ".$name;
+ }
+ $names = preg_replace("/^, /","",$names);
+ $names = trim($names);
+ if(count($tmp) == 3){
+ $names .= " ...";
+ }
+ print_red(sprintf(_("You can't delete this device, it is still in use by these system(s) '%s'"),$names));
+ }else{
+ $this->parent->handle->deleteDevice($this->delete);
+ $this->reload();
+ }
+ }
+
+ /* Open entry for editing if requested */
+ if((isset($_GET['act']))&&($_GET['act']=="edit_device")){
+ $id = base64_decode($_GET['id']);
+ $this->editMode =true;
+ $this->EditEntry = $this->devices[$id];
+ }
+
+ /* Abort editing this entry */
+ if(isset($_POST['AbortDeviceChanges'])){
+ $this->EditEntry = array();
+ $this->editMode = false;
+ }
+
+ /* Save all changes made on currently selected entry */
+ if(isset($_POST['SaveDeviceChanges'])){
+
+ /* First check if all changes made are allowed */
+ if(count($this->check())==0){
+ $this->save();
+ $this->editMode = false;
+ $this->reload();
+ }else{
+ foreach($this->check() as $msg){
+ print_red($msg);
+ }
+ }
+
+ }
+
+ /* Check if we are currently editing something ? */
+ if($this->editMode == true){
+ return ($this->editDevice($this->EditEntry));
+ }
+
+ /* ENDE : GET / POST handling
+ * Below, only output generation for headpage
+ */
+
+ $divlist = new divlist("glpi devices");
+ $divlist->SetPluginMode();
+ $divlist->SetEntriesPerPage(0);
+ $divlist->SetHeader(array(
+ array("string" => " ", "attach" => "style='text-align:center;width:20px;'"),
+ array("string" => _("devices"), "attach" => "style=''"),
+ array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" )));
+
+ $edit = "
%s ";
+ $editdel = "
";
+ $editdel.= "
";
+
+ $useDevice = "
";
+
+ foreach($this->devices as $key=>$user){
+
+ if(isset($user['designation'])){
+ $str = "designation";
+ }else{
+ $str = "name";
+ }
+
+ if(isset($this->Selected[$user['device_type']][$user[$str]])){
+ $use = " checked ";
+ }else{
+ $use ="";
+ }
+
+ /* Dawn databse struckture ....*/
+ if(empty($user['comment']) && isset($user['comments'])) {
+ $user['comment'] = $user['comments'];
+ }
+
+ $field1 = array("string" => preg_replace("/%s/",base64_encode($key),preg_replace("/%USE%/",$use,$useDevice)), "attach" => "style='text-align:center;width:20px;'");
+ $field2 = array("string" => sprintf($edit,base64_encode($key),$user[$str]." [".$user['comment']."]"), "attach" => "style=''");
+ $field3 = array("string" => sprintf($editdel,base64_encode($key),base64_encode($key)),
+ "attach" => "style='width:60px;border-right:0px;text-align:right;'");
+ $divlist->AddEntry(array($field1,$field2,$field3));
+
+ }
+
+ $listhead = "
".
+ " ".
+ " ".
+ " ".
+ " ".
+ " ".
+ " ".
+ " ".
+ " ".
+ " ".
+ " ".
+ " ".
+ " ".
+ " ".
+ "
";
+
+ $filter= $_SESSION['glpiDeviceRegex'];
+ $smarty->assign("devicehead", $listhead);
+ $smarty->assign("devices", $divlist->DrawList());
+ $smarty->assign("search_image", get_template_path('images/search.png'));
+ $smarty->assign("searchu_image", get_template_path('images/search_user.png'));
+ $smarty->assign("tree_image", get_template_path('images/tree.png'));
+ $smarty->assign("infoimage", get_template_path('images/info_small.png'));
+ $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
+ $smarty->assign("apply", apply_filter());
+ $smarty->assign("alphabet", generate_alphabet());
+ $smarty->assign("device_regex", $filter['device_regex']);
+
+ $display.= $smarty->fetch(get_template_path('glpiDeviceManagement.tpl', TRUE));
+ return($display);
+ }
+
+ /* Save device to glpi database
+ * If this is a new device, create a new entry, else update this entry
+ */
+ function save()
+ {
+ if($this->parent->handle->deviceExists($this->EditEntry)){
+ $this->parent->handle->updateDevices($this->EditEntry);
+ }else{
+ $this->parent->handle->addDevice($this->EditEntry);
+ }
+
+ }
+
+ /* this only gets all already defined devices */
+ function reload()
+ {
+ $this->devices = $this->parent->handle->getDevices();
+ ksort($this->devices);
+ }
+
+ /* This funtions saves all POST variables.
+ The variable must be in the array $this->EditEntry
+ */
+ function save_object()
+ {
+ foreach($_POST as $name => $value){
+
+ if(preg_match("/wasOnPage_/",$name)){
+ $dN = base64_decode($value);
+
+ $device = $this->devices[$dN];
+ $type = $device['device_type'];
+
+ if(isset($device['designation'])){
+ $str = "designation";
+ }else{
+ $str = "name";
+ }
+
+ if(isset($_POST['useDevice_'.$value])){
+ $this->Selected[$type][$device[$str]] = $device;
+ }else{
+ if(isset($this->Selected[$type][$device[$str]])){
+ unset($this->Selected[$type][$device[$str]]);
+ }
+ }
+ }
+ }
+
+ if(is_array($this->EditEntry)){
+ foreach($this->EditEntry as $name => $value){
+ if(isset($_POST[$name])){
+ $this->EditEntry[$name] = $_POST[$name];
+ }
+
+ }
+ }
+ }
+
+ /* returns the selected devices */
+ function getSelected()
+ {
+ return($this->Selected);
+ }
+
+ /* This function checks all created devices.
+ If you wan't to use device specific checks,
+ use >>if($attr['device_type']=="moboard")<< to create a device type depending check
+ */
+ function check()
+ {
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+
+ $attr = $this->EditEntry;
+
+ if(isset($attr['designation'])){
+ $str2 = "designation";
+ }else{
+ $str2 = "name";
+ }
+ if(empty($attr[$str2])){
+ $message[]=(_("You have to specify a valid name for this device."));
+ }
+
+ /* Avoid same name twice */
+ $devices = ($this->parent->handle->getDevices());
+ foreach($devices as $dev){
+
+ /* Some devices use designation some name for name
+ */
+ if(isset($dev['designation'])){
+ $str = "designation";
+ }else{
+ $str = "name";
+ }
+
+ if($dev[$str]==$attr[$str2]){
+
+ /* Entries with ['ID'] already exists, and are only edited, if ID is missing we are currently creating a new entry */
+ if(isset($attr['ID'])){
+ if(!(($dev['ID'] == $attr['ID'])&&($dev['device_type']==$attr['device_type']))){
+ $message[] = _("This device name is already in use.");
+ }
+ }else{
+ $message[] = _("This device name is already in use.");
+ }
+ }
+ }
+
+ return($message);
+ }
+
+ /* This functions displays the template for all available devices
+ * This function is also used if we create a new device
+ */
+ function editDevice($entry)
+ {
+ $smarty = get_smarty();
+
+ /* Transfer given data to smarty */
+ foreach($this->EditEntry as $name => $value){
+ $smarty->assign($name,htmlentities(utf8_decode($value)));
+ }
+
+ /* Set default select boxes, manufacturers ... */
+ $smarty->assign("device_type",$entry['device_type']);
+
+ $none = array(0 => _("none"));
+ $manufacturer = array_merge($none,$this->parent->handle->getEnterprises());
+
+ $ramtypes = $this->parent->handle->getRAMTypes();
+
+ $smarty->assign("RAMtypes", $ramtypes);
+ $smarty->assign("RAMtypeKeys", array_flip($ramtypes));
+
+ $deviceControlTypes = array_merge($none,$this->parent->handle->getGlpiDeviceControlTypes());
+
+ $smarty->assign("HDDInterfaceKeys",array_flip($deviceControlTypes));
+ $smarty->assign("HDDInterfaces" , $deviceControlTypes);
+
+ $gfxControlTypes = array("0"=>_("None"),"AGP"=>"AGP","PCI"=>"PCI","PCI-X"=>"PCI-X","Other"=>_("Other"));
+
+ $smarty->assign("GFXInterfaceKeys",array_flip($gfxControlTypes));
+ $smarty->assign("GFXInterfaces" , $gfxControlTypes);
+
+ $smarty->assign("FK_glpi_enterpriseKeys",array_flip($manufacturer));
+ $smarty->assign("FK_glpi_enterprises", $manufacturer);
+
+ $smarty->assign("formats",array("Large","Medium","Micro"));
+ $smarty->assign("formats",array("Large","Medium","Micro"));
+
+ $smarty->assign("formats",array("Large","Medium","Micro"));
+ $smarty->assign("formatKeys",array('Grand','Moyen','Micro'));
+ return($smarty->fetch(get_template_path('glpi_devices.tpl', TRUE)));
+ }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/glpi/class_glpiManufacturer.inc b/plugins/admin/systems/services/glpi/class_glpiManufacturer.inc
new file mode 100644
index 000000000..8e676d8ee
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/class_glpiManufacturer.inc
@@ -0,0 +1,170 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account= TRUE;
+ var $attributes= array("name","type","address","website","phonenumber","comments","deleted","fax","email");
+ var $objectclasses= array("whatever");
+
+ var $ui;
+
+ var $editMode = false;
+ var $Edit_Add = "edit";
+
+ var $name ="";
+ var $type ="";
+ var $address ="";
+ var $website ="";
+ var $phonenumber="";
+ var $comments ="";
+ var $deleted ="";
+ var $fax ="";
+ var $email ="";
+ var $ID =-1;
+
+ function glpiManufacturer(&$config, $dn= NULL, $parent= NULL)
+ {
+ plugin::plugin ($config, $dn, $parent);
+ $this->ui = get_userinfo();
+ }
+
+ function execute()
+ {
+ plugin::execute();
+ $smarty = get_smarty();
+ $display = "";
+
+ /* Remove enterprise from db */
+ if((isset($_POST['remove_manu']))&&(isset($_POST['manufacturer']))){
+
+ $tmp = $this->parent->handle->is_manufacturerUsed($_POST['manufacturer']);
+ if(count($tmp)){
+
+ $names = "";
+ foreach($tmp as $name){
+ $names .= ", ".$name;
+ }
+ $names = preg_replace("/^, /","",$names);
+ $names = trim($names);
+ if(count($tmp) == 3){
+ $names .= " ...";
+ }
+ print_red(sprintf(_("You can't delete this manufacturer, it is still in use by these system(s) '%s'"),$names));
+ }else{
+ $this->parent->handle->removeEnterprise($_POST['manufacturer']);
+ }
+ }
+
+ /* Add new Manufactuer : Open dialog with empty fields */
+ if(isset($_POST['add_manu'])){
+ $this->editMode = true;
+ $this->Edit_Add = "add";
+ foreach($this->attributes as $atr){
+ $this->$atr = "";
+ }
+ }
+
+ /* Edit existing manuatctuerer data */
+ if((isset($_POST['edit_manu']))&&(isset($_POST['manufacturer']))){
+ $this->editMode = true;
+ $this->Edit_Add = "edit";
+ $tmp = $this->parent->handle->getEnterprise($_POST['manufacturer']);
+ $tmp = $tmp[0];
+ foreach($this->attributes as $atr){
+ $this->$atr = "";
+ }
+ foreach($this->attributes as $atr){
+ if(isset($tmp[$atr])){
+ $this->$atr = $tmp[$atr];
+ }
+ }
+ $this->ID = $_POST['manufacturer'];
+ }
+
+ /* close Dialog without saving */
+ if(isset($_POST['close_manufacturer'])){
+ $this->editMode=false;
+ }
+
+ /* close dialog an save all changes / adds */
+ if(isset($_POST['save_manufacturer'])){
+ $tmp = array();
+ foreach($this->attributes as $attrs){
+ $tmp[$attrs]=$this->$attrs;
+ }
+
+ $allok = true;
+ if(empty($tmp['name'])){
+ print_red(_("Please specify a name."));
+ $allok = false;
+ }
+
+ $attr = $this->parent->handle->getEnterprises();
+
+ if($this->ID == -1 ){
+ if(in_array($tmp['name'],$attr)){
+ $allok = false;
+ print_red(_("Specified name is already in use, please choose another one."));
+ }
+ }else{
+ unset($attr[$this->ID]);
+ if(in_array($tmp['name'],$attr)){
+ $allok = false;
+ print_red(_("Specified name is already in use, please choose another one."));
+ }
+ }
+
+ /* all checks are ok , so save changes */
+ if($allok){
+ if($this->Edit_Add == "add"){
+ $this->parent->handle->addEnterprise($tmp);
+ $this->editMode=false;
+ }else{
+ $this->parent->handle->updateEnterprise($tmp,$this->ID);
+ $this->editMode=false;
+ }
+ }
+ }
+
+ /* As long as this war is true, we have to display the edit dialog */
+ if($this->editMode == true){
+ $this->save_object();
+ foreach($this->attributes as $attrs){
+ $smarty->assign($attrs,$this->$attrs);
+ }
+
+ $display.= $smarty->fetch(get_template_path('glpiManufacturerAdd.tpl', TRUE));
+ return($display);
+ }
+
+
+ $smarty->assign("Manus", $this->parent->handle->getEnterprises());
+ $smarty->assign("ManuKeys", array_flip($this->parent->handle->getEnterprises()));
+ $display.= $smarty->fetch(get_template_path('glpiManufacturer.tpl', TRUE));
+ return($display);
+ }
+
+ /* Save to LDAP */
+ function save()
+ {
+ }
+
+ function save_object()
+ {
+ foreach($this->attributes as $attr){
+ if(isset($_POST[$attr])){
+ $this->$attr = stripslashes($_POST[$attr]);
+ }
+ }
+ }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/glpi/class_glpiPrinterAccount.inc b/plugins/admin/systems/services/glpi/class_glpiPrinterAccount.inc
new file mode 100644
index 000000000..049249cd5
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/class_glpiPrinterAccount.inc
@@ -0,0 +1,807 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account= FALSE;
+ var $attributes= array("ID","name","contact","ramSize","flags_serial","flags_par","flags_usb",
+ "tech_num","comments","date_mod","location","domain","network","contact_num","serial","otherserial",
+ "type","is_template","FK_glpi_enterprise","deleted");
+
+ var $ID ; // Is set if this entry is edited
+ var $name = ""; // This should be the dn of this entry
+ var $FK_glpi_enterprise = 0; // Manufacturer id
+ var $tech_num = ""; // Technical responsible person
+ var $contact_num = ""; // Contact person
+
+ var $comments = ""; // Comment
+
+ var $type = 0; // printer type id
+ var $serial = "";
+ var $otherserial = "";
+ var $ramSize = 0;
+ var $flags_serial = false;
+ var $flags_par = false;
+ var $flags_usb = false;
+
+ var $date_mod = ""; // Modification timestamp
+
+ var $location = 0; // Not used yet
+ var $domain = 0; // ? Set to 0
+ var $network = 0; // ? Set to 0
+
+ var $is_template = 0; // Used as template ?
+ var $contact = ""; // Empty
+ var $deleted = "N"; // Deleted entries should have this set to Y
+
+ var $rename = false;
+ var $select_type ;
+
+ var $editManufacturer = false;
+
+ /* Not necessary, cause we use mysql databse */
+ var $objectclasses= array("whatever");
+
+ /* Used to remember if this was an account (simply: is this an edited entry) */
+ var $initially_was_account = false;
+
+ /* Remember current dialog */
+ var $edit_type = false;
+ var $edit_os = false;
+
+ var $data;
+ var $handle = NULL; // Glpi class handle used to query database
+
+ var $cur_dialog = NULL; // This contains the sub dialog handle
+
+ var $orig_dn; // To check if dn, has changed
+ var $ui; // Some GOsa specific user informations
+
+ var $usedDevices = array(); // Which devices are currently selected
+ var $usedAttachments = array(); // Used Attachments
+ var $usedCartridges = array(); // Used Cartridges
+
+ var $view_logged = FALSE;
+
+ /* Contructor
+ Sets default values and checks if we already have an existing glpi account
+ */
+ function glpiPrinterAccount (&$config, $dn= NULL, $parent= NULL)
+ {
+ plugin::plugin ($config, $dn, $parent);
+ $this->ui= get_userinfo();
+
+ $this->is_account = false;
+
+ /* Abort class construction, if no db is defined */
+ if(!isset($this->config->data['SERVERS']['GLPI'])){
+ return;
+ }
+
+ // Get informations about databse connection
+ $this->data = $this->config->data['SERVERS']['GLPI'];
+
+ // Abort if mysql extension is missing
+ if(!is_callable("mysql_connect")){
+ return;
+ }
+
+ // Create handle of glpi class, and check if database connection is established
+ $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
+
+ if(!$this->handle->is_connected){
+ return;
+ }
+
+ // If this dn is already used in database, then get all informations for this entry
+ if($this->handle->is_printer_account($this->dn)){
+ $this->is_account = true;
+ $tmp = ($this->handle->getPrinterInformations($this->dn));
+
+ foreach(array("tech_num","FK_glpi_enterprise","type","comments","contact_num","flags_serial","flags_par","flags_usb","ramSize") as $attr){
+ $this->$attr = $tmp[0][$attr];
+ }
+
+ $atts = $this->handle->getAssignPrinterAttachments($tmp[0]['ID']);
+ foreach($atts as $attachment){
+ $this->usedAttachments[$attachment['FK_doc']]=$attachment['FK_doc'];
+ }
+
+ $cart= $this->handle->getUsedCartridges($tmp[0]['ID']);
+ foreach($cart as $key => $cartridge){
+ $this->usedCartridges[$key]=$cartridge;
+ $this->usedCartridges[$key]['status']="exists";
+ }
+
+
+ }else{
+ $this->is_account = false;
+ }
+
+ /* set defaults */
+ $this->name = $this->dn;
+ $this->orig_dn = $this->dn;
+ $this->initially_was_account = $this->is_account;
+ }
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","printer/".get_class($this),$this->dn);
+ }
+
+ /* Fill templating stuff */
+ $smarty= get_smarty();
+ $display= "";
+
+ $smarty->assign("CartridgesACL",$this->getacl("Cartridges"));
+
+ /* Assign smarty defaults
+ To avoid undefined indexes, if there is an error with the glpi db
+ */
+ foreach(array("PrinterTypeKeys","PrinterTypes","ManufacturerKeys","Manufacturers",
+ "Attachments","AttachmentKeys","CartridgeKeys","Cartridges") as $attr){
+ $smarty->assign($attr,array());
+ }
+ foreach(array("type","FK_glpi_enterprise","tech_num","contact_num","comments","flags_serial","flags_par","flags_usb","AttachmentsDiv") as $attr){
+ $smarty->assign($attr,"");
+ }
+
+ /* Assign acls */
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translation){
+ $smarty->assign($name."ACL",$this->getacl($name));
+ }
+
+ /* Check if there is a glpi database server defined
+ */
+ if(!isset($this->config->data['SERVERS']['GLPI'])){
+ print_red(_("There is no server with valid glpi database service."));
+ return($smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE)));
+ }
+
+ $this->data = $this->config->data['SERVERS']['GLPI'];
+
+ /* Check if we can call mysql_connect
+ If we can't, there is no the mysql-php extension
+ */
+ if(!is_callable("mysql_connect")){
+ print_red(_("Can't connect to glpi database, the php-mysql extension is missing."));
+ return($smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE)));
+ }
+
+ $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
+
+ /* If handle == false, abort
+ Seems that the server, username and or password is wrong
+ */
+ if(!$this->handle->is_connected){
+ print_red(_("Can't connect to glpi database, check configuration twice."));
+ return($smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE)));
+ }
+
+ /* All checks are ok
+ Lets handle Posts, templates etc below ...
+ */
+
+ $users = $this->handle->getUsers();
+ $ldap= $this->config->get_ldap_link();
+
+
+ /* ##########################################################################
+ * Some tab management
+ */
+
+ /* 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;
+ }
+ }
+
+ /* Show tab dialog headers */
+ if ($this->is_account){
+ $display= $this->show_disable_header(_("Remove inventory"),
+ _("This server has inventory features enabled. You can disable them by clicking below."));
+ } else {
+ $display= $this->show_enable_header(_("Add inventory"),
+ _("This server has inventory features disabled. You can enable them by clicking below."));
+ return ($display);
+ }
+
+
+ /* ##########################################################################
+ * Printer type management
+ * Dialog
+ */
+
+ /* Rename was requested */
+ if(isset($_POST['Rename_PType_OK']) && $this->acl_is_writeable("type")){
+ $tmp = $this->handle->getPrinterTypes();
+ $allok = true;
+ foreach($tmp as $id => $name){
+ if(trim($name) == trim($_POST['string'])){
+ $allok = false;
+ }
+ }
+ if($allok){
+ $this->handle->updatePrinterType($_POST['string'],$this->select_type);
+ $this->rename = false;
+ }else{
+ print_red(sprintf(_("Can't rename given printer type to '%s', because this type name already exists."),$_POST['string']));
+ }
+ }
+
+ /* abort rename
+ */
+ if(isset($_POST['Rename_Cancel'])){
+ $this->rename = false;
+ }
+
+ /* Printer type management
+ */
+ if(isset($_POST['edit_type']) && $this->acl_is_writeable("type")){
+ $this->dialog = true;
+ $this->edit_type=true;
+ }
+
+ /* This closes the printer type editing dialog
+ */
+ if(isset($_POST['close_edit_type'])){
+ $this->edit_type=false;
+ $this->dialog = false;
+ }
+
+ /* This appends a new printer to our sytem types
+ */
+ if((isset($_POST['add_type']))&&(!empty($_POST['type_string'])) && $this->acl_is_writeable("type")){
+
+ $tmp = $this->handle->getPrinterTypes();
+ $allok = true;
+ foreach($tmp as $id => $name){
+ if(trim($name) == trim($_POST['type_string'])){
+ $allok = false;
+ }
+ }
+ if($allok){
+ $this->handle->addPrinterType($_POST['type_string']);
+ }else{
+ print_red(sprintf(_("Can't rename given printer type to '%s', because this type name already exists."),$_POST['type_string']));
+ }
+ }
+
+ /* Remove selected type from our printer types list
+ */
+ if((isset($_POST['del_type']))&&(!empty($_POST['select_type'])) && $this->acl_is_writeable("type")){
+ $tmp = $this->handle->is_printerTypeUsed($_POST['select_type']);
+ if(count($tmp)){
+ $str = "";
+ foreach($tmp as $id => $name){
+ $str .= $name.", ";
+ }
+ $str = preg_replace("/, $/","",$str);
+ print_red(sprintf(_("Can't delete printer type, it is still in use by '%s'."),$str));
+ }else{
+ $this->handle->removePrinterType($_POST['select_type']);
+ }
+ }
+
+ /* Rename selected printer type to given string
+ */
+ if((isset($_POST['rename_type']))&&(!empty($_POST['select_type']))||($this->rename) && $this->acl_is_writeable("type")){
+ $this->rename = true;
+
+ $smarty->assign("Method","rename");
+
+ $tmp = $this->handle->getPrinterTypes();
+
+ if(isset($_POST['select_type'])){
+ $this->select_type = $_POST['select_type'];
+ }
+ $smarty->assign("string",$tmp[$this->select_type]);
+ if(isset($_POST['string'])){
+ $smarty->assign("string",$_POST['string']);
+ }
+
+ $display= $smarty->fetch(get_template_path('glpi_edit_printer_type.tpl', TRUE));
+ return($display);
+ }
+
+ /* Someone wants to edit the printer types ...
+ So, lets open a new dialog which provides some buttons to edit the types
+ */
+ if($this->edit_type){
+ $smarty->assign("Method","edit");
+ $smarty->assign("PrinterTypes", $this->handle->getPrinterTypes());
+ $smarty->assign("PrinterTypeKeys", array_flip($this->handle->getPrinterTypes()));
+ $display= $smarty->fetch(get_template_path('glpi_edit_printer_type.tpl', TRUE));
+ return($display);
+ }
+
+
+ /* ##########################################################################
+ * Edit manufacturers
+ * Dialog
+ */
+
+ /* Open dialog which allows to edit the manufacturers
+ */
+ if(isset($_POST['edit_manufacturer']) && $this->acl_is_writeable("FK_glpi_enterprise")){
+ $this->cur_dialog = new glpiManufacturer($this->config,$this->dn);
+ $this->dialog = true;
+ $this->editManufacturer =true;
+ }
+
+ /* Close manufacturer editing dialog
+ */
+ if((isset($_POST['close_edit_manufacturer']))&&($this->editManufacturer)){
+ $this->dialog = false;
+ $this->cur_dialog = false;
+ $this->editManufacturer=false;
+ }
+
+
+ /* ##########################################################################
+ * Technical responsible person
+ * Contact person
+ * Dialog
+ */
+
+ /* Show dialog to select a new contact person
+ * Select a contact person
+ */
+ if(isset($_POST['SelectContactPerson']) && $this->acl_is_writeable("contact_num")){
+ $this->addUser = "contact";
+ $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
+ }
+
+ /* Selecte technical responsible person
+ */
+ if(isset($_POST['SelectTechPerson']) && $this->acl_is_writeable("tech_num")){
+ $this->addUser ="tech";
+ $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
+ }
+
+ /* Abort user selection
+ */
+ $smarty->assign("AbortSelectUser","SelectUserCancel");
+ if(isset($_POST['SelectUserCancel'])){
+ $this->dialog = false;
+ $this->addUser ="";
+ $this->cur_dialog = false;
+ }
+
+ /* Technical responsible/contact person selected */
+ if(isset($_GET['act'])&&($_GET['act']=="user_tech_num")){
+
+ /* Get posted id */
+ $id = base64_decode($_GET['id']);
+
+ /* Check if user is already created in glpi database */
+ if(!in_array($id,$users)){
+
+ /* If this user doesn't exists in glpi db, we must create him */
+ $ldap->cat($id, array('cn', 'mail', 'telephoneNumber'));
+ $atr = $ldap->fetch();
+ $tmp = array();
+ $use = array( "cn" =>"name",
+ "mail" =>"email",
+ "telephoneNumber" =>"phone");
+
+ /* Create array */
+ foreach($use as $gosa => $glpi){
+ if(isset($atr[$gosa])){
+ $tmp[$glpi]= $atr[$gosa][0];
+ }
+ }
+
+ /* Add this user */
+ $this->handle->addUser($tmp,$id);
+ }
+
+ /* Re-read users */
+ $users = ($this->handle->getUsers());
+
+ /* Get user */
+ $tmp = array_flip($users);
+ $id=$tmp[$id];
+
+ /* Use user id, close dialog */
+ if($this->addUser == "tech"){
+ $this->tech_num = $id;
+ }else{
+ $this->contact_num = $id;
+ }
+ $this->cur_dialog = false;
+ $this->dialog= false;
+ }
+
+
+ /* ##########################################################################
+ * Handle attachments
+ */
+
+ /* Attachment pool was closed with use
+ */
+ if(isset($_POST['UseAttachment']) && $this->acl_is_writeable("Attachments")){
+ if(count($this->cur_dialog->check())){
+ foreach($this->cur_dialog->check() as $msg){
+ print_red($msg);
+ }
+ }else{
+ $this->cur_dialog->save_object();
+ $this->usedAttachments = $this->cur_dialog->save();
+ $this->cur_dialog = false;
+ $this->edit_type = false;
+ }
+ }
+
+ /* Attachment pool was closed with abort
+ */
+ if(isset($_POST['AbortAttachment'])){
+ $this->cur_dialog = false;
+ $this->edit_type = false;
+ }
+
+ /* Open Attachment pool to add/edit Attachments
+ */
+ if(isset($_POST['AddAttachment']) && $this->acl_is_writeable("Attachments")){
+ $this->cur_dialog = new glpiAttachmentPool($this->config,$this->dn,$this->usedAttachments);
+ $this->dialog = true;
+ }
+
+ /* Remove Attachment from this tab
+ */
+ $once = true;
+ foreach($_POST as $name => $value){
+ if((preg_match("/^delAttachment_/",$name))&&($once) && $this->acl_is_writeable("Attachments")){
+ $once= false;
+ $name = preg_replace("/^delAttachment_/","",$name);
+ $entry = preg_replace("/_.*$/","",$name);
+ if(isset($this->usedAttachments[$entry])){
+ unset($this->usedAttachments[$entry]);
+ }
+ }
+ }
+ if((isset($_POST['RemoveAttachment']))&&(isset($_POST['Attachments'])) && $this->acl_is_writeable("Attachments")){
+ if(isset($this->usedAttachments[$_POST['Attachments']])){
+ unset($this->usedAttachments[$_POST['Attachments']]);
+ }
+ }
+
+ /* ##########################################################################
+ * Printer Cartridge handling
+ */
+
+ /* Abort cartridge select dialog
+ */
+ if(isset($_POST['SelectCartridgeCancel'])){
+ $this->cur_dialog = false;
+ $this->edit_type = false;
+ }
+
+ /* Get selected cartridges and add them to our list
+ */
+ if(isset($_POST['SelectCartridgeSave'])){
+ $this->cur_dialog->save_object();
+ $carts = $this->cur_dialog->save();
+ foreach($carts as $cart){
+ $cart['status'] = "new";
+ $this->usedCartridges[] = $cart;
+ }
+ $this->cur_dialog = false;
+ $this->edit_type = false;
+ }
+
+ /* Remove cartridge
+ */
+ if((isset($_POST['RemoveCartridge']))&&(isset($_POST['Cartridges'])) && $this->acl_is_writeable("ManageCartridges")){
+
+ foreach($_POST['Cartridges'] as $cartID){
+
+ if(isset($this->usedCartridges[$cartID])){
+ if($this->usedCartridges[$cartID]['status'] == "exists"){
+ $this->usedCartridges[$cartID]['status'] = "deleted";
+ }else{
+ unset($this->usedCartridges[$cartID]);
+ }
+ }
+ }
+ }
+
+ /* Open Attachment pool to add/edit Attachments
+ */
+ if(isset($_POST['AddCartridge']) && $this->acl_is_writeable("ManageCartridges")){
+ $this->cur_dialog = new glpiPrinterCartridges($this->config,$this->dn,$this->type);
+ $this->dialog = true;
+ }
+
+
+ /* ##########################################################################
+ * Draw Dialogs
+ */
+ /* if( cur_dialog != false || cur_dialog != NULL)
+ * There is a dialog which wants to be displayed
+ */
+ if($this->cur_dialog && is_object($this->cur_dialog)){
+ $this->cur_dialog->save_object();
+ $this->dialog=true;
+ $this->cur_dialog->parent = &$this;
+ return($this->cur_dialog->execute());
+ }else{
+ $this->dialog= false;
+ }
+
+
+ /* ##########################################################################
+ * Assign listbox / checkbox .... values to smarty
+ */
+ /* Assign smarty defaults */
+ foreach(array("PrinterTypes","PrinterTypeKeys","Manufacturers","TechnicalResponsibles","Attachments","Cartridges") as $attr){
+ $smarty->assign($attr,array());
+ }
+
+ /* Assign some vars to smarty
+ */
+ foreach(array("type","FK_glpi_enterprise","tech_num","contact_num","flags_serial","flags_par","flags_usb") as $attr){
+ $smarty->assign($attr,"");
+ }
+
+ $smarty->assign("comments", $this->comments);
+ $smarty->assign("flags_serial", $this->flags_serial);
+ $smarty->assign("flags_par", $this->flags_par);
+ $smarty->assign("flags_usb", $this->flags_usb);
+
+ /* Assign system types
+ */
+ $smarty->assign("PrinterTypes", $this->handle->getPrinterTypes());
+ $smarty->assign("PrinterTypeKeys", array_flip($this->handle->getPrinterTypes()));
+ $smarty->assign("type", $this->type);
+
+ /* Append manufacturers
+ */
+ $smarty->assign("ManufacturerKeys", array_flip($this->handle->getEnterprises()));
+ $smarty->assign("Manufacturers", $this->handle->getEnterprises());
+ $smarty->assign("FK_glpi_enterprise", $this->FK_glpi_enterprise);
+
+ /* Assign used Attachments
+ */
+
+ $divlist = new divSelectBox("glpiAttachmentsList");
+ $divlist-> SetHeight(120);
+ $atts = $this->getUsedAttachments(true);
+ $downlink = "
%s ";
+ $del_link = "
";
+ foreach($atts as $id => $attachment){
+ $divlist->AddEntry
+ (
+ array(
+ array("string"=>$attachment['name']),
+ array("string"=>$attachment['mime']),
+ array("string"=>sprintf($downlink,$id,$attachment['filename'])),
+ array("string"=>sprintf($del_link,$attachment['ID']),"attach"=>"style='border-right:0px;'"),
+ )
+ );
+ }
+
+ $smarty->assign("AttachmentsDiv" ,$divlist->DrawList());
+ $smarty->assign("Attachments", $this->getUsedAttachments());
+ $smarty->assign("AttachmentKeys", array_flip($this->getUsedAttachments()));
+
+ /* Assign Cartridges
+ */
+ $smarty->assign("Cartridges", $this->getUsedCartridges());
+ $smarty->assign("CartridgeKeys", $this->getUsedCartridges(true));
+
+ /* ##########################################################################
+ * Assign contact and technical responsible person
+ */
+ if(isset($users[$this->contact_num])){
+ $ldap->cat($users[$this->contact_num], array('givenName', 'sn', 'uid'));
+ $tr = $ldap->fetch();
+ $str = "";
+ if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; }
+ if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; }
+ if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; }
+ $smarty->assign("contact_num", $str);
+ }else{
+ $smarty->assign("contact_num", _("N/A"));
+ }
+
+ /* Handle tech person
+ Assign name ... to smarty, if set
+ */
+ if(isset($users[$this->tech_num])){
+ $ldap->cat($users[$this->tech_num], array('givenName', 'sn', 'uid'));
+ $tr = $ldap->fetch();
+ $str = "";
+ if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; }
+ if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; }
+ if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; }
+ $smarty->assign("tech_num", $str);
+ }else{
+ $smarty->assign("tech_num", _("N/A"));
+ }
+
+ /* If theres a cartridge selected, you can't change the printer type.
+ */
+ $disp = true;
+
+ foreach($this->usedCartridges as $cart){
+ if($cart['status'] != "deleted"){
+ $disp = false;
+ }
+ }
+ if($disp==false){
+ $smarty->assign("typeACL", $this->getacl("type",true));
+ }
+
+ $display.= $smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE));
+ return($display);
+ }
+
+ function remove_from_parent()
+ {
+ $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
+ if($this->initially_was_account){
+ $this->handle->removePrinterInformations($this->dn);
+ new log("remove","printer/".get_class($this),$this->dn);
+ }
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ if(isset($_POST['glpiPrinterFlagsPosted'])){
+ plugin::save_object();
+ foreach($this->attributes as $attrs){
+ if(isset($_POST[$attrs])){
+ $this->$attrs = $_POST[$attrs];
+ }
+ }
+
+ if(isset($_POST['FK_glpi_enterprise']) && $this->acl_is_writeable("FKglpienterprise")){
+ $this->FK_glpi_enterprise = $_POST['FK_glpi_enterprise'];
+ }
+
+ foreach(array("flags_serial","flags_par","flags_usb") as $checkboxes){
+ if($this->acl_is_writeable($checkboxes)){
+ if(isset($_POST[$checkboxes])){
+ $this->$checkboxes = 1;
+ }else{
+ $this->$checkboxes = 0;
+ }
+ }
+ }
+ }
+
+ }
+
+
+ /* Check supplied data */
+ function check()
+ {
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+
+ // if($this->TechnicalResponsible == ""){
+ // $message[] = _("Please select a technical responsible person for this entry.");
+ // }
+
+ return ($message);
+ }
+
+ /* Save to LDAP */
+ function save()
+ {
+ if($this->is_account){
+ $attrs = array();
+ $this->date_mod = date("Y-m-d H:i:s");
+ foreach($this->attributes as $attr){
+ $attrs[$attr] = $this->$attr;
+ }
+ $attrs['name'] = $this->dn;
+ unset($attrs['ID']);
+ $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
+ if($this->initially_was_account&&$this->is_account){
+ $this->handle->updatePrinterInformations($attrs,$this->dn);
+ new log("modify","printer/".get_class($this),$this->dn);
+ }elseif($this->is_account){
+ $this->handle->addPrinterInformations($attrs,$this->dn);
+ new log("create","printer/".get_class($this),$this->dn);
+ }
+ $tmp = $this->handle->getPrinterInformations($this->dn);
+ $this->handle->addAttachmentsToPrinter($this->usedAttachments,$tmp[0]['ID']);
+
+ foreach($this->usedCartridges as $cart){
+ if($cart['status'] == "deleted"){
+ $this->handle->removeCartridgeFromPrinter($cart['ID']);
+ }elseif($cart['status'] == "new"){
+ $this->handle->addCartridgeFromPrinter($tmp[0]['ID'],$cart['type_ID']);
+ }
+ }
+ }
+ }
+
+ /* Return used attachments */
+ function getUsedAttachments($divlist = false)
+ {
+ $atts =$this->handle->getAttachments();
+ $ret = array();
+ foreach($atts as $entry){
+ if(in_array($entry['ID'],$this->usedAttachments)){
+ if($divlist){
+ $ret[$entry['ID']] = $entry;
+ }else{
+ $cm ="";
+ if(isset($entry['comment'])){
+ $cm=" [".$entry['comment']."]";
+ }
+ if(isset($entry['mime'])){
+ $cm.=" -".$entry['mime']."";
+ }
+
+ $ret[$entry['ID']]= $entry['name'].$cm;
+ }
+ }
+ }
+ return($ret);
+ }
+
+ function getUsedCartridges($flip = false)
+ {
+ $ret = array();
+ foreach($this->usedCartridges as $key => $value){
+ if($value['status'] == "deleted") continue;
+ if($flip){
+ $ret[$key] = $key;
+ }else{
+ $ret[$key] = $value['name']." [".$value['type_name']."] "._("since")." :".$value['date_use'];
+ }
+ }
+ return($ret);
+ }
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Glpi"),
+ "plDescription" => _("Printer inventory extension"),
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 10,
+ "plSection" => array("administration"),
+ "plCategory" => array("printer"),
+
+ "plProvidedAcls"=> array(
+ "flags_serial" => _("Supports serial interface"),
+ "flags_par" => _("Supports parallel interface"),
+ "flags_usb" => _("Supports usb interface"),
+ "tech_num" => _("Technical responsible"),
+ "comments" => _("Comments"),
+ "location" => _("Location"),
+ "contact_num" => _("Contact person"),
+ "type" => _("Type"),
+ "FKglpienterprise" => _("Manufacturer"),
+
+ "Attachments" => _("Attachments"),
+
+ "ManageCartridges" => _("Cartridge settings"))
+ ));
+ }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/glpi/class_glpiPrinterCartridges.inc b/plugins/admin/systems/services/glpi/class_glpiPrinterCartridges.inc
new file mode 100644
index 000000000..3d9d63010
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/class_glpiPrinterCartridges.inc
@@ -0,0 +1,298 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account = TRUE;
+ var $attributes = array();
+ var $objectclasses = array("whatever");
+
+ var $parent = NULL; // Contains parent class, to access glpi db handle
+ var $usedCartridges = array(); // IDs of used cartridges for this printer
+ var $PrinterType = 0; // Specifies which cartridge types are available
+
+ var $cur_dialog = false;
+ var $cur_sub_dialog = false;
+
+ var $editManufacturer = false;
+ var $del = 0;
+
+
+ function glpiPrinterCartridges (&$config,$dn,$type)
+ {
+ plugin::plugin ($config, $dn);
+
+ /* Assign some basic settings */
+ $this->ui = get_userinfo();
+ if(!isset($_SESSION['glpiCartridgeRegex'])){
+ $_SESSION['glpiCartridgeRegex'] = "*";
+ }
+
+ /* Only display cartridges for this type of printer */
+ $this->PrinterType = $type;
+ }
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+ $display ="";
+ $smarty = get_smarty();
+ $filter = $_SESSION['glpiCartridgeRegex'];
+
+ /* Filter settings, remove double* */
+ if(isset($_GET['search'])){
+ $filter = preg_replace("/\*\**/","*",$_GET['search']."*");
+ }elseif(isset($_POST['cartridge_regex'])){
+ $filter = preg_replace("/\*\**/","*",$_POST['cartridge_regex']);
+ }
+ if(empty($filter)) {
+ $filter = "*";
+ }
+ $_SESSION['glpiCartridgeRegex']= $filter;
+
+ /* Open dialog which allows to edit the manufacturers
+ */
+ if(isset($_POST['edit_manufacturer_cartridges'])){
+ $this->cur_sub_dialog = new glpiManufacturer($this->config,$this->dn);
+ $this->dialog = true;
+ $this->editManufacturer =true;
+ }
+
+ /* Close manufacturer editing dialog
+ */
+ if((isset($_POST['close_edit_manufacturer']))&&($this->editManufacturer)){
+ $this->dialog = false;
+ $this->cur_sub_dialog = false;
+ $this->editManufacturer=false;
+ }
+
+ /* Check poted vars and do the requested job, but only once */
+ $only_once = true;
+ foreach($_POST as $name => $value){
+
+ /* We have to create a new cartridge */
+ if(preg_match("/^newcartridge/",$name)&&($only_once)){
+ $this->cur_dialog = new glpiPrinterCartridgesEdit($this->config,$this->dn,$this->PrinterType);
+ $only_once = false;
+ }
+ }
+
+ /* Edit cartridge */
+ if(isset($_GET['act'])&&$_GET['act']=="edit_cartridge"){
+ $val = ($this->parent->handle->getCartridgeTypeInformations($_GET['id']));
+ $this->cur_dialog = new glpiPrinterCartridgesEdit($this->config,$this->dn,$this->PrinterType,$val[$_GET['id']]);
+ }
+
+ /* remove cartridge */
+ if(isset($_GET['act'])&&$_GET['act']=="del_cartridge"){
+ /* remove attach from db */
+ $this->del = $_GET['id'];
+ $val = ($this->parent->handle->getCartridgeTypeInformations($_GET['id']));
+ $smarty->assign("warning", sprintf(_("You're about to delete the glpi cartridge type '%s'."), $val[$this->del]['name']));
+ return($smarty->fetch(get_template_path('remove_glpi.tpl', TRUE)));
+ }
+
+ if(isset($_POST['delete_cancel'])){
+ $this->del = false;
+ }
+
+ /* Delete this entry */
+ if(isset($_POST['delete_glpi_confirm'])&&($this->del)) {
+ $tmp = $this->parent->handle->is_cartridgeTypeUsed($this->del);
+ if(count($tmp)){
+
+ $str = "";
+ foreach($tmp as $id => $name){
+ $str .= $name.", ";
+ }
+ $str = preg_replace("/, $/","",$str);
+
+ print_red(sprintf(_("You can't delete this cartridge type, it is still in use by this printer(s) '%s'."),$str));
+ }else{
+ $val = ($this->parent->handle->getCartridgeTypeInformations($this->del));
+ $this->cur_dialog = new glpiPrinterCartridgesEdit($this->config,$this->dn,$this->PrinterType,$val[$this->del]);
+ $this->cur_dialog->parent = $this->parent;
+ $this->cur_dialog->remove_from_parent();
+ $this->cur_dialog= false;
+ }
+ }
+
+ /* Abort edit / add dialog */
+ if(isset($_POST['CancelCartridge'])){
+ $this->cur_dialog = false;
+ }
+
+ /* Save changes if check is ok */
+ if(isset($_POST['SaveCartridge'])){
+ $this->cur_dialog->save_object();
+ if(count($this->cur_dialog->check())) {
+ foreach($this->cur_dialog->check() as $checks){
+ print_red($checks);
+ }
+ }else{
+ $this->cur_dialog->save();
+ $this->cur_dialog = false;
+ }
+ }
+
+ /* If we have a dialog open, display it */
+ if($this->cur_sub_dialog){
+ $this->cur_sub_dialog->parent = $this->parent;
+ $this->cur_sub_dialog->save_object();
+ return($this->cur_sub_dialog->execute());
+ }
+ /* If we have a dialog open, display it */
+ if($this->cur_dialog){
+ $this->cur_dialog->parent = $this->parent;
+ $this->cur_dialog->save_object();
+ return($this->cur_dialog->execute());
+ }
+
+ /* Create divlist */
+ $divlist = new divlist("glpi devices");
+ $divlist->SetPluginMode();
+ $divlist->SetEntriesPerPage(0);
+ $divlist->SetHeader(array(
+ array("string" => " ", "attach" => "style='text-align:center;width:20px;'"),
+ array("string" => _("Cartridges"), "attach" => "style=''"),
+ array("string" => _("Action"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" )));
+
+ /* Links for editing,adding.... */
+ $edit = "
%s ";
+ $editdel = "
";
+ $editdel.= "
";
+
+ /* Checkbox for selection of some cartridges */
+ $useCartridge = "
";
+
+ /* Add cartridges */
+ $cart = $this->getCartridgeTypes();
+
+ /* Remove typically error possibilities */
+ $f = str_replace("/","\/",$filter);
+ $f = str_replace(".","\.",$f);
+ $f = str_replace("*",".*",$f);
+
+ /* Assign cartridges */
+ foreach($cart as $key=>$cartr){
+
+ /* Skip if filter doesn't match*/
+ if(!preg_match("/^".$f."$/i",$cartr['cartridgeName'])){
+ continue;
+ }
+
+ /* check if this cartridge is selected */
+ $chk = "";
+ if(isset($this->usedCartridges[$key])){
+ $chk = " checked ";
+ }
+
+ /* Add fields */
+ $field1 = array("string" => preg_replace("/%s/",($key),preg_replace("/%CHECKED%/",$chk,$useCartridge)),
+ "attach" => "style='text-align:center;width:20px;'");
+ $field2 = array("string" => sprintf($edit,($key),$cartr['cartridgeName']." [".$cartr['cartridgeTypeName']."]"),
+ "attach" => "style=''");
+ $field3 = array("string" => sprintf($editdel,($key),($key)),
+ "attach" => "style='width:60px;border-right:0px;text-align:right;'");
+
+ $divlist->AddEntry(array($field1,$field2,$field3));
+
+ }
+
+ /* Create list header */
+ $listhead = "
".
+ " ".
+ "
";
+
+ /* Tell smarty some vars */
+ $filter= $_SESSION['glpiCartridgeRegex'];
+ $smarty->assign("devicehead", $listhead);
+ $smarty->assign("devices", $divlist->DrawList());
+ $smarty->assign("search_image", get_template_path('images/search.png'));
+ $smarty->assign("searchu_image", get_template_path('images/search_user.png'));
+ $smarty->assign("tree_image", get_template_path('images/tree.png'));
+ $smarty->assign("infoimage", get_template_path('images/info_small.png'));
+ $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
+ $smarty->assign("apply", apply_filter());
+ $smarty->assign("alphabet", generate_alphabet());
+ $smarty->assign("cartridge_regex", $filter);
+
+ $display.= $smarty->fetch(get_template_path('glpiPrinterCartridges.tpl', TRUE));
+ return($display);
+ }
+
+ /* Save device to glpi database
+ * If this is a new device, create a new entry, else update this entry
+ */
+ function save()
+ {
+ $carts = $this->getCartridgeTypes();
+ $ret = array();
+ foreach($this->usedCartridges as $key){
+ $tmp =array();
+ $tmp['date_use'] = date("Y-m-d");
+ $tmp['ID'] = -1;
+ $tmp['type_ID'] = $carts[$key]['cartridgeID'];
+ $tmp['name'] = $carts[$key]['cartridgeName'];
+ $tmp['FK_glpi_printers']= -1;
+ $tmp['type_name'] = $carts[$key]['cartridgeTypeName'];
+ $ret[$key] = $tmp;
+ }
+ return($ret);
+ }
+
+ /* this only gets all already defined devices */
+ function reload()
+ {
+ $this->devices = $this->parent->handle->getDevices();
+ ksort($this->devices);
+ }
+
+ /* This funtions saves all POST variables.
+ The variable must be in the array $this->EditEntry
+ */
+ function save_object()
+ {
+ /* Checkbox handling
+ * Check which checkbox is selected
+ */
+ foreach($_POST as $name => $value){
+ if(preg_match("/wasOnPage/",$name)){
+ $id = preg_replace("/wasOnPage_/","",$name);
+ if(isset($_POST['useCartridge_'.$id])){
+ $this->usedCartridges[$id]=$id;
+ }else{
+ unset($this->usedCartridges[$id]);
+ }
+ }
+ }
+ }
+
+ /* This function cehck all created devices if you wan't to create device specific check
+ use >>if($attr['device_type']=="moboard")<< to create a device type depending check
+ */
+ function check()
+ {
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+
+ return($message);
+ }
+
+ /* Return cartriges for our divlist */
+ function getCartridgeTypes()
+ {
+ $ret = array();
+ $ret = $this->parent->handle->getAvailableCartridgeTypes($this->PrinterType);
+ return($ret);
+ }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/glpi/class_glpiPrinterCartridgesEdit.inc b/plugins/admin/systems/services/glpi/class_glpiPrinterCartridgesEdit.inc
new file mode 100644
index 000000000..e1d86fcb6
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/class_glpiPrinterCartridgesEdit.inc
@@ -0,0 +1,337 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account = TRUE;
+ var $attributes = array("ID","name","ref","location","type","FK_glpi_enterprise","tech_num","deleted","comments","alarm");
+ var $objectclasses = array("whatever");
+
+ var $printer_type = 0;
+
+ var $additional_printer= array();
+ var $needToCatch = true;
+
+ var $parent = NULL;
+
+ var $ID = "";
+ var $name = "";
+ var $ref = "";
+ var $location = "";
+ var $type = "";
+ var $FK_glpi_enterprise = "";
+ var $tech_num = "";
+ var $deleted = "";
+ var $comments = "";
+ var $alarm = "";
+
+ var $cur_dialog = false;
+ var $edit_type =false;
+
+
+ function glpiPrinterCartridgesEdit (&$config, $dn,$printer_type,$values = NULL )
+ {
+ plugin::plugin ($config, $dn);
+ foreach($this->attributes as $val){
+ if(isset($values[$val])){
+ $this->$val = $values[$val];
+ }else{
+ $this->$val = "";
+ }
+ }
+ $this->needToCatch = true;
+ $this->printer_type = $printer_type;
+ }
+
+ function remove_from_parent()
+ {
+ if($this->ID > 0){
+ $this->parent->handle->removeCartridgeDropdownType($this->ID);
+ }
+ }
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ /* Fill templating stuff */
+ $smarty= get_smarty();
+ $display= "";
+
+ /* Get all currently used/supported printer types for this cartridge type
+ */
+ if($this->needToCatch){
+ $this->needToCatch = false;
+ if(!empty($this->type)){
+ $this->additional_printer= $this->parent->handle->getSupportedPrinterTypeIDsForCartridge($this->ID);
+ }
+ }
+
+
+
+
+
+
+ /* Printer type management
+ */
+ if(isset($_POST['edit_type_cartridge'])){
+ $this->dialog = true;
+ $this->edit_type=true;
+ }
+
+ /* This closes the printer type editing dialog
+ */
+ if(isset($_POST['close_edit_type_cartridge'])){
+ $this->edit_type=false;
+ $this->dialog = false;
+ }
+
+ /* This appends a new printer to our sytem types
+ */
+ if((isset($_POST['add_cartridge_type']))&&(!empty($_POST['cartridge_type_string']))){
+ print "Add";
+ $this->parent->handle->addCartridgeDropdownType($_POST['cartridge_type_string']);
+ }
+
+ /* Remove selected type from our printer types list
+ */
+ if((isset($_POST['del_cartridge_type']))&&(!empty($_POST['select_type_cartridge']))){
+ $used = $this->parent->handle->getUsedDropdownTypes($_POST['select_type_cartridge']);
+ if(!count($used)){
+ $this->parent->handle->removeCartridgeDropdownType($_POST['select_type_cartridge']);
+ }else{
+ print_red(_("Can't delete this entry, it is still in use."));
+ }
+ }
+
+ /* Rename selected printer type to given string
+ */
+ /* Update*/
+ if((isset($_POST['rename_cartridge_type']))&&(!empty($_POST['select_type_cartridge']))&&(!empty($_POST['cartridge_type_string']))){
+ $this->parent->handle->updateCartridgeDropdownType($_POST['cartridge_type_string'],$_POST['select_type_cartridge']);
+ }
+
+ /* Someone wants to edit the printer types ...
+ So, lets open a new dialog which provides some buttons to edit the types
+ */
+ if($this->edit_type){
+ $smarty->assign("PrinterTypes", $this->parent->handle->getCartridgeTypes());
+ $smarty->assign("PrinterTypeKeys", array_flip($this->parent->handle->getCartridgeTypes()));
+ $display= $smarty->fetch(get_template_path('glpi_edit_cartridge_type.tpl', TRUE));
+ return($display);
+ }
+
+ /* Assign attributes */
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,$this->$attr);
+ }
+
+ /* Selecte technical responsible person
+ */
+ if(isset($_POST['SelectCartridgeTechPerson'])){
+ $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_cartridge_tech_num");
+ }
+
+ /* Abort user selection
+ */
+ $smarty->assign("AbortSelectUser","SelectCartridgeUserCancel");
+ $smarty->assign("SaveSelectUser" ,"user_cartridge_tech_num");
+ if(isset($_POST['SelectCartridgeUserCancel'])){
+ $this->dialog = false;
+ $this->addUser ="";
+ $this->cur_dialog = false;
+ }
+
+ /* Start ldap, and get all glpiUsers */
+ $ldap = $this->config->get_ldap_link();
+ $users = ($this->parent->handle->getUsers());
+
+ /* Technical responsible/contact person selected
+ */
+ if(isset($_GET['act'])&&($_GET['act']=="user_cartridge_tech_num")){
+
+ /* Get posted id */
+ $id = base64_decode($_GET['id']);
+
+ /* Check if user is already created in glpi database */
+ if(!in_array($id,$users)){
+
+ /* If this user doesn't exists in glpi db, we must create him */
+ $ldap->cat($id, array('cn', 'mail', 'telephoneNumber'));
+ $atr = $ldap->fetch();
+ $tmp = array();
+ $use = array( "cn" =>"name",
+ "mail" =>"email",
+ "telephoneNumber" =>"phone");
+
+ /* Create array */
+ foreach($use as $gosa => $glpi){
+ if(isset($atr[$gosa])){
+ $tmp[$glpi]= $atr[$gosa][0];
+ }
+ }
+
+ /* Add this user */
+ $this->parent->handle->addUser($tmp,$id);
+ }
+
+ /* Re-read users */
+ $users = ($this->parent->handle->getUsers());
+
+ /* Get user */
+ $tmp = array_flip($users);
+ $id=$tmp[$id];
+
+ /* Close dialog and use this user */
+ $this->tech_num = $id;
+ $this->cur_dialog = false;
+ $this->dialog= false;
+ }
+
+ /* Execute dialog*/
+ if($this->cur_dialog){
+ $this->cur_dialog->save_object();
+ $this->dialog=true;
+ $this->cur_dialog->parent = &$this;
+ return($this->cur_dialog->execute());
+ }else{
+ $this->dialog= false;
+ }
+
+ /* Create matrix with all possible printer types
+ */
+ $matrix = "
";
+
+ /* Append manufacturers
+ */
+ $smarty->assign("PrinterTypeMatrix", $matrix);
+
+ $smarty->assign("ManufacturerKeys", array_flip($this->parent->handle->getEnterprises()));
+ $smarty->assign("Manufacturers", $this->parent->handle->getEnterprises());
+ $smarty->assign("FK_glpi_enterprise", $this->FK_glpi_enterprise);
+
+ $smarty->assign("typeKeys", array_flip($this->parent->handle->getCartridgeTypes()));
+ $smarty->assign("types", $this->parent->handle->getCartridgeTypes());
+ $smarty->assign("type", $this->type);
+
+ /* Handle tech person
+ Assign name ... to smarty, if set
+ */
+ if(isset($users[$this->tech_num])){
+ $ldap->cat($users[$this->tech_num], array('givenName', 'sn', 'uid'));
+ $tr = $ldap->fetch();
+ $str = "";
+ if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; }
+ if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; }
+ if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; }
+ $smarty->assign("tech_num", $str);
+ }else{
+ $smarty->assign("tech_num", _("N/A"));
+ }
+
+
+ $display.= $smarty->fetch(get_template_path('glpiPrinterCartridgesEdit.tpl', TRUE,dirname(__FILE__)));
+ return($display);
+ }
+
+ /* Check given values */
+ function check(){
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+
+ /* Avoid choosing an already used name */
+ $types = $this->parent->handle->getCartridgeTypeInformations();
+ foreach($types as $type){
+ if($type['name'] == $this->name){
+ if($type['ID'] != $this->ID){
+ $message[]= _("The selected name is already in use.");
+ }
+ }
+ }
+ return $message;
+ }
+
+ /* Save Post data */
+ function save_object()
+ {
+ foreach($this->attributes as $attr){
+ if(isset($_POST[$attr])){
+ $this->$attr= $_POST[$attr];
+ }
+ }
+
+ /* Get selected checkboxes */
+ foreach($_POST as $name => $value){
+ if(preg_match("/wasOnPage_/",$name)){
+ $id = preg_replace("/wasOnPage_/","",$name);
+ if(isset($_POST['UsePrinterType_'.$id])){
+ $this->additional_printer[$id]=$id;
+ }else{
+ if(isset($this->additional_printer[$id])){
+ unset($this->additional_printer[$id]);
+ }
+ }
+ }
+ }
+ }
+
+ /* Create / Update database with this new infos */
+ function save()
+ {
+ $tmp = array();
+ foreach($this->attributes as $attr){
+ $tmp[$attr] = $this-> $attr;
+ }
+ $types = array();
+ $types = $this->additional_printer;
+ $types[$this->printer_type]=$this->printer_type;
+ $this->parent->handle->Add_UpdateCatrigdeType($tmp,$types);
+ }
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/glpi/class_glpiSelectUser.inc b/plugins/admin/systems/services/glpi/class_glpiSelectUser.inc
new file mode 100644
index 000000000..7073b12a4
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/class_glpiSelectUser.inc
@@ -0,0 +1,285 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account= TRUE;
+ var $attributes= array();
+ var $objectclasses= array("whatever");
+
+ var $users = array();
+ var $departments = array();
+
+ var $ui;
+
+ var $PostVarName = "";
+
+ function glpiSelectUser (&$config, $dn= NULL,$postvar)
+ {
+ plugin::plugin ($config, $dn);
+
+ $this->PostVarName = $postvar;
+
+ if(!isset($_SESSION['glpi_user_filter'])){
+ $tmp['users_regex'] = "*";
+ $tmp['base'] = $this->config->current['BASE'];
+ $_SESSION['glpi_user_filter'] = $tmp;
+ }
+
+ $this->ui = get_userinfo();
+ }
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ if(isset($_POST['depselect'])){
+ $_SESSION['glpi_user_filter']['base'] = $_POST['depselect'];
+ }
+
+ $filter = $_SESSION['glpi_user_filter'];
+
+ /* Filter settings, remove double* */
+ if(isset($_GET['search'])){
+ $filter['users_regex'] = preg_replace("/\*\**/","*",$_GET['search']."*");
+ }elseif(isset($_POST['regex'])){
+ $filter['users_regex'] = preg_replace("/\*\**/","*",$_POST['regex']);
+ }
+ if(empty($filter['users_regex'])) {
+ $filter = "*";
+ }
+
+
+ $s_action="";
+ /* Test Posts */
+ foreach($_POST as $key => $val){
+ // Post for delete
+ if(preg_match("/dep_back.*/i",$key)){
+ $s_action="back";
+ }elseif(preg_match("/user_new.*/",$key)){
+ $s_action="new";
+ }elseif(preg_match("/dep_home.*/i",$key)){
+ $s_action="home";
+ }
+ }
+
+ /* Homebutton is posted */
+ if($s_action=="home"){
+ $filter['base']=(preg_replace("/^[^,]+,/","",$this->ui->dn));
+ $filter['base']=(preg_replace("/^[^,]+,/","",$filter['base']));
+ }
+
+ if($s_action=="root"){
+ $filter['base']=($this->config->current['BASE']);
+ }
+
+
+ /* If Backbutton is Posted */
+ if($s_action=="back"){
+ $base_back = preg_replace("/^[^,]+,/","",$filter['base']);
+ $base_back = convert_department_dn($base_back);
+
+ if(isset($this->config->departments[trim($base_back)])){
+ $filter['base']= $this->config->departments[trim($base_back)];
+ }else{
+ $filter['base']= $this->config->departments["/"];
+ }
+ }
+
+ if((isset($_GET['act']))&&($_GET['act']=="dep_open")){
+ $entry = base64_decode($_GET['dep_id']);
+ $filter['base']= ($this->config->departments[$entry]);
+ }
+
+ $_SESSION['glpi_user_filter'] = $filter;
+
+ $this->reload();
+
+ /* Fill templating stuff */
+ $smarty= get_smarty();
+ $display= "";
+
+ $divlist = new divlist("glpi users");
+ $divlist->SetPluginMode();
+ $divlist->SetEntriesPerPage(0);
+ $divlist->SetHeader(array(
+ array("string" => " ", "attach" => "style='text-align:center;width:20px;'"),
+ array("string" => _("Users")." / "._("Departments"), "attach" => "style=''"),
+ array("string" => _("Use"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" )));
+ $linkopen = "
%s ";
+ foreach($this->departments as $key=> $val){
+
+ if(!isset($this->config->departments[trim($key)])){
+ $this->config->departments[trim($key)]="";
+ }
+
+ $non_empty="";
+ $keys= str_replace("/","\/",$key);
+ foreach($this->config->departments as $keyd=>$vald ){
+ if(preg_match("/".$keys."\/.*/",$keyd)){
+ $non_empty="full";
+ }
+ }
+
+ $field1 = array("string" => "
", "attach" => "style='text-align:center;width:20px;'");
+ $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style=''");
+ $field3 = array("string" => " ", "attach" => "style='width:60px;border-right:0px;text-align:right;'");
+ $divlist->AddEntry(array($field1,$field2,$field3));
+ }
+
+ $useruse = "
PostVarName."&id=%s'>%s ";
+
+ foreach($this->users as $key=>$user){
+ $field1 = array("string" => "
", "attach" => "style='text-align:center;width:20px;'");
+ $field2 = array("string" => sprintf($useruse,base64_encode($key),$user), "attach" => "style=''");
+ $field3 = array("string" => sprintf($useruse,base64_encode($key),"
"),
+ "attach" => "style='width:60px;border-right:0px;text-align:right;'");
+ $divlist->AddEntry(array($field1,$field2,$field3));
+
+ }
+
+ /* Prepare departments,
+ which are shown in the listbox on top of the listbox
+ */
+
+
+ /* Get all departments within this subtree */
+ $this->base = $_SESSION['glpi_user_filter']['base'];
+ $options ="";
+ $base = $this->config->current['BASE'];
+ $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", "users", $base,
+ array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH);
+
+ /* Load possible departments */
+ $ui= get_userinfo();
+ $tdeps= $ui->get_module_departments("users");
+ $ids = $this->config->idepartments;
+ foreach($deps as $dep){
+ if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){
+ $value = $ids[$dep['dn']];
+ if ($this->base == $dep['dn']){
+ $options.= "
$value ";
+ } else {
+ $options.= "
$value ";
+ }
+ }
+ }
+
+ $listhead = "
";
+
+
+ $filter= $_SESSION['glpi_user_filter'];
+ $smarty->assign("usershead", $listhead);
+ $smarty->assign("users", $divlist->DrawList());
+ $smarty->assign("search_image", get_template_path('images/search.png'));
+ $smarty->assign("searchu_image", get_template_path('images/search_user.png'));
+ $smarty->assign("tree_image", get_template_path('images/tree.png'));
+ $smarty->assign("infoimage", get_template_path('images/info_small.png'));
+ $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
+ $smarty->assign("apply", apply_filter());
+ $smarty->assign("alphabet", generate_alphabet());
+ $smarty->assign("users_regex", $filter['users_regex']);
+
+
+ $display.= $smarty->fetch(get_template_path('glpiSelectUser.tpl', TRUE));
+ return($display);
+ }
+
+ /* Save to LDAP */
+ function save()
+ {
+ plugin::save();
+
+ /* Optionally execute a command after we're done */
+#$this->handle_post_events($mode);
+ }
+
+ function reload()
+ {
+
+ $filter= $_SESSION['glpi_user_filter'];
+
+ $base = $filter['base'];
+ $regex= $filter['users_regex'];
+ /* NEW LIST MANAGMENT
+ * We also need to search for the departments
+ * So we are able to navigate like in konquerer
+ */
+
+ $res3= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))","users",
+ $base, array("ou", "description"), GL_SIZELIMIT | GL_CONVERT);
+
+ $this->departments= array();
+ $tmp = array();
+ foreach ($res3 as $value){
+ $tmp[strtolower($value['dn']).$value['dn']]=$value;
+ }
+ ksort($tmp);
+ foreach($tmp as $value){
+ if(isset($value["description"][0])){
+ $this->departments[$value['dn']]= get_sub_department($value['dn'])." - [".$value["description"][0]."]";
+ }else{
+ $this->departments[$value['dn']]= get_sub_department($value['dn']);//$value["description"][0];
+ }
+ }
+
+ /* END NEW LIST MANAGMENT
+ */
+ $ou = get_people_ou();
+
+ $res2= get_list("(&(|(cn=$regex)(sn=$regex))(objectClass=person))", "users",
+ $ou.$base, array("cn", "sn", "uid", "givenName", "description"),
+ GL_SUBSEARCH | GL_SIZELIMIT);
+
+ $tmp = array();
+
+ foreach($res2 as $val){
+ $str = "";
+ if(isset($val['givenName'][0])){
+ $str .= $val['givenName'][0];
+ }
+ if(isset($val['sn'][0])){
+ $str .= $val['sn'][0];
+ }
+ if(isset($val['uid'][0])){
+ $str .= $val['uid'][0];
+ }
+
+ $tmp[$str] = $val;
+ }
+
+ ksort($tmp);
+ $this->users = array();
+ foreach($tmp as $value){
+ if (isset($value["givenName"][0]) && isset($value["sn"][0])){
+ $this->users[$value['dn']]= $value["sn"][0].", ".
+ $value["givenName"][0].
+ " [".$value["uid"][0]."]";
+ } else {
+ $this->users[$value["dn"]]= "[".$value["uid"][0]."]";
+ }
+ }
+ }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/glpi/class_goGlpiServer.inc b/plugins/admin/systems/services/glpi/class_goGlpiServer.inc
new file mode 100644
index 000000000..07c07d427
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/class_goGlpiServer.inc
@@ -0,0 +1,109 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* This plugin only writes its objectClass */
+ var $objectclasses = array("goGlpiServer");
+ var $attributes = array("goGlpiAdmin","goGlpiDatabase","goGlpiPassword");
+ var $StatusFlag = "goGlpiServerStatus";
+
+ /* This class can't be assigned twice so it conflicts with itsself */
+ var $conflicts = array("goGlpiServer");
+
+ var $DisplayName = "";
+ var $dn = NULL;
+ var $cn = "";
+ var $acl;
+
+ var $goGlpiServerStatus ="";
+ var $goGlpiAdmin ="";
+ var $goGlpiDatabase ="";
+ var $goGlpiPassword ="";
+ var $view_logged =FALSE;
+
+
+ function goGlpiServer(&$config,$dn)
+ {
+ goService::goService($config,$dn);
+ $this->DisplayName = _("Inventory database");
+ }
+
+
+ function execute()
+ {
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","server/".get_class($this),$this->dn);
+ }
+
+ $smarty = get_smarty();
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,$this->$attr);
+ }
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translation ){
+ $smarty->assign($name."ACL",$this->getacl($name));
+ }
+ return($smarty->fetch(get_template_path("goGlpiServer.tpl",TRUE,dirname(__FILE__))));
+ }
+
+
+ function getListEntry()
+ {
+ $fields = goService::getListEntry();
+ $fields['Message'] = _("Inventory database service");
+ $fields['AllowEdit'] = true;
+ return($fields);
+ }
+
+ function check()
+ {
+ $message = plugin::check();
+ if(empty($this->goGlpiAdmin)){
+ $message[]= _("The attribute user is empty or contains invalid characters.");
+ }
+ if(empty($this->goGlpiDatabase)){
+ $message[]= _("The attribute database is empty or contains invalid characters.");
+ }
+ return($message);
+ }
+
+
+ function save_object()
+ {
+ if(isset($_POST['goGlpiServer_posted'])){
+ plugin::save_object();
+ }
+ }
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Inventory database"),
+ "plDescription" => _("Inventory database")." ("._("Services").")" ,
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 93,
+ "plSection" => array("administration"),
+ "plCategory" => array("server"),
+
+ "plProvidedAcls"=> array(
+ "start" => _("Start"),
+ "stop" => _("Stop"),
+ "restart" => _("Restart"),
+
+ "goGlpiAdmin" => _("Admin"),
+ "goGlpiDatabase" => _("Database"),
+ "goGlpiPassword" => _("Password"))
+ ));
+ }
+
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/glpi/glpi.tpl b/plugins/admin/systems/services/glpi/glpi.tpl
new file mode 100644
index 000000000..0d2f8db36
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/glpi.tpl
@@ -0,0 +1,138 @@
+
+
+
+
+
+ {t}Generic{/t}
+
+
+
+
+ {t}Comment{/t}
+
+
+
+{render acl=$commentsACL}
+
+{/render}
+
+
+
+
+
+
+
+
+
+
+ {t}Installed devices{/t}
+
+
+
+
+ {t}Attachments{/t}
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/glpi/glpiAttachmentEdit.tpl b/plugins/admin/systems/services/glpi/glpiAttachmentEdit.tpl
new file mode 100644
index 000000000..7d91e50af
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/glpiAttachmentEdit.tpl
@@ -0,0 +1,78 @@
+
+
{t}Attachment{/t}
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/glpi/glpiAttachmentPool.tpl b/plugins/admin/systems/services/glpi/glpiAttachmentPool.tpl
new file mode 100644
index 000000000..e3a73be8d
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/glpiAttachmentPool.tpl
@@ -0,0 +1,54 @@
+
+
+
+
+
+ {t}List of attachments{/t}
+
+
+
+ {$attachmenthead}
+
+
+
+ {$attachments}
+
+
+
+
+
+
{t}Information{/t}
+
+
+ {t}This dialog allow you to attach additional objects (like manuals, guides, etc.) to your currently edited computer.{/t}
+
+
+
+
{t}Filters{/t}
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/glpi/glpiDeviceManagement.tpl b/plugins/admin/systems/services/glpi/glpiDeviceManagement.tpl
new file mode 100644
index 000000000..ab2baa740
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/glpiDeviceManagement.tpl
@@ -0,0 +1,54 @@
+
+
+
+
+
+ {t}List of devices{/t}
+
+
+
+ {$devicehead}
+
+
+
+ {$devices}
+
+
+
+
+
+
{t}Information{/t}
+
+
+ {t}This dialog allows you to attach a device to your currently edited computer.{/t}
+
+
+
+
{t}Filters{/t}
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/glpi/glpiManufacturer.tpl b/plugins/admin/systems/services/glpi/glpiManufacturer.tpl
new file mode 100644
index 000000000..a15a29aa4
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/glpiManufacturer.tpl
@@ -0,0 +1,15 @@
+
{t}Manage manufacturers{/t}
+
+ {html_options values=$ManuKeys output=$Manus}
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/glpi/glpiManufacturerAdd.tpl b/plugins/admin/systems/services/glpi/glpiManufacturerAdd.tpl
new file mode 100644
index 000000000..c5b060d29
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/glpiManufacturerAdd.tpl
@@ -0,0 +1,89 @@
+
{t}Add/Edit manufacturer{/t}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/glpi/glpiPrinter.tpl b/plugins/admin/systems/services/glpi/glpiPrinter.tpl
new file mode 100644
index 000000000..46e344678
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/glpiPrinter.tpl
@@ -0,0 +1,159 @@
+
+
+
+
+
+ {t}Generic{/t}
+
+
+
+ {t}Supported interfaces{/t}
+
+
+
+
+
+
+
+
+
+ {t}Contacts{/t}
+
+
+
+ {t}Attachments{/t}
+
+
+
+
+
+
+
+
+ {t}Information{/t}
+
+
+
+{render acl=$commentsACL}
+
+{/render}
+
+
+
+
+
+ {t}Installed cartridges{/t}
+
+
+
+
diff --git a/plugins/admin/systems/services/glpi/glpiPrinterCartridges.tpl b/plugins/admin/systems/services/glpi/glpiPrinterCartridges.tpl
new file mode 100644
index 000000000..5dcd2de13
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/glpiPrinterCartridges.tpl
@@ -0,0 +1,54 @@
+
+
+
+
+
+ {t}List of available cartridge type for this type of printer{/t}
+
+
+
+ {$devicehead}
+
+
+
+ {$devices}
+
+
+
+
+
+
{t}Information{/t}
+
+
+ {t}This dialog allows you to create new types of cartridges, and select one or more types for your printer. Cartridge types depends on the printer type you have selected. For each selected cartridge type there will be a new cartridge created, this allows you to select the same cartridge type for more then one printer.{/t}
+
+
+
+
{t}Filters{/t}
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/glpi/glpiPrinterCartridgesEdit.tpl b/plugins/admin/systems/services/glpi/glpiPrinterCartridgesEdit.tpl
new file mode 100644
index 000000000..6857efdb3
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/glpiPrinterCartridgesEdit.tpl
@@ -0,0 +1,83 @@
+
+
+
+ {t}Generic{/t}
+
+
+ {t}Comments{/t}
+
+
+ {t}Comment{/t}
+
+
+
+
+
+
+
+
+ {t}Generic{/t}
+
+
+ {$PrinterTypeMatrix}
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/glpi/glpiSelectUser.tpl b/plugins/admin/systems/services/glpi/glpiSelectUser.tpl
new file mode 100644
index 000000000..75bf351bd
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/glpiSelectUser.tpl
@@ -0,0 +1,53 @@
+
+
+
+
+
+ {t}List of users{/t}
+
+
+
+ {$usershead}
+
+
+
+ {$users}
+
+
+
+
+
+
{t}Information{/t}
+
+
+ {t}This dialog allows you to select a user as technical responsible person.{/t}
+
+
+
+
{t}Filters{/t}
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/glpi/glpi_devices.tpl b/plugins/admin/systems/services/glpi/glpi_devices.tpl
new file mode 100644
index 000000000..44de4fa93
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/glpi_devices.tpl
@@ -0,0 +1,763 @@
+{if $device_type=="monitor"}
+
{t}Add/Edit monitor{/t}
+
+
+
+
+
+{elseif $device_type=="pci"}
+
+
{t}Add/Edit other device{/t}
+
+
+
+
+
+
+
+
+
+
+ {t}Manufacturer{/t}
+
+
+
+ {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
+
+
+
+
+
+
+
+
+{elseif $device_type=="power"}
+
+
{t}Add/Edit power supply{/t}
+
+
+
+{elseif $device_type=="gfxcard"}
+
+
{t}Add/Edit graphic card{/t}
+
+
+
+{elseif $device_type=="control"}
+
+
{t}Add/Edit controller{/t}
+
+
+
+
+{elseif $device_type=="drive"}
+
+
{t}Add/Edit drive{/t}
+
+
+
+
+{elseif $device_type=="hdd"}
+
{t}Add/Edit harddisk{/t}
+
+
+
+
+{elseif $device_type=="ram"}
+
+
{t}Add/Edit memory{/t}
+
+
+
+
+{elseif $device_type=="sndcard"}
+
{t}Add/Edit sound card{/t}
+
+
+
+{elseif $device_type=="iface"}
+
{t}Add/Edit network interface{/t}
+
+
+
+
+{elseif $device_type=="processor"}
+
{t}Add/Edit processor{/t}
+
+
+
+
+{elseif $device_type=="moboard"}
+
{t}Add/Edit motherboard{/t}
+
+
+
+{elseif $device_type=="case"}
+
{t}Add/Edit computer case{/t}
+
+
+
+
+
+
+
+
+
+
+ {t}Manufacturer{/t}
+
+
+
+ {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
+
+
+
+
+ {t}format{/t}
+
+
+
+ {html_options values=$formatKeys output=$formats selected=$format}
+
+
+
+
+
+
+
+{/if}
+
+
+
+
diff --git a/plugins/admin/systems/services/glpi/glpi_edit_cartridge_type.tpl b/plugins/admin/systems/services/glpi/glpi_edit_cartridge_type.tpl
new file mode 100644
index 000000000..cbc91d95f
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/glpi_edit_cartridge_type.tpl
@@ -0,0 +1,21 @@
+
+
+ {html_options values=$PrinterTypeKeys output=$PrinterTypes}
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/glpi/glpi_edit_os.tpl b/plugins/admin/systems/services/glpi/glpi_edit_os.tpl
new file mode 100644
index 000000000..8e3726451
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/glpi_edit_os.tpl
@@ -0,0 +1,39 @@
+
{t}Manage OS-types{/t}
+{if $Method == "edit"}
+
+
+ {html_options values=$OSKeys output=$OSs}
+
+
+
+
+
+
+
+
+
+{else}
+{t}Please enter a new name{/t}
+
+
+
+
+
+
+
+
+{/if}
+
+
diff --git a/plugins/admin/systems/services/glpi/glpi_edit_printer_type.tpl b/plugins/admin/systems/services/glpi/glpi_edit_printer_type.tpl
new file mode 100644
index 000000000..a63e9235e
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/glpi_edit_printer_type.tpl
@@ -0,0 +1,40 @@
+
+{if $Method == "edit"}
+
+ {html_options values=$PrinterTypeKeys output=$PrinterTypes}
+
+
+
+
+
+
+
+
+
+
+{else}
+
+ {t}Please enter a new name{/t}
+
+
+
+
+
+
+
+
+
+{/if}
+
diff --git a/plugins/admin/systems/services/glpi/glpi_edit_type.tpl b/plugins/admin/systems/services/glpi/glpi_edit_type.tpl
new file mode 100644
index 000000000..14a4f5431
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/glpi_edit_type.tpl
@@ -0,0 +1,37 @@
+
{t}Manage System-types{/t}
+{if $Method == "edit"}
+
+
+ {html_options values=$SystemTypeKeys output=$SystemTypes}
+
+
+
+
+
+
+
+
+
+{else}
+{t}Please enter a new name{/t}
+
+
+
+
+
+
+
+
+{/if}
diff --git a/plugins/admin/systems/services/glpi/goGlpiServer.tpl b/plugins/admin/systems/services/glpi/goGlpiServer.tpl
new file mode 100644
index 000000000..36a2f2476
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/goGlpiServer.tpl
@@ -0,0 +1,36 @@
+
{t}GLPI database information{/t}
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/glpi/remove_glpi.tpl b/plugins/admin/systems/services/glpi/remove_glpi.tpl
new file mode 100644
index 000000000..4106caf06
--- /dev/null
+++ b/plugins/admin/systems/services/glpi/remove_glpi.tpl
@@ -0,0 +1,17 @@
+
+
{t}Warning{/t}
+
+
+ {$warning}
+ {t}Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t}
+
+
+
+ {t}Best thing to do before performing this action would be to save the current contents of your MySql database in a file. So - if you've done so - press 'Delete' to continue or 'Cancel' to abort.{/t}
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/gofax/class_goFaxServer.inc b/plugins/admin/systems/services/gofax/class_goFaxServer.inc
new file mode 100644
index 000000000..1e5e04976
--- /dev/null
+++ b/plugins/admin/systems/services/gofax/class_goFaxServer.inc
@@ -0,0 +1,103 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* This plugin only writes its objectClass */
+ var $objectclasses = array("goFaxServer");
+ var $attributes = array("goFaxAdmin", "goFaxPassword");
+ var $StatusFlag = "goFaxServerStatus";
+
+ /* This class can't be assigned twice so it conflicts with itsself */
+ var $conflicts = array("goFaxServer");
+
+ var $DisplayName = "";
+ var $dn = NULL;
+ var $acl;
+
+ var $goFaxAdmin = "";
+ var $goFaxPassword = "";
+ var $goFaxServerStatus = "";
+ var $cn = "";
+ var $view_logged =FALSE;
+
+ function goFaxServer(&$config,$dn)
+ {
+ goService::goService($config,$dn);
+ $this->DisplayName = _("FAX database");
+ }
+
+
+ function execute()
+ {
+ $smarty = get_smarty();
+
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","server/".get_class($this),$this->dn);
+ }
+
+ /* Assign acls */
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translation ){
+ $smarty->assign($name."ACL",$this->getacl($name));
+ }
+
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,$this->$attr);
+ }
+ return($smarty->fetch(get_template_path("goFaxServer.tpl",TRUE,dirname(__FILE__))));
+ }
+
+
+ function getListEntry()
+ {
+ $fields = goService::getListEntry();
+ $fields['Message'] = _("FAX database configuration");
+ $fields['AllowEdit'] = true;
+ return($fields);
+ }
+
+ function check()
+ {
+ $message = plugin::check();
+ if (empty($this->goFaxAdmin)){
+ $message[]= _("The attribute user is empty or contains invalid characters.");
+ }
+ if (empty($this->goFaxPassword)){
+ $message[]= _("The attribute password is empty or contains invalid characters.");
+ }
+ return($message);
+ }
+
+
+ function save_object()
+ {
+ if(isset($_POST['goFaxServerPosted'])){
+ plugin::save_object();
+ }
+ }
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Fax database"),
+ "plDescription" => _("Fax database")." ("._("Services").")",
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 99,
+ "plSection" => array("administration"),
+ "plCategory" => array("server"),
+
+ "plProvidedAcls"=> array(
+ "goFaxAdmin" => _("Login name"),
+ "goFaxPassword" => _("Password"))
+ ));
+ }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/gofax/goFaxServer.tpl b/plugins/admin/systems/services/gofax/goFaxServer.tpl
new file mode 100644
index 000000000..27560b3f3
--- /dev/null
+++ b/plugins/admin/systems/services/gofax/goFaxServer.tpl
@@ -0,0 +1,27 @@
+
{t}FAX database information{/t}
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/gofon/class_goFonServer.inc b/plugins/admin/systems/services/gofon/class_goFonServer.inc
new file mode 100644
index 000000000..2e69a849d
--- /dev/null
+++ b/plugins/admin/systems/services/gofon/class_goFonServer.inc
@@ -0,0 +1,182 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* This plugin only writes its objectClass */
+ var $objectclasses = array("goFonServer");
+ var $attributes = array("goFonAdmin", "goFonPassword","goFonAreaCode", "goFonCountryCode");
+ var $StatusFlag = "goFonServerStatus";
+
+ /* This class can't be assigned twice so it conflicts with itsself */
+ var $conflicts = array("goFonServer");
+
+ var $DisplayName = "";
+ var $dn = NULL;
+ var $cn ="";
+ var $acl;
+
+ var $goFonServerStatus = "";
+ var $goFonPassword = "";
+ var $goFonAdmin = "";
+ var $goFonAreaCode = "";
+ var $goFonCountryCode = "";
+ var $view_logged =FALSE;
+
+ var $orig_dn = "";
+
+ function goFonServer(&$config,$dn)
+ {
+ goService::goService($config,$dn);
+ $this->DisplayName = _("VoIP service");
+
+ $this->orig_dn = $dn;
+ }
+
+
+ function execute()
+ {
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","server/".get_class($this),$this->dn);
+ }
+
+ $smarty = get_smarty();
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,$this->$attr);
+ }
+
+ /* Assign acls */
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translation){
+ $smarty->assign($name."ACL",$this->getacl($name));
+ }
+
+ return($smarty->fetch(get_template_path("goFonServer.tpl",TRUE,dirname(__FILE__))));
+ }
+
+
+ function getListEntry()
+ {
+ $fields = goService::getListEntry();
+ $fields['Message'] = _("VoIP service - Asterisk management");
+ $fields['AllowEdit'] = true;
+ return($fields);
+ }
+
+ function check()
+ {
+ $message = plugin::check();
+ if (empty($this->goFonAdmin)){
+ $message[]= _("The attribute DB user is empty or contains invalid characters.");
+ }
+ if (empty($this->goFonPassword)){
+ $message[]= _("The attribute password is empty or contains invalid characters.");
+ }
+ if (empty($this->goFonAreaCode)){
+ $message[]= _("The attribute local dial prefix is empty or contains invalid characters.");
+ }
+ if (empty($this->goFonCountryCode)){
+ $message[]= _("The attribute country dial prefix is empty or contains invalid characters.");
+ }
+ return($message);
+ }
+
+
+ function save_object()
+ {
+ if(isset($_POST['goFonServerPosted'])){
+ plugin::save_object();
+ }
+ }
+
+
+ function allow_remove()
+ {
+ /* Check if we are able to remove the asterisk database. If the database is still in use skip */
+ if($this->is_account){
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(&(goFonHomeServer=".$this->dn.")(|(uid=*)(cn=*)))",array("dn","uid","cn","goFonHomeServer"));
+ if($ldap->count()){
+
+ /* Number of entries shown in warning */
+ $i = 3;
+ $str = "";
+ while(($attrs = $ldap->fetch()) && $i >= 0){
+ $i --;
+ if(isset($attrs['uid'][0])){
+ $str .= $attrs['uid'][0]." ";
+ }else{
+ $str .= $attrs['cn'][0]." ";
+ }
+ }
+
+ /* Some entries found */
+ if($i != 3){
+ return(sprintf(_("You can't remove the asterisk database extension, it is still in use by these objects '%s'."),trim($str)));
+ }
+ }
+ }
+ }
+
+
+ function save()
+ {
+ goService::save();
+ /* Update goFonAccounts if server was is renamed.
+ Set attribute goFonHomeServer to current dn
+ */
+ if(in_array("goFonServer",$this->objectclasses)){
+ if($this->orig_dn != "new" && $this->orig_dn != $this->dn){
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(&(goFonHomeServer=".$this->orig_dn.")(|(objectClass=goFonAccount)(objectClass=goFonConference)))",array("goFonHomeServer"));
+ $dns = array();
+ while($attrs = $ldap->fetch()){
+ $dns[] = $attrs['dn'];
+ }
+ foreach($dns as $dn){
+ $ldap->cd($dn);
+ $ldap->modify(array("goFonHomeServer" => $this->dn));
+ show_ldap_error($ldap->get_error(),sprintf(_("Updating gofon home server failed for '%s'."),$dn));
+ }
+ }
+
+ /* Updated config list of gofon servers */
+ if($this->orig_dn == "new" || $this->orig_dn != $this->dn){
+ $_SESSION['config']->load_servers();
+ }
+ }
+ }
+
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("VoIP service"),
+ "plDescription" => _("VoIP - asterisk management")." ("._("Services").")",
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 92,
+ "plSection" => array("administration"),
+ "plCategory" => array("server"),
+
+ "plProvidedAcls"=> array(
+ "start" => _("Start"),
+ "stop" => _("Stop"),
+ "restart" => _("Restart"),
+
+ "goFonAdmin" => _("Admin"),
+ "goFonPassword" => _("Password"),
+ "goFonAreaCode" => _("Area code"),
+ "goFonCountryCode"=> _("Country code"))
+ ));
+ }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/gofon/goFonServer.tpl b/plugins/admin/systems/services/gofon/goFonServer.tpl
new file mode 100644
index 000000000..14a1603b8
--- /dev/null
+++ b/plugins/admin/systems/services/gofon/goFonServer.tpl
@@ -0,0 +1,43 @@
+
{t}VoIP database information{/t}
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/imap/class_goImapServer.inc b/plugins/admin/systems/services/imap/class_goImapServer.inc
new file mode 100644
index 000000000..e5681b942
--- /dev/null
+++ b/plugins/admin/systems/services/imap/class_goImapServer.inc
@@ -0,0 +1,187 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* This plugin only writes its objectClass */
+ var $objectclasses = array("goImapServer");
+
+ /* This class can't be assigned twice so it conflicts with itsself */
+
+ var $DisplayName = "";
+ var $dn = NULL;
+ var $StatusFlag = "goImapServerStatus";
+ var $attributes = array("goImapName","goImapConnect","goImapAdmin","goImapPassword",
+ "goImapSieveServer","goImapSievePort",
+ "cyrusImap","cyrusImapSSL","cyrusPop3","cyrusPop3SSL");
+
+ var $cn = "";
+
+ var $goImapName = "";
+ var $goImapConnect = "";
+ var $goImapAdmin = "";
+ var $goImapPassword = "";
+
+ var $goImapSieveServer = "";
+ var $goImapSievePort = "";
+
+ var $goImapServerStatus = "";
+
+ var $cyrusImap = false;
+ var $cyrusImapSSL = false;
+ var $cyrusPop3 = false;
+ var $cyrusPop3SSL = false;
+ var $is_account = false;
+ var $view_logged =FALSE;
+
+ var $acl;
+
+ var $Actions = array();
+ var $conflicts = array("goImapServer","kolab");
+
+ function goImapServer(&$config,$dn)
+ {
+ goService::goService($config,$dn);
+
+ $this->DisplayName = _("IMAP/POP3 service");
+
+ $this->Actions = array( SERVICE_STOPPED=>SERVICE_STOPPED,
+ SERVICE_STARTED => SERVICE_STARTED,
+ SERVICE_RESTARTED=>SERVICE_RESTARTED,
+ "repair_database"=>_("Repair database"));
+
+ }
+
+ function execute()
+ {
+ $smarty = get_smarty();
+
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","server/".get_class($this),$this->dn);
+ }
+
+ /* set new status */
+ if(isset($_POST['ExecAction'])){
+ if(isset($this->Actions[$_POST['action']])){
+
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translation) {
+ if(preg_match("/^".$_POST['action']."$/i",$name)){
+ if($this->acl_is_writeable($name)){
+ $this->setStatus($_POST['action']);
+ }
+ }
+ }
+
+ }
+ }
+
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,$this->$attr);
+ }
+
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translation){
+ $smarty->assign($name."ACL",$this->getacl($name));
+ }
+ $smarty->assign("Actions",$this->Actions);
+ $smarty->assign("is_new",$this->dn);
+ $smarty->assign("is_acc",$this->initially_was_account);
+ return($smarty->fetch(get_template_path("goImapServer.tpl",TRUE,dirname(__FILE__))));
+ }
+
+ function getListEntry()
+ {
+ $fields = goService::getListEntry();
+ $fields['Message'] = _("IMAP/POP3 (Cyrus) service");
+ $fields['AllowRemove']= true;
+ $fields['AllowEdit'] = true;
+ return($fields);
+ }
+
+ function check()
+ {
+ $message = plugin::check();
+ if(empty($this->goImapName)){
+ $message[] =_("Please specify a server identifier.");
+ }
+ if(empty($this->goImapConnect)){
+ $message[] =_("Please specify a connect url.");
+ }
+ if(empty($this->goImapAdmin)){
+ $message[] =_("Please specify an admin user.");
+ }
+ if(empty($this->goImapPassword)){
+ $message[] =_("Please specify a password for the admin user.");
+ }
+
+ /* Check connect string */
+ if (!preg_match('/^\{[^:]+:[0-9]+.*\}$/', $this->goImapConnect)){
+ $message[]= sprintf(_("The imap connect string needs to be in the form '%s'."),
+ '{server-name:port/options}');
+ }
+ if (!preg_match('/^[0-9]+$/', $this->goImapSievePort)){
+ $message[]= _("The sieve port needs to be numeric.");
+ }
+
+ return ($message);
+ }
+
+
+ function save_object()
+ {
+ if(isset($_POST['goImapServerPosted'])){
+ plugin::save_object();
+
+ foreach(array("cyrusImap","cyrusImapSSL","cyrusPop3","cyrusPop3SSL") as $checkbox) {
+
+ if($this->acl_is_writeable($checkbox)){
+ if(!isset($_POST[$checkbox])){
+ $this->$checkbox = false;
+ }else{
+ $this->$checkbox = true;
+ }
+ }
+ }
+ }
+ }
+
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("IMAP/POP3"),
+ "plDescription" => _("IMAP/POP3")." ("._("Services").")",
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 94,
+ "plSection" => array("administration"),
+ "plCategory" => array("server"),
+
+ "plProvidedAcls"=> array(
+
+ "start" => _("Start"),
+ "stop" => _("Stop"),
+ "restart" => _("Restart"),
+ "repair_database" => _("Repair database"),
+
+ "goImapName" =>_("Server identifier"),
+ "goImapConnect" =>_("Connect URL"),
+ "goImapAdmin" =>_("Admin user"),
+ "goImapPassword" =>_("Admin password"),
+ "goImapSievePort" =>_("Sieve port"),
+ "cyrusImap" =>_("Start IMAP service"),
+ "cyrusImapSSL" =>_("Start IMAP SSL service"),
+ "cyrusPop3" =>_("Start POP3 service"),
+ "cyrusPop3SSL" =>_("Start POP3 SSL service"))
+ ));
+ }
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/imap/goImapServer.tpl b/plugins/admin/systems/services/imap/goImapServer.tpl
new file mode 100644
index 000000000..17c40092d
--- /dev/null
+++ b/plugins/admin/systems/services/imap/goImapServer.tpl
@@ -0,0 +1,120 @@
+
{t}Generic{/t}
+
+
+
+
Action
+{if $is_new == "new"}
+ {t}The server must be saved before you can use the status flag.{/t}
+{elseif !$is_acc}
+ {t}The service must be saved before you can use the status flag.{/t}
+{/if}
+
+
+
+ {html_options options=$Actions}
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/kerberos/class_goKrbServer.inc b/plugins/admin/systems/services/kerberos/class_goKrbServer.inc
new file mode 100644
index 000000000..3eef127f4
--- /dev/null
+++ b/plugins/admin/systems/services/kerberos/class_goKrbServer.inc
@@ -0,0 +1,107 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* This plugin only writes its objectClass */
+ var $objectclasses = array("goKrbServer");
+ var $attributes = array("goKrbRealm", "goKrbAdmin","goKrbPassword");
+ var $StatusFlag = "goKrbServerStatus";
+
+ /* This class can't be assigned twice so it conflicts with itsself */
+ var $conflicts = array("goKrbServer");
+
+ var $DisplayName = "";
+ var $dn = NULL;
+ var $goKrbServerStatus= "";
+ var $cn ="";
+ var $goKrbRealm = "";
+ var $goKrbAdmin = "";
+ var $goKrbPassword ="";
+ var $view_logged =FALSE;
+
+ function goKrbServer(&$config,$dn)
+ {
+ goService::goService($config,$dn);
+ $this->DisplayName = _("Kerberos service");
+ }
+
+
+ function execute()
+ {
+ $smarty = get_smarty();
+
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","server/".get_class($this),$this->dn);
+ }
+
+ $tmp = $this->plinfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translation){
+ $smarty->assign($name."ACL",$this->getacl($name));
+ }
+
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,$this->$attr);
+ }
+ return($smarty->fetch(get_template_path("goKrbServer.tpl",TRUE,dirname(__FILE__))));
+ }
+
+
+ function getListEntry()
+ {
+ $fields = goService::getListEntry();
+ $fields['Message'] = _("Kerberos service (kadmin access informations)");
+ $fields['AllowEdit'] = true;
+ return($fields);
+ }
+
+ function check()
+ {
+ $message = plugin::check();
+ /* goKrbPassword is a must field, if goKrbServer is used as objectClass */
+ if (empty($this->goKrbPassword)){
+ $message[]= sprintf(_("The specified kerberos password is empty."), $attr);
+ }
+ if (empty($this->goKrbAdmin)){
+ $message[]= sprintf(_("The specified kerberos admin is empty."), $attr);
+ }
+ if (empty($this->goKrbRealm)){
+ $message[]= sprintf(_("The specified kerberos realm is empty."), $attr);
+ }
+
+ return($message);
+ }
+
+
+ function save_object()
+ {
+ if(isset($_POST['goKrbServerPosted'])){
+ plugin::save_object();
+ }
+ }
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Kerberos"),
+ "plDescription" => _("Kerberos access information")." ("._("Services").")",
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 95,
+ "plSection" => array("administration"),
+ "plCategory" => array("server"),
+
+ "plProvidedAcls"=> array(
+ "goKrbRealm" => _("Realm"),
+ "goKrbAdmin" => _("Admin"),
+ "goKrbPassword" => _("Password"))
+ ));
+ }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/kerberos/goKrbServer.tpl b/plugins/admin/systems/services/kerberos/goKrbServer.tpl
new file mode 100644
index 000000000..a0234ebe1
--- /dev/null
+++ b/plugins/admin/systems/services/kerberos/goKrbServer.tpl
@@ -0,0 +1,34 @@
+
{t}Kerberos kadmin access{/t}
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/kiosk/class_goKioskService.inc b/plugins/admin/systems/services/kiosk/class_goKioskService.inc
new file mode 100644
index 000000000..287ed9e36
--- /dev/null
+++ b/plugins/admin/systems/services/kiosk/class_goKioskService.inc
@@ -0,0 +1,245 @@
+DisplayName = _("Kiosk profile service");
+ $this->baseDir = $this->config->search('environment', 'kioskpath',array('menu','tabs'));
+ $this->server_path = preg_replace("/%cn/", $this->cn, $this->server_path);
+
+ /* Load list of profiles and check if they still exists */
+ if ($this->baseDir == ""){
+ print_red(_("There is no KIOSKPATH defined in your gosa.conf. Can't manage kiosk profiles!"));
+ }else{
+ $this->gotoKioskProfiles = array();
+ if(isset($this->attrs['gotoKioskProfile']) && is_array($this->attrs['gotoKioskProfile'])){
+ for($i = 0 ; $i < $this->attrs['gotoKioskProfile']['count']; $i ++){
+ $url = $this->attrs['gotoKioskProfile'][$i];
+ $this->server_path = preg_replace("/\/[^\/]*$/","",$url);
+ $name= preg_replace("/^.*\//","",$url);
+ $this->gotoKioskProfiles[] = array('url' => $url ,
+ 'name' => $name ,
+ 'initial' =>TRUE,
+ 'exists' => file_exists($this->baseDir."/".$name));
+ }
+ }
+ }
+ }
+
+
+ function remove_from_parent()
+ {
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(&(objectClass=gotoEnvironment)(gotoKioskProfile=*/".$this->cn."/*))",array("cn"));
+ $str ="";
+ $cnt = 3;
+ while($cnt && $attrs = $ldap->fetch()){
+ $str .= $attrs['cn'][0].", ";
+ $cnt --;
+ }
+ $str = preg_replace("/, $/","",$str);
+ if($cnt != 3){
+ print_red(sprintf(_("Can not remove kiosk profile service, it is currently in use by following user(s) : %s."),$str));
+ }else{
+ goService::remove_from_parent();
+ }
+ }
+
+
+ function execute()
+ {
+ /* log actions */
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","server/".get_class($this),$this->dn);
+ }
+
+ /* Fill templating stuff */
+ $smarty= get_smarty();
+ $display= "";
+
+ /* Add new kiosk profile
+ * in profile directory ($this->baseDir);
+ */
+ if((isset($_POST['profileAdd']))&&(isset($_FILES['newProfile']))){
+ $file = $_FILES['newProfile'];
+ if(!file_exists($this->baseDir.$file['name'])){
+ $tmp = array(
+ 'url' => "" ,
+ 'name' => $file['name'] ,
+ 'initial' => FALSE,
+ 'tmp_name'=> $file['tmp_name'],
+ 'content' => file_get_contents($file['tmp_name']),
+ 'exists' => TRUE);
+ $this->gotoKioskProfiles[] = $tmp;
+ }
+ if(!is_writeable($this->baseDir)){
+ print_red(sprintf(_("Can't save new kiosk profiles, possibly permission denied for folder: '%s'."),$this->baseDir));
+ }
+ }
+
+ $only_once = true;
+ foreach($_POST as $name => $value){
+
+ if((preg_match("/^delkiosk_/",$name))&&($only_once)){
+
+ /* Get id, name and path */
+ $only_once = false;
+ $id = preg_replace("/^delkiosk_/","",$name);
+ $id = preg_replace("/_.*$/","",$id);
+ $name = $this->gotoKioskProfiles[$id]['name'];
+ $filename = $this->baseDir."/".$name;
+
+ /* check if profile is still in use */
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(&(objectClass=gotoEnvironment)(gotoKioskProfile=*".$name.")",array("cn","uid","gotoKioskProfile"));
+ $used_by = "";
+ $cnt = 3;
+ while(($attrs = $ldap->fetch()) && ($cnt)){
+ $cnt --;
+ $check = preg_replace("/^.*\//i","",$attrs['gotoKioskProfile'][0]);
+ if($check == $name){
+ $used_by .= $attrs['cn'][0].", ";
+ }
+ }
+ $used_by = preg_replace("/, $/","",$used_by);
+ if(!empty($used_by)){
+ print_red(sprintf(_("Can't remove kioks profile, it is still in use by the following objects '%s'."),$used_by));
+ }else{
+ if($this->gotoKioskProfiles[$id]['initial']){
+ $res = @unlink($filename);
+ if(!$res){
+ if(!is_writeable($filename)){
+ print_red(sprintf(_("Can't delete '%s'. Error was: permission denied."), $filename));
+ }
+ if(!file_exists($filename)){
+ print_red(sprintf(_("Can't delete '%s'. Error was: file doesn't exist."), $filename));
+ }
+ }
+ unset($this->gotoKioskProfiles[$id]);
+ }
+ }
+ }
+ }
+
+ /* Display list of profiles */
+ $divlist = new divSelectBox("KioskProfiles");
+ $divlist -> SetHeight (300);
+ foreach($this->gotoKioskProfiles as $key => $val ){
+ $divlist->AddEntry(array(
+ array("string"=>"
".$val['name']." "),
+ array("string"=>"
" ,
+ "attach"=>" style='border-right: 0px;width:24px; text-align:center;' ")
+ ));
+ }
+
+ /* Assign all existing profiles to smarty */
+ $smarty->assign("divlist",$divlist->DrawList());
+ $smarty = get_smarty();
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,$this->$attr);
+ }
+ $smarty->assign("server_path",$this->server_path);
+ return($smarty->fetch(get_template_path("goKioskService.tpl",TRUE,dirname(__FILE__))));
+ }
+
+ function getListEntry()
+ {
+ $fields = goService::getListEntry();
+ $fields['Message'] = _("Kiosk profile service");
+ $fields['AllowEdit'] = TRUE;
+ $fields['AllowStart'] = false;
+ $fields['AllowStop'] = false;
+ $fields['AllowRestart'] = false;
+ return($fields);
+ }
+
+ function check()
+ {
+ $message = plugin::check();
+ return($message);
+ }
+
+ function save()
+ {
+ goService::save();
+
+ $method = $this->server_path."/";
+ $method = preg_replace("/\/\/*$/","/",$method);
+ $this->attrs['gotoKioskProfile'] = array();
+ foreach($this->gotoKioskProfiles as $profile){
+ if(!$profile['initial']){
+
+ $contents = $profile['content'];
+ $path = $this->baseDir."/".$profile['name'];
+ $fp = @fopen($path,"w");
+ if(!$fp){
+ print_red(_("Can't save new kiosk profiles, possibly permission denied for folder")." : ",$path);
+ }else{
+ fwrite($fp,$contents,strlen($contents));
+ $this->attrs['gotoKioskProfile'][] = $method.$profile['name'];
+ }
+ @unlink($profile['tmp_name']);
+ }else{
+ $this->attrs['gotoKioskProfile'][] = $method.$profile['name'];
+ }
+ }
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->cd($this->dn);
+ $ldap->modify($this->attrs);
+ show_ldap_error($ldap->get_error(),_("Wohl kaum"));
+ }
+
+
+ function save_object()
+ {
+ if(isset($_POST['goKioskPosted'])){
+ goService::save_object();
+ if(isset($_POST['server_path'])){
+ $this->server_path = get_post("server_path");
+ }
+ }
+ }
+
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Kiosk"),
+ "plDescription" => _("Kiosk profile management")." ("._("Services").")",
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 100,
+ "plSection" => array("administration"),
+ "plCategory" => array("server"),
+
+ "plProvidedAcls"=> array()
+ ));
+ }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/kiosk/goKioskService.tpl b/plugins/admin/systems/services/kiosk/goKioskService.tpl
new file mode 100644
index 000000000..f81230464
--- /dev/null
+++ b/plugins/admin/systems/services/kiosk/goKioskService.tpl
@@ -0,0 +1,24 @@
+
{t}Kiosk profile management{/t} LABEL>
+
+
+
+{t}Server path{/t}
+
+
+{$divlist}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/kolab/class_servKolab.inc b/plugins/admin/systems/services/kolab/class_servKolab.inc
new file mode 100644
index 000000000..7d31ff58d
--- /dev/null
+++ b/plugins/admin/systems/services/kolab/class_servKolab.inc
@@ -0,0 +1,415 @@
+"Eins ist toll", "zwei"=>"Zwei ist noch besser");
+
+ var $postfix_mydomain = "";
+ var $cyrus_admins = "";
+ var $postfix_mydestination = "";
+ var $postfix_mynetworks = "127.0.0.1/8";
+ var $postfix_enable_virus_scan = "TRUE";
+ var $postfix_relayhost = "";
+ var $postfix_mxrelayenabled = true;
+ var $postfix_allow_unauthenticated = "FALSE";
+ var $cyrus_quotawarn = "80";
+ var $kolabFreeBusyFuture = "1";
+ var $k = "kolab";
+ var $cyrus_imap = "TRUE";
+ var $cyrus_pop3 = "FALSE";
+ var $cyrus_imaps = "TRUE";
+ var $cyrus_pop3s = "TRUE";
+ var $cyrus_sieve = "TRUE";
+ var $apache_allow_unauthenticated_fb = "TRUE";
+ var $proftpd_ftp = "FALSE";
+ var $apache_http = "TRUE";
+ var $kolabHost = array();
+ var $orig_cn = "";
+ var $view_logged = FALSE;
+
+ var $attributes = array("postfix_mydomain", "postfix_mydestination", "proftpd_ftp", "k",
+ "postfix_mynetworks", "postfix_enable_virus_scan", "postfix_relayhost", "apache_http",
+ "postfix_allow_unauthenticated", "cyrus_admins", "cyrus_imap","kolabFreeBusyFuture",
+ "cyrus_pop3", "cyrus_imaps", "cyrus_pop3s", "cyrus_sieve", "apache_allow_unauthenticated_fb",
+ "cyrus_quotawarn");
+ var $objectclasses = array("top", "kolab");
+
+ /* Serverservice vars */
+ var $conflicts = array("goImapServer","goMailServer");
+ var $DisplayName = "Kolab mail service";
+ var $StatusFlag = "";
+
+ function servkolab(&$config, $dn = NULL, $parent= NULL)
+ {
+ /* Setting the hostname and tell this Plugin that we are the kolab extension*/
+ $this->hostname = preg_replace('/^cn=([^,]+),.*$/', '\1', $dn);
+ $this->dn = "k=kolab,".$config->current['BASE'];
+
+ /* Load variables, if given*/
+ plugin::plugin($config, $this->dn);
+
+ /* Copy needed attributes */
+ foreach($this->attributes as $val) {
+ $name = preg_replace('/_/', '-', $val);
+ if (isset($this->attrs["$name"][0])) {
+ $this->$val = $this->attrs["$name"][0];
+ }
+ }
+
+ /* Toggle relayhost */
+ $this->postfix_mxrelayenabled = preg_match('/^\[/', $this->postfix_relayhost);
+ $this->postfix_relayhost = preg_replace("/[\[\]]/","",$this->postfix_relayhost);
+
+ /* Is this Server a member of the Kolab extension or not ?*/
+ if(isset($this->attrs['kolabHost'])) {
+ $this->kolabHost= $this->attrs['kolabHost'];
+ unset($this->kolabHost['count']);
+ }
+ $this->is_account = false;
+ $this->initially_was_account = false;
+ foreach($this->kolabHost as $host){
+ if($this->hostname == $host){
+ $this->is_account = true;
+ $this->initially_was_account = true;
+ }
+ }
+ }
+
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","server/".get_class($this),$this->dn);
+ }
+
+ /***************
+ Variable initialisation
+ ***************/
+
+ $smarty = get_smarty();
+ $display = "";
+ $ldap = $this->config->get_ldap_link();
+
+
+ /* Assemble free/busy string */
+ $edit = sprintf('
',
+ $this->kolabFreeBusyFuture);
+ $fbfuture = sprintf(_("Include data from %s days in the past when creating free/busy lists"), $edit);
+
+ /* Assemble quota string */
+ $edit = sprintf('
',
+ $this->cyrus_quotawarn);
+ $quotastr = sprintf(_("Warn users when using more than %s%% of their mail quota"), $edit);
+
+ /***************
+ Assign informations to smarty
+ ***************/
+
+ /* Set relayhost and if we have MX lookup enabled*/
+ if($this->postfix_mxrelayenabled) {
+ $smarty->assign("RelayMxSupportCheck"," checked ");
+ } else {
+ $smarty->assign("RelayMxSupportCheck","");
+ }
+
+ /* Set acls */
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translation){
+ $smarty->assign($name."ACL",$this->getacl($name));
+ }
+
+ /* Initialize all attributes, that were submitted */
+ foreach($this->attributes as $val)
+ {
+ /* Tell smarty which variables we are useing */
+ $smarty->assign($val, $this->$val);
+ if (($this->$val != "FALSE") && !empty($this->$val)){
+ $smarty->assign($val."Check", "checked");
+ } else {
+ $smarty->assign($val."Check", "");
+ }
+ }
+
+ $smarty->assign("fbfuture", $fbfuture);
+ $smarty->assign("quotastr", $quotastr);
+
+ /* Load Template */
+ $display.=$smarty->fetch(get_template_path('servkolab.tpl', TRUE));
+ return ($display);
+ }
+
+ function remove_from_parent()
+ {
+
+ /* Remove status flag, it is not a memeber of
+ this->attributes, so ensure that it is deleted too */
+ if(!empty($this->StatusFlag)){
+ $this->attrs[$this->StatusFlag] = array();
+ }
+
+
+ /* Only walk through following code, if this host
+ was a member of the kolab hosts, else skip this */
+ if(!$this->initially_was_account){
+ return;
+ }
+
+ /* !!! Don't use "cn" in this function
+ hostname -> the initial name of the host
+ cn -> is the new name of the host, in case that it was renamed.
+ */
+
+ $ldap = $this->config->get_ldap_link();
+ $this->dn = "k=kolab,".$this->config->current['BASE'];
+
+ /* We can't simply remove the whole entry, it is possible that there are
+ some other hosts assigned to this object.
+ So, first of all check if we are the last host entry within the host
+ : Remove k=kolab entry
+ if we aren't alone, only remove host name from hosts entry and save */
+ /* Are we alone? Remove complete entry... */
+
+ /* Check if we are definitly in kolabHosts */
+ if(!in_array_ics($this->hostname,$this->kolabHost)) {
+ return;
+ }
+
+ /* Integration check, not translated because they can't pop up at all, only for debug */
+ if(count($this->kolabHost) == 0){
+ print_red("Server - Kolab tab : This is not possible, we can't remove an account which doesn't exists.");
+ return;
+ }
+ if(!isset($this->hostname) || (empty($this->hostname))){
+ print_red("The required attribute hostname seams to empty.");
+ }
+
+ /* Our hostname is in kolabHosts and there is a only one entry
+ = we are the last host entry, delete k=kolab entry */
+ if (count($this->kolabHost) == 1){
+
+ /* Remove complete entry */
+ $ldap->rmdir ($this->dn);
+ show_ldap_error($ldap->get_error(), sprintf(_("Removing host entry from system server/kolab with dn '%s' failed."),$this->dn));
+ } else {
+
+ /* Only modify kolabHost */
+ $hosts= array();
+ foreach ($this->kolabHost as $host){
+ if($host != $this->hostname){
+ $hosts[]= $host;
+ }
+ }
+ $attrs= array('kolabHost' => $hosts);
+ $ldap->cd($this->dn);
+ $this->cleanup();
+ $ldap->modify ($attrs);
+ show_ldap_error($ldap->get_error(), sprintf(_("Removing host entry from system server/kolab with dn '%s' failed."),$this->dn));
+ }
+
+ new log("remove","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+
+ /* Optionally execute a command after we're done */
+ $this->handle_post_events("remove");
+ }
+
+
+ function save_object()
+ {
+ if (isset($_POST['kolabtab'])){
+ plugin::save_object();
+
+
+ foreach($this->attributes as $attr){
+ if(($this->acl_is_writeable(preg_replace("/_/","",$attr))) && (isset($_POST[$attr]))){
+ $this->$attr = $_POST[$attr];
+ }
+ }
+
+ /* Save checkboxes */
+ foreach (array( "postfix_enable_virus_scan", "postfix_allow_unauthenticated",
+ "cyrus_imap", "cyrus_pop3", "cyrus_imaps",
+ "cyrus_pop3s", "cyrus_sieve", "apache_allow_unauthenticated_fb",
+ "proftpd_ftp", "apache_http") as $cb){
+
+ if($this->acl_is_writeable(preg_replace("/_/","",$cb))){
+ if (isset($_POST[$cb])){
+ $this->$cb= "TRUE";
+ } else {
+ $this->$cb= "FALSE";
+ }
+ }
+ }
+
+ /* Toggell relay check */
+ if($this->acl_is_writeable("postfixmxrelayenabled")){
+ $this->postfix_mxrelayenabled= isset($_POST['RelayMxSupport']);
+ }
+ }
+
+ }
+
+
+ function check()
+ {
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+
+ if(($this->kolabFreeBusyFuture=="")) {
+ $message[] = _("Future days in Free/Busy settings must be set.");
+ }elseif(!is_uid($this->kolabFreeBusyFuture) || $this->kolabFreeBusyFuture < 0){
+ $message[] = _("Future days in Free/Busy settings must be a positive value.");
+ }
+
+ if(!is_int((int)($this->cyrus_quotawarn))) {
+ $message[] = _("The given Quota settings value must be a number.");
+ }elseif(!(($this->cyrus_quotawarn<=100)&&($this->cyrus_quotawarn>=0))){
+ $message[] = _("Please choose a value between 1 and 100 for Quota settings.");
+ }elseif(strcasecmp($this->cyrus_quotawarn,(int)$this->cyrus_quotawarn)){
+ $message[] = _("Future days must be a value.");
+ }
+
+ if(empty($this->postfix_mynetworks)) {
+ $message[] = _("No SMTP privileged networks set.");
+ }
+
+ /*if(empty($this->postfix_relayhost)) {
+ $message[] = _("No SMTP smarthost/relayhost set.");
+ }
+ */
+
+ return ($message);
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ /* Set ldap connection */
+ $ldap = $this->config->get_ldap_link();
+
+ /* Open current dn*/
+ $this->dn = "k=kolab,".$this->config->current['BASE'];
+
+ /* Adapt relayhost */
+ $this->postfix_relayhost= preg_replace('/[\[\]]/', '', $this->postfix_relayhost);
+ if ($this->postfix_mxrelayenabled && $this->postfix_relayhost != ""){
+ $this->postfix_relayhost= "[".$this->postfix_relayhost."]";
+ }
+
+ /* Check if this server was renamed, in this case we have to remove old cn first*/
+ if($this->hostname != $this->cn){
+ $tmp = array();
+ if(in_array_ics($this->hostname,$this->kolabHost)){
+ foreach($this->kolabHost as $host){
+ if($host != $this->hostname){
+ $tmp[] = $host;
+ }
+ }
+ $this->kolabHost = $tmp;
+ }
+ }
+
+ /* Add ourselves to the list of kolabHost's if needed */
+ if (!in_array_ics($this->cn,$this->kolabHost)){
+ $this->kolabHost[]= $this->cn;
+ }
+
+ /* Call parents save to prepare $this->attrs */
+ plugin::save();
+
+ /* Save or modify? */
+ $ldap->cat($this->dn, array('dn'));
+ if (!$ldap->fetch()){
+ $mode= "add";
+ } else {
+ $mode= "modify";
+ }
+
+ /* Do attribute conversion */
+ foreach ($this->attrs as $key => $value){
+ if (preg_match('/_/', $key)){
+ $old_key= $key;
+ $key= preg_replace('/_/', '-', $key);
+ $this->attrs[$key]= $value;
+ unset($this->attrs[$old_key]);
+ }
+ }
+ /* Add kolab hosts */
+ $this->attrs['kolabHost']= $this->kolabHost;
+
+ /* Perform LDAP action */
+ $ldap->cd($this->dn);
+ $this->cleanup();;
+ $ldap->$mode($this->attrs);
+
+ if($mode == "add"){
+ new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }else{
+ new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }
+
+ show_ldap_error($ldap->get_error(), sprintf(_("Saving system server/kolab with dn '%s' failed."),$this->dn));
+
+ /* Optionally execute a command after we're done */
+ if ($this->initially_was_account == $this->is_account) {
+ if ($this->is_modified) {
+ $this->handle_post_events("modify");
+ }
+ } else {
+ $this->handle_post_events("add");
+ }
+ }
+
+
+ function getListEntry()
+ {
+ $fields = goService::getListEntry();
+ $fields['Message'] = _("Kolab mail service");
+ $fields['AllowEdit'] = true;
+ return($fields);
+ }
+
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Kolab"),
+ "plDescription" => _("Kolab mail service")." ("._("Services").")",
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 85,
+ "plSection" => array("administration"),
+ "plCategory" => array("server"),
+
+ "plProvidedAcls"=> array(
+ "postfixmydomain" => _("Postfix mydomain") ,
+ "postfixmydestination" => _("My destination") ,
+ "cyrusadmins" => _("Cyrus admins") ,
+ "proftpdftp" => _("FTP FreeBusy service") ,
+ "postfixmynetworks" => _("SMTP privileged networks") ,
+ "postfixenablevirusscan" => _("Enable virus scan") ,
+ "postfixrelayhost" => _("Relayhost") ,
+ "postfixmxrelayenabled" => _("Enable MX lookup for relayhost"),
+ "apachehttp" => _("HTTP FreeBusy service") ,
+ "apacheallowunauthenticatedfb" => _("Allow unauthenticated free busy"),
+ "postfixallowunauthenticated" => _("Accept Internet Mail") ,
+ "cyrusimap" => _("IMAP service") ,
+ "kolabFreeBusyFuture" => _("kolabFreeBusyFuture") ,
+ "cyruspop3" => _("POP3 service") ,
+ "cyrusimaps" => _("IMAP/SSL service") ,
+ "cyruspop3s" => _("POP3/SSL service") ,
+ "cyrussieve" => _("Sieve service") ,
+ "cyrusquotawarn" => _("Quota settings"))
+ ));
+ }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/kolab/servkolab.tpl b/plugins/admin/systems/services/kolab/servkolab.tpl
new file mode 100644
index 000000000..ec83b7801
--- /dev/null
+++ b/plugins/admin/systems/services/kolab/servkolab.tpl
@@ -0,0 +1,249 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {t}Quota settings{/t}
+
+
+
+
+{render acl=$cyrusquotawarnACL}
+ {$quotastr}
+{/render}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/ldap/class_goLdapServer.inc b/plugins/admin/systems/services/ldap/class_goLdapServer.inc
new file mode 100644
index 000000000..c16df0387
--- /dev/null
+++ b/plugins/admin/systems/services/ldap/class_goLdapServer.inc
@@ -0,0 +1,97 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* This plugin only writes its objectClass */
+ var $objectclasses = array("goLdapServer");
+ var $attributes = array("goLdapBase");
+ var $StatusFlag = "goLdapServerStatus";
+
+ /* This class can't be assigned twice so it conflicts with itsself */
+ var $conflicts = array("goLdapServer");
+
+ var $DisplayName = "";
+ var $dn = NULL;
+ var $cn = "";
+ var $goLdapServerStatus = "";
+ var $goLdapBase = "";
+ var $view_logged =FALSE;
+
+ function goLdapServer(&$config,$dn)
+ {
+ goService::goService($config,$dn);
+ $this->DisplayName = _("LDAP service");
+ }
+
+
+ function execute()
+ {
+
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","server/".get_class($this),$this->dn);
+ }
+
+ $smarty = get_smarty();
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,$this->$attr);
+ }
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translated){
+ $smarty->assign($name."ACL",$this->getacl($name));
+ }
+ return($smarty->fetch(get_template_path("goLdapServer.tpl",TRUE,dirname(__FILE__))));
+ }
+
+
+ function getListEntry()
+ {
+ $fields = goService::getListEntry();
+ $fields['Message'] = _("LDAP Service");
+ $fields['AllowEdit'] = true;
+ return($fields);
+ }
+
+
+
+ function check()
+ {
+ $message = plugin::check();
+ if(empty($this->goLdapBase)){
+ $message[] = _("The given base is empty or contains invalid characters.");
+ }
+ return($message);
+ }
+
+
+ function save_object()
+ {
+ if(isset($_POST['goLdapServerPosted'])){
+ plugin::save_object();
+ }
+ }
+
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Ldap"),
+ "plDescription" => _("Ldap")." ("._("Services").")",
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 96,
+ "plSection" => array("administration"),
+ "plCategory" => array("server"),
+
+ "plProvidedAcls"=> array(
+ "goLdapBase" => _("Ldap base"))
+ ));
+ }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/ldap/goLdapServer.tpl b/plugins/admin/systems/services/ldap/goLdapServer.tpl
new file mode 100644
index 000000000..24e181771
--- /dev/null
+++ b/plugins/admin/systems/services/ldap/goLdapServer.tpl
@@ -0,0 +1,13 @@
+
{t}LDAP service{/t}
+{t}LDAP URI{/t}{$must}
+{render acl=$goLdapBaseACL}
+
+{/render}
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/log/class_gosaLogServer.inc b/plugins/admin/systems/services/log/class_gosaLogServer.inc
new file mode 100644
index 000000000..cade0e243
--- /dev/null
+++ b/plugins/admin/systems/services/log/class_gosaLogServer.inc
@@ -0,0 +1,108 @@
+DisplayName = _("GOsa MySQL logging service");
+ }
+
+
+ function execute()
+ {
+ $smarty = get_smarty();
+
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","server/".get_class($this),$this->dn);
+ }
+
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translation){
+ $smarty->assign($name."ACL",$this->getacl($name));
+ }
+
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,$this->$attr);
+ }
+ return($smarty->fetch(get_template_path("gosaLogServer.tpl",TRUE,dirname(__FILE__))));
+ }
+
+
+ function getListEntry()
+ {
+ $fields = goService::getListEntry();
+ $fields['Message'] = _("GOsa MySQL logging service");
+ $fields['AllowEdit'] = true;
+ $fields['AllowStart'] = FALSE;
+ $fields['AllowStop'] = FALSE;
+ $fields['AllowRestart'] = FALSE;
+ return($fields);
+ }
+
+
+ function check()
+ {
+ $message = plugin::check();
+ if (empty($this->goLogDBUser)){
+ $message[]= sprintf_("The attribute user is empty or contains invalid characters.");
+ }
+ if (empty($this->goLogDBPassword)){
+ $message[]= sprintf_("The attribute password is empty or contains invalid characters.");
+ }
+ if (empty($this->goLogDB)){
+ $message[]= sprintf_("The attribute database is empty or contains invalid characters.");
+ }
+ return($message);
+ }
+
+
+ function save_object()
+ {
+ if(isset($_POST['gosaLogServerPosted'])){
+ plugin::save_object();
+ }
+ }
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("GOsa logging service"),
+ "plDescription" => _("GOsa logging service")." ("._("Services").")",
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 98,
+ "plSection" => array("administration"),
+ "plCategory" => array("server"),
+
+ "plProvidedAcls"=> array(
+ "goLogDB" => _("Database"),
+ "goLogDBUser" => _("User"),
+ "goLogDBPassword" => _("Password"),
+ "viewEntries" => _("Allow view of entries on this server"))
+ ));
+ }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/log/gosaLogServer.tpl b/plugins/admin/systems/services/log/gosaLogServer.tpl
new file mode 100644
index 000000000..7dd032a36
--- /dev/null
+++ b/plugins/admin/systems/services/log/gosaLogServer.tpl
@@ -0,0 +1,35 @@
+
{t}GOsa logging database{/t}
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/mail/class_goMailServer.inc b/plugins/admin/systems/services/mail/class_goMailServer.inc
new file mode 100644
index 000000000..742249ef7
--- /dev/null
+++ b/plugins/admin/systems/services/mail/class_goMailServer.inc
@@ -0,0 +1,725 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* This plugin only writes its objectClass */
+ var $objectclasses = array("goMailServer");
+
+ /* This class can't be assigned twice so it conflicts with itsself */
+ var $DisplayName = "";
+ var $dn = NULL;
+ var $StatusFlag = "goMailServerStatus";
+ var $attributes = array("description","postfixHeaderSizeLimit",
+ "postfixMailboxSizeLimit","postfixMessageSizeLimit",
+ "postfixMyDestinations","postfixMyDomain","postfixMyhostname",
+ "postfixMyNetworks","postfixRelayhost","postfixTransportTable",
+ "postfixSenderRestrictions","postfixRecipientRestrictions");
+
+ var $goMailServerStatus ;
+ var $postfixHeaderSizeLimit = 0;
+ var $postfixMailboxSizeLimit = 0;
+ var $postfixMessageSizeLimit = 0;
+ var $postfixMyDestinations = array();
+ var $postfixMyDomain = "";
+ var $postfixMyhostname = "";
+ var $postfixMyNetworks = array();
+ var $postfixRelayhost = "";
+ var $postfixTransportTable = array();
+ var $postfixSenderRestrictions = array();
+ var $postfixRecipientRestrictions = array();
+ var $description = "";
+ var $RestrictionFilters = array();
+ var $TransportProtocols = array();
+ var $Actions = array();
+ var $cn = "";
+ var $conflicts = array("goMailServer","kolab");
+ var $view_logged =FALSE;
+
+ function goMailServer(&$config,$dn)
+ {
+ goService::goService($config,$dn);
+ $this->DisplayName = _("Mail smtp service (Postfix)");
+
+ $this->Actions = array( SERVICE_STOPPED=>SERVICE_STOPPED,
+ SERVICE_STARTED => SERVICE_STARTED,
+ SERVICE_RESTARTED=>SERVICE_RESTARTED);
+
+ /* Fill RestrictionFilters TransportProtocols from external hooks */
+ $str = $this->config->data['TABS']['SERVERSERVICE'];
+ $this->TransportProtocols =array("smtp"=>"SMTP");
+ $this->RestrictionFilters = array("FILTER"=>"FILTER");
+ foreach(array("ADDITIONALRESTRICTIONFILTERS"=>"RestrictionFilters",
+ "ADDITIONALPROTOCOLLS" =>"TransportProtocols") as $file => $var){
+ if(isset($this->config->data['MAIN'][$file])){
+ $file = $this->config->data['MAIN'][$file];
+ if((isset($file)) && is_readable($file)){
+ $tmp = file_get_contents($file);
+ $tmp2= split("\n",$tmp);
+ foreach($tmp2 as $entry){
+ if(empty($entry)) continue;
+ if(preg_match("/:/",$entry)){
+ $tmp3 = split(":",$entry);
+ $r = $this->$var;
+ $r[$tmp3[0]]=$tmp3[1];
+ $this->$var = $r;
+ }else{
+ $r = $this->$var;
+ $r[$entry] =$entry;
+ $this->$var = $r;
+ }
+ }
+ }
+ }
+ }
+
+
+ /* Get postfix my networks */
+ $this->postfixMyNetworks = array();
+ $tmp = array();
+ if(isset($this->attrs['postfixMyNetworks'][0])){
+ $tmp = split(",",$this->attrs['postfixMyNetworks'][0]);
+ foreach($tmp as $str){
+ if(!empty($str)){
+ $this->postfixMyNetworks[base64_encode($str)] = $str;
+ }
+ }
+ }
+
+
+ /* Create full name */
+ if(isset($this->attrs['postfixMyDomain'][0])){
+ $this->postfixMyhostname .= ".".$this->attrs['postfixMyDomain'][0];
+ }
+
+
+ /* Get postfix my domains */
+ $this->postfixMyDestinations = array();
+ if(isset($this->attrs['postfixMyDestinations'][0])){
+ unset($this->attrs['postfixMyDestinations']['count']);
+ foreach($this->attrs['postfixMyDestinations'] as $str){
+ $this->postfixMyDestinations[base64_encode($str)] = $str;
+ }
+ }
+
+
+ /* Get transport tables */
+ $tmp = array();
+ $this->postfixTransportTable = array();
+ if(isset($this->attrs['postfixTransportTable'])){
+ $tmp = array();
+ unset($this->attrs['postfixTransportTable']['count']);
+ foreach($this->attrs['postfixTransportTable'] as $entry){
+
+ //0: offshore.vip.ms-europa.lhsystems.com smtp:172.28.0.2
+
+ $Number = preg_replace('/^([^:]+):.*$/', '\\1', $entry);
+ $Rest = trim(preg_replace("/^[0-9]*:/","",$entry));
+
+ $Protocol_Destination = preg_replace("/^.*\ /","",$Rest);
+ $Source = preg_replace("/\ .*$/","",$Rest);
+
+ $Protocol = preg_replace ('/^([^:]+):.*$/', '\\1' ,trim($Protocol_Destination));
+ $Destination = preg_replace ('/^[^:]+:(.*)$/', '\\1' ,trim($Protocol_Destination));
+
+ $Destination = preg_replace ("/[\[\]]/","",$Destination);
+
+ $tmp[$Number]['src'] = $Source;
+ $tmp[$Number]['dst'] = $Destination;
+ $tmp[$Number]['prt'] = $Protocol;
+ }
+ ksort($tmp);
+ foreach($tmp as $entry){
+ $this->postfixTransportTable[] = $entry;
+ }
+ }
+
+
+ /* Get sender restrictions */
+ $tmp = array();
+ $this->postfixSenderRestrictions = array();
+ if(isset($this->attrs['postfixSenderRestrictions'])){
+ unset($this->attrs['postfixSenderRestrictions']['count']);
+ foreach($this->attrs['postfixSenderRestrictions'] as $entry){
+ $nr = preg_replace("/:.*$/","",$entry);
+ $rest= trim(preg_replace("/^[^:]+:/","",$entry));
+ $src = preg_replace("/ .*$/","",$rest);
+ $rest= preg_replace("/^[^ ]+ /","",$rest);
+ $dst = preg_replace("/^.* /","",$rest);
+ $prt = preg_replace("/ .*$/","",$rest);
+
+ $tmp[$nr]['src'] = $src;
+ $tmp[$nr]['dst'] = $dst;
+ $tmp[$nr]['filter'] = $prt;
+ }
+ ksort($tmp);
+ foreach($tmp as $entry){
+ $this->postfixSenderRestrictions[] = $entry;
+ }
+ }
+
+
+ /* Get sender restrictions */
+ $tmp = array();
+ $this->postfixRecipientRestrictions = array();
+ if(isset($this->attrs['postfixRecipientRestrictions'])){
+ unset($this->attrs['postfixRecipientRestrictions']['count']);
+ foreach($this->attrs['postfixRecipientRestrictions'] as $entry){
+ $nr = preg_replace("/:.*$/","",$entry);
+ $rest= trim(preg_replace("/^[^:]+:/","",$entry));
+ $src = preg_replace("/ .*$/","",$rest);
+ $rest= preg_replace("/^[^ ]+ /","",$rest);
+ $dst = preg_replace("/^.* /","",$rest);
+ $prt = preg_replace("/ .*$/","",$rest);
+
+ $tmp[$nr]['src'] = $src;
+ $tmp[$nr]['dst'] = $dst;
+ $tmp[$nr]['filter'] = $prt;
+ }
+ ksort($tmp);
+ foreach($tmp as $entry){
+ $this->postfixRecipientRestrictions[] = $entry;
+ }
+ }
+
+ }
+
+ function execute()
+ {
+ $smarty = get_smarty();
+
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","server/".get_class($this),$this->dn);
+ }
+
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translation){
+ $smarty->assign($name."ACL",$this->getacl($name));
+ }
+
+ $delAr = array(
+ "TranslationDel_"=>"TranslationDel",
+ "SenderRestrictDel_"=>"SenderRestrictDel",
+ "RecipientRestrictDel_"=>"RecipientRestrictDel");
+
+ $once = true;
+ $s_action = "";
+ $s_entry = "";
+
+ /* Check posts for some intruductions */
+ foreach($_POST as $name => $value){
+ foreach($delAr as $preg => $type){
+ if((preg_match("/^".$preg."/",$name)) && ($once)){
+ $once = false;
+ $s_action = $type;
+ $s_entry = preg_replace("/^".$preg."/","",$name);
+ $s_entry = preg_replace("/_[xy]$/","",$s_entry);
+ }
+ }
+
+
+ if(preg_match("/^TranslationUp_/",$name) && $once && ($this->acl_is_writeablei("postfixTransportTableACL"))){
+ $once = false;
+ $key = preg_replace("/^TranslationUp_/","",$name);
+ $key = preg_replace("/_[xy]$/","",$key);
+ $this->postfixTransportTable = $this->ArrayUp($key,$this->postfixTransportTable) ;
+ }
+ if(preg_match("/^TranslationDown_/",$name) && $once && ($this->acl_is_writeable("postfixTransportTableACL"))){
+ $once = false;
+ $key = preg_replace("/^TranslationDown_/","",$name);
+ $key = preg_replace("/_[xy]$/","",$key);
+ $this->postfixTransportTable = $this->ArrayDown($key,$this->postfixTransportTable) ;
+ }
+ if(preg_match("/^SenderRestrictUp_/",$name) && $once && ($this->acl_is_writeable("postfixSenderRestrictionsACL"))){
+ $once = false;
+ $key = preg_replace("/^SenderRestrictUp_/","",$name);
+ $key = preg_replace("/_[xy]$/","",$key);
+ $this->postfixSenderRestrictions = $this->ArrayUp($key,$this->postfixSenderRestrictions) ;
+ }
+ if(preg_match("/^SenderRestrictDown_/",$name) && $once && ($this->acl_is_writeable("postfixSenderRestrictionsACL"))){
+ $once = false;
+ $key = preg_replace("/^SenderRestrictDown_/","",$name);
+ $key = preg_replace("/_[xy]$/","",$key);
+ $this->postfixSenderRestrictions = $this->ArrayDown($key,$this->postfixSenderRestrictions) ;
+ }
+ if(preg_match("/^RecipientRestrictUp_/",$name) && $once && ($this->acl_is_writeable("postfixRecipientRestrictionsACL"))){
+ $once = false;
+ $key = preg_replace("/^RecipientRestrictUp_/","",$name);
+ $key = preg_replace("/_[xy]$/","",$key);
+ $this->postfixRecipientRestrictions = $this->ArrayUp($key,$this->postfixRecipientRestrictions) ;
+ }
+ if(preg_match("/^RecipientRestrictDown_/",$name) && $once && ($this->acl_is_writeable("postfixRecipientRestrictionsACL"))){
+ $once = false;
+ $key = preg_replace("/^RecipientRestrictDown_/","",$name);
+ $key = preg_replace("/_[xy]$/","",$key);
+ $this->postfixRecipientRestrictions = $this->ArrayDown($key,$this->postfixRecipientRestrictions) ;
+ }
+ }
+
+
+ /* Add delete my network entry */
+ if((isset($_POST['AddpostfixMyNetworks'])) && (!empty($_POST['NewString_postfixMyNetworks']))){
+ $str = $_POST['NewString_postfixMyNetworks'];
+ $this->postfixMyNetworks[base64_encode($str)] = $str;
+ }
+
+ if((isset($_POST['DelpostfixMyNetworks'])) && isset($_POST['Select_postfixMyNetworks']) &&(count($_POST['Select_postfixMyNetworks']))){
+ foreach($_POST['Select_postfixMyNetworks'] as $str ){
+ unset($this->postfixMyNetworks[$str]);
+ }
+ }
+
+
+ /* Add delete my domain entry */
+ if($this->acl_is_writeable("postfixMyDestinations")){
+ if((isset($_POST['AddpostfixMyDestinations'])) && (!empty($_POST['NewString_postfixMyDestinations']))){
+ $str = $_POST['NewString_postfixMyDestinations'];
+ $this->postfixMyDestinations[base64_encode($str)] = $str;
+ }
+
+ if((isset($_POST['DelpostfixMyDestinations'])) && isset($_POST['Select_postfixMyDestinations']) &&(count($_POST['Select_postfixMyDestinations']))){
+ foreach($_POST['Select_postfixMyDestinations'] as $str ){
+ unset($this->postfixMyDestinations[$str]);
+ }
+ }
+ }
+
+
+ /* Add sender restriction */
+ if($this->acl_is_writeable("postfixSenderRestrictions")){
+ if(($s_action == "SenderRestrictDel") && (isset($this->postfixSenderRestrictions[$s_entry]))){
+ unset($this->postfixSenderRestrictions[$s_entry]);
+ }
+
+ if(isset($_POST['AddpostfixSenderRestrictions'])){
+ $src = $_POST['Source_postfixSenderRestrictions'];
+ $dst = $_POST['Destination_postfixSenderRestrictions'];
+ $Filter = $_POST['SenderRestrictionFilter'];
+ $tmp['src'] = $src;
+ $tmp['dst'] = $dst;
+ $tmp['filter'] = $Filter;
+ $this->postfixSenderRestrictions[] = $tmp;
+ }
+ }
+
+
+ /* Add sender restriction */
+ if($this->acl_is_writeable("postfixRecipientRestrictions")){
+ if(($s_action == "RecipientRestrictDel") && (isset($this->postfixRecipientRestrictions[$s_entry]))){
+ unset($this->postfixRecipientRestrictions[$s_entry]);
+ }
+
+ if(isset($_POST['AddpostfixRecipientRestrictions'])){
+ $src = $_POST['Source_postfixRecipientRestrictions'];
+ $dst = $_POST['Destination_postfixRecipientRestrictions'];
+ $Filter = $_POST['RecipientRestrictionFilter'];
+ $tmp['src'] = $src;
+ $tmp['dst'] = $dst;
+ $tmp['filter'] = $Filter;
+ $this->postfixRecipientRestrictions[] = $tmp;
+ }
+ }
+
+ /* Handle transports */
+ if($this->acl_is_writeable("postfixTransportTable")){
+ if(($s_action == "TranslationDel") && (isset($this->postfixTransportTable[$s_entry]))){
+ unset($this->postfixTransportTable[$s_entry]);
+ }
+
+ if(isset($_POST['AddpostfixTransportTable'])){
+ $src = trim($_POST['Source_postfixTransportTable']);
+ $dst = trim($_POST['Destination_postfixTransportTable']);
+ $prt = trim($_POST['TransportProtocol']);
+
+ if((!empty($src)) && (!empty($dst))){
+ if(preg_match("/:/",$dst)){
+ $tmp = split("\:",$dst);
+ $port = trim($tmp[1]);
+ $ip = trim($tmp[0]);
+
+ if((is_ip($ip)) && (is_numeric($port))){
+ $dst = "[".$ip."]:".$port;
+ }
+ }
+ if(is_ip($dst)){
+ $dst = "[".$dst."]";
+ }
+ $tmp2 ['src'] = $src;
+ $tmp2 ['dst'] = $dst;
+ $tmp2 ['prt'] = $prt;
+
+ $this->postfixTransportTable[] = $tmp2;
+ }
+ }
+ }
+
+ /* Set attributes */
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,$this->$attr);
+ }
+
+
+ /* Create divList for translation tables */
+ $divTranslation = new divSelectBox("TransportProtocols");
+ $divTranslation->SetHeight(90);
+ foreach($this->postfixTransportTable as $key => $entry){
+ $img = "";
+
+ if($key != 0 && $this->acl_is_writeable("postfixTransportTable")){
+ $img.= "
";
+ }else{
+ $img.= "
";
+ }
+ if(($key+1) < count($this->postfixTransportTable) && $this->acl_is_writeable("postfixTransportTable")){
+ $img.= "
";
+ }else{
+ $img.= "
";
+ }
+
+ if($this->acl_is_writeable("postfixTransportTable")){
+ $img.= "
";
+ }
+ $field1 = array("string"=> $entry['src']);
+ $field2 = array("string"=> $entry['dst']);
+ $field3 = array("string"=> $entry['prt'],"attach"=>"style='width:120px;'");
+ $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
+ $divTranslation->AddEntry(array($field1,$field2,$field3,$field4,));
+ }
+ $smarty->assign("Div_postfixTransportTable" ,$divTranslation->DrawList());
+
+
+ /* Create divList for sender restrictions */
+ $DivSenderRestrict = new divSelectBox("postfixSenderRestrictions");
+ $DivSenderRestrict->SetHeight(90);
+ foreach($this->postfixSenderRestrictions as $key => $entry){
+ $img ="";
+
+ if($key != 0 && $this->acl_is_writeable("postfixSenderRestrictions")){
+ $img.= "
";
+ }else{
+ $img.= "
";
+ }
+ if(($key+1) < count($this->postfixSenderRestrictions) && $this->acl_is_writeable("postfixSenderRestrictions")){
+ $img.= "
";
+ }else{
+ $img.= "
";
+ }
+
+ if($this->acl_is_writeable("postfixSenderRestrictions")){
+ $img.= "
";
+ }
+
+ $field1 = array("string"=> $entry['src']);
+ $field2 = array("string"=> $entry['dst']);
+ $field3 = array("string"=> $entry['filter'],"attach"=>"style='width:100px;'");
+ $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
+ $DivSenderRestrict->AddEntry(array($field1,$field2,$field3,$field4,));
+ }
+ $smarty->assign("Div_postfixSenderRestrictions" ,$DivSenderRestrict->DrawList());
+
+
+ /* Create divList for translation tables */
+ $DivRecipientRestrict = new divSelectBox("postfixRecipientRestrictions");
+ $DivRecipientRestrict->SetHeight(90);
+
+ foreach($this->postfixRecipientRestrictions as $key => $entry){
+ $img = "";
+ if($key != 0 && $this->acl_is_writeable("postfixRecipientRestrictions")){
+ $img.= "
";
+ }else{
+ $img.= "
";
+ }
+ if(($key+1) < count($this->postfixRecipientRestrictions) && $this->acl_is_writeable("postfixRecipientRestrictions")){
+ $img.= "
";
+ }else{
+ $img.= "
";
+ }
+
+ if($this->acl_is_writeable("postfixRecipientRestrictions")){
+ $img.= "
";
+ }
+ $field1 = array("string"=> $entry['src']);
+ $field2 = array("string"=> $entry['dst']);
+ $field3 = array("string"=> $entry['filter'],"attach"=>"style='width:100px;'");
+ $field4 = array("string"=> $img, "attach"=>"style='border-right:0px;width:40px;'");
+ $DivRecipientRestrict->AddEntry(array($field1,$field2,$field3,$field4,));
+ }
+ $smarty->assign("Div_postfixRecipientRestrictions" ,$DivRecipientRestrict->DrawList());
+
+
+ /* set new status */
+ if(isset($_POST['ExecAction'])){
+ if(isset($this->Actions[$_POST['action']])){
+ $this->setStatus($_POST['action']);
+ }
+ }
+
+
+ $smarty->assign("is_new", $this->dn);
+ $smarty->assign("is_acc", $this->initially_was_account);
+ $smarty->assign("TransportProtocols", $this->TransportProtocols);
+ $smarty->assign("Actions", $this->Actions);
+ $smarty->assign("RestrictionFilters", $this->RestrictionFilters);
+ $smarty->assign("postfixTransportTable" , $this->getTransports());
+ $smarty->assign("postfixSenderRestrictions" , $this->getSenderRestrictions());
+ $smarty->assign("postfixRecipientRestrictions" ,$this->getRecipientRestrictions());
+
+ return($smarty->fetch(get_template_path("goMailServer.tpl",TRUE,dirname(__FILE__))));
+ }
+
+
+ /* return transports formated for select box */
+ function getTransports()
+ {
+ $ret = array();
+ foreach($this->postfixTransportTable as $key => $vals){
+ $ret[$key] = $vals['src']." -> ".$vals['prt'].":".$vals['dst'];
+ }
+ return($ret);
+ }
+
+
+ /* return sender restriction formated for select box */
+ function getSenderRestrictions()
+ {
+ $ret = array();
+ foreach($this->postfixSenderRestrictions as $key => $vals){
+ $ret[$key] = $vals['src']." ".$vals['filter']." ".$vals['dst'];
+ }
+ return($ret);
+ }
+
+
+ /* return recipient restriction formated for select box */
+ function getRecipientRestrictions()
+ {
+ $ret = array();
+ foreach($this->postfixRecipientRestrictions as $key => $vals){
+ $ret[$key] = $vals['src']." ".$vals['filter']." ".$vals['dst'];
+ }
+ return($ret);
+ }
+
+
+ /* Return list entry */
+ function getListEntry()
+ {
+ $fields = goService::getListEntry();
+ $fields['Message'] = _("Mail smtp service (Postfix)");
+ $fields['AllowEdit'] = true;
+ return($fields);
+ }
+
+
+ function save()
+ {
+ $this->postfixMyDomain = preg_replace("/^[^\.]+\./","",$this->postfixMyhostname);
+ $this->postfixMyhostname = preg_replace("/\..*$/","",$this->postfixMyhostname);
+
+ plugin::save();
+
+ /* Fix transport table*/
+ $i = 0 ;
+ $this->attrs['postfixTransportTable'] = array();
+ foreach($this->postfixTransportTable as $key => $entry){
+ $this->attrs['postfixTransportTable'][] = $i.": ".$entry['src']." ".$entry['prt'].":".$entry['dst'];
+ $i ++;
+ }
+
+
+ /* Fix sender restrictions */
+ $i = 0;
+ $this->attrs['postfixSenderRestrictions'] =array();
+ foreach($this->postfixSenderRestrictions as $key => $entry){
+ $this->attrs['postfixSenderRestrictions'][] = $i.": ".$entry['src']." ".$entry['filter']." ".$entry['dst'];
+ $i ++;
+ }
+
+
+ /* Fix recipient restrictions */
+ $i = 0;
+ $this->attrs['postfixRecipientRestrictions'] =array();
+ foreach($this->postfixRecipientRestrictions as $key => $entry){
+ $this->attrs['postfixRecipientRestrictions'][] = $i.": ".$entry['src']." ".$entry['filter']." ".$entry['dst'];
+ $i ++;
+ }
+
+
+ /* Fix mydomains */
+ $this->attrs['postfixMyDestinations'] = array();
+ foreach($this->postfixMyDestinations as $entry){
+ $this->attrs['postfixMyDestinations'][] =$entry;
+ }
+
+
+ /* Fix mydomains */
+ if(count($this->postfixMyNetworks)){
+ $this->attrs['postfixMyNetworks'] = "";
+ foreach($this->postfixMyNetworks as $entry){
+ $this->attrs['postfixMyNetworks'] .=$entry.",";
+ }
+ $this->attrs['postfixMyNetworks'] = preg_replace("/,$/","",$this->attrs['postfixMyNetworks']);
+ }else{
+ $this->attrs['postfixMyNetworks'] = array();
+ }
+
+
+ /* Check if this is a new entry ... add/modify */
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cat($this->dn,array("objectClass"));
+ if($ldap->count()){
+ $ldap->cd($this->dn);
+ $ldap->modify($this->attrs);
+ }else{
+ $ldap->cd($this->dn);
+ $ldap->add($this->attrs);
+ }
+ show_ldap_error($ldap->get_error(), sprintf(_("Saving server services/mail with dn '%s' failed."),$this->dn));
+ if($this->initially_was_account){
+ $this->handle_post_events("modify");
+ new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }else{
+ $this->handle_post_events("add");
+ new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }
+
+ }
+
+
+ function check()
+ {
+ $message =plugin::check();
+
+ if(!is_numeric($this->postfixHeaderSizeLimit)){
+ $message[] = _("Please specify a numeric value for header size limit.");
+ }
+
+ if(!is_numeric($this->postfixMailboxSizeLimit)){
+ $message[] = _("Please specify a numeric value for mailbox size limit.");
+ }
+
+ if(!is_numeric($this->postfixMessageSizeLimit)){
+ $message[] = _("Please specify a numeric value for message size limit.");
+ }
+
+ return $message;
+ }
+
+
+ /* Combine new array */
+ function combineArrays($ar0,$ar1,$ar2)
+ {
+ $ret = array();
+ if(is_array($ar0))
+ foreach($ar0 as $ar => $a){
+ $ret[]=$a;
+ }
+ if(is_array($ar1))
+ foreach($ar1 as $ar => $a){
+ $ret[]=$a;
+ }
+ if(is_array($ar2))
+ foreach($ar2 as $ar => $a){
+ $ret[]=$a;
+ }
+ return($ret);
+ }
+
+
+ function getpos($atr,$attrs)
+ {
+ $i = 0;
+ foreach($attrs as $attr => $name) {
+ $i++;
+ if($attr == $atr){
+ return($i);
+ }
+ }
+
+ return(-1);
+ }
+
+
+ /* TRansports the geiven Arraykey one position up*/
+ function ArrayUp($atr,$attrs)
+ {
+ $ret = $attrs;
+ $pos = $this->getpos($atr,$attrs) ;
+ $cn = count($attrs);
+ if(!(($pos == -1)||($pos == 1))){
+ $before = array_slice($attrs,0,($pos-2));
+ $mitte = array_reverse(array_slice($attrs,($pos-2),2));
+ $unten = array_slice($attrs,$pos);
+ $ret = array();
+ $ret = $this->combineArrays($before,$mitte,$unten);
+ }
+ return($ret);
+ }
+
+
+ /* TRansports the geiven Arraykey one position up*/
+ function ArrayDown($atr,$attrs)
+ {
+ $ret = $attrs;
+ $pos = $this->getpos($atr,$attrs) ;
+ $cn = count($attrs);
+ if(!(($pos == -1)||($pos == $cn))){
+ $before = array_slice($attrs,0,($pos-1));
+ $mitte = array_reverse(array_slice($attrs,($pos-1),2));
+ $unten = array_slice($attrs,($pos+1));
+ $ret = array();
+ $ret = $this->combineArrays($before,$mitte,$unten);
+ }
+ return($ret);
+ }
+
+ function save_object()
+ {
+ plugin::save_object();
+ }
+
+
+ function PrepareForCopyPaste($source)
+ {
+ plugin::PrepareForCopyPaste($source);
+
+ $source_o = new goMailServer($this->config,$source['dn']);
+ foreach(array("postfixMyDomain","postfixMyhostname","postfixMyNetworks","postfixTransportTable","postfixSenderRestrictions","postfixRecipientRestrictions","postfixMyDestinations") as $attr){
+ $this->$attr = $source_o->$attr;
+ }
+ }
+
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Mail smtp (Postfix)"),
+ "plDescription" => _("Mail smtp - Postfix")." ("._("Services").")",
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 98,
+ "plSection" => array("administration"),
+ "plCategory" => array("server"),
+
+ "plProvidedAcls"=> array(
+ "postfixMyhostname" => _("Visible full qualified hostname"),
+ "description" => _("Description"),
+ "postfixHeaderSizeLimit" => _("Header size limit"),
+ "postfixMailboxSizeLimit" => _("Max mailbox size"),
+ "postfixMessageSizeLimit" => _("Max message size"),
+ "postfixMyDestinations" => _("Domains to accept mail for"),
+ "postfixMyNetworks" => _("Local networks"),
+ "postfixRelayhost" => _("Relay host"),
+ "postfixTransportTable" => _("Transport table"),
+ "postfixSenderRestrictions" => _("Restrictions for sender"),
+ "postfixRecipientRestrictions"=> _("Restrictions for recipient"))
+ ));
+ }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/mail/goMailServer.tpl b/plugins/admin/systems/services/mail/goMailServer.tpl
new file mode 100644
index 000000000..a17d08f04
--- /dev/null
+++ b/plugins/admin/systems/services/mail/goMailServer.tpl
@@ -0,0 +1,225 @@
+
{t}Generic{/t}
+
+
+
+
+
+
+
+
+
+
+
+
+ {t}Domains and routing{/t}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {t}Restrictions{/t}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Action
+{if $is_new == "new"}
+ {t}The server must be saved before you can use the status flag.{/t}
+{elseif !$is_acc}
+ {t}The service must be saved before you can use the status flag.{/t}
+{/if}
+
+
+
+ {html_options options=$Actions}
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/nfs/class_servNfs.inc b/plugins/admin/systems/services/nfs/class_servNfs.inc
new file mode 100644
index 000000000..1386de1fc
--- /dev/null
+++ b/plugins/admin/systems/services/nfs/class_servNfs.inc
@@ -0,0 +1,267 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account = TRUE;
+ var $attributes = array("description","type","charset","path","option", "volume");
+ var $objectclasses = array("whatever");
+ var $is_account = true;
+
+ var $name =""; // Name of
+ var $description =""; // description
+ var $type =""; // Type FS/Samba/NCP
+ var $charset =""; // charset
+ var $host =""; // hostname
+ var $types =array(); // Array Types NFS/Samba/NCP/netatalk
+ var $charsets =array(); // Array with charsets
+ var $path =""; // Path
+ var $volume =""; // Volume
+ var $option =""; // Options
+ var $is_edit =false;
+ var $create_mount_init = false; //mount entry set for this entry (while editing)?
+ var $create_mount = false; //save mount entry
+
+ var $parent = NULL;
+ var $view_logged = FALSE;
+
+ function servnfs (&$config, $parent,$entry= false,$mount =false)
+ {
+ $this->parent = $parent;
+ $dn = $parent->dn;
+ plugin::plugin ($config, $dn);
+
+ $this->types = array("CIFS" => "CIFS", "NFS"=>"NFS","samba"=>"samba","netatalk"=>"netatalk","NCP"=>"NCP");
+ if($dn){
+ $this->host = substr($dn, 3, strpos($dn, ',')-3);
+ }
+
+ $this->charsets = array();
+
+ if(!file_exists(CONFIG_DIR."/encodings")){
+ print_red(sprintf(_("The file '%s/encodings' does not exist, can't get supported charsets."),CONFIG_DIR));
+ }else{
+ if(!is_readable(CONFIG_DIR."/encodings")){
+ print_red(sprintf(_("Can't read '%s/encodings', please check permissions."),CONFIG_DIR));
+ }else{
+ $fp = fopen(CONFIG_DIR."/encodings","r");
+ $i = 100;
+ while(!feof($fp)&&$i){
+ $i -- ;
+ $str = trim(fgets($fp,256));
+
+ /* Skip comments */
+ if(!preg_match("/^#/",$str)){
+ $arr = split("\=",$str);
+ if(count($arr)==2){
+ $this->charsets[$arr[0]]=$arr[1];
+ }
+ }
+ }
+ }
+ }
+
+ if($entry){
+ list($this->name, $this->description, $this->type, $this->charset,
+ $this->path, $this->option, $this->volume)= split("\|",$entry."|");
+ $this->is_edit = true;
+
+ }else{
+ $this->attributes[] = "name";
+ }
+
+
+ $this->create_mount_init = $mount;
+ }
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","server/".get_class($this),$this->dn);
+ }
+
+ /* Fill templating stuff */
+ $smarty= get_smarty();
+
+ $smarty->assign("charsets" ,$this->charsets);
+ $smarty->assign("types" ,$this->types);
+
+ /* attrs to smarty*/
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,$this->$attr);
+ }
+
+ $tmp = $this->parent->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translation){
+ $smarty->assign($name."ACL",$this->parent->getacl($name));
+ }
+
+ $smarty->assign("name",$this->name);
+ if($this->is_edit){
+ $smarty->assign("nameACL", preg_replace("/w/","",$this->parent->getacl("name")));
+ }
+ $smarty->assign("allow_mounts", $this->parent->allow_mounts);
+ $smarty->assign("mount_checked", "");
+
+ $smarty->assign("appleMountsACL", $this->getacl("appleMounts"));
+
+ if (($this->type == "netatalk") || ($this->type == "NFS")) {
+ if ($this->create_mount_init) {
+ $smarty->assign("mount_checked", "checked");
+ } else {
+ $tmp = split(",", $this->dn);
+ $clip = $tmp[0] . ",ou=servers,ou=systems,";
+ $mountsdn = "cn=mounts," . substr($this->dn, strlen($clip));
+ switch ($this->type) {
+ case "netatalk" : {
+ $mountdn = "cn=".$this->host.":/".$this->name.",".$mountsdn;
+ break;
+ }
+ case "NFS" : {
+ $mountdn = "cn=".$this->host.":".$this->path.",".$mountsdn;
+ break;
+ }
+ default : {
+ continue;
+ }
+ }
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cat($mountdn, array('dn'));
+ $attrs = $ldap->fetch();
+ if (count($attrs) > 0) {
+ $smarty->assign("mount_checked", "checked");
+ }
+ }
+ }
+
+ $display= $smarty->fetch(get_template_path('servnfs.tpl', TRUE));
+ return($display);
+ }
+
+ function remove_from_parent()
+ {
+ /* This cannot be removed... */
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ if(isset($_POST['servnfs_posted'])){
+
+ foreach($this->attributes as $name){
+ if($this->parent->acl_is_writeable($name) && isset($_POST[$name])){
+ $this->$name = $_POST[$name];
+ }
+ }
+
+ if ((isset($_POST['netatalk_mount'])) && (($this->type == "netatalk") || ($this->type == "NFS"))) {
+ $this->create_mount = true;
+ } else {
+ $this->create_mount = false;
+ }
+ }
+ }
+
+
+ /* Check supplied data */
+ function check()
+ {
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+
+ // fixme : a check for the path ? ?
+ if(empty($this->path)){
+ $message[]=_("Please specify a valid path for your setup.");
+ }
+
+ // only 0-9a-z
+ if(!$this->is_edit){
+ if(!preg_match("/^[a-z0-9\._äüö]*$/ui",$this->name)){
+ $message[]=_("Please specify a valid name for your share.");
+ }
+ if(empty($this->name)){
+ $message[]=_("Please specify a name for your share.");
+ }
+ }
+
+ if(!empty($this->description) && preg_match("/^[^a-z0-9\._äüö\+ -]*$/ui",$this->description)){
+ $message[]=_("Description contains invalid characters.");
+ }
+
+ if(!empty($this->volume) && preg_match("/^[^a-z0-9\._äüö\+ -]*$/ui",$this->volume)){
+ $message[]=_("Volume contains invalid characters.");
+ }
+
+ if(preg_match("/\|/",$this->path)){
+ $message[]=_("Path contains invalid characters.");
+ }
+
+ if(!empty($this->option) && preg_match("/^[^a-z0-9\._äüö,=\+ -]*$/ui",$this->option)){
+ $message[]=_("Option contains invalid characters.");
+ }
+
+ /* remove a / at the end of the path, we neither need it there nor
+ * do we want to check for it later.
+ */
+ if(substr($this->path, -1, 1) == '/') {
+ $this->path=substr($this->path, 0, -1);
+ }
+
+ $ldap= $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(objectClass=goShareServer)", array("goExportEntry"));
+ while($test = $ldap->fetch()){
+ if($test['dn']==$this->dn)
+ continue;
+ if(isset($test['goExportEntry'])){
+ foreach($test['goExportEntry'] as $entry){
+ $tmp = split("\|",$entry);
+ if($tmp[0] == $this->name){
+ $message[]="Name already in use";
+ }
+ }
+ }
+ }
+ return ($message);
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ /* Everything seems perfect, lets
+ generate an new export Entry
+ */
+
+ $s_return = "";
+
+ $s_return.= $this->name."|";
+ $s_return.= $this->description."|";
+ $s_return.= $this->type."|";
+ $s_return.= $this->charset."|";
+ $s_return.= $this->path."|";
+ $s_return.= $this->option."|";
+ $s_return.= $this->volume;
+
+ return(array($this->name=>$s_return));
+ }
+
+ function should_create_mount() {
+ return $this->create_mount;
+ }
+
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/nfs/servnfs.tpl b/plugins/admin/systems/services/nfs/servnfs.tpl
new file mode 100644
index 000000000..9fb70a5f4
--- /dev/null
+++ b/plugins/admin/systems/services/nfs/servnfs.tpl
@@ -0,0 +1,144 @@
+
{t}Edit share{/t}
+
+
diff --git a/plugins/admin/systems/services/ntp/class_goNtpServer.inc b/plugins/admin/systems/services/ntp/class_goNtpServer.inc
new file mode 100644
index 000000000..b179ae95b
--- /dev/null
+++ b/plugins/admin/systems/services/ntp/class_goNtpServer.inc
@@ -0,0 +1,147 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* This plugin only writes its objectClass */
+ var $objectclasses = array("goNtpServer");
+ var $attributes = array("goTimeSource");
+ var $StatusFlag = "goNtpServerStatus";
+
+ /* This class can't be assigned twice so it conflicts with itsself */
+ var $conflicts = array("goNtpServer");
+
+ var $DisplayName = "";
+ var $dn = NULL;
+ var $goTimeSource = array();
+ var $goNtpServerStatus= "";
+ var $acl;
+ var $cn = "";
+ var $view_logged =FALSE;
+
+ function goNtpServer(&$config,$dn)
+ {
+ goService::goService($config,$dn);
+ $this->DisplayName = _("Time service (NTP)");
+
+ /* Load arrays */
+ $tmp = array();
+ if (isset($this->attrs['goTimeSource'])){
+ for ($i= 0; $i<$this->attrs['goTimeSource']['count']; $i++){
+ $tmp[$this->attrs['goTimeSource'][$i]]= $this->attrs['goTimeSource'][$i];
+ }
+ }
+ $this->goTimeSource= $tmp;
+ }
+
+
+ function execute()
+ {
+ $smarty = get_smarty();
+
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","server/".get_class($this),$this->dn);
+ }
+
+ /* Here we add a new entry */
+ if(isset($_POST['NewNTPAdd']) && $_POST['NewNTPExport'] != "" && $this->acl_is_writeable("goTimeSource")) {
+ $this->goTimeSource[$_POST['NewNTPExport']]= $_POST['NewNTPExport'];
+ asort($this->goTimeSource);
+ }
+
+ /* Deleting an Entry, is a bit more complicated than adding one*/
+ if((isset($_POST['DelNTPEnt'])) && (isset($_POST['goTimeSource'])) && $this->acl_is_writeable("goTimeSource")) {
+ foreach ($_POST['goTimeSource'] as $entry){
+ if (isset($this->goTimeSource[$entry])){
+ unset($this->goTimeSource[$entry]);
+ }
+ }
+ }
+
+ $smarty->assign("goNtpServerACL", $this->getacl("goNtpServer")) ;
+ $smarty->assign("goTimeSource" , $this->goTimeSource);
+ return($smarty->fetch(get_template_path("goNtpServer.tpl",TRUE,dirname(__FILE__))));
+ }
+
+
+ function getListEntry()
+ {
+ $fields = goService::getListEntry();
+ $fields['Message'] = _("Time service (NTP)");
+ $fields['AllowEdit'] = true;
+ return($fields);
+ }
+
+
+ function save()
+ {
+ plugin::save();
+ $this->attrs['goTimeSource'] =array();
+ foreach($this->goTimeSource as $entry){
+ $this->attrs['goTimeSource'][] = $entry;
+ }
+ /* Check if this is a new entry ... add/modify */
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cat($this->dn,array("objectClass"));
+ if($ldap->count()){
+ $ldap->cd($this->dn);
+ $ldap->modify($this->attrs);
+ }else{
+ $ldap->cd($this->dn);
+ $ldap->add($this->attrs);
+ }
+ show_ldap_error($ldap->get_error(), sprintf(_("Saving server services/goNtpServer with dn '%s' failed."),$this->dn));
+ if($this->initially_was_account){
+ $this->handle_post_events("modify");
+ new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }else{
+ $this->handle_post_events("add");
+ new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }
+ }
+
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Time service"),
+ "plDescription" => _("Time service - NTP")." ("._("Services").")",
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 91,
+ "plSection" => array("administration"),
+ "plCategory" => array("server"),
+
+ "plProvidedAcls"=> array(
+ "goTimeSource" =>_("Ntp source"))
+ ));
+ }
+
+
+ function PrepareForCopyPaste($source)
+ {
+ plugin::PrepareForCopyPaste($source);
+
+ /* Load arrays */
+ $tmp = array();
+ if (isset($source['goTimeSource'])){
+ for ($i= 0; $i<$source['goTimeSource']['count']; $i++){
+ $tmp[$source['goTimeSource'][$i]]= $source['goTimeSource'][$i];
+ }
+ }
+ $this->goTimeSource= $tmp;
+
+
+ }
+
+ function check(){ return array();}
+
+ function save_object(){;}
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/ntp/goNtpServer.tpl b/plugins/admin/systems/services/ntp/goNtpServer.tpl
new file mode 100644
index 000000000..25a91d432
--- /dev/null
+++ b/plugins/admin/systems/services/ntp/goNtpServer.tpl
@@ -0,0 +1,32 @@
+
+
{t}Time server{/t}
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/repository/class_servRepository.inc b/plugins/admin/systems/services/repository/class_servRepository.inc
new file mode 100644
index 000000000..10321c024
--- /dev/null
+++ b/plugins/admin/systems/services/repository/class_servRepository.inc
@@ -0,0 +1,366 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ // var $ignore_account = TRUE;
+ var $attributes = array("FAIrepository");
+ var $objectclasses = array("FAIrepositoryServer");
+
+ /* Repositories */
+ var $repositories = array();
+ var $FAIrepository = array();
+ var $conflicts = array("FAIrepositoryServer");
+ var $DisplayName = "";
+ var $StatusFlag = "";
+
+ var $view_logged = FALSE;
+ var $fai_activated = FALSE;
+
+ var $divlist = NULL;
+
+ function servrepository (&$config, $dn= NULL, $parent= NULL)
+ {
+ plugin::plugin ($config, $dn, $parent);
+
+ $this->DisplayName = _("Repository service");
+
+ /* Skip this if fai is deactivated */
+ $tmp= $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
+ if(!empty($tmp)){
+ $this->fai_activated = TRUE;
+ }else{
+ return;
+ }
+
+ $this->repositories = array();
+ if(isset($this->attrs['FAIrepository'])){
+ for($i = 0; $i < $this->attrs['FAIrepository']['count']; $i++){
+ $tmp = split("\|",$this->attrs['FAIrepository'][$i]);
+ $tmp2 = array();
+ $tmp3 = array();
+
+ if(isset($tmp[1])){
+ $tmp2['ParentServer'] = $tmp[1];
+ if(empty($tmp[1])){
+ $tmp2['ParentServer'] = "none";
+ }
+ }else{
+ $tmp2['ParentServer'] = "none";
+ }
+
+ if(isset($tmp[0])){
+ $tmp2['Url'] = $tmp[0];
+ }else{
+ $tmp2['Url'] = "";
+ }
+
+ if(isset($tmp[2])){
+ $tmp2['Release'] = $tmp[2];
+ }else{
+ $tmp2['Release'] = "";
+ }
+
+ if(isset($tmp[3])){
+ $tmp3 = split(",",$tmp[3]);
+ foreach($tmp3 as $sec){
+ $tmp2['Sections'][$sec]=$sec;
+ }
+ }else{
+ $tmp['Section']=array();
+ }
+
+ $this->repositories[$tmp[2]]=$tmp2;
+ }
+ }
+
+
+ /* Create divlist */
+ $this->divlist = new divListRepository($this->config,$this);
+ }
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","server/".get_class($this),$this->dn);
+ }
+
+ if(!$this->fai_activated){
+ $str = "
"._("You can't use this plugin until FAI is activated.")." ";
+ return $str;
+ }
+
+ /* Fill templating stuff */
+ $smarty= get_smarty();
+ $smarty->assign("is_createable",$this->acl_is_createable());
+ $display= "";
+
+ /* Show tab dialog headers */
+ /*
+ ADD / EDIT Repository
+ Dialog Handling
+ */
+ $once = false;
+ if(isset($_POST['servRepository'])){
+ foreach($_POST as $name => $value){
+
+ if(preg_match("/AddRepository/",$name) && $this->acl_is_createable()){
+ $once = true;
+ $this->dialog = new servRepositorySetup($this->config,$this->dn);
+ $this->dialog->parent = $this;
+ }
+
+ if((preg_match("/^delete_/",$name)) && (!$once) && $this->acl_is_removeable()){
+ $once = true;
+ $value = preg_replace("/delete_/","",$name);
+ $value = base64_decode(preg_replace("/_.*$/","",$value));
+
+ $url = $this->repositories[$value]['Url'];
+ $release = $this->repositories[$value]['Release'];
+
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd ($this->config->current['BASE']);
+
+ $ldap->search("(&(objectClass=gotoWorkstation)(objectClass=FAIobject)(FAIdebianMirror=".$url."))",array("cn","FAIclass"));
+
+ $found = false;
+ $found_in = " ";
+ while($attrs = $ldap->fetch()){
+ foreach($attrs['FAIclass'] as $class){
+ if(preg_match("/".str_replace("/","\/",$release)."$/i",$class)){
+ $found = true;
+ $found_in .= $attrs['cn'][0]." ";
+ }
+ }
+ }
+
+ if($found){
+ print_red(sprintf(_("You can't delete this release, it is still used by these workstations [%s]. Please solve this dependencies first, to keep data base consistency."),$found_in));
+ }else{
+ if(isset($this->repositories[$value])){
+ unset($this->repositories[$value]);
+ }
+ }
+ }
+
+ if((preg_match("/^edit_/",$name))&&(!$once)){
+ $value = preg_replace("/edit_/","",$name);
+ $value = base64_decode(preg_replace("/_.$/","",$value));
+
+ if(isset($this->repositories[$value])){
+
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd ($this->config->current['BASE']);
+
+ $url = $this->repositories[$value]['Url'];
+ $release = $this->repositories[$value]['Release'];
+
+ $ldap->search("(&(objectClass=gotoWorkstation)(objectClass=FAIobject)(FAIdebianMirror=".$url."))",array("cn","FAIclass"));
+
+ $found = false;
+ $found_in = " ";
+ while($attrs = $ldap->fetch()){
+ foreach($attrs['FAIclass'] as $class){
+ if(preg_match("/".str_replace("/","\/",$release)."$/i",$class)){
+ $found = true;
+ $found_in .= $attrs['cn'][0]." ";
+ }
+ }
+ }
+
+ if($found){
+ print_red(sprintf(_("Be careful editing this release, it is still used by these workstations [%s]."),$found_in));
+ }
+
+ if(isset($this->repositories[$value])){
+ $once = true;
+ $obj = $this->repositories[$value];
+
+ /* to be able to detect if this was renamed */
+ $obj['initialy_was'] = $obj['Release'];
+ $this->dialog = new servRepositorySetup($this->config,$this->dn,$obj);
+ $this->dialog->parent = $this;
+ }
+ }
+ }
+ }
+ }
+ if((isset($_GET['act']))&&($_GET['act']=="open_repository")&&(isset($_GET['id']))){
+ $obj = $this->repositories[base64_decode($_GET['id'])];
+ $obj['initialy_was'] = $obj['Release'];
+ $this->dialog = new servRepositorySetup($this->config,$this->dn,$obj);
+ $this->dialog->parent = $this;
+ }
+
+ if(isset($_POST['repository_setup_save']) && is_object($this->dialog)){
+ $this->dialog->save_object();
+ if(($this->dialog->is_new_name())&&(isset($this->repositories[$this->dialog->GetName()]))){
+ print_red(_("This name is already in use."));
+ }else
+
+ if(count($this->dialog->check())!=0){
+ foreach($this->dialog->check() as $msg){
+ print_red($msg);
+ }
+ }else{
+ $obj = $this->dialog->save();
+ if($this->dialog->is_new_name()){
+ $oldname = $this->dialog->initialy_was;
+ $this->repositories[$obj['Release']]=$obj;
+ unset($this->repositories[$oldname]);
+ }else{
+ $this->repositories[$obj['Release']]=$obj;
+ }
+ $this->dialog = FALSE;
+ $this->is_dialog= false;
+ }
+ }
+
+ if(isset($_POST['repository_setup_cancel'])){
+ $this->dialog=FALSE;
+ $this->is_dialog = false;
+ }
+
+ if(is_object($this->dialog)){
+ $this->dialog->save_object();
+ $this->is_dialog = true;
+ return($this->dialog->execute());
+ }
+
+ /*
+ Repository setup dialog handling /END
+ */
+
+
+ $link = "
%s ";
+ $edit = "
";
+
+ /* Hide delete icon, if delete is not allowed */
+ if($this->acl_is_removeable()){
+ $delete = "
";
+ }else{
+ $delete = "
";
+ }
+
+ $this->divlist->execute();
+ $this->divlist->setEntries($this->repositories);
+ $smarty->assign("Repositories",$this->divlist->Draw());
+ $display.= $smarty->fetch(get_template_path('servRepository.tpl', TRUE));
+ return($display);
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ plugin::save_object();
+ if(is_object($this->divlist)){
+ $this->divlist->save_object();
+ }
+ }
+
+
+ /* Check supplied data */
+ function check()
+ {
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+ return ($message);
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ if(!$this->fai_activated) return;
+
+ plugin::save();
+
+ $arr = array();
+ foreach($this->repositories as $servername => $conf){
+ $str = "";
+ foreach($conf['Sections'] as $sec){
+ $str.=$sec.",";
+ }
+ $str=preg_replace("/,$/","",$str);
+
+ if($conf['ParentServer']=="none"){
+ $conf['ParentServer'] ="";
+ }
+
+ $arr[]=$conf['Url']."|".$conf['ParentServer']."|".$conf['Release']."|".$str;
+ }
+ $this->attrs['FAIrepository'] = $arr;
+
+ $ldap= $this->config->get_ldap_link();
+ $ldap->cd ($this->config->current['BASE']);
+
+ $ldap->cat($this->dn, array('dn'));
+
+ if($ldap->count()){
+ $ldap->cd($this->dn);
+ $this->cleanup();
+ $ldap->modify ($this->attrs);
+
+ $this->handle_post_events("modify");
+ }else{
+ $ldap->cd ($this->config->current['BASE']);
+ $ldap->create_missing_trees($this->dn);
+ $ldap->cd($this->dn);
+ $ldap->add($this->attrs);
+ $this->handle_post_events("add");
+ }
+
+ if($this->initially_was_account){
+ new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }else{
+ new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }
+ }
+
+
+ function getListEntry()
+ {
+ $fields = goService::getListEntry();
+ $fields['Message'] = _("Repository service");
+ $fields['AllowEdit'] = true;
+ $fields['AllowStart'] = $fields['AllowStop'] = $fields['AllowRestart'] = false;
+ return($fields);
+ }
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Repository"),
+ "plDescription" => _("Repository service")." ("._("Services").")",
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 84,
+ "plSection" => array("administration"),
+ "plCategory" => array("server"),
+
+ "plProvidedAcls"=> array(
+ "cn" => _("Name"),
+ "start" => _("Start"),
+ "stop" => _("Stop"),
+ "restart" => _("Restart"),
+ "Release" => _("Releases"),
+ "Section" => _("Sections"),
+ "ParentServer" => _("Parent server"),
+ "Url" => _("Url"))
+ ));
+ }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/repository/class_servRepositorySetup.inc b/plugins/admin/systems/services/repository/class_servRepositorySetup.inc
new file mode 100644
index 000000000..40f37b062
--- /dev/null
+++ b/plugins/admin/systems/services/repository/class_servRepositorySetup.inc
@@ -0,0 +1,225 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account = TRUE;
+ var $attributes = array("Release","ParentServer","Url","cn");
+ var $objectclasses = array("whatever");
+
+ /* Attributes */
+ var $Release = "";
+ var $ParentServer = "";
+ var $Url = "";
+ var $Sections = array();
+ var $ParentServers = "";
+ var $initialy_was = false;
+ var $cn = "";
+ var $parent = "";
+
+ function servRepositorySetup (&$config, $dn= NULL,$data = false)
+ {
+ plugin::plugin ($config, $dn);
+ if($data != false){
+ foreach(array("Sections","Release","Url","ParentServer","initialy_was") as $atr){
+ if(isset($data[$atr])){
+ $this->$atr = $data[$atr];
+ }
+ }
+ }
+ }
+
+ function GetName()
+ {
+ return($this->Release);
+ }
+
+ function is_new_name()
+ {
+ if(!$this->initialy_was){
+ return(true);
+ }else{
+ if($this->Release != $this->initialy_was){
+ return(true);
+ }
+ }
+ return(false);
+ }
+
+
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ /* Fill templating stuff */
+ $smarty= get_smarty();
+
+ if((isset($_POST['AddSection']))&&(isset($_POST['SectionName']))&&(!empty($_POST['SectionName']))){
+
+ /* Replace multiple spaces with a single, and cut of white spaces (trim)*/
+ $val = preg_replace("/\ \ * /" , " ", trim($_POST['SectionName']));
+
+ /* check if there are more than one entry given ( "section1 section2 )*/
+ if(preg_match("/ /",$val)){
+
+ /* Generate list of new section names */
+ $vals = split(" ",$val);
+
+ /* Add new entries */
+ foreach($vals as $entry){
+ $entry = trim($entry);
+ $this->Sections[$entry]=$entry;
+ }
+ }else{
+ $this->Sections[$val]=$val;
+ }
+ }
+
+ foreach($_POST as $name => $value){
+ if(preg_match("/^delete_/",$name)){
+
+ $val = preg_replace("/^delete_/","",$name);
+ $val = base64_decode(preg_replace("/_.*$/","",$val));
+
+ if(isset($this->Sections[$val])){
+ unset($this->Sections[$val]);
+ }
+ }
+ }
+
+ $divlist = new divSelectBox("servRepositorySetup");
+ $divlist->setHeight("220");
+
+ $dellink = "
";
+
+ foreach($this->Sections as $sec){
+ $divlist->AddEntry(array(
+ array("string"=>$sec),
+ array("string"=>sprintf($dellink,base64_encode($sec),$sec),"attach"=>"style='border-right:0px;width:20px;'")
+ ));
+ }
+
+ $smarty->assign("Sections",$divlist->DrawList());
+
+ /* Get && assign acls */
+ $tmp = $this->parent->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translated){
+ $smarty->assign($name."ACL",$this->parent->getacl($name));
+ }
+
+ /* Assign values */
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr ,$this->$attr);
+ }
+
+ $tmp = $this->getParentServers();
+ $smarty->assign("ParentServers" ,$tmp);
+ $smarty->assign("ParentServerKeys",array_flip($tmp));
+
+ return($smarty->fetch(get_template_path('servRepositorySetup.tpl', TRUE)));
+ }
+
+ /* Save data to object */
+ function save_object()
+ {
+ if(isset($_POST['servRepositorySetup_Posted'])) {
+
+ foreach($this->attributes as $attr){
+ if(($this->parent->acl_is_writeable($attr)) && (isset($_POST[$attr]))){
+ $this->$attr = $_POST[$attr];
+ }
+ }
+ }
+ }
+
+
+ /* Check supplied data */
+ function check()
+ {
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+
+ if(empty($this->Release)){
+ $message[]=_("Please enter a value for 'release'.");
+ }
+
+ if(empty($this->Url)){
+ $message[] = _("Please specify a valid value for 'url'.");
+ }
+
+ return ($message);
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ $tmp = array();
+ $tmp['ParentServer'] = $this->ParentServer;
+ $tmp['Url'] = $this->Url;
+ $tmp['Release'] = $this->Release;
+ $tmp['Sections'] = $this->Sections;
+ return($tmp);
+ }
+
+ function getParentServers()
+ {
+ $ret = array();
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(objectClass=FAIrepositoryServer)",array("*"));
+ while($attr = $ldap->fetch()){
+ if($attr['cn'][0] == $this->cn) continue;
+ $ret[$attr['cn'][0]]= $attr['cn'][0];
+ }
+
+ $ret = array_merge($ret,$this->GetHookElements());
+
+ $ret['none']= " ";
+ asort($ret);
+ return($ret);
+ }
+
+ /* this funtions calls a defined hook
+ and parses all additional serverdata
+ */
+ function GetHookElements()
+ {
+ $ret = array();
+ $cmd = $this->config->search("servrepository", "REPOSITORY_HOOK",array('tabs'));
+ if(!empty($cmd)){
+ $res = shell_exec($cmd);
+ $res2 = trim($res);
+ if(!$res){
+ print_red(sprintf(_("Can't execute specified REPOSITORY_HOOK '%s'. Please check your gosa.conf."),$cmd));
+ }elseif(empty($res2)){
+ print_red(sprintf(_("The specified REPOSITORY_HOOK '%s', specified in your gosa.conf, returns an empty string."),$cmd));
+ }else{
+ $tmp = split("\n",$res);
+ foreach($tmp as $hook){
+ /* skip empty */
+ if(empty($hook)) continue;
+
+ if(preg_match("/;/",$hook)){
+ $hookinfo = split(";",$hook);
+ $ret[$hookinfo[0]] = $hookinfo[0];
+ }else{
+ $ret[$hook] = $hook;
+ }
+ }
+ }
+ }
+ return($ret);
+ }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/repository/servRepository.tpl b/plugins/admin/systems/services/repository/servRepository.tpl
new file mode 100644
index 000000000..ca42710c1
--- /dev/null
+++ b/plugins/admin/systems/services/repository/servRepository.tpl
@@ -0,0 +1,9 @@
+{$Repositories}
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/repository/servRepositorySetup.tpl b/plugins/admin/systems/services/repository/servRepositorySetup.tpl
new file mode 100644
index 000000000..29691ec44
--- /dev/null
+++ b/plugins/admin/systems/services/repository/servRepositorySetup.tpl
@@ -0,0 +1,58 @@
+
{t}Repository{/t}
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/shares/class_goShareServer.inc b/plugins/admin/systems/services/shares/class_goShareServer.inc
new file mode 100644
index 000000000..354d78037
--- /dev/null
+++ b/plugins/admin/systems/services/shares/class_goShareServer.inc
@@ -0,0 +1,409 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* This plugin only writes its objectClass */
+ var $objectclasses = array("goShareServer");
+ var $attributes = array("goExportEntry");
+ var $StatusFlag = "goShareServerStatus";
+
+ /* This class can't be assigned twice so it conflicts with itsself */
+ var $conflicts = array("goShareServer");
+
+ var $DisplayName = "";
+ var $dn = NULL;
+ var $cn = "";
+ var $goShareServerStatus = "";
+ var $goExportEntry = array();
+ var $allow_mounts = false;
+ var $mounts_to_remove = array();
+ var $mounts_to_add = array();
+ var $view_logged =FALSE;
+
+ function goShareServer(&$config,$dn)
+ {
+ goService::goService($config,$dn);
+
+ $this->DisplayName = _("File service");
+
+ $tmp =array();
+ if(isset($this->attrs['goExportEntry'])){
+ if(isset($this->attrs['goExportEntry']['count'])){
+ for($i= 0; $i<$this->attrs['goExportEntry']['count']; $i++){
+ $entry= $this->attrs['goExportEntry'][$i];
+ $tmp[preg_replace('/\|.*$/', '', $entry)]= $entry;
+ }
+ }
+ }
+ $this->goExportEntryList = $tmp;
+
+ $ldap = $this->config->get_ldap_link();
+ $avl_objectclasses = $ldap->get_objectclasses();
+ if (isset($avl_objectclasses["mount"])) {
+ $this->allow_mounts = true;
+ }
+ }
+
+
+ function execute()
+ {
+ $smarty = get_smarty();
+
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","server/".get_class($this),$this->dn);
+ }
+
+
+ if((isset($_POST['DelNfsEnt']))&&(isset($_POST['goExportEntryList'])) && ($this->acl_is_writeable("name"))){
+ if($this->allow_mounts){
+ foreach($_POST['goExportEntryList'] as $entry){
+ $this->deleteFromMountList($this->goExportEntryList[$entry]);
+ }
+ }
+ foreach($_POST['goExportEntryList'] as $entry){
+ $this->deleteFromList($entry);
+ }
+ }
+
+ if(isset($_POST['NewNfsAdd']) && ($this->acl_is_writeable("name"))){
+ $this->oldone = NULL;
+ $this->o_subWindow = new servnfs($this->config, $this);
+ $this->o_subWindow->set_acl_category("server");
+ $this->o_subWindow->set_acl_base($this->dn);
+ $this->dialog = true;
+ }
+
+ if((isset($_POST['NewNfsEdit']))&&(isset($_POST['goExportEntryList']))){
+ $entry = $this->goExportEntryList[$_POST['goExportEntryList'][0]];
+ $add_mount=isset($this->mounts_to_add[$entry]);
+ $this->oldone=$entry;
+ $this->o_subWindow = new servnfs($this->config,$this,$entry,$add_mount);
+ $this->o_subWindow->set_acl_base($this->dn);
+ $this->o_subWindow->set_acl_category("server");
+ $this->dialog = true;
+ }
+ if(isset($this->o_subWindow)){
+ $this->o_subWindow->save_object(TRUE);
+ }
+
+ /* Save NFS setup */
+ if(isset($_POST['NFSsave']) && isset($this->o_subWindow) && is_object($this->o_subWindow)){
+ if(count($this->o_subWindow->check())>0){
+ foreach($this->o_subWindow->check() as $msg) {
+ print_red($msg);
+ }
+ }else{
+ $this->o_subWindow->save_object();
+ $newone = $this->o_subWindow->save();
+
+ $this->addToList($newone);
+ if($this->allow_mounts){
+ if($this->oldone != NULL) {
+ $this->deleteFromMountList($this->oldone);
+ }
+ if ($this->o_subWindow->should_create_mount()) {
+ $this->addToMountList($newone);
+ }
+ }
+ unset($this->o_subWindow);
+ $this->dialog = false;
+ }
+ }
+
+ /* Cancel NFS setup */
+ if(isset($_POST['NFScancel'])){
+ $this->oldone = NULL;
+ unset($this->o_subWindow);
+ $this->dialog = false;
+ }
+
+ /* Execute NFS setup dialog*/
+ if(isset($this->o_subWindow)){
+ return $this->o_subWindow->execute();
+ }
+
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,$this->$attr);
+ }
+
+ /* Set acls */
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translated){
+ $smarty->assign($name."ACL",$this->getacl($name));
+ }
+ $smarty->assign("createable",$this->acl_is_createable());
+ $smarty->assign("removeable",$this->acl_is_removeable());
+
+ $tellSmarty= array();
+ ksort($this->goExportEntryList);
+ foreach($this->goExportEntryList as $name=>$values){
+ $tmp = split("\|",$values);
+ $tellSmarty[$name] = $tmp[0]." ".$tmp[4]." (".$tmp[2].")";
+ }
+ $smarty->assign("goExportEntry",array_keys($tellSmarty));
+ $smarty->assign("goExportEntryKeys",($tellSmarty));
+ return($smarty->fetch(get_template_path("goShareServer.tpl",TRUE,dirname(__FILE__))));
+ }
+
+
+ function getListEntry()
+ {
+ $fields = goService::getListEntry();
+ $fields['Message'] = _("File service (Shares)");
+ $fields['AllowEdit'] = true;
+ return($fields);
+ }
+
+
+ function save()
+ {
+ plugin::save();
+
+ /* Arrays */
+ foreach (array("goExportEntryList"=>"goExportEntry") as $source => $destination){
+ $this->attrs[$destination]= array();
+ foreach ($this->$source as $element){
+ $this->attrs[$destination][]= $element;
+ }
+ }
+
+
+ /* Process netatalk mounts */
+ if($this->allow_mounts) {
+ $this->process_mounts();
+ }
+
+ /* Check if this is a new entry ... add/modify */
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cat($this->dn,array("objectClass"));
+ if($ldap->count()){
+ $ldap->cd($this->dn);
+ $ldap->modify($this->attrs);
+ }else{
+ $ldap->cd($this->dn);
+ $ldap->add($this->attrs);
+ }
+ show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/shares with dn '%s' failed."),$this->dn));
+ if($this->initially_was_account){
+ $this->handle_post_events("modify");
+ new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }else{
+ $this->handle_post_events("add");
+ new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }
+ }
+
+
+ function check()
+ {
+ $message = plugin::check();
+ return($message);
+ }
+
+
+ function save_object()
+ {
+ if(isset($_POST['goShareServerPosted'])){
+ plugin::save_object();
+ }
+ }
+
+ function addToList($entry){
+ $key = key($entry);
+ $this->goExportEntryList[$key]=$entry[$key];
+ }
+
+ function deleteFromList($id)
+ {
+ /* Check if the share is used by someone */
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(|(gotoProfileServer=*|$id)(gotoShare=*|$id|*||*))", array("cn"));
+ $cnt= $ldap->count();
+ if ($cnt){
+ $msg= sprintf(_("The share can't be removed since it is still used by %d users:"), $cnt);
+ $msg.= "
";
+ while ($attrs= $ldap->fetch()){
+ $msg.= "".$attrs["cn"][0]." ";
+ }
+ $msg.= " "._("Please correct the share-/profile settings of these users");
+ print_red($msg);
+
+ } else {
+ /* Finally remove it */
+ unset($this->goExportEntryList[$id]);
+ }
+ }
+
+ function process_mounts() {
+
+ $clip = "cn=" . $this->cn . ",ou=servers,ou=systems,";
+ $mountsdn = "cn=mounts," . substr($this->dn, strlen($clip));
+
+ $mounts = array(
+ "objectClass" => "container",
+ "cn" => "mounts"
+ );
+
+ # load data from mounts container
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cat($mountsdn, array('dn'));
+ $attrs = $ldap->fetch();
+
+ # mounts container not present yet, so we create it
+ if (count($attrs) == 0) {
+ $ldap->cd($mountsdn);
+ $ldap->add($mounts);
+ show_ldap_error($ldap->get_error(), sprintf(_("Creating system server/shares (mount container) with dn '%s' failed."),$this->dn));
+ new log("modify","server/".get_class($this),$mountsdn,array_keys($mounts),$ldap->get_error());
+ }
+
+ # remove deleted mounts from the container
+ foreach ($this->mounts_to_remove as $entry) {
+ $mount=$this->returnMountEntry($entry);
+ $mountdn = "cn=".$mount["cn"].","."$mountsdn";
+
+ $ldap->cat($mountdn, array('dn'));
+ $attrs = $ldap->fetch();
+
+ if (count($attrs) != 0) {
+ $ldap->rmdir($mountdn);
+ show_ldap_error($ldap->get_error(), sprintf(_("Removing system server/shares (mount container) with dn '%s' failed."),$this->dn));
+ new log("remove","server/".get_class($this),$mountdn,array_keys($mount),$ldap->get_error());
+ }
+ }
+
+ # add new mounts to the container
+ foreach ($this->mounts_to_add as $entry) {
+ $mount=$this->returnMountEntry($entry);
+ $mountdn = "cn=".$mount["cn"].","."$mountsdn";
+ $ldap->cd($mountdn);
+ $ldap->add($mount);
+ show_ldap_error($ldap->get_error(), sprintf(_("Saving system server/shares (mount container) with dn '%s' failed."),$this->dn));
+ new log("create","server/".get_class($this),$mountdn,array_keys($mount),$ldap->get_error());
+ }
+ }
+
+ function addToMountList($entry)
+ {
+ if($this->acl_is_writeable("name")){
+ $key = key($entry);
+ $type = $this->get_share_type($entry[$key]);
+ if (($type == "netatalk") || ($type == "NFS")) {
+ $this->mounts_to_add[$entry[$key]] = $entry[$key];
+ unset($this->mounts_to_remove[$entry[$key]]);
+ }
+ }
+ }
+
+ function deleteFromMountList($entry)
+ {
+ if($this->acl_is_writeable("name")){
+ $type = $this->get_share_type($entry);
+ if (($type == "netatalk") || ($type == "NFS")) {
+ $this->mounts_to_remove[$entry] = $entry;
+ unset($this->mounts_to_add[$entry]);
+ }
+ }
+ }
+
+ function get_share_type($share)
+ {
+ $tmp = split("\|", $share);
+ return $tmp[2];
+ }
+
+ function returnMountEntry($entry)
+ {
+ $item = split("\|", $entry);
+ $name = $item[0];
+ $description = $item[1];
+ $type = $item[2];
+ $charset = $item[3];
+ $path = $item[4];
+ $options = $item[5];
+
+ switch ($type) {
+ case "netatalk" : {
+ $mount = array(
+ "mountDirectory" => "/Network/Servers/",
+ "mountOption" => array(
+ "net",
+ "url==afp://;AUTH=NO%20USER%20AUTHENT@".$this->cn."/$name/"
+ ),
+ "mountType" => "url",
+ "objectClass" => "mount",
+ "cn" => $this->cn .":/".$name
+ );
+ break;
+ }
+ case "NFS" : {
+ $mount = array(
+ "mountDirectory" => "/Network/Servers/",
+ "mountOption" => "net",
+ "mountType" => "nfs",
+ "objectClass" => "mount",
+ "cn" => $this->cn .":".$path
+ );
+ break;
+ }
+ default : {
+ continue;
+ }
+ }
+ return $mount;
+ }
+
+
+ function PrepareForCopyPaste($source)
+ {
+ plugin::PrepareForCopyPaste($source);
+
+ $tmp =array();
+ if(isset($source['goExportEntry'])){
+ if(isset($source['goExportEntry']['count'])){
+ for($i= 0; $i<$source['goExportEntry']['count']; $i++){
+ $entry= $source['goExportEntry'][$i];
+ $tmp[preg_replace('/\|.*$/', '', $entry)]= $entry;
+ }
+ }
+ }
+ $this->goExportEntryList = $tmp;
+ $this->goExportEntry = $tmp;
+ }
+
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("File service (Shares)"),
+ "plDescription" => _("File service - Shares")." ("._("Services").")",
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 90,
+ "plSection" => array("administration"),
+ "plCategory" => array("server"),
+
+ "plProvidedAcls"=> array(
+ "name" => _("Name"),
+ "netatalkmount" => _("Apple mounts"),
+ "description" => _("Description"),
+ "type" => _("Type"),
+ "charset" => _("Charset"),
+ "path" => _("Path"),
+ "option" => _("Option"),
+ "volume" => _("Volume"))
+
+ ));
+ }
+
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/shares/goShareServer.tpl b/plugins/admin/systems/services/shares/goShareServer.tpl
new file mode 100644
index 000000000..2c645c7f4
--- /dev/null
+++ b/plugins/admin/systems/services/shares/goShareServer.tpl
@@ -0,0 +1,33 @@
+
{t}Shares{/t}
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/spam/class_goSpamServer.inc b/plugins/admin/systems/services/spam/class_goSpamServer.inc
new file mode 100644
index 000000000..82ff0fbaf
--- /dev/null
+++ b/plugins/admin/systems/services/spam/class_goSpamServer.inc
@@ -0,0 +1,357 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* This plugin only writes its objectClass */
+ var $objectclasses = array("goSpamServer");
+ var $attributes = array("saRewriteHeader","saTrustedNetworks","saRequiredScore","saFlags","saRule");
+ var $StatusFlag = "saStatus";
+
+ /* This class can't be assigned twice so it conflicts with itsself */
+ var $conflicts = array("goSpamServer");
+ var $Flags = array("B","b","C","R","D","P");
+
+ var $DisplayName = "";
+ var $dn = NULL;
+ var $cn = "";
+ var $saStatus = "";
+
+ var $saRewriteHeader = "";
+ var $saTrustedNetworks= array();
+ var $TrustedNetworks = array();
+ var $saRequiredScore = 0;
+ var $saFlags = "";
+ var $Rules = array();
+ var $saRule = array();
+
+ var $saFlagsB = false;
+ var $saFlagsb = false;
+ var $saFlagsC = false;
+ var $saFlagsR = false;
+ var $saFlagsD = false;
+ var $saFlagsP = false;
+
+ var $ui = NULL;
+ var $acl = NULL;
+ var $view_logged =FALSE;
+
+ function gospamserver(&$config,$dn, $parent= NULL)
+ {
+ /* Init class */
+ goService::goService($config,$dn, $parent);
+ $this->DisplayName = _("Spamassassin");
+
+ /* Get userinfo & acls */
+ $this->ui = get_userinfo();
+
+ /* Get Flags */
+ foreach($this->Flags as $flag){
+ $var = "saFlags".$flag;
+ if(preg_match("/".$flag."/",$this->saFlags)){
+ $this->$var = TRUE;
+ }
+ }
+
+ /* Get trusted networks */
+ $this->TrustedNetworks = array();
+ if(isset($this->attrs['saTrustedNetworks']) && is_array($this->attrs['saTrustedNetworks'])){
+ $var = $this->attrs['saTrustedNetworks'];
+ for($i = 0 ; $i < $var['count'] ; $i ++ ){
+ $var2 = $this->attrs['saTrustedNetworks'][$i];
+ $this->TrustedNetworks[ $var2 ] = $var2;
+ }
+ }
+
+ /* Get rules */
+ $this->Rules = array();
+ if(isset($this->attrs['saRule']) && is_array($this->attrs['saRule'])){
+ $var = $this->attrs['saRule'];
+ for($i = 0 ; $i < $var['count'] ; $i ++ ){
+ $var2 = $this->attrs['saRule'][$i];
+ $name = preg_replace("/:.*$/","",$var2);
+ $value= base64_decode(preg_replace("/^.*:/","",$var2));
+ $this->Rules[ $name ] = $value;
+ }
+ }
+ }
+
+
+ function execute()
+ {
+ $display ="";
+ $smarty = get_smarty();
+
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","server/".get_class($this),$this->dn);
+ }
+
+ /* If displayed, it is ever true*/
+ $this->is_account =true;
+
+ /* Get acls */
+ $tmp = $this->plinfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translation){
+ $smarty->assign($name."ACL",$this->getacl($name));
+ }
+
+ /* Add new trusted network */
+ if(isset($_POST['AddNewTrust']) && ($this->acl_is_writeable("saTrustedNetworks"))){
+ $this->AddTrust($_POST['NewTrustName']);
+ }
+
+ /* Delete selected trusted network */
+ if(isset($_POST['DelTrust']) && ($this->acl_is_writeable("saTrustedNetworks"))){
+ $this->DelTrust($_POST['TrustedNetworks']);
+ }
+
+ /* Add a new rule */
+ if(isset($_POST['AddRule']) && $this->acl_is_writeable("saRule")){
+ $this->dialog = new goSpamServerRule($this->config,$this->dn);
+ }
+
+ /* Cancel adding/editing specified rule */
+ if(isset($_POST['CancelRule'])){
+ $this->dialog = FALSE;
+ }
+
+ /* Handle post to delete rules */
+ $once = true;
+ foreach($_POST as $name => $value){
+ if(preg_match("/^editRule_/",$name) && $once && $this->acl_is_readable("saRule")){
+ $once = false;
+ $entry = preg_replace("/^editRule_/","",$name);
+ $entry = preg_replace("/_(x|y)$/","",$entry);
+ $rule = $this->Rules[$entry];
+ $name = $entry;
+ $this->dialog = new goSpamServerRule($this->config,$this->dn,$name,$rule);
+ }
+ if(preg_match("/^delRule_/",$name) && $once && $this->acl_is_writeable("saRule")){
+ $once = false;
+ $entry = preg_replace("/^delRule_/","",$name);
+ $entry = preg_replace("/_(x|y)$/","",$entry);
+ unset($this->Rules[$entry]);
+ }
+ }
+
+ /* Save rules */
+ if(isset($_POST['SaveRule'])){
+ $this->dialog->save_object();
+ $msgs = $this->dialog->check();
+ if(count($msgs)){
+ foreach($msgs as $msg){
+ print_red($msg);
+ }
+ }elseif($this->acl_is_writeable("saRule")){
+ $ret = $this->dialog->save();
+ if((!empty($ret['orig_name'])) && isset($this->Rules[$ret['orig_name']])){
+ unset($this->Rules[$ret['orig_name']]);
+ }
+ $this->Rules[$ret['name']] = $ret['rule'];
+ $this->dialog = FALSE;
+ }
+ }
+
+ /* Display dialog if available */
+ if($this->dialog && $this->dialog->config){
+ $this->dialog->save_object();
+ return($this->dialog->execute());
+ }
+
+ /* Assign smarty vars */
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,$this->$attr);
+ }
+
+ /* Assign checkbox states */
+ foreach($this->Flags as $Flag){
+ $var = "saFlags".$Flag;
+ $smarty->assign("saFlags".$Flag."ACL", $this->getacl($Flag));
+ if($this->$var){
+ $smarty->assign("saFlags".$Flag."CHK"," checked " );
+ }else{
+ $smarty->assign("saFlags".$Flag."CHK","");
+ }
+ }
+
+ /* Create divlist */
+ $DivRules = new divSelectBox("SpamRules");
+ $DivRules->SetHeight(130);
+
+ if($this->acl_is_writeable("saTrustedNetworks")){
+ $actions = "";
+ }else{
+
+ $actions = "
";
+ if($this->acl_is_writeable("saRule")){
+ $actions.= "
";
+ }
+ }
+
+ foreach($this->Rules as $key => $net){
+ $field1 = array("string" => $key );
+ $field2 = array("string" => sprintf($actions,$key,$key) , "attach" => "style='border-right:0px;width:36px;'");
+ $DivRules->AddEntry(array($field1,$field2));
+ }
+ $smarty->assign("divRules",$DivRules->DrawList());
+ $smarty->assign("TrustedNetworks",$this->TrustedNetworks);
+
+ /* Create Spam score select box entries */
+ $tmp = array();
+ for($i = 0 ; $i <= 20 ; $i ++ ){
+ $tmp[$i] = $i;
+ }
+ $smarty->assign("SpamScore",$tmp);
+
+ return($display.$smarty->fetch(get_template_path("goSpamServer.tpl",TRUE,dirname(__FILE__))));
+ }
+
+
+ /* Add $post to list of configured trusted */
+ function AddTrust($post)
+ {
+ if(!empty($post)){
+ if(is_ip($post) || is_domain($post) || (is_ip_with_subnetmask($post))){
+ $this->TrustedNetworks[$post] = $post;
+ }else{
+ print_red(_("Specified value is not a valid 'trusted network' value."));
+ }
+ }
+ }
+
+
+ /* Delete trusted network */
+ function DelTrust($posts)
+ {
+ foreach($posts as $post){
+ if(isset($this->TrustedNetworks[$post])){
+ unset($this->TrustedNetworks[$post]);
+ }
+ }
+ }
+
+ function save()
+ {
+ if(!$this->is_account) return;
+ plugin::save();
+
+ /* Create Flags */
+ $this->attrs['saFlags'] = array();
+ foreach($this->Flags as $flag){
+ $var = "saFlags".$flag;
+ if($this->$var){
+ $this->attrs['saFlags'].=$flag;
+ }
+ }
+
+ /* Create trusted network entries */
+ $this->attrs['saTrustedNetworks'] = array();
+ foreach($this->TrustedNetworks as $net){
+ $this->attrs['saTrustedNetworks'][] = $net;
+ }
+
+ /* Rules */
+ $this->attrs['saRule'] = array();
+ foreach($this->Rules as $name => $rule){
+ $this->attrs['saRule'][] = $name.":".base64_encode($rule);
+ }
+
+ /* Check if this is a new entry ... add/modify */
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cat($this->dn,array("objectClass"));
+ if($ldap->count()){
+ $ldap->cd($this->dn);
+ $ldap->modify($this->attrs);
+ }else{
+ $ldap->cd($this->dn);
+ $ldap->add($this->attrs);
+ }
+ if($this->initially_was_account){
+ $this->handle_post_events("modify");
+ new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }else{
+ $this->handle_post_events("add");
+ new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }
+
+ show_ldap_error($ldap->get_error(), sprintf(_("Saving of server services/spamassassin with dn '%s' failed."),$this->dn));
+ }
+
+ function check()
+ {
+ $message = plugin::check();
+
+ /* Check if required score is numeric */
+ if(!is_numeric($this->saRequiredScore)){
+ $message[] = _("Required score must be a numeric value.");
+ }
+
+ return($message);
+ }
+
+
+ function save_object()
+ {
+ if(isset($_POST['goSpamServer'])){
+
+ plugin::save_object();
+
+ /* Check flags */
+ foreach($this->Flags as $flag){
+ $var = "saFlags".$flag;
+
+ if($this->acl_is_writeable($var)){
+ if(isset($_POST[$var])){
+ $this->$var = TRUE;
+ }else{
+ $this->$var = FALSE;
+ }
+ }
+ }
+ }
+ }
+
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Spamassassin"),
+ "plDescription" => _("Spamassassin")." ("._("Services").")",
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 89,
+ "plSection" => array("administration"),
+ "plCategory" => array("server"),
+ "plProvidedAcls"=> array(
+
+ "saRewriteHeader" => _("Rewrite header"),
+ "saTrustedNetworks" => _("Trusted networks"),
+ "saRequiredScore" => _("Required score"),
+ "saRule" => _("Rules"),
+
+ "saFlagB" => _("Enable use of bayes filtering"),
+ "saFlagb" => _("Enabled bayes auto learning"),
+ "saFlagC" => _("Enable RBL checks"),
+ "saFlagR" => _("Enable use of Razor"),
+ "saFlagD" => _("Enable use of DDC"),
+ "saFlagP" => _("Enable use of Pyzor"))
+ ));
+ }
+
+ /* For newer service management dialogs */
+ function getListEntry()
+ {
+ $fields = goService::getListEntry();
+ $fields['Message'] = _("Spamassassin");
+ $fields['AllowEdit'] = true;
+ return($fields);
+ }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/spam/class_goSpamServerRule.inc b/plugins/admin/systems/services/spam/class_goSpamServerRule.inc
new file mode 100644
index 000000000..c8eed5d4e
--- /dev/null
+++ b/plugins/admin/systems/services/spam/class_goSpamServerRule.inc
@@ -0,0 +1,61 @@
+name = $this->orig_name= $name;
+ $this->rule = $rule;
+ }
+
+
+ function execute()
+ {
+ $smarty = get_smarty();
+
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","server/".get_class($this),$this->dn);
+ }
+
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,$this->$attr);
+ }
+ return($smarty->fetch(get_template_path("goSpamServerRule.tpl",TRUE,dirname(__FILE__))));
+ }
+
+ function save_object()
+ {
+ plugin::save_object();
+ foreach($this->attributes as $attr){
+ if(isset($_POST[$attr])){
+ $this->$attr = $_POST[$attr];
+ }
+ }
+ }
+
+
+ function save()
+ {
+ $ret =array();
+ $ret['orig_name'] = $this->orig_name;
+ $ret['name'] = $this->name;
+ $ret['rule'] = $this->rule;
+ return($ret);
+ }
+
+ function check()
+ {
+ $messages = plugin::check();
+ return($messages);
+ }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/spam/goSpamServer.tpl b/plugins/admin/systems/services/spam/goSpamServer.tpl
new file mode 100644
index 000000000..c8b58852f
--- /dev/null
+++ b/plugins/admin/systems/services/spam/goSpamServer.tpl
@@ -0,0 +1,129 @@
+
+
+ Spam tagging
+
+
+
+
+ Trusted networks
+
+
+
+
+
+
+
+
+
+
+
+
+ Flags
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Rules
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/spam/goSpamServerRule.tpl b/plugins/admin/systems/services/spam/goSpamServerRule.tpl
new file mode 100644
index 000000000..6448ab556
--- /dev/null
+++ b/plugins/admin/systems/services/spam/goSpamServerRule.tpl
@@ -0,0 +1,25 @@
+
Edit spam rule
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/syslog/class_goLogDBServer.inc b/plugins/admin/systems/services/syslog/class_goLogDBServer.inc
new file mode 100644
index 000000000..3a193dbf2
--- /dev/null
+++ b/plugins/admin/systems/services/syslog/class_goLogDBServer.inc
@@ -0,0 +1,106 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* This plugin only writes its objectClass */
+ var $objectclasses = array("goLogDBServer");
+ var $attributes = array("goLogAdmin", "goLogPassword");
+ var $StatusFlag = "goLogDBServerStatus";
+
+ /* This class can't be assigned twice so it conflicts with itsself */
+ var $conflicts = array("goLogDBServer");
+
+ var $DisplayName = "";
+ var $dn = NULL;
+ var $acl;
+ var $cn = "";
+ var $goLogDBServerStatus = "";
+ var $goLogAdmin = "";
+ var $goLogPassword = "";
+ var $view_logged =FALSE;
+
+
+ function goLogDBServer(&$config,$dn)
+ {
+ goService::goService($config,$dn);
+ $this->DisplayName = _("Syslog service database");
+ }
+
+
+ function execute()
+ {
+ $smarty = get_smarty();
+
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","server/".get_class($this),$this->dn);
+ }
+
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translation){
+ $smarty->assign($name."ACL",$this->getacl($name));
+ }
+
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,$this->$attr);
+ }
+ return($smarty->fetch(get_template_path("goLogDBServer.tpl",TRUE,dirname(__FILE__))));
+ }
+
+
+ function getListEntry()
+ {
+ $fields = goService::getListEntry();
+ $fields['Message'] = _("Syslog service database");
+ $fields['AllowEdit'] = true;
+ return($fields);
+ }
+
+
+ function check()
+ {
+ $message = plugin::check();
+ if (empty($this->goLogAdmin)){
+ $message[]= sprintf_("The attribute user is empty or contains invalid characters.");
+ }
+ if (empty($this->goLogPassword)){
+ $message[]= sprintf_("The attribute password is empty or contains invalid characters.");
+ }
+ return($message);
+ }
+
+
+ function save_object()
+ {
+ if(isset($_POST['goLogDBServerPosted'])){
+ plugin::save_object();
+ }
+ }
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Logging database"),
+ "plDescription" => _("Logging database")." ("._("Services").")",
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 97,
+ "plSection" => array("administration"),
+ "plCategory" => array("server"),
+
+ "plProvidedAcls"=> array(
+ "start" => _("Start"),
+ "stop" => _("Stop"),
+ "restart" => _("Restart"),
+ "goLogAdmin" => _("Admin"),
+ "goLogPassword" => _("Password"))
+ ));
+ }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/syslog/class_goSyslogServer.inc b/plugins/admin/systems/services/syslog/class_goSyslogServer.inc
new file mode 100644
index 000000000..9461977e2
--- /dev/null
+++ b/plugins/admin/systems/services/syslog/class_goSyslogServer.inc
@@ -0,0 +1,83 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* This plugin only writes its objectClass */
+ var $objectclasses = array("goSyslogServer");
+ var $attributes = array();
+ var $StatusFlag = "goSyslogServerStatus";
+
+ /* This class can't be assigned twice so it conflicts with itsself */
+ var $conflicts = array("goSyslogServer");
+
+ var $DisplayName = "";
+ var $dn = NULL;
+ var $acl;
+ var $cn = "";
+ var $goSyslogServerStatus = "";
+ var $view_logged =FALSE;
+
+ function goSyslogServer(&$config,$dn)
+ {
+ goService::goService($config,$dn);
+ $this->DisplayName = _("Syslog server");
+ }
+
+
+ function execute()
+ {
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","server/".get_class($this),$this->dn);
+ }
+
+
+ $smarty = get_smarty();
+ return($smarty->fetch(get_template_path("goSyslogServer.tpl",TRUE,dirname(__FILE__))));
+ }
+
+
+ function getListEntry()
+ {
+ $fields = goService::getListEntry();
+ $fields['Message'] = _("Syslog server");
+ $fields['AllowEdit'] = false;
+ return($fields);
+ }
+
+ function check()
+ {
+ $message = plugin::check();
+ return($message);
+ }
+
+
+ function save_object()
+ {
+ plugin::save_object();
+ }
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Logging service"),
+ "plDescription" => _("Logging service")." ("._("Services").")",
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 88,
+ "plSection" => array("administration"),
+ "plCategory" => array("server"),
+
+ "plProvidedAcls"=> array()
+ ));
+ }
+
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/syslog/goLogDBServer.tpl b/plugins/admin/systems/services/syslog/goLogDBServer.tpl
new file mode 100644
index 000000000..839507029
--- /dev/null
+++ b/plugins/admin/systems/services/syslog/goLogDBServer.tpl
@@ -0,0 +1,27 @@
+
{t}Logging database information{/t}
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/syslog/goSyslogServer.tpl b/plugins/admin/systems/services/syslog/goSyslogServer.tpl
new file mode 100644
index 000000000..a7ed661a8
--- /dev/null
+++ b/plugins/admin/systems/services/syslog/goSyslogServer.tpl
@@ -0,0 +1,9 @@
+
{t}Syslog Service{/t} {t}enabled{/t}
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/terminal/class_goTerminalServer.inc b/plugins/admin/systems/services/terminal/class_goTerminalServer.inc
new file mode 100644
index 000000000..e832de04c
--- /dev/null
+++ b/plugins/admin/systems/services/terminal/class_goTerminalServer.inc
@@ -0,0 +1,141 @@
+ "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* This plugin only writes its objectClass */
+ var $objectclasses = array("goTerminalServer");
+ var $attributes = array("goXdmcpIsEnabled", "goFontPath");
+ var $StatusFlag = "goTerminalServerStatus";
+
+ /* This class can't be assigned twice so it conflicts with itsself */
+ var $conflicts = array("goTerminalServer");
+
+ var $DisplayName = "";
+ var $dn = NULL;
+ var $acl;
+ var $cn = "";
+ var $goTerminalServerStatus = "";
+ var $goXdmcpIsEnabled = false;
+ var $goFontPath = "";
+ var $view_logged =FALSE;
+
+
+ function goTerminalServer(&$config,$dn)
+ {
+ goService::goService($config,$dn);
+ $this->DisplayName = _("Terminal service");
+ }
+
+
+ function execute()
+ {
+ $smarty = get_smarty();
+
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","server/".get_class($this),$this->dn);
+ }
+
+
+ $tmp = $this->plinfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translation){
+ $smarty->assign($name."ACL",$this->getacl($name));
+ }
+
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,$this->$attr);
+ }
+ return($smarty->fetch(get_template_path("goTerminalServer.tpl",TRUE,dirname(__FILE__))));
+ }
+
+
+ function getListEntry()
+ {
+ $fields = goService::getListEntry();
+ $fields['Message'] = _("Terminal service");
+ $fields['AllowEdit'] = true;
+ return($fields);
+ }
+
+
+ function save()
+ {
+ plugin::save();
+
+ if(!$this->goXdmcpIsEnabled){
+ $this->attrs['goXdmcpIsEnabled'] = "0";
+ }
+
+ /* Check if this is a new entry ... add/modify */
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cat($this->dn,array("objectClass"));
+ if($ldap->count()){
+ $ldap->cd($this->dn);
+ $ldap->modify($this->attrs);
+ }else{
+ $ldap->cd($this->dn);
+ $ldap->add($this->attrs);
+ }
+ show_ldap_error($ldap->get_error(), sprintf(_("Saving server services/terminalServer with dn '%s' failed."),$this->dn));
+ if($this->initially_was_account){
+ $this->handle_post_events("modify");
+ new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }else{
+ $this->handle_post_events("add");
+ new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }
+ }
+
+
+ function check()
+ {
+ $message = plugin::check();
+ if(empty($this->goFontPath)){
+ $message[]=_("Terminal server, must have fontpath specified.");
+ }
+
+ return($message);
+ }
+
+
+ function save_object()
+ {
+ if(isset($_POST['goTerminalServerPosted'])){
+ plugin::save_object();
+ if($this->acl_is_writeable("goXdmcpIsEnabled")){
+ if(isset($_POST['goXdmcpIsEnabled'])){
+ $this->goXdmcpIsEnabled = true;
+ }else{
+ $this->goXdmcpIsEnabled = false;
+ }
+ }
+ }
+ }
+
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Terminal service"),
+ "plDescription" => _("Terminal service")." ("._("Services").")",
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 87,
+ "plSection" => array("administration"),
+ "plCategory" => array("server"),
+
+ "plProvidedAcls"=> array(
+ "goXdmcpIsEnabled" => _("Temporary disable login"),
+ "goFontPath" => _("Font path"))
+ ));
+ }
+
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/terminal/goTerminalServer.tpl b/plugins/admin/systems/services/terminal/goTerminalServer.tpl
new file mode 100644
index 000000000..5fca2091f
--- /dev/null
+++ b/plugins/admin/systems/services/terminal/goTerminalServer.tpl
@@ -0,0 +1,27 @@
+
{t}Terminal service{/t}
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/services/virus/class_goVirusServer.inc b/plugins/admin/systems/services/virus/class_goVirusServer.inc
new file mode 100644
index 000000000..f91c5f5ae
--- /dev/null
+++ b/plugins/admin/systems/services/virus/class_goVirusServer.inc
@@ -0,0 +1,248 @@
+DisplayName = _("Anti virus");
+
+ /* Get userinfo & acls */
+ $this->ui = get_userinfo();
+
+ /* Get Flags */
+ foreach($this->Flags as $flag){
+ $var = "avFlags".$flag;
+ if(preg_match("/".$flag."/",$this->avFlags)){
+ $this->$var = TRUE;
+ }
+ }
+ }
+
+
+ function execute()
+ {
+ $smarty = get_smarty();
+
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","server/".get_class($this),$this->dn);
+ }
+
+
+ /* Set acls */
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translation) {
+ $smarty->assign($name."ACL",$this->getacl($name));
+ }
+
+ $display = "";
+ $smarty->assign("servtabs",FALSE);
+ $this->is_account = true;
+
+ /* Assign smarty vars */
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,$this->$attr);
+ }
+
+ /* Assign checkbox states */
+ foreach($this->Flags as $Flag){
+ $var = "avFlags".$Flag;
+ if($this->$var){
+ $smarty->assign("avFlags".$Flag."CHK"," checked " );
+ }else{
+ $smarty->assign("avFlags".$Flag."CHK","");
+ }
+ }
+
+ /* Assign value for max thread select box */
+ $tmp = array();
+ for($i = 1 ; $i <= 20 ; $i ++){
+ $tmp[$i] = $i;
+ }
+ $smarty->assign("ThreadValues",$tmp);
+
+ if($this->avFlagsA){
+ $smarty->assign("avFlagsAState" , "" );
+ }else{
+ $smarty->assign("avFlagsAState" , " disabled " );
+ }
+
+ return($display.$smarty->fetch(get_template_path("goVirusServer.tpl",TRUE,dirname(__FILE__))));
+ }
+
+
+ function save()
+ {
+ if(!$this->is_account) return;
+
+ /* Create Flags */
+ $this->avFlags = "";
+ foreach($this->Flags as $flag){
+ $var = "avFlags".$flag;
+ if($this->$var){
+ $this->avFlags .=$flag;
+ }
+ }
+
+ plugin::save();
+
+ if(!$this->avFlagsA){
+ $arr = array("avArchiveMaxFileSize","avArchiveMaxRecursion","avArchiveMaxCompressionRatio");
+ foreach($arr as $attr){
+ $this->attrs[$attr] = array();
+ }
+ $this->attrs['avFlags'] = preg_replace("/E/","",$this->attrs['avFlags']);
+ }
+
+ /* Check if this is a new entry ... add/modify */
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cat($this->dn,array("objectClass"));
+ if($ldap->count()){
+ $ldap->cd($this->dn);
+ $ldap->modify($this->attrs);
+ }else{
+ $ldap->cd($this->dn);
+ $ldap->add($this->attrs);
+ }
+ if($this->initially_was_account){
+ $this->handle_post_events("modify");
+ new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }else{
+ $this->handle_post_events("add");
+ new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }
+
+ show_ldap_error($ldap->get_error(), sprintf(_("Saving of server services/anti virus with dn '%s' failed."),$this->dn));
+ }
+
+ function check()
+ {
+ $message = plugin::check();
+
+ $mustBeNumeric = array(
+ "avMaxDirectoryRecursions" =>_("Maximum directory recursions"),
+ "avMaxThreads" =>_("Maximum threads"),
+ "avArchiveMaxFileSize" =>_("Maximum file size"),
+ "avArchiveMaxRecursion" =>_("Maximum recursions"),
+ "avArchiveMaxCompressionRatio" =>_("Maximum compression ratio"),
+ "avChecksPerDay" =>_("Checks per day"));
+
+ foreach($mustBeNumeric as $key => $trans){
+ if(!is_numeric($this->$key)){
+ $message[] = sprintf(_("The specified value for '%s' must be a numeric value."),$trans);
+ }
+ }
+
+ foreach(array("avUser"=>_("Database user"),"avHttpProxyURL"=>_("Http proxy URL"),"avDatabaseMirror"=>_("Database mirror")) as $attr => $name){
+ if(!preg_match("/^[a-z0-9:_\-\.\/]*$/",$this->$attr)){
+ $message[] = sprintf(_("Please specify a valid value for '%s'."),$name);
+ }
+ }
+
+ return($message);
+ }
+
+
+ function save_object()
+ {
+ if(isset($_POST['goVirusServer'])){
+ plugin::save_object();
+ foreach($this->Flags as $flag){
+
+ $var = "avFlags".$flag;
+ if($this->acl_is_writeable($var)){
+ if(isset($_POST[$var])){
+ $this->$var = TRUE;
+ }else{
+ $this->$var = FALSE;
+ }
+ }
+ }
+ }
+ }
+
+
+ /* For newer service management dialogs */
+ function getListEntry()
+ {
+ $fields = goService::getListEntry();
+ $fields['AllowEdit'] = true;
+ $fields['Message'] = _("Anti virus");
+ return($fields);
+ }
+
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Anti virus"),
+ "plDescription" => _("Anti virus")." ("._("Services").")",
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 96,
+ "plSection" => array("administration"),
+ "plCategory" => array("server"),
+ "plProvidedAcls"=> array(
+
+ "start" => _("Start"),
+ "stop" => _("Stop"),
+ "restart" => _("Restart"),
+
+ "avFlagsD" =>_("Enable debugging"),
+ "avFlagsS" =>_("Enable mail scanning"),
+ "avFlagsA" =>_("Enable scanning of archives"),
+ "avFlagsE" =>_("Block encrypted archives"),
+
+ "avMaxThreads" =>_("Maximum threads"),
+ "avMaxDirectoryRecursions" =>_("Maximum directory recursions"),
+ "avUser" =>_("Anti virus user"),
+ "avArchiveMaxFileSize" =>_("Maximum file size"),
+ "avArchiveMaxRecursion" =>_("Maximum recursions"),
+ "avArchiveMaxCompressionRatio" =>_("Maximum compression ratio"),
+ "avDatabaseMirror" =>_("Database mirror"),
+ "avChecksPerDay" =>_("Checks per day"),
+ "avHttpProxyURL" =>_("Http proxy URL"))
+ ));
+ }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/admin/systems/services/virus/goVirusServer.tpl b/plugins/admin/systems/services/virus/goVirusServer.tpl
new file mode 100644
index 000000000..af14a2b1c
--- /dev/null
+++ b/plugins/admin/systems/services/virus/goVirusServer.tpl
@@ -0,0 +1,172 @@
+
+
+
+
+ {t}Generic virus filtering{/t}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {t}Archive scanning{/t}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/admin/systems/servkolab.tpl b/plugins/admin/systems/servkolab.tpl
deleted file mode 100644
index ec83b7801..000000000
--- a/plugins/admin/systems/servkolab.tpl
+++ /dev/null
@@ -1,249 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
- {t}Quota settings{/t}
-
-
-
-
-{render acl=$cyrusquotawarnACL}
- {$quotastr}
-{/render}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/plugins/admin/systems/servnfs.tpl b/plugins/admin/systems/servnfs.tpl
deleted file mode 100644
index 9fb70a5f4..000000000
--- a/plugins/admin/systems/servnfs.tpl
+++ /dev/null
@@ -1,144 +0,0 @@
-
{t}Edit share{/t}
-
-