2022-11-02 23:21:46 +08:00
< ? php
/* @ authorcode codestrings
* @ 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' );
}
2023-02-06 20:10:06 +08:00
require libfile ( 'function/code' );
2023-02-09 20:00:07 +08:00
Hook :: listen ( 'check_login' );
2022-11-02 23:21:46 +08:00
$filter = trim ( $_GET [ 'filter' ]);
if ( $filter == 'new' ){ //列出所有新通知
$list = array ();
$nids = array (); //new>0
foreach ( DB :: fetch_all ( " select n.*,u.avatarstatus from %t n LEFT JOIN %t u ON n.authorid=u.uid where n.new>0 and n.uid=%d order by dateline DESC " , array ( 'notification' , 'user' , $_G [ 'uid' ])) as $value ){
$value [ 'dateline' ] = dgmdate ( $value [ 'dateline' ], 'u' );
$value [ 'note' ] = dzzcode ( $value [ 'note' ], 1 , 1 , 1 , 1 , 1 );
$nids [] = $value [ 'id' ];
$list [] = $value ;
}
if ( $nids ){ //去除新标志
C :: t ( 'notification' ) -> update ( $nids , array ( 'new' => 0 ));
}
} elseif ( $filter == 'checknew' ){ //检查有没有新通知
$num = DB :: result_first ( " select COUNT(*) from %t where new>0 and uid=%d " , array ( 'notification' , $_G [ 'uid' ]));
2023-02-09 20:00:07 +08:00
exit ( json_encode ( array ( 'sum' => $num , 'timeout' => $_G [ 'setting' ][ 'notification' ] * 1000 )));
2022-11-02 23:21:46 +08:00
} else {
$list = array ();
$page = empty ( $_GET [ 'page' ]) ? 1 : intval ( $_GET [ 'page' ]);
$fromid = isset ( $_GET [ 'appid' ]) ? intval ( $_GET [ 'appid' ]) : '' ;
$keyword = isset ( $_GET [ 'keyword' ]) ? trim ( $_GET [ 'keyword' ]) : '' ;
$searchsql = " and 1 " ;
$perpage = 20 ;
$start = ( $page - 1 ) * $perpage ;
$gets = array (
2023-08-30 17:17:34 +08:00
'mod' => MOD_NAME ,
2022-11-02 23:21:46 +08:00
'op' => 'notification' ,
'filter' => 'all'
);
//获取通知包含类型
$searchappid = array ();
foreach ( DB :: fetch_all ( " select distinct(from_id) from %t where uid = %d " , array ( 'notification' , $_G [ 'uid' ])) as $v ){
$searchappid [] = $v [ 'from_id' ];
}
2024-04-22 20:40:02 +08:00
if ( ! $_G [ 'setting' ][ 'bbclosed' ]){
2024-09-29 15:22:35 +08:00
$sitelogo = $_G [ 'setting' ][ 'sitelogo' ] ? 'index.php?mod=io&op=thumbnail&size=small&original=1&path=' . dzzencode ( 'attach::' . $_G [ 'setting' ][ 'sitelogo' ]) : 'static/image/common/logo.png' ;
2024-04-22 20:40:02 +08:00
} else {
$sitelogo = 'static/image/common/logo.png' ;
}
2022-11-02 23:21:46 +08:00
$searchcats = array ();
if ( in_array ( 0 , $searchappid )){
$systemindex = array_search ( 0 , $searchappid );
unset ( $searchappid [ $systemindex ]);
2023-02-09 20:00:07 +08:00
$searchcats [ 1 ] = array ( 'appid' => 1 , 'appname' => '系统' , 'appico' => $sitelogo );
2022-11-02 23:21:46 +08:00
}
if ( count ( $searchappid ) > 0 ){
foreach ( DB :: fetch_all ( " select appname,appid,appico from %t where appid in(%n) " , array ( 'app_market' , $searchappid )) as $v ){
$searchcats [ $v [ 'appid' ] + 1 ] = array ( 'appid' => $v [ 'appid' ] + 1 , 'appname' => $v [ 'appname' ], 'appico' => $_G [ 'setting' ][ 'attachurl' ] . $v [ 'appico' ]);
}
}
//如果接收到搜索条件按条件搜索
//通知类型
if ( ! is_string ( $fromid )){
2023-02-09 20:00:07 +08:00
$gets [ 'appid' ] = $fromid ;
$appid = $fromid - 1 ;
$searchsql .= " and n.from_id = { $appid } " ;
$navtitle = $searchcats [ $fromid ][ 'appname' ] . ' - ' . lang ( 'panel_notice_title' );
$img = $searchcats [ $fromid ][ 'appico' ];
$tongzhileixing = $searchcats [ $fromid ][ 'appname' ];
2022-11-02 23:21:46 +08:00
} else {
2023-02-09 20:00:07 +08:00
$tongzhileixing = '全部通知' ;
$navtitle = '全部通知' . ' - ' . lang ( 'panel_notice_title' );
2022-11-02 23:21:46 +08:00
}
$params = array ( 'notification' , 'user' , 'app_market' , $_G [ 'uid' ]);
$countparam = array ( 'notification' , $_G [ 'uid' ]);
//通知内容
if ( $keyword ){
$searchsql .= ' and n.wx_note like(%s)' ;
$gets [ 'keyword' ] = $keyword ;
$countparam [] = '%' . $keyword . '%' ;
$params [] = '%' . $keyword . '%' ;
}
$theurl = BASESCRIPT . " ? " . url_implode ( $gets );
$list = array ();
if ( $count = DB :: result_first ( " select COUNT(*) from %t n where n.uid=%d $searchsql " , $countparam )){
foreach ( DB :: fetch_all ( " select n.*,u.avatarstatus,a.appico from %t n LEFT JOIN %t u ON n.authorid=u.uid left join %t a on n.from_id = a.appid where n.uid=%d $searchsql order by n.dateline DESC limit $start , $perpage " , $params ) as $value ){
$value [ 'dateline' ] = dgmdate ( $value [ 'dateline' ], 'u' );
$value [ 'note' ] = dzzcode ( $value [ 'note' ], 1 , 1 , 1 , 1 , 1 );
if ( ! $value [ 'appico' ]){
2023-02-09 20:00:07 +08:00
$value [ 'appico' ] = $sitelogo ;
2022-11-02 23:21:46 +08:00
} else {
$value [ 'appico' ] = $_G [ 'setting' ][ 'attachurl' ] . $value [ 'appico' ];
}
$list [] = $value ;
}
}
$next = false ;
if ( $count && $count > $start + count ( $list )) $next = true ;
$theurl = DZZSCRIPT . " ? " . url_implode ( $gets ); //分页链接
$multi = multi ( $count , $perpage , $page , $theurl );
include template ( 'notification_list' );
dexit ();
}
include template ( 'notification' );
dexit ();
?>