private function SendImMessage($planid, $title, $tojid, $message) { if (!empty($planid)) { if (empty($message)) { //获取消息内容 if (!empty($planid)) { $ds = $this->GetPlan($planid); if (count($ds) > 0) { $message = json_encode($ds[0]); } else { return false; } } else { return false; } } if (!empty($this->user)) { if (empty($tojid)) { $sql = "select GROUP_CONCAT(staffid) as staffid from we_meeting_member where planid=? "; $paras = array((string) $planid); $ds = $this->conn->GetData("result", $sql, $paras); $tojid = $ds["result"]["rows"][0]["staffid"]; } $staffinfo = "{\"nick_name\":\"" . $this->user->nick_name . "\","; if (!empty($message)) { $message = str_replace("{", $staffinfo, $message); } //开始发送消息 Utils::sendImMessage($this->user->fafa_jid, $tojid, $title . "_meetingmember", $message, $this->container, "", "", false, Utils::$systemmessage_code); } } }
public function commit($parameters) { if (empty($parameters)) { $result = Utils::WrapResultError("无效的数据"); return $result; } $currUser = $parameters["user"]; if (empty($currUser)) { return Utils::WrapResultError("请登录后重试", ReturnCode::$NOTLOGIN); } try { //写业务表 $apply_id = SysSeq::GetSeqNextValue($this->conn, "we_app_notice", "id"); $sql = "insert into we_app_notice(id,title,content,author,publishdate,publishstaff,publisharea,isprivate,status,eno,appid)values(?,?,?,?,now(),?,?,?,'1',?,?)"; $this->conn->ExecSQL($sql, array((string) $apply_id, (string) $parameters["title"], (string) $parameters["content"], (string) $currUser->getUserName(), (string) $currUser->getUserName(), (string) $parameters["publisharea"], (string) $parameters["isprivate"], (string) $currUser->eno, (string) $parameters["appid"])); //消息内容 $message_body = array("appid" => $parameters["appid"], "title" => $parameters["title"], "id" => $apply_id); //获取发布范围内的人员jid $toDept = explode(",", $parameters["publisharea"]); $tojids = array(); $deptMgr = new Dept($this->conn, $this->conn_im, $this->container); for ($i = 0; $i < count($toDept); $i++) { //获取部门下的所有人员jid $staffjid = $deptMgr->getAllStaffJid($toDept[$i]); for ($i = 0; $i < count($staffjid); $i++) { $tojids[] = $staffjid[$i]["jid"]; if (count($tojids) >= 500) { //向审批人发送消息,一次性最多推送500个帐号 Utils::sendImMessage("", $tojids, "bus_app_msgpush", json_encode($message_body), $this->container, "", "", false, '', '0'); $tojids = array(); } } } if (count($tojids) > 0) { //向审批人发送消息 Utils::sendImMessage("", $tojids, "bus_app_msgpush", json_encode($message_body), $this->container, "", "", false, '', '0'); } $result = Utils::WrapResultOK(""); } catch (\Exception $e) { $this->logger->err($e); $result = Utils::WrapResultError($e->getMessage()); } return $result; }
public static function genAtMeWithMobile($da, $AConvContent, $conv_id, $user, $ctl = null) { try { if ($ctl == null) { return; } $matchs = $ctl->get("request")->get("atstaffs"); //手机端提交的是jid列表 if (empty($matchs)) { return; } $matchs = explode(",", $matchs); $imJids = array(); for ($i = 0; $i < count($matchs); $i++) { if (empty($matchs[$i]) || in_array($matchs[$i], $imJids)) { continue; } $imJids[] = $matchs[$i]; } //写入we_staff_at_me表 $sqls = array(); $paras = array(); for ($j = 0; $j < count($imJids); $j++) { $sql = "insert into we_staff_at_me select login_account,? from we_staff where fafa_jid=?;"; $para = array((string) $conv_id, (string) $imJids[$j]); array_push($sqls, $sql); array_push($paras, $para); } if (count($sqls) > 0) { try { $da->ExecSQLs($sqls, $paras); } catch (\Exception $e) { $ctl->get('logger')->err($e->getMessage()); } } /* $sqls = array(); $sql = "insert into we_staff_at_me(login_account, conv_id) select ?, ? from dual where not exists(select 1 from we_staff_at_me c where c.login_account=? and c.conv_id=?)"; $sqls[] = $sql; $sql = "delete a from we_staff_at_me a where a.login_account=? and (0+a.conv_id) < (select t1.conv_id from (select 0+b.conv_id as conv_id from we_staff_at_me b where b.login_account=? order by 0+b.conv_id desc limit 0, 100) as t1 order by t1.conv_id limit 0, 1)"; $sqls[] = $sql; $sql = "insert into we_notify(notify_type, msg_id, notify_staff) select '03', ?, ? from dual where exists(select 1 from we_convers_list wcl, we_circle_staff wcs where wcl.post_to_circle=wcs.circle_id and wcl.conv_id=? and wcs.login_account=?) and not exists(select 1 from we_notify c where c.notify_type='03' and c.msg_id=? and c.notify_staff=?)"; $sqls[] = $sql; $sql = "insert into we_staff_last_at(login_account, at_date, at_login_account) select ?, CURRENT_TIMESTAMP(), ? from dual where not exists(select 1 from we_staff_last_at c where c.login_account=? and c.at_login_account=?) "; $sqls[] = $sql; $sql = "delete a from we_staff_last_at a where a.login_account=? and a.at_date < (select min(t1.at_date) from (select b.at_date from we_staff_last_at b where b.login_account=? order by b.at_date desc limit 0, 10) as t1)"; $sqls[] = $sql; for ($i = 0; $i < count($matchs); $i++) { $login_account = $matchcount[$i]; if(empty($login_account)) continue; $staff = new \Justsy\BaseBundle\Management\Staff($da,null,$login_account,$ctl->get("logger"),$ctl); $staffdata = $staff->getInfo(); if(empty($staffdata)) continue; if(in_array($staffdata["fafa_jid"],$imJids)) continue; $imJids[] = $staffdata["fafa_jid"]; $all_params = array(); $params = array(); $params[] = (string)$login_account; $params[] = (string)$conv_id; $params[] = (string)$login_account; $params[] = (string)$conv_id; $all_params[] = $params; $params = array(); $params[] = (string)$login_account; $params[] = (string)$login_account; $all_params[] = $params; $params = array(); $params[] = (string)$conv_id; $params[] = (string)$login_account; $params[] = (string)$conv_id; $params[] = (string)$login_account; $params[] = (string)$conv_id; $params[] = (string)$login_account; $all_params[] = $params; $params = array(); $params[] = (string)$user->getUserName(); $params[] = (string)$login_account; $params[] = (string)$user->getUserName(); $params[] = (string)$login_account; $all_params[] = $params; $params = array(); $params[] = (string)$user->getUserName(); $params[] = (string)$user->getUserName(); $all_params[] = $params; $da->ExecSQLs($sqls, $all_params); }*/ if ($ctl != null && count($imJids) > 0) { try { //获取是否是在评论中@的 $get_sql = "select conv_root_id from we_convers_list where conv_id=?"; $ds = $da->GetData("get_sql", $get_sql, array((string) $conv_id)); if ($ds && count($ds["get_sql"]["rows"]) > 0) { $conv_id = $ds["get_sql"]["rows"][0]["conv_root_id"]; } //发送即时消息 $link = $ctl->get('router')->generate("JustsyBaseBundle_view_oneconv", array("conv_root_id" => $conv_id), true); $linkButtons = Utils::makeBusButton(array(array("code" => "action", "text" => "查看", "value" => "", "blank" => "true"))); $message = "您的好友在圈子中提到了你,快去看看吧!"; Utils::sendImMessage("", implode(",", $imJids), "atme", $message, $ctl, $link, $linkButtons, "", "", false, Utils::$atme_code); } catch (\Exception $e) { $ctl->get('logger')->err($e); } } } catch (\Exception $e) { throw $e; } }
public function deleteapply($paraObj) { $wfl = new \Justsy\BaseBundle\Business\WeWorkflow($this->container); $re = $wfl->removeWorkflowNode($paraObj); //消息通知 if ($re) { $message = "申请删除成功"; Utils::sendImMessage("", $paraObj["user"]->fafa_jid, "enterprise_deleteapply", $message, $this->container, "", "", true, '', '0'); //通知企业其他管理员 $endata = $this->getInfo($re["appid"]); $to = $endata["sys_manager"]; if (empty($to)) { $to = $endata["create_staff"]; } Utils::sendImMessage("", explode(";", $to), "enterprise_deleteapply", json_encode($re), $this->container, "", "", true, '', '0'); } return Utils::WrapResultOK($re); }
public function executeAction() { $request = $this->getRequest(); $login_account = $request->get("login_account"); $fafa_jid = $request->get("fafa_jid"); $type = $request->get("type"); $password = $request->get("password"); $my_jid = $this->get('security.context')->getToken()->getUser()->fafa_jid; $result = array(); $send_status = false; $msg = ""; //修改密码 if ($type == "adminLock") { $da = $this->get('we_data_access'); $da_im = $this->get('we_data_access_im'); $u_staff = new Staff($da, $da_im, $login_account, $this->get('logger')); $targetStaffInfo = $u_staff->getInfo(); $re = $u_staff->changepassword($login_account, $password, $this->get('security.encoder_factory')); if ($re) { $send_status = Utils::sendImMessage($my_jid, $fafa_jid, $type, $password, $this->container, "", "", false, Utils::$systemmessage_code, '0'); } else { $msg = "密码修改失败!"; } } else { $send_status = Utils::sendImMessage($my_jid, $fafa_jid, $type, $type, $this->container, "", "", false, Utils::$systemmessage_code, '0'); } $result = array("success" => $send_status, "msg" => $msg); $response = new Response(json_encode($result)); $response->headers->set('Content-Type', 'text/json'); return $response; }
private function sendMessage($jid, $message) { //发送共享通知 try { //发送即时消息 Utils::sendImMessage("", $jid, "文档共享通知", $message, $this->container, "", "", false, Utils::$systemmessage_code); } catch (\Exception $e) { $this->get('logger')->err($e); } }
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 removeapply($paraObj) { $wfl = new \Justsy\BaseBundle\Business\WeWorkflow($this->container); $re = $wfl->cancel($paraObj); //消息通知 if ($re) { $message = "申请取消成功"; Utils::sendImMessage("", $paraObj["user"]->fafa_jid, "bus_apply_remove", $message, $this->container, "", "", false, '', '0'); //通知所有的节点处理人 $dealstaffJids = isset($re["dealstaffs"]) ? $re["dealstaffs"] : ""; if (!empty($dealstaffJids)) { $to = explode(",", $dealstaffJids); Utils::sendImMessage("", $to, "bus_apply_remove", json_encode($re), $this->container, "", "", false, '', '0'); } } return Utils::WrapResultOK($re); }
public function revokeMsgAction() { //判断请求域。是wefafa或子域则不验证授权令牌 $isWeFaFaDomain = $this->checkWWWDomain(); $request = $this->get("request"); $da = $this->get("we_data_access"); if (!$isWeFaFaDomain) { $token = $this->checkAccessToken($request, $da); if (!$token) { return $this->responseJson($request, Utils::WrapResultError('参数Appid或Openid或Access_token未指定或无效.')); } } $openid = $request->get("openid"); $staffinfo = new \Justsy\BaseBundle\Management\Staff($da, $this->get("we_data_access_im"), $openid, $this->get("logger"), $this->container); $staffdata = $staffinfo->getInfo(); if (empty($staffdata)) { $result = Utils::WrapResultError("无效操作帐号"); return $this->responseJson($request, $result); } $to_jid = array(); $chatjid = $request->get('jid'); $to_jid[] = $chatjid; $groupid = $request->get('groupid'); $msgid = $request->get('msgid'); if (empty($chatjid) && empty($groupid)) { return $this->responseJson($request, Utils::WrapResultError('无效的撤回类型.')); } if (empty($msgid)) { return $this->responseJson($request, Utils::WrapResultError('无效的消息ID.')); } if (!empty($groupid)) { $groupMgr = new \Justsy\BaseBundle\Management\GroupMgr($da, $this->get("we_data_access_im"), $this->container); $to_jid = $groupMgr->getGroupMembersJidByIM($groupid); //群消息默认采用的发送时的iq ID。生成规则:Msgid =case QMsgid of []-> From#jid.luser++"-"++IQId; _-> QMsgid end, //生成消息ID $jid_user = explode('@', $staffdata['jid'])[0]; $msgid = $jid_user . '-' . $msgid; } $msgtype = !empty($chatjid) ? 'chat' : 'group'; $notice = array(); $message = json_encode(Utils::WrapMessage('message_revoke', array('type' => $msgtype, 'msgid' => $msgid, 'sender' => array('nick_name' => $staffdata['nick_name'], 'photo' => $staffdata['photo_path'], 'jid' => $staffdata['jid'], 'sendtime' => date("Y-m-d H:i:s", time()))), $notice)); $success = Utils::sendImMessage($staffdata['jid'], $to_jid, "message_revoke", $message, $this->container, "", "", false, Utils::$systemmessage_code); return $this->responseJson($request, Utils::WrapResultOK('')); }
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; }
public function setGroupMemberByDept($deptid) { try { //获取部门关联的群组 $sql = 'select groupid from im_group_memberarea where status=1 and objid=?'; $ds = $this->conn_im->GetData("table", $sql, array((string) $deptid)); if ($ds && $ds["table"]["recordcount"] > 0) { $imGroupJoinSql = 'insert into im_groupemployee(employeeid,groupid,grouprole,employeenick,lastreadid)values'; $values = array(); $newMember = array(); foreach ($ds["table"]["rows"] as $key => $value) { $groupid = $value['groupid']; //判断是否是该群组成员 $sql = 'SELECT a.loginname jid,a.employeename nick_name FROM im_employee a where a.deptid=? and not exists(select 1 from im_groupemployee where groupid=? and a.loginname=employeeid)'; $h1 = $this->conn_im->GetData("table2", $sql, array((string) $deptid, (string) $groupid)); foreach ($h1['table2']['rows'] as $key => $value) { $values[] = '(\'' . $value['jid'] . '\',\'' . $groupid . '\',\'normal\',\'' . $value['nick_name'] . '\',0)'; $newMember[] = $value['jid']; } } if (count($values) > 0) { $this->conn_im->ExecSQL($imGroupJoinSql . implode(',', $values), array()); } $groupmgr = new GroupMgr($this->conn, $this->conn_im, $this->container); foreach ($ds["table"]["rows"] as $key => $value) { $members = $groupmgr->getGroupMembersJidByIM($value['groupid']); $this->conn_im->ExecSQL('update im_group set max_number=(select count(1) from im_groupemployee where groupid=?) where groupid=?', array((string) $value['groupid'], (string) $value['groupid'])); $groupinfo = $groupmgr->GetByIM($value['groupid'], true); if (!empty($members)) { //通知这部分成员需要更新群信息 $noticeinfo = array(); $msg = Utils::WrapMessage("update_group", $groupinfo, $noticeinfo); Utils::sendImMessage('', implode(',', $members), "update_group", json_encode($msg), $this->container, "", "", false, ''); } if (count($newMember)) { //向新成员发送入群通知 $iconUrl = $groupinfo['logo']; $noticeinfo = Utils::WrapMessageNoticeinfo('你已自动进入群组 ' . $groupinfo['groupname'], '系统消息', null, $iconUrl); $msg = Utils::WrapMessage("join_group", $groupinfo, $noticeinfo); //添加成员成功发送消息 Utils::sendImMessage('', $newMember, "join_group", json_encode($msg), $this->container, "", "", false, ''); } } } } catch (\Exception $e) { $this->container->get("logger")->err($e); return false; } return true; }
public function service_revoke($parameter) { $msgid = $parameter["msgid"]; $login_account = $parameter["login_account"]; $user = $parameter["user"]; $send_jid = $user->fafa_jid; $staffMgr = new \Justsy\BaseBundle\Management\Staff($this->conn, $this->conn_im, $login_account, $this->container->get("logger"), $this->container); $microData = $staffMgr->getInfo(); $jid = $this->service_sendjid($microData["fafa_jid"]); $to_jid = implode(",", $jid); $notice = array(); $message = json_encode(Utils::WrapMessage('message_revoke', array('type' => 'serviceaccount', 'msgid' => $msgid), $notice)); $success = Utils::sendImMessage($send_jid, $to_jid, "message_revoke", $message, $this->container, "", "", false, Utils::$systemmessage_code); if ($success) { //删除推送消息记录 $sqls = array(); $paras = array(); $sql = "delete from we_micro_send_message where id=?;"; array_push($sqls, $sql); array_push($paras, array((string) $msgid)); $sql = "delete from we_micro_message where send_id=?;"; array_push($sqls, $sql); array_push($paras, array((string) $msgid)); try { $this->conn->ExecSQLS($sqls, $paras); $sql = 'delete from im_microaccount_msg where msgid=?'; $this->conn_im->ExecSQL($sql, array((string) $msgid)); } catch (\Exception $e) { $success = false; $this->logger->err($e->getMessage()); return Utils::WrapResultError($e->getMessage()); } } return Utils::WrapResultOK(""); }
public function bothAddFriend($paraObj) { $firendaccount = $paraObj['firendaccount']; $datarow = $this->getStaffInfo($firendaccount); if (empty($datarow)) { return Utils::WrapResultError('好友帐号无效'); } $me = $this->getInfo(); $jid = $me["fafa_jid"]; $nick_name = $me["nick_name"]; $att_jid = $datarow['fafa_jid']; $att_nick_name = $datarow['nick_name']; $firend_login_account = $datarow['login_account']; $sqls = array(); $paras = array(); $sqls[] = 'delete from rosterusers where username=? and jid=? '; $paras[] = array((string) $jid, (string) $att_jid); $sqls[] = 'delete from rosterusers where username=? and jid=? '; $paras[] = array((string) $att_jid, (string) $jid); $sql = "insert into rosterusers (username, jid, nick, subscription, ask, server, type, created_at) values (?, ?, ?, 'B','N','N','item',now())"; $sqls[] = $sql; $paras[] = array((string) $jid, (string) $att_jid, (string) $att_nick_name); $sqls[] = $sql; $paras[] = array((string) $att_jid, (string) $jid, (string) $nick_name); try { try { $this->conn_im->ExecSQLs($sqls, $paras); //发送即时消息 $notice = array(); // Utils::WrapMessageNoticeinfo('你已添加'.$att_nick_name.'为好友。','',null,''); $senddata = array('jid' => $me['jid'], 'photo_path' => $me['photo_path'], 'nick_name' => $me['nick_name'], 'msg' => '你已添加' . $me['nick_name'] . '为好友,可以开始聊天了。'); $message = json_encode(Utils::WrapMessage('friend_both', $senddata, $notice)); Utils::sendImMessage($jid, $att_jid, "friend_both", $message, $this->container, "", "", false, Utils::$systemmessage_code); $notice = array(); //Utils::WrapMessageNoticeinfo('你已添加'.$nick_name.'为好友。','',null,''); $senddata = array('jid' => $datarow['jid'], 'photo_path' => $datarow['photo_path'], 'nick_name' => $datarow['nick_name'], 'msg' => '你已添加' . $att_nick_name . '为好友,可以开始聊天了。'); $message = json_encode(Utils::WrapMessage('friend_both', $senddata, $notice)); Utils::sendImMessage($att_jid, $jid, "friend_both", $message, $this->container, "", "", false, Utils::$systemmessage_code); } catch (\Exception $e) { } } catch (\Exception $e) { $this->logger->err($e); } //不处理已经是好友时,又添加为好友的异常。这时数据库会报主键重复异常 return Utils::WrapResultOK(array('jid' => $att_jid, 'nick_name' => $att_nick_name, 'photo_path' => $datarow['photo_path'])); }
public function UserAgreeAction() { $da = $this->get('we_data_access'); $da_im = $this->get('we_data_access_im'); $logger = $this->get('logger'); $request = $this->getRequest(); $apply_id = $request->get('apply_id'); $re = $request->get('re'); $user = $this->get('security.context')->getToken()->getUser(); $r = array('s' => 1, 'm' => ''); try { //验证是否能审核 $sql = "select result,is_valid from we_apply where id=?"; $params = array($apply_id); $ds = $da->Getdata('info', $sql, $params); if ($ds['info']['recordcount'] == 0) { $r = array('s' => 0, 'm' => '该条审核记录已失效'); } else { if ($ds['info']['rows'][0]['is_valid'] == '0') { $r = array('s' => 0, 'm' => '你已经审核过了!'); } } if ($r['s'] == '1') { //同意人数 $sql = "select a.content,a.account,b.openid,b.fafa_jid from we_apply a left join we_staff b on b.login_account=a.account where a.id=?"; $params = array($apply_id); $ds = $da->Getdata('content', $sql, $params); if ($ds['content']['recordcount'] > 0) { $content = $ds['content']['rows'][0]['content']; $account = $ds['content']['rows'][0]['account']; $acc_openid = $ds['content']['rows'][0]['openid']; $acc_jid = $ds['content']['rows'][0]['fafa_jid']; $num = (int) $content; $sql2[] = "select 1 from we_apply where account=? and recv_type='p' and result='1'"; $sql2[] = "select distinct recv_id from we_apply where account=? and recv_type='p' and result='0'"; $sql2[] = "select distinct recv_id from we_apply where account=? and recv_type='p'"; $params2[] = array($account); $params2[] = array($account); $params2[] = array($account); $ds = $da->GetDatas(array('agreenum', 'confictnum', 'allnum'), $sql2, $params2); $n = $ds['agreenum']['recordcount']; $m = $ds['confictnum']['recordcount']; $allnum = $ds['allnum']['recordcount']; if ($re == '1') { $n++; } if ($re == '0') { $m++; } //更新审核结果 $sql1[] = "update we_apply set result=?,is_valid='0' where id=? and (result is null or result='') and is_valid='1'"; $params1[] = array($re, $apply_id); if ($num <= $n) { $sql1[] = "update we_staff set auth_level=? where login_account=?"; $params1[] = array($user->eno_level, $account); if ($user->edomain == $user->eno) { $sql = "select 1 from we_public_domain where LOCATE(domain_name,?)=0 and not exists(select 1 from we_enterprise where edomain=?)"; $params = array($account, $this->getSubDomain($account)); $ds = $da->Getdata('acc', $sql, $params); if ($ds['acc']['recordcount'] > 0) { $sql1[] = "update we_enterprise set edomain=? where eno=?"; $params1[] = array($this->getSubDomain($account), $user->eno); $sql1[] = "update we_enterprise_stored set eno_mail=? where enoname=?"; $params1[] = array($account, $user->ename); $sql1[] = "update we_circle set network_domain=? where enterprise_no=?"; $params1[] = array($this->getSubDomain($account), $user->eno); } } //写入消息 $msg_id = SysSeq::GetSeqNextValue($da, "we_message", "msg_id"); $msg = "您已通过身份认证,现在就可以正常使用Wefafa平台了!"; $sql1[] = "insert into we_message (msg_id,sender,recver,title,content,send_date) values(?,?,?,?,?,now())"; $params1[] = array($msg_id, '*****@*****.**', $account, '用户认证协助审核', $msg); } if ($allnum - $m < $num) { //写入消息 $msg_id = SysSeq::GetSeqNextValue($da, "we_message", "msg_id"); $msg = "您的身份认证申请未通过审核。"; $sql1[] = "insert into we_message (msg_id,sender,recver,title,content,send_date) values(?,?,?,?,?,now())"; $params1[] = array($msg_id, '*****@*****.**', $account, '用户认证协助审核', $msg); } if (!$da->ExecSQLs($sql1, $params1)) { $r = array('s' => 0, 'm' => '系统错误'); } if ($r['s'] == '1') { //通知申请人审核结果 //Utils::sendImMessage($user->openid,$acc_openid,"用户身份认证",$user->nick_name.($re=='1'?"通过了您的加入请求。":"拒绝了您的加入请求。"),$this->container,"","",true,Utils::$systemmessage_code); if ($num <= $n) { //同步权限到Rbac $staffRole = new StaffRole($da, $da_im, $this->get('logger')); /* if($user->vip_level!='0') $staffRole->UpdateStaffRoleByCode($account,(Identify::$SIdent).($user->vip_level),(Identify::$BIdent).($user->vip_level),$user->eno); else $staffRole->UpdateStaffRoleByCode($account,(Identify::$SIdent).($user->vip_level),(Identify::$MIdent).($user->vip_level),$user->eno); */ $staffRole->UpdateStaffRoleByCode($account, Identify::$SIdent . $user->vip_level, $user->eno_level . $user->vip_level, $user->eno); //通知申请人权限已通过 Utils::sendImMessage('', $acc_openid, "用户身份认证", "您的身份认证申请已被审核通过。", $this->container, "", "", true, Utils::$systemmessage_code); //发送出席 Utils::sendImPresence('', $acc_jid, "用户身份认证", "您的身份认证申请已被审核通过。", $this->container, "", "", false, Utils::$eno_identify_auth); } else { if ($allnum - $m < $num) { //通知申请人权限已通过 Utils::sendImMessage('', $acc_openid, "用户身份认证", "您的身份认证申请未通过审核。", $this->container, "", "", true, Utils::$systemmessage_code); } } } } } } catch (\Exception $e) { $this->get('logger')->err($e); $r = array('s' => 0, 'm' => '审核出现错误'); } $desc = ""; $title = ""; if ($r['s'] == '0') { $title = "提交失败"; $desc = $r['m']; } else { $title = "提交成功"; $desc = "您的审核结果已经提交成功,谢谢你的配合。"; } $home = $this->container->getParameter('open_api_url'); return $this->render("JustsyBaseBundle:IdentifyAuth:verify_success.html.twig", array('desc' => $desc, 'home' => $home, 'title' => $title)); }
//判断改圈子成员数是否已满 if ($ec->IsBeyondGroupMembers($group_id)) { return new Response("-3"); } //para 群组ID,申请人帐号 DES加密 $para = DES::encrypt($group_id . "," . $user->getUserName() . "," . $network_domain); $activeurl = $this->generateUrl("JustsyBaseBundle_group_agreejoin", array('para' => $para), true); $txt = $this->renderView("JustsyBaseBundle:Group:msg_apply_join.html.twig", array("ename" => $user->ename, "nick_name" => $user->nick_name, "account" => DES::encrypt($user->getUsername()), "activeurl" => $activeurl, "group_name" => $group_name)); //发送站内消息 $msgId = SysSeq::GetSeqNextValue($da, "we_message", "msg_id"); $sql = "insert into we_message(msg_id,sender,recver,send_date,title,content)values(?,?,?,now(),?,?)"; $para = array((int) $msgId, (string) $user->getUserName(), (string) $create_staff, "申请加入群组", $txt); $da->ExecSQL($sql, $para); //发送即时消息 $im_sender = $this->container->getParameter('im_sender'); $fafa_jid = Utils::getJidByAccount($da, $create_staff); $message = Utils::makeHTMLElementTag('employee', $user->fafa_jid, $user->nick_name) . "申请加入您的群组【" . $group_name . "】"; $buttons = array(); $buttons[] = array("text" => "同意", "code" => "agree", "value" => "1"); $buttons[] = array("text" => "拒绝", "code" => "agree", "value" => "0"); Utils::sendImMessage($user->fafa_jid, $fafa_jid, "申请加入群组", $message, $this->container, $activeurl . "?apply_user="******"1"); return new Response("1"); } //同意加入群组 public function agreeJoinGroupAction($para) { $paraArr = explode(",", trim(DES::decrypt($para))); $da = $this->get("we_data_access"); $da_im = $this->get("we_data_access_im"); //检查帐号是否存在 $sql = "select fafa_jid,nick_name from we_staff where login_account=?"; $ds = $da->GetData('we_staff', $sql, array((string) $paraArr[1])); if (!$ds || $ds['we_staff']['recordcount'] == 0) { return $this->render('JustsyBaseBundle:Circle:join_err.html.twig', array('error' => '申请人帐号不存在!')); } $jid = $ds['we_staff']['rows'][0]['fafa_jid']; $nick_name = $ds['we_staff']['rows'][0]['nick_name']; $sql = "select count(1) as cnt from we_group_staff where group_id=? and login_account=?"; $ds = $da->GetData('we_group_staff', $sql, array((string) $paraArr[0], (string) $paraArr[1])); if ($ds && $ds['we_group_staff']['rows'][0]['cnt'] > 0) { return $this->render('JustsyBaseBundle:Circle:join_err.html.twig', array('error' => '申请人已加入该群组!')); } else { $sql = "select fafa_groupid,group_name from we_groups where group_id=?"; $ds = $da->GetData('we_groups', $sql, array((string) $paraArr[0])); $fafa_groupid = $ds && $ds['we_groups']['recordcount'] > 0 ? $ds['we_groups']['rows'][0]['fafa_groupid'] : ''; $group_name = $ds['we_groups']['rows'][0]['group_name']; $request = $this->get("request"); //判断是同意还是拒绝 $agree = $request->get("agree"); if ($agree == "0") { $apply_user = $request->get("apply_user"); $im_sender = $this->container->getParameter('im_sender'); $message = "【" . $group_name . '】管理员拒绝了您的群申请!'; Utils::sendImMessage($im_sender, $apply_user, "群消息", $message, $this->container, "", "", true, Utils::$systemmessage_code); return $this->render('JustsyBaseBundle::Error:success.html.twig'); } $sql = "insert into im_groupemployee (employeeid, groupid, employeenick, grouprole) values (?,?,?,'normal')";
public function saveGroupAction($network_domain) { try { $DataAccess = $this->get('we_data_access'); $group_id = $this->getRequest()->get('group_id'); $circle_id = $this->getRequest()->get('circle_id'); $circle_name = $this->getRequest()->get('circle_name'); $group_name = $this->getRequest()->get('group_name'); $group_desc = $this->getRequest()->get('group_desc'); //$group_photo_path =$this->getRequest()->get('group_photo_path'); $join_method = $this->getRequest()->get('join_method'); $create_date = $this->getRequest()->get('create_date'); $fafa_groupid = $this->getRequest()->get('fafa_groupid'); $group_class = $this->getRequest()->get('classify'); $session = $this->get('session'); $group_photo_path = $session->get('group_photo_path'); $group_photo_path_big = $session->get('avatar_big'); $group_photo_path_small = $session->get('avatar_small'); if (empty($group_id) == true || empty($group_name) == true) { return $this->res('{"success":0}', 'json'); } //$dm=$this->get('doctrine.odm.mongodb.document_manager'); /* if(!empty($group_photo_path)) { //$group_photo_path =$this->saveFile($group_photo_path,$dm); // $group_photo_path_big =$this->saveFile($group_photo_path_big,$dm); unlink($group_photo_path_big); // $group_photo_path_small =$this->saveFile($group_photo_path_small,$dm); unlink($group_photo_path_small); $session->remove('avatar_middle'); $session->remove('avatar_big'); $session->remove('avatar_small'); $sql='select group_photo_path from we_groups where group_id=?'; $dataset=$DataAccess->GetData('we_groups',$sql,array((string)$group_id)); if($dataset['we_groups']['recordcount']>0) { $this->deleteFile($dataset['we_groups']["rows"][0]["group_photo_path"],$dm); } } */ $sql = 'select fafa_groupid from we_groups where group_id=?'; $dataset = $DataAccess->GetData('we_groups', $sql, array((string) $group_id)); if ($dataset != null && count($dataset['we_groups']['rows']) > 0) { if (empty($group_photo_path)) { $sql = 'update we_groups set group_name=?,group_desc=?,group_class=?,join_method=? where group_id=?'; $para = array((string) $group_name, (string) $group_desc, (string) $group_class, (string) $join_method, (string) $group_id); } else { $sql = 'update we_groups set group_name=?,group_desc=?,group_class=?,group_photo_path=?,join_method=? where group_id=?'; $para = array((string) $group_name, (string) $group_desc, (string) $group_class, (string) $group_photo_path, (string) $join_method, (string) $group_id); } $dataexec = $DataAccess->ExecSQL($sql, $para); $path = empty($group_photo_path) ? "" : $this->ifPicNull($group_photo_path); //取群成员 $sql = "SELECT b.fafa_jid FROM we_group_staff a LEFT JOIN we_staff b ON a.login_account=b.login_account WHERE a.group_id=? AND b.fafa_jid IS NOT NULL"; $para = array($group_id); $data = $DataAccess->GetData('dt', $sql, $para); //var_dump($sql,$para); if ($data != null && count($data['dt']['rows']) > 0) { //修改头像之后需要发出席消息。让各端及时修改头像 $user = $this->get('security.context')->getToken()->getUser(); $fafa_jid = $user->fafa_jid; $tojid = array(); for ($i = 0; $i < count($data['dt']['rows']); $i++) { array_push($tojid, $data['dt']['rows'][$i]['fafa_jid']); } $groupjid = $dataset['we_groups']["rows"][0]["fafa_groupid"]; $message = json_encode(array('group_id' => $group_id, 'logo_path' => $group_photo_path, 'jid' => $groupjid, 'group_name' => $group_name)); //group_id,group_photo_path,fafa_groupid,group_name //var_dump($groupjid,$group_id,$tojid,$fafa_jid); Utils::sendImMessage($fafa_jid, implode(",", $tojid), "group_info_change", $message, $this->container, "", "", false, Utils::$systemmessage_code); } return $this->res('{"success":1,"logo_path":"' . $path . '"}', 'json'); } return $this->res('{"success":1,"logo_path":""}', 'json'); } catch (\Exception $e) { $this->get('logger')->err($e); return $this->res('{"success":0}', 'json'); } }
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 changeStaffDeptAction($network_domain) { $res = $this->get("request"); $account = trim($res->get("staff")); $deptid = trim($res->get("deptid")); if (empty($account) || empty($deptid)) { $response = new Response(json_encode(array("s" => 0, "msg" => "人员帐号或部门不能为空"))); $response->headers->set('Content-Type', 'text/json'); return $response; } try { $da = $this->get("we_data_access"); $da_im = $this->get('we_data_access_im'); $accountList = explode(",", $account); $user = $this->get('security.context')->getToken()->getUser(); $deptmgr = new \Justsy\BaseBundle\Management\Dept($da, $da_im); $deptInfo = $deptmgr->getinfo($deptid); if ($deptInfo != null) { for ($i = 0; $i < count($accountList); $i++) { $staffmgr = new \Justsy\BaseBundle\Management\Staff($da, $da_im, $accountList[$i]); $result_jid = $staffmgr->moveToDept($deptid, $deptInfo["fafa_deptid"]); //如果是其他人员更新了自己的部门,则向被移动的人员发条消息 if ($user->getUsername() != $accountList[$i]) { try { //发送即时消息 $message = "你的所属部门已变更为【" . $deptInfo["dept_name"] . "】"; Utils::sendImMessage($user->fafa_jid, $result_jid, "资料变更", $message, $this->container, "", "", false, Utils::$systemmessage_code); } catch (\Exception $e) { $this->get('logger')->err($e); } } } $response = new Response(json_encode(array("s" => 1, "msg" => ""))); $response->headers->set('Content-Type', 'text/json'); return $response; } else { $response = new Response(json_encode(array("s" => 0, "msg" => "部门编号无效"))); $response->headers->set('Content-Type', 'text/json'); return $response; } } catch (\Exception $e) { $this->get("logger")->err($e); $response = new Response(json_encode(array("s" => 0, "msg" => "数据操作失败"))); $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(); $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 delDefaultGroup($parameter) { $groupid = $parameter["groupid"]; $da_im = $this->conn_im; $sqls = array(); $paras = array(); $to_jid = ""; //删除群组 $sql = "select logo from im_group where groupid=?"; try { $ds = $da_im->GetData("table", $sql, array((string) $groupid)); if ($ds && $ds["table"]["recordcount"] > 0) { $fileid = $ds["table"]["rows"][0]["logo"]; if (!empty($fileid)) { $this->removeFile($fileid); } } } catch (\Exception $e) { $this->logger->err($e->getMessage()); } $sql = "delete from im_group where groupid=?"; array_push($sqls, $sql); array_push($paras, array((string) $groupid)); //删除群成员(删除群成员表时取群用户jid以发送出席) $groupObj = $this->getGroupMemberJid($groupid); $to_jid = $groupObj["member_jid"]; $groupname = $groupObj["groupname"]; $sql = "delete from im_groupemployee where groupid=?;"; array_push($sqls, $sql); array_push($paras, array((string) $groupid)); //删除群组对应允许加入的部门表 $sql = "delete from im_group_memberarea where groupid=?;"; array_push($sqls, $sql); array_push($paras, array((string) $groupid)); $sql = "delete from im_group_msg where groupid=?;"; array_push($sqls, $sql); array_push($paras, array((string) $groupid)); /* $sql = "delete from im_groupemployee_covert where groupid=?;"; array_push($sqls,$sql); array_push($paras,array((string)$groupid));*/ $success = true; $msg = ""; try { $da_im->ExecSQLs($sqls, $paras); //解散群组成功后发送出席 $userinfo = $parameter["user"]; $send_jid = $userinfo->fafa_jid; $title = "remove_group"; $message = $userinfo->nick_name; $message = '管理员解散群组了 ' . $groupname; $noticeinfo = Utils::WrapMessageNoticeinfo($message, $userinfo->nick_name, null, null); $msg = Utils::WrapMessage($title, array('groupid' => $groupid), $noticeinfo); Utils::sendImMessage($send_jid, $to_jid, $title, json_encode($msg), $this->container, "", "", false, Utils::$systemmessage_code); } catch (\Exception $e) { $this->logger->err($e->getMessage()); Utils::WrapResultError($e->getMessage()); } return Utils::WrapResultOK(""); }
public function reSendInvitationAction() { $im_sender = $this->container->getParameter('im_sender'); $da = $this->get('we_data_access'); $user = $this->get('security.context')->getToken()->getUser(); $eno = $this->get("request")->request->get("eno"); $invite_recv_email = $this->get("request")->request->get("invite_recv_email"); $invInfo = array('inv_send_acc' => $user->getUsername(), 'inv_recv_acc' => $invite_recv_email, 'eno' => $eno, 'inv_rela' => '', 'inv_title' => '', 'inv_content' => '', 'active_addr' => ''); //被邀请帐号是否存在,存在则update we_invite,不存在 取we_invite的数据,重发邮件 $sql = "select fafa_jid from we_staff where login_account=?"; $ds = $da->GetData("we_staff", $sql, array((string) $invite_recv_email)); if ($ds && $ds['we_staff']['recordcount'] > 0) { InviteController::saveWeInvInfo($da, $invInfo); //发送即时消息 $fafa_jid = $ds['we_staff']['rows'][0]['fafa_jid']; $message = $user->nick_name . "邀请您加入圈子,请登录微发发进行确认。"; Utils::sendImMessage($im_sender, $fafa_jid, "邀请加入圈子", $message, $this->container, "", "", false, Utils::$systemmessage_code); } else { $sql = "select inv_title,inv_content from we_invite where invite_recv_email=? and invite_send_email=? and eno=?"; $ds = $da->GetData("we_invite", $sql, array((string) $invite_recv_email, (string) $user->getUsername(), (string) $eno)); if ($ds && $ds['we_invite']['recordcount'] > 0) { Utils::saveMail($da, $user->getUsername(), $invite_recv_email, $ds['we_invite']['rows'][0]['inv_title'], $ds['we_invite']['rows'][0]['inv_content'], $eno); //Utils::sendMail($this->get('mailer'),$ds['we_invite']['rows'][0]['inv_title'],$this->container->getParameter('mailer_user'),null,$invite_recv_email,$ds['we_invite']['rows'][0]['inv_content']); } InviteController::saveWeInvInfo($da, $invInfo); } return new Response("1"); }
public function updateStaffAction() { $da = $this->get("we_data_access"); $da_im = $this->get('we_data_access_im'); $request = $this->getRequest(); $state = $request->get("state"); $im_deptid = $request->get("dept_id"); //将im的部门id转化为sns里的部门id $deptInfo = $this->getDeptInfo($im_deptid); $sns_deptid = $deptInfo["deptid"]; $login_account = $request->get("login_account"); $e_mail = $request->get("e_mail"); $nick_name = $request->get("nick_name"); $password = $request->get("password"); $sex = $request->get("sex"); $duty = $request->get("duty"); $duty = empty($duty) ? null : $duty; $mobile = $request->get("mobile"); $mobile = empty($mobile) ? null : $mobile; $success = true; $msg = ""; //判断手机号正误 if (!empty($mobile)) { if (!Utils::validateMobile($mobile)) { $result = array("success" => false, "msg" => "手机账号格式错误!"); $response = new Response(json_encode($result)); $response->headers->set('Content-Type', 'text/json'); return $response; } else { $sql = ""; $para = array(); if ($state == "add") { $sql = "select count(*) number from we_staff where mobile_bind=?;"; array_push($para, (string) $mobile); } else { $sql = "select count(*) number from we_staff where mobile_bind=? and login_account!=?;"; array_push($para, (string) $mobile, $login_account); } try { $ds = $da->GetData("table", $sql, $para); if ($ds && $ds["table"]["recordcount"] > 0) { if ((int) $ds["table"]["rows"][0]["number"] > 0) { $result = array("success" => false, "msg" => "已存在该手机号码!"); $response = new Response(json_encode($result)); $response->headers->set('Content-Type', 'text/json'); return $response; } } } catch (\Exception $e) { $this->get("logger")->err($e->getMessage()); } } } $user = $this->get('security.context')->getToken()->getUser(); $deptMgr = new \Justsy\BaseBundle\Management\Dept($da, $da_im, $this->container); $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $da_im, $login_account, $this->container->get("logger"), $this->container); if ($state == "add") { if ($staffMgr->checkUser($mobile)) { $result = array("success" => false, "msg" => "用户账号已存在,请重新输入!"); $response = new Response(json_encode($result)); $response->headers->set('Content-Type', 'text/json'); return $response; } //获得ldap_uid $login_array = explode("@", $login_account); if (count($login_array) < 2) { continue; } $ldap_uid = $login_array[0]; //注册用户账号 $register = new \Justsy\BaseBundle\Controller\ActiveController(); $register->setContainer($this->container); $parameter = array("account" => $login_account, "realName" => $nick_name, "passWord" => $password, "ldap_uid" => $ldap_uid, "eno" => $user->eno, "ename" => $user->ename, "isNew" => '0', "mailtype" => "1", "import" => '1', "isSendMessage" => "N", "mobile" => $mobile, "duty" => $duty, "deptid" => $sns_deptid, "mutual" => "Y"); $result = $register->doSave($parameter); if ($result["returncode"] == "0000") { $staffdata = $staffMgr->getInfo(); //成功后统计人员 $sql = "call dept_emp_stat(?)"; $da_im->ExecSQL($sql, array((string) $staffdata["fafa_jid"])); //自动关注服务号 $servicerMgr = new \Justsy\BaseBundle\Management\Service($this->container); $parameter = array("eno" => $user->eno, "deptid" => $im_deptid, "login_account" => $login_account); $servicerMgr->atten_service($parameter); $revJids = $staffMgr->getFriendAndColleagueJid(); Utils::sendImMessage($user->fafa_jid, implode(",", $revJids), "newstaff", json_encode($staffMgr->getinfo()), $this->container, "", "", false, Utils::$systemmessage_code); } else { $success = false; $msg = "添加用户账号失败:" . $result["msg"]; } $result = array("success" => $success, "msg" => $msg); $response = new Response(json_encode($result)); $response->headers->set('Content-Type', 'text/json'); return $response; } else { $staffinfo = $staffMgr->getInfo(); $deptinfo = $deptMgr->getinfo($staffinfo["dept_id"]); //判断是否更改了性别 if ($sex == $staffinfo["sex_id"]) { $sex = null; } //判断是否更改了职务 if ($duty == $staffinfo["duty"]) { $duty = null; } //判断是否更改了姓名 if ($nick_name == $staffinfo["nick_name"]) { $nick_name = null; } //判断是否更新了部门 if ($sns_deptid == $deptinfo["dept_id"]) { $sns_deptid = null; } //判断是否更新了手机 if ($mobile == $staffinfo["mobile_bind"]) { $mobile = null; } $uResult = $staffMgr->checkAndUpdate($nick_name, $mobile, $sns_deptid, $duty, null, $sex, null, $e_mail); $u_staff = null; $factory = null; //判断是否修改了密码 if (!empty($password)) { $u_staff = new Staff($da, $da_im, $login_account, $this->get('logger'), $this->container); $factory = $this->get('security.encoder_factory'); $targetStaffInfo = $u_staff->getInfo(); $re = $u_staff->changepassword($targetStaffInfo["login_account"], $password, $factory); if ($re) { //给自己发送一个staff-changepasswod的出席,通知在线客户端密码发生修改,需要新密码重新登录 Utils::sendImPresence($user->fafa_jid, $targetStaffInfo["fafa_jid"], "staff-changepasswod", "staff-changepasswod", $this->container, "", "", false, Utils::$systemmessage_code); } } //判断是否修改了帐号 if ($e_mail != $login_account) { //判断邮件是否存在 if (empty($u_staff)) { $u_staff = new Staff($da, $da_im, $login_account, $this->get('logger'), $this->container); } if (empty($factory)) { $factory = $this->get('security.encoder_factory'); } $u_staff->changeLoginAccount($e_mail, $factory); } try { $revJids = $staffMgr->getFriendAndColleagueJid(); if ($uResult && !empty($sns_deptid)) { //部门变更时,需要通知手机端更新原部门和新部门数据 Utils::sendImMessage("", implode(",", $revJids), "staff-changedept", json_encode($deptinfo), $this->container, "", "", false, Utils::$systemmessage_code); Utils::sendImMessage("", implode(",", $revJids), "staff-changedept", json_encode($deptMgr->getinfo($sns_deptid)), $this->container, "", "", false, Utils::$systemmessage_code); $old_fafa_deptid = $deptinfo["fafa_deptid"]; $fafa_jid = $staffinfo["fafa_jid"]; //取消关注服务号 $servicerMgr = new \Justsy\BaseBundle\Management\Service($this->container); $parameter = array("eno" => $user->eno, "deptid" => $old_fafa_deptid, "login_account" => $login_account); $servicerMgr->cancel_atten($parameter); //自动关注服务号 $parameter = array("eno" => $user->eno, "deptid" => $im_deptid, "login_account" => $login_account); $servicerMgr->atten_service($parameter); } } catch (\Exception $e) { $this->get("logger")->err($e->getMessage()); $success = false; $msg = "修改人员信息失败!"; } } $result = array("success" => $success, "msg" => $msg); $response = new Response(json_encode($result)); $response->headers->set('Content-Type', 'text/json'); return $response; }
public function refuseJoinAction() { $para = $this->getRequest()->get('para'); $paraArr = explode(",", trim(DES::decrypt($para))); $da = $this->get("we_data_access"); $user = $this->get('security.context')->getToken()->getUser(); //检查帐号是否存在 $sql = "select eno from we_staff where login_account=?"; $ds = $da->GetData('we_staff', $sql, array((string) $paraArr[1])); if (!$ds || $ds['we_staff']['recordcount'] == 0) { return new Response("0"); } $eno = $ds['we_staff']['rows'][0]['eno']; $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) { return new Response("0"); } else { $txt = "您加入圈子【" . $paraArr[3] . "】的请求被拒绝了!"; $msgId = SysSeq::GetSeqNextValue($da, "we_message", "msg_id"); $sql = "insert into we_message(msg_id,sender,recver,send_date,title,content)values(?,?,?,now(),?,?)"; $param = array((int) $msgId, (string) $user->getUserName(), (string) $paraArr[1], "申请加入圈子被拒绝", $txt); $da->ExecSQL($sql, $param); $apply = new \Justsy\BaseBundle\Management\ApplyMgr($da, null); $apply->SetCircleApplyInvalid($paraArr[1], $paraArr[0]); //发送即时消息通知申请人 $im_sender = $this->container->getParameter('im_sender'); $message = $txt; Utils::sendImMessage($im_sender, $paraArr[1], "圈子消息", $message, $this->container, "", "", true, Utils::$systemmessage_code); return new Response("1"); } }