mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-05 05:29:13 +01:00
Work in progress of straightening out the user selection options
This commit is contained in:
parent
a82580211e
commit
c735663346
@ -489,7 +489,14 @@ class etemplate_widget_menupopup extends etemplate_widget
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// Popup is the only preference option that doesn't need more select options
|
||||||
|
if($select_pref == 'popup') break;
|
||||||
|
|
||||||
|
// Determine if users or groups (or both) are needed
|
||||||
|
$groups = in_array($type, array('owngroups','groups','both')) && $select_pref != 'none';
|
||||||
|
$accounts = ($type == 'both') || (!$groups && $select_pref != 'none');
|
||||||
|
|
||||||
|
// If there are group, type or preference based restrictions, find those
|
||||||
if($type == 'owngroups' || $select_pref == 'groupmembers')
|
if($type == 'owngroups' || $select_pref == 'groupmembers')
|
||||||
{
|
{
|
||||||
$owngroups = true;
|
$owngroups = true;
|
||||||
@ -501,11 +508,11 @@ class etemplate_widget_menupopup extends etemplate_widget
|
|||||||
$mygroups[] = $GLOBALS['egw_info']['user']['account_primary_group'];
|
$mygroups[] = $GLOBALS['egw_info']['user']['account_primary_group'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Popup is the only preference option that doesn't need more select options
|
|
||||||
if($select_pref == 'popup') break;
|
|
||||||
|
|
||||||
$no_lang = True;
|
error_log("$widget Type $type Pref: $select_pref Groups:".array2string($mygroups));
|
||||||
$accs = array();
|
$accs = array();
|
||||||
|
|
||||||
|
// No restrictions, just search for the right type
|
||||||
if(!$mygroups)
|
if(!$mygroups)
|
||||||
{
|
{
|
||||||
$accs = $GLOBALS['egw']->accounts->search(array(
|
$accs = $GLOBALS['egw']->accounts->search(array(
|
||||||
@ -513,13 +520,17 @@ class etemplate_widget_menupopup extends etemplate_widget
|
|||||||
'order' => 'account_fullname', // order according to pref of how to display accounts
|
'order' => 'account_fullname', // order according to pref of how to display accounts
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
else if ($type == 'groups')
|
|
||||||
{
|
// Add restricted groups, and expand restricted groups into users if needed
|
||||||
$accs = $GLOBALS['egw']->accounts->get_list($type);
|
if($owngroups)
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
foreach($mygroups as $group)
|
foreach($mygroups as $group)
|
||||||
|
{
|
||||||
|
if($groups)
|
||||||
|
{
|
||||||
|
$accs[$group] = $GLOBALS['egw']->accounts->read($group);
|
||||||
|
}
|
||||||
|
if($accounts)
|
||||||
{
|
{
|
||||||
$accs += $GLOBALS['egw']->accounts->search(array(
|
$accs += $GLOBALS['egw']->accounts->search(array(
|
||||||
'type' => $group,
|
'type' => $group,
|
||||||
@ -527,19 +538,34 @@ class etemplate_widget_menupopup extends etemplate_widget
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Primary group and search includes users from primary group,
|
||||||
|
// and all groups, not just primary group, so add those in
|
||||||
|
if($groups && $select_pref == 'primary_group')
|
||||||
|
{
|
||||||
|
foreach($GLOBALS['egw']->accounts->membership() as $group)
|
||||||
|
{
|
||||||
|
$accs[$group['account_id']] = $GLOBALS['egw']->accounts->read($group['account_id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
error_log("$widget Accs: " . implode(',',array_keys($accs)));
|
||||||
|
|
||||||
|
// Go through list of accounts (users & groups) and format them for display
|
||||||
foreach($accs as $acc)
|
foreach($accs as $acc)
|
||||||
{
|
{
|
||||||
if ($acc['account_type'] == 'u')
|
if ($acc['account_type'] == 'u' && $accounts)
|
||||||
{
|
{
|
||||||
$options[$acc['account_id']] = self::accountInfo($acc['account_id'],$acc,$type2,$type=='both');
|
$options[$acc['account_id']] = self::accountInfo($acc['account_id'],$acc,$type2,$type=='both');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach($accs as $acc)
|
foreach($accs as $acc)
|
||||||
{
|
{
|
||||||
if ($acc['account_type'] == 'g' && (!$owngroups || ($owngroups && in_array($acc['account_id'],(array)$mygroups))))
|
if ($acc['account_type'] == 'g' && $groups)
|
||||||
{
|
{
|
||||||
$options[$acc['account_id']] = self::accountInfo($acc['account_id'],$acc,$type2,$type=='both');
|
$options[$acc['account_id']] = self::accountInfo($acc['account_id'],$acc,$type2,$type=='both');
|
||||||
}
|
}
|
||||||
|
error_log(" {$acc['account_id']}:" . $options[$acc['account_id']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure all values are present, even if not normally sent (according to preferences)
|
// Make sure all values are present, even if not normally sent (according to preferences)
|
||||||
|
Loading…
Reference in New Issue
Block a user