public function render1($data)
 {
     $data['entity'] = M('store_entity')->find($data['info']['entity_id']);
     $data['data'] = M('Data')->getByInfoId($data['info']['info_id']);
     $data['user'] = M('User')->getUserInfo($data['info']['uid']);
     $map['info_id'] = $data['info']['id'];
     $m_com['condition'] = ORDER_CON_DONE;
     $m_com['response_time'] = array('neq', 0);
     $items = M('store_item')->where('good_id=' . $data['info']['info_id'])->findAll();
     $ids = getSubByKey($items, 'order_id');
     $ids_uni = array_unique($ids);
     $m_com['order_id'] = array('in', implode(',', $ids_uni));
     $data['info']['com'] = M('store_order')->where($m_com)->findPage(5);
     foreach ($data['info']['com']['data'] as $k => $v) {
         $data['info']['com']['data'][$k]['user'] = M('User')->getUserInfo($v['uid']);
     }
     $data['info']['data'] = M('Data')->getByInfoId($data['info']['info_id']);
     $data['mid'] = $this->mid;
     if ($data['entity']['name'] == 'shop') {
         $content = $this->renderFile(dirname(__FILE__) . '/shop.html', $data);
     } elseif ($data['entity']['name'] == 'good') {
         $data['shop'] = M('Info')->getById($data['info']['shop_id']);
         $content = $this->renderFile(dirname(__FILE__) . '/good.html', $data);
     } else {
         $content = $this->renderFile(dirname(__FILE__) . '/tpl.html', $data);
     }
     return $content;
 }
 public function appmessage()
 {
     $db_prefix = C('DB_PREFIX');
     $sql = "SELECT COUNT(appid) AS count,`appid`,`typename` FROM {$db_prefix}myop_myinvite WHERE `touid`={$this->mid} GROUP BY `appid`";
     $res = M('')->query($sql);
     $my_count = array();
     foreach ($res as $v) {
         $my_count[$v['appid']] = $v;
     }
     //$map['touid']	= $this->mid;
     $res = M('myop_myinvite')->where($map)->order('appid DESC')->findPage('10');
     unset($map);
     // 将应用消息置为已读
     $appids = getSubByKey($res['data'], 'id');
     $map['touid'] = $this->mid;
     $map['id'] = array('in', $appids);
     M('myop_myinvite')->where($map)->setField('is_read', '1');
     //修正邀请链接错误问题
     foreach ($res['data'] as $k => $v) {
         $myml = '';
         $myml = $v['myml'];
         $myml = str_ireplace(MYOP_URL, '', $myml);
         $myml = str_ireplace('userapp.php', MYOP_URL . '/userapp.php', $myml);
         $myml = preg_replace('/(invite[^\\"]*)/', '#', $myml);
         $res['data'][$k]['myml'] = $myml;
     }
     $this->assign($res);
     $this->setTitle(L('app_message'));
     $this->display('appmessage');
 }
 /**
  * 获取资源列表
  * @param array $map 查询条件
  * @return array 获取资源列表
  */
 public function getChannelList($map)
 {
     // 获取资源分页结构
     $data = $this->field('DISTINCT `feed_id`, `feed_channel_link_id`, `status`')->where($map)->order('`feed_channel_link_id` DESC')->findPage();
     // 获取分享ID
     $feedIds = getSubByKey($data['data'], 'feed_id');
     // 获取分享分类频道信息
     $cmap['c.feed_id'] = array('IN', $feedIds);
     $categoryInfo = D()->table('`' . $this->tablePrefix . 'channel` AS c LEFT JOIN `' . $this->tablePrefix . 'channel_category` AS cc ON cc.channel_category_id = c.channel_category_id')->field('c.`feed_id`,c.`feed_channel_link_id`, c.`status`, cc.channel_category_id, cc.`title`')->where($cmap)->findAll();
     $categoryInfos = array();
     foreach ($categoryInfo as $val) {
         $categoryInfos[$val['feed_id']][] = $val;
     }
     // 获取分享信息
     $feedInfo = model('Feed')->getFeeds($feedIds);
     $feedInfos = array();
     foreach ($feedInfo as $val) {
         $feedInfos[$val['feed_id']] = $val;
     }
     // 组装信息
     foreach ($data['data'] as &$value) {
         $value['uid'] = $feedInfos[$value['feed_id']]['user_info']['uid'];
         $value['uname'] = $feedInfos[$value['feed_id']]['user_info']['uname'];
         $value['content'] = $feedInfos[$value['feed_id']]['body'];
         $value['categoryInfo'] = $categoryInfos[$value['feed_id']];
         $value['app_row_id'] = $feedInfos[$value['feed_id']]['app_row_id'];
         $value['app_row_table'] = $feedInfos[$value['feed_id']]['app_row_table'];
         $value['app'] = $feedInfos[$value['feed_id']]['app'];
         $value['type'] = $feedInfos[$value['feed_id']]['type'];
         $value['is_repost'] = $feedInfos[$value['feed_id']]['is_repost'];
         $value['digg_count'] = $feedInfos[$value['feed_id']]['digg_count'];
     }
     return $data;
 }
 /**
  * 模板渲染
  * @param array $data 相关数据
  * @return string 图片内容渲染入口
  */
 public function render($data)
 {
     // 设置频道模板
     $template = empty($data['tpl']) ? 'hot' : t($data['tpl']);
     // 配置参数
     switch ($template) {
         case 'hot':
             $var['title'] = '推荐';
             $var['list'] = $this->_getHostAlbum();
             break;
         case 'new':
             $var['title'] = '最新上传的';
             $var['list'] = $this->_getNewAlbum();
             break;
         case 'photo':
             $var['albumId'] = intval($data['albumId']);
             $var['uid'] = intval($data['uid']);
             $var['list'] = $this->_getPhotoAlbum($var['albumId'], $var['uid']);
             // 选中图片数目
             $var['photoId'] = intval($data['photoId']);
             $sort = getSubByKey($var['list'], 'id');
             $var['checkNum'] = array_search($var['photoId'], $sort) + 1;
             // 选择页数
             $var['pageKey'] = ceil((array_search(intval($data['photoId']), $sort) + 1) / 9);
             break;
     }
     // 如果数据为空
     if (empty($var['list'])) {
         return false;
     }
     $content = $this->renderFile(dirname(__FILE__) . "/" . $template . ".html", $var);
     return $content;
 }
 /**
  * 获取用户的相关数据
  *
  * @param array $data
  *        	配置相关数据
  * @return array 显示所需数据
  */
 private function _getRelatedZhanggui($data)
 {
     // 用户ID
     $var['uid'] = isset($data['uid']) ? intval($data['uid']) : $GLOBALS['ts']['mid'];
     // 显示相关人数
     $var['limit'] = isset($data['limit']) ? intval($data['limit']) : 4;
     // 掌柜信息
     $key = '_getRelatedZhanggui' . $var['uid'] . '_' . $var['limit'] . '_' . date('Ymd');
     $var['user'] = S($key);
     if ($var['user'] === false || intval($_REQUEST['rel']) == 1) {
         $sql = "SELECT uid FROM `ts_user_verified` WHERE usergroup_id=5 AND verified=1 order by rand() limit " . $var['limit'];
         $list = M()->query($sql);
         // 			dump($list);
         $uids = getSubByKey($list, 'uid');
         $userInfos = model('User')->getUserInfoByUids($uids);
         $userStates = model('Follow')->getFollowStateByFids($GLOBALS['mid'], $uids);
         foreach ($list as $v) {
             $key = $v['uid'];
             $arr[$key]['userInfo'] = $userInfos[$key];
             $arr[$key]['followState'] = $userStates[$key];
             $arr[$key]['info']['msg'] = '掌柜';
             $arr[$key]['info']['extendMsg'] = '';
         }
         $var['user'] = $arr;
         S($key, $var['user'], 86400);
         // 			S ( 'now_'.$key, $var ['user'], 86400 );
     }
     // 		dump($var);
     return $var;
 }
 /**
  * 通过备注名搜索
  *
  * @param  int    $mid    用户id
  * @param  string $remark 备注名
  * @return array
  * @author Foreach <*****@*****.**>
  **/
 public function searchRemark($mid, $remark)
 {
     $rmap['mid'] = $mid;
     $rmap['remark'] = array('LIKE', '%' . $remark . '%');
     $ruid_arr = getSubByKey($this->where($rmap)->field('uid')->findAll(), 'uid');
     return $ruid_arr;
 }
 /**
  * 获取用户的相关数据
  *
  * @param  array $data
  *                     配置相关数据
  * @return array 显示所需数据
  */
 private function _getRelatedDaren($data)
 {
     // 用户ID
     $var['uid'] = isset($data['uid']) ? intval($data['uid']) : $GLOBALS['ts']['mid'];
     // 显示相关人数
     $var['limit'] = isset($data['limit']) ? intval($data['limit']) : 4;
     // 收藏达人的信息
     $key = '_getRelatedDaren' . $var['uid'] . '_' . $var['limit'] . '_' . date('Ymd');
     $var['user'] = S($key);
     if ($var['user'] === false || intval($_REQUEST['rel']) == 1) {
         $sql = "select * from \n\t\t\t(SELECT DISTINCT uid FROM `ts_user_data` WHERE `key`='collect_total_count' ORDER BY `value` DESC LIMIT 100) as t\n\t\t\torder by rand() limit " . $var['limit'];
         $list = M()->query($sql);
         $uids = getSubByKey($list, 'uid');
         $userInfos = model('User')->getUserInfoByUids($uids);
         $userStates = model('Follow')->getFollowStateByFids($GLOBALS['mid'], $uids);
         foreach ($list as $v) {
             $key = $v['uid'];
             $arr[$key]['userInfo'] = $userInfos[$key];
             $arr[$key]['followState'] = $userStates[$key];
             $arr[$key]['info']['msg'] = '掌柜';
             $arr[$key]['info']['extendMsg'] = '';
         }
         $var['user'] = $arr;
         S($key, $var['user'], 86400);
     }
     return $var;
 }
 public function reply()
 {
     if ($_POST) {
         $d['attach_type'] = 'message_image';
         $d['upload_type'] = 'image';
         $info = model('Attach')->upload($d, $d);
         $data['attach_ids'] = getSubByKey($info['info'], 'attach_id');
     } else {
         if (empty($this->data['id']) || empty($this->data['content'])) {
             return false;
         }
     }
     ////隐私判断开始
     $message['member'] = model('Message')->getMessageMembers(intval($this->data['id']), 'member_uid');
     $message['to'] = array();
     // 添加发送用户ID
     foreach ($message['member'] as $v) {
         $this->mid != $v['member_uid'] && ($message['to'][] = $v);
     }
     $UserPrivacy = model('UserPrivacy')->getPrivacy($this->mid, $message['to'][0]['user_info']['uid']);
     if ($UserPrivacy['message'] != 0) {
         return 0;
     }
     ////隐私判断结束
     return (int) model('Message')->replyMessage($this->data['id'], $this->data['content'], $this->mid, $data['attach_ids']);
 }
 public function getUserList($map = '', $show_dept = false, $show_user_group = false, $field = '*', $order = 'id ASC', $limit = 30)
 {
     $res = $this->where($map)->field($field)->order($order)->findPage($limit);
     $uids = getSubByKey($res['data'], 'id');
     //部门信息
     if ($show_dept) {
         $temp_dept = $this->getDepartmentByUser($uids);
         //转换成array($uid => $dept)的格式
         foreach ($temp_dept['data'] as $v) {
             $dept[$v['uid']][] = $v;
         }
         unset($temp_dept);
         //将部门信息添加至结果集
         foreach ($res['data'] as $k => $v) {
             $res['data'][$k]['department'] = isset($dept[$v['id']]) ? $dept[$v['id']] : array();
         }
     }
     //用户组
     if ($show_user_group) {
         $temp_user_group = model('UserGroup')->getGroupByUser($uids);
         //转换成array($uid => $user_group)的格式
         foreach ($temp_user_group as $v) {
             $user_group[$v['uid']][] = $v;
         }
         unset($temp_user_group);
         //dump($res['data']);exit;
         //将用户组信息添加至结果集
         foreach ($res['data'] as $k => $v) {
             $res['data'][$k]['user_group'] = isset($user_group[$v['id']]) ? $user_group[$v['id']] : array();
         }
     }
     return $res;
 }
 public function getWidget($id = null, $pid = null)
 {
     if (isset($id)) {
         if (is_array($id)) {
             $map['id'] = array('in', $id);
         } else {
             $map['id'] = $id;
         }
     }
     $data = $this->where($map)->findAll();
     $field = getSubByKey($data, 'field');
     $posterData = M('poster')->field($field)->where('id=' . $pid)->find();
     foreach ($data as &$value) {
         $value['data'] = stripslashes($value['data']);
         $value['data'] = unserialize($value['data']);
         if ($value['widget'] == 'CheckBox' || $value['widget'] == 'Radio') {
             $poster = $posterData[$value['field']];
             $poster = preg_replace("'([\r\n])[\\s]+'", "", $poster);
             $poster = explode(',', $poster);
             $value['data'] = preg_replace("'([\r\n])[\\s]+'", "", $value['data']);
             $validData = array();
             if (isset($pid)) {
                 foreach ($value['data'] as &$val) {
                     $val = str_replace("[selected]", "", $val);
                     if (in_array($val, $poster)) {
                         $val = $val . '[selected]';
                     }
                 }
             }
         } else {
             $value['data'] = $posterData[$value['field']];
         }
     }
     return $data;
 }
 /**
  * 频道首页页面
  * @return void
  */
 public function index()
 {
     // 添加样式
     $this->appCssList[] = 'channel.css';
     // 获取频道分类列表
     $channelCategory = model('CategoryTree')->setTable('channel_category')->getCategoryList();
     $this->assign('channelCategory', $channelCategory);
     // 频道分类选中
     $cid = intval($_GET['cid']);
     $channelConf = model('Xdata')->get('channel_Admin:index');
     if (empty($cid)) {
         $cid = $channelConf['default_category'];
     }
     $this->assign('cid', $cid);
     // 获取模板样式
     $templete = t($_GET['tpl']);
     if (empty($templete) || !in_array($templete, array('load', 'list'))) {
         $categoryConf = model('CategoryTree')->setTable('channel_category')->getCatgoryConf($cid);
         $templete = empty($categoryConf) ? $channelConf['show_type'] == 1 ? 'list' : 'load' : ($categoryConf['show_type'] == 1 ? 'list' : 'load');
     }
     $this->assign('tpl', $templete);
     // 设置页面信息
     $titleHash = model('CategoryTree')->setTable('channel_category')->getCategoryHash();
     $title = empty($cid) ? '频道首页' : $titleHash[$cid];
     $this->setTitle($title);
     $this->setKeywords($title);
     $this->setDescription(implode(',', getSubByKey($channelCategory, 'title')));
     $this->display();
 }
 function doSearchTag($k)
 {
     global $ts;
     $keyinfo = M('tag')->where("tag_name='{$k}'")->find();
     if ($keyinfo && $k) {
         $list = $this->where("tag_id=" . $keyinfo['tag_id'])->field('uid')->findPage();
         $uids = getSubByKey($list['data'], 'uid');
         /*
          * 缓存用户的资料, 粉丝数, 关注数, Tag列表
          */
         $user_model = D('User', 'home');
         $user_count_model = model('UserCount');
         $user_model->setUserObjectCache($uids);
         $user_count_model->setUserFollowerCount($uids);
         $user_count_model->setUserFollowingCount($uids);
         $this->setUserTagObjectCache($uids);
         foreach ($list['data'] as $k => $v) {
             $list['data'][$k]['user'] = $user_model->getUserByIdentifier($v['uid']);
             $list['data'][$k]['taglist'] = $this->getUserTagList($v['uid']);
             $list['data'][$k]['following'] = $user_count_model->getUserFollowingCount($v['uid']);
             $list['data'][$k]['follower'] = $user_count_model->getUserFollowerCount($v['uid']);
             $list['data'][$k]['followState'] = getFollowState($ts['user']['uid'], $v['uid']);
         }
     } else {
         $list['count'] = 0;
     }
     return $list;
 }
 function adddel($table, $field)
 {
     $sql = "SELECT * FROM {$this->db1}.`{$table}`";
     $list1 = M()->query($sql);
     $arr1 = getSubByKey($list1, $field);
     // dump ( $arr1 );
     $sql = "SELECT * FROM {$this->db2}.`{$table}`";
     $list2 = M()->query($sql);
     $arr2 = getSubByKey($list2, $field);
     // dump ( $arr2 );
     $add_arr = array_diff($arr1, $arr2);
     // dump ( $add_arr );
     $del_arr = array_diff($arr2, $arr1);
     // dump ( $del_arr );
     foreach ($list1 as $key => $value) {
         unset($value['id']);
         if (in_array($value[$field], $add_arr)) {
             $fields = array_keys($value);
             $fields = '`' . implode('`,`', $fields) . '`';
             $val = "'" . implode("','", $value) . "'";
             echo "INSERT INTO {$table} ({$fields}) VALUES ({$val});<br/>";
         }
         if (in_array($value[$field], $del_arr)) {
             echo "DELETE FROM {$table} WHERE `{$field}`='{$value[$field]}';<br/>";
         }
     }
 }
 /**
  * 检查给定用户是否拥有给定节点的权限
  * 
  * @param int	 $uid               用户ID(默认当前用户)
  * @param string $node              节点, 格式为"APP_NAME/MOD_NAME/ACT_NAME"(默认当前节点)
  * @param bool	 $has_admin_popedom 当没有设置admin节点权限时的是否默认拥有admin权限 ( true:有权限 false:没有权限 )
  */
 public function hasPopedom($uid = null, $node = null, $has_admin_popedom = true)
 {
     global $ts;
     $uid = isset($uid) ? intval($uid) : $_SESSION['mid'];
     // 超级管理员拥有所有权限
     if ($uid == $_SESSION['mid'] && $_SESSION['userInfo']['admin_level'] == '1') {
         return true;
     }
     $node = isset($node) ? explode('/', $node) : array($ts['_app'], $ts['_mod'], $ts['_act']);
     $app = $node[0];
     $mod = $node[1];
     $act = $node[2];
     unset($node);
     //获取有权限查看此节点的用户组ID
     $prefix = C('DB_PREFIX');
     $where = "n.app_name='{$app}' AND ( ( n.mod_name='{$mod}' AND ( n.act_name='{$act}' OR n.act_name='*' ) ) OR n.mod_name='*' )";
     $sql = "SELECT p.user_group_id FROM {$prefix}node AS n INNER JOIN {$prefix}user_group_popedom AS p ON n.node_id = p.node_id WHERE {$where}";
     $gid = M('')->query($sql);
     $gid = getSubByKey($gid, 'user_group_id');
     if (empty($gid)) {
         return $has_admin_popedom ? true : $app != 'admin';
     } else {
         // 检查用户是否有权限
         return model('UserGroup')->isUserInUserGroup($uid, $gid);
     }
 }
 function lists()
 {
     $addon_list = D('Home/Addons')->getWeixinList(true);
     foreach ($addon_list as $v) {
         $all_ids[] = $v['id'];
         $nameArr[$v['id']] = $v['title'];
     }
     $model = $this->getModel($this->table);
     $map['mp_id'] = intval($_GET['mp_id']);
     if (!empty($_GET['title'])) {
         $title = I('get.title');
         $where = "nickname like '%{$title}%'";
         $uids = M('member')->where($where)->field('uid')->select();
         $uids = getSubByKey($uids, 'uid');
         $uids[] = 0;
         $map['uid'] = array('in', $uids);
     }
     session('common_condition', $map);
     $list_data = $this->_get_model_list($model);
     foreach ($list_data['list_data'] as &$vo) {
         $vo['addon_status'] = explode(',', $vo['addon_status']);
         $vo['addon_status'] = array_diff($all_ids, $vo['addon_status']);
         $vo['addon_status'] = $this->_idToName($vo['addon_status'], $nameArr);
     }
     $this->assign($list_data);
     // dump($list_data);
     $this->assign('add_url', U('add?model=' . $model['id'] . '&mp_id=' . $map['mp_id']));
     $this->assign('search_url', U('lists?model=' . $model['id'] . '&mp_id=' . $map['mp_id']));
     // $this->assign ( 'search_button', false );
     $this->display('Think:lists');
 }
 /**
 * 帮助中心首页
 * @return void
 */
 public function index(){
     // 添加样式
     $this->appCssList[] = 'help.css';
     // 获取帮助列表
     $helpCategory = model('CategoryTree')->setTable('help_category')->getCategoryList();
     $this->assign('helpCategory',$helpCategory);
     // 帮助分类选中
     $cid = intval($_GET['cid']);
     $index = false;
     if (empty($_GET['cid'])){
         $index = true;
     }
     $categoryIds = getSubByKey($helpCategory,'help_category_id');
     if (!in_array($cid,$categoryIds) && !empty($cid)){
         $this->error('您请求的帮助页面已不存在');
         return false;
     }
     $this->assign('isIndex',$index);
     $this->assign('cid',$cid);
    
     $masterCate = getMasterCategories();
     $this->assign('masterCate',$masterCate);
     
     $titleHash = model('CategoryTree')->setTable('help_category')->getCategoryHash();
     $title = empty($cid) ? "帮助中心首页" : $titleHash[$cid];
     $this->setTitle($title);
     $this->setKeywords($title);
     $this->setDescription(implode(',',getSubByKey($helpCategory,'title')));
     $this->display();
 }
 function lists()
 {
     //查询数据
     $map['token'] = get_token();
     $map['uid'] = $this->getUid();
     $name = 'credit_data';
     $page = I('p', 1, 'intval');
     // 默认显示第一页数据
     $row = 50;
     $data = M($name)->where($map)->order('id DESC')->page($page, $row)->select();
     // 获取相关的用户信息
     $names = getSubByKey($data, 'credit_name');
     $names = array_filter($names);
     $names = array_unique($names);
     if (!empty($names)) {
         $cond['name'] = array('in', $names);
         $credit_config = M('credit_config')->distinct(true)->where($cond)->field('name,title')->select();
         foreach ($credit_config as $cc) {
             $cnames[$cc['name']] = $cc;
         }
         foreach ($data as &$vo) {
             $vo['title'] = $cnames[$vo['credit_name']]['title'];
         }
     }
     $this->assign('list_data', $data);
     $this->meta_title = '积分明细';
     $this->assign('total', $this->getScore());
     //$this->display ( T ( 'Addons://ScoreDetail@ScoreDetail/lists' ) );
     $this->display();
 }
 public function doInstallMadel()
 {
     $_GET['path_name'] = t($_GET['path_name']);
     $info = $this->__getPluginInfo('Medal/' . t($_GET['path_name']));
     if (!$info) {
         $this->error('未找到安装信息');
     } else {
         // 检查是否已安装
         $installed = model('Medal')->getInstalledMedal();
         $installed = getSubByKey($installed, 'path_name');
         if (in_array($_GET['path_name'], $installed)) {
             $this->error('该勋章已安装');
         }
         $info['is_active'] = 1;
         $info['ctime'] = time();
         if ($medal_id = M('medal')->add($info)) {
             // 为排序方便,设置 display_order = medal_id
             M('medal')->where('`medal_id`=' . $medal_id)->setField('display_order', $medal_id);
             $this->assign('jumpUrl', U('admin/Plugin/installMedal'));
             $this->success('安装成功');
         } else {
             $this->error('安装失败');
         }
     }
 }
 private function dataProcess($userInfoList)
 {
     $fieldList = $this->data_field();
     foreach ($userInfoList as $value) {
         if ($value['type'] == 'info') {
             $database[$value['module']] = unserialize($value['data']);
         } else {
             $data['profile']['list'][] = array_merge(array('module' => $value['module'], 'id' => $value['id']), unserialize($value['data']));
         }
     }
     $data['profile']['completeness'] = round(count(array_unique(getSubByKey($data['profile']['list'], 'module'))) / 2, 2) * 100;
     foreach ($fieldList as $key => $value) {
         foreach ($value as $k => $v) {
             $t = $database[$key][$k];
             if ($t) {
                 $complete++;
             }
             $data[$key]['list'][] = array('field' => $k, 'name' => $v, 'value' => $t);
         }
         $data[$key]['completeness'] = round($complete / count($value), 2) * 100;
         unset($complete);
     }
     unset($userInfoList);
     unset($fieldList);
     unset($database);
     return $data;
 }
 /**
  * 获取用户的相关数据
  *
  * @param array $data
  *        	配置相关数据
  * @return array 显示所需数据
  */
 private function _getRelatedDaren($data)
 {
     // 用户ID
     $var['uid'] = isset($data['uid']) ? intval($data['uid']) : $GLOBALS['ts']['mid'];
     // 显示相关人数
     $var['limit'] = isset($data['limit']) ? intval($data['limit']) : 4;
     if (!empty($data['weibaid'])) {
         $weibaid = intval($data['weibaid']);
     }
     $var['weibaid'] = isset($data['weibaid']) ? intval($data['weibaid']) : 0;
     // 收藏达人的信息
     $key = '_getWeibaDaren' . $var['uid'] . '_' . $var['limit'] . '_' . date('Ymd') . '_' . $weibaid;
     $var['user'] = S($key);
     if ($var['user'] === false || intval($_REQUEST['rel']) == 1) {
         $uidlist = M('user_group_link')->where('user_group_id=7')->limit(1000)->select();
         $map['follower_uid'] = array('in', getSubByKey($uidlist, 'uid'));
         if ($data['weibaid']) {
             $map['weiba_id'] = $weibaid;
         }
         $list = M('weiba_follow')->where($map)->group('follower_uid')->limit($var['limit'])->select();
         $uids = getSubByKey($list, 'follower_uid');
         $userInfos = model('User')->getUserInfoByUids($uids);
         $userStates = model('Follow')->getFollowStateByFids($GLOBALS['ts']['mid'], $uids);
         foreach ($list as $v) {
             $key = $v['follower_uid'];
             $arr[$key]['userInfo'] = $userInfos[$key];
             $arr[$key]['followState'] = $userStates[$key];
             $arr[$key]['info']['msg'] = '掌柜';
             $arr[$key]['info']['extendMsg'] = '';
         }
         $var['user'] = $arr;
         S($key, $var['user'], 86400);
     }
     return $var;
 }
 function lists()
 {
     // 获取模型信息
     $model = $this->getModel();
     $map['token'] = get_token();
     session('common_condition', $map);
     // 获取模型列表数据
     $list_data = $this->_get_model_list($model);
     // 获取相关的用户信息
     $uids = getSubByKey($list_data['list_data'], 'uid');
     $uids = array_filter($uids);
     $uids = array_unique($uids);
     if (!empty($uids)) {
         $map['id'] = array('in', $uids);
         $members = M('follow')->where($map)->field('id,nickname,mobile')->select();
         foreach ($members as $m) {
             $user[$m['id']] = $m;
         }
         foreach ($list_data['list_data'] as &$vo) {
             empty($vo['mobile']) || ($vo['mobile'] = $user[$vo['uid']]['mobile']);
             empty($vo['nickname']) || ($vo['nickname'] = $user[$vo['uid']]['nickname']);
         }
     }
     $this->assign($list_data);
     $this->assign('add_url', U('suggest'));
     $this->display($model['template_list']);
 }
Exemple #22
0
 /**
  * @param string width wigdet显示宽度
  * @param string appname 资源对应的应用名称
  * @param string apptable 资源对应的表
  * @param integer row_id 资源在资源所在表中的主键ID,为0表示该资源为新加资源,需要在资源添加,往sociax_app_tag表添加相关数据
  * @param string tpl 显示模版,tag/show 默认是tag,如果为show表示只显示标签
  * @param string tag_url 标签上的链接前缀,为空表示标签没有链接,只针对tpl=show有效
  * @param string name 输入框的input名称,标签的ID存储的隐藏域名称为 {name}_tags
  */
 public function render($data)
 {
     $var = array();
     $var['width'] = "200px";
     $var['appname'] = 'public';
     $var['apptable'] = 'user';
     $var['row_id'] = 0;
     $var['tpl'] = 'tag';
     $var['tag_num'] = 10;
     is_array($data) && ($var = array_merge($var, $data));
     // 清除缓存
     model('Cache')->rm('temp_' . $var['apptable'] . $GLOBALS['ts']['mid']);
     $var['add_url'] = U('widget/Tag/addTag', array('appname' => $var['appname'], 'apptable' => $var['apptable'], 'row_id' => $var['row_id']));
     $var['delete_url'] = U('widget/Tag/deleteTag', array('appname' => $var['appname'], 'apptable' => $var['apptable'], 'row_id' => $var['row_id']));
     // 获取标签
     $tags = model('Tag')->setAppName($var['appname'])->setAppTable($var['apptable'])->getAppTags($var['row_id']);
     $var['tags'] = $tags;
     // 以选中ID
     $var['tags_my'] = implode(',', array_flip($tags));
     // 获取推荐标签
     $uid = intval($data['uid']);
     $var['uid'] = $uid;
     $var['selected'] = model('UserCategory')->getRelatedUserInfo($uid);
     !empty($var['selected']) && ($var['selectedIds'] = getSubByKey($var['selected'], 'user_category_id'));
     $var['nums'] = count($tags);
     $var['categoryTree'] = model('CategoryTree')->setTable('user_category')->getNetworkList();
     foreach ($var['categoryTree'] as $key => $value) {
         if (empty($value['child'])) {
             unset($var['categoryTree'][$key]);
         }
     }
     $content = $this->renderFile(dirname(__FILE__) . "/" . $var['tpl'] . ".html", $var);
     return $content;
 }
 /**
  * 主页右钩子
  */
 public function home_index_left_feedtop()
 {
     $list = $this->model('FeedTop')->getFeedTopList(1);
     $close_feeds = $_SESSION['feed_top_' . $this->mid];
     foreach ($list as $k => $v) {
         if (!in_array($v['feed_id'], $close_feeds)) {
             $list[$k]['feed_info'] = model('Feed')->get($v['feed_id']);
         } else {
             unset($list[$k]);
         }
     }
     foreach ($list as &$v) {
         switch ($v['feed_info']['app']) {
             case 'weiba':
                 $v['feed_info']['from'] = getFromClient(0, $v['feed_info']['app'], '微吧');
                 break;
             case 'tipoff':
                 $v['feed_info']['from'] = getFromClient(0, $v['feed_info']['app'], '爆料');
                 break;
             default:
                 $v['feed_info']['from'] = getFromClient($v['feed_info']['from'], $v['feed_info']['app']);
                 break;
         }
         !isset($uids[$v['feed_info']['uid']]) && $v['feed_info']['uid'] != $GLOBALS['ts']['mid'] && ($uids[] = $v['feed_info']['uid']);
     }
     $this->assign('data', $list);
     // 赞微博
     $feed_ids = getSubByKey($list, 'feed_id');
     $diggArr = model('FeedDigg')->checkIsDigg($feed_ids, $GLOBALS['ts']['mid']);
     $this->assign('diggArr', $diggArr);
     $this->display('feedtop');
 }
Exemple #24
0
 public function listAllWeibo($page = 1, $count = 30, $map = array(), $loadCount = 1, $lastId = 0, $keywords = '')
 {
     //获取微博列表
     if (isset($keywords) && $keywords != '') {
         $map['content'] = array('like', "%{$keywords}%");
     }
     $map[] = array('status' => 1);
     $model = $this->weiboModel;
     if ($page == 1 && $loadCount == 1) {
         $list = $model->field('id')->where($map)->order('is_top desc,create_time desc')->limit(10)->select();
     } elseif ($loadCount > 1 && $loadCount <= 3) {
         $is_top = D('weibo')->field('id,is_top')->where(array('id' => $lastId))->getField('is_top');
         if (!$is_top) {
             $map['id'] = array('lt', $lastId);
             $list = $model->field('id')->where($map)->order('create_time desc')->limit(10)->select();
         } else {
             $ids = $model->field('id,is_top')->where(array('id' => array('egt', $lastId), 'is_top' => 1))->field('id')->select();
             $ids = getSubByKey($ids, 'id');
             $ids = implode(",", $ids);
             $map['_string'] = '(id < ' . $lastId . ' AND is_top =1 ) OR (id > 0  AND (id NOT IN (' . $ids . '))) ';
             $list = $model->field('id,is_top')->where($map)->order('is_top desc,create_time desc')->limit(10)->select();
         }
     } elseif ($page > 1) {
         $list = $model->field('id')->where($map)->order('is_top desc,create_time desc')->page($page, $count)->select();
     }
     //获取每个微博详情
     foreach ($list as &$e) {
         $e = $this->getWeiboStructure($e['id']);
     }
     unset($e);
     //返回微博列表
     return $this->apiSuccess('获取成功', array('list' => arrayval($list), 'lastId' => $list[count($list) - 1]['id']));
 }
Exemple #25
0
 /**
  * 我的活动页面
  * @param int    $page
  * @param int    $type_id
  * @param string $norh
  * autor:xjw129xjt
  */
 public function myevent($page = 1, $type_id = 0, $lora = '')
 {
     $type_id = intval($type_id);
     if ($type_id != 0) {
         $map['type_id'] = $type_id;
     }
     $map['status'] = 1;
     $order = 'create_time desc';
     if ($lora == 'attend') {
         $attend = D('event_attend')->where(array('uid' => is_login()))->select();
         $enentids = getSubByKey($attend, 'event_id');
         $map['id'] = array('in', $enentids);
     } else {
         $map['uid'] = is_login();
     }
     $content = D('Event')->where($map)->order($order)->page($page, 10)->select();
     $totalCount = D('Event')->where($map)->count();
     foreach ($content as &$v) {
         $v['user'] = query_user(array('id', 'username', 'nickname', 'space_url', 'space_link', 'avatar128', 'rank_html'), $v['uid']);
         $v['type'] = $this->getType($v['type_id']);
         $v['check_isSign'] = D('event_attend')->where(array('uid' => is_login(), 'event_id' => $v['id']))->select();
     }
     unset($v);
     $this->assign('type_id', $type_id);
     $this->assign('contents', $content);
     $this->assign('lora', $lora);
     $this->assign('totalPageCount', $totalCount);
     $this->getRecommend();
     $this->setTitle('我的活动——活动');
     $this->assign('current', 'myevent');
     $this->display();
 }
 public function index()
 {
     $cid = intval($_REQUEST['cid']);
     $channelConf = model('Xdata')->get('channel_Admin:index');
     if (empty($cid)) {
         $cid = $channelConf['default_category'];
     }
     $cid or $cid = D('channel_category')->limit(1)->order('channel_category_id ASC')->getField('channel_category_id');
     //echo $cid;exit;
     $cate = model('CategoryTree')->setTable('channel_category')->getCategoryById($cid);
     if (!is_array($cate)) {
         $this->error('参数错误', 3, U('w3g/Index/channel_list'));
     }
     $channelCategory = model('CategoryTree')->setTable('channel_category')->getCategoryList();
     $this->assign('channelCategory', $channelCategory);
     // 获取分享数据
     $list = D('Channel', 'channel')->getDataWithCid($cid, $loadId, $loadLimit);
     $fids = getSubByKey($list['data'], 'feed_id');
     $weibolist = model('Feed')->formatFeed($fids, true);
     // 分页的设置
     //    	if(!empty($list['data'])) {
     //            $content['firstId'] = $['firstId'] = $list['data'][0]['feed_channel_link_id'];
     //            $content['lastId'] = $list['data'][(count($list['data'])-1)]['feed_channel_link_id'];
     //            // 分享配置
     //            $weiboSet = model('Xdata')->get('admin_Config:feed');
     //            //$var['weibo_premission'] = $weiboSet['weibo_premission'];
     //    	}
     $list['data'] = $this->__formatByContent($weibolist);
     $this->assign('weibolist', $list['data']);
     $this->assign('count', $list['totalRows']);
     $this->assign('cid', $cid);
     //        dump($channelCategory);exit;
     $this->assign('cate', $cate);
     $this->display();
 }
Exemple #27
0
 /**
  * 返回用户勋章列表
  * @param  unknown_type $map
  * @param  unknown_type $limit
  * @return unknown
  */
 public function getUserMedalList($map, $limit = 20)
 {
     $list = D('medal_user')->where($map)->findPage();
     if (!$list) {
         return false;
     }
     $uids = getSubByKey($list['data'], 'uid');
     $mids = getSubByKey($list['data'], 'medal_id');
     $users = model('User')->getUserInfoByUids($uids);
     $unames = array();
     foreach ($users as $n) {
         $unames[$n['uid']] = $n['uname'];
     }
     $gmap['id'] = array('in', $mids);
     $medals = $this->where($gmap)->findAll();
     $medalnames = array();
     foreach ($medals as $m) {
         $src = explode('|', $m['src']);
         $medalnames[$m['id']]['src'] = $src[1];
         $medalnames[$m['id']]['name'] = $m['name'];
     }
     foreach ($list['data'] as &$v) {
         $v['uname'] = $unames[$v['uid']];
         $v['medalsrc'] = $medalnames[$v['medal_id']]['src'];
         $v['medalname'] = $medalnames[$v['medal_id']]['name'];
     }
     return $list;
 }
 public function getInstalled($uId)
 {
     $db_prefix = getDbPrefix();
     $result = doQuery("SELECT `appid` FROM {$db_prefix}userapp WHERE `uid` = {$uId}");
     $result = getSubByKey($result, 'appid');
     return new APIResponse($result);
 }
 public function lists($model = null, $page = 0, $templateFile = '', $order = 'id desc')
 {
     $isAjax = I('isAjax');
     $isRadio = I('isRadio');
     // 获取模型信息
     is_array($model) || ($model = $this->getModel($model));
     $list_data = $this->_get_model_list($model, $page, $order);
     if (!empty($list_data['list_data'])) {
         $coupon_ids = array_unique(getSubByKey($list_data['list_data'], 'coupon_id'));
         $map['id'] = array('in', $coupon_ids);
         $list = M('coupon')->where($map)->field('id,title')->select();
         $couponArr = makeKeyVal($list);
         foreach ($list_data['list_data'] as &$v) {
             $v['coupon_name'] = $couponArr[$v['coupon_id']];
         }
     }
     if ($isAjax) {
         $this->assign('isRadio', $isRadio);
         $this->assign($list_data);
         $this->display('ajax_lists_data');
     } else {
         $this->assign($list_data);
         $templateFile || ($templateFile = $model['template_list'] ? $model['template_list'] : '');
         $this->display($templateFile);
     }
 }
 public function getForumList($map_type = array('status' => 1))
 {
     $tag = 'forum_list_' . serialize($map_type);
     $forum_list = S($tag);
     $cache_time = modC('CACHE_TIME', 300, 'Forum');
     if (empty($forum_list)) {
         //读取板块列表
         $forum_list = D('Forum/Forum')->where($map_type)->order('sort asc')->select();
         $forumPostModel = D('ForumPost');
         $forumPostReplyModel = D('ForumPostReply');
         $forumLzlReplyModel = D('ForumLzlReply');
         foreach ($forum_list as &$f) {
             $map['status'] = 1;
             $map['forum_id'] = $f['id'];
             $f['background'] = $f['background'] ? getThumbImageById($f['background'], 800, 'auto') : C('TMPL_PARSE_STRING.__IMG__') . '/default_bg.jpg';
             $f['logo'] = $f['logo'] ? getThumbImageById($f['logo'], 128, 128) : C('TMPL_PARSE_STRING.__IMG__') . '/default_logo.png';
             $f['topic_count'] = $forumPostModel->where($map)->count();
             $post_id = $forumPostModel->where(array('forum_id' => $f['id']))->field('id')->select();
             $p_id = getSubByKey($post_id, 'id');
             $map['post_id'] = array('in', implode(',', $p_id));
             $f['total_count'] = $f['topic_count'] + $forumPostReplyModel->where($map)->count();
             // + $forumLzlReplyModel->where($map)->count();
         }
         unset($f);
         S($tag, $forum_list, $cache_time);
     }
     return $forum_list;
 }