Commit 0a66d96e authored by Côme Bernigaud's avatar Côme Bernigaud Committed by Benoit Mortier
Browse files

Fixes: #2733 Some clean on debconf

Showing with 56 additions and 101 deletions
+56 -101
......@@ -41,7 +41,7 @@ class DebconfEntriesAttribute extends CompositeAttribute
/* Load template */
$ldap = $this->plugin->config->get_ldap_link();
$ou = $this->plugin->attributesInfo['main']['attrs']['ou']->getValue();
$ou = $this->plugin->attributesAccess['ou']->getValue();
$ldap->cd("ou=templates,".$this->plugin->dn);
$ldap->search("(objectClass=debConfDbEntry)");
while ($entry = $ldap->fetch()) {
......@@ -115,12 +115,12 @@ class DebconfImportAttribute extends FileAttribute
strpos($str, "dn:");
$tmp = str_replace ("\n", "", $str); // removing breaklines
$tmp = str_replace (" ", "", $tmp); // removing spaces
if (preg_match( "/dn:.*,ou=templates,ou=(.+),".get_ou("debconfRDN").
if (preg_match( "/dn:.*,ou=templates,ou=([^,=]+),".get_ou("debconfRDN").
$this->plugin->config->current['BASE']."/",
$tmp, $matches) > 0) { // searching for dn: containing the template name
$this->plugin->attributesInfo['main']['attrs']['ou']->setPostValue($matches[1]);
$this->plugin->attributesInfo['main']['attrs']['ou']->setValue($matches[1]);
$this->plugin->attributesInfo['main']['attrs']['ou']->setDisabled(TRUE);
$this->plugin->attributesAccess['ou']->setPostValue($matches[1]);
$this->plugin->attributesAccess['ou']->setValue($matches[1]);
$this->plugin->attributesAccess['ou']->setDisabled(TRUE);
while (!feof($handle)) {
$str .= fread($handle, 1024);
......@@ -130,6 +130,7 @@ class DebconfImportAttribute extends FileAttribute
$ldap = $this->plugin->config->get_ldap_link();
try {
$ldap->import_complete_ldif($str, FALSE, FALSE);
$this->plugin->initially_was_account = TRUE;
} catch(Exception $e) {
msg_dialog::display(_('LDAP error'), $e->getMessage(), ERROR_DIALOG);
}
......@@ -156,31 +157,23 @@ class debconfProfileGeneric extends simplePlugin
var $objectclasses = array("top","organizationalUnit");
public function __construct(&$config, $dn = NULL, $object = NULL)
{
parent::__construct($config, $dn, $object);
$this->attributesInfo['main']['attrs']['ou']->setUnique(TRUE);
if (count($this->attributesInfo['entries']['attrs']['debconfEntries']->attributes) == 0) {
unset($this->attributesInfo['entries']);
$this->attributesInfo['main']['attrs']['ou']->setVisible(FALSE);
$this->attributesInfo['main']['attrs']['ou']->setDisabled(TRUE);
$this->attributesInfo['main']['name'] = _('Import');
} else {
$this->attributesInfo['main']['attrs']['import']->setVisible(FALSE);
$this->attributesInfo['main']['attrs']['import']->setDisabled(TRUE);
}
}
function ldap_save($cleanup = TRUE)
public static function plInfo()
{
parent::ldap_save($cleanup);
if (isset($this->attributesInfo['entries'])) {
$this->attributesInfo['entries']['attrs']['debconfEntries']->saveInLdap();
}
return array(
'plShortName' => _('Debconf profile'),
'plDescription' => _('Debconf profile generic'),
'plSelfModify' => FALSE,
'plCategory' => array('debconfProfile' => array('description' => _('Debconf profile'),
'objectClass' => 'debConfDbEntry')),
'plObjectType' => array('debconfProfile' => array(
'name' => _('Debconf profile'),
'filter' => 'objectClass=debConfDbEntry',
'ou' => get_ou('debconfRDN')
)),
'plProvidedAcls' => parent::generatePlProvidedAcls(self::getAttributesInfo())
);
}
// The main function : information about attributes
static function getAttributesInfo ()
{
return array(
......@@ -201,19 +194,34 @@ class debconfProfileGeneric extends simplePlugin
);
}
/* Return plugin informations for acl handling */
public static function plInfo()
public function __construct(&$config, $dn = NULL, $object = NULL)
{
return array(
"plShortName" => _("Debconf profile"),
"plDescription" => _("Debconf profile generic"),
"plSelfModify" => FALSE,
"plCategory" => array("debconfProfile" => array("description" => _("Debconf profile"),
"objectClass" => "debConfDbEntry")),
"plObjectType" => array("debconfProfile" => array( "name" => _("Debconf profile"),
"filter" => "objectClass=debConfDbEntry")),
"plProvidedAcls" => parent::generatePlProvidedAcls(self::getAttributesInfo())
);
parent::__construct($config, $dn, $object);
$this->attributesAccess['ou']->setUnique(TRUE);
if (count($this->attributesAccess['debconfEntries']->attributes) == 0) {
unset($this->attributesInfo['entries']);
$this->attributesAccess['ou']->setVisible(FALSE);
$this->attributesAccess['ou']->setDisabled(TRUE);
$this->attributesInfo['main']['name'] = _('Import');
} else {
$this->attributesAccess['import']->setVisible(FALSE);
$this->attributesAccess['import']->setDisabled(TRUE);
}
}
function compute_dn()
{
$ou = $this->attributesAccess['ou']->getValue();
return "ou=$ou,".get_ou("debconfRDN").$this->config->current['BASE'];
}
function ldap_save($cleanup = TRUE)
{
parent::ldap_save($cleanup);
if (isset($this->attributesInfo['entries'])) {
$this->attributesInfo['entries']['attrs']['debconfEntries']->saveInLdap();
}
}
}
?>
......@@ -22,7 +22,7 @@
class debconfProfileManagement extends management
{
// Tab definition
protected $tabClass = "debconfprofiletabs";
protected $tabClass = "simpleTabs";
protected $tabType = "DEBCONFPROFILETABS";
protected $aclCategory = "debconfProfile";
protected $aclPlugin = "debconfProfile";
......@@ -32,14 +32,14 @@ class debconfProfileManagement extends management
static function plInfo()
{
return array(
"plShortName" => _("Debconf"),
"plDescription" => _("Debconf profile management"),
"plIcon" => "plugins/debconf/images/icon.png",
"plPriority" => 31,
"plSection" => "admin",
"plCategory" => array("debconfProfile"),
'plShortName' => _('Debconf'),
'plDescription' => _('Debconf profile management'),
'plIcon' => 'plugins/debconf/images/icon.png',
'plPriority' => 31,
'plSection' => 'admin',
'plManages' => array('debconfProfile'),
"plProvidedAcls" => array()
'plProvidedAcls' => array()
);
}
......
......@@ -34,6 +34,7 @@
<frequency>0.5</frequency>
<characters>3</characters>
</autocomplete>
<scope>one</scope>
</element>
</filterdef>
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2011-2013 FusionDirectory
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
class debconfprofiletabs extends tabs
{
var $Release = "";
function __construct($config, $data, $dn, $category, $copied_object = NULL)
{
parent::__construct($config, $data, $dn, $category, $copied_object);
/* Add references/acls/snapshots */
$this->addSpecialTabs();
}
function save()
{
$baseobject = $this->getBaseObject();
$ou = $baseobject->attributesInfo['main']['attrs']['ou']->getValue();
$new_dn = "ou=$ou,".get_ou("debconfRDN").$this->config->current['BASE'];
/* Move group? */
if ($this->dn != $new_dn) {
/* Write entry on new 'dn' */
if ($this->dn != "new") {
$baseobject->move($this->dn, $new_dn);
}
/* Happen to use the new one */
$this->dn = $new_dn;
}
parent::save();
}
}
?>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment