From 85e6d0d13244f787429c73263a128c0bd794121f Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 3 Jun 2008 13:22:42 +0000 Subject: [PATCH] Updated apache stuff - Works, but not cleanup. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11176 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../services/apache2/class_apacheUtils.inc | 6 +- .../apache2/class_servApacheEditVhost.inc | 13 +-- .../apache2/class_servApacheVhost.inc | 99 ++++++++++++------- .../services/apache2/servApacheVhost.tpl | 15 ++- 4 files changed, 84 insertions(+), 49 deletions(-) diff --git a/gosa-plugins/apache2/admin/systems/services/apache2/class_apacheUtils.inc b/gosa-plugins/apache2/admin/systems/services/apache2/class_apacheUtils.inc index a9538f351..5439cac35 100644 --- a/gosa-plugins/apache2/admin/systems/services/apache2/class_apacheUtils.inc +++ b/gosa-plugins/apache2/admin/systems/services/apache2/class_apacheUtils.inc @@ -5,7 +5,7 @@ class apacheUtils extends plugin /* This function returns the vhost entries specified for given host */ - function getVhostEntries($config,$HostDn,$silent = false) + public static function getVhostEntries($config,$HostDn,$silent = false) { $ldap = $config->get_ldap_link(); @@ -80,7 +80,7 @@ class apacheUtils extends plugin * - rename, if a dn must be renamed, for example, the apacheServerName has changed * - add, if there is a new vhost entries created */ - function getVhostEntriesDiff($config,$newVhosts,$HostDn) + public static function getVhostEntriesDiff($config,$newVhosts,$HostDn) { $oldVhosts = apacheUtils::getVhostEntries($config,$HostDn,true); @@ -251,7 +251,7 @@ class apacheUtils extends plugin /* Simple is domain check, it checks if the given string looks like "string.string.string" or string.string */ - function GetVhostsDomain($str) + public static function GetVhostsDomain($str) { return(preg_match("/[^\.\/]+\.[^\.\/]+$/",$str)); } diff --git a/gosa-plugins/apache2/admin/systems/services/apache2/class_servApacheEditVhost.inc b/gosa-plugins/apache2/admin/systems/services/apache2/class_servApacheEditVhost.inc index 64045327a..60d64b9c5 100644 --- a/gosa-plugins/apache2/admin/systems/services/apache2/class_servApacheEditVhost.inc +++ b/gosa-plugins/apache2/admin/systems/services/apache2/class_servApacheEditVhost.inc @@ -152,10 +152,7 @@ class servapacheVhostEdit extends plugin if(isset($_POST['SaveVhostEntryChanges'])){ $this->dialog->save_object(); if(count($this->dialog->check())){ - $msgs = $this->dialog->check(); - foreach($msgs as $msg){ - print_red($msg); - } + msg_dialog::displayChecks($this->dialog->check()); }else{ $this->dialog->save(); $this->dialog = false; @@ -282,7 +279,7 @@ class servapacheVhostEdit extends plugin /* Set apacheServerNames without server suffix */ $smarty->assign("apacheServerName",$this->apacheServerName); - $div = new DivSelectBox("apacheServerAlias"); + $div = new divSelectBox("apacheServerAlias"); $div->setHeight(120); $recs = $this->apacheServerAlias; @@ -328,7 +325,7 @@ class servapacheVhostEdit extends plugin $smarty->assign("apacheScriptAlias", $div->DrawList()); /* Display template */ - $display.= $smarty->fetch(get_template_path('servApacheVhostEdit.tpl', TRUE)); + $display.= $smarty->fetch(get_template_path('servApacheVhostEdit.tpl', TRUE, dirname(__FILE__))); return($display); } @@ -368,11 +365,11 @@ class servapacheVhostEdit extends plugin $message[] =sprintf(_("Please choose a valid Virtual Host Name.")); } - if(!is_path($this->apacheDocumentRoot) || empty($this->apacheDocumentRoot)){ + if(!tests::is_path($this->apacheDocumentRoot) || empty($this->apacheDocumentRoot)){ $message[] = _("Please choose a valid Path as Virtual Host Document Root."); } - if(!is_email($this->apacheServerAdmin) || empty($this->apacheServerAdmin)){ + if(!tests::is_email($this->apacheServerAdmin) || empty($this->apacheServerAdmin)){ $message[] = _("Please choose a valid Email Account as Admin Mail address."); } diff --git a/gosa-plugins/apache2/admin/systems/services/apache2/class_servApacheVhost.inc b/gosa-plugins/apache2/admin/systems/services/apache2/class_servApacheVhost.inc index 868c7a813..3cb51cd74 100644 --- a/gosa-plugins/apache2/admin/systems/services/apache2/class_servApacheVhost.inc +++ b/gosa-plugins/apache2/admin/systems/services/apache2/class_servApacheVhost.inc @@ -8,9 +8,8 @@ class servapache extends goService var $objectclasses = array("whatever"); var $RecordTypes = array(); - var $Vhosts = array(); + var $Vhosts = array(); var $dialog = NULL; - var $orig_dn = ""; var $APACHEinitially_was_account; @@ -34,6 +33,9 @@ class servapache extends goService $this->is_account = true; } $this->APACHEinitially_was_account = $this->is_account; + + /* Set service name */ + $this->DisplayName = _("Apache service"); } @@ -48,29 +50,6 @@ class servapache extends goService $smarty= get_smarty(); $display= ""; - /* Do we need to flip is_account state? - */ - if (isset($_POST['modify_state'])){ - - /* Only change account state if allowed */ - if($this->is_account && $this->acl == "#all#"){ - $this->is_account= !$this->is_account; - $this->is_modified = true; - }elseif(!$this->is_account && chkacl($this->acl,"create") == ""){ - $this->is_account= !$this->is_account; - $this->is_modified = true; - } - } - - if ($this->is_account){ - $display= $this->show_header(_("Remove Apache service"), - _("This server has Apache features enabled. You can disable them by clicking below.")); - } else { - $display= $this->show_header(_("Add Apache service"), - _("This server has Apache features disabled. You can enable them by clicking below.")); - return ($display); - } - /* Edited or Added vhost */ if((isset($_POST['SaveVhostChanges'])) && is_object($this->dialog)){ @@ -79,9 +58,7 @@ class servapache extends goService /* Check for errors */ if(count($this->dialog->check())){ - foreach($this->dialog->check() as $msgs){ - print_red($msgs); - } + msg_dialog::displayChecks($this->dialog->check()); }else{ /* add new/edited vhost */ @@ -102,7 +79,7 @@ class servapache extends goService /* Add empty new vhost */ - if(isset($_POST['AddVhost']) && chkacl($this->acl,"servapache") == ""){ + if(isset($_POST['AddVhost']) && $this->acl_is_writeable("VirtualHosts")){ $this->dialog = new servapacheVhostEdit($this->config,$this->dn); } @@ -113,7 +90,7 @@ class servapache extends goService //user_error(print_r($this->Vhosts,true)); /* check all post for edit request */ - if(preg_match("/^editVhost_/",$name)&&!$once && chkacl($this->acl,"servapache") == ""){ + if(preg_match("/^editVhost_/",$name)&& !$once && $this->acl_is_writeable("VirtualHosts")){ $once =true; $tmp = preg_replace("/^editVhost_/","",$name); $tmp = base64_decode(preg_replace("/_.*$/","",$tmp)); @@ -122,7 +99,7 @@ class servapache extends goService /* check posts for delete vhost */ - if(preg_match("/^delVhost_/",$name)&&!$once && chkacl($this->acl,"servapache") == ""){ + if(preg_match("/^delVhost_/",$name)&&!$once && $this->acl_is_writeable("VirtualHosts")){ $once =true; $tmp = preg_replace("/^delVhost_/","",$name); @@ -157,13 +134,20 @@ class servapache extends goService array("string" => str_replace("%s",base64_encode($vhost),$editImg)) )); } - - $smarty->assign("servapacheACL",chkacl($this->acl,"servapache")); + + + /* Assign ACL to smarty + */ + $info = $this->plInfo(); + foreach($info['plProvidedAcls'] as $name => $desc){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + /* Display template */ $smarty->assign("VhostList",$VhostList->DrawList()); - $display.= $smarty->fetch(get_template_path('servApacheVhost.tpl', TRUE)); + $display.= $smarty->fetch(get_template_path('servApacheVhost.tpl', TRUE , dirname(__FILE__))); return($display); } @@ -225,6 +209,7 @@ class servapache extends goService } $tmp = apacheUtils::getVhostEntriesDiff($this->config,$this->Vhosts,$old_dn); + print_a($tmp); /* Updated vhost entries if reverser or forward name has changed * Must be done before moving entries, else the given dn is invalid @@ -233,7 +218,10 @@ class servapache extends goService foreach($tmp['vhostUpdates'] as $dn => $attrs){ $ldap->cd($dn); $ldap->modify($attrs); - show_ldap_error("Vhost:".$ldap->get_error(), _("Updating Apache service failed")); + + if (!$ldap->success()){ + msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class())); + } } } @@ -242,7 +230,9 @@ class servapache extends goService foreach($tmp['del'] as $dn => $del){ $ldap->cd($dn); $ldap->rmdir_recursive($dn); - show_ldap_error($ldap->get_error(), _("Removing Apache entries failed")); + if (!$ldap->success()){ + msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class())); + } } /* move follwoing entries @@ -264,9 +254,44 @@ class servapache extends goService $ldap->cd($dn); $ldap->add($attrs); } - show_ldap_error($ldap->get_error(), _("Saving apache entries failed")); + if (!$ldap->success()){ + msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_ADD, get_class())); + } } } + + + /*! \brief Returns the required information about this plugin for the + service list + @return Array With information for the service plugin. + */ + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("Apache service"); + $fields['AllowEdit'] = false; + return($fields); + } + + + /* \brief Return plugin information used by the ACL handling. + @return Array ACL infos. + */ + static function plInfo() + { + return (array( + "plShortName" => _("Apache service"), + "plDescription" => _("Apache virtual host service")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 88, + "plSection" => array("administration"), + "plCategory" => array("server"), + + "plProvidedAcls"=> array( + "VirtualHost" => _("Virtual hosts")) + )); + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?> diff --git a/gosa-plugins/apache2/admin/systems/services/apache2/servApacheVhost.tpl b/gosa-plugins/apache2/admin/systems/services/apache2/servApacheVhost.tpl index a1449753b..30385f9bf 100644 --- a/gosa-plugins/apache2/admin/systems/services/apache2/servApacheVhost.tpl +++ b/gosa-plugins/apache2/admin/systems/services/apache2/servApacheVhost.tpl @@ -3,7 +3,10 @@ {$VhostList} - + + {render acl=$VirtualHostACL} + + {/render} @@ -12,3 +15,13 @@ document.mainform.AddVhost.focus(); --> + + +

 

+
+
+ +   + +
+ -- 2.30.2