public function getMenuAction() { $re = array("returncode" => ReturnCode::$SUCCESS); $request = $this->getRequest(); $user = $this->get('security.context')->getToken()->getUser(); $da = $this->get('we_data_access'); $da_im = $this->get('we_data_access_im'); try { $mode = $this->container->getParameter('deploy_mode'); //判断用户是否系统管理员 $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $da_im, $user, $this->get("logger"), $this->container); $isAdmin = $staffMgr->isAdmin(); if (!empty($mode) && $isAdmin && (strtolower($mode) == "e" || strtolower($mode) == "c" && Utils::$PUBLIC_ENO == $user->eno)) { $sql = "select distinct menu_id id, parent_menu_id pId, menu_name name, 'true' open, url m_url from mb_menus\n where exists(select 1 from mb_staff_menu b where b.menu_id=mb_menus.menu_id and b.staff_id=?\n union select 1 from we_enterprise b where b.eno=? and b.create_staff=?\n union select 1 from we_enterprise b where b.eno=? and position(? in b.sys_manager)>0 ) order by order_no asc"; } else { $sql = "select distinct menu_id id, parent_menu_id pId, menu_name name, 'true' open, url m_url from mb_menus\n where exists(select 1 from mb_staff_menu b where b.menu_id=mb_menus.menu_id and b.staff_id=?\n union select 1 from we_enterprise b where b.eno=? and b.create_staff=?\n union select 1 from we_enterprise b where b.eno=? and position(? in b.sys_manager)>0)\n order by order_no asc"; } $params = array(); $params[] = (string) $user->getUserName(); $params[] = (string) $user->eno; $params[] = (string) $user->getUserName(); $params[] = (string) $user->eno; $params[] = (string) $user->getUserName(); $ds = $da->GetData("menus", $sql, $params); $re["menus"] = $ds["menus"]["rows"]; } catch (\Exception $e) { $re["returncode"] = ReturnCode::$SYSERROR; $this->get('logger')->err($e->getMessage()); } $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 static function userAuthAction($container, $request, $dbcon, $con_im, $login_account, $password, $comefrom) { $login_account = strtolower($login_account); try { $Obj = new \Justsy\BaseBundle\Login\UserProvider($container); $user = $Obj->loadUserByUsername($login_account, $comefrom); $logined = 1; //$container->get("logger")->err(json_encode($user)); $user2 = new UserSession($user->getusername(), $password, $user->getusername(), array("ROLE_USER")); $factory = $container->get("security.encoder_factory"); $encoder = $factory->getEncoder($user2); $password_enc = $encoder->encodePassword($password, $user2->getSalt()); /*$factory = $container->get('security.encoder_factory'); $encoder = $factory->getEncoder($user); $password_enc = $encoder->encodePassword($password, $user->getSalt()); $logined= 1;*/ if ($user->getPassword() != $password_enc) { //如果密码不正确时,有可能是修改了密码,只刷新了一台服务器上的缓存,其他集群环境中的还是原来的缓存 //刷新当前服务器的人员信息才重试 $u_staff = new \Justsy\BaseBundle\Management\Staff($dbcon, $con_im, $user->getusername(), $container->get('logger'), $container); $user = $u_staff->getInfo(true); //刷新人员信息 //$container->get("logger")->err("refresh cache data....."); $user = $Obj->loadUserByUsername($login_account, $comefrom); if ($user->getPassword() != $password_enc) { $container->get("logger")->err($login_account . "==>" . $password . "=>" . $password_enc . "=>" . $user->getPassword()); $re["returncode"] = ReturnCode::$ERROFUSERORPWD; $logined = null; } } if (!empty($logined)) { $user->comefrom = $comefrom; //登录源 //�Ǽ�seesion //$token = new \Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken($user, $user->getPassword(), "secured_area", $user->getRoles()); //$container->get("security.context")->setToken($token); //$session = $request->getSession()->set('_security_'.'secured_area', serialize($token)); //$event = new \Symfony\Component\Security\Http\Event\InteractiveLoginEvent($request, $token); //$container->get("event_dispatcher")->dispatch("security.interactive_login", $event); $re["returncode"] = ReturnCode::$SUCCESS; $re["openid"] = $user->openid; $re["login_account"] = $user->getusername(); $re["ldap_uid"] = $user->ldap_uid; $re["jid"] = $user->fafa_jid; $re["des"] = DES::encrypt($user->t_code); //im登录密码。生成session时对该属性解密,在些进行重新加密得到 } } catch (\Symfony\Component\Security\Core\Exception\UsernameNotFoundException $e) { $re["returncode"] = ReturnCode::$ERROFUSERORPWD; } catch (\Exception $e) { $re["returncode"] = ReturnCode::$SYSERROR; } return $re; }
public function loadUserByUsername($username, $comeform = "") { if (Utils::validateMobile($username)) { //手机登录 return $this->loadUserByUsernameWithMobile($username); } $DataAccess = $this->container->get('we_data_access'); $staff = new \Justsy\BaseBundle\Management\Staff($DataAccess, $this->container->get('we_data_access_im'), $username, $this->container->get("logger"), $this->container); $us = $staff->getInfo(); if (!empty($us)) { $us = $staff->getSessionUser($us); return $us; } else { throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username)); } }
public function pushNotice($data) { $receiver = $data["receiver"]; if (empty($receiver)) { return Utils::WrapResultError("接收人不能为空"); } $receiver = explode(',', $receiver); if (empty($data["text"])) { return Utils::WrapResultError("内容不能为空"); } $files = isset($data["files"]) ? $data["files"] : ''; if (!empty($files) && is_array($files)) { $files = implode(',', $files); } $noticeid = SysSeq::GetSeqNextValue($this->conn_im, "im_pushnotice_msg", "id"); $filefix = $this->container->getParameter('FILE_WEBSERVER_URL'); $senddata = array(); $senddata = array('noticeid' => $noticeid, 'text' => $data["text"], 'files' => $files, 'receivercount' => count($receiver), 'receiver' => implode(',', $receiver), 'sender' => array('nickname' => $this->user["nick_name"], 'photo' => $this->user["photo_path"], 'jid' => $this->user["jid"], 'date' => date("Y-m-d H:i:s", time()))); $notice = Utils::WrapMessageNoticeinfo($data["text"], $this->module["appname"], null, $this->module["logo"]); $msg = Utils::WrapMessage('push-notice', $senddata, $notice); $msgxml = Utils::WrapMessageXml($this->module["jid"], $msg, 'push-notice-' . $noticeid); $sql = 'insert into im_pushnotice_msg(id,replyid,msg,created,us,msgid)values(?,0,?,now(),?,?)'; $para = array((int) $noticeid, (string) $msgxml, (string) $this->user["jid"], 'push-notice-' . $noticeid); $sql2 = 'insert into im_pushnotice_memebr(noticeid,employeeid,lastread_reply,receive_time)values'; $sql2Values = array(); $staffinfo = new \Justsy\BaseBundle\Management\Staff($this->conn, $this->conn_im, $this->user['login_account'], $this->logger, $this->container); foreach ($receiver as $key => $value) { $rdata = $staffinfo->getstaffinfo($value); if (!empty($rdata)) { $receiver[$key] = $rdata['jid']; $sql2Values[] = '(' . $noticeid . ',\'' . $rdata['jid'] . '\',0,null)'; } } if (count($sql2Values) > 0) { $sql2 = $sql2 . implode(',', $sql2Values); $this->conn_im->ExecSQLs(array($sql, $sql2), array($para, array())); //发送消息 $receiver[] = $this->user["jid"]; Utils::findonlinejid($this->conn_im, $receiver); if (count($receiver) > 0) { $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 TencentLoginAction() { $da = $this->get("we_data_access"); $request = $this->getRequest(); $openid = $request->get("openid"); //普通用户的标识,对当前开发者帐号唯一 $logintype = $request->get("logintype"); $logintype = empty($logintype) ? "02" : $logintype; $ldap_uid = ""; $login_account = $openid . "@fafatime.com"; $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $this->get('we_data_access_im'), $login_account, $this->get("logger"), $this->container); $staffdata = $staffMgr->getInfo(); $re = array("returncode" => ReturnCode::$SYSERROR, "msg" => ""); $password = ""; //账号为空表示不存在 if (empty($staffdata)) { $sex = $request->get("gender"); if (trim($sex) == "男") { $sex = 1; } else { if (trim($sex) == "女") { $sex = 2; } else { $sex = 0; } } $parameter = array("appid" => $request->get("appid"), "province" => $request->get("province"), "city" => $request->get("city"), "account" => $login_account, "nick_name" => $request->get("nickname"), "eno" => $request->get("eno"), "ldap_uid" => $openid, "openid" => $openid, "sex" => $sex, "headimgurl" => $request->get("figureurl_2"), "type" => "tencent"); $registerInfo = $staffMgr->createstaff($parameter); if ($registerInfo["returncode"] == ReturnCode::$SUCCESS) { $re = $this->autologin($login_account, $logintype); } else { $re = $registerInfo; } } else { $re = $this->autologin($login_account, $logintype); } $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 joinCircle($account, $nick_name = null) { $falg = $this->IsExist($account); if ($falg) { return false; } $staffMgr = new \Justsy\BaseBundle\Management\Staff($this->conn, $this->conn_im, $account); $staffObj = $staffMgr->getInfo(); if ($staffObj == null) { return false; } if (empty($nick_name)) { $nick_name = $staffObj["nick_name"]; } $falg = $this->NicknameIsExist($nick_name); if ($falg) { $enoInfo = $staffMgr->getEnInfo(); $nick_name = $nick_name . "(" . $enoInfo["eshortname"] . ")"; } $sql = "insert into we_circle_staff (circle_id,login_account,nick_name) values (?,?,?)"; $this->conn->ExecSQL($sql, array((string) $this->circleid, (string) $account, (string) $nick_name)); return true; }
public function resetpwdAction() { $request = $this->getRequest(); $account = $request->get("account"); $txtvaildcode = $request->get("txtvaildcode"); $pwd = $request->get("txtnewpwd"); $pwd_im = $pwd; $da = $this->get("we_data_access"); $da_im = $this->get("we_data_access_im"); $re = array("returncode" => ReturnCode::$SUCCESS); if (empty($account)) { return $this->responseJson(Utils::WrapResultError("帐号不能为空"), $request->get('jsoncallback')); } if (empty($txtvaildcode)) { return $this->responseJson(Utils::WrapResultError("验证码不能为空"), $request->get('jsoncallback')); } //验证帐号及验证码 $isEmail = Utils::validateEmail($account); $isMobile = Utils::validateMobile($account); if (!$isEmail && !$isMobile) { return $this->responseJson(Utils::WrapResultError("帐号格式不正确,仅支持邮箱或手机帐号"), $request->get('jsoncallback')); } $u_staff = new \Justsy\BaseBundle\Management\Staff($da, $da_im, $account, $this->get('logger'), $this->container); $targetStaffInfo = $u_staff->getInfo(); if (empty($targetStaffInfo)) { return $this->responseJson(Utils::WrapResultError("帐号无效"), $request->get('jsoncallback')); } $sysparam = new \Justsy\BaseBundle\DataAccess\SysParam($this->container); $wn_code = $sysparam->GetSysParam("mobile_active_code"); if ($txtvaildcode != $wn_code) { $sql = "select * from we_mobilebind_validcode where login_account=? and actiontype='FP' and valid_date>now() order by valid_date desc limit 0,1"; $ds = $da->GetData('t', $sql, array((string) $account)); if ($txtvaildcode != $ds["t"]["rows"][0]["validcode"]) { return $this->responseJson(Utils::WrapResultError("验证码无效"), $request->get('jsoncallback')); } } try { $login_account = $targetStaffInfo['login_account']; $re = $u_staff->changepassword($login_account, $pwd, $this->get('security.encoder_factory')); return $this->responseJson($re, $request->get('jsoncallback')); } catch (Exception $e) { return $this->responseJson(Utils::WrapResultError("重置密码失败,请稍后重试"), $request->get('jsoncallback')); } }
public function mobilenumactiveAction() { $deploy_mode = $this->container->getParameter('deploy_mode'); $request = $this->getRequest(); $mobile_num = $request->get('mobile_num'); $mobile_pwd = $request->get('mobile_pwd'); //$eno = $request->get('eno'); $eno = $deploy_mode == "C" ? Utils::$PUBLIC_ENO : $this->container->getParameter("ENO"); //企业独立部署时企业不设置,从配置文件中获取固定的企业号 $ename = $request->get('ename'); $nick_name = $request->get('nick_name'); $active_code = $request->get('active_code'); $login_account = $mobile_num; $ldap_uid = $request->get("ldap_uid"); if (empty($active_code)) { return $this->getResponse(ReturnCode::$OTHERERROR, "请输入短信验证码!"); } if (empty($mobile_pwd)) { return $this->getResponse(ReturnCode::$OTHERERROR, "请输入密码!"); } if (empty($nick_name)) { return $this->getResponse(ReturnCode::$OTHERERROR, "请输入姓名!"); } $da = $this->get('we_data_access'); $da_im = $this->get('we_data_access_im'); $cacheobj = new \Justsy\BaseBundle\Management\Enterprise($da, $this->get("logger"), $this->container); if (!strpos($login_account, "@")) { $domain = $this->container->getParameter('edomain'); $login_account .= "@" . $domain; } $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $da_im, $login_account, $this->get("logger"), $this->container); $had = $staffMgr->getInfo(); if (!empty($had)) { return $this->getResponse(ReturnCode::$OTHERERROR, "该手机号已注册,继续使用请先找回密码"); } //判断手机号是否已经被使用 if ($staffMgr->checkUser($mobile_num)) { return $this->getResponse(ReturnCode::$OTHERERROR, "该手机号已被绑定,请解绑后重试"); } $sysparam = new \Justsy\BaseBundle\DataAccess\SysParam($this->container); $wn_code = $sysparam->GetSysParam("mobile_active_code"); try { if ($wn_code != $active_code) { $sql = "select state_id,active_code,review_note from we_register where login_account=?"; $ds = $da->GetData("we_register", $sql, array($login_account)); if ($ds && $ds['we_register']['recordcount'] <= 0) { return $this->getResponse(ReturnCode::$OTHERERROR, "未找到该手机号的注册信息!"); } if ($ds['we_register']['rows'][0]['state_id'] == '3') { return $this->getResponse(ReturnCode::$OTHERERROR, "该手机号已被注册!"); } if ((empty($ds['we_register']['rows'][0]['review_note']) ? 0 : $ds['we_register']['rows'][0]['review_note']) >= 5) { return $this->getResponse(ReturnCode::$OTHERERROR, "抱歉,验证码请求次数过多,如果获取不到验证码请根据下方提示与我们联系"); } if ($ds['we_register']['rows'][0]['active_code'] != $active_code) { $num = 5 - (empty($ds['we_register']['rows'][0]['review_note']) ? 0 : $ds['we_register']['rows'][0]['review_note']); $sql = "update we_register set review_note=ifnull(review_note,0)+1 where login_account=?"; $da->ExecSQL($sql, array($login_account)); return $this->getResponse(ReturnCode::$OTHERERROR, "验证码错误,请重新输入。"); } } $para = array(); $para['account'] = $mobile_num; $para['password'] = $mobile_pwd; $para['deptid'] = ''; $para['nick_name'] = $nick_name; $para['ldap_uid'] = ''; $re = $staffMgr->createstaff($para); } catch (\Exception $e) { $re = Utils::WrapResultError($e->getMessage()); } return $this->getResponse($re['returncode'], $re['msg']); }
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 getPrivateConvsAction() { $re = array("returncode" => ReturnCode::$SUCCESS); $request = $this->getRequest(); $user = $this->get('security.context')->getToken()->getUser(); $da = $this->get('we_data_access'); $circle_id = $request->get("circle_id"); $last_end_id = $request->get("last_end_id"); try { if (empty($circle_id)) { throw new \Exception("param is null"); } $sql = "select a.conv_root_id \nfrom we_convers_list a\nwhere a.conv_id=a.conv_root_id\n and a.post_to_circle=? and a.post_to_group='PRIVATE' and a.login_account=?"; $params = array(); $params[] = (string) $circle_id; $params[] = (string) $user->getUserName(); if ($circle_id == "9999") { //从im库中查询好友 $staffmgr = new \Justsy\BaseBundle\Management\Staff($da, $this->get('we_data_access_im'), $user); $getfriendList = $staffmgr->getFriendLoginAccountList("1"); if ($getfriendList && count($getfriendList) > 0) { $sql .= " and a.login_account in ('" . implode("','", $getfriendList) . "','" . $user->getUserName() . "')"; } else { $sql .= " and a.login_account=?"; $params[] = (string) $user->getUserName(); } } if (!empty($last_end_id)) { $sql .= " and (0+conv_root_id)<? "; $params[] = (double) $last_end_id; } $sql .= " and a.conv_type_id<>'06'"; $sql .= " order by (0+a.conv_id) desc"; $sql .= " limit 0, 15 "; $da = $this->get('we_data_access'); $ds = $da->GetData("we_convers_list", $sql, $params); $conv_root_ids = array_map(function ($row) { return $row["conv_root_id"]; }, $ds["we_convers_list"]["rows"]); $re["convs"] = $this->getConvAction($conv_root_ids); } 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 sendPresence($conv_id, $da, $circle_id, $post_to_group, $type) { $groupid = ""; $group_type = "group"; $fafa_jid = array(); $jid = ""; if ($circle_id == "10000") { return; } $user = $this->get('security.context')->getToken()->getUser(); if ($post_to_group != "ALL" && $post_to_group != "PRIVATE") { $groupObj = new \Justsy\BaseBundle\Management\GroupMgr($da, $this->get('we_data_access_im'), $this->container); $getGroupInfo = $groupObj->Get($post_to_group); $jid = $getGroupInfo["fafa_groupid"]; $fafa_jid = $groupObj->getGroupMembersJid($post_to_group, "1"); //获取允许接收群组动态通知的成员列表 $groupid = $post_to_group; } else { $group_type = "circle"; $groupid = $circle_id; $circlemgr = new \Justsy\BaseBundle\Management\CircleMgr($da, $this->get('we_data_access_im')); $getGroupInfo = $circlemgr->Get($circle_id); $jid = $getGroupInfo["fafa_groupid"]; //判断是否是私密,私密时不向圈子成员发出席 if ($post_to_group == "PRIVATE") { $group_type = "private"; } else { if ($circle_id == "9999") { $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $this->get('we_data_access_im'), $user, $this->get("logger"), $this->container); $fafa_jid = $staffMgr->getFriendJidList($conv_id); } else { $fafa_jid = $circlemgr->getCircleMembersJid($circle_id, "1"); } } } $cc_jid = array(); //获取抄送的人员jid $sql = "select b.fafa_jid from we_convers_notify a ,we_staff b where a.cc_login_account=b.login_account and conv_id=?"; $ds = $da->getData("ds", $sql, array((string) $conv_id)); if ($ds && count($ds["ds"]["rows"]) > 0) { for ($i = 0; $i < count($ds["ds"]["rows"]); $i++) { $cc_jid[] = $ds["ds"]["rows"][$i]["fafa_jid"]; } } //发送即时消息 $ec = new \Justsy\OpenAPIBundle\Controller\ApiController(); $ec->setContainer($this->container); $message = array($group_type . "id" => $groupid, "t" => $type, "jid" => $jid); $link = $this->generateUrl("JustsyBaseBundle_view_oneconv", array("conv_root_id" => $conv_id), true); $linkButtons = Utils::makeBusButton(array(array("code" => "action", "text" => "详细", "blank" => "1", "value" => ""))); //分次发送通知。每次200个号 $c = 0; $sendAry = array(); for ($i = 0; $i < count($fafa_jid); $i++) { $sendAry[] = $fafa_jid[$i]; $c++; if ($c >= 200) { $r = $ec->sendPresence($user->fafa_jid, implode(",", $sendAry), "", json_encode($message), $link, $linkButtons, false, $group_type . "_newtrend"); $c = 0; $sendAry = array(); } } if ($c > 0) { $r = $ec->sendPresence($user->fafa_jid, implode(",", $sendAry), "", json_encode($message), $link, $linkButtons, false, $group_type . "_newtrend", "0"); } if (count($cc_jid) > 0) { //给抄送人员推消息 $r = $ec->sendMsg($user->fafa_jid, implode(",", $cc_jid), "", json_encode($message), $link, $linkButtons, false, "private_newtrend"); } }
public function delete_announcer($parameter) { $login_account = $parameter["login_account"]; $this->account = $login_account; $staffMgr = new \Justsy\BaseBundle\Management\Staff($this->conn, $this->conn_im, $login_account, $this->logger, $this->container); $success = $staffMgr->leave(); if ($success) { $sqls = array(); $paras = array(); $sql = "delete from we_announcer where login_account=?;"; array_push($sqls, $sql); array_push($paras, array((string) $login_account)); $sql = "delete from mb_staff_menu where staff_id=?;"; array_push($sqls, $sql); array_push($paras, array((string) $login_account)); try { $this->conn->ExecSQLs($sqls, $paras); } catch (\Exception $e) { $this->container->get("logger")->err($e->getMessage()); } } return array("success" => $success); }
public function getMemberByCircleAction() { $code = ReturnCode::$SUCCESS; $rows = array(); $pagecount = 0; try { $user = $this->get('security.context')->getToken()->getUser(); $request = $this->getRequest(); $da = $this->get('we_data_access'); $da_im = $this->get('we_data_access_im'); $PageSize = $request->get('pagesize', 20); $PageIndex = $request->get('pageindex') ? $request->get('pageindex') - 1 : 0; $circleId = $request->get('circleId'); $searchby = $request->get('searchby'); //总数 $sql_total = ""; //数据sql $sql_data = ""; if ($circleId == '9999') { $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $da_im, $user, $this->container->get("logger"), $this->container); $list = $staffMgr->getFriendJidList(); $pagecount = ceil(count($list) / $PageSize); $rows = array(); if (!empty($list)) { $sql_sql = "select B.nick_name,B.login_account,B.photo_path,B.photo_path_small,B.photo_path_big from we_staff B where B.login_account in ('" . implode("','", $list) . "') "; $sql_sql .= empty($searchby) ? "" : (strlen($searchby) > mb_strlen($searchby, 'utf8') ? " and B.nick_name like ? " : " and (B.nick_name like ? or B.login_account like ?)"); $sql_sql .= " order by A.login_account"; $sql_sql .= " limit " . $PageIndex * $PageSize . "," . ($PageIndex * $PageSize + $PageSize); $params = array($circleId); if (!empty($searchby)) { array_push($params, $searchby . "%"); if (strlen($searchby) == mb_strlen($searchby, 'utf8')) { array_push($params, $searchby . "%"); } } $ds = $da->Getdata('info', $sql_sql, $params); $rows = $ds['info']['rows']; } } else { //根据jid获取sns ID //$sql = "select circle_id from we_circle where fafa_groupid=?"; //$ds=$da->Getdata('circle',$sql,array((string)$circleId)); //$circleId = $ds["circle"]["rows"][0]["circle_id"]; $sql_sql = "select B.nick_name,B.login_account,B.photo_path,B.photo_path_small,B.photo_path_big from we_circle_staff A,we_staff B where A.login_account=B.login_account and A.circle_id=? "; $sql_sql .= empty($searchby) ? "" : (strlen($searchby) > mb_strlen($searchby, 'utf8') ? " and A.nick_name like ? " : " and (A.nick_name like ? or A.login_account like ?)"); $sql_sql .= " order by B.login_account"; $sql_sql .= " limit " . $PageIndex * $PageSize . "," . ($PageIndex * $PageSize + $PageSize); $sql_total = "select count(1) cnt from we_circle_staff where circle_id=?"; $sql_total .= empty($searchby) ? "" : (strlen($searchby) > mb_strlen($searchby, 'utf8') ? " and nick_name like ? " : " and (nick_name like ? or login_account like ?)"); $params = array($circleId); if (!empty($searchby)) { array_push($params, $searchby . "%"); if (strlen($searchby) == mb_strlen($searchby, 'utf8')) { array_push($params, $searchby . "%"); } } $ds = $da->Getdata('info', $sql_sql, $params); $ds_total = $da->Getdata('total', $sql_total, $params); $pagecount = ceil($ds_total['total'][0]['cnt'] / $PageSize); $rows = $ds['info']['rows']; } } catch (\Exception $e) { //var_dump($e->getMessage()); $this->get('logger')->err($e); $rows = array(); $code = ReturnCode::$SYSERROR; } $re = array('returncode' => $code, 'rows' => $rows, 'pagecount' => $pagecount); $response = new Response(json_encode($re)); $response->headers->set('Content-Type', 'Application/json'); return $response; }
public function delTrendAction() { $re = array(); $user = $this->get('security.context')->getToken()->getUser(); $request = $this->getRequest(); $conv_root_id = $request->get('conv_root_id'); $da = $this->get('we_data_access'); $conv = new \Justsy\BaseBundle\Business\Conv(); //不是自己的不能删除 if ($conv->checkIsOwenConv($da, $conv_root_id, $user->getUserName())) { $result = $conv->delConvByRootID($da, $conv_root_id); if ($result) { //出席接收人员 $staffmgr = new \Justsy\BaseBundle\Management\Staff($da, $this->get('we_data_access_im'), $user, $this->get("logger"), $this->container); $send_jid = $staffmgr->getFriendJidList($conv_root_id); if ($send_jid && count($send_jid) > 0) { Utils::sendImPresence($user->fafa_jid, implode(",", $send_jid), "del_dynamic", $conv_root_id, $this->container, "", "", false, Utils::$systemmessage_code); } $AnnouncerMgr = new \Justsy\BaseBundle\Management\Announcer($this->container); $AnnouncerMgr->delConvers($conv_root_id); $re = array('success' => '1'); } else { $re = array('success' => '0'); } } else { $re = array('success' => '0'); } $response = new Response(json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; }
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 staffInviteAction($network_domain) { $user = $this->get('security.context')->getToken()->getUser(); $circle_id = $user->get_circle_id($network_domain); if ($circle_id != $user->get_circle_id($user->edomain)) { $response = new Response(""); $response->headers->set('Content-Type', 'text/html'); return $response; } else { $a = array(); //判断是否有同事 $staffMgr = new \Justsy\BaseBundle\Management\Staff($this->get('we_data_access'), $this->get('we_data_access_im'), $user->getUserName(), $this->get("logger")); $a["list"] = $staffMgr->getColleague(7); return $this->render('JustsyBaseBundle:EnterpriseHome:staff_invite.html.twig', $a); } }
public function getHisMessageAction() { $request = $this->getRequest(); $conn = $this->get("we_data_access"); $conn_im = $this->get("we_data_access_im"); $logger = $this->get("logger"); $container = $this->container; $api = new \Justsy\OpenAPIBundle\Controller\ApiController(); $api->setContainer($this->container); $isWeFaFaDomain = $api->checkWWWDomain(); if (!$isWeFaFaDomain) { $token = $api->checkAccessToken($request, $conn); if (!$token) { $re = array("returncode" => "9999"); $re["code"] = "err0105"; $re["msg"] = "参数Appid或Openid或Access_token未指定或无效."; return $this->responseJson($re); } } $microaccount = $request->get("microaccount"); //微应用帐号 $microgroupid = $request->get("microgroupid"); //微应用分组ID $pageindex = $request->get("pageindex"); //分页索引数 $factory = $this->get('security.encoder_factory'); if (empty($microaccount)) { return $this->responseJson(array("returncode" => ReturnCode::$SYSERROR, "msg" => "帐号不能为空.")); } if (empty($pageindex)) { $pageindex = 1; } $baseinfoCtl = new \Justsy\BaseBundle\Management\Staff($conn, $conn_im, $request->get("openid"), $this->get("logger"), $this->container); $currUser = $baseinfoCtl->getSessionUser(); if (empty($currUser)) { return $this->responseJson(array("returncode" => ReturnCode::$SYSERROR, "msg" => "无效的操作帐号")); } $sql_micro = "select number,type from we_micro_account where jid=?"; $para_micro = array($microaccount); $data_micro = $conn->GetData("dt", $sql_micro, $para_micro); if ($data_micro == null || count($data_micro["dt"]["rows"]) == 0 || empty($data_micro["dt"]["rows"][0]["number"])) { return $this->responseJson(array("returncode" => ReturnCode::$SYSERROR, "msg" => "微应用帐号不存在.")); } $microaccount = $data_micro["dt"]["rows"][0]['number']; $login_account = $currUser->getUserName(); $micr_type = $data_micro["dt"]["rows"][0]["type"]; //var_dump($login_account); $sql_total = "select count(1) as count from we_micro_send_message where send_account=? "; $para_total = array($microaccount); if (!empty($microgroupid)) { $sql_total = "select count(1) as count from we_micro_send_message where send_account=? and send_groupid=? "; $para_total = array($microaccount, $microgroupid); } $data_total = $conn->GetData("dt", $sql_total, $para_total); $total = 0; if ($data_total != null && count($data_total['dt']['rows']) > 0) { $total = $data_total['dt']['rows'][0]['count']; } $totalpage = 1; if ($total > 1) { $totalpage = ceil($total / 10); } $startrow = ($pageindex - 1) * 10; $sql = "select * from we_micro_send_message where send_account=? order by send_datetime desc LIMIT " . $startrow . ",10"; $para = array($microaccount); if (!empty($microgroupid)) { $sql = "select * from we_micro_send_message where send_account=? and send_groupid=? order by send_datetime desc LIMIT " . $startrow . ",10"; $para = array($microaccount, $microgroupid); } $re = array('returncode' => '9999', "msg" => '消息获取失败'); $data_row = $conn->GetData("dt", $sql, $para); //var_dump($sql); if ($data_row != null && count($data_row['dt']['rows']) > 0) { $objlist = array(); $pushMgr = new \Justsy\AdminAppBundle\Controller\MsgPushController(); $pushMgr->setContainer($this->container); for ($i = 0; $i < count($data_row['dt']['rows']); $i++) { $send_id = $data_row['dt']['rows'][$i]["id"]; $send_type = $data_row['dt']['rows'][$i]["send_type"]; $send_datetime = $data_row['dt']['rows'][$i]["send_datetime"]; $sql = "select * from we_micro_message where send_id=?"; $para = array($send_id); $dataitem = $conn->GetData("dt", $sql, $para); if ($dataitem != null && count($dataitem['dt']['rows']) > 0) { $list = array("type" => $send_type, "date" => $send_datetime); //var_dump($send_type); switch ($send_type) { case 'TEXT': $text_items = array(); for ($l = 0; $l < count($dataitem['dt']['rows']); $l++) { $item = array('title' => $dataitem['dt']['rows'][$l]["msg_title"], 'content' => $dataitem['dt']['rows'][$l]["msg_text"]); array_push($text_items, $item); } $list['data'] = array('item' => $text_items); //var_dump($list); break; case 'PICTURE': for ($j = 0; $j < count($dataitem['dt']['rows']); $j++) { $headitem = array("title" => $dataitem['dt']['rows'][$j]["msg_title"], 'content' => $dataitem['dt']['rows'][$j]["msg_summary"], 'image' => array('type' => $dataitem['dt']['rows'][$j]["msg_img_type"], 'value' => $dataitem['dt']['rows'][$j]["msg_img_url"]), 'link' => $pushMgr->getLink($dataitem['dt']['rows'][$j]["msg_web_url"])); $list['data'] = array("headitem" => $headitem); } break; case 'TEXTPICTURE': $items = array(); for ($k = 0; $k < count($dataitem['dt']['rows']); $k++) { $ishead = $dataitem['dt']['rows'][$k]["ishead"]; //var_dump($ishead); if ($ishead == "1") { $headitem = array("title" => $dataitem['dt']['rows'][$k]["msg_title"], 'content' => $dataitem['dt']['rows'][$k]["msg_text"], 'image' => array('type' => $dataitem['dt']['rows'][$k]["msg_img_type"], 'value' => $dataitem['dt']['rows'][$k]["msg_img_url"]), 'link' => $pushMgr->getLink($dataitem['dt']['rows'][$k]["msg_web_url"])); $data['headitem'] = $headitem; } else { $item = array("title" => $dataitem['dt']['rows'][$k]["msg_title"], 'content' => $dataitem['dt']['rows'][$k]["msg_text"], 'image' => array('type' => $dataitem['dt']['rows'][$k]["msg_img_type"], 'value' => $dataitem['dt']['rows'][$k]["msg_img_url"]), 'link' => $pushMgr->getLink($dataitem['dt']['rows'][$k]["msg_web_url"])); array_push($items, $item); } } if (!empty($items)) { $data['item'] = $items; } $list['data'] = $data; break; } array_push($objlist, $list); } } if (!empty($objlist)) { $re = array('returncode' => '0000', "total" => $total, 'totalpage' => $totalpage, 'list' => $objlist); } } else { $re = array('returncode' => '0000', "total" => 0, 'totalpage' => 1, 'list' => array()); } return $this->responseJson($re); }
public function getDataAccessAction() { $request = $this->get("request"); $module = $request->get("module"); $action = $request->get("action"); $params = $request->get("params"); $class = null; $re["action"] = $action; if (empty($params)) { $params = array(); } else { if (is_string($params)) { $params = json_decode($params, true); } } $currUser = $this->get('security.context')->getToken(); if (empty($currUser)) { $openid = $request->get("openid"); if (empty($openid)) { $re = array(); $re["returncode"] = ReturnCode::$SYSERROR; $re["msg"] = "openid不能为空"; return $this->responseJson($request, $re); } $staffObj = new \Justsy\BaseBundle\Management\Staff($this->get('we_data_access'), $this->get('we_data_access_im'), $openid, $this->get("logger"), $this->container); $currUser = $staffObj->getSessionUser(); } else { $currUser = $currUser->getUser(); } $params["user"] = $currUser; $module = strtolower($module); //转化为小写 if ($module == "app") { $class = new \Justsy\BaseBundle\Management\App($this->container); } else { if ($module == "staff") { $class = new \Justsy\BaseBundle\Management\Staff($this->get('we_data_access'), $this->get('we_data_access_im'), $currUser->getUserName(), $this->get("logger"), $this->container); } else { if ($module == "enterprise") { $class = new \Justsy\BaseBundle\Management\Enterprise($this->get('we_data_access'), $this->get("logger"), $this->container); } else { if ($module == "dept") { $class = new \Justsy\BaseBundle\Management\Dept($this->get('we_data_access'), $this->get('we_data_access_im'), $this->container); } else { if ($module == "group") { $class = new \Justsy\BaseBundle\Management\GroupMgr($this->get('we_data_access'), $this->get('we_data_access_im'), $this->container); } else { if ($module == "microaccount") { $class = new \Justsy\BaseBundle\Management\MicroAccountMgr($this->get('we_data_access'), $this->get('we_data_access_im'), $currUser->getUserName(), $this->get("logger"), $this->container); } else { if ($module == "service") { $class = new \Justsy\BaseBundle\Management\Service($this->container); } else { if ($module == "announcer") { $class = new \Justsy\BaseBundle\Management\Announcer($this->container); } else { if ($module == "rolefunc") { $class = new \Justsy\BaseBundle\Management\RoleFunc($this->container); } else { if ($module == "role") { $class = new \Justsy\BaseBundle\Management\Role($this->container); } else { if ($module == "portal") { $class = new \Justsy\BaseBundle\Management\Portal($this->container); } else { if ($module == "sysparam") { $class = new \Justsy\BaseBundle\Management\EnoParamManager($this->get('we_data_access'), $this->get('we_data_access_im'), $this->container); } else { if ($module == "servermonitor") { $class = new \Justsy\BaseBundle\Management\ServerMonitor($this->container); } else { if ($module == "hrattendance") { $class = new \Justsy\BaseBundle\Management\HrAttendance($this->container); } else { $result = array("returncode" => "9999", "msg" => "请转入正确的模块名称!"); return $this->responseJson($request, $result); } } } } } } } } } } } } } } $result = call_user_func_array(array($class, $action), array($params)); return $this->responseJson($request, $result); }
public function agreeJoinCircleAction($para) { if (empty($para)) { return $this->render('JustsyBaseBundle:Error:index.html.twig', array('error' => '参数错误!')); } $da = $this->get('we_data_access'); $res = $this->get('request'); $urlSource = $res->get("_urlSource"); //获取操作源。FaFaWin:从PC客户端操作的 //受邀人员帐号,圈子id,邀请人帐号 $paraArr = explode(",", trim(DES::decrypt($para))); //是否有帐号 $sql = "select nick_name,fafa_jid from we_staff where login_account=?"; $ds = $da->GetData("we_staff", $sql, array((string) $paraArr[0])); if (!$ds || $ds['we_staff']['recordcount'] == 0) { if (empty($urlSource)) { return $this->render('JustsyBaseBundle:Error:index.html.twig', array('error' => '您还没有微发发帐号,请先注册!')); } else { $response = new Response("{\"succeed\":0,\"msg\":\"您还没有微发发帐号,请先注册!\"}"); $response->headers->set('Content-Type', 'text/json'); return $response; } } //判断是否是邀请加入人脉圈子,则在互相关注 if ($paraArr[1] == "9999") { //互相添加好友 $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $this->get('we_data_access_im'), $paraArr[2], $this->get("logger")); try { $staffMgr->attentionTo($paraArr[0]); } catch (\Exception $e) { } try { $staffMgr->attentionMe($paraArr[0]); } catch (\Exception $e) { } try { $staffMgr->bothAddFriend($this->container, $paraArr[0]); } catch (\Exception $e) { } $response = new Response("{\"succeed\":1,\"name\":\"人脉圈\",\"circleurl\":\"" . $this->generateUrl("JustsyBaseBundle_enterprise", array('network_domain' => "9999"), true) . "\"}"); $response->headers->set('Content-Type', 'text/json'); return $response; } $nick_name = $ds['we_staff']['rows'][0]['nick_name']; $fafa_jid = $ds['we_staff']['rows'][0]['fafa_jid']; //圈子是否存在 $sql = "select network_domain,circle_name,fafa_groupid from we_circle where circle_id=?"; $ds = $da->GetData("we_circle", $sql, array((string) $paraArr[1])); if (!$ds || $ds['we_circle']['recordcount'] == 0) { if (empty($urlSource)) { return $this->render('JustsyBaseBundle:Error:index.html.twig', array('error' => '您要加入的圈子不存在!')); } else { $response = new Response("{\"succeed\":0,\"msg\":\"您要加入的圈子不存在!\"}"); $response->headers->set('Content-Type', 'text/json'); return $response; } } $fafa_groupid = $ds['we_circle']['rows'][0]['fafa_groupid']; $network_domain = $ds['we_circle']['rows'][0]['network_domain']; $circle_name = $ds['we_circle']['rows'][0]['circle_name']; //是否已经加入圈子 $sql = "select count(1) cnt from we_circle_staff where login_account=? and circle_id=?"; $ds = $da->GetData("cnt", $sql, array((string) $paraArr[0], (string) $paraArr[1])); if ($ds && $ds['cnt']['rows'][0]['cnt'] > 0) { if (empty($urlSource)) { return $this->render('JustsyBaseBundle:Error:index.html.twig', array('error' => '您已经加入该圈子!')); } else { $response = new Response("{\"succeed\":0,\"msg\":\"您已经加入该圈子!\"}"); $response->headers->set('Content-Type', 'text/json'); return $response; } } //圈子id+nick_name不能重复 $sql = "select count(1) cnt from we_circle_staff where circle_id=? and nick_name=?"; $ds = $da->GetData("cnt", $sql, array((string) $paraArr[1], (string) $nick_name)); if ($ds && $ds['cnt']['rows'][0]['cnt'] > 0) { $user = $this->get('security.context')->getToken()->getUser(); $nick_name = $nick_name . "(" . $user->eshortname . ")"; } //判断圈子是否有人 $sql = "select count(1) as cnt from we_circle_staff where circle_id=?"; $ds = $da->GetData('we_circle_staff', $sql, array((string) $paraArr[1])); if ($ds && $ds['we_circle_staff']['rows'][0]['cnt'] == 0) { $sql = "update we_circle set create_staff=? where circle_id=?"; $da->ExecSQL($sql, array((string) $paraArr[0], (string) $paraArr[1])); } $sql = "insert into we_circle_staff (circle_id,login_account,nick_name) values (?,?,?)"; $da->ExecSQL($sql, array((string) $paraArr[1], (string) $paraArr[0], (string) $nick_name)); //更新邀请信息 $sql = "update we_invite set real_active_email=?,active_date=now() where invite_send_email=? and invite_recv_email=? and eno=?"; $da->ExecSQL($sql, array((string) $paraArr[0], (string) $paraArr[2], (string) $paraArr[0], (string) ("c" . $paraArr[1]))); //10-加入外部圈子-5 $sql = "insert into we_staff_points (login_account,point_type,point_desc,point,point_date) values (?,?,?,?,now())"; $da->ExecSQL($sql, array((string) $paraArr[0], (string) '10', (string) '成功加入外部圈子' . $circle_name . ',获得积分5', (int) 5)); $apply = new \Justsy\BaseBundle\Management\ApplyMgr($da, null); $apply->SetCircleApplyInvalid($paraArr[0], $paraArr[1]); //发送即时消息通知申请人及成员 $circleObj = new \Justsy\BaseBundle\Controller\CircleController(); $circleObj->setContainer($this->container); $message = Utils::makeHTMLElementTag('employee', $fafa_jid, $nick_name) . "加入了圈子【" . Utils::makeHTMLElementTag('circle', $fafa_groupid, $circle_name) . "】"; $circleObj->sendPresenceCirlce($paraArr[1], "circle_addmember", $message); $backurl = $this->generateUrl("JustsyBaseBundle_enterprise", array('network_domain' => $paraArr[0]), true); if (empty($urlSource)) { return $this->render('JustsyBaseBundle:Error:success.html.twig', array('backurl' => $backurl)); } else { $response = new Response("{\"succeed\":1,\"name\":\"" . $circle_name . "\",\"circleurl\":\"" . $backurl . "\"}"); $response->headers->set('Content-Type', 'text/json'); return $response; } }
public static function tokenAction($container, $con, $appid, $code, $encrypt) { $app = new \Justsy\BaseBundle\Management\App($container->container); $stat_v = explode(",", $appid); $appid = $stat_v[0]; $openid = $stat_v[1]; $isLogin = null; if (strpos($appid, "SSO_") !== false) { $isLogin = $appid; //新浪微博集成登录 //获取微博对应的业务系统认证配置 $syspara = new \Justsy\BaseBundle\DataAccess\SysParam($container); $appid = $syspara->GetSysParam(strtolower($appid) . "_appid"); if (empty($appid)) { $resp = new Response("未配置微博业务系统或参数sso_sina_appid"); $resp->headers->set('Content-Type', 'text/html'); return $resp; } $appdata = $app->getbussysteminfo(array("appid" => $appid)); $appid = $isLogin; //把appid还原成sso集成登录标识 } else { if (strpos($appid, "SYS_") !== false) { //业务系统直接对接 $appdata = $app->getbussysteminfo(array("appid" => substr($appid, 4))); } else { $appdata = $app->getappinfo(array("appid" => $appid)); } } if (empty($appdata)) { return "无效的APPID"; } $token_url = $appdata["token_url"]; if (empty($token_url)) { return "无效的配置:令牌获取地址无效"; } $token_method = $appdata["token_method"]; $token_method = empty($token_method) ? "POST" : $token_method; $auth_url = $token_url; $para_name = $appdata["redirecturl_para_name"]; if (empty($para_name)) { $para_name = "redirect_uri"; } $paraString = ""; if (empty($code)) { $paraString .= "grant_type=client_credentials&" . $para_name . "=" . $appdata["redirection_url"]; } else { $paraString .= "grant_type=authorization_code&" . $para_name . "=" . $appdata["redirection_url"]; } $para_name = $appdata["clientid_para_name"]; if (empty($para_name)) { $para_name = "client_id"; } $paraString .= "&" . $para_name . "=" . $appdata["clientid"]; $para_name = $appdata["clientkey_para_name"]; if (empty($para_name)) { $para_name = "client_secret"; } $paraString .= "&" . $para_name . "=" . $appdata["clientkey"]; $paraString .= "&code=" . $code; $paraString .= "&state=" . $appid . "," . $openid; $container->get("logger")->err($auth_url . " -- " . $paraString); if (strtoupper($token_method) == "POST") { $token = Utils::do_post_request($auth_url, $paraString); } else { $token = Utils::do_post_request($auth_url . "?" . $paraString, null); } $container->get("logger")->err("token value:" . $token); $retuenAry = array(); if (substr($token, 0, 1) == "{") { $retuenAry = json_decode($token, true); } else { $rv = explode("&", $token); for ($i = 0; $i < count($rv); $i++) { $rv_i = explode("=", $rv[$i]); $retuenAry[$rv_i[0]] = preg_replace("/'/is", "", $rv_i[1]); } } $result = array("returncode" => "0000", "data" => null); $para_name = $appdata["token_para_name"]; if (empty($para_name)) { $para_name = "access_token"; } if (isset($retuenAry[$para_name])) { $retuenAry[$appdata["clientid_para_name"]] = $appdata["clientid"]; $retuenAry[$appdata["clientkey_para_name"]] = $appdata["clientkey"]; $result["returncode"] = "0000"; $retuenAry[$appdata["token_para_name"]] = $retuenAry[$para_name]; $app->setappsession(array("session" => $retuenAry, "openid" => $openid, "appid" => $appid)); } else { $result["returncode"] = "9999"; } $result["data"] = $retuenAry; if (!empty($isLogin)) { if (strpos($isLogin, "SSO_") !== false) { if ($isLogin == "SSO_SINA") { $uid = $retuenAry["uid"]; } else { if ($isLogin == "SSO_WECHAT") { $uid = $retuenAry["openid"]; } } //判断并注册用户 $staffobj = new \Justsy\BaseBundle\Management\Staff($container->get("we_data_access"), $container->get("we_data_access_im"), $uid, null, $container->container); $re = $staffobj->createstaff(array("password" => rand(100000, 999999), "eno" => Utils::$PUBLIC_ENO, "nick_name" => $uid, "ldap_uid" => $uid, "account" => "")); $re["data"]["des"] = DES::decrypt($re["data"]["t_code"]); } return self::responseLoginJson(json_encode($re)); } else { if (strpos($appid, "SYS_") !== false) { return self::responseJsonStr(json_encode($result)); } else { return self::responseJson(json_encode($result)); } } }
public function write_msg($fromjid, $msgxml, $msgid) { if (empty($fromjid)) { $domain = $this->container->getParameter('edomain'); $staffinfo = new \Justsy\BaseBundle\Management\Staff($this->conn, $this->conn_im, 'admin@' . $domain, $this->container->get("logger"), $this->container); $staffdata = $staffinfo->getInfo(); $fromjid = $staffdata['jid']; } if (empty($msgid)) { $msgid = split("@", $fromjid); $msgid = $msgid[0] . time(); } //存储业务消息 $xml = Utils::WrapMessageXml($fromjid, $msgxml, $msgid); $sql = 'insert into im_b_msg(msg,created,us,msgid)values(?,now(),?,?)'; $para = array((string) $xml, (string) $fromjid, (string) $msgid); $this->conn_im->ExecSQL($sql, $para); }
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 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 rejectjoin($paraObj) { $currUser = $paraObj["user"]; if (empty($currUser)) { return Utils::WrapResultError("请登录后重试", ReturnCode::$NOTLOGIN); } $wfl = new \Justsy\BaseBundle\Business\WeWorkflow($this->container); //根据申请帐号处理 $account = isset($paraObj["staff"]) ? $paraObj["staff"] : ""; if (!empty($account)) { $paraObj["appid"] = $paraObj["user"]->eno; $paraObj["submit_staff"] = $account; } $nodeinfo = $wfl->getNode($paraObj); if (empty($nodeinfo)) { return Utils::WrapResultError("申请已被取消或删除"); } //判断申请人是否已加入企业 $staffobj = new \Justsy\BaseBundle\Management\Staff($this->da, $this->container->get('we_data_access_im'), $paraObj["submit_staff"], $this->logger, $this->container); $staffata = $staffobj->getInfo(); if ($staffata["eno"] != Utils::$PUBLIC_ENO) { if ($staffata["eno"] == $currUser->eno) { return Utils::WrapResultError("该帐号已加入企业"); } else { return Utils::WrapResultError("该帐号已加入其他企业"); } } $paraObj["node_id"] = $nodeinfo["node_id"]; //申请状态处理 $re = $wfl->reject($paraObj); //消息通知 if (!empty($re)) { $message = "你的企业加入申请已被拒绝,请联系企业管理员"; Utils::sendImMessage("", $re["submit_staff"], "enterprise_joinreject", $message, $this->container, "", "", true, '', '0'); //通知企业其他管理员 $endata = $this->getInfo($currUser->eno); $to = $endata["sys_manager"]; if (empty($to)) { $to = $endata["create_staff"]; } Utils::sendImMessage("", explode(";", $to), "enterprise_joinreject", json_encode($re), $this->container, "", "", true, '', '0'); } return Utils::WrapResultOK($re); }
public function getMicroMessageAction() { $request = $this->getRequest(); $conn = $this->get("we_data_access"); $conn_im = $this->get("we_data_access_im"); $logger = $this->get("logger"); $container = $this->container; $microaccount = $request->get("microaccount"); //微应用帐号 $microgroupid = $request->get("microgroupid"); //微应用分组ID $pageindex = $request->get("pageindex"); //分页索引数 $factory = $this->get('security.encoder_factory'); if (empty($microaccount)) { return $this->responseJson(array("returncode" => ReturnCode::$SYSERROR, "msg" => "微应用帐号不能为空.")); } if (empty($pageindex)) { $pageindex = 1; } $currUser = $this->get('security.context')->getToken(); if (!empty($currUser)) { $currUser = $currUser->getUser(); } else { $baseinfoCtl = new \Justsy\BaseBundle\Management\Staff($da, null, $request->get("openid"), $this->get("logger")); $currUser = $baseinfoCtl->getSessionUser(); } if (empty($currUser)) { return $this->responseJson(array("returncode" => ReturnCode::$SYSERROR, "msg" => "您还没有登录呢.")); } $sql_micro = "select number,type from we_micro_account where number=?"; $para_micro = array($microaccount); $data_micro = $conn->GetData("dt", $sql_micro, $para_micro); if ($data_micro == null || count($data_micro["dt"]["rows"]) == 0 || empty($data_micro["dt"]["rows"][0]["number"])) { return $this->responseJson(array("returncode" => ReturnCode::$SYSERROR, "msg" => "微应用帐号不存在.")); } $login_account = $currUser->getUserName(); $micr_type = $data_micro["dt"]["rows"][0]["type"]; //var_dump($login_account); $sql_atten = "select count(1) as count from we_staff_atten where atten_type='01' and login_account=? and atten_id=?"; $para_atten = array($login_account, $microaccount); $data_atten = $conn->GetData("dt", $sql_atten, $para_atten); $isatten = false; if ($data_atten == null || count($data_atten["dt"]["rows"]) == 0 || empty($data_atten["dt"]["rows"][0]["count"])) { $isatten = true; //没有被关注 } //$microgroupid=""; if ($isatten) { //没有关注 if ($micr_type == "0") { //内部微应用帐号需要判断是否关注该公众号 return $this->responseJson(array("returncode" => ReturnCode::$SYSERROR, "msg" => "未关注微应用帐号.")); } } else { //已经关注 //$sql_micro_group="select GROUP_CONCAT(id) as id from we_micro_account_group where micro_account=? ORDER BY id"; //$para_micro_group=array($microaccount); //$data_micro_group=$conn->GetData("dt",$sql_micro_group,$para_micro_group); //if($data_micro_group!=null && count($data_micro_group["dt"]["rows"])>0 && !empty($data_micro_group["dt"]["rows"][0]["id"])){ // $microgroupid=$data_micro_group["dt"]["rows"][0]["id"]; //} } $sql_total = "select count(1) as count from we_micro_send_message where send_account=? "; $para_total = array($microaccount); if (!empty($microgroupid)) { $sql_total = "select count(1) as count from we_micro_send_message where send_account=? and send_groupid=? "; $para_total = array($microaccount, $microgroupid); } $data_total = $conn->GetData("dt", $sql_total, $para_total); $total = 0; if ($data_total != null && count($data_total['dt']['rows']) > 0) { $total = $data_total['dt']['rows'][0]['count']; } $totalpage = 1; if ($total > 1) { $totalpage = ceil($total / 10); } $startrow = ($pageindex - 1) * 10; $sql = "select * from we_micro_send_message where send_account=? order by send_datetime desc LIMIT " . $startrow . ",10"; $para = array($microaccount); if (!empty($microgroupid)) { $sql = "select * from we_micro_send_message where send_account=? and send_groupid=? order by send_datetime desc LIMIT " . $startrow . ",10"; $para = array($microaccount, $microgroupid); } $re = array('returncode' => '9999', "msg" => '消息获取失败'); $data_row = $conn->GetData("dt", $sql, $para); //var_dump($sql); if ($data_row != null && count($data_row['dt']['rows']) > 0) { $objlist = array(); for ($i = 0; $i < count($data_row['dt']['rows']); $i++) { $send_id = $data_row['dt']['rows'][$i]["id"]; $send_type = $data_row['dt']['rows'][$i]["send_type"]; $send_datetime = $data_row['dt']['rows'][$i]["send_datetime"]; $sql = "select * from we_micro_message where send_id=?"; $para = array($send_id); $dataitem = $conn->GetData("dt", $sql, $para); if ($dataitem != null && count($dataitem['dt']['rows']) > 0) { $list = array("type" => $send_type, "date" => $send_datetime); //var_dump($send_type); switch ($send_type) { case 'TEXT': $text_items = array(); for ($l = 0; $l < count($dataitem['dt']['rows']); $l++) { $item = array('title' => $dataitem['dt']['rows'][$l]["msg_title"], 'content' => $dataitem['dt']['rows'][$l]["msg_text"]); array_push($text_items, $item); } $list['data'] = array('item' => $text_items); //var_dump($list); break; case 'PICTURE': for ($j = 0; $j < count($dataitem['dt']['rows']); $j++) { $headitem = array("title" => $dataitem['dt']['rows'][$j]["msg_title"], 'content' => $dataitem['dt']['rows'][$j]["msg_summary"], 'image' => array('type' => $dataitem['dt']['rows'][$j]["msg_img_type"], 'value' => $dataitem['dt']['rows'][$j]["msg_img_url"]), 'link' => $dataitem['dt']['rows'][$j]["msg_web_url"]); $list['data'] = array("headitem" => $headitem); } break; case 'TEXTPICTURE': $items = array(); for ($k = 0; $k < count($dataitem['dt']['rows']); $k++) { $ishead = $dataitem['dt']['rows'][$k]["ishead"]; //var_dump($ishead); if ($ishead == "1") { $headitem = array("title" => $dataitem['dt']['rows'][$k]["msg_title"], 'content' => $dataitem['dt']['rows'][$k]["msg_text"], 'image' => array('type' => $dataitem['dt']['rows'][$k]["msg_img_type"], 'value' => $dataitem['dt']['rows'][$k]["msg_img_url"]), 'link' => $dataitem['dt']['rows'][$k]["msg_web_url"]); $data['headitem'] = $headitem; } else { $item = array("title" => $dataitem['dt']['rows'][$k]["msg_title"], 'content' => $dataitem['dt']['rows'][$k]["msg_text"], 'image' => array('type' => $dataitem['dt']['rows'][$k]["msg_img_type"], 'value' => $dataitem['dt']['rows'][$k]["msg_img_url"]), 'link' => $dataitem['dt']['rows'][$k]["msg_web_url"]); array_push($items, $item); } } if (!empty($items)) { $data['item'] = $items; } $list['data'] = $data; break; } array_push($objlist, $list); } } if (!empty($objlist)) { $re = array('returncode' => '0000', "total" => $total, 'totalpage' => $totalpage, 'list' => $objlist); } } else { $re = array('returncode' => '0000', "total" => 0, 'totalpage' => 1, 'list' => array()); } //$data=array('microaccount'=>$microaccount,'microgroupid'=>$microgroupid,'pageindex'=>$pageindex); //$data='microaccount='.$microaccount.'µgroupid='.$microgroupid.'&pageindex='.$pageindex; //var_dump($data); //$re=$this->do_post_request('http://mp.wefafa.com/interface/getmessagelist',$data); return $this->responseJson($re); }
public function getNode($parameter) { $file_url = $this->containerObj->getParameter("FILE_WEBSERVER_URL"); $node_id = isset($parameter["node_id"]) ? $parameter["node_id"] : ""; $appid = isset($parameter["appid"]) ? $parameter["appid"] : ""; $wftype = isset($parameter["wf_type"]) ? $parameter["wf_type"] : ""; $submit_staff = isset($parameter["submit_staff"]) ? $parameter["submit_staff"] : ""; $sql = "select b.eno,b.appid,e.ename,concat('{$file_url}',e.logo_path_big) logo_path,a.*,b.wf_name,b.content from we_app_workflow_node a,we_app_businessworkflow b,we_enterprise e where a.wf_id=b.wf_id and b.eno=e.eno "; $para = array(); if (!empty($node_id)) { $sql .= " and a.node_id=?"; $para[] = (string) $node_id; } if (!empty($appid)) { $sql .= " and exists (select 1 from we_app_businessworkflow w where a.wf_id=w.wf_id and w.appid=?)"; $para[] = (string) $appid; } if (!empty($submit_staff)) { $sql .= " and a.submit_staff=?"; $para[] = (string) $submit_staff; } if (!empty($wftype)) { $sql .= " and exists (select 1 from we_app_businessworkflow w where a.wf_id=w.wf_id and w.wf_type=?)"; $para[] = (string) $wftype; } $re = $this->conn->GetData("t", $sql, $para); $re = count($re["t"]["rows"]) > 0 ? $re["t"]["rows"][0] : null; if (!empty($re)) { $staff = new \Justsy\BaseBundle\Management\Staff($this->conn, $this->conn_im, $re["submit_staff"], $this->logger, $this->containerObj); $staffdata = $staff->getInfo(); $re["nick_name"] = empty($staffdata) ? "" : $staffdata["nick_name"]; //获取节点附件 $sql = "select * from we_app_workflow_attachment where node_id=?"; $ds = $this->conn->GetData("att", $sql, array((string) $re["node_id"])); $attachment = array(); for ($i = 0; $i < count($ds["att"]["rows"]); $i++) { $attachment[] = $ds["att"]["rows"][$i]["file_id"]; } $re["attachment"] = implode(",", $attachment); //获取共同处理人 $sql = "select * from we_app_workflow_nodesetting where node_id=?"; $ds = $this->conn->GetData("att", $sql, array((string) $re["node_id"])); $dealstaffs = array(); for ($i = 0; $i < count($ds["att"]["rows"]); $i++) { $dealstaffs[] = $ds["att"]["rows"][$i]["staff_jid"]; } $re["dealstaffs"] = implode(",", $dealstaffs); } return $re; }
public function savemobilebindAction() { $re = array(); $user = $this->get('security.context')->getToken()->getUser(); $request = $this->getRequest(); $txtmobile = $request->get("txtmobile"); $txtvaildcode = $request->get("txtvaildcode"); if (empty($txtmobile)) { $re["returncode"] = ReturnCode::$SYSERROR; $re["msg"] = "请输入正确的手机号!"; $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; } if ($txtmobile != $request->getSession()->get("txtmobile")) { $re["returncode"] = ReturnCode::$SYSERROR; $re["msg"] = "两次手机号输入不一致!"; $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; } if (empty($txtvaildcode) || $txtvaildcode != $request->getSession()->get("mobilevaildcode")) { $re["returncode"] = ReturnCode::$SYSERROR; $re["msg"] = "请输入正确的验证码!"; $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; } try { $sqls = array(); $all_params = array(); $sql = "update we_staff set mobile_bind=null where mobile_bind=?"; $params = array(); $params[] = $txtmobile; $sqls[] = $sql; $all_params[] = $params; $sql = "update we_staff set mobile=?, mobile_bind=? where login_account=?"; $params = array(); $params[] = $txtmobile; $params[] = $txtmobile; $params[] = $user->getUserName(); $sqls[] = $sql; $all_params[] = $params; $da = $this->get("we_data_access"); $da->ExecSQLs($sqls, $all_params); //发送手机绑定通知 try { $noticeMsg = array(); $noticeMsg["login_account"] = $user->fafa_jid; $noticeMsg["nick_name"] = $user->nick_name; $noticeMsg["mobile_bind"] = "1"; $noticeMsg["mobile"] = $txtmobile; $message = json_encode($noticeMsg); $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $this->get("we_data_access_im"), $user); $recv = $staffMgr->getFriendAndColleagueJid(); array_push($recv, $user->fafa_jid); Utils::sendImPresence("", implode(",", $recv), "mobile_bind", $message, $this->container, "", "", false, Utils::$systemmessage_code); } catch (\Exception $e) { $this->get("logger")->err($e); } $re["returncode"] = ReturnCode::$SUCCESS; } catch (\Exception $e) { $re["returncode"] = ReturnCode::$SYSERROR; $re["msg"] = "绑定手机号失败!请重试"; $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 updatePassByMobileAction(Request $request) { $login_account = $request->get("login_account"); $pwd = $request->get("pwd"); $active = $request->get("active_code"); $result = array(); $state = $this->checkLose($login_account, $active); if ($state == 2) { $result = array("succeed" => false, "err" => "短信验证码错误!"); } else { if ($state == 0) { $result = array("succeed" => false, "err" => "短信验证码已过期!"); } else { if ($state == 1) { $da = $this->get('we_data_access'); $da_im = $this->get('we_data_access_im'); $pwdMgr = new \Justsy\BaseBundle\Management\Staff($da, $da_im, $login_account, $this->get("logger"), $this->container); $factory = $this->container->get("security.encoder_factory"); $result = $pwdMgr->changepassword($login_account, $pwd, $factory); $success = isset($result["returncode"]) ? $result["returncode"] : "9999"; if ($success == "0000") { $sql = "update we_retrieve_password set valid='0' where id=? and login_account=?"; $da->ExecSQL($sql, array((string) $active, (string) $login_account)); $result = array("succeed" => true, "url" => $this->generateUrl('root')); } else { $result = array("succeed" => false, "err" => "修改密码失败"); } } } } $response = new Response(json_encode($result)); $response->headers->set('Content-Type', 'text/json'); return $response; }