public function indexAction() { $da = $this->get('we_data_access'); $da_im = $this->get('we_data_access_im'); $user = $this->get('security.context')->getToken()->getUser(); $login_account = $user->getUserName(); $groupMgr = new \Justsy\BaseBundle\Management\GroupMgr($da, $da_im, $this->container); $manager = $groupMgr->isManager($user->eno, $login_account); $exist = true; if (empty($manager)) { $sql = "select 1 from mb_staff_menu where staff_id=?;"; try { $ds = $da->GetData("table", $sql, array((string) $login_account)); if ($ds && $ds["table"]["recordcount"] == 0) { $exist = false; } } catch (\Exception $e) { } } if ($exist) { return $this->render('JustsyAdminAppBundle:Home:index.html.twig', array()); } else { return $this->render('JustsyAdminAppBundle:Home:error.html.twig', array()); } }
public function IndexAction() { $user = $this->get('security.context')->getToken()->getUser(); $login_account = $user->getUserName(); $eno = $user->eno; $da = $this->get('we_data_access'); $url = $this->container->getParameter('FILE_WEBSERVER_URL'); $groupMgr = new \Justsy\BaseBundle\Management\GroupMgr($this->get('we_data_access'), $this->get('we_data_access_im'), $this->container); $manager = $groupMgr->isManager($eno, $login_account); $request = $this->getRequest(); $type = $request->get("type"); if (empty($type)) { return $this->render("JustsyAdminAppBundle:Sys:service.html.twig", array("manager" => $manager)); } else { return $this->render("JustsyAdminAppBundle:Sys:service2.html.twig", array("manager" => $manager)); } }
public function FriendCircleAction() { $user = $this->get('security.context')->getToken()->getUser(); $login_account = $user->getUserName(); $eno = $user->eno; $groupMgr = new \Justsy\BaseBundle\Management\GroupMgr($this->get('we_data_access'), $this->get('we_data_access_im'), $this->container); $manager = $groupMgr->isManager($eno, $login_account); $da = $this->get('we_data_access'); $url = $this->container->getParameter('FILE_WEBSERVER_URL'); $head_img = ""; $sql = "select case when ifnull(photo_path,'')='' then '' else concat('{$url}',photo_path) end head_img from we_staff where login_account=?"; try { $ds = $da->GetData("table", $sql, array((string) $login_account)); if ($ds && $ds["table"]["recordcount"] > 0) { $head_img = $ds["table"]["rows"][0]["head_img"]; } } catch (\Exception $e) { } return $this->render("JustsyAdminAppBundle:Sys:friendcircle.html.twig", array("manager" => $manager, "account" => $user->getUserName(), "head_img" => $head_img, "nick_name" => $user->nick_name)); }
public function sendsharemsgAction() { $da = $this->get("we_data_access"); $da_im = $this->get("we_data_access_im"); $re = array("returncode" => ReturnCode::$SUCCESS, 'msg' => ''); $res = $this->getRequest(); $user = $this->get('security.context')->getToken()->getUser(); try { //获取接收者 $openids = $res->get("openids"); $groupid = $res->get("groupid"); $circleid = $res->get("circleid"); //分享到指定的圈子中,需要单独 处理。不走实时消息通道 if (empty($openids) && empty($groupid) && empty($circleid)) { $toType = $res->get("totype"); //分享目标类型,当openids\groupid\circleid存在时无效 //分享到其他网站或者平台上,暂时支持微信朋友圈\QQ空间 $re = ""; $response = new Response($res->get('jsoncallback') ? $res->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; } //获取推送的分享图片地址 $imgurl = $res->get("imgurl"); //获取推送的分享内容 $content = $res->get("content"); $shareitem = array(); $shareitem["content"] = $content; if (!empty($imgurl)) { $shareitem["image"] = array("value" => $imgurl, "type" => "URL"); } $shareitem["iosclass"] = $res->get("iosclass"); $shareitem["androidclass"] = $res->get("androidclass"); $shareitem["bizdata"] = $res->get("bizdata"); if (!empty($circleid)) { $ref_url = json_encode(array("iosclass" => $shareitem["iosclass"], "androidclass" => $shareitem["androidclass"], "bizdata" => $shareitem["bizdata"])); //分享到圈子 $conv_id = \Justsy\BaseBundle\DataAccess\SysSeq::GetSeqNextValue($da, "we_convers_list", "conv_id"); $conv = new \Justsy\BaseBundle\Business\Conv(); $conv->newShareTrend($da, $user->getUserName(), $conv_id, $content, $imgurl, $circleid, "ALL", $ref_url, array(), "00", null); $response = new Response($res->get('jsoncallback') ? $res->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; } $msgBody = array(); $msgBody["snssharemsg"] = array("shareitem" => $shareitem); $tolist = array(); if (!empty($groupid)) { $groupmgr = new \Justsy\BaseBundle\Management\GroupMgr($da, $da_im); //$groupdata = $groupmgr->GetByIM($groupid); $tolist = $groupmgr->getGroupMembersJidByIM($groupid); $msgBody["snssharemsg"]["shareitem"]["groupid"] = $groupid; } if (!empty($openids)) { $tolist = array_merge($tolist, explode(",", $openids)); } $cnt = count($tolist); if ($cnt > 0) { $api = new \Justsy\OpenAPIBundle\Controller\ApiController(); $api->setContainer($this->container); $re = $api->sendMsg2($user->fafa_jid, implode(",", $tolist), json_encode($msgBody), "sharemsg", true); } } catch (\Exception $e) { $re["returncode"] = ReturnCode::$SYSERROR; $re["msg"] = "系统错误"; $this->get('logger')->err($e); } $response = new Response($res->get('jsoncallback') ? $res->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; }
public function setgrouplogoAction() { $request = $this->getRequest(); $groupid = $request->get("groupid"); $dm = $this->container->get('doctrine.odm.mongodb.document_manager'); $da = $this->get('we_data_access_im'); $photofile = ""; try { $photofile = empty($_FILES['photofile']) ? null : $_FILES['photofile']['tmp_name']; } catch (\Exception $e) { } if (empty($photofile)) { $photofile = tempnam(sys_get_temp_dir(), "we"); unlink($photofile); $somecontent1 = base64_decode($request->get('photodata')); if ($handle = fopen($photofile, "w+")) { if (!fwrite($handle, $somecontent1) == FALSE) { fclose($handle); } } } $returncode = "0000"; $path = ""; try { if (empty($photofile)) { throw new \Exception("param is null"); } $im = new \Imagick($photofile); $im->scaleImage(120, 120); $im->writeImage($photofile); $im->destroy(); $sql = "select logo from im_group where groupid=?;"; $table = $da->GetData("group", $sql, array((string) $groupid)); if ($table && $table["group"]["recordcount"] > 0) { $file = $table["group"]["rows"][0]["logo"]; if (!empty($file)) { Utils::removeFile($table["group"]["rows"][0]["logo"], $dm); } } $fileid = ""; if (!empty($photofile)) { $fileid = Utils::saveFile($photofile, $dm); } $sql = "update im_group set logo=? where groupid=?;"; try { $da->ExecSQL($sql, array((string) $fileid, (string) $groupid)); } catch (\Exception $e) { $this->get("logger")->err($e->getMessage()); } if (!empty($fileid)) { $path = $this->container->getParameter('FILE_WEBSERVER_URL'); $path = $path . $fileid; } $path = $path . $fileid; //发送出席 $groupMgr = new \Justsy\BaseBundle\Management\GroupMgr($this->get('we_data_access'), $da, $this->container); $groupObj = $groupMgr->getGroupMemberJid($groupid); $to_jid = $groupObj["member_jid"]; $groupname = $groupObj["groupname"]; $user = $this->get('security.context')->getToken()->getUser(); $nick_name = $user->nick_name; $send_jid = $user->fafa_jid; if (!empty($to_jid)) { $title = "group-changelogo"; $message = $nick_name . "修改了群(" . $groupname . ")头像!"; Utils::sendImPresence($send_jid, $to_jid, $title, $message, $this->container, "", "", false, Utils::$systemmessage_code); } } catch (\Exception $e) { $returncode = "9999"; $this->get("logger")->err($e->getMessage()); } $result = array("returncode" => $returncode, "fileid" => $fileid, "path" => $path); $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($result) . ");" : json_encode($result)); $response->headers->set('Content-Type', 'text/json'); return $response; }
public function setgroupAction(Request $request) { $conn = $this->get('we_data_access'); $conn_im = $this->get('we_data_access_im'); $user = $this->get('security.context')->getToken()->getUser(); $groupobj = $request->get('groupobj'); $groupobj = explode(';', $groupobj); $result = array("success" => false, "msg" => "变更群组动态设置失败"); //var_dump($groupobj); if (!empty($groupobj)) { $groupMgr = new \Justsy\BaseBundle\Management\GroupMgr($conn, $conn_im); for ($i = 0; $i < count($groupobj); $i++) { $grouphint = explode('#', $groupobj[$i]); //var_dump($grouphint); if (count($grouphint) == 2) { $success = $groupMgr->setHint($grouphint[0], $user, $grouphint[1]); if ($success) { $result = array("success" => true, "msg" => "变更群组动态设置成功"); } } } } $response = new Response(json_encode($result)); $response->headers->set('Content-Type', 'text/html'); return $response; }
public function getgroupmemberAction() { //判断请求域。是wefafa或子域则不验证授权令牌 $isWeFaFaDomain = $this->checkWWWDomain(); $res = $this->get("request"); $da = $this->get("we_data_access"); if (!$isWeFaFaDomain) { $token = $this->checkAccessToken($res, $da); if (!$token) { $re = array("returncode" => "9999"); $re["code"] = "err0105"; $re["msg"] = "参数Appid或Openid或Access_token未指定或无效."; $response = new Response($res->get('jsoncallback') ? $res->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; } } $opneid = $res->get("openid"); $ds = $this->checkOpenid($da, $opneid); if ($ds === false) { $re = array("returncode" => "9999"); $re["code"] = "err0105"; $re["msg"] = "参数openid未指定或无效."; $response = new Response($res->get('jsoncallback') ? $res->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; } $groupid = $res->get("groupid"); $obj = new \Justsy\BaseBundle\Management\GroupMgr($da, $this->get("we_data_access_im")); $isPriv = $obj->IsExist($groupid, $opneid); if ($isPriv === false) { $re = array("returncode" => "9999"); $re["code"] = "err0105"; $re["msg"] = "权限不足,不能获取该群组的成员信息."; $response = new Response($res->get('jsoncallback') ? $res->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; } $datalist = $obj->getGroupMembers($groupid); $re = array("returncode" => "0000"); $re["members"] = $datalist == null ? array() : $datalist; $response = new Response($res->get('jsoncallback') ? $res->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; }
$sql = "call p_quitgroup(?, ?, 0)"; $params = array(); $params[] = (string) $group_id; $params[] = (string) $user->getUserName(); $ds = $da->GetData("p_quitgroup", $sql, $params); if ($ds["p_quitgroup"]["rows"][0]["recode"] == "0") { //向客户端发送即时通知 $message = Utils::makeHTMLElementTag('employee', $user->fafa_jid, $user->nick_name) . "退出了群组【" . Utils::makeHTMLElementTag('group', $fafa_groupid, $group_name) . "】"; $this->sendPresenceGroup($fafa_groupid, "group_deletemeber", $message); $re = array('success' => '1'); //变更版本信息
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 getOfficialTrendWinAction($conv_root_id) { $FILE_WEBSERVER_URL = $this->container->getParameter('FILE_WEBSERVER_URL'); $user = $this->get('security.context')->getToken()->getUser(); $da = $this->get('we_data_access'); $conv = new \Justsy\BaseBundle\Business\Conv(); $ds = $conv->getOfficialTrend($da, $user, $conv_root_id, $FILE_WEBSERVER_URL); if (count($ds["we_convers_list"]["rows"]) == 0) { return new Response(""); } $isGroup = $ds["we_convers_list"]["rows"][0]["post_to_group"]; if ($isGroup != "ALL") { //获取群组logo $groupmgr = new \Justsy\BaseBundle\Management\GroupMgr($da, null); $groupdata = $groupmgr->Get($isGroup); if ($groupdata != null) { $ds["we_convers_list"]["rows"][0]["en_logo_path"] = $FILE_WEBSERVER_URL . (empty($groupdata["group_photo_path"]) ? "default_group.png" : $groupdata["group_photo_path"]); } } else { //判断是否是非企业圈子 $circleid = $ds["we_convers_list"]["rows"][0]["post_to_circle"]; if ($user->get_circle_id("") != $circleid) { $circlemgr = new \Justsy\BaseBundle\Management\CircleMgr($da, null); $data = $circlemgr->Get($circleid); if ($data != null) { $ds["we_convers_list"]["rows"][0]["en_logo_path"] = $FILE_WEBSERVER_URL . (empty($data["logo_path"]) ? "default_cirle.png" : $data["logo_path"]); } } } if ($ds["we_convers_list"]["rows"][0]["auth_level"] != 'S') { $ds["we_convers_list"]["rows"][0]["vip_level"] = \Justsy\BaseBundle\Common\ExperienceLevel::getLevel($ds["we_convers_list"]["rows"][0]["total_point"]); } else { $ds["we_convers_list"]["rows"][0]["vip_level"] = "1"; // } $css_level = (int) ($ds["we_convers_list"]["rows"][0]["we_level"] / 10); $para = array('this' => $this, 'ds' => $ds, 'css_level' => $css_level, "trend" => $this->getRequest()->get("trend")); return $this->render('JustsyBaseBundle:CDisplayArea:officialtrend_win.html.twig', $para); }
public function search_service($parameter) { $success = true; $data = array(); $staff = isset($parameter["staff"]) ? $parameter["staff"] : null; $user = $parameter["user"]; $curUser = $user->getUserName(); $pageindex = isset($parameter["pageindex"]) ? $parameter["pageindex"] : 1; $record = isset($parameter["record"]) ? $parameter["record"] : 100; $pageindex = $pageindex < 1 ? 1 : $pageindex; $limit = " limit " . ($pageindex - 1) * $record . "," . $record; $recordcount = 0; $groupMgr = new \Justsy\BaseBundle\Management\GroupMgr($this->conn, $this->conn_im, $this->container); $manager = $groupMgr->isManager($user->eno, $curUser); $fileurl = $this->container->getParameter("FILE_WEBSERVER_URL"); if (empty($manager)) { $sql = "select b.id as micro_id,a.fafa_jid as jid,a.login_account,a.nick_name,b.micro_use,concat('{$fileurl}',a.photo_path_big) photo_path,b.type,\n ifnull((select 'manager' from we_service s where s.objid='" . $curUser . "' and s.login_account=b.number and type=3 ),'') manager ,(select count(1) msgcount from we_micro_send_message msg where msg.send_account=b.number) msgcount\n from we_staff a inner join we_micro_account b on a.fafa_jid=b.jid where b.eno=? "; } else { $sql = "select b.id as micro_id,a.fafa_jid as jid,a.login_account,a.nick_name,b.micro_use,concat('{$fileurl}',a.photo_path_big) photo_path,b.type,'" . $manager . "' manager ,(select count(1) msgcount from we_micro_send_message msg where msg.send_account=b.number) msgcount\n from we_staff a inner join we_micro_account b on a.fafa_jid=b.jid where b.eno=? "; } $condition = ""; $page_sql = "select count(*) recordcount from we_staff a inner join we_micro_account b on a.fafa_jid=b.jid where b.eno=?"; $para = array((string) $user->eno); if (!empty($staff)) { if (strlen($staff) > mb_strlen($staff, 'utf8')) { $condition = " and a.nick_name like concat('%',?,'%') "; array_push($para, (string) $staff); } else { $condition = " and (a.login_account like concat('%',?,'%') or a.nick_name like concat('%',?,'%')) "; array_push($para, (string) $staff, (string) $staff); } } $sql .= $condition . " order by a.login_account asc " . $limit; try { $ds = null; if (count($para) == 0) { $ds = $this->conn->GetData("table", $sql); } else { $ds = $this->conn->GetData("table", $sql, $para); } if ($ds && $ds["table"]["recordcount"] > 0) { $data = $ds["table"]["rows"]; $sql = 'select a.send_account,a.send_datetime,b.msg_title,b.msg_text,b.msg_content,msg_summary,msg_img_url,msg_web_url,msg_type from we_micro_send_message a ,we_micro_message b where a.id=b.send_id and a.send_account=? order by a.send_datetime desc limit 1'; foreach ($data as $key => $value) { //获取最后推送的消息 $data[$key]["message"] = array(); if ($value['msgcount'] == 0) { continue; } $tmp_para = array((string) $value['login_account']); $tmp_ds = $this->conn->GetData("msg", $sql, $tmp_para); $data[$key]["message"] = $tmp_ds['msg']['rows']; } $count = $ds["table"]["recordcount"]; if ($pageindex == 1 && $count >= $record) { $page_sql .= $condition; if (count($para) == 0) { $ds = $this->conn->GetData("table", $page_sql); } else { $ds = $this->conn->GetData("table", $page_sql, $para); } if ($ds && $ds["table"]["recordcount"] > 0) { $recordcount = $ds["table"]["rows"][0]["recordcount"]; } } } } catch (\Exception $e) { $success = false; $this->logger->err($e->getMessage()); return Utils::WrapResultError($e->getMessage()); } return Utils::WrapResultOK($data); }