summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: deebe2d)
raw | patch | inline | side by side (parent: deebe2d)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 12 Dec 2007 14:03:47 +0000 (14:03 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 12 Dec 2007 14:03:47 +0000 (14:03 +0000) |
- Group membership is now editable for multiple users
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8105 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8105 594d385d-05f5-0310-b6e9-bd551577e9d8
index 06a3ccd7a210f0e80d7a9bb88cbe249b68ca84ec..f9a02ba3e3a02e4be8c6f0393cb068f2d65bd516 100644 (file)
*/
public function populate_values()
{
-
if($this->multiple_available() && is_array($this->a_handles)){
foreach($this->o_tab->by_object as $name => $obj){
$values = $this->o_tab->by_object[$name]->get_multi_edit_values();
foreach($this->a_handles as $i_id => $o_handle){
- foreach($values as $a_name => $a_value){
- $this->a_handles[$i_id]->by_object[$name]->$a_name = $a_value;
- }
+ $this->a_handles[$i_id]->by_object[$name]->set_multi_edit_values($values);
}
}
}
index da0a6c4d1e6001f4fc9189e5e5a4ad95612d6904..9d4434090c60940007e89458bc600473da931d7f 100644 (file)
return($ret);
}
+
+ /*! \brief Update class variables with values collected by multiple edit.
+ */
+ function set_multi_edit_values($attrs)
+ {
+ foreach($attrs as $name => $value){
+ $this->$name = $value;
+ }
+ }
+
/*! \brief execute plugin
diff --git a/gosa-core/plugins/personal/posix/class_posixAccount.inc b/gosa-core/plugins/personal/posix/class_posixAccount.inc
index e1a5412c9adba153911a6030fb7232617a1e8a4d..e2430559e272bec00a20d350cf028c5ca544321f 100644 (file)
var $uid= "";
var $multiple_support = TRUE;
+ var $groupMembership_some = array();
/* constructor, if 'dn' is set, the node loads the given
'dn' from LDAP */
$smarty->assign("shells", $this->loginShellList);
$smarty->assign("secondaryGroups", $this->secondaryGroups);
$smarty->assign("primaryGroup", $this->primaryGroup);
- if (!count($this->groupMembership)){
- $smarty->assign("groupMembership", array(" "));
- } else {
+ if(!$this->multiple_support_active){
+ if (!count($this->groupMembership)){
+ $smarty->assign("groupMembership", array(" "));
+ } else {
+ $smarty->assign("groupMembership", $this->groupMembership);
+ }
+ }else{
$smarty->assign("groupMembership", $this->groupMembership);
+ $smarty->assign("groupMembership_some", $this->groupMembership_some);
}
if (count($this->groupMembership) > 16){
$smarty->assign("groups", "too_many_for_nfs");
/* Walk through groups and add the descriptive entry if not exists */
foreach ($groups as $value){
+
if (!array_key_exists($value, $this->groupMembership)){
$ldap->cat($value, array('cn', 'description', 'dn'));
$attrs= $ldap->fetch();
if(obj_is_writable($attrs['dn'],"groups/group","memberUid")){
$this->groupMembership[$attrs['dn']]= $entry;
+ if($this->multiple_support_active && isset($this->groupMembership_some[$attrs['dn']])){
+ unset($this->groupMembership_some[$attrs['dn']]);
+ }
}
}
}
if(isset($this->groupMembership[$dn_to_del]) && obj_is_writable($dn_to_del,"groups/group","memberUid")){
unset($this->groupMembership[$dn_to_del]);
}
+ if($this->multiple_support_active){
+ if(isset($this->groupMembership_some[$dn_to_del]) && obj_is_writable($dn_to_del,"groups/group","memberUid")){
+ unset($this->groupMembership_some[$dn_to_del]);
+ }
+ }
}
}
function get_multi_edit_values()
{
$ret = plugin::get_multi_edit_values();
+ $ret['groupMembership'] = $this->groupMembership;
+ $ret['groupMembership_some']= $this->groupMembership_some;
return($ret);
}
}
}
}
+
+ function init_multiple_support($attrs,$all)
+ {
+ plugin::init_multiple_support($attrs,$all);
+
+ restore_error_handler();
+
+ $groups_some = array();
+ $groups_all = array();
+ $groups_uid = array();
+ $uids = array();
+ $first = TRUE;
+
+ $uid_filter="";
+ for($i =0; $i < $this->multi_attrs_all['uid']['count'] ; $i ++){
+ $uid = $this->multi_attrs_all['uid'][$i];
+ $uids[] = $uid;
+ $uid_filter.= "(memberUid=".$uid.")";
+ }
+ $uid_filter = "(&(objectClass=posixGroup)(|".$uid_filter."))";
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search($uid_filter,array("dn","cn","memberUid"));
+ while($group = $ldap->fetch()){
+ $groups_some[$group['dn']] = $group['cn'][0];
+ for($i = 0 ; $i < $group['memberUid']['count'] ; $i++){
+ $groups_uid[$group['dn']][] = $group['memberUid'][$i];
+ }
+ }
+
+ $groups_all = $groups_some;
+ foreach($groups_all as $id => $group){
+ foreach($uids as $uid){
+ if(!in_array($uid,$groups_uid[$id])){
+ unset($groups_all[$id]);
+ break;
+ }
+ }
+ }
+
+ $this->groupMembership = $groups_all;
+ foreach( $groups_all as $dn => $cn){
+ if(isset($groups_some[$dn])){
+ unset($groups_some[$dn]);
+ }
+ }
+ $this->groupMembership_some = $groups_some;
+ }
+
+
+ function set_multi_edit_values($attrs)
+ {
+ $groups = array();
+
+ /* Update groupMembership, keep optinal group */
+ foreach($attrs['groupMembership_some'] as $dn => $cn){
+ if(isset($this->groupMembership[$dn])){
+ $groups[$dn] = $cn;
+ }
+ }
+ /* Update groupMembership, add forced groups */
+ foreach($attrs['groupMembership'] as $dn => $cn){
+ $groups[$dn] = $cn;
+ }
+ plugin::set_multi_edit_values($attrs);
+ $this->groupMembership = $groups;
+ }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
diff --git a/gosa-core/plugins/personal/posix/generic.tpl b/gosa-core/plugins/personal/posix/generic.tpl
index c9dc98d4779b4123e678e306c9ccd0411dffaa73..5371c53b73c3a57fe5364d7d27f16fd079cfad79 100644 (file)
{if !$multiple_support}
{html_options options=$groupMembership}
{else}
-
-
+ {foreach from=$groupMembership item=group key=key}
+ <option value="{$key}">{$group} ({t}In all groups{/t})</option>
+ {/foreach}
+ {foreach from=$groupMembership_some item=group key=key}
+ <option value="{$key}"
+ style='color: #888888; background: #DDDDDD;background-color: #DDDDDD;'>{$group} ({t}Not in all groups{/t})</option>
+ {/foreach}
{/if}
</select>
{/render}