Skip to content

Commit 5f005b5

Browse files
committed
Userlist filtering fix.
1 parent 010ba14 commit 5f005b5

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

e107_handlers/form_handler.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,9 @@ function datepicker($name, $datestamp = false, $options = null)
10671067
* @param array $options
10681068
* @param string $options['group'] if == 'class' then users will be sorted into userclass groups.
10691069
* @param string $options['fields']
1070-
* @param string $options['classes']
1070+
* @param string $options['classes'] - single or comma-separated list of user-classes members to include.
1071+
* @param string $options['excludeSelf'] = exlude logged in user from list.
1072+
* @param string $options['return'] if == 'array' an array is returned.
10711073
* @return string select form element.
10721074
*/
10731075
public function userlist($name, $val=null, $options=array())
@@ -1133,9 +1135,16 @@ public function userlist($name, $val=null, $options=array())
11331135
foreach($users as $u)
11341136
{
11351137
$uclass = explode(',',$u['user_class']);
1136-
if(($classList == e_UC_ADMIN) || ($classList = e_UC_MEMBER) || in_array($cls,$uclass))
1138+
1139+
if(($classList == e_UC_ADMIN) || ($classList == e_UC_MEMBER) || in_array($cls,$uclass))
11371140
{
11381141
$id = $u['user_id'];
1142+
1143+
if(!empty($options['excludeSelf']) && ($id == USERID))
1144+
{
1145+
continue;
1146+
}
1147+
11391148
$opt[$cname][$id] = $u['user_name'];
11401149
}
11411150
}
@@ -1154,6 +1163,15 @@ public function userlist($name, $val=null, $options=array())
11541163

11551164
}
11561165

1166+
1167+
ksort($opt);
1168+
1169+
1170+
if(!empty($options['return']) && $options['return'] == 'array') // can be used by user.php ajax method..
1171+
{
1172+
return $opt;
1173+
}
1174+
11571175
return $this->select($name,$opt,$val,$options, varset($options['default'],null));
11581176

11591177
}

e107_plugins/pm/pm_shortcodes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public function sc_pm_form_touser()
176176
else
177177
{
178178
$frm = e107::getForm();
179-
$ret = $frm->userlist('pm_to',null,array('default'=>'blank', 'classes'=>varset($this->pmPrefs['send_to_class'], e_UC_MEMBER)));
179+
$ret = $frm->userlist('pm_to',null,array('excludeSelf'=>true, 'default'=>'blank', 'classes'=>varset($this->pmPrefs['send_to_class'], e_UC_MEMBER)));
180180
}
181181

182182

0 commit comments

Comments
 (0)