Ejemplo n.º 1
0
         $curuser = $this->get('security.context')->getToken()->getUser();
         $eno = $curuser->eno;
         $verchange = new \Justsy\BaseBundle\Management\VersionChange($da, $this->get("logger"));
         $result = $verchange->SetVersionChange(2, (string) $paraArr[0], $eno);
         //向客户端发送即时通知
         $message = Utils::makeHTMLElementTag('employee', $jid, $nick_name) . "加入了群组【" . Utils::makeHTMLElementTag('group', $fafa_groupid, $group_name) . "】";
         $this->sendPresenceGroup($fafa_groupid, "group_addmember", $message);
         return $this->render('JustsyBaseBundle:Error:success.html.twig', array('backurl' => $backurl));
     }
 }
 //向指定的群组成员发送出席
Ejemplo n.º 2
0
 public function sendGroupPresenceAction()
 {
     //判断请求域。是wefafa或子域则不验证授权令牌
     $isWeFaFaDomain = $this->checkWWWDomain();
     $res = $this->get("request");
     $da = $this->get("we_data_access");
     if (!$isWeFaFaDomain) {
         $token = $this->checkAccessToken($res, $da);
         if (!$token) {
             $response = new Response("{\"returncode\":\"9999\",\"code\":\"err1015\",\"msg\":\"参数Appid或Openid或Access_token未指定或无效.\"}");
             $response->headers->set('Content-Type', 'text/html');
             return $response;
         }
     }
     //获取群组人员
     $depts = trim($res->get("groupid"));
     if (empty($depts)) {
         $response = new Response("{\"returncode\":\"9999\",\"code\":\"err1015\",\"msg\":\"参数groupid未指定或无效.\"}");
         $response->headers->set('Content-Type', 'text/html');
         return $response;
     }
     $cctomail = $res->get("cctomail");
     $deptMgr = new \Justsy\BaseBundle\Management\GroupMgr($da, $this->get("we_data_access_im"));
     $r = "{\"returncode\" : \"0000\"}";
     $depts = explode(",", $depts);
     for ($pos = 0; $pos < count($depts); $pos++) {
         if (empty($depts[$pos])) {
             continue;
         }
         $jids = $deptMgr->getGroupMembersJid($depts[$pos]);
         if ($jids != null && count($jids) > 0) {
             $r = $this->sendPresence($res->get("From") . $res->get("from"), implode(",", $jids), $res->get("Title") . $res->get("title"), $res->get("Message") . $res->get("message"), $res->get("Link") . $res->get("link"), $res->get("Linktext") . $res->get("Buttons") . $res->get("linktext") . $res->get("buttons"), false, trim($res->get("type")), $cctomail);
         }
     }
     $response = new Response($r);
     $response->headers->set('Content-Type', 'text/html');
     return $response;
 }
Ejemplo n.º 3
0
 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");
     }
 }