diff --git a/trunk/gosa-plugins/fai/admin/fai/class_faiPackage.inc b/trunk/gosa-plugins/fai/admin/fai/class_faiPackage.inc
index ebc2e96640b8d9cb5307ff0e8a0252359a5ebe6c..ece39a90a89b3aa4567a07de1fa546eb7e0d1814 100644 (file)
var $direct_packages_add = FALSE;
var $configure_dialog_shown = FALSE;
+ var $debconf_configurations = FALSE;
function faiPackage (&$config, $dn= NULL)
{
ksort($this->usedPackages);
}
- /* Fetch all package configurations from ldap
- */
- $PackageFilter = "";
- foreach($this->usedPackages as $name => $value){
- $PackageFilter .= "(FAIpackage=".$name.")";
- }
- /* Also fetch d-i */
- $PackageFilter .= "(FAIpackage=d-i)";
-
- $PackageFilter = "(&(objectClass=FAIdebconfInfo)(|".$PackageFilter."))";
-
- /* Search for configuration objects */
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->dn);
- $ldap->search($PackageFilter,array("FAIvariable","FAIvariableType",
- "FAIvariableContent","FAIpackage","FAIdebianSection","FAIstate"));
-
- /* Walk through configurations and append them to our list of ConfiguredPackages
- */
- while($attr = $ldap->fetch()){
-
- /* Skip objects, that are tagged as removed */
- if(isset($object['FAIstate'][0])){
- if(preg_match("/removed$/",$attr['FAIstate'][0])){
- continue;
- }
- }
-
- $tmp =array();
- $tmp['Name'] = $attr['FAIvariable'][0];
- $tmp['Type'] = $attr['FAIvariableType'][0];
- $tmp['Save'] = TRUE;
-
- if (isset($attr['FAIvariableContent'][0])){
- if(!in_array($attr['FAIvariableType'],array("multiselect"))){
- $tmp['Value'] = $attr['FAIvariableContent'][0];
- }else{
- $content = array();
- unset($attr['FAIvariableContent']['count']);
- foreach($attr['FAIvariableContent'] as $attr){
- $tmp['Value'][] = $attr;
- }
- }
- $this->ConfiguredPackages[$attr['FAIpackage'][0]][$attr['FAIvariable'][0]]=$tmp;
- }
- else {
- $tmp['Value'] = "";
- $this->ConfiguredPackages[$attr['FAIpackage'][0]][$attr['FAIvariable'][0]]=$tmp;
- }
- }
+ /* Fetch package configurations from LDAP */
+ $this->ConfiguredPackages = $this->get_configured_packages($this->usedPackages, $this->dn);
$this->FAIdebianSection = array();
if(isset($this->attrs['FAIdebianSection'])){
$this->direct_packages_add = TRUE;
}
+ /* Force Release and Sections to the currently selected Defaults */
+ $this->FAIdebianRelease = $this->getRelease();
+ $this->FAIdebianSection = $this->getSections();
+
/* Generate package list */
$this->list= $this->genPkgs(TRUE);
}
+ function get_configured_packages($packages, $base)
+ {
+ /* Fetch all package configurations from ldap
+ */
+ $PackageFilter = "";
+ foreach($packages as $name => $value){
+ $PackageFilter .= "(FAIpackage=".$name.")";
+ }
+ /* Also fetch d-i */
+ $PackageFilter .= "(FAIpackage=d-i)";
+
+ $PackageFilter = "(&(objectClass=FAIdebconfInfo)(|".$PackageFilter."))";
+
+ /* Search for configuration objects */
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($base);
+ $ldap->search($PackageFilter,array("FAIvariable","FAIvariableType",
+ "FAIvariableContent","FAIpackage","FAIdebianSection","FAIstate"));
+
+ $configured_packages = array();
+
+ /* Walk through configurations and append them to our list of ConfiguredPackages
+ */
+ while($attr = $ldap->fetch()){
+
+ /* Skip objects, that are tagged as removed */
+ if(isset($object['FAIstate'][0])){
+ if(preg_match("/removed$/",$attr['FAIstate'][0])){
+ continue;
+ }
+ }
+
+ $tmp =array();
+ $tmp['Name'] = $attr['FAIvariable'][0];
+ $tmp['Type'] = $attr['FAIvariableType'][0];
+ $tmp['Save'] = TRUE;
+
+ if (isset($attr['FAIvariableContent'][0])){
+ if(!in_array($attr['FAIvariableType'],array("multiselect"))){
+ $tmp['Value'] = $attr['FAIvariableContent'][0];
+ }else{
+ $content = array();
+ unset($attr['FAIvariableContent']['count']);
+ foreach($attr['FAIvariableContent'] as $attr){
+ $tmp['Value'][] = $attr;
+ }
+ }
+ $configured_packages[$attr['FAIpackage'][0]][$attr['FAIvariable'][0]]=$tmp;
+ }
+ else {
+ $tmp['Value'] = "";
+ $configured_packages[$attr['FAIpackage'][0]][$attr['FAIvariable'][0]]=$tmp;
+ }
+ }
+
+ return $configured_packages;
+ }
+
function execute()
{
if(!$this->is_account){
- /* Assemble release name */
- $release = $this->parent->parent->fai_release;
- $tmp= preg_replace('/[,]*'.preg_quote(get_ou('faiBaseRDN'), '/').'.*$/', '', $release);
- $tmp= preg_replace('/ou=/', '', $tmp);
- $rev= array_reverse(split(',', $tmp));
- $this->FAIdebianRelease= "/";
- foreach ($rev as $part){
- $this->FAIdebianRelease.= "/$part";
- }
- $this->FAIdebianRelease= preg_replace('#^[/]*#', '', $this->FAIdebianRelease);
+ $this->FAIdebianRelease = $this->getRelease();
- /* Assemble sections */
- $repos= $this->getServerInfos();
- if(isset($repos[$this->FAIdebianRelease])){
- $this->FAIdebianSection= $repos[$this->FAIdebianRelease];
- $this->FAIdebianSection= array_unique($this->FAIdebianSection);
- }
+ $this->FAIdebianSection = $this->getSections();
/* Assign Repository settings*/
$this->is_account = true;
}
if(isset($_POST['EditConfigurations']) &&
- $this->acl_is_writeable("FAIpackage")) {
+ $this->acl_is_writeable("FAIdebconfInfo")) {
$this->dialog = new faiDebconfConfigurations($this->config, $this->dn, $this);
$this->dialog->set_acl_base($this->acl_base);
$this->is_dialog = true;
foreach($tmp['plProvidedAcls'] as $name => $translated){
$smarty->assign($name."ACL",$this->getacl($name,preg_match("/freeze/",$this->FAIstate)));
}
+
+ if ($this->acl_is_writeable("FAIdebconfInfo")) {
+ $this->debconf_configurations = TRUE;
+ }
$smarty->assign("freeze", preg_match("/freeze/",$this->FAIstate));
$smarty->assign("divlist",$divlist->DrawList());
$smarty->assign("sections",$this->sections);
$smarty->assign("section" ,$strsec);
$smarty->assign("direct_packages_add", $this->direct_packages_add);
+ $smarty->assign("debconf_configurations", $this->debconf_configurations);
$display.= $smarty->fetch(get_template_path('faiPackage.tpl', TRUE));
return($display);
}
$message[] = msgPool::duplicated(_("Name"));
}
}
+
+ if (preg_match("/^-/", $this->cn)) {
+ $message[] = sprintf(_("The specified classname '%s' is invalid. Classnames must not start with a dash."), $this->cn);
+ }
+
+ if($this->cn != preg_replace("/ /","",trim($this->cn))){
+ $message[] = msgPool::invalid(_("Name"),preg_replace("/ /","_",$this->cn),"/[^_]/");
+ }
+
return ($message);
}
$ldap = $this->config->get_ldap_link();
$ldap->cat($dn);
if ($ldap->count()) {
- $ldap->cd($dn);
- $ldap->rmdir($dn);
+ FAI::prepare_to_save_FAI_object($dn,array(),true);
}
}
}
$ldap = $this->config->get_ldap_link();
$ldap->cat($pkgdn);
if ($ldap->count()) {
- $ldap->cd($pkgdn);
- $ldap->rmdir($pkgdn);
+ FAI::prepare_to_save_FAI_object($pkgdn,array(),true);
}
else {
unset($this->ConfiguredPackages[$pkgname][$name]);
$this->FAIdebianSection[$source['FAIdebianSection'][$i]]=$source['FAIdebianSection'][$i];
}
}
+ $this->ConfiguredPackages = $this->get_configured_packages($this->usedPackages, $source['dn']);
- /* Create one filter with all package names,
- instead of calling $ldap->search for every single package
- */
- $PackageFilter = "";
- foreach($this->usedPackages as $name){
- $PackageFilter .= "(FAIpackage=".$name.")";
- }
-
- /* Search for configuration objects */
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($source['dn']);
- $ldap->search($PackageFilter,array("FAIvariable","FAIvariableType","FAIvariableContent","FAIpackage","FAIdebianSection","FAIstate"));
-
- /* Walk through configurations and append them to our list of ConfiguredPackages */
- while($attr = $ldap->fetch()){
-
- /* Skip objects, that are tagged as removed */
- if(isset($object['FAIstate'][0])){
- if(preg_match("/removed$/",$attr['FAIstate'][0])){
- continue;
- }
- }
-
- $tmp =array();
- $tmp['Name'] = $attr['FAIvariable'][0];
- $tmp['Type'] = $attr['FAIvariableType'][0];
-
- if (isset($attr['FAIvariableContent'][0])){
- if(!in_array($attr['FAIvariableType'],array("multiselect"))){
- $tmp['Value'] = $attr['FAIvariableContent'][0];
- }else{
- $content = array();
- unset($attr['FAIvariableContent']['count']);
- foreach($attr['FAIvariableContent'] as $attr){
- $tmp['Value'][] = $attr;
- }
- }
- $this->ConfiguredPackages[$attr['FAIpackage'][0]][$attr['FAIvariable'][0]]=$tmp;
- }
- }
}
return($ret);
}
+ /*! \brief Assemble release name
+ Returns the currently used Debian Release.
+ */
+ function getRelease()
+ {
+ /* Assemble release name */
+ if (isset($this->parent->parent->fai_release)) {
+ $release = $this->parent->parent->fai_release;
+ } else {
+ $release = $this->dn;
+ # Remove CN
+ $tmp = preg_replace('/cn='.$this->cn.',/', '', $release);
+ # Remove ou=packages
+ $release = preg_replace('/'.preg_quote(get_ou('faiPackageRDN'), '/').'/', '', $tmp);
+ }
+ $tmp= preg_replace('/[,]*'.preg_quote(get_ou('faiBaseRDN'), '/').'.*$/', '', $release);
+ $tmp= preg_replace('/ou=/', '', $tmp);
+ $rev= array_reverse(split(',', $tmp));
+ $release = "/";
+ foreach ($rev as $part){
+ $release .= "/$part";
+ }
+ return(preg_replace('#^[/]*#', '', $release));
+ }
+
+ /*! \brief Assemble sections
+ Returns the currently used Debian archive sections.
+ */
+ function getSections()
+ {
+ $ret = array();
+ $repos= $this->getServerInfos();
+ if(isset($repos[$this->FAIdebianRelease])){
+ $ret = $repos[$this->FAIdebianRelease];
+ $ret = array_unique($ret);
+ }
+ return $ret;
+ }
/*! \brief Used for copy & paste.
Returns a HTML input mask, which allows to change the cn of this entry.