Files
Pichome/dzz/system/common.php
2024-01-31 01:00:33 +08:00

208 lines
6.3 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/*
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
* @license https://www.oaooa.com/licenses/
*
* @link https://www.oaooa.com
* @author zyx(zyx@oaooa.com)
*/
if(!defined('IN_OAOOA')) {
exit('Access Denied');
}
global $_G;
// Hook::listen('check_login');//检查是否登录,未登录跳转到登录界面
$uid = $_G['uid'];
include libfile('function/filerouterule');
require libfile('function/code');
$operation = $_GET['operation'] ? trim($_GET['operation']) : '';
if($operation == 'getApp'){
$config = array();
if($_G['uid']){
$config= dzz_userconfig_init();
if(!$config){
//$config= dzz_userconfig_init();
if($config['applist']){
$applist=explode(',',$config['applist']);
}else{
$applist=array();
}
}
else{//检测不允许删除的应用,重新添加进去
if($config['applist']){
$applist=explode(',',$config['applist']);
}else{
$applist=array();
}
if($applist_n =array_keys(C::t('app_market')->fetch_all_by_notdelete($_G['uid']))) {
$newappids = array();
foreach ($applist_n as $appid) {
if (!in_array($appid, $applist)) {
$applist[] = $appid;
$newappids[] = $appid;
}
}
if ($newappids) C::t('app_user')->insert_by_uid($_G['uid'], $newappids);
C::t('user_field')->update($_G['uid'], array('applist' => implode(',', $applist)));
}
}
}else{
$applist =array_keys(C::t('app_market')->fetch_all_by_default());
}
//获取已安装应用
$app=C::t('app_market')->fetch_all_by_appid($applist);
$applist_1=array();
foreach($app as $key => $value){
if($value['isshow']<1) continue;
if($value['available']<1) continue;
if($value['position']<1) continue;//位置为无的忽略
//判断管理员应用
if($_G['adminid']!=1 && $value['group']==3){
continue;
}
$params=array('name'=>$value['identifier'],'perm'=>1,'return_type'=>'bool');
if(Hook::listen('rolecheck',$params,null,true)===false) continue;
//if($value['system'] == 2) continue;
$value['disp']+=1000;//保证库排前面
//首页固定排在最前面
if(getglobal('setting/default_mod')==$value['identifier']){
$value['disp']=-1000;
}
$applist_1[$value['appid']] = $value;
}
//获取虚拟应用
$params=array();
$vapps=Hook::listen('vapplist',$params,null,true);
foreach($vapps as $key => $value){
$params=array('name'=>'vapp/'.$value['identifier'],'perm'=>1,'return_type'=>'bool');
if(Hook::listen('rolecheck',$params,null,true)===false) continue;
//首页固定排在最前面
if(getglobal('setting/default_mod')=='vapp_'.$value['identify']){
$value['disp']=-1000;
}
$applist_1[$value['appid']] = $value;
}
//对应用根据disp 排序
if($applist_1){
$sort = array(
'direction' => 'SORT_ASC', //排序顺序标志 SORT_DESC 降序SORT_ASC 升序
'field' => 'disp', //排序字段
);
$arrSort = array();
foreach($applist_1 AS $uniqid => $row){
foreach($row AS $key=>$value){
$arrSort[$key][$uniqid] = $value;
}
}
if($sort['direction']){
array_multisort($arrSort[$sort['field']], constant($sort['direction']), $applist_1);
}
}
if($sortids=C::t('user_setting')->fetch_by_skey('myappids')){
$appids=explode(',',$sortids);
$temp=array();
foreach($appids as $appid){
if($applist_1[$appid]){
$temp[$appid]=$applist_1[$appid];
unset($applist_1[$appid]);
}
}
foreach($applist_1 as $appid =>$value){
$temp[$appid]=$value;
}
$applist_1=array_values($temp);
}else{
$applist_1=array_values($applist_1);
}
exit(json_encode(array('data'=>$applist_1)));
}elseif($operation == 'getNotice'){// 获取通知
$notice_num=DB::result_first("select COUNT(*) from %t where new>0 and uid=%d",array('notification',$_G['uid']));
exit(json_encode(array('data'=>$notice_num)));
}else{
// 地址栏名称
$navtitle = $_G['setting']['sitename'];
// 获取hash
$hash = FORMHASH;
// 获取当前用户信息
$userData = array();
$udata = DB::fetch_first("select u.uid,u.avatarstatus,u.username,u.groupid,u.adminid,u.nickname,s.svalue from %t u
left join %t s on s.uid = u.uid and s.skey=%swhere u.uid =%d",
array('user','user_setting','headerColor',$uid));
if($udata['avatarstatus'] == 1){
$userData['icon'] = 'avatar.php?uid='.$udata['uid'];
}elseif($udata['svalue']){
$userData['firstword'] = strtoupper(new_strsubstr($udata['username'],1,''));
$userData['headerColor'] = $udata['svalue'];
$userData['icon'] = false;
}else{
$colorkey = rand(1,15);
$headerColor = $colors[$colorkey];
C::t('user_setting')->insert_by_skey('headerColor',$headerColor,$udata['uid']);
$userData['firstword'] = strtoupper(new_strsubstr($udata['username'],1,''));
$userData['headerColor'] = $udata['svalue'];
}
if( C::t('user')->checkfounder($udata)){
$userData['perm'] = 3;
}elseif($udata['adminid'] == 1){
$userData['perm'] = 2;
}else{
$userData['perm'] = 1;
}
$userData['username'] = $udata['username'];
$userData['uid'] = $uid;
$userData['language'] = $_G['language'];
// 获取顶部应用
if($userData['language'] == 'en-US'){
$navMenuNames = ['System setting','Cloud settings','Orguser','App','Statistics','System Tool'];
}else{
$navMenuNames = ['系统设置','云设置','用户','应用','统计','系统工具'];
}
$navMenu = array(
array(
'name'=>$navMenuNames[0],
'index'=>'setting',
'type'=>'admin'
),
array(
'name'=>$navMenuNames[1],
'index'=>'cloudsetting',
'type'=>'admin'
),
array(
'name'=>$navMenuNames[2],
'index'=>'orguser',
'type'=>'admin'
),
array(
'name'=>$navMenuNames[3],
'index'=>'app',
'type'=>'admin'
),
array(
'name'=>$navMenuNames[4],
'index'=>'stats',
'type'=>'dzz'
),
array(
'name'=>$navMenuNames[5],
'index'=>'system',
'type'=>'admin'
),
);
// 获取通知
$notice_num=DB::result_first("select COUNT(*) from %t where new>0 and uid=%d",array('notification',$_G['uid']));
exit(json_encode(array('hash'=>$hash,'navMenu'=>$navMenu,'userData'=>$userData,'notice_num'=>$notice_num,'navtitle'=>$navtitle)));
}
?>