/** * 首页 */ public function indexOp() { $model = Model(); // 热门圈子 **显示3个圈子,按推荐随机排列,推荐不够按成员数主题数降序排列** $circle_list = $model->table('circle')->field('*, is_hot*rand() as rand')->where(array('circle_status' => 1, 'is_hot' => 1))->order('rand desc')->limit(3)->select(); if (!empty($circle_list)) { $circle_list = array_under_reset($circle_list, 'circle_id'); $circleid_array = array_keys($circle_list); // 查询圈子最新主题 foreach ($circle_list as $key => $val) { // 最新的两条数据 $theme_list = $model->table('circle_theme')->where(array('circle_id' => $val['circle_id'], 'is_closed' => 0))->order('theme_id desc')->limit(2)->select(); $circle_list[$key]['theme_list'] = $theme_list; } Tpl::output('circle_list', $circle_list); $now = strtotime(date('Y-m-d', time())); // 今天发表的主题 $nowthemecount_array = $model->table('circle_theme')->field('count(circle_id) as count,circle_id')->group('circle_id')->where(array('theme_addtime' => array('gt', $now), 'circle_id' => array('in', $circleid_array), 'is_closed' => 0))->select(); if (!empty($nowthemecount_array)) { $nowthemecount_array = array_under_reset($nowthemecount_array, 'circle_id'); Tpl::output('nowthemecount_array', $nowthemecount_array); } // 今天新加入的成员 $nowjoincount_array = $model->table('circle_member')->field('count(circle_id) as count,circle_id')->group('circle_id')->where(array('cm_jointime' => array('gt', $now), 'circle_id' => array('in', $circleid_array)))->select(); if (!empty($nowjoincount_array)) { $nowjoincount_array = array_under_reset($nowjoincount_array, 'circle_id'); Tpl::output('nowjoincount_array', $nowjoincount_array); } } // 圈子分类 $class_list = $model->table('circle_class')->where(array('class_status' => 1, 'is_recommend' => 1))->order('class_sort asc')->select(); Tpl::output('class_list', $class_list); // 推荐圈子 $rcircle_list = $model->table('circle')->field('*, is_recommend*rand() as rand')->where(array('circle_status' => 1, 'is_recommend' => 1))->order('rand desc')->limit('20')->select(); Tpl::output('rcircle_list', $rcircle_list); // 推荐话题 $theme_list = $model->table('circle_theme')->field('*, is_recommend*rand() as rand')->where(array('has_affix' => 1, 'is_closed' => 0, 'is_recommend' => 1))->order('rand desc')->limit(8)->select(); if (!empty($theme_list)) { $theme_list = array_under_reset($theme_list, 'theme_id'); $themeid_array = array_keys($theme_list); // 附件 $affix_list = $model->table('circle_affix')->where(array('theme_id' => array('in', $themeid_array), 'affix_type' => 1))->group('theme_id')->select(); if (!empty($affix_list)) { $affix_list = array_under_reset($affix_list, 'theme_id'); } foreach ($theme_list as $key => $val) { if (isset($affix_list[$val['theme_id']])) { $theme_list[$key]['affix'] = themeImageUrl($affix_list[$val['theme_id']]['affix_filethumb']); } } Tpl::output('theme_list', $theme_list); } // 商品话题 $gtheme_list = $model->table('circle_theme')->where(array('has_goods' => 1, 'is_closed' => 0))->order('theme_id desc')->limit(6)->select(); if (!empty($gtheme_list)) { $gtheme_list = array_under_reset($gtheme_list, 'theme_id'); $themeid_array = array_keys($gtheme_list); // 圈子商品 $thg_list = $model->table('circle_thg')->where(array('theme_id' => array('in', $themeid_array), 'reply_id' => 0))->select(); $thg_list = tidyThemeGoods($thg_list, 'theme_id', 2); Tpl::output('thg_list', $thg_list); Tpl::output('gtheme_list', $gtheme_list); } // 优秀成员 $member_list = $model->table('circle_member')->field('*, is_recommend*rand() as rand')->where(array('is_recommend' => 1))->order('rand desc')->limit(5)->select(); if (!empty($member_list)) { $member_list = array_reverse($member_list); $one_member = array_pop($member_list); $where = array(); $where['member_id'] = $one_member['member_id']; $where['circle_id'] = $one_member['circle_id']; $one_membertheme = $model->table('circle_theme')->where($where)->order('theme_id desc')->limit(4)->select(); Tpl::output('one_member', $one_member); Tpl::output('one_membertheme', $one_membertheme); if (!empty($member_list)) { $where = ''; foreach ($member_list as $val) { $where .= '( circle_member.member_id = ' . $val['member_id'] . ' and circle_member.circle_id = ' . $val['circle_id'] . ') or '; } $where = rtrim($where, 'or '); $more_membertheme = $model->table('circle_member,circle_theme')->join('inner')->on('circle_member.member_id = circle_theme.member_id and circle_member.circle_id = circle_theme.circle_id')->where($where)->group('circle_member.member_id,circle_member.circle_id')->select(); Tpl::output('more_membertheme', $more_membertheme); } } // 最新话题/热门话题/人气回复 $this->themeTop(); // 首页幻灯 $loginpic = unserialize(C('circle_loginpic')); Tpl::output('loginpic', $loginpic); $this->circleSEO(); Tpl::showpage('index'); }
/** * 编辑话题 */ public function edit_themeOp() { // 身份验证 $rs = $this->checkIdentity('cm'); if (!empty($rs)) { uk86_showMessage($rs); } $t_id = intval($_GET['t_id']); if ($t_id <= 0) { uk86_showMessage(L('wrong_argument')); } Tpl::output('t_id', $t_id); $model = Model(); if (uk86_chksubmit()) { // 主题分类 $thclass_id = intval($_POST['thtype']); $thclass_name = ''; if ($thclass_id > 0) { $thclass_info = $model->table('circle_thclass')->find($thclass_id); $thclass_name = $thclass_info['thclass_name']; } $model = Model(); $update = array(); $update['theme_id'] = $t_id; $update['theme_name'] = circleCenterCensor($_POST['name']); $update['theme_content'] = circleCenterCensor($_POST['themecontent']); $update['thclass_id'] = $thclass_id; $update['thclass_name'] = $thclass_name; $update['theme_editname'] = $_SESSION['member_name']; $update['theme_edittime'] = time(); $update['theme_readperm'] = intval($_POST['readperm']); $rs = $model->table('circle_theme')->update($update); if ($rs) { $has_goods = 0; // 存在商品标记 $has_affix = 0; // 存在附件标记 // 删除原有商品 $goods_list = Model()->table('circle_thg')->where(array('theme_id' => $t_id, 'reply_id' => 0))->delete(); // 插入话题商品 if (!empty($_POST['goods'])) { $goods_insert = array(); foreach ($_POST['goods'] as $key => $val) { $p = array(); $p['theme_id'] = $t_id; $p['reply_id'] = 0; $p['circle_id'] = $this->c_id; $p['goods_id'] = $key; $p['goods_name'] = $val['name']; $p['goods_price'] = $val['price']; $p['goods_image'] = $val['image']; $p['store_id'] = $val['storeid']; $goods_insert[] = $p; } $rs = $model->table('circle_thg')->insertAll($goods_insert); $has_goods = 1; } // 更新话题信息 $affixe_count = $model->table('circle_affix')->where(array('affix_type' => 1, 'theme_id' => $t_id))->count(); if ($affixe_count > 0) { $has_affix = 1; } if ($has_goods || $has_affix) { $update = array(); $update['theme_id'] = $t_id; $update['has_goods'] = $has_goods; $update['has_affix'] = $has_affix; $model->table('circle_theme')->update($update); } // Special theme if ($_GET['sp'] == 1) { // Update the vote $update = array(); $update['theme_id'] = $t_id; $update['poll_multiple'] = intval($_POST['multiple']); $update['poll_startime'] = time(); $update['poll_endtime'] = intval($_POST['days']) != 0 ? time() + intval($_POST['days']) * 60 * 60 * 12 : 0; $update['poll_days'] = intval($_POST['days']); $model->table('circle_thpoll')->update($update); // Update the voting options if (!empty($_POST['polloption'])) { $insert_array = array(); foreach ($_POST['polloption'] as $key => $val) { $option_info = $model->table('circle_thpolloption')->where(array('pollop_id' => $key, 'theme_id' => $t_id))->find(); if (!empty($option_info)) { $update = array(); $update['pollop_id'] = $key; $update['pollop_option'] = $val; $update['pollop_sort'] = $_POST['pollsort'][$key]; $model->table('circle_thpolloption')->update($update); } else { if ($val == '') { continue; } $i = array(); $i['theme_id'] = $t_id; $i['pollop_option'] = $val; $i['pollop_sort'] = $_POST['pollsort'][$key]; $insert_array[] = $i; } } if (!empty($insert_array)) { $model->table('circle_thpolloption')->insertAll($insert_array); } } } showDialog(L('nc_common_op_succ'), CIRCLE_SITE_URL . '/index.php?act=theme&op=theme_detail&c_id=' . $this->c_id . '&t_id=' . $t_id, 'succ'); } else { showDialog(L('nc_common_op_fail')); } } // 圈子信息 $this->circleInfo(); // 圈主和管理信息 $this->manageList(); // 会员信息 $this->memberInfo(); // 话题信息 $this->theme_info = $model->table('circle_theme')->where(array('theme_id' => $t_id, 'circle_id' => $this->c_id))->find(); if (empty($this->theme_info)) { uk86_showMessage(L('wrong_argument')); } Tpl::output('theme_info', $this->theme_info); // 话题商品 $goods_list = $model->table('circle_thg')->where(array('theme_id' => $t_id, 'reply_id' => 0))->select(); $goods_list = tidyThemeGoods($goods_list, 'themegoods_id'); Tpl::output('goods_list', $goods_list); // 话题附件 $affix_list = $model->table('circle_affix')->where(array('affix_type' => 1, 'theme_id' => $t_id))->select(); Tpl::output('affix_list', $affix_list); // 话题分类 $where = array(); $where['circle_id'] = $this->c_id; $where['thclass_status'] = 1; $thclass_list = $model->table('circle_thclass')->where($where)->select(); $thclass_list = uk86_array_under_reset($thclass_list, 'thclass_id'); Tpl::output('thclass_list', $thclass_list); // Read permissions $readperm = $this->readPermissions($this->cm_info); Tpl::output('readperm', $readperm); // breadcrumb navigation $this->breadcrumd(L('nc_edit_theme')); if ($this->theme_info['theme_special'] == 1) { $poll_info = $model->table('circle_thpoll')->find($t_id); Tpl::output('poll_info', $poll_info); $option_list = $model->table('circle_thpolloption')->where(array('theme_id' => $t_id))->order('pollop_sort asc')->select(); Tpl::output('option_list', $option_list); Tpl::showpage('group_manage_edit_themepoll'); } else { Tpl::showpage('group_manage_edit_theme'); } }
/** * 首页 */ public function indexOp() { $model = Model(); //我的圈子,话题,和回复数 $my_counts['circle_count'] = $model->table('circle_member')->where(array('member_id' => $_SESSION['member_id']))->count(); $my_counts['theme_count'] = $model->table('circle_theme')->where(array('member_id' => $_SESSION['member_id']))->count(); $my_counts['threply_count'] = $model->table('circle_threply')->where(array('member_id' => $_SESSION['member_id']))->count(); Tpl::output('circle_counts', $my_counts); // 热门圈子 **显示3个圈子,按推荐随机排列,推荐不够按成员数主题数降序排列** $circle_list = $model->table('circle')->field('*, is_hot*rand() as rand')->where(array('circle_status' => 1, 'is_hot' => 1, 'is_official' => 0))->order('rand desc')->limit(4)->select(); if (!empty($circle_list)) { $circle_list = uk86_array_under_reset($circle_list, 'circle_id'); $circleid_array = array_keys($circle_list); // 查询圈子最新主题 foreach ($circle_list as $key => $val) { // 最新的两条数据 $theme_list = $model->table('circle_theme')->where(array('circle_id' => $val['circle_id'], 'is_closed' => 0))->order('theme_id desc')->find(); $circle_list[$key]['theme_list'] = $theme_list; } Tpl::output('circle_list', $circle_list); //var_dump($circle_list); /*$now = strtotime(date('Y-m-d',time())); // 今天发表的主题 $nowthemecount_array = $model->table('circle_theme')->field('count(circle_id) as count,circle_id')->group('circle_id')->where(array('theme_addtime'=>array('gt', $now), 'circle_id'=>array('in', $circleid_array), 'is_closed'=>0))->select(); if(!empty($nowthemecount_array)){ $nowthemecount_array = uk86_array_under_reset($nowthemecount_array, 'circle_id'); Tpl::output('nowthemecount_array', $nowthemecount_array); } // 今天新加入的成员 $nowjoincount_array = $model->table('circle_member')->field('count(circle_id) as count,circle_id')->group('circle_id')->where(array('cm_jointime'=>array('gt', $now), 'circle_id'=>array('in', $circleid_array)))->select(); if(!empty($nowjoincount_array)){ $nowjoincount_array = uk86_array_under_reset($nowjoincount_array, 'circle_id'); Tpl::output('nowjoincount_array', $nowjoincount_array); }*/ } //官方圈子及其活动 $official_list = $model->table('circle')->field('circle_id')->where(array('circle_status' => 1, 'is_official' => 1))->select(); if (!empty($official_list)) { $arr = array(); foreach ($official_list as $official) { array_push($arr, intval($official['circle_id'])); } $condition['is_closed'] = 0; $condition['has_affix'] = 1; $condition['circle_id'] = array("in", $arr); $condition['is_shut'] = 0; $official_theme_list = $model->table('circle_theme')->where($condition)->limit(8)->order('theme_addtime desc')->select(); if (!empty($official_theme_list)) { foreach ($official_theme_list as $key => $official_theme) { $affix = $model->table('circle_affix')->where(array('theme_id' => $official_theme['theme_id'], 'affix_type' => 1))->find(); $official_theme_list[$key]['affix'] = $affix; unset($affix); } } Tpl::output('official_theme_list', $official_theme_list); } // 圈子分类 $class_list = $model->table('circle_class')->where(array('class_status' => 1, 'is_recommend' => 1))->order('class_sort asc')->select(); Tpl::output('class_list', $class_list); // 推荐圈子 $rcircle_list = $model->table('circle')->field('*, is_recommend*rand() as rand')->where(array('circle_status' => 1, 'is_recommend' => 1, 'is_official' => 0))->order('rand desc')->limit('20')->select(); Tpl::output('rcircle_list', $rcircle_list); // 推荐话题 $theme_list = $model->table('circle_theme')->field('*, is_recommend*rand() as rand')->where(array('has_affix' => 1, 'is_closed' => 0, 'is_recommend' => 1, 'is_official' => 0))->order('rand desc')->limit(8)->select(); if (!empty($theme_list)) { $theme_list = uk86_array_under_reset($theme_list, 'theme_id'); $themeid_array = array_keys($theme_list); // 附件 $affix_list = $model->table('circle_affix')->where(array('theme_id' => array('in', $themeid_array), 'affix_type' => 1))->group('theme_id')->select(); if (!empty($affix_list)) { $affix_list = uk86_array_under_reset($affix_list, 'theme_id'); } foreach ($theme_list as $key => $val) { if (isset($affix_list[$val['theme_id']])) { $theme_list[$key]['affix'] = uk86_themeImageUrl($affix_list[$val['theme_id']]['affix_filethumb']); } } Tpl::output('theme_list', $theme_list); } // 商品话题 $gtheme_list = $model->table('circle_theme')->where(array('has_goods' => 1, 'is_closed' => 0))->order('theme_id desc')->limit(6)->select(); //var_dump($gtheme_list); if (!empty($gtheme_list)) { $gtheme_list = uk86_array_under_reset($gtheme_list, 'theme_id'); $themeid_array = array_keys($gtheme_list); // 圈子商品 $thg_list = $model->table('circle_thg')->where(array('theme_id' => array('in', $themeid_array), 'reply_id' => 0))->select(); $thg_list = tidyThemeGoods($thg_list, 'theme_id', 2); Tpl::output('thg_list', $thg_list); //var_dump($thg_list); Tpl::output('gtheme_list', $gtheme_list); } // 优秀成员 $member_list = $model->table('circle_member')->field('*, is_recommend*rand() as rand')->where(array('is_recommend' => 1))->order('rand desc')->limit(5)->select(); if (!empty($member_list)) { $member_list = array_reverse($member_list); $one_member = array_pop($member_list); $where = array(); $where['member_id'] = $one_member['member_id']; $where['circle_id'] = $one_member['circle_id']; $one_membertheme = $model->table('circle_theme')->where($where)->order('theme_id desc')->limit(4)->select(); Tpl::output('one_member', $one_member); Tpl::output('one_membertheme', $one_membertheme); if (!empty($member_list)) { $where = ''; foreach ($member_list as $val) { $where .= '( circle_member.member_id = ' . $val['member_id'] . ' and circle_member.circle_id = ' . $val['circle_id'] . ') or '; } $where = rtrim($where, 'or '); $more_membertheme = $model->table('circle_member,circle_theme')->join('inner')->on('circle_member.member_id = circle_theme.member_id and circle_member.circle_id = circle_theme.circle_id')->where($where)->group('circle_member.member_id,circle_member.circle_id')->select(); Tpl::output('more_membertheme', $more_membertheme); } } // 最新话题/热门话题/人气回复 $this->themeTop(); //有附件图片的热门话题(非官方) $hot_theme_list_with_img = $model->table('circle_theme')->where(array('is_closed' => 0, 'has_affix' => 1, 'is_official' => 0))->limit(5)->order('theme_browsecount desc')->select(); if (!empty($hot_theme_list_with_img)) { $hot_theme_list_with_img = uk86_array_under_reset($hot_theme_list_with_img, 'theme_id'); $themeid_array2 = array_keys($hot_theme_list_with_img); // 附件 $affix_list2 = $model->table('circle_affix')->where(array('theme_id' => array('in', $themeid_array2), 'affix_type' => 1))->group('theme_id')->select(); if (!empty($affix_list2)) { $affix_list2 = uk86_array_under_reset($affix_list2, 'theme_id'); } foreach ($hot_theme_list_with_img as $key => $val) { if (isset($affix_list2[$val['theme_id']])) { $hot_theme_list_with_img[$key]['affix'] = uk86_themeImageUrl($affix_list2[$val['theme_id']]['affix_filethumb']); } } Tpl::output('hot_theme_list_with_img', $hot_theme_list_with_img); } //无附件图片的热门话题(非官方) $hotThemeListWithoutImg = $model->table('circle_theme')->where(array('is_closed' => 0, 'has_affix' => 0, 'is_official' => 0))->limit(6)->order('theme_browsecount desc')->select(); Tpl::output('hot_theme_list_without_img', $hotThemeListWithoutImg); //var_dump($hotThemeListWithoutImg); // 首页幻灯 $loginpic = unserialize(C('circle_loginpic')); Tpl::output('loginpic', $loginpic); $this->circleSEO(); Tpl::setLayout('null_layout'); Tpl::showpage('circle_index'); }
/** * 编辑回复 */ public function edit_replyOp() { // 验证回复信息 $this->checkReplySelf(); if (chksubmit()) { /** * 验证 */ $obj_validate = new Validate(); $obj_validate->validateparam = array(array("input" => $_POST["replycontent"], "require" => "true", "message" => L('circle_reply_not_null'))); $error = $obj_validate->validate(); if ($error != '') { showDialog($error); } else { $model = Model(); $update = array(); $update['theme_id'] = $this->t_id; $update['reply_id'] = $this->r_id; $update['member_id'] = $_SESSION['member_id']; $update['member_name'] = $_SESSION['member_name']; $update['reply_content'] = circleCenterCensor($_POST['replycontent']); $update['reply_addtime'] = time(); $update['is_closed'] = 0; $rs = $model->table('circle_threply')->where(array('theme_id' => $this->t_id, 'reply_id' => $this->r_id))->update($update); if ($rs) { // 删除原有商品 $goods_list = Model()->table('circle_thg')->where(array('theme_id' => $this->t_id, 'reply_id' => $this->r_id))->delete(); // 插入话题商品 if (!empty($_POST['goods'])) { $goods_insert = array(); foreach ($_POST['goods'] as $key => $val) { $p = array(); $p['theme_id'] = $this->t_id; $p['reply_id'] = $this->r_id; $p['circle_id'] = $this->c_id; $p['goods_id'] = $val['id']; $p['goods_name'] = $val['name']; $p['goods_price'] = $val['price']; $p['goods_image'] = $val['image']; $p['store_id'] = $val['storeid']; $p['thg_type'] = $val['type']; $p['thg_url'] = $val['type'] == 1 ? $val['uri'] : ''; $goods_insert[] = $p; } $rs = $model->table('circle_thg')->insertAll($goods_insert); } // 更新话题附件 $model->table('circle_affix')->where(array('affix_type' => 2, 'member_id' => $_SESSION['member_id'], 'reply_id' => 0))->update(array('theme_id' => $this->t_id, 'reply_id' => $this->r_id, 'circle_id' => $this->c_id)); showDialog(L('nc_common_op_succ'), 'index.php?act=theme&op=theme_detail&c_id=' . $this->c_id . '&t_id=' . $this->t_id, 'succ'); } } } // 圈子信息 $this->circleInfo(); // 圈主和管理信息 $this->manageList(); // 会员信息 $this->memberInfo(); // 话题信息 $this->themeInfo(); // 附件信息 $where = array(); $where['member_id'] = $_SESSION['member_id']; $where['affix_type'] = 2; $where['reply_id'] = array('in', array(0, $this->r_id)); $where['theme_id'] = array('in', array(0, $this->t_id)); $affix_list = Model()->table('circle_affix')->where($where)->select(); Tpl::output('affix_list', $affix_list); // 商品信息 $where = array(); $where['theme_id'] = $this->t_id; $where['reply_id'] = $this->r_id; $goods_list = Model()->table('circle_thg')->where($where)->select(); $goods_list = tidyThemeGoods($goods_list, 'themegoods_id'); Tpl::output('goods_list', $goods_list); $this->circleSEO(L('nc_edit_theme')); // breadcrumb navigation $this->breadcrumd(L('nc_edit_reply')); Tpl::showpage('theme.edit_reply'); }