Commit 6faa2411 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

feat(core) Moved objectClass list to static plInfo

This allows to generate filters automagically most of the time and avoid
 duplicated informations.

issue #5135
parent 270ad481
......@@ -829,6 +829,8 @@ class config
if (!preg_match('/^\(.*\)$/', $value['filter'])) {
$value['filter'] = '('.$value['filter'].')';
}
} elseif (isset($plInfo['plFilter'])) {
$value['filter'] = $plInfo['plFilter'];
} else {
$value['filter'] = NULL;
}
......
......@@ -150,6 +150,13 @@ class pluglist {
if (!isset($infos['plTitle']) && isset($infos['plShortName'])) {
$infos['plTitle'] = $infos['plShortName'];
}
if (!empty($infos['plObjectClass']) && !isset($infos['plFilter'])) {
if (count($infos['plObjectClass']) == 1) {
$infos['plFilter'] = '(objectClass='.$infos['plObjectClass'][0].')';
} else {
$infos['plFilter'] = '(&(objectClass='.implode(')(objectClass=', $infos['plObjectClass']).'))';
}
}
if (isset($infos['plFilter'])) {
$infos['plFilterObject'] = ldapFilter::parse($infos['plFilter']);
}
......
......@@ -153,6 +153,12 @@ class simplePlugin
$this->parent = $parent;
$this->mainTab = $mainTab;
$plInfo = pluglist::pluginInfos(get_class($this));
if (isset($plInfo['plObjectClass'])) {
$this->objectclasses = $plInfo['plObjectClass'];
}
if ($attributesInfo === NULL) {
$attributesInfo = $this->getAttributesInfo();
}
......@@ -188,11 +194,10 @@ class simplePlugin
/* Ensure that we've a valid acl_category set */
if (empty($this->acl_category)) {
$tmp = pluglist::pluginInfos(get_class($this));
if (isset($tmp['plCategory'])) {
$c = key($tmp['plCategory']);
if (isset($plInfo['plCategory'])) {
$c = key($plInfo['plCategory']);
if (is_numeric($c)) {
$c = $tmp['plCategory'][0];
$c = $plInfo['plCategory'][0];
}
$this->acl_category = $c.'/';
}
......
......@@ -260,8 +260,6 @@ class ACLsAssignmentAttribute extends DialogOrderedArrayAttribute
class aclAssignment extends simplePlugin
{
var $objectclasses = array('gosaAcl');
static function plInfo()
{
global $config;
......@@ -269,7 +267,6 @@ class aclAssignment extends simplePlugin
'aclAssignment' => array(
'aclCategory' => 'acl',
'name' => _('ACL assignment'),
'filter' => 'objectClass=gosaAcl',
'ou' => '',
'icon' => 'geticon.php?context=categories&icon=acl&size=16',
'tabClass' => 'simpleTabs_noSpecial',
......@@ -284,6 +281,7 @@ class aclAssignment extends simplePlugin
return array(
'plShortName' => _('ACL Assignment'),
'plDescription' => _('Access control roles assignment'),
'plObjectClass' => array('gosaAcl'),
'plObjectType' => $oc,
'plForeignKeys' => array(
'gosaAclEntry' => array(
......
......@@ -69,17 +69,15 @@ class ACLsAttribute extends DialogOrderedArrayAttribute
class aclRole extends simplePlugin
{
var $objectclasses = array('top','gosaRole');
static function plInfo()
{
return array(
'plShortName' => _('Role'),
'plDescription' => _('Access control roles'),
'plObjectClass' => array('gosaRole'),
'plObjectType' => array('aclRole' => array(
'aclCategory' => 'acl',
'name' => _('ACL role'),
'filter' => 'objectClass=gosaRole',
'ou' => get_ou('aclRoleRDN'),
'icon' => 'geticon.php?context=categories&icon=acl&size=16',
)),
......
......@@ -20,18 +20,19 @@
class country extends department
{
static $namingAttr = "c";
var $structuralOC = array("country");
static protected $namingAttr = 'c';
protected $structuralOC = array('country');
static function plInfo()
{
return array(
'plShortName' => _('Country'),
'plDescription' => _('Country'),
'plObjectClass' => array('gosaDepartment'),
'plFilter' => '(&(objectClass=country)(objectClass=gosaDepartment))',
'plObjectType' => array('country' => array(
'aclCategory' => 'department',
'name' => _('Country'),
'filter' => '(&(objectClass=country)(objectClass=gosaDepartment))',
'ou' => '',
'icon' => 'geticon.php?context=types&icon=country&size=16',
'tabClass' => 'deptabs',
......
......@@ -20,19 +20,18 @@
class dcObject extends department
{
static $namingAttr = "dc";
var $objectclasses = array("top", "dcObject", "gosaDepartment");
var $structuralOC = array("locality");
static protected $namingAttr = 'dc';
protected $structuralOC = array('locality');
static function plInfo()
{
return array(
'plShortName' => _('Domain Component'),
'plDescription' => _('Domain Component'),
'plObjectClass' => array('dcObject', 'gosaDepartment'),
'plObjectType' => array('dcObject' => array(
'aclCategory' => 'department',
'name' => _('Domain Component'),
'filter' => '(&(objectClass=dcObject)(objectClass=gosaDepartment))',
'ou' => '',
'icon' => 'geticon.php?context=types&icon=dc&size=16',
'tabClass' => 'deptabs',
......
......@@ -21,23 +21,22 @@
class department extends simplePlugin
{
static $namingAttr = 'ou';
/* Do not append the structural object classes here, they are added dynamically in the constructor */
var $objectclasses = array("top", "gosaDepartment");
var $structuralOC = array("organizationalUnit");
static protected $namingAttr = 'ou';
protected $structuralOC = array('organizationalUnit');
static function plInfo()
{
return array(
'plShortName' => _('Department'),
'plDescription' => _('Departments'),
/* Do not append the structural object classes here, they are added dynamically in the constructor */
'plObjectClass' => array('gosaDepartment'),
'plFilter' => '(&(objectClass=organizationalUnit)(objectClass=gosaDepartment))',
'plCategory' => array('department' => array('objectClass' => 'gosaDepartment', 'description' => _('Departments'))),
'plObjectType' =>
array(
'department' => array(
'name' => _('Department'),
'filter' => '(&(objectClass=organizationalUnit)(objectClass=gosaDepartment))',
'ou' => '',
'icon' => 'geticon.php?context=places&icon=folder&size=16',
'tabClass' => 'deptabs',
......
......@@ -20,19 +20,18 @@
class domain extends department
{
static $namingAttr = "dc";
var $objectclasses = array("top", "domain", "gosaDepartment");
var $structuralOC = array("domain");
static protected $namingAttr = 'dc';
protected $structuralOC = array('domain');
static function plInfo()
{
return array(
'plShortName' => _('Domain'),
'plDescription' => _('Domain'),
'plObjectClass' => array('domain', 'gosaDepartment'),
'plObjectType' => array('domain' => array(
'aclCategory' => 'department',
'name' => _('Domain'),
'filter' => '(&(objectClass=domain)(objectClass=gosaDepartment))',
'ou' => '',
'icon' => 'geticon.php?context=types&icon=domain&size=16',
'tabClass' => 'deptabs',
......
......@@ -20,19 +20,19 @@
class locality extends department
{
static $namingAttr = "l";
var $objectclasses = array("top", "gosaDepartment");
var $structuralOC = array("locality");
static protected $namingAttr = 'l';
protected $structuralOC = array('locality');
static function plInfo()
{
return array(
'plShortName' => _('Locality'),
'plDescription' => _('Locality'),
'plObjectClass' => array('gosaDepartment'),
'plFilter' => '(&(!(objectClass=dcObject))(objectClass=locality)(objectClass=gosaDepartment))',
'plObjectType' => array('locality' => array(
'aclCategory' => 'department',
'name' => _('Locality'),
'filter' => '(&(!(objectClass=dcObject))(objectClass=locality)(objectClass=gosaDepartment))',
'ou' => '',
'icon' => 'geticon.php?context=types&icon=locality&size=16',
'tabClass' => 'deptabs',
......
......@@ -20,19 +20,19 @@
class organization extends department
{
static $namingAttr = "o";
var $objectclasses = array("top", "gosaDepartment");
var $structuralOC = array("organization");
static protected $namingAttr = 'o';
protected $structuralOC = array('organization');
static function plInfo()
{
return array(
'plShortName' => _('Organization'),
'plDescription' => _('Organization'),
'plObjectClass' => array('gosaDepartment'),
'plFilter' => '(&(objectClass=organization)(objectClass=gosaDepartment))',
'plObjectType' => array('organization' => array(
'aclCategory' => 'department',
'name' => _('Organization'),
'filter' => '(&(objectClass=organization)(objectClass=gosaDepartment))',
'ou' => '',
'icon' => 'geticon.php?context=types&icon=organization&size=16',
'tabClass' => 'deptabs',
......
......@@ -151,8 +151,6 @@ class ObjectSelectDialog extends GenericSelectDialog
class ogroup extends simplePlugin
{
var $objectclasses = array('groupOfNames', 'gosaGroupOfNames');
var $used_workstations = array();
protected $savedTypedMembers;
......@@ -176,11 +174,12 @@ class ogroup extends simplePlugin
'plDescription' => _('Object group information'),
'plFilter' => '(objectClass=groupOfNames)',
'plPriority' => 1,
'plObjectClass' => array('groupOfNames', 'gosaGroupOfNames'),
'plFilter' => '(objectClass=groupOfNames)',
'plObjectType' => array('ogroup' => array(
'name' => _('Group'),
'description' => _('Group'),
'ou' => get_ou('ogroupRDN'),
'filter' => 'objectClass=groupOfNames',
'icon' => 'geticon.php?context=types&icon=resource-group&size=16',
'tabClass' => 'ogrouptabs',
)),
......
......@@ -47,20 +47,18 @@ class RoleMembersAttribute extends UsersAttribute
class roleGeneric extends simplePlugin
{
var $objectclasses = array('organizationalRole');
static function plInfo()
{
return array(
'plShortName' => _('Role'),
'plDescription' => _('Role information'),
'plObjectClass' => array('organizationalRole'),
'plFilter' => '(&(objectClass=organizationalRole)(!(objectClass=simpleSecurityObject)))',
'plObjectType' => array('role' =>
array(
'name' => _('Role'),
'description' => _('Organizational role'),
'ou' => get_ou('roleRDN'),
'filter' => '(&(objectClass=organizationalRole)(!(objectClass=simpleSecurityObject)))',
'icon' => 'geticon.php?context=types&icon=role&size=16',
'mainAttr' => 'cn',
)
......
......@@ -21,7 +21,7 @@
/* Debug level is an OR combination of several values */
class DebugLevelAttribute extends SetAttribute
{
protected function loadAttrValue ($attrs)
protected function loadAttrValue (array $attrs)
{
if (isset($attrs[$this->getLdapName()])) {
$value = $attrs[$this->getLdapName()][0];
......@@ -48,8 +48,6 @@ class DebugLevelAttribute extends SetAttribute
class configInLdap extends simplePlugin
{
var $objectclasses = array("fusionDirectoryConf");
static function plInfo()
{
return array(
......@@ -57,6 +55,7 @@ class configInLdap extends simplePlugin
'plTitle' => _('FusionDirectory configuration'),
'plDescription' => _('Configuration screen of FusionDirectory'),
'plIcon' => 'geticon.php?context=categories&icon=settings&size=48',
'plObjectClass' => array('fusionDirectoryConf'),
'plObjectType' => array(
'configuration' => array(
'name' => _('FusionDirectory configuration'),
......
......@@ -20,14 +20,13 @@
class dashboardConfig extends simplePlugin
{
var $objectclasses = array('fdDashboardPluginConf');
static function plInfo()
{
return array(
'plShortName' => _('Dashboard configuration'),
'plDescription' => _('FusionDirectory dashboard plugin configuration'),
'plCategory' => array('configuration'),
'plObjectClass' => array('fdDashboardPluginConf'),
'plObjectType' => array('smallConfig'),
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo())
......
......@@ -20,17 +20,16 @@
class mainPluginsConfig extends simplePlugin
{
var $objectclasses = array("fusionDirectoryPluginsConf");
static function plInfo()
{
return array(
"plShortName" => _("Plugins configuration"),
"plDescription" => _("FusionDirectory plugins configuration"),
"plCategory" => array("configuration"),
"plObjectType" => array("smallConfig"),
'plShortName' => _('Plugins configuration'),
'plDescription' => _('FusionDirectory plugins configuration'),
'plCategory' => array('configuration'),
'plObjectClass' => array('fusionDirectoryPluginsConf'),
'plObjectType' => array('smallConfig'),
"plProvidedAcls" => parent::generatePlProvidedAcls(static::getAttributesInfo())
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo())
);
}
......
......@@ -26,12 +26,12 @@ class pluginsConfigInLdap extends multiPlugin
static function plInfo()
{
return array(
"plShortName" => _("Plugins"),
"plDescription" => _("Configuration for plugins"),
"plPriority" => 20,
"plObjectType" => array("configuration"),
'plShortName' => _('Plugins'),
'plDescription' => _('Configuration for plugins'),
'plPriority' => 20,
'plObjectType' => array('configuration'),
"plProvidedAcls" => array()
'plProvidedAcls' => array()
);
}
}
......
......@@ -20,13 +20,12 @@
class recoveryConfig extends simplePlugin
{
var $objectclasses = array('fdPasswordRecoveryConf');
static function plInfo()
{
return array(
'plShortName' => _('Password recovery'),
'plDescription' => _('Settings for the password recovery feature'),
'plObjectClass' => array('fdPasswordRecoveryConf'),
'plObjectType' => array('configuration'),
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo())
......
......@@ -84,7 +84,7 @@ class UserPasswordAttribute extends CompositeAttribute
}
/* We need to handle method select disabling manually */
function renderAttribute(&$attributes, $readOnly)
function renderAttribute(array &$attributes, $readOnly)
{
global $config;
if ($this->visible) {
......@@ -110,7 +110,7 @@ class UserPasswordAttribute extends CompositeAttribute
/*! \brief Loads this attribute value from the attrs array
*/
protected function loadAttrValue ($attrs)
protected function loadAttrValue (array $attrs)
{
if (isset($attrs[$this->getLdapName()])) {
$this->setValue($this->inputValue($attrs[$this->getLdapName()][0]));
......@@ -186,7 +186,7 @@ class UserPasswordAttribute extends CompositeAttribute
return array($pw_storage, $password, $password, $value, $locked);
}
function writeValues($values)
function writeValues(array $values)
{
if ($this->needPassword[$values[0]] && ($values[1] == '')) {
if ($this->plugin->is_template) {
......@@ -268,8 +268,6 @@ class PostalAddressAttribute extends TextAreaAttribute
class user extends simplePlugin
{
var $objectclasses = array('inetOrgPerson','organizationalPerson','person');
private $was_locked;
static function plInfo()
......@@ -277,14 +275,14 @@ class user extends simplePlugin
return array(
'plShortName' => _('User'),
'plDescription' => _('User account information'),
'plFilter' => '(objectClass=inetOrgPerson)',
'plIcon' => 'geticon.php?context=applications&icon=user-info&size=48',
'plSmallIcon' => 'geticon.php?context=applications&icon=user-info&size=16',
'plSelfModify' => TRUE,
'plObjectClass' => array('inetOrgPerson','organizationalPerson','person'),
'plFilter' => '(objectClass=inetOrgPerson)',
'plObjectType' => array('user' => array(
'name' => _('User'),
'description' => _('User account'),
'filter' => '(objectClass=inetOrgPerson)',
'mainAttr' => 'uid',
'nameAttr' => 'cn',
'icon' => 'geticon.php?context=types&icon=user&size=16',
......
Markdown is supported
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