Exemple #1
0
 public static function sendImMessage($fromjid, $tojid, $title, $message, $container, $link = "", $linktext = "", $ischeckjid = true, $type = '', $cctomail = '0')
 {
     try {
         if (is_array($tojid)) {
             $tojid = implode(",", $tojid);
         }
         $ec = new \Justsy\OpenAPIBundle\Controller\ApiController();
         $ec->setContainer($container);
         if (!empty($linktext) && is_array($linktext)) {
             $linktext = Utils::makeBusButton($linktext);
         }
         $s = $ec->sendMsg($fromjid, $tojid, $title, $message, $link, $linktext, $ischeckjid, $type, $cctomail);
         $jo = json_decode($s);
         if ($jo && $jo->{'returncode'} == "0000") {
             return true;
         } else {
             return false;
         }
     } catch (\Exception $e) {
         $container->get('logger')->err($e);
         return false;
     }
 }
Exemple #2
0
    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);
    }
 public function sendPresence($conv_id, $da, $circle_id, $post_to_group, $type)
 {
     $groupid = "";
     $group_type = "group";
     $fafa_jid = array();
     $jid = "";
     if ($circle_id == "10000") {
         return;
     }
     $user = $this->get('security.context')->getToken()->getUser();
     if ($post_to_group != "ALL" && $post_to_group != "PRIVATE") {
         $groupObj = new \Justsy\BaseBundle\Management\GroupMgr($da, $this->get('we_data_access_im'), $this->container);
         $getGroupInfo = $groupObj->Get($post_to_group);
         $jid = $getGroupInfo["fafa_groupid"];
         $fafa_jid = $groupObj->getGroupMembersJid($post_to_group, "1");
         //获取允许接收群组动态通知的成员列表
         $groupid = $post_to_group;
     } else {
         $group_type = "circle";
         $groupid = $circle_id;
         $circlemgr = new \Justsy\BaseBundle\Management\CircleMgr($da, $this->get('we_data_access_im'));
         $getGroupInfo = $circlemgr->Get($circle_id);
         $jid = $getGroupInfo["fafa_groupid"];
         //判断是否是私密,私密时不向圈子成员发出席
         if ($post_to_group == "PRIVATE") {
             $group_type = "private";
         } else {
             if ($circle_id == "9999") {
                 $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $this->get('we_data_access_im'), $user, $this->get("logger"), $this->container);
                 $fafa_jid = $staffMgr->getFriendJidList($conv_id);
             } else {
                 $fafa_jid = $circlemgr->getCircleMembersJid($circle_id, "1");
             }
         }
     }
     $cc_jid = array();
     //获取抄送的人员jid
     $sql = "select b.fafa_jid from we_convers_notify a ,we_staff b where a.cc_login_account=b.login_account and conv_id=?";
     $ds = $da->getData("ds", $sql, array((string) $conv_id));
     if ($ds && count($ds["ds"]["rows"]) > 0) {
         for ($i = 0; $i < count($ds["ds"]["rows"]); $i++) {
             $cc_jid[] = $ds["ds"]["rows"][$i]["fafa_jid"];
         }
     }
     //发送即时消息
     $ec = new \Justsy\OpenAPIBundle\Controller\ApiController();
     $ec->setContainer($this->container);
     $message = array($group_type . "id" => $groupid, "t" => $type, "jid" => $jid);
     $link = $this->generateUrl("JustsyBaseBundle_view_oneconv", array("conv_root_id" => $conv_id), true);
     $linkButtons = Utils::makeBusButton(array(array("code" => "action", "text" => "详细", "blank" => "1", "value" => "")));
     //分次发送通知。每次200个号
     $c = 0;
     $sendAry = array();
     for ($i = 0; $i < count($fafa_jid); $i++) {
         $sendAry[] = $fafa_jid[$i];
         $c++;
         if ($c >= 200) {
             $r = $ec->sendPresence($user->fafa_jid, implode(",", $sendAry), "", json_encode($message), $link, $linkButtons, false, $group_type . "_newtrend");
             $c = 0;
             $sendAry = array();
         }
     }
     if ($c > 0) {
         $r = $ec->sendPresence($user->fafa_jid, implode(",", $sendAry), "", json_encode($message), $link, $linkButtons, false, $group_type . "_newtrend", "0");
     }
     if (count($cc_jid) > 0) {
         //给抄送人员推消息
         $r = $ec->sendMsg($user->fafa_jid, implode(",", $cc_jid), "", json_encode($message), $link, $linkButtons, false, "private_newtrend");
     }
 }
Exemple #4
0
         $json = $this->getCircleMembers($circleId, $account, $page * 8);
         $rows['json'] = $json;
     } else {
         $rows['page'] = 0;
         $rows['cnt'] = 0;
     }
     $response = new Response(json_encode($rows));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
 //获取圈子成员
 public function getCircleMembers($circleId, $account, $page)
 {
     $members = array();
     $da = $this->get('we_data_access');
     $fileurl = $this->container->getParameter('FILE_WEBSERVER_URL');
     $sql = "select a.login_account,a.nick_name,fafa_jid,\r      concat('" . $fileurl . "',case trim(ifnull(a.photo_path,'')) when '' then null else a.photo_path end) as photo_path\r      from we_staff a\r      inner join we_circle_staff b on a.login_account=b.login_account where b.circle_id=?\r      and a.login_account!=? order by a.login_account limit {$page},8";
     $ds = $da->GetData('we_staff', $sql, array((string) $circleId, (string) $account));
     if ($ds && $ds['we_staff']['recordcount'] > 0) {
         $members = $ds['we_staff']['rows'];
     }
     return $members;
 }
 //添加成员
 public function addGroupMemberAction()
 {
     $acts = $this->get('request')->request->get('acts');
     $groupId = $this->get('request')->request->get('groupId');
     $invMsg = $this->get('request')->request->get('invMsg');
     $gname = $this->get('request')->request->get('gname');
     $fafa_groupid = $this->get('request')->request->get('fafa_groupid');
     $network_domain = $this->get('request')->request->get('network_domain');
     $im_sender = $this->container->getParameter('im_sender');
     $da = $this->get('we_data_access');
     $user = $this->get('security.context')->getToken()->getUser();
     $title = "邀请加入群组";
     try {
         $b = true;
         foreach ($acts as $key => $value) {
             $s = explode(",", $value);
             $act = $s[0];
             $jid = $s[1];
             $encode = DES::encrypt("{$groupId},{$act},{$network_domain},{$fafa_groupid}");
 public function applyJoinAction()
 {
     $da = $this->get("we_data_access");
     $user = $this->get('security.context')->getToken()->getUser();
     $circleId = $this->get('request')->request->get('circleId');
     $apply = new \Justsy\BaseBundle\Management\ApplyMgr($da, null);
     //判断是否已加入该圈子
     $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) $circleId, (string) $user->getUserName()));
     if (!$ds || $ds['we_circle_staff']['recordcount'] == 0) {
         //已经是该圈子成员
         return new Response("-1");
     }
     //判断是否已超出加入圈子数量的限制
     $ec = new \Justsy\BaseBundle\Management\EnoParamManager($da, $this->get('logger'));
     if ($ec->IsBeyondJoinCircle($user->getUserName())) {
         return new Response("-2");
     }
     //判断改圈子成员数是否已满
     if ($ec->IsBeyondCircleMembers($circleId)) {
         return new Response("-3");
     }
     //判断是否已申请或者超出申请限制
     $result = $apply->ApplyJoinCircle($user->getUsername(), $circleId, "");
     if ($result == 0 || $result == 99999) {
         return new Response((string) $result);
     }
     $circleObj = new \Justsy\BaseBundle\Management\CircleMgr($da, null, $circleId);
     $circle = $circleObj->Get();
     if ($circle == null) {
         return new Response("0");
     }
     $createStaff = $circle["create_staff"];
     $circleName = $circle["circle_name"];
     //para 圈子ID,申请人帐号,申请人姓名,圈子名称 DES加密
     $para = DES::encrypt($circleId . "," . $user->getUserName() . "," . $user->nick_name . "," . $circleName);
     $addurl = $this->generateUrl("JustsyBaseBundle_publicpage_agreejoincircle", array('para' => $para), true);
     $refuseurl = $this->generateUrl("JustsyBaseBundle_circle_refusejoincircle", array(), true);
     $txt = $this->renderView("JustsyBaseBundle:Circle:mail_apply_join.html.twig", array("ename" => $user->ename, "realName" => $user->nick_name, "account" => DES::encrypt($user->getUserName()), "activeurl" => $addurl, "circlename" => $circleName, "refuseurl" => $refuseurl, "para" => $para));
     //发送站内消息
     $sqls = array();
     $paras = array();
     $msgId = SysSeq::GetSeqNextValue($da, "we_message", "msg_id");
     $sqls[] = "insert into we_message(msg_id,sender,recver,send_date,title,content)values(?,?,?,now(),?,?)";
     //$sqls[] = "insert into we_notify(notify_type, msg_id,notify_staff)values('01',?,?)";
     $paras[] = array((int) $msgId, (string) $user->getUserName(), (string) $createStaff, "申请加入圈子", $txt);
     //$paras[] = array((int)$msgId,(string)$createStaff);
     $da->ExecSQLs($sqls, $paras);
     Utils::saveMail($da, $user->getUsername(), $createStaff, "申请加入圈子", $txt, $circleId);
     //Utils::sendMail($this->get('mailer'),"申请加入微发发企业社交圈子",$this->container->getParameter('mailer_user'),null,$createStaff,$txt);
     //发送即时消息
     $im_sender = $this->container->getParameter('im_sender');
     $fafa_jid = $circle["fafa_jid"];
     $message = Utils::makeHTMLElementTag('employee', $user->fafa_jid, $user->nick_name) . "申请加入您的圈子【" . $circleName . "】";
     $buttons = array();
     $buttons[] = array("text" => "拒绝", "code" => "agree", "value" => "0", "link" => $refuseurl . "?para=" . $para);
     $buttons[] = array("text" => "同意", "code" => "agree", "value" => "1", "link" => $addurl);
     Utils::sendImMessage($im_sender, $fafa_jid, "申请加入圈子", $message, $this->container, "", Utils::makeBusButton($buttons), false, Utils::$systemmessage_code);
     return new Response("1");
 }
 public function sendInvitationAction()
 {
     $res = $this->getRequest();
     $im_sender = $this->container->getParameter('im_sender');
     $acts = $res->get('acts');
     $logger = $this->get('logger');
     $da = $this->get('we_data_access');
     $user = $this->get('security.context')->getToken()->getUser();
     $circleId = $res->get("circleId");
     $eno = $res->get('eno');
     $invMsg = $res->get('invMsg');
     $subject = $res->get('subject');
     $invRela = $res->get('invRela');
     $circleName = "";
     if (!empty($circleId)) {
         $circleMgr = new \Justsy\BaseBundle\Management\CircleMgr($da, $this->get('we_data_access_im'), null);
         $circleObj = $circleMgr->Get($circleId);
         if ($circleObj == null && (empty($eno) || $eno == "-1")) {
             return new Response('1');
         }
         $circleName = $circleObj["circle_name"];
     }
     $invInfo = array('inv_send_acc' => $user->getUsername(), 'inv_recv_acc' => '', 'eno' => '', 'inv_rela' => $invRela, 'inv_title' => '', 'inv_content' => '', 'active_addr' => '');
     $photourl = $this->container->getParameter('FILE_WEBSERVER_URL');
     $staff_e = array();
     $staff_c = array();
     $sql = "select c.login_account,c.nick_name,concat('" . $photourl . "',case trim(ifnull(c.photo_path,'')) when '' then null else c.photo_path end) as photo_path \nfrom we_staff c inner join we_circle_staff d on c.login_account=d.login_account where d.circle_id=(\nselect b.circle_id from we_staff a inner join we_circle b on a.eno=b.enterprise_no and a.login_account=?) limit 0,9";
     $ds = $da->GetData("staff", $sql, array((string) $user->getUsername()));
     if ($ds && $ds['staff']['recordcount'] > 0) {
         $staff_e = $ds['staff']['rows'];
     }
     $sql = "select a.login_account,a.nick_name,concat('" . $photourl . "',case trim(ifnull(a.photo_path,'')) when '' then null else a.photo_path end) as photo_path \nfrom we_staff a inner join we_circle_staff b on a.login_account=b.login_account\nwhere a.eno=(select eno from we_staff where login_account=?) and b.circle_id=? limit 0,9";
     $ds = $da->GetData("staff", $sql, array((string) $user->getUsername(), (string) $circleId));
     if ($ds && $ds['staff']['recordcount'] > 0) {
         $staff_c = $ds['staff']['rows'];
     }
     try {
         foreach ($acts as $key => $value) {
             $invacc = trim($value);
             $invInfo['inv_recv_acc'] = $invacc;
             //排除自己
             if ($invacc == $user->getUsername()) {
                 continue;
             }
             $sql = "select fafa_jid from we_staff where login_account=?";
             $ds = $da->GetData("we_staff", $sql, array((string) $invacc));
             $isReg = $ds && $ds['we_staff']['recordcount'] > 0;
             //是否已注册
             if (empty($eno) || $eno == "-1") {
                 //加入圈子
                 if ($isReg) {
                     //1.帐号存在,直接加入圈子
                     //受邀人员帐号,圈子id,邀请人帐号
                     $encode = DES::encrypt("{$invacc},{$circleId}," . $user->getUsername());
                     $activeurl = $this->generateUrl("JustsyBaseBundle_invite_agreejoincircle", array('para' => $encode, 'eno' => 'c' . $circleId), true);
                     $rejectactiveurl = $this->generateUrl("JustsyBaseBundle_invite_refuse", array('para' => $encode, 'eno' => 'c' . $circleId), 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' => $invMsg));
                     $invInfo['eno'] = "c{$circleId}";
                     if (empty($subject)) {
                         if ($circleId == "9999") {
                             $invInfo['inv_title'] = $user->nick_name . " 邀请您加入TA的人脉圈";
                         } else {
                             $invInfo['inv_title'] = $user->nick_name . " 邀请您加入圈子【" . Utils::makeCircleTipHTMLTag($circleId, $circleName) . "】";
                         }
                     } else {
                         $invInfo['inv_title'] = $subject;
                     }
                     $invInfo['inv_content'] = $invMsg;
                     $invInfo['active_addr'] = $activeurl;
                     //保存邀请信息
                     InviteController::saveWeInvInfo($da, $invInfo);
                     //发送即时消息
                     $fafa_jid = $ds['we_staff']['rows'][0]['fafa_jid'];
                     if ($circleId == "9999") {
                         $message = Utils::makeHTMLElementTag('employee', $user->fafa_jid, $user->nick_name) . "邀请您加入TA的人脉圈";
                     } else {
                         $message = Utils::makeHTMLElementTag('employee', $user->fafa_jid, $user->nick_name) . "邀请您加入圈子【" . Utils::makeHTMLElementTag('circle', $circleObj["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($user->fafa_jid, $fafa_jid, "邀请加入圈子", $message, $this->container, "", Utils::makeBusButton($buttons), false, Utils::$systemmessage_code, "1");
                 } 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() . ",{$circleId},{$eno}");
                             $eno = "";
                             $activeurl = $this->generateUrl("JustsyBaseBundle_active_inv_s1", array('account' => DES::encrypt($invacc), 'invacc' => $encode), true);
                             $staff_t = $staff_e;
                             $has_e = "1";
                         } 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) " . "select ?,'','','" . strtoupper(substr(uniqid(), 3, 10)) . "','" . $_SERVER['REMOTE_ADDR'] . "','1',now(),now(),now(),'0' 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},{$circleId}," . $user->getUserName() . "," . $user->ename);
                             $activeurl = $this->generateUrl("JustsyBaseBundle_active_reg_s1", array('account' => $encode), true);
                             $staff_t = array();
                             $has_e = "0";
                         }
                         //保存邀请信息 circleid保存到eno字段,以字母'c'开头
                         if ($circleId == "-1") {
                             $invInfo['eno'] = "-1";
                             $title = empty($subject) ? $user->nick_name . " 邀请您加入Wefafa企业协作网络" : $subject;
                             $txt = $this->renderView("JustsyBaseBundle:Invite:enterprise_invitation.html.twig", array("ename" => $user->ename, "realName" => $user->nick_name, "activeurl" => $activeurl, "invMsg" => $invMsg, "staff" => $staff_t, "has_e" => $has_e));
                         } else {
                             if ($invRela == "0") {
                                 $has_e = "1";
                                 $staff_t = $staff_e;
                             } else {
                                 $has_e = "0";
                                 $staff_t = array();
                             }
                             $invInfo['eno'] = "c{$circleId}";
                             $title = empty($subject) ? $user->nick_name . " 邀请您加入 " . Utils::makeCircleTipHTMLTag($circleId, $circleName) . " 协作网络" : $subject;
                             $txt = $this->renderView('JustsyBaseBundle:Invite:circle_invitation.html.twig', array("ename" => $user->ename, "nick_name" => $user->nick_name, "activeurl" => $activeurl, 'circle_name' => $circleName, 'invMsg' => $invMsg, "staff" => $staff_t, "has_e" => $has_e));
                         }
                         $invInfo['inv_title'] = $title;
                         $invInfo['inv_content'] = $txt;
                         $invInfo['active_addr'] = $activeurl;
                         InviteController::saveWeInvInfo($da, $invInfo);
                         $title = empty($subject) ? $user->nick_name . " 邀请您加入 " . $circleName . " 协作网络" : $subject;
                         Utils::saveMail($da, $user->getUsername(), $invacc, $title, $txt, $invInfo['eno']);
                         //Utils::sendMail($this->get('mailer'),$title,$this->container->getParameter('mailer_user'),null,$invacc,$txt);
                     } else {
                         //2.2公共邮箱
                         if ($invRela == "0") {
                             //邀请同事
                             $eno = $user->eno;
                             $encode = DES::encrypt($user->getUsername() . ",{$circleId},{$eno}");
                             $eno = "";
                             $activeurl = $this->generateUrl("JustsyBaseBundle_active_inv_s1", array('account' => DES::encrypt($invacc), 'invacc' => $encode), true);
                             $txt = $this->renderView('JustsyBaseBundle:Invite:circle_invitation.html.twig', array("ename" => $user->ename, "nick_name" => $user->nick_name, "activeurl" => $activeurl, 'circle_name' => $circleName, 'invMsg' => $invMsg, "staff" => $staff_c, "has_e" => "1"));
                             //保存邀请信息 circleid保存到eno字段,以字母'c'开头
                             $invInfo['eno'] = "c{$circleId}";
                             $invInfo['inv_title'] = empty($subject) ? $user->nick_name . " 邀请您加入 " . Utils::makeCircleTipHTMLTag($circleId, $circleName) . " 协作网络" : $subject;
                             $invInfo['inv_content'] = $txt;
                             $invInfo['active_addr'] = $activeurl;
                             InviteController::saveWeInvInfo($da, $invInfo);
                             $invInfo['inv_title'] = empty($subject) ? $user->nick_name . " 邀请您加入 " . $circleName . " 协作网络" : $subject;
                             Utils::saveMail($da, $user->getUsername(), $invacc, $invInfo['inv_title'], $txt, $invInfo['eno']);
                             //Utils::sendMail($this->get('mailer'),"邀请加入圈子【".$circleName."】",$this->container->getParameter('mailer_user'),null,$invacc,$txt);
                         } 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},{$circleId}," . $user->getUserName() . "," . $user->ename);
                             $activeurl = $this->generateUrl("JustsyBaseBundle_active_reg_s1", array('account' => $encode), true);
                             if ($circleId == "-1") {
                                 $invInfo['eno'] = "-1";
                                 $circleName = "Wefafa企业";
                                 $title = empty($subject) ? $user->nick_name . " 邀请您加入" . $circleName . "协作网络" : $subject;
                                 $txt = $this->renderView("JustsyBaseBundle:Invite:enterprise_invitation.html.twig", array("ename" => $user->ename, "realName" => $user->nick_name, "activeurl" => $activeurl, "invMsg" => $invMsg, "staff" => array()));
                             } else {
                                 $invInfo['eno'] = "c{$circleId}";
                                 $title = empty($subject) ? $user->nick_name . " 邀请您加入 " . Utils::makeCircleTipHTMLTag($circleId, $circleName) . " 协作网络" : $subject;
                                 $txt = $this->renderView('JustsyBaseBundle:Invite:circle_invitation.html.twig', array("ename" => $user->ename, "nick_name" => $user->nick_name, "activeurl" => $activeurl, 'circle_name' => $circleName, 'invMsg' => $invMsg, "staff" => array()));
                             }
                             //保存邀请信息
                             $invInfo['inv_title'] = $title;
                             $invInfo['inv_content'] = $txt;
                             $invInfo['active_addr'] = $activeurl;
                             InviteController::saveWeInvInfo($da, $invInfo);
                             $invInfo['inv_title'] = empty($subject) ? $user->nick_name . " 邀请您加入 " . $circleName . " 协作网络" : $subject;
                             Utils::saveMail($da, $user->getUsername(), $invacc, $title, $txt, $invInfo['eno']);
                             //Utils::sendMail($this->get('mailer'),$title,$this->container->getParameter('mailer_user'),null,$invacc,$txt);
                         }
                     }
                 }
             } else {
                 //判断受邀请人是否已注册,已注册的不能再邀请加个企业圈子
                 //与邀请人不同企业域的其他企业邮箱不能加入
                 if (!$isReg) {
                     //加入企业
                     $activeurl = $this->generateUrl("JustsyBaseBundle_active_inv_s1", array('account' => DES::encrypt($invacc), 'invacc' => DES::encrypt($user->getUsername())), true);
                     $txt = $this->renderView("JustsyBaseBundle:Invite:enterprise_invitation.html.twig", array("ename" => $user->ename, "realName" => $user->nick_name, "activeurl" => $activeurl, "invMsg" => $invMsg, "staff" => $staff_e, "has_e" => "1"));
                     //保存邀请信息
                     $invInfo['eno'] = $eno;
                     $invInfo['inv_title'] = empty($subject) ? "您的同事 " . $user->nick_name . " 邀请您加入Wefafa企业协作网络" : $subject;
                     $invInfo['inv_content'] = $txt;
                     $invInfo['active_addr'] = $activeurl;
                     InviteController::saveWeInvInfo($da, $invInfo);
                     Utils::saveMail($da, $user->getUsername(), $invacc, $invInfo['inv_title'], $txt, $invInfo['eno']);
                 }
             }
         }
     } catch (\Exception $e) {
         $logger->err($e);
         return new Response('0');
     }
     return new Response('1');
 }
Exemple #7
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;
 }
 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;
 }
 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;
 }