public function modifyavatarAction() { $re = array("returncode" => ReturnCode::$SUCCESS); $request = $this->getRequest(); $user = $this->get('security.context')->getToken()->getUser(); $dm = $this->get('doctrine.odm.mongodb.document_manager'); $da = $this->get("we_data_access"); $login_account = $user->getUsername(); $photofile = $_FILES['photofile']['tmp_name']; 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); } } } $photofile_24 = $photofile . "_24"; $photofile_48 = $photofile . "_48"; try { if (empty($photofile)) { throw new \Exception("param is null"); } $im = new \Imagick($photofile); $im->scaleImage(48, 48); $im->writeImage($photofile_48); $im->destroy(); $im = new \Imagick($photofile); $im->scaleImage(24, 24); $im->writeImage($photofile_24); $im->destroy(); $table = $da->GetData("staff", "select photo_path,photo_path_small,photo_path_big \n from we_staff where login_account=?", array((string) $login_account)); if ($table && $table["staff"]["recordcount"] > 0) { Utils::removeFile($table["staff"]["rows"][0]["photo_path"], $dm); Utils::removeFile($table["staff"]["rows"][0]["photo_path_small"], $dm); Utils::removeFile($table["staff"]["rows"][0]["photo_path_big"], $dm); } if (!empty($photofile)) { $photofile = Utils::saveFile($photofile, $dm); } if (!empty($photofile_48)) { $photofile_48 = Utils::saveFile($photofile_48, $dm); } if (!empty($photofile_24)) { $photofile_24 = Utils::saveFile($photofile_24, $dm); } $da->ExecSQL("update we_staff set photo_path=?,photo_path_big=?,photo_path_small=? \n where login_account=?", array((string) $photofile_48, (string) $photofile, (string) $photofile_24, (string) $login_account)); $message = json_encode(array("path" => $this->container->getParameter('FILE_WEBSERVER_URL') . $photofile)); $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $this->get("we_data_access_im"), $user, $this->container->get("logger"), $this->container); Utils::sendImPresence($user->fafa_jid, implode(",", $staffMgr->getFriendJidList()), "staff-changeinfo", $message, $this->container, "", "", false, Utils::$systemmessage_code); $re["returncode"] = ReturnCode::$SUCCESS; $re["fileid"] = $photofile; $re["photo_path"] = $photofile_48; $re["photo_path_big"] = $photofile; $re["photo_path_small"] = $photofile_24; } 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 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 delConvTrendAction() { $re = array("returncode" => ReturnCode::$SUCCESS); $request = $this->getRequest(); $user = $this->get('security.context')->getToken()->getUser(); $da = $this->get('we_data_access'); $conv_id = $request->get("conv_id"); try { if (empty($conv_id)) { throw new \Exception("param is null"); } $conv = new \Justsy\BaseBundle\Business\Conv(); //不是自己的不能删除 if ($conv->checkIsOwenConv($da, $conv_id, $user->getUserName())) { $result = $conv->delConvByRootID($da, $conv_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_id); if ($send_jid && count($send_jid) > 0) { Utils::sendImPresence($user->fafa_jid, implode(",", $send_jid), "del_dynamic", $conv_id, $this->container, "", "", false, Utils::$systemmessage_code); } //删除动态人员范围表(后台广播) $announcerMgr = new \Justsy\BaseBundle\Management\Announcer($this->container); $announcerMgr->delConvers($conv_id); $re["returncode"] = ReturnCode::$SUCCESS; } else { $re["returncode"] = ReturnCode::$NOTAUTHORIZED; } $re["returncode"] = ReturnCode::$SUCCESS; } else { $re["returncode"] = ReturnCode::$NOTAUTHORIZED; } } 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 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; }