Esempio n. 1
0
     } else {
         $pageindex = 1;
     }
     $pagestart = ($pageindex - 1) * $pagesize;
     $sql .= " limit {$pagestart}, 100 ";
     $sql = " select * from ({$sql}) as _ttt_ where 1=1 ";
     if ($endid) {
         $sql .= " and (0+conv_root_id)<? ";
         $para[] = (double) $endid;
     }
     $sql .= " limit 0, 15 ";
     $da = $this->get('we_data_access');
     $ds = $da->GetData("we_convers_list", $sql, $para);
     //生成html返回
     $conv_root_ids = array_map(function ($row) {
         return $row["conv_root_id"];
     }, $ds["we_convers_list"]["rows"]);
     if ($type == 'all' && empty($endid) && count($conv_root_ids) > 0) {
         //更新用户最后读的信息ID
         $conv = new \Justsy\BaseBundle\Business\Conv();
         $conv->updateLastReadID_Group($da, $user, $groupid, $conv_root_ids[0]);
     }
     return $this->forward("JustsyBaseBundle:CDisplayArea:getConv", array("conv_root_ids" => $conv_root_ids, 'trend' => true));
 }
 public function getGroupConversPcAction($type, $groupid)
 {
     $request = $this->get("request");
     $user = $this->get('security.context')->getToken()->getUser();
     $da = $this->get('we_data_access');
     $circleId = $user->get_circle_id($request->get("network_domain"));
     $endid = $request->get('endid');
     $pre450num = $request->get('pre450num');
     $pageindex = $request->get('pageindex');
     $pagesize = 45;
     $sql = '';
     $para = array();
     if ($type == 'all') {
         $sql = "select conv_root_id from we_convers_list a where a.conv_id=a.conv_root_id and a.post_to_group=?";
         $para[] = (string) $groupid;
     } else {
         if ($type == 'atten') {
             $sql = "select a.conv_root_id \r        from we_convers_list a, we_staff_atten b\r        where a.conv_id=a.conv_root_id\r          and a.login_account=b.atten_id \r          and b.atten_type='01'\r          and a.post_to_group=?\r          and a.post_to_circle=?\r          and b.login_account=?";
             $para[] = (string) $groupid;
             $para[] = (string) $circleId;
             $para[] = (string) $user->getUsername();
         } else {
             if ($type == 'publish') {
                 $sql = "select a.conv_root_id \r        from we_convers_list a\r        where a.conv_id=a.conv_root_id\r          and a.post_to_group=?\r          and a.post_to_circle=?\r          and a.login_account=?";
                 $para[] = (string) $groupid;
                 $para[] = (string) $circleId;
                 $para[] = (string) $user->getUsername();
             }
         }
     }
     if ($pre450num) {
         $sql = "select count(*) c from ({$sql} limit 0, 450) as _ttt_";
         $ds = $da->GetData("we_convers_list", $sql, $para);
         $re = array("pre450num" => $ds["we_convers_list"]["rows"][0]["c"]);
         $response = new Response(json_encode($re));
         $response->headers->set('Content-Type', 'text/json');
         return $response;
     }
     $sql .= " order by post_date desc";
     if ($pageindex) {
Esempio n. 2
0
 public function getUnreadConvAction()
 {
     $re = array("returncode" => ReturnCode::$SUCCESS);
     $request = $this->getRequest();
     $user = $this->get('security.context')->getToken()->getUser();
     $da = $this->get('we_data_access');
     $circle_id = $request->get("circle_id");
     $group_id = $request->get("group_id");
     $max_id = $request->get("max_id");
     $last_end_id = $request->get("last_end_id");
     try {
         if (empty($circle_id)) {
             throw new \Exception("param is null");
         }
         $sql = "select a.conv_root_id \nfrom we_convers_list a\nwhere a.conv_id=a.conv_root_id\n  and a.post_to_circle=?";
         $params = array();
         $params[] = (string) $circle_id;
         if ($circle_id == "9999") {
             //从im库中查询好友
             $staffmgr = new \Justsy\BaseBundle\Management\Staff($da, $this->get('we_data_access_im'), $user, $this->get("logger"), $this->container);
             $getfriendList = $staffmgr->getFriendLoginAccountList("1");
             if ($getfriendList && count($getfriendList) > 0) {
                 $sql .= " and a.login_account in ('" . implode("','", $getfriendList) . "','" . $user->getUserName() . "')";
             } else {
                 $sql .= " and a.login_account=?";
                 $params[] = (string) $user->getUserName();
             }
         }
         if (!empty($group_id)) {
             $sql .= " and a.post_to_group = ? ";
             $params[] = (string) $group_id;
         } else {
             $sql .= " and (a.post_to_group in ('ALL', case when a.login_account=? then 'PRIVATE' else '' end)\n                    or exists(select 1 from we_convers_notify wcn where wcn.conv_id=a.conv_id and wcn.cc_login_account=?)) ";
             $params[] = (string) $user->getUserName();
             $params[] = (string) $user->getUserName();
         }
         $sql .= " and (0+conv_root_id)>? and 0<>?";
         $params[] = (double) $max_id;
         $params[] = (double) $max_id;
         if (!empty($last_end_id)) {
             $sql .= " and (0+conv_root_id)<? ";
             $params[] = (double) $last_end_id;
         }
         $sql .= " and a.conv_type_id<>'06' ";
         $sql .= " order by (0+a.conv_id) desc";
         $sql .= " limit 0, 15 ";
         $da = $this->get('we_data_access');
         $ds = $da->GetData("we_convers_list", $sql, $params);
         $conv_root_ids = array_map(function ($row) {
             return $row["conv_root_id"];
         }, $ds["we_convers_list"]["rows"]);
         $re["convs"] = $this->getConvAction($conv_root_ids);
         if (count($conv_root_ids) > 0 && empty($last_end_id)) {
             //更新用户最后读的信息ID
             $conv = new \Justsy\BaseBundle\Business\Conv();
             if (empty($group_id)) {
                 $conv->updateLastReadID_Circle($da, $user, $circle_id, $conv_root_ids[0]);
             } else {
                 $conv->updateLastReadID_Group($da, $user, $group_id, $conv_root_ids[0]);
             }
         }
     } catch (\Exception $e) {
         $re["returncode"] = ReturnCode::$SYSERROR;
         $this->get('logger')->err($e);
     }
     $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }