示例#1
0
 function view()
 {
     $uid = MEMBER_ID;
     $qid = intval(trim($this->Get['qid']));
     $tag = get_safe_code($this->Get['tag']);
     $view = trim($this->Get['view']);
     $qun_info = $this->QunLogic->get_qun_info($qid);
     if ($qun_info['qun_theme_id']) {
         $this->Config['qun_theme_id'] = $qun_info['qun_theme_id'];
         $this->Config['theme_id'] = '';
         $this->Config['theme_bg_image'] = '';
         $this->Config['theme_bg_color'] = '';
         $this->Config['theme_text_color'] = '';
         $this->Config['theme_link_color'] = '';
         $this->Config['theme_bg_image_type'] = '';
         $this->Config['theme_bg_repeat'] = '';
         $this->Config['theme_bg_fixed'] = '';
     }
     if (empty($qun_info)) {
         $this->Messager("当前" . $this->Config[changeword][weiqun] . "不存在或者已经被删除了", 'index.php?mod=qun');
     }
     if (!empty($tag)) {
         $qun_info['icon'] = $this->QunLogic->qun_avatar($qun_info['qid'], 's');
     } else {
         $qun_info['icon'] = $this->QunLogic->qun_avatar($qun_info['qid'], 'b');
     }
     $active = array();
     $topic_list = array();
     $get_topic_flg = true;
     $this->item_id = $qid;
     $params['code'] = $this->item;
     $cat_ary = $this->QunLogic->get_category();
     $top_cat = array();
     $sub_cat = array();
     if ($cat_ary['second'][$qun_info['cat_id']]) {
         $sub_cat = array('cat_name' => $cat_ary['second'][$qun_info['cat_id']]['cat_name'], 'cat_id' => $qun_info['cat_id']);
         $parent_id = $cat_ary['second'][$qun_info['cat_id']]['parent_id'];
         $top_cat = array('cat_name' => $cat_ary['first'][$parent_id]['cat_name'], 'cat_id' => $parent_id);
     } else {
         $top_cat = array('cat_name' => $cat_ary['first'][$qun_info['cat_id']]['cat_name'], 'cat_id' => $qun_info['cat_id']);
     }
     $founder_info = $this->TopicLogic->GetMember($qun_info['founderuid']);
     $qun_admin_list = $this->QunLogic->get_admin_list($qid);
     $tag_ary = $this->QunLogic->get_qun_tag($qid);
     $recd_event_list = $this->QunLogic->getRecdEventList($qid);
     $recd_vote_list = $this->QunLogic->getRecdVoteList($qid);
     $followme_nums = $this->QunLogic->followme_nums($qid, MEMBER_ID);
     $perm = $this->QunLogic->chk_perm($qid, MEMBER_ID);
     $status = '';
     $allow_list_manage = false;
     if (in_array($perm, array(1, 2, 4)) || MEMBER_ROLE_TYPE == 'admin') {
         $status = 'isgroupuser';
         $allow_list_manage = true;
     }
     jfunc('app');
     $gets = array('mod' => 'qun', 'type' => $this->Get['type'], 'qid' => $qid, 'tag' => $this->Get['tag'], 'code' => $this->Code);
     $page_url = 'index.php?' . url_implode($gets);
     $where = " type!='reply' ";
     if ($this->Get['type']) {
         if ('pic' == $this->Get['type']) {
             $where = " `imageid` > 0 ";
         } else {
             if ('video' == $this->Get['type']) {
                 $where = " `videoid` > 0 ";
             } else {
                 if ('music' == $this->Get['type']) {
                     $where = " `musicid` > 0 ";
                 } else {
                     $this->Get['type'] = '';
                 }
             }
         }
     }
     if (!empty($tag)) {
         $sql = "SELECT * FROM  " . DB::table('tag') . " WHERE name='" . addslashes($tag) . "'";
         $tag_info = DB::fetch_first($sql);
         $tag_id = $tag_info['id'];
         $sql = "SELECT item_id FROM " . DB::table('topic_tag') . " WHERE tag_id='{$tag_id}' ";
         $query = DB::query($sql);
         $topic_ids = array();
         while ($row = DB::fetch($query)) {
             $topic_ids[$row['item_id']] = $row['item_id'];
         }
         if (!empty($topic_ids)) {
             $where .= " AND tid IN(" . jimplode($topic_ids) . ") ";
         }
         $content = "#{$tag}#";
         $view = 'tag';
     } else {
         if ($view == "newreply") {
             $type_where = ' AND ' . $where;
             $per_page_num = $this->ShowConfig['qun']['topic_reply'] ? $this->ShowConfig['qun']['topic_reply'] : 10;
             $count = DB::result_first("SELECT COUNT(*)\r\n\t\t\t\t\t\t\t\t\t\t\tFROM " . DB::table('topic') . "\r\n\t\t\t\t\t\t\t\t\t\t\tWhere `replys` > 0 AND item='qun' AND item_id='{$qid}' {$type_where}");
             if ($count > 0) {
                 $page_arr = page($count, $per_page_num, $page_url, array('return' => 'array'));
                 $condition = " WHERE  `replys` > 0 AND item='qun' AND item_id='{$qid}' {$type_where} ORDER BY `lastupdate` DESC {$page_arr['limit']}";
                 $topic_list = $this->TopicLogic->Get($condition);
             }
             $get_topic_flg = false;
         } else {
             if ($view == 'recd') {
                 Load::logic('topic_list');
                 $TopicListLogic = new TopicListLogic();
                 $p = array('where' => " tr.recd <= 2 AND tr.item='qun' AND tr.item_id='{$qid}' ", 'perpage' => $per_page_num, 'filter' => $this->Get['type']);
                 $info = $TopicListLogic->get_recd_list($p);
                 if (!empty($info)) {
                     $count = $info['count'];
                     $topic_list = $info['list'];
                     $page_arr = $info['page'];
                 }
                 $get_topic_flg = false;
             } elseif ($view == 'event') {
                 $param = array('qid' => $qid, 'where' => " a.item = 'qun' and a.item_id = '{$qid}' ", 'page' => true, 'perpage' => 10, 'page_url' => 'index.php?mod=qun&view=event&qid=' . $qid);
                 load::logic('event');
                 $EventLogic = new EventLogic();
                 $return = $EventLogic->getEventInfo($param);
                 $count = $return['count'] ? $return['count'] : 0;
                 $event = $return['event_list'];
                 $page_arr = $return['page'];
                 $get_topic_flg = false;
             } elseif ($view == 'vote') {
                 load::logic('vote');
                 $VoteLogic = new VoteLogic();
                 $param = array('where' => " v.item = 'qun' and v.item_id = '{$qid}' ", 'order' => " order by v.dateline ", 'page' => true, 'perpage' => 10, 'page_url' => 'index.php?mod=qun&view=vote&qid=' . $qid);
                 $return = $VoteLogic->find($param);
                 $count = $return['count'] ? $return['count'] : 0;
                 if (!empty($return)) {
                     $vote_list = $return['vote_list'];
                     $page_arr['html'] = $return['page']['html'];
                     $uid_ary = $return['uids'];
                 }
                 if (!empty($uid_ary)) {
                     $members = $this->TopicLogic->GetMember($uid_ary);
                 }
                 $get_topic_flg = false;
             } elseif ($view == 'image') {
                 $param = array('item' => 'qun', 'itemid' => $qid, 'page' => true, 'per_page_num' => 20, 'page_url' => 'index.php?mod=qun&view=image&qid=' . $qid);
                 $return = jlogic('image')->get($param);
                 $count = $return['count'] ? $return['count'] : 0;
                 $image_list = $return['list'];
                 $page_arr['html'] = $return['page']['html'];
                 $get_topic_flg = false;
             } elseif ($view == 'attach' && $this->Config['qun_attach_enable']) {
                 global $attach_list;
                 $type = $this->Get['type'];
                 load::logic('attach');
                 $AttachLogic = new AttachLogic();
                 $param = array('item' => 'qun', 'itemid' => $qid, 'page' => true, 'per_page_num' => 20, 'page_url' => 'index.php?mod=qun&view=attach&qid=' . $qid . '&type=' . $type);
                 if ($type) {
                     if ('hot' == $type) {
                         $param['order'] = " order by download DESC ";
                     } else {
                         if ('new' == $type) {
                             $param['order'] = " order by id DESC ";
                         }
                     }
                 }
                 $return = $AttachLogic->get($param);
                 $count = $return['count'] ? $return['count'] : 0;
                 $attach_list = $return['list'];
                 $page_arr['html'] = $return['page']['html'];
                 $get_topic_flg = false;
             } else {
                 $view = 'newtopic';
             }
         }
         $active[$view] = "class='current'";
     }
     if ($get_topic_flg) {
         $options = array('where' => $where, 'page' => true, 'perpage' => $this->ShowConfig['qun']['topic_new'] ? $this->ShowConfig['qun']['topic_new'] : 10, 'page_url' => $page_url);
         $topic_info = app_get_topic_list($this->item, $qid, $options);
         if (!empty($topic_info)) {
             $topic_list = $topic_info['list'];
             $page_arr['html'] = $topic_info['page']['html'];
         }
     }
     $topic_list_count = count($topic_list);
     $parent_list = $this->_get_parent_topic($topic_list);
     $gets = array('item' => $this->item, 'item_id' => $qid);
     $member =& $this->my;
     if (!$this->Config['acceleration_mode'] && $member['medal_id']) {
         $medal_list = $this->TopicLogic->GetMedal($member['medal_id'], $member['uid']);
     }
     $set_qun_closed = 1;
     if (empty($tag)) {
         $new_members = $this->QunLogic->get_new_member_list($qid);
         $this->Title = $this->Config[changeword][weiqun] . ' - ' . $qun_info['name'];
         include template('qun/view');
     } else {
         $this->Title = $this->Config[changeword][weiqun] . ' - ' . $qun_info['name'] . ' - ' . $tag;
         include template('qun/tag_view');
     }
 }