/** * 设置回复图文 * @param array $newsData * 数组结构: * array( * "0"=>array( * 'Title'=>'msg title', * 'Description'=>'summary text', * 'PicUrl'=>'http://www.domain.com/1.jpg', * 'Url'=>'http://www.domain.com/1.html' * ), * "1"=>.... * ) */ function getLatestData($wx, $uid, $limit = 10) { $param = array('news'); $sql = "status<2"; $orderby = "ORDER BY dateline DESC"; //阅读范围查询语句 $sql .= " and ("; $sql_gid = array("orgids=''"); $orgarr = getDepartmentByUid($uid); //获取当前用户所在的部门数组 foreach ($orgarr as $value) { foreach ($value as $value1) { $sql_gid[] = "FIND_IN_SET(%d,orgids)"; $param[] = $value1['orgid']; } } $sql .= "(" . implode(' OR ', $sql_gid) . ") and ( uids='' OR FIND_IN_SET(%d,uids)))"; $param[] = $uid; $data = array(); $limit = intval($limit); if (!$limit) { $limit = 10; } foreach (DB::fetch_all("select * from %t where {$sql} {$orderby} limit {$limit} ", $param) as $value) { $temp = array(); $temp['Title'] = $value['subject']; $url = getglobal('siteurl') . 'index.php?mod=news&op=view&newid=' . $value['newid']; if ($value['type'] == 0) { //文本模式 $temp['Description'] = getstr($value['content'], 300, 0, 0, 0, -1); $temp['Url'] = getOauthRedirect($url); } elseif ($value['type'] == 1) { //图片模式 $temp['Description'] = ''; $temp['Url'] = getOauthRedirect($url); if ($pic = DB::fetch_first("select aid from %t where newid=%d limit 1", array('news_pic', $value['newid']))) { $temp['PicUrl'] = getglobal('siteurl') . 'index.php?mod=io&op=thumbnail&original=1&path=' . dzzencode('attach::' . $pic['aid']); } } else { //链接模式 $temp['Url'] = $value['url']; $temp['Description'] = ''; } $data[] = $temp; } return $data; }
$action = $_GET['action']; //判断用户访问权限 include libfile('function/organization'); include libfile('function/news', '', 'dzz/news'); $perm = getPermByUid($_G['uid']); $result = true; $sql = "1"; if ($perm < 2) { //阅读范围查询语句 if ($_G['uid'] < 1) { $sql .= " and n.orgids='' and n.uids=''"; } else { $sql .= " and ( n.authorid=%d OR ("; $param[] = $_G['uid']; $sql_gid = array("n.orgids=''"); if ($orgarr = getDepartmentByUid($_G['uid'])) { //获取当前用户所在的部门数组 foreach ($orgarr as $value) { foreach ($value as $value1) { $sql_gid[] = "FIND_IN_SET(%d,orgids)"; $param[] = $value1['orgid']; } } } else { $sql_gid[] = "FIND_IN_SET(%s,orgids)"; $param[] = 'other'; } $sql .= "(" . implode(' OR ', $sql_gid) . ") and ( n.uids='' OR FIND_IN_SET(%d,n.uids))"; $sql .= "))"; $param[] = $_G['uid']; }
$orgids = getOrgidTree($orgid); $uids = C::t('organization_user')->fetch_uids_by_orgid($orgids); if ($count = DB::result_first("SELECT COUNT(*) FROM " . DB::table('user') . " WHERE uid IN (" . dimplode($uids) . ")")) { $user = DB::fetch_all("SELECT * FROM " . DB::table('user') . " WHERE uid IN (" . dimplode($uids) . ") {$order} limit {$start},{$perpage}"); $multi = multi($count, $perpage, $page, $theurl, 'pull-right'); } } else { if ($count = DB::result_first("SELECT COUNT(*) FROM " . DB::table('user') . " WHERE 1 ")) { $user = DB::fetch_all("SELECT * FROM " . DB::table('user') . " WHERE 1 {$order} limit {$start},{$perpage}"); $multi = multi($count, $perpage, $page, $theurl, 'pull-right'); } } } $list = array(); foreach ($user as $value) { $value['department'] = getDepartmentByUid($value['uid']); $userfield = C::t('user_field')->fetch($value['uid']); $status = C::t('user_status')->fetch($value['uid']); $value['verify'] = ''; if ($_G['setting']['verify']['enabled']) { $verify = C::t('user_verify')->fetch($value['uid']); for ($i = 1; $i < 8; $i++) { if ($_G['setting']['verify'][$i]['available'] && $_G['setting']['verify'][$i]['showicon']) { $icon = ''; if ($verify['verify' . $i] && $_G['setting']['verify'][$i]['icon']) { $icon = $_G['setting']['attachurl'] . $_G['setting']['verify'][$i]['icon']; } elseif (!$verify['verify' . $i] && $_G['setting']['verify'][$i]['unverifyicon']) { $icon = $_G['setting']['attachurl'] . $_G['setting']['verify'][$i]['unverifyicon']; } if ($icon) { $value['verify'] .= '<img class="verify-icon" src="' . $icon . '" title="' . $_G['setting']['verify'][$i]['title'] . '" >';
function getOrgByUid($uid, $getManage = 0) { $orglist = array(); $arr = getDepartmentByUid($uid, $getManage); foreach ($arr as $key => $value) { $orglist[$value[0]['orgid']] = $value[0]; } foreach ($arr as $key => $value) { if (count($value) > 1) { $orglist[$value[0]['orgid']]['sublist'][$value[count($value) - 1]['orgid']] = $value[count($value) - 1]; } } return $orglist; }