Ejemplo n.º 1
0
function getViewPerm($news)
{
    global $_G;
    //自己发布的有权限
    if ($news['authorid'] == $_G['uid']) {
        return true;
    }
    //管理员有权限
    if (getPermByUid($_G['uid']) > 1) {
        return true;
    }
    //游客时,只要设置了范围,就没有权限;
    if ($_G['uid'] < 1 && ($news['orgids'] || $news['uids'])) {
        return false;
    }
    //转换为数组
    if ($news['orgids']) {
        $news['orgids'] = explode(',', $news['orgids']);
    } else {
        $news['orgids'] = array();
    }
    //转换为数组
    if ($news['uids']) {
        $news['uids'] = explode(',', $news['uids']);
    } else {
        $news['uids'] = array();
    }
    //判断普通用户权限
    if (!$news['uids'] && !$news['orgids']) {
        return true;
    }
    //未设置范围,全部有权限
    if ($news['uids'] && in_array($_G['uid'], $news['uids'])) {
        //用户在用户列表内,允许查看
        return true;
    }
    //当未加入机构和部门在部门列表中时,单独判断;
    if (in_array('other', $news['orgids']) && !DB::result_first("SELECT COUNT(*) from %t where uid=%d", array('organization_user', $_G['uid']))) {
        return true;
    }
    //获取用户所在的机构或部门
    $orgids = C::t('organization_user')->fetch_orgids_by_uid($_G['uid']);
    if (array_intersect($orgids, $news['orgids'])) {
        return true;
    }
    //检查每个部门的下级
    include_once libfile('function/organization');
    foreach ($orgids as $orgid) {
        $upids = getUpOrgidTree($orgid, true);
        if ($upids && array_intersect($upids, $news['orgids'])) {
            return true;
        }
    }
    return false;
}
Ejemplo n.º 2
0
function getAdminPerm($moderators)
{
    //检查用户是否是管理员
    global $_G;
    if ($_G['uid'] < 1) {
        return 0;
    }
    if ($_G['adminid'] == 1) {
        return 3;
    }
    $muids = $moderators ? explode(',', $moderators) : array();
    if (!$muids) {
        return 0;
    }
    //转换为数组
    $orgids = array();
    $uids = array();
    foreach ($muids as $value) {
        if (strpos($value, 'uid_') !== false) {
            $uids[] = str_replace('uid_', '', $value);
        } else {
            $orgids[] = $value;
        }
    }
    if (in_array($_G['uid'], $uids)) {
        return 1;
    }
    //当未加入机构和部门在部门列表中时,单独判断;
    if (in_array('other', $orgids) && !DB::result_first("SELECT COUNT(*) from %t where uid=%d and orgid>0", array('organization_user', $_G['uid']))) {
        return 1;
    }
    //获取用户所在的机构或部门
    $uorgids = C::t('organization_user')->fetch_orgids_by_uid($_G['uid']);
    if (array_intersect($uorgids, $orgids)) {
        return 1;
    }
    //检查每个部门的上级
    include_once libfile('function/organization');
    foreach ($uorgids as $orgid) {
        $upids = getUpOrgidTree($orgid, true);
        if ($upids && array_intersect($upids, $orgids)) {
            return 1;
        }
    }
    return 0;
}
Ejemplo n.º 3
0
 public function fetch_notin_appids_by_uid($uid)
 {
     include_once libfile('function/organization');
     $paichu_appids = $orgids = array();
     foreach (C::t('organization_user')->fetch_orgids_by_uid($uid) as $orgid) {
         if ($parentids = getUpOrgidTree($orgid)) {
             $orgids = array_merge($orgids, $parentids);
         }
     }
     if ($orgids) {
         $appids = C::t('app_organization')->fetch_appids_by_orgid($orgids);
     } else {
         $appids = array();
     }
     foreach (DB::fetch_all("select appid from %t where appid NOT IN(%n) ", array($this->_table, $appids)) as $value) {
         $paichu_appids[] = $value['appid'];
     }
     return $paichu_appids;
 }
Ejemplo n.º 4
0
    $data = array('other');
    if (!$nouser) {
        $uids = array();
        foreach (DB::fetch_all("select * from %t where {$sql} ", array('user', $str)) as $value) {
            $uids[] = $value['uid'];
            $data['uid_' . $value['uid']] = 'uid_' . $value['uid'];
        }
        $orgids = array();
        foreach ($orgusers = C::t('organization_user')->fetch_all_by_uid($uids) as $value) {
            $data['uid_' . $value['uid']] = 'orgid_' . $value['orgid'] . '_uid_' . $value['uid'];
            $orgids[] = $value['orgid'];
        }
    }
    foreach (DB::fetch_all("select orgid from %t where {$sql_org}", array('organization', $str)) as $value) {
        $orgids[] = $value['orgid'];
    }
    $orgids = array_unique($orgids);
    foreach ($orgids as $orgid) {
        $uporgids = getUpOrgidTree($orgid, true);
        foreach ($uporgids as $value) {
            $data[$value] = $value;
        }
    }
    $temp = array();
    foreach ($data as $value) {
        $temp[] = $value;
    }
    exit(json_encode($temp));
}
$ismobile = helper_browser::ismobile();
include template('orgtree');
Ejemplo n.º 5
0
                    $sql_org .= " and orgid IN(%n)";
                    $param_org[] = $orgids;
                    foreach (DB::fetch_all("select orgname,orgid,forgid from %t {$sql_org} limit 10", $param_org) as $org) {
                        $porgids = array_reverse(getUpOrgidTree($org['orgid']));
                        $titles = array();
                        foreach ($porgids as $porgid) {
                            if ($porg = C::t('organization')->fetch($porgid)) {
                                $titles[] = $porg['orgname'];
                            }
                        }
                        $data[] = array('name' => $org['orgname'], 'title' => implode('-', $titles), 'searchkey' => $py->getAllPY($org['orgname']) . $org['orgname'], 'id' => 'g' . $org['orgid'], 'icon' => $org['forgid'] ? 'dzz/system/images/department.png' : 'dzz/system/images/organization.png');
                    }
                }
                break;
            case 3:
                //全部
                foreach (DB::fetch_all("select orgname,orgid,forgid from %t {$sql_org} limit 10", $param_org) as $org) {
                    $porgids = array_reverse(getUpOrgidTree($org['orgid']));
                    $titles = array();
                    foreach ($porgids as $porgid) {
                        if ($porg = C::t('organization')->fetch($porgid)) {
                            $titles[] = $porg['orgname'];
                        }
                    }
                    $data[] = array('name' => $org['orgname'], 'title' => implode('-', $titles), 'searchkey' => $py->getAllPY($org['orgname']) . $org['orgname'], 'id' => 'g' . $org['orgid'], 'icon' => $org['forgid'] ? 'dzz/system/images/department.png' : 'dzz/system/images/organization.png');
                }
                break;
        }
    }
}
exit(json_encode($data));
Ejemplo n.º 6
0
 public function setPathkeyByOrgid($orgid, $force = 0)
 {
     //设置此机构的pathkey的值,$force>0 重设此部门的pathkey
     @set_time_limit(0);
     if (!($org = parent::fetch($orgid))) {
         return false;
     }
     if ($force || empty($org['pathkey'])) {
         //没有pathkey,
         include_once libfile('function/organization');
         if ($ids = array_reverse(getUpOrgidTree($org['orgid']))) {
             $pathkey = '_' . implode('_-_', $ids) . '_';
             if (parent::update($org['orgid'], array('pathkey' => $pathkey))) {
                 return $pathkey;
             }
         }
         return false;
     }
     //设置所有子部门的pathkey;
     if ($org['forgid'] && ($porg = parent::fetch($org['forgid']))) {
         $npathkey = $porg['pathkey'] . '-' . '_' . $orgid . '_';
     } else {
         $npathkey = '_' . $orgid . '_';
     }
     if ($org['pathkey'] == $npathkey) {
         return $npathkey;
     }
     //没有改变;
     $like = '^' . $org['pathkey'];
     if (DB::query("update %t set pathkey=REPLACE(pathkey,%s,%s) where pathkey REGEXP %s", array($this->_table, $org['pathkey'], $npathkey, $like))) {
         return $npathkey;
     }
 }
Ejemplo n.º 7
0
function checkFeedAtPerm($gid)
{
    global $_G;
    include_once libfile('function/organization');
    $_G['setting']['feed_at_range'] = unserialize($_G['setting']['feed_at_range']);
    $range = $_G['setting']['feed_at_range'][$_G['groupid']];
    if ($range == 3) {
        //所有机构
        return true;
    } elseif ($range == 2) {
        //机构
        $orgids = C::t('organization_user')->fetch_orgids_by_uid($_G['uid']);
        foreach ($orgids as $orgid) {
            $toporgids = getUpOrgidTree($orgid);
            if (in_array($gid, $toporgids)) {
                return true;
            }
        }
        return false;
    } elseif ($range == 1) {
        //部门
        $orgids = C::t('organization_user')->fetch_orgids_by_uid($_G['uid']);
        if (in_array($gid, $orgids)) {
            return true;
        }
        return false;
    }
    return false;
}
Ejemplo n.º 8
0
 * @copyright   Leyun internet Technology(Shanghai)Co.,Ltd
 * @license     http://www.dzzoffice.com/licenses/license.txt
 * @package     DzzOffice
 * @link        http://www.dzzoffice.com
 * @author      zyx(zyx@dzz.cc)
 */
if (!defined('IN_DZZ')) {
    exit('Access Denied');
}
if (!$_G['uid']) {
    exit;
}
require libfile('function/organization');
$toporgid = 0;
$orgid = intval($_GET['orgid']);
if ($org = C::t('organization')->fetch($orgid)) {
    if ($org['forgid'] == 0) {
        $toporgid = $orgid;
    } else {
        //获取此部门的顶级机构
        $orguptree = getUpOrgidTree($orgid, true);
        $toporgid = $orguptree[count($orguptree) - 1];
    }
}
//机构列表
$orgtree = getDepartmentOption($toporgid, '', true);
//获取部门的用户列表;
$userlist = C::t('organization_user')->fetch_user_by_orgid($orgid);
//获取机构部门树
//$departmenttree=getDepartmentOption($orgid);
include template('misc_seluser');
Ejemplo n.º 9
0
                    if (count($open[$arr[$count - 1]]) > $count) {
                        $open[$arr[count($arr) - 1]] = $arr;
                    }
                } else {
                    $open[$arr[$count - 1]] = $arr;
                }
            }
            if (in_array('other', $orgids)) {
                $sel_org[] = array('orgname' => '无机构人员', 'orgid' => 'other', 'forgid' => 1);
            }
        }
        if ($uids) {
            $sel_user = C::t('user')->fetch_all($uids);
            if ($aorgids = C::t('organization_user')->fetch_orgids_by_uid($uids)) {
                foreach ($aorgids as $orgid) {
                    $arr = getUpOrgidTree($orgid, true);
                    $arr = array_reverse($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;
                    }
                }
            }
        }
        $openarr = json_encode(array('muids' => $open));
    }
} elseif ($do == 'cover') {
Ejemplo n.º 10
0
function getUpOrgidTree($orgid, $onlyid = true, $pids = array())
{
    global $_G;
    if ($org = C::t('organization')->fetch($orgid)) {
        if ($onlyid) {
            $pids[] = $orgid;
        } else {
            $pids[$orgid] = $org;
        }
        $pids = getUpOrgidTree($org['forgid'], $onlyid, $pids);
    }
    return $pids;
}
Ejemplo n.º 11
0
 public function ismoderator_by_uid_orgid($orgid, $uid, $up = 1)
 {
     global $_G;
     include_once libfile('function/organization');
     if ($_G['adminid'] == 1) {
         return true;
     }
     if ($up) {
         $orgids = getUpOrgidTree($orgid, true);
     } else {
         $orgids = array($orgid);
     }
     return DB::result_first("select COUNT(*) from %t where orgid IN (%n) and uid=%d ", array($this->_table, $orgids, $uid));
 }