public function removeMonitorAction() { $da = $this->get("we_data_access"); $da_im = $this->get('we_data_access_im'); $request = $this->getRequest(); //访问权限校验 $api = new ApiController(); $api->setContainer($this->container); $isWeFaFaDomain = $api->checkWWWDomain(); if (!$isWeFaFaDomain) { $token = $api->checkAccessToken($request, $da); if (!$token) { $re = array("returncode" => "9999"); $re["code"] = "err0105"; $re["msg"] = "参数Appid或Openid或Access_token未指定或无效."; return $this->responseJson($request, $re); } } $openid = $request->get("openid"); $staffinfo = new Staff($da, $da_im, $openid, $this->get("logger"), $this->container); $staffdata = $staffinfo->getInfo(); if (empty($staffdata)) { $result = Utils::WrapResultError("无效操作帐号"); return $this->responseJson($request, $result); } $to = $request->get("to"); if (empty($to)) { $result = Utils::WrapResultError("无效的帐号"); return $this->responseJson($request, $result); } $to = $staffinfo->getStaffInfo($to); if (empty($to)) { $result = Utils::WrapResultError("无效的帐号"); return $this->responseJson($request, $result); } try { $sql = 'delete from t_module_location_monitor where staff=?'; $da->ExecSQL($sql, array((string) $to['jid'])); $sql = 'delete from t_module_location where staff=?'; $da->ExecSQL($sql, array((string) $to['login_account'])); } catch (\Exception $e) { } $senddata = array('opt' => 'stop'); $msg = Utils::WrapMessage('sendlocation', $senddata, array()); //$msgxml = Utils::WrapMessageXml($this->module["jid"],$msg,'sendlocation-id'); $api->sendMsg("", $to['jid'], 'sendlocation', json_encode($msg)); return $this->responseJson($request, Utils::WrapResultOk("")); }
public function SendMsgAction() { $conn = $this->get("we_data_access"); $conn_im = $this->get("we_data_access_im"); $request = $this->getRequest(); $currUser = $this->get('security.context')->getToken(); if ($currUser == null) { $openid = $request->get('openid'); $staffinfo = new \Justsy\BaseBundle\Management\Staff($conn, $conn_im, $openid, $this->get("logger"), $this->container); $staffdata = $staffinfo->getInfo(); if (empty($staffdata)) { $re = array('returncode' => '9999', 'msg' => '无效的操作人'); return $this->responseJson(json_encode($re)); } $user = $staffinfo->getSessionUser($staffdata); } else { $user = $this->get('security.context')->getToken()->getUser(); } //公众号相关参数 $microObj = $request->get('microObj'); $microName = $microObj["microName"]; //接收对象(公众号名称) $microNumber = $microObj["microNumber"]; //接收对象(公众号帐号) $microOpenid = $microObj["microOpenid"]; //接收对象(公众号Openid) $microType = $microObj["microType"]; //接收对象(公众号类型,内部或外部) $microUse = $microObj["microUse"]; //接收对象(是公众号还是微应用) $microGroupId = ""; //$microObj["microGroupId"]; //接收对象(公众号分组主键) //消息参数 $msgType = ""; //消息类型 $msgContent = ""; //消息内容(XML拼接Json字符串,包括标题,图片,摘要等) $msgContentHtml = ""; //消息内容(HTML内容) $msgTitle = ""; //消息标题 $imgUrl = ""; //图片地址 $formid = ""; //表单编号。推送表单时设置 $webpage_url = ""; //网页地址。推送网页地址时设置 $msgObj_list = $request->get('msgObj'); //消息对象 if (!empty($msgObj_list)) { foreach ($msgObj_list as $key => $val) { if ($key == "type") { $msgType = $val; } else { if ($key == "msgContent") { $msgContent = $val; } else { if ($key == "contentHtml") { $msgContentHtml = $val; } else { if ($key == "title") { $msgTitle = $val; } else { if ($key == "imgUrl") { $imgUrl = $val; } else { if ($key == "formid") { $formid = $val; } else { if ($key == "webpage_url") { $webpage_url = $val; } } } } } } } } } $staffinfo = new \Justsy\BaseBundle\Management\Staff($conn, $conn_im, empty($microNumber) ? $microOpenid : $microNumber, $this->get("logger"), $this->container); $staffdata = $staffinfo->getInfo(); if (empty($staffdata)) { $re = array('returncode' => '9999', 'msg' => '请选择接收对象'); return $this->responseJson(json_encode($re)); } else { $microOpenid = $staffdata["openid"]; $microNumber = $staffdata["login_account"]; } $re = array('returncode' => '0000'); $sqls = array(); $paras = array(); $send_state = '2'; $id = SysSeq::GetSeqNextValue($conn, 'we_micro_send_message', 'id'); $sqls[] = "insert into `we_micro_send_message` (`id`, `send_account`, `send_groupid`, `send_datetime`, `send_state`, `send_isbutton`, `send_source`,`send_type`) VALUES (?, ?, ?, now(), ?, ?, ?,?);"; $paras[] = array($id, $microNumber, $microGroupId, $send_state, false, 'wefafa', $msgType); $error = array('returncode' => '9999', 'msg' => '消息内容有误,请检查'); //处理消息 switch ($msgType) { case 'PICTURE': $title = ''; //标题 $image_type = ''; //图片类型 URL或CODE $image_value = ''; //图片地址 $content = ''; //摘要 $link = ''; //手机端点击之后连接地址 try { foreach ($msgContent as $key => $value) { if ($key == 'picturemsg') { $picturemsg = $value; //判断参数是否为空。并返回错误提示 if (empty($picturemsg)) { return $this->responseJson(json_encode($error)); } foreach ($picturemsg as $pkey => $pvalue) { if ($pkey == 'headitem') { $headitem = $pvalue; //判断参数是否为空。并返回错误提示 if (empty($headitem)) { return $this->responseJson(json_encode($error)); } foreach ($headitem as $hkey => $hvalue) { if ($hkey == 'title') { $title = $hvalue; } else { if ($hkey == 'image') { $image = $hvalue; //判断参数是否为空。并返回错误提示 if (empty($image)) { return $this->responseJson(json_encode($error)); } foreach ($image as $ikey => $ivalue) { if ($ikey == 'type') { $image_type = $ivalue; } else { if ($ikey == 'value') { $image_value = $ivalue; } } } } else { if ($hkey == 'content') { $content = $hvalue; } } } } } } } } } catch (Exception $e) { $this->get('logger')->err($e->getMessage()); return $this->responseJson(json_encode($error)); } if (!empty($webpage_url)) { $link = $webpage_url; $uniqid = $webpage_url; } else { $uniqid = str_replace('.', '', uniqid('', true)); $link = !empty($formid) ? $this->getWebFormLink($formid) : $this->getLink($uniqid); if (!empty($formid)) { $uniqid = $link; } } $noticeinfo = Utils::WrapMessageNoticeinfo($title, $microName); $msgContent = Utils::WrapMessage("mm-picturemsg", array('headitem' => array('title' => $title, 'image' => array('type' => $image_type, 'value' => $image_value), 'content' => $content, 'link' => $link)), $noticeinfo); //$msgContent= array('picturemsg'=>array('headitem'=>array('title'=>$title,'image'=>array('type'=>$image_type,'value'=>$image_value),'content'=>$content,'link'=>$link))); $msgid = SysSeq::GetSeqNextValue($conn, 'we_micro_message', 'id'); $sqls[] = "insert into `we_micro_message` (`id`, `send_id`, `msg_title`, `msg_type`, `msg_text`, `msg_content`, `msg_summary`, `msg_img_type`, `msg_img_url`, `msg_web_url`, `ishead`, `isread`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"; $msgContentHtml = $this->SetElementStyle($msgContentHtml); $paras[] = array($msgid, $id, $title, $msgType, null, $msgContentHtml, $content, $image_type, $image_value, $uniqid, true, false); break; case 'TEXTPICTURE': try { $headitem = array(); $items = array(); foreach ($msgContent as $key => $value) { if ($key == 'textpicturemsg') { $textpicturemsg = $value; if (empty($textpicturemsg)) { return $this->responseJson(json_encode($error)); } foreach ($textpicturemsg as $tpmkey => $tpmvalue) { if ($tpmkey == 'headitem') { $headitem = $tpmvalue; if (empty($headitem)) { return $this->responseJson(json_encode($error)); } $head_title = ''; $head_img_type = ''; $head_img_url = ''; $head_contentHtml = ''; $head_link = ''; $formid = ""; foreach ($headitem as $hkey => $hvalue) { if ($hkey == 'title') { $head_title = $hvalue; } else { if ($hkey == 'image') { $image = $hvalue; if (empty($image)) { return $this->responseJson(json_encode($error)); } foreach ($image as $imgkey => $imgvalue) { if ($imgkey == 'type') { $head_img_type = $imgvalue; } else { if ($imgkey == 'value') { $head_img_url = $imgvalue; } } } } else { if ($hkey == 'content') { $head_contentHtml = $hvalue; } else { if ($hkey == 'formid') { $formid = $hvalue; } } } } } $uniqid = str_replace('.', '', uniqid('', true)); $head_link = !empty($formid) ? $this->getWebFormLink($formid) : $this->getLink($uniqid); $headitem = array('title' => $head_title, 'image' => array('type' => $head_img_type, 'value' => $head_img_url), 'link' => $head_link); $msgid = SysSeq::GetSeqNextValue($conn, 'we_micro_message', 'id'); $sqls[] = "insert into `we_micro_message` (`id`, `send_id`, `msg_title`, `msg_type`, `msg_text`, `msg_content`, `msg_summary`, `msg_img_type`, `msg_img_url`, `msg_web_url`, `ishead`, `isread`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"; $head_contentHtml = $this->SetElementStyle($head_contentHtml); $paras[] = array($msgid, $id, $head_title, $msgType, null, $head_contentHtml, null, $head_img_type, $head_img_url, $uniqid, true, false); } else { if ($tpmkey == 'item') { $item = $tpmvalue; if (empty($item)) { return $this->responseJson(json_encode($error)); } $item_array = array(); for ($i = 0; $i < count($item); $i++) { $item_title = ''; $item_img_type = ''; $item_img_url = ''; $item_contentHtml = ''; $item_link = ''; $formid = ""; foreach ($item[$i] as $itemkey => $itemvalue) { if ($itemkey == 'title') { $item_title = $itemvalue; } else { if ($itemkey == 'image') { $image = $itemvalue; if (empty($image)) { return $this->responseJson(json_encode($error)); } foreach ($image as $imgkey => $imgvalue) { if ($imgkey == 'type') { $item_img_type = $imgvalue; } else { if ($imgkey == 'value') { $item_img_url = $imgvalue; } } } } else { if ($itemkey == 'content') { $item_contentHtml = $itemvalue; } else { if ($itemkey == 'formid') { $formid = $itemvalue; } } } } } $uniqid = str_replace('.', '', uniqid('', true)); $item_link = !empty($formid) ? $this->getWebFormLink($formid) : $this->getLink($uniqid); $item_array = array('title' => $item_title, 'image' => array('type' => $item_img_type, 'value' => $item_img_url), 'link' => $item_link); array_push($items, $item_array); $msgid = SysSeq::GetSeqNextValue($conn, 'we_micro_message', 'id'); $sqls[] = "INSERT INTO `we_micro_message` (`id`, `send_id`, `msg_title`, `msg_type`, `msg_text`, `msg_content`, `msg_summary`, `msg_img_type`, `msg_img_url`, `msg_web_url`, `ishead`, `isread`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"; $paras[] = array($msgid, $id, $item_title, $msgType, null, $item_contentHtml, null, $item_img_type, $item_img_url, $uniqid, false, false); } } } } } } $noticeinfo = Utils::WrapMessageNoticeinfo($headitem["title"], $microName); $msgContent = Utils::WrapMessage("mm-textpicturemsg", array('headitem' => $headitem, 'item' => $items), $noticeinfo); //$msgContent= array('textpicturemsg'=>array('headitem'=>$headitem,'item'=>$items)); } catch (\Exception $e) { $this->get('logger')->err($e->getMessage()); return $this->responseJson(json_encode($error)); } break; case 'TEXT': foreach ($msgContent as $key => $value) { if ($key == 'textmsg') { $textmsg = $value; //判断参数是否为空。并返回错误提示 if (empty($textmsg)) { return $this->responseJson(json_encode($error)); } foreach ($textmsg as $tkey => $tvalue) { if ($tkey == 'item') { $items = $tvalue; //判断参数是否为空。并返回错误提示 if (empty($items)) { return $this->responseJson(json_encode($error)); } $new_items = array(); for ($i = 0; $i < count($items); $i++) { $title = ''; $content = ''; foreach ($items[$i] as $itemkey => $itemvalue) { if ($itemkey == 'title') { $title = $itemvalue; } else { if ($itemkey == 'content') { $content = $itemvalue; } } } if (empty($title)) { return $this->responseJson(json_encode($error)); } if (empty($content)) { return $this->responseJson(json_encode($error)); } array_push($new_items, array('title' => $title, 'content' => $content)); $msgid = SysSeq::GetSeqNextValue($conn, 'we_micro_message', 'id'); $sqls[] = "INSERT INTO `we_micro_message` (`id`, `send_id`, `msg_title`, `msg_type`, `msg_text`, `msg_content`, `msg_summary`, `msg_img_type`, `msg_img_url`, `msg_web_url`, `ishead`, `isread`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"; $paras[] = array($msgid, $id, $title, $msgType, $content, null, null, null, null, null, false, false); } $noticeinfo = Utils::WrapMessageNoticeinfo($title, $microName); $msgContent = Utils::WrapMessage("mm-textmsg", array('item' => $new_items), $noticeinfo); // array('code'=>'textmsg','data'=>array('item'=>$new_items),'noticeinfo'=>''); } } } } break; default: //消息类型有误 return $this->responseJson(json_encode($error)); break; } $msgContent = json_encode($msgContent); try { $staffMgr = new \Justsy\BaseBundle\Management\Staff($conn, $conn_im, $microNumber, $this->get("logger"), $this->container); $microData = $staffMgr->getInfo(); $mic_jid = $microData["fafa_jid"]; $msgxml = Utils::WrapMicroMessageXml($mic_jid, $msgContent, $id); $im_msg_sql = "insert into im_microaccount_msg(microaccount,msg,created,us,msgid)values(?,?,now(),?,?)"; $conn_im->ExecSQL($im_msg_sql, array((string) $mic_jid, (string) $msgxml, "", (string) $id)); $fafa_jids = array(); $sqls_staff = array(); $paras_staff = array(); $apicontroller = new \Justsy\OpenAPIBundle\Controller\ApiController(); $apicontroller->setContainer($this->container); $serviceMgr = new \Justsy\BaseBundle\Management\Service($this->container); //$this->get('logger')->err("================1:".time()); $fafa_jids = $serviceMgr->service_sendjid($mic_jid, true); //$this->get('logger')->err("================:".json_encode($fafa_jids)); if (!empty($fafa_jids)) { $jids = array(); $count = count($fafa_jids); for ($i = 0; $i < $count; $i++) { array_push($jids, (string) $fafa_jids[$i]); if ($i > 0 && $i % 5000 == 0) { $re = $apicontroller->sendMsg2($microOpenid, implode(",", $jids), $msgContent, $msgType, false, "0", $id); $jids = array(); } } if (!empty($jids) && count($jids) > 0) { $re = $apicontroller->sendMsg2($microOpenid, implode(",", $jids), $msgContent, $msgType, false, "0", $id); } } //$this->get('logger')->err("================3:".time()); if (!empty($re['returncode']) && $re['returncode'] == '0000') { //添加发送消息数据 if (!empty($sqls)) { $conn->ExecSQLs($sqls, $paras); } //添加接收人员 if (!empty($sqls_staff)) { $conn->ExecSQLs($sqls_staff, $paras_staff); } } } catch (\Exception $e) { $this->get('logger')->err($e->getMessage()); $re = array('returncode' => '9999', 'msg' => '消息发送失败'); } return $this->responseJson(json_encode($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 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 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)); }
public function UploadFileAction() { $da = $this->get('we_data_access'); $da_im = $this->get('we_data_access_im'); $request = $this->getRequest(); $content = $request->get("update_content"); $version1 = $request->get("version_1"); $version2 = $request->get("version_2"); $version3 = $request->get("version_3"); $version4 = $request->get("version_4"); $version = $version1 . "." . $version2 . "." . $version3 . "." . $version4; $plist_url = $request->get("plist_url"); $plist_url = empty($plist_url) ? null : $plist_url; $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(); $login_account = $staffdata["login_account"]; $fileElementName = 'filedata'; $success = true; $msg = ""; try { $filename = $_FILES[$fileElementName]['name']; $filesize = $_FILES[$fileElementName]['size']; $filetemp = $_FILES[$fileElementName]['tmp_name']; //判断文件类型 $file_name = basename($filename); $fixedType = explode(".", strtolower($file_name)); $fixedType = $fixedType[count($fixedType) - 1]; $type = 0; if ($fixedType == "apk") { $type = 1; } else { if ($fixedType == "ipa") { $type = 2; } } //比较版本号 $sql = "select max(replace(version,'.','')) version from we_version where type=?;"; try { $ds = $da->GetData("table", $sql, array((string) $type)); if ($ds && $ds["table"]["recordcount"] > 0) { $old_ver = (int) $ds["table"]["rows"][0]["version"]; $new_ver = $version1 . $version2 . $version3 . $version4; $new_ver = (int) $new_ver; if ($new_ver <= $old_ver) { return Utils::WrapResultError("你输入的版本号比数据库里的小,请重新输入"); } } } catch (\Exception $e) { return Utils::WrapResultError($e->getMessage()); } $fileid = $this->saveCertificate($filetemp, $filename); if (!empty($fileid)) { //上传文件成功后返回文件id $url = $this->container->getParameter('FILE_WEBSERVER_URL'); $path = $_SERVER['DOCUMENT_ROOT'] . "/download/app"; $dir = explode('src', __DIR__); if (!is_dir($dir[0] . '/download/app')) { mkdir($dir[0] . '/download/app', 0777, true); } $path = $path . "/"; $dowurl = $url . $fileid; $id = SysSeq::GetSeqNextValue($da, "we_version", "id"); $sql = "insert into we_version(id,version,type,update_content,filename,date,staffid,fileid,plist_url)values(?,?,?,?,?,now(),?,?,?)"; $para = array((string) $id, (string) $version, (string) $type, (string) $content, (string) $file_name, (string) $login_account, (string) $fileid, $plist_url); try { $da->ExecSQL($sql, $para); //发送出席 $presence = new \Justsy\OpenAPIBundle\Controller\ApiController(); $presence->setContainer($this->container); $my_jid = $staffdata['jid']; $sql = "select distinct us from global_session;"; $ds = $da_im->GetData("us", $sql); $tojids = array(); $title = ""; if ($type == 1) { $title = "andorid"; } else { if ($type == 2) { $title = "ios"; } else { $title = "pc"; } } $sendMessage = new \Justsy\BaseBundle\Common\SendMessage($da, $da_im); $body = "有新版本(" . $version . "),请及时更新!"; $notice = Utils::WrapMessageNoticeinfo($body, '系统通知', null, null); $msg = json_encode(Utils::WrapMessage('newversion', array('type' => $title), $notice)); $parameter = array("eno" => $staffdata['eno'], "flag" => "all", "title" => "newversion", "message" => $msg, "container" => $this->container); $sendMessage->sendImMessage($parameter); } catch (\Exception $e) { $success = false; $this->get("logger")->err($e->getMessage()); $msg = "添加数据记录失败!"; return Utils::WrapResultError($e->getMessage()); } } else { $success = false; $msg = "上传安装包文件失败"; return Utils::WrapResultError($msg); } } catch (\Exception $e) { $success = false; $msg = "上传安装包失败。"; $this->get("logger")->err($e->getMessage()); return Utils::WrapResultError($e->getMessage()); } //删除上传的文件 @unlink($_FILES[$fileElementName]); return Utils::WrapResultOK(""); }
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 checkAndUpdate($nick_name, $mobile = null, $deptid = null, $duty = null, $ldap_uid = null, $sex_id = null, $self_desc = null) { $sql = "update we_staff set "; $returnItem = array(); $para = array(); $updateItm = array(); if (!empty($nick_name)) { $updateItm[] = "nick_name=?"; $para[] = (string) $nick_name; $returnItem["nick_name"] = $nick_name; } if ($mobile !== null) { $updateItm[] = "mobile=?, mobile_bind=?"; $para[] = (string) $mobile; $para[] = (string) $mobile; $returnItem["mobile"] = $mobile; } if ($duty !== null) { $updateItm[] = "duty=?"; $para[] = (string) $duty; $returnItem["duty"] = $duty; } if ($ldap_uid != null) { $updateItm[] = "ldap_uid=?"; $para[] = (string) $ldap_uid; } if ($sex_id != null) { $updateItm[] = "sex_id=?"; $para[] = (string) $sex_id; $returnItem["sex_id"] = $sex_id; } if ($self_desc != null) { $updateItm[] = "self_desc=?"; $para[] = (string) $self_desc; $returnItem["self_desc"] = $self_desc; } if ($deptid !== null) { $staffinfo = $this->getInfo(); $this->moveToDept($deptid); } if (empty($updateItm) || count($updateItm) == 0) { return true; } $sql = "update we_staff set " . implode(",", $updateItm) . " where login_account=? or ldap_uid=? or openid=?"; $para[] = (string) $this->account; $para[] = (string) $this->account; $para[] = (string) $this->account; $this->conn->ExecSQL($sql, $para); if (!empty($nick_name)) { $this->conn->ExecSQL("call emp_change_name(?,?)", array((string) $this->account, (string) $nick_name)); $jid = $this->getInfo(); $jid = $jid["fafa_jid"]; $this->conn_im->ExecSQL("call emp_change_name(?,?)", array((string) $jid, (string) $nick_name)); } //刷新缓存 $staffdata = $this->getInfo(true); if (!empty($self_desc) || !empty($nick_name)) { $pinyin = $this->syncAttrsToIM(); $returnItem['spell'] = $pinyin; } $VersionChange = new VersionChange($this->conn, $this->logger, $this->container); $VersionChange->deptchange($staffdata); $returnItem['jid'] = $staffdata['jid']; $msg = json_encode(Utils::WrapMessage('staff-changeinfo', $returnItem, array())); //操作成功发送出席 $sendMessage = new \Justsy\BaseBundle\Common\SendMessage($this->conn, $this->conn_im); $parameter = array("eno" => $staffdata["eno"], "fromjid" => $staffdata["jid"], "flag" => "all", "title" => "staff-changeinfo", "message" => $msg, "container" => $this->container); $sendMessage->sendImMessage($parameter); $parameter = array("eno" => $staffdata["eno"], "fromjid" => $staffdata["jid"], "flag" => "onself", "title" => "staff-changeinfo", "message" => $msg, "container" => $this->container); $sendMessage->sendImPresence($parameter); return true; }