From 3b607ddaa38e9235c21a77f0c53918650db00af4 Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 26 Jul 2010 15:46:25 +0000 Subject: [PATCH] Updated several service dialogs, fixed typos, string, html, post handling and more. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19116 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../apache2/class_servApacheEditVhost.inc | 480 +++++++++--------- 1 file changed, 241 insertions(+), 239 deletions(-) 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 d763d4cb0..84001e4cf 100644 --- a/gosa-plugins/apache2/admin/systems/services/apache2/class_servApacheEditVhost.inc +++ b/gosa-plugins/apache2/admin/systems/services/apache2/class_servApacheEditVhost.inc @@ -23,273 +23,275 @@ class servapacheVhostEdit extends plugin { - /* attribute list for save action */ - var $ignore_account= TRUE; - - var $attributes = array("apacheServerName","apacheDocumentRoot","apacheServerAlias", - "apacheServerAdmin","apacheScriptAlias"); - - var $objectclasses = array("whatever"); - - var $apacheServerName = ""; - var $apacheDocumentRoot = ""; - var $apacheServerAdmin = ""; - var $apacheSuexecUid = ""; - var $apacheSuexecGid = ""; - - var $apacheServerAlias = array(); - var $apacheScriptAlias = array(); - - var $OldApacheServerName = ""; // To detect changes made with this edit - var $InitialApacheServerName = ""; - - var $Records = array(); - - var $dialog = false; - - var $isNew = true; - var $cn; - var $VhostObject = array(); - - - function servapacheVhostEdit ($config, $dn= NULL,$attrs = array()) - { - plugin::plugin ($config, $dn); - if(!count($attrs)){ - $this->OldApacheServerName = ""; - $this->isNew = true; - $this->InitialApacheServerName = "";//$attrs['InitialApacheServerName']; - }else{ - $this->VhostObject = $attrs; - $this->OldApacheServerName = $attrs['apacheServerName']; - $this->InitialApacheServerName = $attrs['InitialApacheServerName']; - $this->isNew = false; - foreach($this->attributes as $value){ - if(isset($attrs[$value])){ - $this->$value = $attrs[$value]; + /* attribute list for save action */ + var $ignore_account= TRUE; + + var $attributes = array("apacheServerName","apacheDocumentRoot","apacheServerAlias", + "apacheServerAdmin","apacheScriptAlias"); + + var $objectclasses = array("whatever"); + + var $apacheServerName = ""; + var $apacheDocumentRoot = ""; + var $apacheServerAdmin = ""; + var $apacheSuexecUid = ""; + var $apacheSuexecGid = ""; + + var $apacheServerAlias = array(); + var $apacheScriptAlias = array(); + + var $OldApacheServerName = ""; // To detect changes made with this edit + var $InitialApacheServerName = ""; + + var $Records = array(); + + var $dialog = false; + + var $isNew = true; + var $cn; + var $VhostObject = array(); + + + function servapacheVhostEdit ($config, $dn= NULL,$attrs = array()) + { + plugin::plugin ($config, $dn); + if(!count($attrs)){ + $this->OldApacheServerName = ""; + $this->isNew = true; + $this->InitialApacheServerName = "";//$attrs['InitialApacheServerName']; + }else{ + $this->VhostObject = $attrs; + $this->OldApacheServerName = $attrs['apacheServerName']; + $this->InitialApacheServerName = $attrs['InitialApacheServerName']; + $this->isNew = false; + foreach($this->attributes as $value){ + if(isset($attrs[$value])){ + $this->$value = $attrs[$value]; + } + } + + if(!isset($attrs['apacheServerAlias'])) $this->apacheServerAlias = array(); + if(!isset($attrs['apacheScriptAlias'])) $this->apacheScriptAlias = array(); } - } - if(!isset($attrs['apacheServerAlias'])) $this->apacheServerAlias = array(); - if(!isset($attrs['apacheScriptAlias'])) $this->apacheScriptAlias = array(); - } - - // Prepare lists - $this->serverList = new sortableListing(array(),array(), TRUE); - $this->serverList->setDeleteable(true); - $this->serverList->setInstantDelete(false); - $this->serverList->setEditable(false); - $this->serverList->setWidth("100%"); - $this->serverList->setHeight("100px"); - $this->serverList->setHeader(array(_("Alias"),_("Directory"))); - $this->serverList->setColspecs(array('*','*','20px')); - $this->serverList->setDefaultSortColumn(0); - - $this->scriptList = new sortableListing(array(),array(), TRUE); - $this->scriptList->setDeleteable(true); - $this->scriptList->setInstantDelete(false); - $this->scriptList->setEditable(false); - $this->scriptList->setWidth("100%"); - $this->scriptList->setHeight("100px"); - $this->scriptList->setColspecs(array('*','*','20px')); - $this->scriptList->setHeader(array(_("Alias"),_("Directory"))); - $this->scriptList->setDefaultSortColumn(0); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - - /* Fill templating stuff */ - $smarty= get_smarty(); - - $display= ""; - - $this->serverList->save_object(); - $action = $this->serverList->getAction(); - if($action['action'] == 'delete'){ - $key = $this->serverList->getKey($action['targets'][0]); - unset($this->apacheServerAlias[$key]); - } - if($action['action'] == 'reorder'){ - $this->apacheServerAlias = $this->serverList->getMaintainedData(); + // Prepare lists + $this->serverList = new sortableListing(array(),array(), TRUE); + $this->serverList->setDeleteable(true); + $this->serverList->setInstantDelete(false); + $this->serverList->setEditable(false); + $this->serverList->setWidth("100%"); + $this->serverList->setHeight("100px"); + $this->serverList->setHeader(array(_("Alias"),_("Directory"))); + $this->serverList->setColspecs(array('*','*','20px')); + $this->serverList->setDefaultSortColumn(0); + + $this->scriptList = new sortableListing(array(),array(), TRUE); + $this->scriptList->setDeleteable(true); + $this->scriptList->setInstantDelete(false); + $this->scriptList->setEditable(false); + $this->scriptList->setWidth("100%"); + $this->scriptList->setHeight("100px"); + $this->scriptList->setColspecs(array('*','*','20px')); + $this->scriptList->setHeader(array(_("Alias"),_("Directory"))); + $this->scriptList->setDefaultSortColumn(0); } - $this->scriptList->save_object(); - $action = $this->scriptList->getAction(); - if($action['action'] == 'delete'){ - $key = $this->scriptList->getKey($action['targets'][0]); - unset($this->apacheScriptAlias[$key]); - } - if($action['action'] == 'reorder'){ - $this->apacheScriptAlias = $this->scriptList->getMaintainedData(); - } + function execute() + { + /* Call parent execute */ + plugin::execute(); - /* Add a new "Server Alias" - */ - if((isset($_POST['AddSARecord'])) && (!empty($_POST['StrSAAlias'])) && (!empty($_POST['StrSADir']))){ - $this->apacheServerAlias[] = trim($_POST['StrSAAlias']." ".$_POST['StrSADir']); - } - /* Add a new "Script Alias" - */ - if((isset($_POST['AddSCRecord'])) && (!empty($_POST['StrSCAlias'])) && (!empty($_POST['StrSCDir']))){ - $this->apacheScriptAlias[] = trim($_POST['StrSCAlias']." ".$_POST['StrSCDir']); - } + return "

Plugin is deactivated

"; - /* Fill in values */ - foreach($this->attributes as $name){ - $smarty->assign($name,$this->$name); - } + /* Fill templating stuff */ + $smarty= get_smarty(); - /* Set apacheServerNames without server suffix */ - $smarty->assign("apacheServerName",$this->apacheServerName); - $smarty->assign("NotNew", false); + $display= ""; + $this->serverList->save_object(); + $action = $this->serverList->getAction(); + if($action['action'] == 'delete'){ + $key = $this->serverList->getKey($action['targets'][0]); + unset($this->apacheServerAlias[$key]); + } + if($action['action'] == 'reorder'){ + $this->apacheServerAlias = $this->serverList->getMaintainedData(); + } - $this->serverList->setAcl($this->parent->getacl('apacheServerAlias')); - $data = $lData = array(); - foreach($this->apacheServerAlias as $key => $rec){ - $data[$key] = $rec; - $lData[$key]= array('data' => preg_split("/ /",$rec)); - } - $this->serverList->setListData($data,$lData); - $this->serverList->update(); - $smarty->assign("apacheServerAlias", $this->serverList->render()); - - $this->scriptList->setAcl($this->parent->getacl('apacheScriptAlias')); - $data = $lData = array(); - foreach($this->apacheScriptAlias as $key => $rec){ - $data[$key] = $rec; - $lData[$key]= array('data' => preg_split("/ /",$rec)); - } - $this->scriptList->setListData($data,$lData); - $this->scriptList->update(); - $smarty->assign("apacheScriptAlias", $this->scriptList->render()); - - /* Display template */ - $display.= $smarty->fetch(get_template_path('servApacheVhostEdit.tpl', TRUE, dirname(__FILE__))); - return($display); - } - - - function remove_from_parent() - { - } - - - /* 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(); - - /* Check if apacheServerName is already in use */ - $usedVhosts = $this->getUsedServerNames(); - if(($this->isNew == true)||($this->apacheServerName != $this->InitialApacheServerName)){ - if((isset($usedVhosts[$this->apacheServerName]))&&($this->apacheServerName != $this->InitialApacheServerName)){ - $message[] = msgPool::duplicated(_("Name")); - } - } + $this->scriptList->save_object(); + $action = $this->scriptList->getAction(); + if($action['action'] == 'delete'){ + $key = $this->scriptList->getKey($action['targets'][0]); + unset($this->apacheScriptAlias[$key]); + } + if($action['action'] == 'reorder'){ + $this->apacheScriptAlias = $this->scriptList->getMaintainedData(); + } - /* Check given virtual server name - */ - if(!tests::is_domain($this->apacheServerName) || empty($this->apacheServerName)){ - $message[] = msgPool::invalid(_("Virtual host name"),$this->apacheServerName,"", - _("Only lowercase strings are allowed as Virtual Host Name.")." "._("e.g. example.com")); - } + /* Add a new "Server Alias" + */ + if((isset($_POST['AddSARecord'])) && (!empty($_POST['StrSAAlias'])) && (!empty($_POST['StrSADir']))){ + $this->apacheServerAlias[] = trim(get_post('StrSAAlias')." ".get_post('StrSADir')); + } - /* check if there is a valid document root given - */ - if(!tests::is_path($this->apacheDocumentRoot) || empty($this->apacheDocumentRoot)){ - $message[] = msgPool::invalid(_("Document root"),$this->apacheDocumentRoot); - } - - /* Check given mail address - */ - if(!tests::is_email($this->apacheServerAdmin) || empty($this->apacheServerAdmin)){ - $message[] = msgPool::invalid(_("Admin mail address"),$this->apacheServerAdmin); + /* Add a new "Script Alias" + */ + if((isset($_POST['AddSCRecord'])) && (!empty($_POST['StrSCAlias'])) && (!empty($_POST['StrSCDir']))){ + $this->apacheScriptAlias[] = trim(get_post('StrSCAlias')." ".get_post('StrSCDir')); + } + + /* Fill in values */ + foreach($this->attributes as $name){ + $smarty->assign($name, set_post($this->$name)); + } + + /* Set apacheServerNames without server suffix */ + $smarty->assign("apacheServerName", set_post($this->apacheServerName)); + $smarty->assign("NotNew", false); + + + $this->serverList->setAcl($this->parent->getacl('apacheServerAlias')); + $data = $lData = array(); + foreach($this->apacheServerAlias as $key => $rec){ + $data[$key] = $rec; + $lData[$key]= array('data' => preg_split("/ /",$rec)); + } + $this->serverList->setListData($data,$lData); + $this->serverList->update(); + $smarty->assign("apacheServerAlias", $this->serverList->render()); + + $this->scriptList->setAcl($this->parent->getacl('apacheScriptAlias')); + $data = $lData = array(); + foreach($this->apacheScriptAlias as $key => $rec){ + $data[$key] = $rec; + $lData[$key]= array('data' => preg_split("/ /",$rec)); + } + $this->scriptList->setListData($data,$lData); + $this->scriptList->update(); + $smarty->assign("apacheScriptAlias", $this->scriptList->render()); + + /* Display template */ + $display.= $smarty->fetch(get_template_path('servApacheVhostEdit.tpl', TRUE, dirname(__FILE__))); + return($display); } - /* Check server aliases - */ - foreach($this->apacheServerAlias as $key => $line){ - $apacheServerAlias_ar=explode(" ",$line); - $url=$apacheServerAlias_ar[1]; - if(!tests::is_path($url)){ - $message[] = msgPool::invalid(_("Server alias")); - } + + function remove_from_parent() + { } - - /* Check script aliases - */ - foreach($this->apacheScriptAlias as $key => $line){ - $apacheScriptAlias_ar=explode(" ",$line); - $url=$apacheScriptAlias_ar[1]; - if(!tests::is_path($url)){ - $message[] = msgPool::invalid(_("Script alias")); - } + + + /* Save data to object */ + function save_object() + { + plugin::save_object(); } - return ($message); - } + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); - /* This funtion returns all used apacheServerNames */ - function getUsedServerNames() - { - $ret = array(); - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=apacheConfig)(apacheServerName=*))",array("apacheServerName")); - while($attr = $ldap->fetch()){ - $ret[$attr['apacheServerName'][0]]=""; - } - return($ret); - } + /* Check if apacheServerName is already in use */ + $usedVhosts = $this->getUsedServerNames(); + if(($this->isNew == true)||($this->apacheServerName != $this->InitialApacheServerName)){ + if((isset($usedVhosts[$this->apacheServerName]))&&($this->apacheServerName != $this->InitialApacheServerName)){ + $message[] = msgPool::duplicated(_("Name")); + } + } + /* Check given virtual server name + */ + if(!tests::is_domain($this->apacheServerName) || empty($this->apacheServerName)){ + $message[] = msgPool::invalid(_("Virtual host name"),$this->apacheServerName,"", + _("Only lowercase strings are allowed as Virtual Host Name.")." "._("e.g. example.com")); + } - /* Save to LDAP */ - function save() - { - $ret =array(); - foreach($this->attributes as $name){ - $ret[$name] = $this->$name; - } + /* check if there is a valid document root given + */ + if(!tests::is_path($this->apacheDocumentRoot) || empty($this->apacheDocumentRoot)){ + $message[] = msgPool::invalid(_("Document root"),$this->apacheDocumentRoot); + } + + /* Check given mail address + */ + if(!tests::is_email($this->apacheServerAdmin) || empty($this->apacheServerAdmin)){ + $message[] = msgPool::invalid(_("Admin mail address"),$this->apacheServerAdmin); + } + + /* Check server aliases + */ + foreach($this->apacheServerAlias as $key => $line){ + $apacheServerAlias_ar=explode(" ",$line); + $url=$apacheServerAlias_ar[1]; + if(!tests::is_path($url)){ + $message[] = msgPool::invalid(_("Server alias")); + } + } - /* Create SA records - */ - foreach($this->apacheServerAlias as $key => $rec){ - $rec['value']= $key." ".$rec['value']; - $this->Records [] = $rec; + /* Check script aliases + */ + foreach($this->apacheScriptAlias as $key => $line){ + $apacheScriptAlias_ar=explode(" ",$line); + $url=$apacheScriptAlias_ar[1]; + if(!tests::is_path($url)){ + $message[] = msgPool::invalid(_("Script alias")); + } + } + + return ($message); } - /* Create SC records - */ - foreach($this->apacheScriptAlias as $key => $rec){ - $rec['value']= $key." ".$rec['value']; - $this->Records [] = $rec; + + /* This funtion returns all used apacheServerNames */ + function getUsedServerNames() + { + $ret = array(); + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=apacheConfig)(apacheServerName=*))",array("apacheServerName")); + while($attr = $ldap->fetch()){ + $ret[$attr['apacheServerName'][0]]=""; + } + return($ret); } - $ret['RECORDS'] = $this->Records; - $ret['InitialApacheServerName'] = $this->InitialApacheServerName; - return($ret); - } - function acl_is_writeable($attribute,$skip_write = FALSE) - { - return($this->parent->acl_is_writeable($attribute,$skip_write)); - } + /* Save to LDAP */ + function save() + { + $ret =array(); + foreach($this->attributes as $name){ + $ret[$name] = $this->$name; + } + + /* Create SA records + */ + foreach($this->apacheServerAlias as $key => $rec){ + $rec['value']= $key." ".$rec['value']; + $this->Records [] = $rec; + } + + /* Create SC records + */ + foreach($this->apacheScriptAlias as $key => $rec){ + $rec['value']= $key." ".$rec['value']; + $this->Records [] = $rec; + } + + $ret['RECORDS'] = $this->Records; + $ret['InitialApacheServerName'] = $this->InitialApacheServerName; + return($ret); + } + + function acl_is_writeable($attribute,$skip_write = FALSE) + { + return($this->parent->acl_is_writeable($attribute,$skip_write)); + } } -- 2.30.2