$zero, 'nouser'=>$nouser, 'stype'=>$stype, 'moderator'=>$moderator, 'range'=>$range, 'multiple'=>$multiple, 'nosearch'=>1, 'showjob'=>$showjob, 'exids'=>$exids, 'limit'=>$limit, 'ctrlid'=>'seluser', 'callback_url'=>$callback_url ); $theurl = MOD_URL."&op=orgtree&".url_implode($gets); $ids=explode(',',$ids); //规整默认值 g_开头的为群组,纯数字的为uid $orgids=array(); $uids=array(); foreach($ids as $value){ if(strpos($value,'g_')!==false){ if($stype==2) continue;//仅选择用户时,忽略部门和群组 $orgid=intval(str_replace('g_','',$value)); if($orgid==0) $orgid='other'; $orgids[$orgid]=$orgid; }elseif($uid=intval($value)){ if($stype==1) continue; //仅选择部门和群组时,忽略用户; $uids[$uid]=$uid; } } $selects=array();//已选数组 //组装openarr $open = array();//默认打开的 if($orgids && $stype!=2){ if(in_array('other',$orgids)){ $open['other']=array('other'); $selects['other']=array('orgid'=>0,'orgname'=>$zero); } unset($orgids['other']); $sel_org=C::t('organization')->fetch_all($orgids); foreach($sel_org as $key=> $value){ $selects[$value['orgid']]=$value; $arr=explode('-',str_replace('_','',$value['pathkey'])); if($arr){ $count = count($arr); if ($open[$arr[$count - 1]]) { if (count($open[$arr[$count - 1]]) > $count) $open[$arr[count($arr) - 1]] = $arr; } else { $open[$arr[$count - 1]] = $arr; } } } } if($uids && $stype !=1){ $sel_user=C::t('user')->fetch_all($uids); foreach($sel_user as $value){ $selects['uid_'.$value['uid']]=$sel_user[$value['uid']]; } if ($aorgids = C::t('organization_user')->fetch_orgids_by_uid($uids)) { foreach ($aorgids as $orgid) { $arr = C::t('organization')->fetch_parent_by_orgid($orgid, true); $count = count($arr); if ($open[$arr[$count - 1]]) { if (count($open[$arr[$count - 1]]) > $count) $open[$arr[count($arr) - 1]] = $arr; } else { $open[$arr[$count - 1]] = $arr; } } } } //判断是否有无机构用户 if($uids){ $no_org_uids=C::t('organization_user')->fetch_user_not_in_orgid(); if(array_intersect($uids,array_keys($no_org_uids))){ $open['other']=array('other'); } } $openarr_length=count($open)?'1':''; $openarr=json_encode($open); $ismobile = helper_browser::ismobile(); if($ismobile){ include template('mobile_selectuser'); dexit(); }else{ include template('selorguser'); exit(); }