Exemple #1
0
 public function reply($data)
 {
     $noticeid = $data["noticeid"];
     if (empty($noticeid)) {
         return Utils::WrapResultError("noticeid不能为空");
     }
     $files = isset($data["files"]) ? $data["files"] : '';
     if (!empty($files) && is_array($files)) {
         $files = implode(',', $files);
     }
     $sql = 'update im_pushnotice_memebr set receive_time=now() where noticeid=? and employeeid=? and receive_time is not null';
     $sql1 = 'insert into im_pushnotice_msg(id,replyid,msg,created,us,msgid)values(?,?,?,now(),?,?)';
     $replyid = SysSeq::GetSeqNextValue($this->conn_im, "im_pushnotice_msg", "id");
     $sql = 'select count(1)+1 cnt from im_pushnotice_msg where replyid=?';
     $ds = $this->conn_im->Getdata('t', $sql, array((int) $noticeid));
     $cnt = $ds['t']['rows'][0]['cnt'];
     $senddata = array();
     $senddata = array('noticeid' => $noticeid, 'reply_count' => $cnt, 'reply' => array('id' => $replyid, 'nickname' => $this->user["nick_name"], 'photo' => $this->user["photo_path"], 'jid' => $this->user["jid"], 'text' => $data["reply-text"], 'files' => $files, 'sendtime' => date("Y-m-d H:i:s", time())));
     $notice = array();
     // Utils::WrapMessageNoticeinfo($data["reply-text"],$this->module["appname"],null,$this->module["logo"]);
     $msg = Utils::WrapMessage('push-notice-reply', $senddata, $notice);
     $msgxml = Utils::WrapMessageXml($this->module["jid"], $msg, 'push-notice-reply-' . $replyid);
     $this->conn_im->ExecSQLs(array($sql, $sql1), array(array((int) $noticeid, (string) $this->user["jid"]), array((int) $replyid, (int) $noticeid, (string) json_encode($senddata['reply']), $this->user['jid'], 'push-notice-reply-' . $replyid)));
     $noticeinfo = $this->getinfo($noticeid);
     $receiver = $this->getmember($noticeid);
     $receiver[] = $noticeinfo["us"];
     Utils::findonlinejid($this->conn_im, $receiver);
     if (!empty($receiver)) {
         //发送消息
         $presence = new \Justsy\OpenAPIBundle\Controller\ApiController();
         $presence->setContainer($this->container);
         $presence->sendMsg($this->module["jid"], $receiver, '通知回复', json_encode($msg));
     }
     return Utils::WrapResultOK(array('noticeid' => $noticeid));
 }
Exemple #2
0
 public function setFriendByDept($deptid, $user = null)
 {
     //判断部门是否设置了自动好友
     $deptinfo = $this->getInfo($deptid);
     if ($deptinfo['friend'] != '1') {
         return;
     }
     $da = $this->conn_im;
     $friendLst = array();
     $success = true;
     $msg = "";
     if (!empty($user)) {
         $login_account = $user["login_account"];
         $fafa_jid = array(isset($user["fafa_jid"]) ? $user["fafa_jid"] : null);
         $staffMgr = new Staff($this->conn, $this->conn_im, $login_account, $this->container->get("logger"), $this->container);
         if (empty($fafa_jid)) {
             $user = $staffMgr->getInfo();
         }
         $friendLst = array(array("jid" => $user["fafa_jid"], "nick_name" => $user["nick_name"]));
     } else {
         $domain = $this->container->getParameter('edomain');
         $staffMgr = new Staff($this->conn, $this->conn_im, "admin@" . $domain, $this->container->get("logger"), $this->container);
         $sql = 'SELECT a.loginname jid,a.employeename nick_name FROM im_employee a where a.deptid=? and not exists(select jid from rosterdept where deptid=? and a.loginname=jid)';
         $ds = $da->GetData("t", $sql, array((string) $deptid, (string) $deptid));
         $friendLst = $ds["t"]["rows"];
     }
     $to_jid = array();
     $staffcount = count($friendLst);
     if ($staffcount == 0) {
         return array("success" => false, "message" => '该部门下没有人员,请进入子部门进行设置');
     }
     for ($i = 0; $i < $staffcount; $i++) {
         $fafa_jid = $friendLst[$i]["jid"];
         $nick_name = $friendLst[$i]["nick_name"];
         //判断是否已全部成为好友
         $sql = "SELECT a.loginname jid,a.employeename nick_name FROM im_employee a where a.deptid=? and not exists (select jid from rosterusers b where a.loginname=b.jid and b.username=? and b.subscription='B')";
         try {
             $ds_member = $da->GetData("member", $sql, array((string) $deptid, (string) $fafa_jid));
             if ($ds_member && count($ds_member["member"]["rows"] > 0)) {
                 if (!empty($user)) {
                     //如果是指定人员与部门人员成为好友,通知对象为部门中还未不是该人的帐号jid
                     for ($ic = 0; $ic < count($ds_member["member"]["rows"]); $ic++) {
                         array_push($to_jid, $ds_member["member"]["rows"][$ic]["jid"]);
                     }
                 }
                 $state = $staffMgr->DeptAddFriend($this->container, $deptid, $fafa_jid, $nick_name, $ds_member["member"]["rows"]);
             }
         } catch (\Exception $e) {
             $success = false;
             $msg = "设置部门人员互为好友出错!";
             $this->container->get("logger")->err($e->getMessage());
             return array("success" => $success, "message" => $msg);
         }
     }
     $to_jid = $this->getStaffJid($deptid);
     if (count($to_jid) > 0) {
         //获取在线帐号
         Utils::findonlinejid($da, $to_jid);
         //向成员发送出席
         $message = array('deptid' => $deptid);
         $msg = json_encode(Utils::WrapMessage('dept_friend', $message, array()));
         Utils::sendImPresence($fafa_jid, $to_jid, "dept_friend", $msg, $this->container, "", "", false, '', '0');
     }
     return array("success" => $success, "message" => $msg);
 }
 public function sendPresenceCirlce($circleid, $caption = "circle_addmember", $msg, $buttons = "", $excludeLst = null)
 {
     $sql = "select c.fafa_jid,c.login_account from we_circle_staff a,we_circle b,we_staff c where b.circle_id=a.circle_id and a.login_account=c.login_account and b.circle_id=? and c.fafa_jid is not null";
     $da = $this->get("we_data_access");
     $ds = $da->GetData("ims", $sql, array((string) $circleid));
     $staffArr = array();
     $len = count($ds["ims"]["rows"]);
     for ($i = 0; $i < $len; $i++) {
         if (!empty($excludeLst) && in_array($ds["ims"]["rows"][$i]["login_account"], $excludeLst)) {
             continue;
         }
         $staffArr[] = $ds["ims"]["rows"][$i]["fafa_jid"];
     }
     $sender = $this->container->getParameter('im_sender');
     $staffArr = null;
     $onlinejid = Utils::findonlinejid($this->get("we_data_access_im"), $staffArr);
     $jidArr = array();
     $len = count($onlinejid);
     for ($i = 0; $i < $len; $i++) {
         $jidArr[] = $onlinejid[$i];
         if ($i > 0 && $i % 5000 == 0) {
             Utils::sendImPresence($sender, implode(",", $jidArr), $caption, $msg, $this->container, "", $buttons, false, Utils::$systemmessage_code);
             $jidArr = array();
         }
     }
     if (count($jidArr) > 0) {
         Utils::sendImPresence($sender, implode(",", $jidArr), $caption, $msg, $this->container, "", $buttons, false, Utils::$systemmessage_code);
     }
 }
Exemple #4
0
 public function service_sendjid($micro_jid, $onlyonline = false)
 {
     $jids = array();
     $sql = "select a.employeeid jid from im_microaccount_memebr a where a.microaccount=?;";
     try {
         $ds = $this->conn_im->GetData("table", $sql, array((string) $micro_jid));
         $count = $ds["table"]["recordcount"];
         if ($ds && $count > 0) {
             foreach ($ds["table"]["rows"] as $key => $value) {
                 $jids[] = $value["jid"];
             }
         } else {
             return array();
         }
     } catch (\Exception $e) {
         $this->logger->err($e->getMessage());
     }
     !$onlyonline ? Utils::resortjid($this->conn_im, $jids) : Utils::findonlinejid($this->conn_im, $jids);
     return $jids;
 }