function delete_qun($qid, $cat_id) { $where_sql = " qid='{$qid}' "; DB::query("DELETE FROM " . DB::table('qun') . " WHERE {$where_sql}"); DB::query("DELETE FROM " . DB::table('qun_user') . " WHERE {$where_sql}"); $this->delete_tag_relation($qid); $info = DB::fetch_first("SELECT icon FROM " . DB::table('qun') . " WHERE qid='{$qid}'"); if (!empty($info['icon'])) { unlink($this->qun_avatar($qid, 's')); unlink($this->qun_avatar($qid, 'b')); } DB::query("DELETE FROM " . DB::table('qun_announcement') . " WHERE qid='{$qid}'"); $cat_ary = $this->get_category(); $top_cat_id = $cat_ary['second'][$cat_id]['parent_id']; DB::query("UPDATE " . DB::table('qun_category') . "\r\n\t\t\t\t SET qun_num = if(qun_num>0,qun_num-1,0)\r\n\t\t\t\t WHERE cat_id IN('{$cat_id}','{$top_cat_id}') "); $this->update_category_cache(); load::logic('event'); $EventLogic = new EventLogic(); $eid_arr = array(); $query = DB::query("SELECT eid FROM " . DB::table('qun_event') . " WHERE qid='{$qid}'"); while ($val = DB::fetch($query)) { $eid_arr[$val['eid']] = $val['eid']; } foreach ($eid_arr as $key => $eid) { $EventLogic->delEvent($eid); } $tids = array(); $query = DB::query("SELECT tid FROM " . DB::table('topic_qun') . " WHERE item_id='{$qid}'"); while ($value = DB::fetch($query)) { $tids[] = $value['tid']; } if (!empty($tids)) { DB::query("DELETE FROM " . DB::table('topic_qun') . " WHERE item_id='{$qid}'"); $where_sql = " tid IN(" . jimplode($tids) . ") "; DB::query("DELETE FROM " . DB::table('topic') . " WHERE {$where_sql} "); } }
function editEvent() { $id = (int) $this->Get['id']; load::logic('event'); $EventLogic = new EventLogic(); $postman = $EventLogic->get_postman($id); if ($postman != MEMBER_ID) { $this->Messager("你无权修改该活动"); } $free = 'checked'; $all = 'checked'; $info = array(); $info = jconf::get('profileeventinfo'); $val = array(); if ($id) { $act = "edit"; $val = $EventLogic->get_event_info($id); $item_id = $val['item_id']; $title = $val['title']; $moneys = $val['money']; $content = $val['content']; $address = $val['address']; if ($val['image']) { $image = $val['image']; } $edit_fromt = date("Y-m-d", $val['fromt']); $edit_fromt_h = date("H", $val['fromt']); $edit_fromt_i = date("i", $val['fromt']); $edit_tot = date("Y-m-d", $val['tot']); $edit_tot_h = date("H", $val['tot']); $edit_tot_i = date("i", $val['tot']); if ($val['money']) { $money = 'checked'; $free = ''; } else { $money = ''; $free = 'checked'; } $qualification = unserialize($val['qualification']); if (count($qualification)) { $qua = "checked"; $all = ""; if ($qualification['fans_num']) { $fans = "checked"; $fans_num = $qualification['fans_num']; } if ($qualification['same_city']) { $same_city = "checked"; } if ($qualification['inqun']) { $inqun = " checked "; } } $need_app_info = unserialize($val['need_app_info']); if (count($need_app_info)) { foreach ($need_app_info as $value) { $info[$value]['checked'] = "checked"; } } } $rs = $EventLogic->get_event_type(TRUE); $event_type = jform()->Select("type", $rs, $val['type_id']); $province = $EventLogic->get_province(); $province_id = $val['province_id']; $hid_province = $province_id; $province_list = jform()->Select("province", $province, $province_id, "onchange=\"changeProvince();\""); $city_id = $val['city_id']; $hid_city = $city_id; $area_id = $val['area_id']; $hid_area = $area_id; $fromt = $edit_fromt ? $edit_fromt : my_date_format(TIMESTAMP, 'Y-m-d'); $edit_fromt_h = $edit_fromt_h ? $edit_fromt_h : false; $edit_fromt_i = $edit_fromt_i ? $edit_fromt_i : false; $hour_select_from = mk_time_select('hour', $edit_fromt_h, 'hour_select_from'); $min_select_from = mk_time_select('min', $edit_fromt_i, 'min_select_from'); $tot = $edit_tot ? $edit_tot : my_date_format(TIMESTAMP + 7 * 24 * 3600, 'Y-m-d'); $edit_tot_h = $edit_tot_h ? $edit_tot_h : false; $edit_tot_i = $edit_tot_i ? $edit_tot_i : false; $hour_select_to = mk_time_select('hour', $edit_tot_h, 'hour_select_to'); $min_select_to = mk_time_select('min', $edit_tot_i, 'min_select_to'); $member = $this->Member; $this->Title = "修改活动"; include template('event/event_create'); }
function need_info() { load::logic('event'); $EventLogic = new EventLogic(); $id = (int) $this->Get['id']; $post = $this->Post; $profile = jlogic('member_profile')->getProfile(); $event_info = $EventLogic->get_event_info($id); $qua = $event_info['need_app_info']; $qua_info = unserialize($qua); $qua_arr = array(); $time = TIMESTAMP; if ($qua_info) { foreach ($qua_info as $key => $val) { if (!$post[$val]) { json_error("请输入" . $profile[$val]['title']); } if ($profile[$val]['formtype'] == 'select' && $profile[$val]['choices']) { $choices = explode("\r\n", $profile[$val]['choices']); foreach ($choices as $v) { list($v1, $v2) = explode("|", $v); $v2 || ($v2 = $v1); $new_choices[$v1] = $v2; } if ($new_choices[$post[$val]]) { $post[$val] = $new_choices[$post[$val]]; } unset($new_choices); } $qua_arr[$profile[$val]['title']] = $post[$val]; } } $qua_arr['留言'] = $post['content']; $qua = serialize($qua_arr); $EventLogic->doApp($id, $qua); json_result("1"); }
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'); } }
function delete() { $ids = array(); $up_ids = array(); $id = (int) $this->Get['id']; if ($id) { $ids[] = $id; } if ($this->Post['cronssubmit']) { $ids = $this->Post['ids']; $up_ids = $this->Post['up_id']; $vid = $this->Post['vid']; } if (!empty($vid)) { $this->DatabaseHandler->Query("update " . TABLE_PREFIX . "event set recd = 0 where id in ('" . implode("','", $vid) . "')"); foreach ($vid as $val) { if (!in_array($val, $ids) && in_array($val, $up_ids)) { $this->DatabaseHandler->Query("update " . TABLE_PREFIX . "event set recd = 1 where id = '{$val}' "); } } } load::logic('event'); $eventLogic = new EventLogic(); if ($ids) { foreach ($ids as $val) { $eventLogic->delEvent($val, 1); } } $this->Messager("操作成功"); }
function SearchTopics2($createduid = '', $containers = '', $appose = true, $content = '', $content2 = '', $topicIds = '', $item = '', $item_Ids = '', $forwards = '', $replys = '', $from = '', $type = '', $location = '', $sDateline = '', $eDateline = '', $page = 1, $pageSize, $getReply = false, $includeSelf = true, $getItem = true, $isOpen = false) { $sql = "SELECT t.*,u.uname,u.face_url,b.bname,tl.longtext,tl.id as longid,tl.dateline as ldateline,tl.views,tl.modify_times,tl.last_modify "; $sql .= ",(select (count(tt.tid)) from topic tt where tt.item='baobei' and tt.item_id=t.item_id) as baobei_replys "; $sql .= "FROM topic t "; $sql .= "left join user u on u.uid=t.uid "; $sql .= "left join topic_longtext tl on tl.id=t.longtextid "; $sql .= "left join building b on b.bid=t.container_id "; $order = " order by t.dateline desc"; $where = " where 1=1"; $sqlcount = "select count(t.tid) as rs from topic t"; if ($page > 0) { if ($pageSize == "" || $pageSize == 0) { $pageSize = $this->Config['building_topic_pagesize']; } $startrecord = $pageSize * ($page - 1); $endrecord = $pageSize * $page; $limit = ' limit ' . $startrecord . ',' . $pageSize; } if ($content != '') { $where .= " and t.content like '%{$content}%'"; } if ($content2 != '') { $where .= " and t.content like '%{$content2}%'"; } if ($topicIds != '') { if (!$getReply) { $where .= " and t.tid in({$topicIds})"; } else { $where .= " and t.tid in(select replyids from topic_more where tid in({$topicIds}))"; } } if ($item != '') { $where .= " and t.item='{$item}'"; } if ($item_Ids != '') { $where .= " and t.item_id in({$item_Ids})"; } if ($forwards > 0) { $where .= " and t.forwards>{$forwards}"; } if ($replys > 0) { $where .= " and t.replys>{$replys}"; } if ($from != '') { $where .= " and t.from='{$from}'"; } if ($type != '') { if ($type != 'reply') { $where .= " and t.type='{$type}' and t.type!='reply'"; } else { $where .= " and t.type='{$type}'"; } } else { $where .= " and t.type!='reply'"; } if ($sDateline && $sDateline != '' && $sDateline > 0) { $where .= " and t.dateline>={$sDateline}"; } if ($eDateline && $eDateline != '' && $eDateline > 0) { $where .= " and t.dateline<={$eDateline}"; } $temp = ''; if ($containers && is_array($containers) && count($containers) > 0) { foreach ($containers as $con) { $context = $con['name']; $conids = $con['ids']; if ($temp == '') { $temp = "(t.container='{$context}' and t.container_id in({$conids}))"; } else { $temp .= " or (t.container='{$context}' and t.container_id in({$conids}))"; } } } $uidcon = ''; if ($createduid != '') { $uidcon = "(t.uid in({$createduid}) and t.type!='reply')"; } if ($this->User && $this->User['uid'] > 0) { if ($includeSelf) { if ($uidcon == '') { $uidcon = "(t.uid=" . $this->User['uid'] . " and t.type!='reply')"; } else { $uidcon .= " or " . "(t.uid=" . $this->User['uid'] . " and t.type!='reply')"; } } } if ($uidcon != '' && $temp != '') { if (!$appose) { $where .= " and ({$uidcon} or(" . $temp . "))"; } else { $where .= " and {$uidcon} and (" . $temp . "))"; } } else { if ($uidcon != '' && $temp == '') { $where .= " and {$uidcon}"; } else { if ($uidcon == '' && $temp != '') { $where .= " and (" . $temp . ")"; } } } $time_s = time(); $sqlcount .= $where; $rows = array(); $total_row = $this->DatabaseHandler->FetchFirst($sqlcount); $totalRS = $total_row['rs']; //$this->Logger->Write($sqlcount); if ($totalRS > 0) { $sqlr = trim($sql . $where . $order . $limit); $query = $this->DatabaseHandler->Query($sqlr); $rows = $query->GetAll(); $topics = array(); if ($rows && is_array($rows) && count($rows) > 0) { foreach ($rows as $row) { $row['o_content'] = $row['content']; $this->_parseTag($row); $this->_parseAt($row); if ($isOpen && $isOpen == true) { $row['longtext'] = Json_Filter($row['longtext']); $row['o_content'] = Json_Filter($row['content']); $row['content'] = Json_Filter($row['content']); } $imageids = $row['imageid']; if ($imageids && $imageids != '') { $imagedRows = $this->ImageTopic->GetTopicImages($imageids); if ($imagedRows && is_array($imagedRows) && count($imagedRows) > 0) { $row['imageurls'] = $imagedRows; } $img_names = ''; foreach ($imagedRows as $img) { if ($img_names == '') { $img_names = $img['img_prefix']; } else { $img_names = $img_names . "," . $img['img_prefix']; } } $row['img_names'] = $img_names; } $row['date'] = getTime($row['dateline']); if ($row['lastupdate'] && $row['lastupdate'] > 0) { $row['update'] = date('Y-m-j H:i', $row['lastupdate']); } $from = $row['from']; if ($from == 'web') { $row['platform'] = "邻居网页版"; } else { if (strtolower($from) == 'android') { $row['platform'] = "Android客户端"; } else { if (strtolower($from) == 'iphone') { $row['platform'] = "iPhone客户端"; } else { if (strtolower($from) == 'wp') { $row['platform'] = "WindowsPhone客户端"; } else { $row['platform'] = "未知平台"; } } } } $from = "<a href=\"index.php\">" . $this->Config['sitetitle'] . "</a>"; if ($row['container'] != '') { $c = $row['container']; $c_id = $row['container_id']; $c_name = ''; switch ($c) { case "building": $crow = $this->DatabaseHandler->FetchFirst("select bname from {$c} where bid={$c_id}"); if ($crow) { $from = "<a href=\"index.php?mod=point&action=profile&bid={$c_id}\" target=\"_blank\">" . $crow['bname'] . "</a>"; } break; } } $itemlink = ''; if ($getItem && $getItem == true) { if ($row['item'] != '' && $row['item_id'] != '') { $row['hasitem'] = 1; $item_id = $row['item_id']; switch ($row['item']) { case 'event': $itemlink = "<a href=\"index.php?mod=event&action=main\">活动</a>"; if (!class_exists('EventEntity')) { include __WEB_ROOT . '/Include/Entities/event.entity.php'; } if (!class_exists('EventLogic')) { include __WEB_ROOT . '/Include/logic/event.logic.php'; } $eventLogic = new EventLogic($this->ModObj); $event_row = $eventLogic->SearchEvents('', $item_id, '', '', '', 0, 0); $event = $event_row['data'][0]; $row['item_info'] = $event; break; case 'baobei': $itemlink = "<a href=\"index.php?mod=baobei&action=main\">宝贝</a>"; if (!class_exists('BaoBeiItem')) { include __WEB_ROOT . '/Include/Entities/baobeiitem.php'; } if (!class_exists('BaobeiLogic')) { include __WEB_ROOT . '/Include/logic/baobei.logic.php'; } $baobeiLogic = new BaobeiLogic($this->ModObj); $baobe_row = $baobeiLogic->SearchBaobeis($item_id, '', 0, 0, '', '', 0, 1, 21); $baobei = $baobe_row['data'][0]; $row['item_info'] = $baobei; break; case 'vote': $itemlink = "<a href=\"index.php?mod=vote&action=main\">投票</a>"; if (!class_exists('VoteEntity')) { include __WEB_ROOT . '/Include/Entities/vote.entity.php'; } if (!class_exists('VoteEntryEntity')) { include __WEB_ROOT . '/Include/Entities/voteentry.entity.php'; } if (!class_exists('VoteLogic')) { include __WEB_ROOT . '/Include/logic/vote.logic.php'; } $voteLogic = new VoteLogic($this->ModObj); $vote_row = $vote = $voteLogic->SearchVote('', $item_id, '', '', '', 0, 0); $vote = $vote_row['data'][0]; $row['item_info'] = $vote; break; } } } if ($isOpen && $isOpen == true) { $itemlink = Json_Filter($itemlink); $from = Json_Filter($from); } if ($itemlink != '') { $row['f'] = $itemlink . ' - ' . $from; } else { $row['f'] = $from; } if ($row['roottid'] > 0) { $result = $this->SearchTopics('', '', '', '', '', '', $row['roottid']); $row['root'] = $result['data'][0]; } $topics[] = $row; } $result['data'] = $topics; } } else { $result['data'] = array(); } $time_e = time(); $result['total'] = $totalRS; return $result; }