public function ResetPassWordAction()
 {
     $da = $this->get("we_data_access");
     $da_im = $this->get("we_data_access_im");
     $request = $this->getRequest();
     $account = strtolower($request->get("account"));
     $password = $request->get("password");
     $result = array("success" => true, "message" => "");
     $user = $this->get('security.context')->getToken()->getUser();
     try {
         $u_staff = new Staff($da, $da_im, $account, $this->get('logger'), $this->container);
         $targetStaffInfo = $u_staff->getInfo();
         $re = $u_staff->changepassword($targetStaffInfo["login_account"], $password, $this->get('security.encoder_factory'));
         if ($re) {
             //$this->get("logger")->err("sendImPresence:".$targetStaffInfo["fafa_jid"]);
             //给自己发送一个staff-changepasswod的出席,通知在线客户端密码发生修改,需要新密码重新登录
             Utils::sendImPresence($user->fafa_jid, $targetStaffInfo["fafa_jid"], "staff-changepasswod", "staff-changepasswod", $this->container, "", "", false, Utils::$systemmessage_code);
             //记录用户操作日志
             $syslog = new \Justsy\AdminAppBundle\Controller\SysLogController();
             $syslog->setContainer($this->container);
             $desc = "重置了用户账号:" . $account . "登录密码!";
             $syslog->AddSysLog($desc, "重置密码");
         } else {
             $result = array("success" => false, "message" => "修改密码错误!");
         }
     } catch (\Exception $e) {
         $this->get("logger")->err($e->getMessage());
         $result = array("success" => false, "message" => "修改密码错误!");
     }
     $response = new Response(json_encode($result));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
 private function SendImPresence($planid, $title, $tojid, $message)
 {
     if (empty($message)) {
         //获取消息内容
         if (!empty($planid)) {
             $ds = $this->GetPlan($planid);
             if (count($ds) > 0) {
                 $message = json_encode($ds[0]);
             } else {
                 return false;
             }
         } else {
             return false;
         }
     }
     if (!empty($this->user)) {
         if (empty($tojid)) {
             $eno = $this->user->eno;
             //根据企业号获取接收人
             $sqltojid = " select GROUP_CONCAT(distinct fafa_jid) as login_account from we_circle t1 left join we_circle_staff t2 on t1.circle_id=t2.circle_id  inner join we_staff t3 on t1.enterprise_no=t3.eno" . " where t1.enterprise_no=? ";
             $parastojid = array((string) $eno);
             $dstojid = $this->conn->GetData("result", $sqltojid, $parastojid);
             $tojid = $dstojid["result"]["rows"][0]["login_account"];
         }
         $staffinfo = "{\"nick_name\":\"" . $this->user->nick_name . "\",";
         if (!empty($message)) {
             $message = str_replace("{", $staffinfo, $message);
         }
         //开始发送出席消息
         Utils::sendImPresence($this->user->fafa_jid, $tojid, $title . "_meetingmember", $message, $this->container, "", "", false, Utils::$systemmessage_code);
     }
 }
 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;
 }
Exemple #4
0
 public function setCovert($parameter)
 {
     $groupid = isset($parameter["groupid"]) ? $parameter["groupid"] : null;
     $jid = isset($parameter["jid"]) ? $parameter["jid"] : null;
     $state = isset($parameter["state"]) ? $parameter["state"] : "1";
     //默认为添加
     $success = true;
     $msg = "";
     if (empty($groupid)) {
         return Utils::WrapResultError('群编号不能为空');
     } else {
         if (empty($jid)) {
             return Utils::WrapResultError('设置的成员帐号不能为空');
         }
     }
     $sql = "";
     $para = array();
     if ($state == "1") {
         $sql = "insert into im_groupemployee_covert(groupid,jid)values(?,?);";
     } else {
         $sql = "delete from im_groupemployee_covert where groupid=? and jid=?;";
     }
     try {
         $this->conn_im->ExecSQL($sql, array((string) $groupid, (string) $jid));
         //向成员发送出席
         $user = $parameter["user"];
         $title = $state == "1" ? "set_covert" : "cancel_covert";
         $message = $state == "1" ? "设置了您的屏蔽群消息" : "取消了您的屏蔽群消息";
         Utils::sendImPresence($user->fafa_jid, $jid, $title, $message, $this->container, "", "", true, '', '0');
     } catch (\Exception $e) {
         $success = false;
         $msg = $state == "1" ? "设置屏蔽成员失败!" : "取消屏蔽成员失败!";
         return Utils::WrapResultError($e->getMessage());
     }
     return Utils::WrapResultOK('1');
 }
 public function savePcSyncAction(Request $request)
 {
     $session = $this->get('session');
     $filename120 = $session->get("avatar_big");
     $filename48 = $session->get("avatar_middle");
     $filename24 = $session->get("avatar_small");
     $user = $this->get('security.context')->getToken()->getUser();
     $dm = $this->get('doctrine.odm.mongodb.document_manager');
     if (!empty($filename120)) {
         $filename120 = $this->saveFile($filename120, $dm);
     }
     if (!empty($filename48)) {
         $filename48 = $this->saveFile($filename48, $dm);
     }
     if (!empty($filename24)) {
         $filename24 = $this->saveFile($filename24, $dm);
     }
     $session->remove("avatar_big");
     $session->remove("avatar_middle");
     $session->remove("avatar_small");
     $da = $this->get("we_data_access");
     $da_im = $this->get('we_data_access_im');
     $para["account"] = $user->getUsername();
     $table = $da->GetData("staff", "select nick_name,photo_path,photo_path_small,photo_path_big,fafa_jid from we_staff where login_account=?", array((string) $para["account"]));
     $oldRow = $table["staff"]["rows"][0];
     if (!empty($filename120)) {
         if ($table && $table["staff"]["recordcount"] > 0) {
             $this->removeFile($table["staff"]["rows"][0]["photo_path"], $dm);
             $this->removeFile($table["staff"]["rows"][0]["photo_path_small"], $dm);
             $this->removeFile($table["staff"]["rows"][0]["photo_path_big"], $dm);
         }
     }
     $old_nick_name = $oldRow["nick_name"];
     $Jid = $oldRow["fafa_jid"];
     $y = $request->get("dateYear");
     $birthday = empty($y) || $y == "0000" ? "" : $y . "-" . $request->get("dateMonth") . "-" . $request->get("dateDay");
     $nick_name = $request->get("txtname");
     if (empty($filename120)) {
         $sql = "update we_staff set nick_name=?,birthday=?,dept_id=?,work_phone=?,mobile=?,self_desc=?,specialty=?,hobby=?,hometown=?,graduated=?,work_his=?,sex_id=? where login_account=?";
         $paras[] = $nick_name;
         $paras[] = $birthday;
         $paras[] = $request->get("txtdeptid");
         $paras[] = $request->get("txtwork_phone");
         $paras[] = $request->get("txtmobile");
         $paras[] = $request->get("txtself_desc");
         $paras[] = $request->get("txtspecialty");
         $paras[] = $request->get("txthobby");
         $paras[] = $request->get("txthometown");
         $paras[] = $request->get("txtgraduated");
         $paras[] = $request->get("txtwork_his");
         $paras[] = $request->get("txtsex");
         $paras[] = $para["account"];
     } else {
         $sql = "update we_staff set nick_name=?,birthday=?,photo_path=?,photo_path_small=?,photo_path_big=?,dept_id=?,work_phone=?,mobile=?,self_desc=?,specialty=?,hobby=?,hometown=?,graduated=?,work_his=?,sex_id=?  where login_account=?";
         $paras[] = $nick_name;
         $paras[] = $birthday;
         $paras[] = $filename48;
         $paras[] = $filename24;
         $paras[] = $filename120;
         $paras[] = $request->get("txtdeptid");
         $paras[] = $request->get("txtwork_phone");
         $paras[] = $request->get("txtmobile");
         $paras[] = $request->get("txtself_desc");
         $paras[] = $request->get("txtspecialty");
         $paras[] = $request->get("txthobby");
         $paras[] = $request->get("txthometown");
         $paras[] = $request->get("txtgraduated");
         $paras[] = $request->get("txtwork_his");
         $paras[] = $request->get("txtsex");
         $paras[] = $para["account"];
     }
     try {
         if (empty($filename120)) {
             if ($table && $table["staff"]["recordcount"] > 0) {
                 $para["path"] = $this->container->getParameter('FILE_WEBSERVER_URL') . $table["staff"]["rows"][0]["photo_path_big"];
             } else {
                 $para["path"] = $this->get('templating.helper.assets')->geturl('bundles/fafatimewebase/images/no_photo.png');
             }
         } else {
             $para["path"] = $this->container->getParameter('FILE_WEBSERVER_URL') . $filename120;
             $friendevent = new \Justsy\BaseBundle\Management\FriendEvent($da, $this->get('logger'), $this->container);
             $friendevent->photochange($user->getUserName(), $user->nick_name);
         }
         try {
             $da->ExecSQL($sql, $paras);
         } catch (\Exception $ex) {
             $this->get("logger")->err("========保存人员资料时错误:" . $ex);
             $this->get("logger")->err("========保存人员资料时错误-SQL:" . $sql);
             $this->get("logger")->err("========保存人员资料时错误-DATA:" . $paras);
             Utils::sendImPresence("", "*****@*****.**", "保存人员资料时错误", "AccountController->savePcSyncAction:<br>" . $sql . "<br>" . $paras, $this->container);
         }
         //如果更改了姓名时,需要同步到im库中并更新相关引用
         if ($old_nick_name != $nick_name) {
             $da_im->ExecSQL("call emp_change_name(?,?)", array((string) $user->fafa_jid, (string) $nick_name));
         }
         //发送个人资料编辑通知
         try {
             //发送即时消息
             $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $da_im, $user);
             $message = "{\"path\":\"" . $para["path"] . "\",\"desc\":\"" . strtr($request->get("txtself_desc"), array("\"" => "“")) . "\"}";
             Utils::sendImPresence($user->fafa_jid, implode(",", $staffMgr->getFriendAndColleagueJid()), "staff-changeinfo", $message, $this->container, "", "", false, Utils::$systemmessage_code);
         } catch (\Exception $e) {
             $this->get('logger')->err($e);
         }
         $response = new Response("{\"succeed\":1,\"path\":\"" . $para["path"] . "\"}");
         $response->headers->set('Content-Type', 'text/json');
         return $response;
     } catch (\Exception $e) {
         //return $this->render('JustsyBaseBundle:login:index.html.twig', array('name' => 'err'));
         $response = new Response("{\"succeed\":0,\"e\":{$e}}");
         $response->headers->set('Content-Type', 'text/json');
         return $response;
     }
 }
 public function addEmployeeAction()
 {
     $request = $this->getRequest();
     $user = $this->get('security.context')->getToken()->getUser();
     //跟新字段
     $sex = $request->get("sex");
     $dept = $request->get("txtdeptid");
     $mobile = $request->get("mobile");
     $account = $request->get("account");
     $duty = $request->get("duty");
     $pass = $request->get("pass");
     $realName = $request->get("realName");
     if (empty($account)) {
         $response = new Response(json_encode(array('s' => 0, 'm' => '帐号不能为空')));
         $response->headers->set('Content-Type', 'text/json');
         return $response;
     }
     if (empty($pass)) {
         $response = new Response(json_encode(array('s' => 0, 'm' => '密码不能为空')));
         $response->headers->set('Content-Type', 'text/json');
         return $response;
     }
     $da = $this->get("we_data_access");
     $dm = $this->get("we_data_access_im");
     $sql = "select 1 from we_staff where login_account=?";
     $params = array($account);
     $ds = $da->Getdata('staff', $sql, $params);
     if ($ds['staff']['recordcount'] > 0) {
         $response = new Response(json_encode(array('s' => 0, 'm' => '用户已存在')));
         $response->headers->set('Content-Type', 'text/json');
         return $response;
     }
     $active = new \Justsy\BaseBundle\Controller\ActiveController();
     $active->setContainer($this->container);
     $success = 1;
     $msg = "";
     try {
         //自动注册
         $active->doSave(array('account' => $account, 'realName' => $realName, 'passWord' => $pass, 'eno' => $user->eno, 'ename' => $user->ename, 'isNew' => '0', 'mailtype' => "1", 'import' => '1', 'deptid' => $dept));
         $sql = "select 1 from we_staff where login_account=?";
         $params = array($account);
         $ds = $da->Getdata('staff', $sql, $params);
         if ($ds['staff']['recordcount'] > 0) {
             if (empty($mobile)) {
                 $sql = "update we_staff set sex_id=? where login_account=?";
                 $params = array($sex, $account);
             } else {
                 $sql = "update we_staff set mobile=?,mobile_bind=?,sex_id=? where login_account=?";
                 $params = array($mobile, $mobile, $sex, $account);
             }
             try {
                 $da->ExecSQL($sql, $params);
                 $dm->ExecSQL("call dept_emp_stat(?)", array((string) $user->eno));
                 //推送消息
                 $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $this->get("we_data_access_im"), $user);
                 Utils::sendImPresence($user->fafa_jid, implode(",", $staffMgr->getFriendAndColleagueJid()), "staff-changeinfo", "", $this->container, "", "", false, Utils::$systemmessage_code);
             } catch (\Exception $e) {
                 $log->err($e->getMessage());
             }
         } else {
             $success = 0;
             $msg = "添加失败!";
         }
     } catch (\Exception $e) {
         $this->get("logger")->err($e->getMessage());
         $success = 0;
         $msg = "添加失败!";
     }
     $result = array("s" => $success, "m" => $msg);
     $response = new Response(json_encode($result));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
 public function applyJoinAppAction()
 {
     $da = $this->get("we_data_access");
     $userinfo = $this->get('security.context')->getToken()->getUser();
     $eno = $userinfo->eno;
     $return = array("success" => true, "message" => "");
     try {
         $sql = "select sys_manager from we_enterprise where eno=?";
         $ds = $da->GetData("staff", $sql, array((string) $eno));
         if ($ds && $ds["staff"]["recordcount"] > 0) {
             $manager = $ds["staff"]["rows"][0]["sys_manager"];
             $request = $this->getrequest();
             $appid = $request->get("appid");
             $appname = $request->get("appname");
             $staffid = $userinfo->getUserName();
             $id = SysSeq::GetSeqNextValue($da, "we_app_developer", "id");
             $sql = "insert into we_app_developer(id,login_account,appid,agree)values(?,?,?,0)";
             $da->ExecSQL($sql, array((string) $id, (string) $staffid, (string) $appid));
             //向企业管理都或应用创建者发送消息
             $message = "申请访问" . $appname;
             Utils::sendImPresence($this->container->getParameter('im_sender'), $manager, "appdeveloper_apply", $message, $this->container, "", "", false, Utils::$systemmessage_code);
         } else {
             $return = array("success" => false, "message" => $e->getMessage());
         }
     } catch (\Exception $e) {
         $return = array("success" => false, "message" => $e->getMessage());
     }
     $result = new Response(json_encode($return));
     $result->headers->set('Content-Type', 'text/json');
     return $result;
 }
Exemple #8
0
 //判断群组是否有人
 $sql = "select count(1) as cnt from we_group_staff where group_id=?";
 $ds = $da->GetData('we_group_staff', $sql, array((string) $paraArr[0]));
 if ($ds && $ds['we_group_staff']['rows'][0]['cnt'] == 0) {
     $sql = "update we_groups set create_staff=? where group_id=?";
     $da->ExecSQL($sql, array((string) $paraArr[1], (string) $paraArr[0]));
 }
 $sql = "insert into we_group_staff (group_id,login_account) values (?,?)";
 $para = array((string) $paraArr[0], (string) $paraArr[1]);
 $da->ExecSQL($sql, $para);
 $backurl = $this->generateUrl("JustsyBaseBundle_group", array('network_domain' => $paraArr[2], 'group_id' => $paraArr[0]));
 $this->get("logger")->err("同意加入群");
 //变更版本信息
Exemple #9
0
 public function joinbycode($paraObj)
 {
     $currUser = $paraObj["user"];
     if (empty($currUser)) {
         return Utils::WrapResultError("请登录后重试", ReturnCode::$NOTLOGIN);
     }
     if ($currUser->eno != Utils::$PUBLIC_ENO) {
         return Utils::WrapResultError("你已加入企业");
     }
     $invitecode = $paraObj["invitecode"];
     if (empty($invitecode)) {
         return Utils::WrapResultError("邀请码不能为空");
     }
     //获取设置的邀请码过期小时数,默认为1小时
     //企业参数名称:invitecode_expire_hour
     $sys = new \Justsy\BaseBundle\DataAccess\SysParam($this->container);
     $hour = $sys->GetSysParam("invitecode_expire_hour");
     if (empty($hour)) {
         $hour = 1;
     }
     $sql = "select eno,review_staff from we_register where active_code=? and register_date>date_sub(now(),interval " . $hour . " hour)";
     $dataset = $this->da->GetData("t", $sql, array((string) $invitecode));
     if (count($dataset["t"]["rows"]) > 0) {
         $eno = $dataset["t"]["rows"][0]["eno"];
         if (empty($eno)) {
             return Utils::WrapResultError("邀请码已过期");
         }
         if ($currUser->eno == $eno) {
             return Utils::WrapResultError("你已经是该企业员工");
         }
         //消息通知
         $message = "你已成功加入企业";
         Utils::sendImPresence("", $currUser->fafa_jid, "enterprise_joinagree", $message, $this->container, "", "", false, '', '0');
         //加入企业
         $jid = SysSeq::GetSeqNextValue($this->da, "we_staff", "fafa_jid");
         $jid .= "-" . $eno . "@fafacn.com";
         $staffobj = new \Justsy\BaseBundle\Management\Staff($this->da, $this->container->get("we_data_access_im"), $currUser->getUsername(), $this->logger, $this->container);
         $tr = $staffobj->swtichEno($eno);
         //更换企业号
         if ($tr) {
             $staffobj->updateJid($currUser->fafa_jid, $jid);
         }
         //更新im库中的jid
         //申请人和邀请人成为好友
         $staffobj->bothAddFriend($this->container, $dataset["t"]["rows"][0]["review_staff"]);
         $newinfo = $staffobj->getInfo();
         $enodata = $this->getInfo($eno);
         return Utils::WrapResultOK($enodata);
     }
     return Utils::WrapResultError("无效的邀请码");
 }
 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;
 }
Exemple #11
0
 public function sendPresenceCirlce($circleid, $caption = "circle_addmember", $msg, $buttons = "", $excludeLst = null)
 {
     $sql = "select c.fafa_jid,c.login_account from we_circle_staff a,we_circle b,we_staff c where b.circle_id=a.circle_id and a.login_account=c.login_account and b.circle_id=? and c.fafa_jid is not null";
     $da = $this->get("we_data_access");
     $ds = $da->GetData("ims", $sql, array((string) $circleid));
     $staffArr = array();
     $len = count($ds["ims"]["rows"]);
     for ($i = 0; $i < $len; $i++) {
         if (!empty($excludeLst) && in_array($ds["ims"]["rows"][$i]["login_account"], $excludeLst)) {
             continue;
         }
         $staffArr[] = $ds["ims"]["rows"][$i]["fafa_jid"];
     }
     $sender = $this->container->getParameter('im_sender');
     $staffArr = null;
     $onlinejid = Utils::findonlinejid($this->get("we_data_access_im"), $staffArr);
     $jidArr = array();
     $len = count($onlinejid);
     for ($i = 0; $i < $len; $i++) {
         $jidArr[] = $onlinejid[$i];
         if ($i > 0 && $i % 5000 == 0) {
             Utils::sendImPresence($sender, implode(",", $jidArr), $caption, $msg, $this->container, "", $buttons, false, Utils::$systemmessage_code);
             $jidArr = array();
         }
     }
     if (count($jidArr) > 0) {
         Utils::sendImPresence($sender, implode(",", $jidArr), $caption, $msg, $this->container, "", $buttons, false, Utils::$systemmessage_code);
     }
 }
Exemple #12
0
 public function creategroupAction()
 {
     $re = array("returncode" => ReturnCode::$SUCCESS);
     $user = $this->get('security.context')->getToken()->getUser();
     $request = $this->getRequest();
     $circleid = $request->get("circle_id");
     $groupname = $request->get("group_name");
     $groupdesc = $request->get("group_desc");
     $joinmethod = $request->get("join_method", "0");
     $groupclassid = $request->get("group_class_id");
     $invitedmemebers = $request->get("invitedmemebers");
     $group_photo_path = $request->get("group_photo_path");
     $da = $this->get('we_data_access');
     $da_im = $this->get('we_data_access_im');
     $ec = new \Justsy\BaseBundle\Management\EnoParamManager($da, $this->get('logger'));
     try {
         if ($ec->IsBeyondCreateGroup($user->getUserName())) {
             $re["returncode"] = ReturnCode::$SYSERROR;
             $re["error"] = "创建群组数量已超过限制!";
             $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($circleid) || empty($groupname)) {
             $re["returncode"] = ReturnCode::$SYSERROR;
             $re["error"] = "参数传递错误!";
             $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 (!$this->hasGroup($da, $groupname)) {
             //根据typeid取出typename
             $sql = "select typename from im_grouptype where typeid=?";
             $ds = $da_im->GetData('im_grouptype', $sql, array($groupclassid));
             $typename = '';
             if ($ds['im_grouptype']["recordcount"] > 0) {
                 $typename = $ds["im_grouptype"]['rows'][0]["typename"];
             } else {
                 $typename = $groupclassid;
             }
             //注册fafa_group
             $sqls = array();
             $paras = array();
             $fafa_groupid = SysSeq::GetSeqNextValue($da_im, "im_group", "groupid");
             $sqls[] = "insert into im_group (groupid, groupname, groupclass, groupdesc, creator, add_member_method, accessright) \n\t\t\t        values (?, ?, ?, ?, ?, ?, 'any')";
             $paras[] = array((string) $fafa_groupid, (string) $groupname, (string) $typename, (string) $groupdesc, (string) $user->fafa_jid, (string) $joinmethod);
             $sqls[] = "insert into im_groupemployee (employeeid, groupid, employeenick, grouprole) values (?,?,?,'owner')";
             $paras[] = array((string) $user->fafa_jid, (string) $fafa_groupid, (string) $user->nick_name);
             //跟新群组版本号
             $sqls[] = "delete from im_group_version where us=?";
             $paras[] = array((string) $user->fafa_jid);
             $da_im->ExecSQLs($sqls, $paras);
             //保存图标
             $sqls = array();
             $paras = array();
             $groupId = SysSeq::GetSeqNextValue($da, "we_groups", "group_id");
             $sqls[] = "insert into we_groups (group_id,circle_id,group_name,group_desc,group_photo_path,join_method,create_staff,fafa_groupid,create_date, group_class)\n\t\t\t        values (?,?,?,?,?,?,?,?,now(),?)";
             $paras[] = array((string) $groupId, (string) $circleid, (string) $groupname, (string) $groupdesc, (string) $group_photo_path, (string) $joinmethod, (string) $user->getUserName(), (string) $fafa_groupid, (string) $groupclassid);
             $sqls[] = "insert into we_group_staff (group_id,login_account) values (?,?)";
             $paras[] = array((string) $groupId, (string) $user->getUserName());
             $da->ExecSQLs($sqls, $paras);
             //创建文档根目录
             $docCtl = new \Justsy\BaseBundle\Controller\DocumentMgrController();
             $docCtl->setContainer($this->container);
             if ($docCtl->createDir("g" . $groupId, "c" . $circleid, $groupname, $circleid) > 0) {
                 $docCtl->saveShare("g" . $groupId, "0", $groupId, "g", "w");
                 //将群目录共享给该群组成员
             }
             $im_sender = $this->container->getParameter('im_sender');
             //给创建者发送创建群组成功出席
             Utils::sendImPresence($im_sender, $user->fafa_jid, "creategroup", json_encode(array("groupid" => $fafa_groupid, "logoid" => $group_photo_path, "groupname" => $groupname)), $this->container, "", "", false, Utils::$systemmessage_code);
             //给邀请人员发送消息 站内和即时消息
             if (!empty($invitedmemebers)) {
                 $invitedmemebers = str_replace(";", ";", $invitedmemebers);
                 $invs = explode(";", $invitedmemebers);
                 $title = "邀请加入群组";
                 foreach ($invs as $key => $value) {
                     if (empty($value)) {
                         continue;
                     }
                     //群编号,被邀请人帐号,network_domain,fafa_groupid
                     $encode = DES::encrypt("{$groupId},{$value},{$circleid}," . $fafa_groupid);
                     $activeurl = $this->generateUrl("JustsyBaseBundle_group_invjoin", array('para' => $encode), true);
                     $txt = $this->renderView("JustsyBaseBundle:Group:message.html.twig", array("ename" => $user->ename, "realName" => $user->nick_name, "activeurl" => $activeurl, 'gname' => $groupname));
                     //发送站内消息
                     $msgId = SysSeq::GetSeqNextValue($da, "we_message", "msg_id");
                     $sql = "insert into we_message(msg_id,sender,recver,title,content,send_date)values(?,?,?,?,?,now())";
                     $da->ExecSQL($sql, array((int) $msgId, (string) $user->getUserName(), (string) $value, "邀请加入群组", $txt));
                     //发送即时消息
                     $fafa_jid = Utils::getJidByAccount($da, $value);
                     //$this->get("logger")->info(Utils::makeHTMLElementTag('employee',$user->fafa_jid,$user->nick_name));
                     $message = Utils::makeHTMLElementTag('employee', $user->fafa_jid, $user->nick_name) . "邀请您加入群组【" . Utils::makeHTMLElementTag('group', $fafa_groupid, $groupname) . "】";
                     $buttons = array();
                     $buttons[] = array("text" => "立即加入", "code" => "agree", "value" => "1");
                     $buttons[] = array("text" => "拒绝", "code" => "agree", "value" => "0");
                     Utils::sendImMessage($im_sender, $fafa_jid, $title, $message, $this->container, $activeurl . "?invite_user="******"1");
                 }
             }
             $re["group"] = $this->getGroup($da, $user, $circleid, $groupId);
             //变更版本信息
             $eno = $user->eno;
             $verchange = new \Justsy\BaseBundle\Management\VersionChange($da, $this->get("logger"));
             $result = $verchange->SetVersionChange(2, $groupId, $eno);
         } else {
             $re["returncode"] = ReturnCode::$SYSERROR;
             $re["error"] = "群组名称已存在!";
         }
     } catch (Exception $e) {
         $re["returncode"] = ReturnCode::$SYSERROR;
         $re["error"] = "系统错误,创建群组失败!";
         $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;
 }
Exemple #13
0
 public function setFriendByDept($deptid, $user = null)
 {
     //判断部门是否设置了自动好友
     $deptinfo = $this->getInfo($deptid);
     if ($deptinfo['friend'] != '1') {
         return;
     }
     $da = $this->conn_im;
     $friendLst = array();
     $success = true;
     $msg = "";
     if (!empty($user)) {
         $login_account = $user["login_account"];
         $fafa_jid = array(isset($user["fafa_jid"]) ? $user["fafa_jid"] : null);
         $staffMgr = new Staff($this->conn, $this->conn_im, $login_account, $this->container->get("logger"), $this->container);
         if (empty($fafa_jid)) {
             $user = $staffMgr->getInfo();
         }
         $friendLst = array(array("jid" => $user["fafa_jid"], "nick_name" => $user["nick_name"]));
     } else {
         $domain = $this->container->getParameter('edomain');
         $staffMgr = new Staff($this->conn, $this->conn_im, "admin@" . $domain, $this->container->get("logger"), $this->container);
         $sql = 'SELECT a.loginname jid,a.employeename nick_name FROM im_employee a where a.deptid=? and not exists(select jid from rosterdept where deptid=? and a.loginname=jid)';
         $ds = $da->GetData("t", $sql, array((string) $deptid, (string) $deptid));
         $friendLst = $ds["t"]["rows"];
     }
     $to_jid = array();
     $staffcount = count($friendLst);
     if ($staffcount == 0) {
         return array("success" => false, "message" => '该部门下没有人员,请进入子部门进行设置');
     }
     for ($i = 0; $i < $staffcount; $i++) {
         $fafa_jid = $friendLst[$i]["jid"];
         $nick_name = $friendLst[$i]["nick_name"];
         //判断是否已全部成为好友
         $sql = "SELECT a.loginname jid,a.employeename nick_name FROM im_employee a where a.deptid=? and not exists (select jid from rosterusers b where a.loginname=b.jid and b.username=? and b.subscription='B')";
         try {
             $ds_member = $da->GetData("member", $sql, array((string) $deptid, (string) $fafa_jid));
             if ($ds_member && count($ds_member["member"]["rows"] > 0)) {
                 if (!empty($user)) {
                     //如果是指定人员与部门人员成为好友,通知对象为部门中还未不是该人的帐号jid
                     for ($ic = 0; $ic < count($ds_member["member"]["rows"]); $ic++) {
                         array_push($to_jid, $ds_member["member"]["rows"][$ic]["jid"]);
                     }
                 }
                 $state = $staffMgr->DeptAddFriend($this->container, $deptid, $fafa_jid, $nick_name, $ds_member["member"]["rows"]);
             }
         } catch (\Exception $e) {
             $success = false;
             $msg = "设置部门人员互为好友出错!";
             $this->container->get("logger")->err($e->getMessage());
             return array("success" => $success, "message" => $msg);
         }
     }
     $to_jid = $this->getStaffJid($deptid);
     if (count($to_jid) > 0) {
         //获取在线帐号
         Utils::findonlinejid($da, $to_jid);
         //向成员发送出席
         $message = array('deptid' => $deptid);
         $msg = json_encode(Utils::WrapMessage('dept_friend', $message, array()));
         Utils::sendImPresence($fafa_jid, $to_jid, "dept_friend", $msg, $this->container, "", "", false, '', '0');
     }
     return array("success" => $success, "message" => $msg);
 }
Exemple #14
0
 public function modifyavatar($parameter)
 {
     $re = array("success" => true);
     $request = $this->container->getRequest();
     $user = $parameter["user"];
     $dm = $this->container->get('doctrine.odm.mongodb.document_manager');
     $da = $this->container->get("we_data_access");
     $da_im = $this->container->get("we_data_access_im");
     $login_account = $user->getUsername();
     $photofile = $_FILES['photofile']['tmp_name'];
     if (empty($photofile)) {
         $photofile = tempnam(sys_get_temp_dir(), "we");
         unlink($photofile);
         $somecontent1 = base64_decode($parameter['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 = $this->getInfo();
         if (!empty($table)) {
             Utils::removeFile($table["photo_path"], $dm);
             Utils::removeFile($table["photo_path_small"], $dm);
             Utils::removeFile($table["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\t        where login_account=?", array((string) $photofile_48, (string) $photofile, (string) $photofile_24, (string) $login_account));
         $da_im->ExecSQL("update im_employee set photo=? where loginname=?", array((string) $photofile, (string) $table["fafa_jid"]));
         $this->getInfo(true);
         $this->syncAttrsToIM();
         $message = json_encode(array('jid' => $user->fafa_jid, "path" => $this->container->getParameter('FILE_WEBSERVER_URL') . $photofile));
         Utils::sendImPresence($user->fafa_jid, implode(",", $this->getFriendJidList()), "staff-changeinfo", $message, $this->container, "", "", false, Utils::$systemmessage_code);
         $re["success"] = true;
         $re["fileid"] = $photofile;
         $re["photo_path"] = $photofile_48;
         $re["photo_path_big"] = $photofile;
         $re["photo_path_small"] = $photofile_24;
     } catch (\Exception $e) {
         $re["success"] = false;
         $this->get('logger')->err($e);
     }
     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 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 updateStaffAction()
 {
     $da = $this->get("we_data_access");
     $da_im = $this->get('we_data_access_im');
     $request = $this->getRequest();
     $state = $request->get("state");
     $im_deptid = $request->get("dept_id");
     //将im的部门id转化为sns里的部门id
     $deptInfo = $this->getDeptInfo($im_deptid);
     $sns_deptid = $deptInfo["deptid"];
     $login_account = $request->get("login_account");
     $e_mail = $request->get("e_mail");
     $nick_name = $request->get("nick_name");
     $password = $request->get("password");
     $sex = $request->get("sex");
     $duty = $request->get("duty");
     $duty = empty($duty) ? null : $duty;
     $mobile = $request->get("mobile");
     $mobile = empty($mobile) ? null : $mobile;
     $success = true;
     $msg = "";
     //判断手机号正误
     if (!empty($mobile)) {
         if (!Utils::validateMobile($mobile)) {
             $result = array("success" => false, "msg" => "手机账号格式错误!");
             $response = new Response(json_encode($result));
             $response->headers->set('Content-Type', 'text/json');
             return $response;
         } else {
             $sql = "";
             $para = array();
             if ($state == "add") {
                 $sql = "select count(*) number from we_staff where mobile_bind=?;";
                 array_push($para, (string) $mobile);
             } else {
                 $sql = "select count(*) number from we_staff where mobile_bind=? and login_account!=?;";
                 array_push($para, (string) $mobile, $login_account);
             }
             try {
                 $ds = $da->GetData("table", $sql, $para);
                 if ($ds && $ds["table"]["recordcount"] > 0) {
                     if ((int) $ds["table"]["rows"][0]["number"] > 0) {
                         $result = array("success" => false, "msg" => "已存在该手机号码!");
                         $response = new Response(json_encode($result));
                         $response->headers->set('Content-Type', 'text/json');
                         return $response;
                     }
                 }
             } catch (\Exception $e) {
                 $this->get("logger")->err($e->getMessage());
             }
         }
     }
     $user = $this->get('security.context')->getToken()->getUser();
     $deptMgr = new \Justsy\BaseBundle\Management\Dept($da, $da_im, $this->container);
     $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $da_im, $login_account, $this->container->get("logger"), $this->container);
     if ($state == "add") {
         if ($staffMgr->checkUser($mobile)) {
             $result = array("success" => false, "msg" => "用户账号已存在,请重新输入!");
             $response = new Response(json_encode($result));
             $response->headers->set('Content-Type', 'text/json');
             return $response;
         }
         //获得ldap_uid
         $login_array = explode("@", $login_account);
         if (count($login_array) < 2) {
             continue;
         }
         $ldap_uid = $login_array[0];
         //注册用户账号
         $register = new \Justsy\BaseBundle\Controller\ActiveController();
         $register->setContainer($this->container);
         $parameter = array("account" => $login_account, "realName" => $nick_name, "passWord" => $password, "ldap_uid" => $ldap_uid, "eno" => $user->eno, "ename" => $user->ename, "isNew" => '0', "mailtype" => "1", "import" => '1', "isSendMessage" => "N", "mobile" => $mobile, "duty" => $duty, "deptid" => $sns_deptid, "mutual" => "Y");
         $result = $register->doSave($parameter);
         if ($result["returncode"] == "0000") {
             $staffdata = $staffMgr->getInfo();
             //成功后统计人员
             $sql = "call dept_emp_stat(?)";
             $da_im->ExecSQL($sql, array((string) $staffdata["fafa_jid"]));
             //自动关注服务号
             $servicerMgr = new \Justsy\BaseBundle\Management\Service($this->container);
             $parameter = array("eno" => $user->eno, "deptid" => $im_deptid, "login_account" => $login_account);
             $servicerMgr->atten_service($parameter);
             $revJids = $staffMgr->getFriendAndColleagueJid();
             Utils::sendImMessage($user->fafa_jid, implode(",", $revJids), "newstaff", json_encode($staffMgr->getinfo()), $this->container, "", "", false, Utils::$systemmessage_code);
         } else {
             $success = false;
             $msg = "添加用户账号失败:" . $result["msg"];
         }
         $result = array("success" => $success, "msg" => $msg);
         $response = new Response(json_encode($result));
         $response->headers->set('Content-Type', 'text/json');
         return $response;
     } else {
         $staffinfo = $staffMgr->getInfo();
         $deptinfo = $deptMgr->getinfo($staffinfo["dept_id"]);
         //判断是否更改了性别
         if ($sex == $staffinfo["sex_id"]) {
             $sex = null;
         }
         //判断是否更改了职务
         if ($duty == $staffinfo["duty"]) {
             $duty = null;
         }
         //判断是否更改了姓名
         if ($nick_name == $staffinfo["nick_name"]) {
             $nick_name = null;
         }
         //判断是否更新了部门
         if ($sns_deptid == $deptinfo["dept_id"]) {
             $sns_deptid = null;
         }
         //判断是否更新了手机
         if ($mobile == $staffinfo["mobile_bind"]) {
             $mobile = null;
         }
         $uResult = $staffMgr->checkAndUpdate($nick_name, $mobile, $sns_deptid, $duty, null, $sex, null, $e_mail);
         $u_staff = null;
         $factory = null;
         //判断是否修改了密码
         if (!empty($password)) {
             $u_staff = new Staff($da, $da_im, $login_account, $this->get('logger'), $this->container);
             $factory = $this->get('security.encoder_factory');
             $targetStaffInfo = $u_staff->getInfo();
             $re = $u_staff->changepassword($targetStaffInfo["login_account"], $password, $factory);
             if ($re) {
                 //给自己发送一个staff-changepasswod的出席,通知在线客户端密码发生修改,需要新密码重新登录
                 Utils::sendImPresence($user->fafa_jid, $targetStaffInfo["fafa_jid"], "staff-changepasswod", "staff-changepasswod", $this->container, "", "", false, Utils::$systemmessage_code);
             }
         }
         //判断是否修改了帐号
         if ($e_mail != $login_account) {
             //判断邮件是否存在
             if (empty($u_staff)) {
                 $u_staff = new Staff($da, $da_im, $login_account, $this->get('logger'), $this->container);
             }
             if (empty($factory)) {
                 $factory = $this->get('security.encoder_factory');
             }
             $u_staff->changeLoginAccount($e_mail, $factory);
         }
         try {
             $revJids = $staffMgr->getFriendAndColleagueJid();
             if ($uResult && !empty($sns_deptid)) {
                 //部门变更时,需要通知手机端更新原部门和新部门数据
                 Utils::sendImMessage("", implode(",", $revJids), "staff-changedept", json_encode($deptinfo), $this->container, "", "", false, Utils::$systemmessage_code);
                 Utils::sendImMessage("", implode(",", $revJids), "staff-changedept", json_encode($deptMgr->getinfo($sns_deptid)), $this->container, "", "", false, Utils::$systemmessage_code);
                 $old_fafa_deptid = $deptinfo["fafa_deptid"];
                 $fafa_jid = $staffinfo["fafa_jid"];
                 //取消关注服务号
                 $servicerMgr = new \Justsy\BaseBundle\Management\Service($this->container);
                 $parameter = array("eno" => $user->eno, "deptid" => $old_fafa_deptid, "login_account" => $login_account);
                 $servicerMgr->cancel_atten($parameter);
                 //自动关注服务号
                 $parameter = array("eno" => $user->eno, "deptid" => $im_deptid, "login_account" => $login_account);
                 $servicerMgr->atten_service($parameter);
             }
         } catch (\Exception $e) {
             $this->get("logger")->err($e->getMessage());
             $success = false;
             $msg = "修改人员信息失败!";
         }
     }
     $result = array("success" => $success, "msg" => $msg);
     $response = new Response(json_encode($result));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
 public function UserAgreeAction()
 {
     $da = $this->get('we_data_access');
     $da_im = $this->get('we_data_access_im');
     $logger = $this->get('logger');
     $request = $this->getRequest();
     $apply_id = $request->get('apply_id');
     $re = $request->get('re');
     $user = $this->get('security.context')->getToken()->getUser();
     $r = array('s' => 1, 'm' => '');
     try {
         //验证是否能审核
         $sql = "select result,is_valid from we_apply where id=?";
         $params = array($apply_id);
         $ds = $da->Getdata('info', $sql, $params);
         if ($ds['info']['recordcount'] == 0) {
             $r = array('s' => 0, 'm' => '该条审核记录已失效');
         } else {
             if ($ds['info']['rows'][0]['is_valid'] == '0') {
                 $r = array('s' => 0, 'm' => '你已经审核过了!');
             }
         }
         if ($r['s'] == '1') {
             //同意人数
             $sql = "select a.content,a.account,b.openid,b.fafa_jid from we_apply a left join we_staff b on b.login_account=a.account where a.id=?";
             $params = array($apply_id);
             $ds = $da->Getdata('content', $sql, $params);
             if ($ds['content']['recordcount'] > 0) {
                 $content = $ds['content']['rows'][0]['content'];
                 $account = $ds['content']['rows'][0]['account'];
                 $acc_openid = $ds['content']['rows'][0]['openid'];
                 $acc_jid = $ds['content']['rows'][0]['fafa_jid'];
                 $num = (int) $content;
                 $sql2[] = "select 1 from we_apply where account=? and recv_type='p' and result='1'";
                 $sql2[] = "select distinct recv_id from we_apply where account=? and recv_type='p' and result='0'";
                 $sql2[] = "select distinct recv_id from we_apply where account=? and recv_type='p'";
                 $params2[] = array($account);
                 $params2[] = array($account);
                 $params2[] = array($account);
                 $ds = $da->GetDatas(array('agreenum', 'confictnum', 'allnum'), $sql2, $params2);
                 $n = $ds['agreenum']['recordcount'];
                 $m = $ds['confictnum']['recordcount'];
                 $allnum = $ds['allnum']['recordcount'];
                 if ($re == '1') {
                     $n++;
                 }
                 if ($re == '0') {
                     $m++;
                 }
                 //更新审核结果
                 $sql1[] = "update we_apply set result=?,is_valid='0' where id=? and (result is null or result='') and is_valid='1'";
                 $params1[] = array($re, $apply_id);
                 if ($num <= $n) {
                     $sql1[] = "update we_staff set auth_level=? where login_account=?";
                     $params1[] = array($user->eno_level, $account);
                     if ($user->edomain == $user->eno) {
                         $sql = "select 1 from we_public_domain where LOCATE(domain_name,?)=0 and not exists(select 1 from we_enterprise where edomain=?)";
                         $params = array($account, $this->getSubDomain($account));
                         $ds = $da->Getdata('acc', $sql, $params);
                         if ($ds['acc']['recordcount'] > 0) {
                             $sql1[] = "update we_enterprise set edomain=? where eno=?";
                             $params1[] = array($this->getSubDomain($account), $user->eno);
                             $sql1[] = "update we_enterprise_stored set eno_mail=? where enoname=?";
                             $params1[] = array($account, $user->ename);
                             $sql1[] = "update we_circle set network_domain=? where enterprise_no=?";
                             $params1[] = array($this->getSubDomain($account), $user->eno);
                         }
                     }
                     //写入消息
                     $msg_id = SysSeq::GetSeqNextValue($da, "we_message", "msg_id");
                     $msg = "您已通过身份认证,现在就可以正常使用Wefafa平台了!";
                     $sql1[] = "insert into we_message (msg_id,sender,recver,title,content,send_date) values(?,?,?,?,?,now())";
                     $params1[] = array($msg_id, '*****@*****.**', $account, '用户认证协助审核', $msg);
                 }
                 if ($allnum - $m < $num) {
                     //写入消息
                     $msg_id = SysSeq::GetSeqNextValue($da, "we_message", "msg_id");
                     $msg = "您的身份认证申请未通过审核。";
                     $sql1[] = "insert into we_message (msg_id,sender,recver,title,content,send_date) values(?,?,?,?,?,now())";
                     $params1[] = array($msg_id, '*****@*****.**', $account, '用户认证协助审核', $msg);
                 }
                 if (!$da->ExecSQLs($sql1, $params1)) {
                     $r = array('s' => 0, 'm' => '系统错误');
                 }
                 if ($r['s'] == '1') {
                     //通知申请人审核结果
                     //Utils::sendImMessage($user->openid,$acc_openid,"用户身份认证",$user->nick_name.($re=='1'?"通过了您的加入请求。":"拒绝了您的加入请求。"),$this->container,"","",true,Utils::$systemmessage_code);
                     if ($num <= $n) {
                         //同步权限到Rbac
                         $staffRole = new StaffRole($da, $da_im, $this->get('logger'));
                         /*
                         if($user->vip_level!='0')
                         	$staffRole->UpdateStaffRoleByCode($account,(Identify::$SIdent).($user->vip_level),(Identify::$BIdent).($user->vip_level),$user->eno);
                         else
                         	$staffRole->UpdateStaffRoleByCode($account,(Identify::$SIdent).($user->vip_level),(Identify::$MIdent).($user->vip_level),$user->eno);
                         */
                         $staffRole->UpdateStaffRoleByCode($account, Identify::$SIdent . $user->vip_level, $user->eno_level . $user->vip_level, $user->eno);
                         //通知申请人权限已通过
                         Utils::sendImMessage('', $acc_openid, "用户身份认证", "您的身份认证申请已被审核通过。", $this->container, "", "", true, Utils::$systemmessage_code);
                         //发送出席
                         Utils::sendImPresence('', $acc_jid, "用户身份认证", "您的身份认证申请已被审核通过。", $this->container, "", "", false, Utils::$eno_identify_auth);
                     } else {
                         if ($allnum - $m < $num) {
                             //通知申请人权限已通过
                             Utils::sendImMessage('', $acc_openid, "用户身份认证", "您的身份认证申请未通过审核。", $this->container, "", "", true, Utils::$systemmessage_code);
                         }
                     }
                 }
             }
         }
     } catch (\Exception $e) {
         $this->get('logger')->err($e);
         $r = array('s' => 0, 'm' => '审核出现错误');
     }
     $desc = "";
     $title = "";
     if ($r['s'] == '0') {
         $title = "提交失败";
         $desc = $r['m'];
     } else {
         $title = "提交成功";
         $desc = "您的审核结果已经提交成功,谢谢你的配合。";
     }
     $home = $this->container->getParameter('open_api_url');
     return $this->render("JustsyBaseBundle:IdentifyAuth:verify_success.html.twig", array('desc' => $desc, 'home' => $home, 'title' => $title));
 }