function atreplacement($matches) { global $at_users, $_G; include_once libfile('function/organization'); if (strpos($matches[2], 'g') !== false) { $gid = str_replace('g', '', $matches[2]); if (($org = C::t('organization')->fetch($gid)) && checkAtPerm($gid)) { //判定用户有没有权限@此部门 $uids = getUserByOrgid($gid, true, array(), true); foreach ($uids as $uid) { if ($uid != $_G['uid']) { $at_users[] = $uid; } } return '[org=' . $gid . '] @' . $org['orgname'] . '[/org]'; } else { return ''; } } else { $uid = str_replace('u', '', $matches[2]); if (($user = C::t('user')->fetch($uid)) && $user['uid'] != $_G['uid']) { $at_users[] = $user['uid']; return '[uid=' . $user['uid'] . ']@' . $user['username'] . '[/uid]'; } else { return $matches[0]; } } }
function getDepartmentJStree($orgid = 0, $notin = array()) { static $uids = array(); $html = ''; foreach (C::t('organization')->fetch_all_by_forgid($orgid, false) as $key => $value) { $html .= '<li data-jstree=\'{"type":"org","icon":"dzz/system/images/organization.png"}\'>' . $value['orgname']; $html .= '<ul>'; if (C::t('organization')->fetch_all_by_forgid($value['orgid'], true)) { $re = getDepartmentJStree($value['orgid'], $notin, $html); $html .= $re['html']; } $users = getUserByOrgid($value['orgid'], 0, $notin); foreach ($users as $value1) { $uids[] = $value1['uid']; $html .= '<li uid="' . $value1['uid'] . '" data-jstree=\'{"type":"user","icon":"dzz/system/images/user.png"}\'>' . $value1['username'] . '</li>'; } $html .= '</ul>'; $html .= ' </li>'; } return array('html' => $html, 'uids' => $uids); }
function groupPerm($fid, $action, $gid) { //判断容器有没有指定的权限 global $_G; $ismoderator = C::t('organization_admin')->ismoderator_by_uid_orgid($gid, $_G['uid']); //if($action=='admin' && $ismoderator) return true; if ($ismoderator) { //是机构管理员 return true; } //exit($action); include_once libfile('function/organization'); if ($gid) { $members = getUserByOrgid($gid, 1, array(), true); } if (!in_array($_G['uid'], $members)) { return false; } //if($action=='download' || $action=='saveto' || $action=='copy' ) return true; $perm = self::getPerm($fid); //exit($perm.'====='.$fid.'======='.$gid.'===='.$action); if ($perm > 0) { $power = new perm_binPerm($perm); //exit($perm.'====='.$fid.'======='.$gid.'===='.$action.'==='.$power->isPower($action)); return $power->isPower($action); } return false; }
function getUidsByOrgid($orgids, $uids) { //通过获取在此机构数组下的所有用户 @set_time_limit(0); if ($uids) { $uids = explode(',', $uids); } else { $uids = array(); } if ($orgids) { $orgids = explode(',', $orgids); } else { $orgids = array(); } if ($orgids) { //获取机构的id if (in_array('other', $orgids)) { if ($nots = C::t('organization_user')->fetch_user_not_in_orgid(1000)) { $uids = array($uids, array_keys($nots)); } $orgids = array_diff($orgids, array('other')); } if ($orgids && ($ouids = getUserByOrgid($orgids, 1, array(), true))) { $uids = array_merge($uids, $ouids); unset($ouids); } return array_unique($uids); } else { //orgids为空时 if ($uids) { return array_unique($uids); } else { //返回全体成员id foreach (DB::fetch_all("select u.uid from %t u LEFT JOIN %t s on u.uid=s.uid where u.status<1 order by s.lastactivity DESC limit 1000", array('user', 'user_status')) as $value) { $uids[] = $value['uid']; } return array_unique($uids); } } }
<?php if (!defined('IN_DZZ')) { exit('Access Denied'); } require libfile('function/organization'); if ($_GET['op'] == 'getDepartment') { $orgid = intval($_GET['orgid']); //获取机构部门树 $departmenttree = getDepartmentOption($orgid); echo '<li role="presentation"><a href="javascript:;" tabindex="-1" role="menuitem" _orgid="0" onclick="selDepart(this)">请选择部门</a></li>'; echo $departmenttree; exit; } elseif ($_GET['op'] == 'getuserlist') { $orgid = intval($_GET['orgid']); //获取机构部门树 $users = getUserByOrgid($orgid, 1); $html = ''; foreach ($users as $uid => $value) { $html .= '<li uid="' . $value['uid'] . '" username="******" >'; $html .= '<img src="avatar.php?uid=' . $value['uid'] . '" ><span>' . $value['username'] . '</span>'; $html .= '<a class="pull-right add" href="javascript:;" title="添加"><i class="glyphicon glyphicon-forward"></i></a></li>'; } echo $html; exit; }