Commit 04dd554b authored by Côme Bernigaud's avatar Côme Bernigaud Committed by Benoit Mortier
Browse files

Fixes #3334 Users are now using simpleManagement

parent bc77b97d
......@@ -173,4 +173,21 @@ class ldapFilterLeaf extends ldapFilter
}
}
function fdTemplateFilter($filter)
{
if ($filter instanceof ldapFilterLeaf) {
if ($filter->operator == '=') {
$filter->subparts[1] = $filter->subparts[0].':'.$filter->subparts[1];
$filter->subparts[0] = 'fdTemplateField';
} else {
trigger_error('Not able to adapt this filter for templates');
}
} else {
foreach ($filter->subparts as &$subpart) {
$subpart = fdTemplateFilter($subpart);
}
}
return $filter;
}
?>
......@@ -173,6 +173,9 @@ class plugin
/* Load data to 'attrs' and save 'dn' */
if ($object !== NULL) {
$this->attrs = $object->attrs;
if (isset($object->is_template)) {
$this->setTemplate($object->is_template);
}
} else {
$ldap = $this->config->get_ldap_link();
$ldap->cat($this->dn);
......@@ -181,8 +184,8 @@ class plugin
/* Set the template flag according to the existence of objectClass fdTemplate */
if (isset($this->attrs['objectClass'])) {
if (in_array_ics ("fdTemplate", $this->attrs['objectClass'])) {
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "found", "Template check");
if (in_array_ics ('fdTemplate', $this->attrs['objectClass'])) {
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, 'found', 'Template check');
$this->templateLoadAttrs($this->attrs);
}
}
......@@ -190,7 +193,7 @@ class plugin
/* Is Account? */
if ($this->is_this_account($this->attrs)) {
$this->is_account = TRUE;
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "found", "Object check");
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, 'found', 'Object check');
}
}
......@@ -437,22 +440,30 @@ class plugin
/* Start with empty array */
$this->attrs = array();
/* Get current objectClasses in order to add the required ones */
$ldap->cat($this->dn);
if ($this->is_template) {
// TODO: do it this way even if not a template?
$this->attrs['objectClass'] = $this->objectclasses;
if (!empty($this->saved_attributes)) {
$this->attrs['objectClass'] = array_merge_unique($this->saved_attributes['objectClass'], $this->attrs['objectClass']);
}
} else {
/* Get current objectClasses in order to add the required ones */
$ldap->cat($this->dn);
$tmp = $ldap->fetch ();
$tmp = $ldap->fetch ();
$oc = array();
if (isset($tmp['objectClass'])) {
$oc = $tmp["objectClass"];
unset($oc['count']);
$this->is_new = FALSE;
} else {
$this->is_new = TRUE;
}
$oc = array();
if (isset($tmp['objectClass'])) {
$oc = $tmp["objectClass"];
unset($oc['count']);
$this->is_new = FALSE;
} else {
$this->is_new = TRUE;
}
/* Load (minimum) attributes, add missing ones */
$this->attrs['objectClass'] = array_merge_unique($oc, $this->objectclasses);
/* Load (minimum) attributes, add missing ones */
$this->attrs['objectClass'] = array_merge_unique($oc, $this->objectclasses);
}
/* Copy standard attributes */
foreach ($this->attributes as $val) {
......
......@@ -18,6 +18,7 @@
<attribute>cn</attribute>
<attribute>uid</attribute>
<attribute>userPassword</attribute>
<attribute>fdTemplateField</attribute>
</query>
<scope>auto</scope>
</search>
......
......@@ -11,22 +11,6 @@
<label>List of users</label>
<defaultSortColumn>1</defaultSortColumn>
<objectType>
<label>Template</label>
<objectClass>fdTemplate</objectClass>
<category>user</category>
<class>user</class>
<image>plugins/users/images/select_template.png</image>
</objectType>
<objectType>
<label>User</label>
<objectClass>gosaAccount</objectClass>
<category>user</category>
<class>user</class>
<image>geticon.php?context=types&amp;icon=user&amp;size=16</image>
</objectType>
</definition>
<table>
......@@ -89,16 +73,16 @@
<label>Create</label>
<action>
<name>new</name>
<name>new_user</name>
<type>entry</type>
<image>geticon.php?context=types&amp;icon=user&amp;size=16</image>
<label>User</label>
</action>
<action>
<name>new_template</name>
<name>new_template_user</name>
<type>entry</type>
<image>plugins/users/images/select_template.png</image>
<image>geticon.php?context=actions&amp;icon=document-new&amp;size=16</image>
<label>Template</label>
</action>
</action>
......@@ -121,14 +105,6 @@
<label>Remove</label>
</action>
<action>
<name>password</name>
<type>entry</type>
<image>geticon.php?context=status&amp;icon=dialog-password&amp;size=16</image>
<label>Change password</label>
<acl>user/password[w]</acl>
</action>
<action>
<type>separator</type>
</action>
......@@ -154,7 +130,7 @@
</action>
<action>
<name>templatize</name>
<name>template_apply_user</name>
<type>entry</type>
<image>geticon.php?context=actions&amp;icon=tools-wizard&amp;size=16</image>
<label>Apply template</label>
......@@ -185,7 +161,7 @@
<actiontriggers snapshot="true" copypaste="true">
<action>
<name>newfromtpl</name>
<name>template_apply_user</name>
<type>entry</type>
<image>geticon.php?context=actions&amp;icon=document-new&amp;size=16</image>
<objectclass>fdTemplate</objectclass>
......@@ -214,15 +190,6 @@
<label>%{filter:lockLabel(userPassword)}</label>
</action>
<action>
<name>password</name>
<type>entry</type>
<objectclass>!fdTemplate</objectclass>
<acl>user/password[w]</acl>
<image>geticon.php?context=status&amp;icon=dialog-password&amp;size=16</image>
<label>Change password</label>
</action>
<action>
<name>snapshot</name>
<type>snapshot</type>
......
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