Example #1
0
 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;
 }
Example #2
0
 function GetMessages()
 {
     $uid2 = $this->Post['uid'] ? $this->Post['uid'] : $this->Get['uid'];
     $type = $this->Post['type'] ? $this->Post['type'] : $this->Get['type'];
     $unread = $this->Post['unread'] ? $this->Post['unread'] : $this->Get['unread'];
     $uid = $this->User['uid'];
     $results = $this->Message_Logic->GetMessages($uid, $uid2, $type, 1, 500, $unread);
     $total = $results['total'];
     $msgList = $results['data'];
     if (count($msgList) == 0) {
         echo "";
         exit;
     }
     if ($type == 'outbox') {
         $this->TemplateHandler->AssignValue('box', $type);
         $this->TemplateHandler->AssignValue('messages', $msgList);
         $this->TemplateHandler->AssignValue('uid2', $uid2);
         $this->TemplateHandler->Display('message_list.html');
         return;
     }
     $msgList = ArrayToJson($msgList);
     //$a=array();
     //$a['messages']=$msgList;
     $jsonStr = urldecode(json_encode($msgList));
     //$jsonStr=escape($jsonStr);
     //$jsonStr=addslashes($jsonStr);
     $jsonStr = Json_Filter($jsonStr);
     echo $jsonStr;
     exit;
 }
Example #3
0
 function GetMyFollowings()
 {
     $this->NoLoginAjaxReturn();
     $scope = $this->Post['scope'] ? $this->Post['scope'] : $this->Get['scope'];
     $total = 0;
     $followings = $this->UserLogic->GetUserFollowing($this->User['uid'], 0, 0, $total, true);
     $followings = ArrayToJson($followings);
     $jsonStr = urldecode(json_encode($followings));
     $jsonStr = Json_Filter($jsonStr);
     echo $jsonStr;
     exit;
 }