예제 #1
0
파일: Conv.php 프로젝트: 3116246/haolinju
    public function replyConv($da, $user, $conv_root_id, $conv_id, $conv_content, $reply_to, $comefrom = "00", $ownerContoller = null, $attachs = [])
    {
        $sqls = array();
        $all_params = array();
        $sql = "update we_convers_list set reply_num=reply_num+1 where conv_id=?";
        $params = array();
        $params[] = (string) $conv_root_id;
        $sqls[] = $sql;
        $all_params[] = $params;
        $sqlInsert = 'insert into we_convers_list (conv_id, login_account, post_date, conv_type_id, conv_root_id, conv_content, post_to_group, post_to_circle, reply_to, copy_num, reply_num, comefrom) 
select ?, ?, CURRENT_TIMESTAMP(), ?, ?, ?, a.post_to_group, a.post_to_circle, ?, 0, 0, ?
from we_convers_list a
where a.conv_id=?';
        $params = array();
        $params[] = (string) $conv_id;
        $params[] = (string) $user->getUserName();
        $params[] = (string) '99';
        $params[] = (string) $conv_root_id;
        $params[] = (string) $conv_content;
        $params[] = (string) $reply_to;
        $params[] = (string) $comefrom;
        $params[] = (string) $conv_root_id;
        $sqls[] = $sqlInsert;
        $all_params[] = $params;
        //    for ($i=0; $i<count($notifystaff); $i++)
        //    {
        //      $sqlInsert = 'insert into we_convers_notify (conv_id, cc_login_account) values (?, ?)';
        //      $params = array();
        //      $params[] = (string)$conv_id;
        //      $params[] = (string)$notifystaff[$i];
        //
        //      $sqls[] = $sqlInsert;
        //      $all_params[] = $params;
        //    }
        for ($i = 0; $i < count($attachs); $i++) {
            $sqlInsert = "insert into we_convers_attach (conv_id, attach_type, attach_id) values (?, '0', ?)";
            $params = array();
            $params[] = (string) $conv_id;
            $params[] = (string) $attachs[$i];
            $sqls[] = $sqlInsert;
            $all_params[] = $params;
        }
        $da->ExecSQLs($sqls, $all_params);
        if ($ownerContoller != null && $reply_to != $user->getUserName()) {
            try {
                $link = $ownerContoller->get('router')->generate("JustsyBaseBundle_view_oneconv", array("conv_root_id" => $conv_root_id), true);
                //发送即时消息
                //$link = $this->generateUrl("JustsyBaseBundle_view_oneconv",array("conv_root_id"=> $conv_root_id),true);
                $linkButtons = Utils::makeBusButton(array(array("code" => "action", "text" => "查看", "blank" => "1", "value" => "")));
                if (empty($reply_to)) {
                    $message = "好友" . Utils::makeHTMLElementTag('employee', $user->fafa_jid, $user->nick_name) . "评论了您的动态!";
                    $tmp_rs = $da->GetData("tmp", "SELECT b.fafa_jid,b.login_account FROM we_convers_list a,we_staff b where a.login_account=b.login_account and a.conv_id=?", array((string) $conv_root_id));
                    //var_dump($tmp_rs["tmp"]["rows"][0]["login_account"],$user->getUserName());
                    if ($tmp_rs != null && count($tmp_rs["tmp"]["rows"]) > 0 && $tmp_rs["tmp"]["rows"][0]["login_account"] != $user->getUserName()) {
                        //回复自己发的动态不发消息
                        $to_jid = $tmp_rs["tmp"]["rows"][0]["fafa_jid"];
                        Utils::sendImMessage($user->fafa_jid, $to_jid, "trend-reply", $message, $ownerContoller, $link, $linkButtons, false, Utils::$systemmessage_code);
                    }
                } else {
                    $message = "好友" . Utils::makeHTMLElementTag('employee', $user->fafa_jid, $user->nick_name) . "回复了您的评论!";
                    $tmp_rs = $da->GetData("tmp", "SELECT b.fafa_jid FROM we_staff b where b.login_account=?", array((string) $reply_to));
                    //var_dump($reply_to,$tmp_rs["tmp"]["rows"][0]["fafa_jid"],$user->getUserName());
                    if ($tmp_rs != null && count($tmp_rs["tmp"]["rows"]) > 0) {
                        $to_jid = $tmp_rs["tmp"]["rows"][0]["fafa_jid"];
                        Utils::sendImMessage($user->fafa_jid, $to_jid, "trend-reply", $message, $ownerContoller, $link, $linkButtons, false, Utils::$systemmessage_code);
                    }
                }
            } catch (\Exception $e) {
                $this->get('logger')->err($e);
            }
        }
        //生成评论数
        if ($reply_to != $user->getUserName()) {
            $sql = "";
            $params = array();
            if (empty($reply_to)) {
                $sql = "insert into we_notify(notify_type, msg_id, notify_staff) \nselect '04', ?, login_account \nfrom we_convers_list\nwhere conv_id=? and login_account<>?";
                $params = array();
                $params[] = (string) $conv_id;
                $params[] = (string) $conv_root_id;
                $params[] = (string) $user->getUserName();
            } else {
                $sql = "insert into we_notify(notify_type, msg_id, notify_staff) values('04', ?, ?)";
                $params = array();
                $params[] = (string) $conv_id;
                $params[] = (string) $reply_to;
            }
            $da->ExecSQL($sql, $params);
        }
        \Justsy\BaseBundle\Controller\CInputAreaController::genAtMe($da, $conv_content, $conv_id, $user, $ownerContoller);
    }
예제 #2
0
 public function agreeJoinAction($para)
 {
     //_urlSource
     $res = $this->get('request');
     $urlSource = $res->get("_urlSource");
     //获取操作源。FaFaWin:从PC客户端操作的
     $paraArr = explode(",", trim(DES::decrypt($para)));
     $da = $this->get("we_data_access");
     //检查帐号是否存在
     $sql = "select a.eno,a.fafa_jid,a.nick_name,b.eshortname,a.login_account from we_staff a,we_enterprise b where a.eno=b.eno and login_account=?";
     $ds = $da->GetData('we_staff', $sql, array((string) $paraArr[1]));
     if (!$ds || $ds['we_staff']['recordcount'] == 0) {
         if (empty($urlSource)) {
             return $this->render('JustsyBaseBundle:Circle:join_err.html.twig', array('error' => '申请人帐号不存在!'));
         } else {
             $response = new Response("{\"succeed\":0,\"msg\":\"申请人帐号不存在!\"}");
             $response->headers->set('Content-Type', 'text/json');
             return $response;
         }
     }
     $row = $ds['we_staff']['rows'][0];
     $eno = $row['eno'];
     $appy_user_jid = $row['fafa_jid'];
     $nick_name = $row['nick_name'];
     $eshortname = $row['eshortname'];
     $appy_login_account = $row['login_account'];
     $sql = "select count(1) as cnt from we_circle_staff where circle_id=? and login_account=?";
     $ds = $da->GetData('we_circle_staff', $sql, array((string) $paraArr[0], (string) $paraArr[1]));
     if ($ds && $ds['we_circle_staff']['rows'][0]['cnt'] > 0) {
         if (empty($urlSource)) {
             return $this->render('JustsyBaseBundle:Circle:join_err.html.twig', array('error' => '申请人已加入该圈子!'));
         } else {
             $response = new Response("{\"succeed\":0,\"msg\":\"申请人已加入该圈子!\"}");
             $response->headers->set('Content-Type', 'text/json');
             return $response;
         }
     } else {
         $sqls = array();
         $paras = array();
         //判断圈子是否有人
         $sql = "select min(a.circle_name) circle_name,min(a.fafa_groupid) fafa_groupid, count(1) as cnt from we_circle a, we_circle_staff b where a.circle_id=b.circle_id and b.circle_id=?";
         $ds = $da->GetData('we_circle_staff', $sql, array((string) $paraArr[0]));
         $circle_name = $ds['we_circle_staff']['rows'][0]['circle_name'];
         $fafa_groupid = $ds['we_circle_staff']['rows'][0]['fafa_groupid'];
         if ($ds && $ds['we_circle_staff']['rows'][0]['cnt'] == 0) {
             $sqls[] = "update we_circle set create_staff=? where circle_id=?";
             $paras[] = array((string) $paraArr[1], (string) $paraArr[0]);
         }
         //圈子id+nick_name不能重复
         $sql = "select count(1) cnt from we_circle_staff where circle_id=? and nick_name=?";
         $ds = $da->GetData("cnt", $sql, array((string) $paraArr[0], (string) $nick_name));
         if ($ds && $ds['cnt']['rows'][0]['cnt'] > 0) {
             $nick_name = $nick_name . "(" . $eshortname . ")";
         }
         $sqls[] = "insert into we_circle_staff (circle_id,login_account,nick_name) values (?,?,?)";
         $paras[] = array((string) $paraArr[0], (string) $paraArr[1], (string) $nick_name);
         //10-加入外部圈子-5
         $sqls[] = "insert into we_staff_points (login_account,point_type,point_desc,point,point_date)\n        values (?,?,?,?,now())";
         $paras[] = array((string) $paraArr[1], (string) '10', (string) '成功加入外部圈子' . $circle_name . ',获得积分5', (int) 5);
         $da->ExecSQLs($sqls, $paras);
         $apply = new \Justsy\BaseBundle\Management\ApplyMgr($da, null);
         $apply->SetCircleApplyInvalid($paraArr[1], $paraArr[0]);
         //变更版本信息
         //$curuser = $this->get('security.context')->getToken()->getUser();
         //$eno = $curuser->eno;
         $verchange = new \Justsy\BaseBundle\Management\VersionChange($da, $this->get("logger"));
         $result = $verchange->SetVersionChange(3, $paraArr[0], $eno);
         //发送即时消息通知申请人及成员
         $message = Utils::makeHTMLElementTag('employee', $appy_user_jid, $nick_name) . "加入了圈子【" . Utils::makeHTMLElementTag('circle', $fafa_groupid, $circle_name) . "】";
         $excludeLst = array();
         $excludeLst[] = $appy_login_account;
         //排除自己
         $this->sendPresenceCirlce($paraArr[0], "circle_addmember", $message, "", $excludeLst);
         $message = "你已成功加入圈子【" . $circle_name . "】。";
         $im_sender = $this->container->getParameter('im_sender');
         Utils::sendImMessage($im_sender, $appy_user_jid, "圈子消息", $message, $this->container, "", "", false, Utils::$systemmessage_code);
         $backurl = $this->generateUrl("JustsyBaseBundle_enterprise", array('network_domain' => $paraArr[0]), true);
         if (empty($urlSource)) {
             return $this->render('JustsyBaseBundle:Error:success.html.twig', array('backurl' => $backurl));
         } else {
             $response = new Response("{\"succeed\":1,\"name\":\"" . $circle_name . "\",\"circleurl\":\"" . $backurl . "\"}");
             $response->headers->set('Content-Type', 'text/json');
             return $response;
         }
     }
 }
예제 #3
0
         $list = array();
         $list["curr_network_domain"] = $user->edomain;
         $list["account"] = $user->getUsername();
         $list["trend"] = true;
         $da = $this->get("we_data_access");
         $table = $da->GetData("group", "select group_id,group_name from we_groups where fafa_groupid=?", array((string) $paras[1]));
         if ($table && $table["group"]["recordcount"] > 0) {
             $list["groupId"] = $table["group"]["rows"][0]["group_id"];
             $list["groupName"] = $table["group"]["rows"][0]["group_name"];
         } else {
             $list["groupId"] = $paras[1];
             $list["groupName"] = $paras[1];
         }
         $list['view'] = true;
         $list['publish'] = true;
         $list['group_c'] = $user->IsFunctionCreateGroup($user->edomain);
         $list['group_s'] = $user->IsExistsFunction("GROUP_S");
         return $this->render('JustsyBaseBundle:Group:pcsync.html.twig', $list);
     } catch (\Exception $e) {
         $this->get("logger")->err($e);
         return $this->render('JustsyBaseBundle:Group:pcsync_error.html.twig');
         //$this->redirect($this->generateUrl('JustsyBaseBundle_login'));
     }
 }
 public function quitGroupAction($group_id)
 {
     $re = array();
     $user = $this->get('security.context')->getToken()->getUser();
     $request = $this->getRequest();
     $da = $this->get('we_data_access');
     $sql = "select fafa_groupid,group_name from we_groups where group_id=?";
     $ds = $da->GetData('we_groups', $sql, array((string) $group_id));
     $fafa_groupid = $ds['we_groups']['rows'][0]['fafa_groupid'];
     $group_name = $ds['we_groups']['rows'][0]['group_name'];
예제 #4
0
 public function quitCircleAction($network_domain)
 {
     $re = array();
     $user = $this->get('security.context')->getToken()->getUser();
     $request = $this->getRequest();
     $circle_id = $user->get_circle_id($network_domain);
     $da = $this->get('we_data_access');
     $da_im = $this->get('we_data_access_im');
     $sql = "call p_quitcircle(?, ?, 0)";
     $params = array();
     $params[] = (string) $circle_id;
     $params[] = (string) $user->getUserName();
     $ds = $da->GetData("p_quitcircle", $sql, $params);
     if ($ds["p_quitcircle"]["rows"][0]["recode"] == "0") {
         //向成员发送通知
         $circleMgr = new \Justsy\BaseBundle\Management\CircleMgr($da, $da_im, $circle_id);
         $circleObj = $circleMgr->Get();
         if (!empty($circleObj)) {
             $goupCtl = new GroupController();
             $goupCtl->setContainer($this->container);
             $message = Utils::makeHTMLElementTag('employee', $user->fafa_jid, $user->nick_name) . "退出了圈子【" . $circleObj["circle_name"] . "】";
             $goupCtl->sendPresenceGroup($circleObj["fafa_groupid"], "group_deletemeber", $message);
         }
         $re = array('success' => '1');
     } else {
         $re = array('success' => '0');
         $logger = $this->container->get('logger');
         $logger->err("quitCircle Error circle_id:" . $circle_id . " msg:" . $ds["p_quitgroup"]["rows"][0]["remsg"]);
     }
     $response = new Response(json_encode($re));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
예제 #5
0
 public function agreeJoinCircleAction($para)
 {
     if (empty($para)) {
         return $this->render('JustsyBaseBundle:Error:index.html.twig', array('error' => '参数错误!'));
     }
     $da = $this->get('we_data_access');
     $res = $this->get('request');
     $urlSource = $res->get("_urlSource");
     //获取操作源。FaFaWin:从PC客户端操作的
     //受邀人员帐号,圈子id,邀请人帐号
     $paraArr = explode(",", trim(DES::decrypt($para)));
     //是否有帐号
     $sql = "select nick_name,fafa_jid from we_staff where login_account=?";
     $ds = $da->GetData("we_staff", $sql, array((string) $paraArr[0]));
     if (!$ds || $ds['we_staff']['recordcount'] == 0) {
         if (empty($urlSource)) {
             return $this->render('JustsyBaseBundle:Error:index.html.twig', array('error' => '您还没有微发发帐号,请先注册!'));
         } else {
             $response = new Response("{\"succeed\":0,\"msg\":\"您还没有微发发帐号,请先注册!\"}");
             $response->headers->set('Content-Type', 'text/json');
             return $response;
         }
     }
     //判断是否是邀请加入人脉圈子,则在互相关注
     if ($paraArr[1] == "9999") {
         //互相添加好友
         $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $this->get('we_data_access_im'), $paraArr[2], $this->get("logger"));
         try {
             $staffMgr->attentionTo($paraArr[0]);
         } catch (\Exception $e) {
         }
         try {
             $staffMgr->attentionMe($paraArr[0]);
         } catch (\Exception $e) {
         }
         try {
             $staffMgr->bothAddFriend($this->container, $paraArr[0]);
         } catch (\Exception $e) {
         }
         $response = new Response("{\"succeed\":1,\"name\":\"人脉圈\",\"circleurl\":\"" . $this->generateUrl("JustsyBaseBundle_enterprise", array('network_domain' => "9999"), true) . "\"}");
         $response->headers->set('Content-Type', 'text/json');
         return $response;
     }
     $nick_name = $ds['we_staff']['rows'][0]['nick_name'];
     $fafa_jid = $ds['we_staff']['rows'][0]['fafa_jid'];
     //圈子是否存在
     $sql = "select network_domain,circle_name,fafa_groupid from we_circle where circle_id=?";
     $ds = $da->GetData("we_circle", $sql, array((string) $paraArr[1]));
     if (!$ds || $ds['we_circle']['recordcount'] == 0) {
         if (empty($urlSource)) {
             return $this->render('JustsyBaseBundle:Error:index.html.twig', array('error' => '您要加入的圈子不存在!'));
         } else {
             $response = new Response("{\"succeed\":0,\"msg\":\"您要加入的圈子不存在!\"}");
             $response->headers->set('Content-Type', 'text/json');
             return $response;
         }
     }
     $fafa_groupid = $ds['we_circle']['rows'][0]['fafa_groupid'];
     $network_domain = $ds['we_circle']['rows'][0]['network_domain'];
     $circle_name = $ds['we_circle']['rows'][0]['circle_name'];
     //是否已经加入圈子
     $sql = "select count(1) cnt from we_circle_staff where login_account=? and circle_id=?";
     $ds = $da->GetData("cnt", $sql, array((string) $paraArr[0], (string) $paraArr[1]));
     if ($ds && $ds['cnt']['rows'][0]['cnt'] > 0) {
         if (empty($urlSource)) {
             return $this->render('JustsyBaseBundle:Error:index.html.twig', array('error' => '您已经加入该圈子!'));
         } else {
             $response = new Response("{\"succeed\":0,\"msg\":\"您已经加入该圈子!\"}");
             $response->headers->set('Content-Type', 'text/json');
             return $response;
         }
     }
     //圈子id+nick_name不能重复
     $sql = "select count(1) cnt from we_circle_staff where circle_id=? and nick_name=?";
     $ds = $da->GetData("cnt", $sql, array((string) $paraArr[1], (string) $nick_name));
     if ($ds && $ds['cnt']['rows'][0]['cnt'] > 0) {
         $user = $this->get('security.context')->getToken()->getUser();
         $nick_name = $nick_name . "(" . $user->eshortname . ")";
     }
     //判断圈子是否有人
     $sql = "select count(1) as cnt from we_circle_staff where circle_id=?";
     $ds = $da->GetData('we_circle_staff', $sql, array((string) $paraArr[1]));
     if ($ds && $ds['we_circle_staff']['rows'][0]['cnt'] == 0) {
         $sql = "update we_circle set create_staff=? where circle_id=?";
         $da->ExecSQL($sql, array((string) $paraArr[0], (string) $paraArr[1]));
     }
     $sql = "insert into we_circle_staff (circle_id,login_account,nick_name) values (?,?,?)";
     $da->ExecSQL($sql, array((string) $paraArr[1], (string) $paraArr[0], (string) $nick_name));
     //更新邀请信息
     $sql = "update we_invite set real_active_email=?,active_date=now() where invite_send_email=? and invite_recv_email=? and eno=?";
     $da->ExecSQL($sql, array((string) $paraArr[0], (string) $paraArr[2], (string) $paraArr[0], (string) ("c" . $paraArr[1])));
     //10-加入外部圈子-5
     $sql = "insert into we_staff_points (login_account,point_type,point_desc,point,point_date) values (?,?,?,?,now())";
     $da->ExecSQL($sql, array((string) $paraArr[0], (string) '10', (string) '成功加入外部圈子' . $circle_name . ',获得积分5', (int) 5));
     $apply = new \Justsy\BaseBundle\Management\ApplyMgr($da, null);
     $apply->SetCircleApplyInvalid($paraArr[0], $paraArr[1]);
     //发送即时消息通知申请人及成员
     $circleObj = new \Justsy\BaseBundle\Controller\CircleController();
     $circleObj->setContainer($this->container);
     $message = Utils::makeHTMLElementTag('employee', $fafa_jid, $nick_name) . "加入了圈子【" . Utils::makeHTMLElementTag('circle', $fafa_groupid, $circle_name) . "】";
     $circleObj->sendPresenceCirlce($paraArr[1], "circle_addmember", $message);
     $backurl = $this->generateUrl("JustsyBaseBundle_enterprise", array('network_domain' => $paraArr[0]), true);
     if (empty($urlSource)) {
         return $this->render('JustsyBaseBundle:Error:success.html.twig', array('backurl' => $backurl));
     } else {
         $response = new Response("{\"succeed\":1,\"name\":\"" . $circle_name . "\",\"circleurl\":\"" . $backurl . "\"}");
         $response->headers->set('Content-Type', 'text/json');
         return $response;
     }
 }
예제 #6
0
 public function invitedmemebersAction()
 {
     $re = array("returncode" => ReturnCode::$SUCCESS);
     $user = $this->get('security.context')->getToken()->getUser();
     $request = $this->getRequest();
     $group_id = $request->get("group_id");
     $circle_id = $request->get("circle_id");
     $group_name = $request->get("group_name");
     $fafa_groupid = $request->get('fafa_groupid');
     $invitedmemebers = $request->get("invitedmemebers");
     $im_sender = $this->container->getParameter('im_sender');
     $da = $this->get('we_data_access');
     try {
         if (empty($circle_id) || empty($group_id) || empty($fafa_groupid) || empty($invitedmemebers)) {
             $re["returncode"] = ReturnCode::$SYSERROR;
             $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
             $response->headers->set('Content-Type', 'text/json');
             return $response;
         }
         $invs = explode(";", $invitedmemebers);
         $title = "邀请加入群组";
         $groupStaffs = array();
         $sql = "select login_account from we_group_staff where group_id=?";
         $ds = $da->GetData("group_staffs", $sql, array($group_id));
         if ($ds && $ds["group_staffs"]["recordcount"] > 0) {
             foreach ($ds["group_staffs"]["rows"] as &$row) {
                 $groupStaffs[] = $row['login_account'];
             }
         }
         foreach ($invs as $key => $value) {
             if (empty($value)) {
                 continue;
             }
             if (count($groupStaffs) > 0 && in_array($value, $groupStaffs)) {
                 continue;
             }
             //群编号,被邀请人帐号,network_domain,fafa_groupid
             $encode = DES::encrypt("{$group_id},{$value},{$circle_id}," . $fafa_groupid);
             $activeurl = $this->generateUrl("JustsyBaseBundle_group_invjoin", array('para' => $encode), true);
             $txt = $this->renderView("JustsyBaseBundle:Group:message.html.twig", array("ename" => $user->ename, "realName" => $user->nick_name, "activeurl" => $activeurl, 'gname' => $group_name));
             //发送站内消息
             $msgId = SysSeq::GetSeqNextValue($da, "we_message", "msg_id");
             $sql = "insert into we_message(msg_id,sender,recver,title,content,send_date)values(?,?,?,?,?,now())";
             $da->ExecSQL($sql, array((int) $msgId, (string) $user->getUserName(), (string) $value, "邀请加入群组", $txt));
             //发送即时消息
             $fafa_jid = Utils::getJidByAccount($da, $value);
             //$this->get("logger")->info(Utils::makeHTMLElementTag('employee',$user->fafa_jid,$user->nick_name));
             $message = Utils::makeHTMLElementTag('employee', $user->fafa_jid, $user->nick_name) . "邀请您加入群组【" . Utils::makeHTMLElementTag('group', $fafa_groupid, $group_name) . "】";
             $buttons = array();
             $buttons[] = array("text" => "拒绝", "code" => "agree", "value" => "0");
             $buttons[] = array("text" => "立即加入", "code" => "agree", "value" => "1");
             Utils::sendImMessage($im_sender, $fafa_jid, $title, $message, $this->container, $activeurl . "?invite_user="******"1");
         }
         $re["returncode"] = ReturnCode::$SUCCESS;
     } 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;
 }
예제 #7
0
 public function invitedmemebersAction()
 {
     $re = array("returncode" => ReturnCode::$SUCCESS);
     $user = $this->get('security.context')->getToken()->getUser();
     $request = $this->getRequest();
     $circle_id = $request->get("circle_id");
     $invitedmemebers = $request->get("invitedmemebers");
     $da = $this->get('we_data_access');
     $da_im = $this->get('we_data_access_im');
     try {
         if (empty($invitedmemebers) || empty($circle_id)) {
             $re["returncode"] = ReturnCode::$SYSERROR;
             $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
             $response->headers->set('Content-Type', 'text/json');
             return $response;
         }
         $circlename = "";
         $fafa_groupid = "";
         $user = $this->get('security.context')->getToken()->getUser();
         $invInfo = array('inv_send_acc' => $user->getUsername(), 'inv_recv_acc' => '', 'eno' => '', 'inv_rela' => '', 'inv_title' => '', 'inv_content' => '', 'active_addr' => '');
         $invitedmemebersLst = explode(";", $invitedmemebers);
         $circleStaffs = array();
         $sql = "select login_account from we_circle_staff where circle_id=?";
         $ds = $da->GetData("circle_staffs", $sql, array($circle_id));
         if ($ds && $ds["circle_staffs"]["recordcount"] > 0) {
             foreach ($ds["circle_staffs"]["rows"] as &$row) {
                 $circleStaffs[] = $row['login_account'];
             }
         }
         $sql = "select circle_name,fafa_groupid from we_circle where circle_id=?";
         $ds = $da->GetData("circle", $sql, array($circle_id));
         if ($ds && $ds["circle"]["recordcount"] > 0) {
             $circlename = $ds["circle"]["rows"][0]['circle_name'];
             $fafa_groupid = $ds["circle"]["rows"][0]['fafa_groupid'];
         }
         foreach ($invitedmemebersLst as $key => $value) {
             $invacc = trim($value);
             if (empty($invacc)) {
                 continue;
             }
             $invInfo['inv_recv_acc'] = $invacc;
             $sql = "select eno,fafa_jid from we_staff where login_account=?";
             $ds = $da->GetData("we_staff", $sql, array((string) $invacc));
             //帐号存在
             if ($ds && $ds['we_staff']['recordcount'] > 0) {
                 if (count($circleStaffs) > 0 && in_array($invacc, $circleStaffs)) {
                     continue;
                 }
                 //1.帐号存在,直接加入圈子
                 //受邀人员帐号,圈子id,邀请人帐号
                 $encode = DES::encrypt("{$invacc},{$circle_id}," . $user->getUsername());
                 $activeurl = $this->generateUrl("JustsyBaseBundle_invite_agreejoincircle", array('para' => $encode, 'eno' => 'c' . $circle_id), true);
                 $rejectactiveurl = $this->generateUrl("JustsyBaseBundle_invite_refuse", array('para' => $encode, 'eno' => 'c' . $circle_id), true);
                 $txt = $this->renderView('JustsyBaseBundle:Invite:circle_invitation_msg.html.twig', array("ename" => $user->ename, "nick_name" => $user->nick_name, "activeurl" => $activeurl, 'circle_name' => $circlename, 'invMsg' => '', 'staff' => array()));
                 $invInfo['eno'] = "c{$circle_id}";
                 $invInfo['inv_title'] = "邀请您加入圈子【" . Utils::makeCircleTipHTMLTag($circle_id, $circlename) . "】";
                 $invInfo['inv_content'] = '';
                 $invInfo['active_addr'] = $activeurl;
                 //保存邀请信息
                 InviteController::saveWeInvInfo($da, $invInfo);
                 //发送即时消息
                 $fafa_jid = $ds['we_staff']['rows'][0]['fafa_jid'];
                 $message = Utils::makeHTMLElementTag('employee', $user->fafa_jid, $user->nick_name) . "邀请您加入圈子【" . Utils::makeHTMLElementTag('circle', $fafa_groupid, $circlename) . "】";
                 $buttons = array();
                 $buttons[] = array("text" => "拒绝", "code" => "agree", "value" => "0", "link" => $rejectactiveurl);
                 $buttons[] = array("text" => "立即加入", "code" => "agree", "value" => "1", "link" => $activeurl);
                 Utils::sendImMessage($im_sender, $fafa_jid, "邀请加入圈子", $message, $this->container, "", Utils::makeBusButton($buttons), false, Utils::$systemmessage_code);
             } else {
                 //2.帐号不存在
                 $tmp = explode("@", $invacc);
                 $tmp = count($tmp) > 1 ? $tmp[1] : 'fafatime.com';
                 $sql = "select count(1) as cnt from we_public_domain where domain_name=?";
                 $ds = $da->GetData("we_public_domain", $sql, array((string) $tmp));
                 if ($ds && $ds['we_public_domain']['rows'][0]['cnt'] == 0) {
                     //2.1企业邮箱
                     $sql = "select eno from we_enterprise where edomain=?";
                     $ds = $da->GetData("we_enterprise", $sql, array((string) $tmp));
                     if ($ds && $ds['we_enterprise']['recordcount'] > 0) {
                         //2.1.1企业已创建 帐号,圈子id,企业edomain des encode
                         $eno = $ds['we_enterprise']['rows'][0]['eno'];
                         $encode = DES::encrypt($user->getUsername() . ",{$circle_id},{$eno}");
                         $activeurl = $this->generateUrl("JustsyBaseBundle_active_inv_s1", array('account' => DES::encrypt($invacc), 'invacc' => $encode), true);
                     } else {
                         //2.1.2企业未创建
                         $sql = "insert into we_register (login_account,ename,credential_path,active_code,ip,email_type,first_reg_date,last_reg_date,register_date,state_id)" . " values (?,?,?,?,?,?,now(),now(),now(),'0')";
                         $para = array($invacc, '', '', strtoupper(substr(uniqid(), 3, 10)), $_SERVER['REMOTE_ADDR'], '1');
                         $da->ExecSQL($sql, $para);
                         //发送邮件 帐号,圈子id,邀请发送者帐号,邀请人企业名 des encode
                         $encode = DES::encrypt("{$invacc},{$circle_id}," . $user->getUserName() . "," . $user->ename);
                         $activeurl = $this->generateUrl("JustsyBaseBundle_active_reg_s1", array('account' => $encode), true);
                     }
                     //保存邀请信息 circleid保存到eno字段,以字母'c'开头
                     $invInfo['eno'] = "c{$circle_id}";
                     $title = $user->nick_name . " 邀请您加入 " . Utils::makeCircleTipHTMLTag($circle_id, $circlename) . " 协作网络";
                     $txt = $this->renderView('JustsyBaseBundle:Invite:circle_invitation.html.twig', array("ename" => $user->ename, "nick_name" => $user->nick_name, "activeurl" => $activeurl, 'circle_name' => $circlename, 'invMsg' => '', 'staff' => array()));
                     $invInfo['inv_title'] = $title;
                     $invInfo['inv_content'] = $txt;
                     $invInfo['active_addr'] = $activeurl;
                     InviteController::saveWeInvInfo($da, $invInfo);
                     Utils::saveMail($da, $user->getUsername(), $invacc, $title, $txt, $invInfo['eno']);
                 } else {
                     //公共邮箱
                     $sql = "insert into we_register (login_account,ename,credential_path,active_code,ip,email_type,first_reg_date,last_reg_date,register_date,state_id) " . "select ?,'','','" . strtoupper(substr(uniqid(), 3, 10)) . "','" . $_SERVER['REMOTE_ADDR'] . "','0',now(),now(),now(),'2' from dual " . "where not exists (select 1 from we_register where login_account=?)";
                     $para = array($invacc, $invacc);
                     $da->ExecSQL($sql, $para);
                     //发送邮件 帐号,圈子id,邀请发送者帐号,邀请人企业名 des encode
                     $encode = DES::encrypt("{$invacc},{$circle_id}," . $user->getUserName() . "," . $user->ename);
                     $activeurl = $this->generateUrl("JustsyBaseBundle_active_reg_s1", array('account' => $encode), true);
                     $invInfo['eno'] = "c{$circle_id}";
                     $title = $user->nick_name . " 邀请您加入 " . Utils::makeCircleTipHTMLTag($circle_id, $circlename) . " 协作网络";
                     $txt = $this->renderView('JustsyBaseBundle:Invite:circle_invitation.html.twig', array("ename" => $user->ename, "nick_name" => $user->nick_name, "activeurl" => $activeurl, 'circle_name' => $circlename, 'invMsg' => '', 'staff' => array()));
                     //保存邀请信息
                     $invInfo['inv_title'] = $title;
                     $invInfo['inv_content'] = $txt;
                     $invInfo['active_addr'] = $activeurl;
                     InviteController::saveWeInvInfo($da, $invInfo);
                     Utils::saveMail($da, $user->getUsername(), $invacc, $title, $txt, $invInfo['eno']);
                 }
             }
         }
         $re["returncode"] = ReturnCode::$SUCCESS;
     } 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;
 }
예제 #8
0
 public function attentionAction($attenaccount)
 {
     $this->get("logger")->err("---------------------------2222222222222222------------------");
     $curuser = $this->get('security.context')->getToken()->getUser();
     $isme = $curuser->getUsername();
     $da = $this->get('we_data_access');
     $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $this->get('we_data_access_im'), $curuser->getUserName(), $this->get("logger"));
     $staffMgr->attentionTo($attenaccount);
     //变更版本信息
     $eno = $curuser->eno;
     $this->get("logger")->err("----------------------------eno:" . $eno . "----------------------");
     $verchange = new \Justsy\BaseBundle\Management\VersionChange($da, $this->get("logger"));
     $result = $verchange->SetVersionChange(1, $attenaccount, $eno);
     $result = $verchange->SetVersionChange(1, $isme, $eno);
     $this->get("logger")->err("-----------------444444-------------------");
     //发送关注消息
     $msgId = SysSeq::GetSeqNextValue($da, "we_message", "msg_id");
     $sql = "insert into we_message(msg_id,sender,recver,send_date,title,content)values(?,?,?,now(),?,?)";
     $da->ExecSQL($sql, array((int) $msgId, (string) $isme, (string) $attenaccount, "好友请求", "你的好友<a style='cursor:pointer;color:#1A65A5' class='employee_name' login_account='{$isme}'>" . $curuser->nick_name . "</a>关注了你"));
     //查询是否互关注
     $sql = "select f_checkAttentionWithAccount(?,?) cnt";
     $ds = $da->GetData("both", $sql, array((string) $isme, (string) $attenaccount));
     $IsBoth = $ds["both"]["rows"][0]["cnt"];
     $im_sender = $this->container->getParameter('im_sender');
     $fafa_jid = Utils::getJidByAccount($da, $attenaccount);
     if ($IsBoth != 2) {
         //发送即时消息
         $message = "您的好友 " . Utils::makeHTMLElementTag("employee", $curuser->fafa_jid, $curuser->nick_name) . " 关注了您";
         $link = $this->generateUrl("JustsyBaseBundle_component_emp_attention", array("attenaccount" => $isme), true);
         $linkButtons = Utils::makeBusButton(array(array("code" => "action", "text" => "关注TA", "value" => "atten")));
         Utils::sendImMessage($im_sender, $fafa_jid, "好友请求", $message, $this->container, $link, $linkButtons, false, Utils::$systemmessage_code);
         $response = new Response("{\"succeed\":1,\"both\":{$IsBoth}}");
         //提醒交换名片
         $msg_id = SysSeq::GetSeqNextValue($da, "we_message", "msg_id");
         $sql = "insert into we_message (msg_id,sender,recver,send_date,title,content,msg_type) values(?,?,?,now(),?,?,'02')";
         $params = array($msg_id, $isme, $attenaccount, '好友请求', "<a login_account='" . $isme . "' class='account_baseinfo'>" . $curuser->nick_name . "</a>希望与您成为好友");
         $da->ExecSQL($sql, $params);
     } else {
         //互相添加好友
         $staffMgr->bothAddFriend($this->container, $attenaccount);
         //加入对方的人脉圈子
         $msg_id = SysSeq::GetSeqNextValue($da, "we_message", "msg_id");
         $sql = "insert into we_message (msg_id,sender,recver,send_date,title,content,msg_type) values(?,?,?,now(),?,?,'02')";
         $params = array($msg_id, $isme, $attenaccount, '好友消息', "<a login_account='" . $isme . "' class='account_baseinfo'>" . $curuser->nick_name . "</a>与您成为了好友,并进入了您的人脉圈");
         $da->ExecSQL($sql, $params);
         $response = new Response("{\"succeed\":1,\"both\":{$IsBoth},\"msg\":\"\"}");
     }
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }