예제 #1
0
 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;
 }
예제 #2
0
 public function commit($parameters)
 {
     if (empty($parameters)) {
         $result = Utils::WrapResultError("无效的数据");
         return $result;
     }
     $currUser = $parameters["user"];
     if (empty($currUser)) {
         return Utils::WrapResultError("请登录后重试", ReturnCode::$NOTLOGIN);
     }
     $audit_staffs = $parameters["audit_staffs"];
     //审批人。多个审批人使用;分隔
     if (empty($audit_staffs)) {
         return Utils::WrapResultError("审批人不能为空");
     }
     $wfl = new \Justsy\BaseBundle\Business\WeWorkflow($this->container);
     try {
         $content = $currUser->nick_name . "申请请假" . $parameters["days"] . "天";
         //创建新流程
         $result = $wfl->createWorkflow(array("appid" => $parameters["appid"], "user" => $currUser, "to" => $audit_staffs, "wf_name" => "请假申请", "wf_content" => $content, "wf_type" => $wf_type, "attachment" => $parameters["attachment"]));
         if (!empty($result)) {
             try {
                 //写业务表
                 $apply_id = SysSeq::GetSeqNextValue($this->conn, "we_app_apply_leave", "id");
                 $sql = "insert into we_app_apply_leave(id,wf_id,leavetype,start_date,end_date,days,reason,create_datetime,staff,eno,appid)values(?,?,?,?,?,?,?,now(),?,?,?)";
                 $this->conn->ExecSQL($sql, array((string) $apply_id, (string) $result["wf_id"], (string) $parameters["leavetype"], (string) $parameters["start_date"], (string) $parameters["end_date"], (double) $parameters["days"], (string) $parameters["reason"], (string) $currUser->getUserName(), (string) $currUser->eno, (string) $parameters["appid"]));
             } catch (\Exception $e) {
                 $wfl->removeWorkflow(array("wf_id" => $result["wf_id"]));
                 throw new \Exception($e);
             }
             //获取审批人的jid
             $to = explode(";", $audit_staffs);
             $tojids = array();
             for ($i = 0; $i < count($to); $i++) {
                 $staff = new Staff($this->conn, $this->conn_im, $to[$i], $this->logger, $this->container);
                 $staffdata = $staff->getInfo();
                 if (empty($staffdata)) {
                     continue;
                 }
                 $tojids[] = $staffdata["fafa_jid"];
             }
             //向审批人发送消息
             Utils::sendImMessage("", $tojids, "bus_apply", json_encode($re), $this->container, "", "", false, '', '0');
         }
         return $result;
     } catch (\Exception $e) {
         $this->logger->err($e);
         $result = Utils::WrapResultError($e->getMessage());
     }
     return $result;
 }
예제 #3
0
 public function __construct($_db, $_db_im, $user, $_logger, $container)
 {
     $this->conn = $_db;
     $this->conn_im = $_db_im;
     //$this->user = $user;
     if (is_string($user)) {
         //$this->account=$user;
         $staff = new Staff($_db, $_db_im, $user, $_logger);
         $this->user = $staff->getSessionUser();
     } else {
         $this->user = $user;
     }
     $this->container = $container;
 }
예제 #4
0
 public function saveAction()
 {
     $reslt = array();
     $request = $this->get("request");
     $uid = isset($_SESSION["uid"]) ? $_SESSION["uid"] : "";
     if (empty($uid)) {
         $reslt["s"] = "0";
         $reslt["msg"] = "微博登录失败或超时,请重新通过微博登录!";
         $response = new Response(json_encode($reslt));
         $response->headers->set('Content-Type', 'text/json');
         return $response;
     }
     $type = $request->get("bind_type");
     $login_account = $request->get("login_account");
     $pwd = $request->get("pwd");
     try {
         //校验wefafa帐号和密码
         $staffMgr = new Staff($this->get('we_data_access'), null, $login_account, $this->get('logger'));
         $staffInfo = $staffMgr->getInfo();
         if (empty($staffInfo)) {
             $reslt["s"] = "0";
             $reslt["msg"] = "帐号[" . $login_account . "]不存在!";
         } else {
             $tcode = $staffInfo["t_code"];
             $p_code = DES::encrypt($pwd);
             if ($tcode != $p_code) {
                 $reslt["s"] = "0";
                 $reslt["msg"] = "帐号或密码不正确!";
             } else {
                 $accountbind = new \Justsy\BaseBundle\Management\StaffAccountBind($this->get('we_data_access'), null, $this->get('logger'));
                 $r = $accountbind->Bind($type, "", $login_account, $uid);
                 $this->get('logger')->err($type . "," . $uid . "," . $login_account . "," . $uid);
                 $reslt["s"] = $r;
             }
         }
     } catch (\Exception $e) {
         $this->get('logger')->err($e);
         $reslt["s"] = "0";
         $reslt["msg"] = "绑定失败,请检查帐号是否填写正确!";
     }
     $response = new Response(json_encode($reslt));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
예제 #5
0
 public function n($parameters)
 {
     if (is_string($parameters)) {
         $parameters = explode("\\", $parameters);
     }
     if (count($parameters) == 0) {
         return Utils::WrapResultError("无效的login_account参数");
     }
     $login_account = $parameters[0];
     if (empty($login_account)) {
         return Utils::WrapResultError("无效的login_account参数");
     }
     $staffMgr = new Staff($this->conn, $this->conn_im, $login_account, $this->logger, $this->container);
     $staffdata = $staffMgr->getInfo();
     if (empty($staffdata)) {
         return Utils::WrapResultError("未查找到人员信息");
     }
     return Utils::WrapResultOK(array('code' => 'n', 'data' => $staffdata));
 }
예제 #6
0
 public function DeleteStaffRoleAction()
 {
     $request = $this->getRequest();
     $conn = $this->get("we_data_access");
     $conn_im = $this->get("we_data_access_im");
     $currUser = $this->get('security.context')->getToken();
     if (!empty($currUser)) {
         $currUser = $currUser->getUser();
     } else {
         //当应用通过api接口调用时,不用登录,只能通过openid获取人员信息
         $baseinfoCtl = new Staff($conn, null, $request->get("openid"), $this->get("logger"));
         $currUser = $baseinfoCtl->getSessionUser();
     }
     $rolecode = $request->get("rolecode");
     $staffRole = new StaffRole($conn, $conn_im, $this->get("logger"));
     $re = $staffRole->DeleteStaffRoleByCode($currUser->getUsername(), $rolecode, $currUser->getEno());
     $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
예제 #7
0
 public function attenUserAction()
 {
     $code = ReturnCode::$SUCCESS;
     $msg = '';
     try {
         $user = $this->get('security.context')->getToken()->getUser();
         $request = $this->getRequest();
         $login_account = $request->get('atten_account');
         $da = $this->get('we_data_access');
         $da_im = $this->get('we_data_access_im');
         $staff = new Staff($da, $da_im, $user->getUserName());
         $staff->attentionTo($login_account);
     } catch (\Exception $e) {
         $this->get('logger')->err($e);
         $msg = '系统错误';
         $code = ReturnCode::$SYSERROR;
     }
     $re = array('returncode' => $code, 'msg' => $msg);
     $response = new Response(json_encode($re));
     $response->headers->set('Content-Type', 'Application/json');
     return $response;
 }
 public function importEmployeeAction($network_domain)
 {
     $request = $this->get("request");
     $user = $this->get('security.context')->getToken()->getUser();
     //判断当前导入人员是否是企业邮箱
     $userDomain = explode("@", $user->getUserName());
     $da = $this->get("we_data_access");
     $sql = "select 1 from we_public_domain where domain_name=?";
     $ds = $da->GetData("mt", $sql, array((string) $userDomain[1]));
     $mailType = count($ds["mt"]["rows"]) > 0 ? "0" : "1";
     //1表示是企业邮箱
     try {
         $upfile = $request->files->get("filedata");
         $tmpPath = $upfile->getPathname();
         $oldName = $upfile->getClientOriginalName();
         $fixs = explode(".", strtolower($oldName));
         if (count($fixs) < 2) {
             $re = array('s' => 0, 'message' => "文件类型不正确");
         } else {
             $fixedType = $fixs[count($fixs) - 1];
             if ($fixedType != "xlsx" && $fixedType != "xls") {
                 $re = array('s' => 0, 'message' => "文件类型不正确");
             } else {
                 $newFileName = $user->openid . date('y-m-d-H-m-s') . "." . $fixedType;
                 if (move_uploaded_file($tmpPath, 'upload/' . $newFileName)) {
                     $da = $this->container->get('we_data_access');
                     $objReader = \PHPExcel_IOFactory::createReader($fixedType == "xlsx" ? 'Excel2007' : "Excel5");
                     //use excel2007 for 2007 format
                     $objPHPExcel = $objReader->load($_SERVER['DOCUMENT_ROOT'] . '/upload/' . $newFileName);
                     $objWorksheet = $objPHPExcel->getActiveSheet();
                     $highestRow = $objWorksheet->getHighestRow();
                     $highestColumn = $objWorksheet->getHighestColumn();
                     $highestColumnIndex = \PHPExcel_Cell::columnIndexFromString($highestColumn);
                     //总列数
                     //获取标题行
                     $titleAry = array();
                     $account_index = 0;
                     $name_index = 0;
                     $mobile_index = 0;
                     $duty_index = 0;
                     $dept_index = 0;
                     $pwd_index = 0;
                     for ($row = 0; $row <= 1; $row++) {
                         for ($col = 0; $col < $highestColumnIndex; $col++) {
                             $titleAry[$col] = $objWorksheet->getCellByColumnAndRow($col, $row)->getValue();
                             if (strpos($titleAry[$col], "邮箱") !== false) {
                                 $account_index = $col;
                             } else {
                                 if (strpos($titleAry[$col], "姓名") !== false) {
                                     $name_index = $col;
                                 } else {
                                     if (strpos($titleAry[$col], "手机") !== false) {
                                         $mobile_index = $col;
                                     } else {
                                         if (strpos($titleAry[$col], "职务") !== false) {
                                             $duty_index = $col;
                                         } else {
                                             if (strpos($titleAry[$col], "部门") !== false) {
                                                 $dept_index = $col;
                                             } else {
                                                 if (strpos($titleAry[$col], "密码") !== false) {
                                                     $pwd_index = $col;
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     $dm = $this->get("we_data_access_im");
                     $titleAry[] = "eno";
                     $err_list = array();
                     $active = new \Justsy\BaseBundle\Controller\ActiveController();
                     $active->setContainer($this->container);
                     //获取数据行
                     for ($row = 2; $row <= $highestRow; $row++) {
                         $strs = array();
                         for ($col = 0; $col < $highestColumnIndex; $col++) {
                             $strs[$col] = trim((string) $objWorksheet->getCellByColumnAndRow($col, $row)->getValue());
                         }
                         $strs[] = $user->eno;
                         $name = $strs[$name_index];
                         if (empty($name)) {
                             $err_list[] = array("name" => "", "row" => $row, "msg" => "姓名不能为空");
                             continue;
                         }
                         if (strlen($name) == 1) {
                             $err_list[] = array("name" => "", "row" => $row, "msg" => "姓名不能少于2个字符");
                             continue;
                         }
                         //获取填写的帐号
                         $account = $strs[$account_index];
                         if (empty($account)) {
                             $err_list[] = array("name" => $name, "row" => $row, "msg" => "邮箱帐号不能为空");
                             continue;
                         }
                         if (!Utils::validateEmail($account)) {
                             $err_list[] = array("name" => $name, "row" => $row, "msg" => "邮箱帐号格式不正确");
                             continue;
                         }
                         $staffmgr = new Staff($this->get("we_data_access"), $this->get("we_data_access_im"), $account);
                         if ($staffmgr->checkNickname($user->eno, $name) === true) {
                             $err_list[] = array("name" => "", "row" => $row, "msg" => "[" . $name . "]已经注册,请检查!");
                             continue;
                         }
                         //if($mailType=="1" && explode("@",$account)[1]!=$userDomain[1] )
                         //{
                         //	 $err_list[]=array("name"=>$name,"row"=>($row),"msg"=>"不允许导入公共邮箱$account");
                         //   continue;
                         //}
                         $mobile = $strs[$mobile_index];
                         if (!empty($mobile)) {
                             if (!Utils::validateMobile($mobile)) {
                                 $err_list[] = array("name" => $name, "row" => $row, "msg" => "手机号码格式不正确");
                                 continue;
                             }
                         }
                         //判断帐号是否已经注册
                         $isexist = $staffmgr->isExist($mobile);
                         if (!empty($isexist)) {
                             //已注册
                             $err_list[] = array("name" => $name, "msg" => "邮箱或手机号已被使用");
                             continue;
                         }
                         //判断是否已导入,已导入,则不再发邮件
                         $isImport = false;
                         try {
                             $isImport = $staffmgr->getImportInfo();
                         } catch (\Exception $err) {
                         }
                         try {
                             $staffmgr->importReg($titleAry, $strs);
                             //判断是否设置了密码
                             $pwd = $strs[$pwd_index];
                             if (!empty($pwd)) {
                                 $sql = "select ename from we_enterprise where eno=?";
                                 $ds = $da->GetData("t", $sql, array((string) $user->eno));
                                 //自动激活
                                 $active = new \Justsy\BaseBundle\Controller\ActiveController();
                                 $active->setContainer($this->container);
                                 $active->doSave(array('account' => $account, 'realName' => $name, 'passWord' => $pwd, 'eno' => $user->eno, 'ename' => $user->ename, 'eshortname' => $user->eshortname, 'isNew' => '0', 'mailtype' => "1", 'isSendMessage' => "N", 'import' => '1'));
                                 $dm->ExecSQL("call dept_emp_stat(?)", array((string) $user->eno));
                                 $staffmgr = new Staff($da, $dm, $account);
                                 $importData = $staffmgr->getImportInfo();
                                 $staffmgr->updateByImport($importData);
                                 $staffmgr->deleteImportPhy();
                             } else {
                                 if ($isImport === false) {
                                     if ($active->doSave(array('account' => $account, 'passWord' => empty($mobile) ? $account : $mobile, 'realName' => $name, 'eno' => $user->eno, 'ename' => $user->ename, 'eshortname' => $user->eshortname, 'isNew' => '0', 'mailtype' => "1", 'isSendMessage' => "N", 'import' => '1'))) {
                                         $staffmgr = new Staff($da, $dm, $account);
                                         //根据导入信息更新注册信息
                                         $importData = $staffmgr->getImportInfo();
                                         $staffmgr->updateByImport($importData);
                                         $staffmgr->deleteImportPhy();
                                     }
                                 } else {
                                     $err_list[] = array("name" => $name, "msg" => "注册失败!");
                                 }
                             }
                         } catch (\Exception $err) {
                             //写导入数据发生异常
                             $err_list[] = array("name" => $name, "msg" => "导入失败:" . $err->getMessage());
                             continue;
                         }
                     }
                     $re = array('s' => 1, 'error_list' => $err_list);
                 } else {
                     $re = array('s' => 0, 'message' => "文件上传失败");
                 }
                 try {
                     unlink($tmpPath);
                 } catch (\Exception $e) {
                 }
             }
         }
     } catch (\Exception $ex) {
         $re = array('s' => 0, 'message' => "导入失败");
     }
     $response = new Response("<script>parent.import_callback(" . json_encode($re) . ")</script>");
     $response->headers->set('Content-Type', 'text/html');
     return $response;
 }
예제 #9
0
 public function delete_service($parameter)
 {
     $micro_id = $parameter["micro_id"];
     $login_account = $parameter["login_account"];
     $user = $parameter["user"];
     $MicroAccountMgr = new Staff($this->conn, $this->conn_im, $login_account, $this->container->get("logger"), $this->container);
     $data = $MicroAccountMgr->getInfo();
     if (empty($data)) {
         return array("success" => false);
     }
     $MicroAccountMgr = new MicroAccountMgr($this->conn, $this->conn_im, $login_account, $this->container->get("logger"), $this->container);
     $dataexec = $MicroAccountMgr->removeByID($micro_id);
     $success = true;
     if ($dataexec === false) {
         $success = false;
     } else {
         $sqls = array();
         $paras = array();
         $sqls[] = "delete from im_microaccount_msg where microaccount=?";
         $paras[] = array((string) $data["fafa_jid"]);
         $sqls[] = "delete from im_microaccount_memebr where microaccount=?";
         $paras[] = array((string) $data["fafa_jid"]);
         $this->conn_im->ExecSQLS($sqls, $paras);
         $sql = "delete from we_service where login_account=?;";
         try {
             $this->conn->ExecSQL($sql, array((string) $login_account));
         } catch (\Exception $e) {
             $this->container->get("logger")->err($e->getMessage());
             return Utils::WrapResultError($e->getMessage());
         }
     }
     return Utils::WrapResultOK("");
 }
예제 #10
0
 public function importActiveSaveAction()
 {
     $request = $this->get("request");
     $account = trim($request->get("account"));
     $passWord = trim($request->get("passWord"));
     if (empty($account) || empty($passWord)) {
         return $this->render('JustsyBaseBundle:Error:index.html.twig', array('error' => "帐号或者密码不能为空"));
     }
     $staffmgr = new Staff($this->get("we_data_access"), $this->get("we_data_access_im"), $account);
     $isexist = $staffmgr->isExist();
     if ($isexist != null) {
         return $this->render('JustsyBaseBundle:Error:index.html.twig', array('error' => "帐号已可以正常使用"));
     }
     try {
         $importData = $staffmgr->getImportInfo();
         ////判断帐号、姓名、手机是否重复或已使用
         $arrayName = array((string) $importData["login_account"], (string) $importData["eno"], (string) $importData["nick_name"]);
         $sql = "select  (select nick_name from we_staff where login_account=?) accountcheck ,";
         $sql = $sql . "  (select nick_name from we_staff where eno=? and nick_name=?) namecheck ";
         $mobileNO = trim($importData["mobile"]);
         if (!empty($mobileNO)) {
             $sql = $sql . " ,(select nick_name from we_staff where mobile=?) mobilecheck ";
             $arrayName[] = (string) $mobileNO;
         }
         $da = $this->get("we_data_access");
         $ds = $da->getdata("t", $sql, $arrayName);
         if ($ds) {
             $dr = $ds["t"]["rows"][0];
             if (!empty($dr["accountcheck"])) {
                 if ($dr["accountcheck"] == $importData["nick_name"]) {
                     throw new \Exception("您的帐号的已激活,可以正常使用。");
                 } else {
                     throw new \Exception("该帐号已被" . $dr["accountcheck"] . "使用!");
                 }
             } else {
                 if (!empty($dr["namecheck"])) {
                     throw new \Exception("姓名已存在,不能重复激活!");
                 } else {
                     if (!empty($dr["mobilecheck"])) {
                         throw new \Exception("手机号已被" . $dr["mobilecheck"] . "使用,请使用其他有效手机号码注册!");
                     }
                 }
             }
         }
         //激活人员帐号
         $sdo = new \Justsy\BaseBundle\Controller\ActiveController();
         $sdo->setContainer($this->container);
         $sdo->doSaveAction();
         //根据导入信息更新注册信息
         $staffmgr->updateByImport($importData);
         $staffmgr->deleteImportPhy();
     } catch (\Exception $e) {
         $this->get("logger")->err($e);
         return $this->render('JustsyBaseBundle:Error:index.html.twig', array('error' => $e->getMessage()));
     }
     $data = $staffmgr->getInfo();
     $data["t_code"] = substr($passWord, 0, 1) . "******" . substr($passWord, -1);
     $data["password"] = $passWord;
     return $this->render('JustsyBaseBundle:Active:import_succeed.html.twig', array('edomain' => $data["eno"], 'data' => $data));
 }
예제 #11
0
 public function updatepasswordAction()
 {
     //判断请求域。是wefafa或子域则不验证授权令牌
     $isWeFaFaDomain = $this->checkWWWDomain();
     $res = $this->get("request");
     $da = $this->get("we_data_access");
     $opneid = $res->get("staff");
     $newpass = $res->get("newpass");
     $factory = $this->get('security.encoder_factory');
     $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $this->get("we_data_access_im"), $opneid);
     $staffMgr->changepassword($opneid, $newpass, $factory);
     $re = array();
     $re["returncode"] = "0000";
     $response = new Response($res->get('jsoncallback') ? $res->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
예제 #12
0
 public function push_receiverlistAction()
 {
     $da = $this->get("we_data_access");
     $da_im = $this->get('we_data_access_im');
     $request = $this->getRequest();
     //访问权限校验
     $api = new \Justsy\OpenAPIBundle\Controller\ApiController();
     $api->setContainer($this->container);
     $isWeFaFaDomain = $api->checkWWWDomain();
     if (!$isWeFaFaDomain) {
         $token = $api->checkAccessToken($request, $da);
         if (!$token) {
             $re = array("returncode" => "9999");
             $re["code"] = "err0105";
             $re["msg"] = "参数Appid或Openid或Access_token未指定或无效.";
             return $this->responseJson($request, $re);
         }
     }
     $openid = $request->get("openid");
     $staffinfo = new \Justsy\BaseBundle\Management\Staff($da, $da_im, $openid, $this->get("logger"), $this->container);
     $staffdata = $staffinfo->getInfo();
     if (empty($staffdata)) {
         $result = Utils::WrapResultError("无效操作帐号");
         return $this->responseJson($request, $result);
     }
     $appid = $request->get('appid');
     $appmgr = new \Justsy\BaseBundle\Management\App($this->container);
     $appdata = $appmgr->getappinfo(array('appid' => $appid));
     if (empty($appdata)) {
         $result = Utils::WrapResultError("无效应用标识");
         return $this->responseJson($request, $result);
     }
     $data = $request->get("data");
     //部门名称
     if (empty($data)) {
         $result = Utils::WrapResultError("无效的数据");
         return $this->responseJson($request, $result);
     }
     $data = json_decode($data, true);
     $noticeMgr = new \Justsy\BaseBundle\Management\PromptlyNotice($this->container, $staffdata, $appdata);
     $result = $noticeMgr->getReceiverList($data);
     return $this->responseJson($request, $result);
 }
예제 #13
0
 public function resetpassAction($appid)
 {
     $request = $this->get("request");
     $pv = $request->get("pv");
     $result = array();
     $result["s"] = "0";
     if (empty($appid) || empty($pv)) {
         $result["msg"] = "参数无效!";
     } else {
         $da = $this->get('we_data_access');
         $curuser = $this->get('security.context')->getToken()->getUser();
         try {
             $sql = "select b.login_account from we_appcenter_apps a,we_staff b where a.appname=b.nick_name and a.appid=?";
             $ds = $da->GetData("t", $sql, array((string) $appid));
             if ($ds == null || count($ds["t"]["rows"]) == 0) {
                 $result["msg"] = "appid参数无效!";
             } else {
                 $u_staff = new Staff($da, $this->get('we_data_access_im'), $curuser, $this->get('logger'));
                 $u_staff->changepassword($ds["t"]["rows"][0]["login_account"], $pv, $this->get('security.encoder_factory'));
                 $result["s"] = "1";
                 $result["msg"] = $pv;
             }
         } catch (\Exception $e) {
             $result["msg"] = $e->getMessage();
         }
     }
     $response = new Response(json_encode($result));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
예제 #14
0
 public function getatten_staff_setup($paramObj)
 {
     $staff = $paramObj['staff'];
     $user = $paramObj['user'];
     $eno = $user->eno;
     $sql = 'select * from ma_checkatten_setup where object_id=? and eno=? and object_type=3 and setup_statu=1';
     $ds = $this->conn->GetData('t', $sql, array((string) $staff, (string) $user->eno));
     if (count($ds['t']['rows']) == 0) {
         $staffMgr = new Staff($this->conn, $this->conn_im, $staff, $this->logger, $this->container);
         $data = $staffMgr->getInfo();
         $paramObj['deptid'] = $data['dept_id'];
         return $this->getatten_dept_setup($paramObj);
     }
     return Utils::WrapResultOK($ds['t']['rows']);
 }
예제 #15
0
 public function getLoginAppendData(&$re, $login_account, $portalversion, $comefrom, $db, $db_im, $clientdatetime)
 {
     $we_sys_param = $this->container->get('we_sys_param');
     $imserver = $we_sys_param->GetSysParam("imserver");
     if (empty($imserver)) {
         $imserver = "localhost:5222";
     }
     $re["imserver"] = $imserver;
     $url = $this->container->getParameter('FILE_WEBSERVER_URL');
     $url = str_replace("/getfile/", "", $url) . "/api/http/version/check";
     $re["imupdateserver"] = $url;
     if (!empty($clientdatetime)) {
         $sys = new \Justsy\InterfaceBundle\Controller\SystemController();
         $sys->setContainer($this->container);
         $re["server_time"] = $sys->getMillisecond($clientdatetime);
     } else {
         $re["server_time"] = 0;
     }
     //$re["publicuser"] = "******"; //是否是公共用户(未加入企业用户)
     //$re["micro_app_jid"] = "";
     $re["info"] = array();
     //$re["rosters"] = array();
     //$re["portalconfig_version"] = "";
     //$re["portalconfig_xml"] = "";
     //获取个人信息
     $staffinfo = new Staff($db, $db_im, $login_account, $this->get("logger"), $this->container);
     $result = $staffinfo->getInfo();
     if (!empty($result)) {
         $returnAttrs = explode(",", "jid,login_account,nick_name,photo_path,dept_id,dept_name,eno,ename,self_desc,duty,sex_id,mobile_bind,birthday");
         for ($i = 0; $i < count($returnAttrs); $i++) {
             $key = $returnAttrs[$i];
             $re["info"][$key] = $result[$key];
         }
         //为了避免用户修改密码后只刷新了所在服务器,im密码实时获取
         //$sql = "select password from users where username=?";
         //$iminfo = $db_im->GetData("im",$sql,array((string)$re["jid"]));
         //$re["des"] =count($iminfo["im"]["rows"])>0 ? $iminfo["im"]["rows"][0]["password"] : "";
     }
     return $re;
 }
예제 #16
0
 public function register_announcer($parameter)
 {
     $nick_name = isset($parameter["name"]) ? $parameter["name"] : null;
     $state = isset($parameter["state"]) ? $parameter["state"] : "add";
     $login_account = isset($parameter["login_account"]) ? $parameter["login_account"] : null;
     $account = explode("@", $login_account);
     $ldap_uid = $account[0];
     $deptid = isset($parameter["deptid"]) ? $parameter["deptid"] : array();
     $fileid = isset($parameter["fileid"]) ? $parameter["fileid"] : null;
     $fileid = empty($fileid) ? null : $fileid;
     $password = isset($parameter["password"]) ? $parameter["password"] : null;
     $staffid = isset($parameter["staffid"]) ? $parameter["staffid"] : array();
     $user = $parameter["user"];
     $success = true;
     $msg = "";
     $da = $this->conn;
     if ($state == "add") {
         //取公众号部门id
         $departmentid = "";
         $sql = " select dept_id from we_department where fafa_deptid=?;";
         $ds = $da->GetData("table", $sql, array("v" . $user->eno . "999888"));
         if ($ds && $ds["table"]["recordcount"] > 0) {
             $departmentid = $ds["table"]["rows"][0]["dept_id"];
             $register = new \Justsy\BaseBundle\Controller\ActiveController();
             $register->setContainer($this->container);
             $register_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" => "", "duty" => "", "indefaultgroup" => "N", "mutual" => "N", "deptid" => $departmentid);
             $success = $register->doSave($register_parameter);
         }
         if ($success) {
             //向广播员添加具有的默认菜单项
             $sql = "insert into mb_staff_menu(staff_id,menu_id)values(?,'firendcircle');";
             try {
                 $da->ExecSQL($sql, array((string) $login_account));
             } catch (\Exception $e) {
             }
         }
         if (!$success) {
             $msg = "用户账号(" . $login_account . ")注册失败!";
         }
     } else {
         //用户修改了密码的操作
         if (!empty($password)) {
             $u_staff = new Staff($da, $this->conn_im, $login_account, $this->logger);
             $targetStaffInfo = $u_staff->getInfo();
             $re = $u_staff->changepassword($targetStaffInfo["login_account"], $password, $this->container->get('security.encoder_factory'));
             $this->logger("-----------" . $re);
         }
     }
     if ($success) {
         $sqls = array();
         $paras = array();
         //修改头像
         $sql = "update we_staff set nick_name=?,photo_path=?,photo_path_small=?,photo_path_big=? where login_account=?;";
         $para = array((string) $nick_name, (string) $fileid, (string) $fileid, (string) $fileid, (string) $login_account);
         array_push($sqls, $sql);
         array_push($paras, $para);
         //修改im数据
         //获得fafa_jid
         $fafa_jid = "";
         $sql = "select fafa_jid from we_staff where login_account=?;";
         $ds = $da->GetData("table", $sql, array((string) $login_account));
         if ($ds && $ds["table"]["recordcount"] > 0) {
             $fafa_jid = $ds["table"]["rows"][0]["fafa_jid"];
             $sql_im = "update im_employee set employeename=?,photo=? where loginname=?;";
             $para_im = array((string) $nick_name, $fileid, (string) $fafa_jid);
             try {
                 $this->conn_im->ExecSQL($sql_im, $para_im);
             } catch (\Exception $e) {
             }
         }
         if ($state == "edit") {
             $sql = "delete from we_announcer where login_account=?;";
             $da->ExecSQL($sql, array((string) $login_account));
         }
         //部门的处理
         for ($j = 0; $j < count($deptid); $j++) {
             $sql = "insert into we_announcer(login_account,objid,`type`)values(?,?,1)";
             $para = array((string) $login_account, (string) $deptid[$j]);
             array_push($sqls, $sql);
             array_push($paras, $para);
         }
         //人员的处理
         for ($j = 0; $j < count($staffid); $j++) {
             $sql = "insert into we_announcer(login_account,objid,`type`)values(?,?,2)";
             $para = array((string) $login_account, (string) $staffid[$j]);
             array_push($sqls, $sql);
             array_push($paras, $para);
         }
         try {
             $da->ExecSQLS($sqls, $paras);
         } catch (\Exception $e) {
             $success = false;
             $msg = "更新用户信息失败!";
             $this->logger->err($e->getMessage());
         }
     }
     return array("success" => $success, "msg" => $msg);
 }
예제 #17
0
파일: Dept.php 프로젝트: 3116246/haolinju
 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);
 }
 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;
 }
예제 #19
0
 public function listAction()
 {
     $da = $this->get("we_data_access");
     $da_im = $this->get('we_data_access_im');
     $request = $this->getRequest();
     //访问权限校验
     $api = new \Justsy\OpenAPIBundle\Controller\ApiController();
     $api->setContainer($this->container);
     $isWeFaFaDomain = $api->checkWWWDomain();
     if (!$isWeFaFaDomain) {
         $token = $api->checkAccessToken($request, $da);
         if (!$token) {
             $re = array("returncode" => "9999");
             $re["code"] = "err0105";
             $re["msg"] = "参数Appid或Openid或Access_token未指定或无效.";
             return $this->responseJson($request, $re);
         }
     }
     $openid = $request->get("openid");
     $staffinfo = new \Justsy\BaseBundle\Management\Staff($da, $da_im, $openid, $this->get("logger"), $this->container);
     $staffdata = $staffinfo->getInfo();
     if (empty($staffdata)) {
         $result = Utils::WrapResultError("无效操作帐号");
         return $this->responseJson($request, $result);
     }
     $verCrl = new \Justsy\AdminAppBundle\Controller\VersionController();
     $verCrl->setContainer($this->container);
     return $this->responseJson($request, $verCrl->SearchVersionAction());
 }
예제 #20
0
 public function executeAction()
 {
     $request = $this->getRequest();
     $login_account = $request->get("login_account");
     $fafa_jid = $request->get("fafa_jid");
     $type = $request->get("type");
     $password = $request->get("password");
     $my_jid = $this->get('security.context')->getToken()->getUser()->fafa_jid;
     $result = array();
     $send_status = false;
     $msg = "";
     //修改密码
     if ($type == "adminLock") {
         $da = $this->get('we_data_access');
         $da_im = $this->get('we_data_access_im');
         $u_staff = new Staff($da, $da_im, $login_account, $this->get('logger'));
         $targetStaffInfo = $u_staff->getInfo();
         $re = $u_staff->changepassword($login_account, $password, $this->get('security.encoder_factory'));
         if ($re) {
             $send_status = Utils::sendImMessage($my_jid, $fafa_jid, $type, $password, $this->container, "", "", false, Utils::$systemmessage_code, '0');
         } else {
             $msg = "密码修改失败!";
         }
     } else {
         $send_status = Utils::sendImMessage($my_jid, $fafa_jid, $type, $type, $this->container, "", "", false, Utils::$systemmessage_code, '0');
     }
     $result = array("success" => $send_status, "msg" => $msg);
     $response = new Response(json_encode($result));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
예제 #21
0
 private function checkOpenid($db, $openid)
 {
     $staffinfo = new Staff($db, $this->get("we_data_access_im"), $openid, $this->get("logger"), $this->container);
     $obj = $staffinfo->getInfo();
     return empty($obj) ? false : $obj;
 }
예제 #22
0
 public function delGroupMember($parameter)
 {
     $groupid = $parameter["groupid"];
     $jid = $parameter["jid"];
     // $staff = $parameter["member"];
     $staffMgr = new Staff($this->conn, $this->conn_im, $jid, $this->logger, $this->container);
     $staffdata = $staffMgr->getinfo();
     if (empty($staffdata)) {
         return Utils::WrapResultError('成员不存在');
     }
     $staffdata = array('jid' => $staffdata['jid'], 'nick_name' => $staffdata['nick_name'], 'photo_path' => $staffdata['photo_path']);
     $success = true;
     $da = $this->conn_im;
     $sql = 'select ge.grouprole from im_groupemployee ge where ge.groupid=? and ge.employeeid=? ';
     $result = $da->GetData('t', $sql, array((string) $groupid, (string) $jid));
     if ($result['t']['rows'][0]['grouprole'] == 'owner') {
         //创建者不能删除
         return Utils::WrapResultOK('false', '不能删除创建者!');
     } else {
         if ($result['t']['rows'][0]['number'] <= 3) {
             //群成员小于3人,自动解散群
             $this->delDefaultGroup(array('groupid' => $groupid));
             return Utils::WrapResultOK("dissolve", "成员小于3人,已自动解散该群!");
         }
     }
     $sql = "delete from im_groupemployee where employeeid=? and groupid=?;";
     $para = array((string) $jid, (string) $groupid);
     try {
         $da->ExecSQL($sql, $para);
         //同时重新计算群成员数量
         $sql = "update im_group set number = number-1 where groupid=?;";
         $para = array((string) $groupid, (string) $groupid);
         try {
             $da->ExecSQL($sql, $para);
             $groupinfo = $this->GetByIM($groupid, true);
             //向群组所有成员发送出席(包括当前被删除的群成员)
             $groupObj = $this->getGroupMemberJid($groupid);
             $to_jid = $groupObj["member_jid"];
             $groupname = $groupObj["groupname"];
             if (!empty($to_jid)) {
                 //由于当前被删除群成员已经不在表中,所以应加上
                 $to_jid .= "," . $jid;
                 $userinfo = $parameter["user"];
                 $send_jid = $userinfo->fafa_jid;
                 $title = "exit_group";
                 $message = $staffdata['nick_name'] . '退出了 ' . $groupname . ' 群';
                 $noticeinfo = Utils::WrapMessageNoticeinfo($message, $userinfo->nick_name, null, $groupinfo['logo']);
                 $msg = Utils::WrapMessage($title, array('groupid' => $groupid, 'groupname' => $groupinfo['groupname'], 'member' => $staffdata), $noticeinfo);
                 Utils::sendImMessage($send_jid, $to_jid, $title, json_encode($msg), $this->container, "", "", false, Utils::$systemmessage_code);
             }
         } catch (\Exception $e) {
             $this->logger->err($e->getMessage());
         }
     } catch (\Exception $e) {
         $success = false;
         $this->logger->err($e->getMessage());
     }
     return Utils::WrapResultOK('');
 }
예제 #23
0
 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;
     }
 }
예제 #24
0
 public function removeMonitorAction()
 {
     $da = $this->get("we_data_access");
     $da_im = $this->get('we_data_access_im');
     $request = $this->getRequest();
     //访问权限校验
     $api = new ApiController();
     $api->setContainer($this->container);
     $isWeFaFaDomain = $api->checkWWWDomain();
     if (!$isWeFaFaDomain) {
         $token = $api->checkAccessToken($request, $da);
         if (!$token) {
             $re = array("returncode" => "9999");
             $re["code"] = "err0105";
             $re["msg"] = "参数Appid或Openid或Access_token未指定或无效.";
             return $this->responseJson($request, $re);
         }
     }
     $openid = $request->get("openid");
     $staffinfo = new Staff($da, $da_im, $openid, $this->get("logger"), $this->container);
     $staffdata = $staffinfo->getInfo();
     if (empty($staffdata)) {
         $result = Utils::WrapResultError("无效操作帐号");
         return $this->responseJson($request, $result);
     }
     $to = $request->get("to");
     if (empty($to)) {
         $result = Utils::WrapResultError("无效的帐号");
         return $this->responseJson($request, $result);
     }
     $to = $staffinfo->getStaffInfo($to);
     if (empty($to)) {
         $result = Utils::WrapResultError("无效的帐号");
         return $this->responseJson($request, $result);
     }
     try {
         $sql = 'delete from  t_module_location_monitor where staff=?';
         $da->ExecSQL($sql, array((string) $to['jid']));
         $sql = 'delete from  t_module_location where staff=?';
         $da->ExecSQL($sql, array((string) $to['login_account']));
     } catch (\Exception $e) {
     }
     $senddata = array('opt' => 'stop');
     $msg = Utils::WrapMessage('sendlocation', $senddata, array());
     //$msgxml = Utils::WrapMessageXml($this->module["jid"],$msg,'sendlocation-id');
     $api->sendMsg("", $to['jid'], 'sendlocation', json_encode($msg));
     return $this->responseJson($request, Utils::WrapResultOk(""));
 }
예제 #25
0
 public function getManager($paraObj)
 {
     $eno = $paraObj['user']->eno;
     $data = $this->getInfo($eno);
     if (empty($data)) {
         return Utils::WrapResultError("无效的企业信息");
     }
     $result = array();
     $managers = $data['sys_manager'];
     $managers = explode(';', $managers);
     $staffMgr = new Staff($this->da, $this->db_im, $paraObj['user'], $this->logger, $this->container);
     foreach ($managers as $key => $value) {
         $result[] = $staffMgr->getStaffInfo($value);
     }
     return Utils::WrapResultOK($result);
 }
예제 #26
0
 public static function userAuthAction($container, $request, $dbcon, $con_im, $login_account, $password, $comefrom)
 {
     $login_account = strtolower($login_account);
     try {
         $password = strtoupper(md5($password));
         //$container->get("logger")->err($password);
         $staff = new Staff($dbcon, $con_im, strtolower($login_account));
         $user = $staff->getInfo();
         if ($user == null || $user["state_id"] != "1") {
             $re["returncode"] = ReturnCode::$ERROFUSERORPWD;
             return $re;
         }
         $login_account = $user["login_account"];
         $Obj = new \Justsy\BaseBundle\Login\UserProvider($container);
         //
         $factory = $container->get('security.encoder_factory');
         //判断是否修改过密码.这时针对从第三方注册的帐号的密码为不可解开密文的情况时,sns中的密码和t_code字段临时存储为完全相同的数据
         //程序判断到这种情况 时,需要进行内部自动更改密码操作,之前的临时数据即为用户新密码
         //$container->get("logger")->err($user["password"]."==".$user["t_code"]);
         if ($user["password"] == $user["t_code"]) {
             $tmpPass = DES::encrypt($password);
             if ($tmpPass != $user["t_code"]) {
                 $re["returncode"] = ReturnCode::$ERROFUSERORPWD;
             }
             //更新密码
             $staff->changepassword($login_account, $password, $factory);
         }
         $user = new UserSession($login_account, $password, $login_account, array("ROLE_USER"));
         $encoder = $factory->getEncoder($user);
         $password_enc = $encoder->encodePassword($password, $login_account);
         $user = $Obj->loadUserByUsername($login_account, $comefrom);
         //$container->get("logger")->err($user->getPassword()."==".$password_enc);
         $logined = 1;
         if ($user->getPassword() != $password_enc) {
             //如果密码不正确时,有可能是修改了密码,只刷新了一台服务器上的缓存,其他集群环境中的还是原来的缓存
             //刷新当前服务器的人员信息才重试
             $u_staff = new Staff($dbcon, $con_im, $user->getusername(), $container->get('logger'));
             $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)) {
             //�Ǽ�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"] = $login_account;
             $re["ldap_uid"] = $user->ldap_uid;
             $re["jid"] = $user->fafa_jid;
             $re["des"] = $user->t_code;
         }
     } catch (\Symfony\Component\Security\Core\Exception\UsernameNotFoundException $e) {
         $re["returncode"] = ReturnCode::$ERROFUSERORPWD;
     } catch (\Exception $e) {
         $container->get("logger")->err($e);
         $re["returncode"] = ReturnCode::$SYSERROR;
     }
     return $re;
 }
예제 #27
0
 public function accessCheck()
 {
     $da = $this->get("we_data_access");
     $da_im = $this->get('we_data_access_im');
     $request = $this->getRequest();
     //访问权限校验
     $api = new ApiController();
     $api->setContainer($this->container);
     $isWeFaFaDomain = $api->checkWWWDomain();
     if (!$isWeFaFaDomain) {
         $token = $api->checkAccessToken($request, $da);
         if (!$token) {
             $re = array("returncode" => "9999");
             $re["code"] = "err0105";
             $re["msg"] = "参数Appid或Openid或Access_token未指定或无效.";
             return $re;
         }
     }
     $openid = $request->get("openid");
     $staffinfo = new Staff($da, $da_im, $openid, $this->get("logger"), $this->container);
     $staffdata = $staffinfo->getInfo();
     if (empty($staffdata)) {
         return Utils::WrapResultError("无效操作帐号");
     }
     return Utils::WrapResultOk($staffinfo->getSessionUser($staffdata));
 }
예제 #28
0
 public static function userAuthAction($container, $request, $dbcon, $con_im, $login_account, $password, $comefrom)
 {
     $defaultPostURl = "http://10.100.20.27/CallCenter/ESB_InvokeService.ashx";
     $cacheobj = new Enterprise($dbcon, $container->get("logger"), $container);
     //
     $authConfig = $cacheobj->getUserAuth();
     $httpUrlConfig = $authConfig["ssoauthurl"];
     if (empty($httpUrlConfig)) {
         $httpUrlConfig = $defaultPostURl;
         $eno = "100001";
     } else {
         $ldapConfgiObject = json_decode($httpUrlConfig, true);
         $eno = $ldapConfgiObject["ENO"];
         $httpUrlConfig = $ldapConfgiObject["URL"];
     }
     try {
         $data = array();
         $data["loginName"] = $login_account;
         $data["password"] = $password;
         $data["isNeedSyn"] = false;
         $para = "ServiceName=WXSC_Account&MethodName=POST:JSON:UserAuthentication&Message=" . json_encode($data) . "&Version=1";
         $container->get("logger")->err("SOA URL:" . $httpUrlConfig . "?" . $para);
         $postresult = Utils::do_post_request($httpUrlConfig, $para);
         $container->get("logger")->err("SOA Result:" . $postresult);
         $resultObject = json_decode($postresult, true);
         if (!empty($resultObject["errcode"]) || $resultObject["isSuccess"] === false) {
             $re["returncode"] = ReturnCode::$ERROFUSERORPWD;
             return $re;
         }
         $mbuser = $resultObject["results"];
         $fafa_account = strtolower($login_account . "@fafatime.com");
         if (count($mbuser) > 0) {
             $mbuser = $mbuser[0];
             $nickName = isset($mbuser["nickName"]) ? $mbuser["nickName"] : $mbuser["phoneNumber"];
             $staff = new Staff($dbcon, $con_im, $fafa_account);
             $staffinfo = $staff->getInfo();
             if (empty($staffinfo)) {
                 //新用户:注册 激活
                 $enInfo = $cacheobj->getInfo($eno);
                 $active = new \Justsy\BaseBundle\Controller\ActiveController();
                 $active->setContainer($container);
                 $uid = strtolower($mbuser["id"]);
                 $active->doSave(array('account' => $fafa_account, 'realName' => $nickName, 'passWord' => $password, 'eno' => $eno, 'ename' => $enInfo["ename"], 'isNew' => '0', 'mailtype' => "1", 'isSendMessage' => "N", 'import' => '1'));
                 $sex_id = "1";
                 $duty = isset($mbuser["userRoles"]) ? $mbuser["userRoles"] : "";
                 $ldap_uid = isset($mbuse["id"]) ? $mbuser["id"] : "";
                 $tmp = "";
                 if (!empty($duty) && count($duty) > 0) {
                     for ($i = 0; $i < count($duty); $i++) {
                         $tmp = $duty[$i]["roleName"];
                         if ($tmp == "Designer") {
                             break;
                         }
                     }
                 }
                 if ($tmp == "Designer") {
                     $duty = "造型师";
                 } else {
                     $duty = "";
                 }
                 $sql = "update we_staff set ldap_uid=?,sex_id=?,duty=? where login_account=?";
                 $params = array($uid, (string) $sex_id, $duty, $fafa_account);
                 $dbcon->ExecSQL($sql, $params);
                 if (!empty($mbuser["phoneNumber"])) {
                     $staff->checkAndUpdate(null, $mbuser["phoneNumber"], null, null);
                 }
             } else {
                 $duty = isset($mbuser["userRoles"]) ? $mbuser["userRoles"] : "";
                 $ldap_uid = isset($mbuser["id"]) ? $mbuser["id"] : "";
                 $tmp = "";
                 if (!empty($duty) && count($duty) > 0) {
                     for ($i = 0; $i < count($duty); $i++) {
                         $tmp = $duty[$i]["roleName"];
                         if ($tmp == "Designer") {
                             break;
                         }
                     }
                 }
                 if ($tmp == "Designer") {
                     $duty = "造型师";
                 } else {
                     $duty = "";
                 }
                 //更新信息
                 $staff->checkAndUpdate($nickName, $mbuser["phoneNumber"], null, $duty, $ldap_uid);
             }
             //头像
             $headUrl = $mbuser["headPortrait"];
         }
         $Obj = new \Justsy\BaseBundle\Login\UserProvider($container);
         $user = $Obj->loadUserByUsername($fafa_account, $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"] = $fafa_account;
         $re["ldap_uid"] = $user->ldap_uid;
         $re["jid"] = $user->fafa_jid;
         //为了避免用户修改密码后只刷新了所在服务器,im密码实时获取
         $sql = "select password from users where username=?";
         $iminfo = $con_im->GetData("im", $sql, array((string) $user->fafa_jid));
         $re["des"] = count($iminfo["im"]["rows"]) > 0 ? $iminfo["im"]["rows"][0]["password"] : "";
     } catch (\Symfony\Component\Security\Core\Exception\UsernameNotFoundException $e) {
         $re["returncode"] = ReturnCode::$ERROFUSERORPWD;
     } catch (\Exception $e) {
         $re["returncode"] = ReturnCode::$SYSERROR;
     }
     return $re;
 }
예제 #29
0
 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;
 }
예제 #30
0
 public static function tokenValidate($container, $token)
 {
     $request = $container->get("request");
     $dbcon = $container->get("we_data_access");
     $con_im = $container->get("we_data_access_im");
     $rest = "/rest/validate";
     $defaultPostURl = "https://sso.avicmall.com:8443";
     $appcodeConfig = "fafa-app";
     $appkeyConfig = "DKGHwqJ5H91noPYNYm9b8EUPQSY";
     $cacheobj = new Enterprise($dbcon, $container->get("logger"), $container);
     //
     $authConfig = $cacheobj->getUserAuth();
     $httpUrlConfig = $authConfig["ssoauthurl"];
     if (empty($httpUrlConfig)) {
         $httpUrlConfig = $defaultPostURl;
         $eno = "100001";
     } else {
         $ldapConfgiObject = json_decode($httpUrlConfig, true);
         $eno = $ldapConfgiObject["ENO"];
         $httpUrlConfig = $ldapConfgiObject["URL"];
         $appcodeConfig = $ldapConfgiObject["AppCode"];
         $appkeyConfig = $ldapConfgiObject["AppKey"];
     }
     $httpUrlConfig = $httpUrlConfig . $rest;
     try {
         $reqHeader = SsoAvicAuth::getHeaders($appcodeConfig, $appkeyConfig);
         $para = array("ticketName" => "SIAMTGT", "ticketValue" => $token);
         //$container->get("logger")->err("SOA URL:".$httpUrlConfig." Body:".json_encode($para));
         $postresult = Utils::do_post_request($httpUrlConfig, json_encode($para), $reqHeader, $container->get("logger"));
         //$container->get("logger")->err("SOA Result:".$postresult);
         $resultObject = json_decode($postresult, true);
         if (!isset($resultObject["status"])) {
             $re["returncode"] = ReturnCode::$ERROFUSERORPWD;
             $re["msg"] = "服务器异常";
             return $re;
         }
         if (!$resultObject["status"] || $resultObject["status"] == "false") {
             $re["returncode"] = ReturnCode::$ERROFUSERORPWD;
             $re["msg"] = $resultObject["message"];
             return $re;
         }
         $usertoken = $resultObject["ticketEntry"]["ticketValue"];
         $user = $resultObject["user"];
         //用户信息
         $nickName = $user["cn"];
         //获取姓名
         $phoneNumber = $user["smart-securemobile"];
         //获取手机号
         $login_account = $user["uid"];
         $eninfo = $cacheobj->getInfo($eno);
         $domain = $eninfo["edomain"];
         $domain = strpos($domain, ".") === false ? "fafatime.com" : $domain;
         $fafa_account = strtolower($login_account . "@" . $domain);
         $staff = new Staff($dbcon, $con_im, $fafa_account);
         $staffinfo = $staff->getInfo();
         if (empty($staffinfo)) {
             $password = rand(100000, 999999);
             //新用户:注册 激活
             $enInfo = $cacheobj->getInfo($eno);
             $active = new \Justsy\BaseBundle\Controller\ActiveController();
             $active->setContainer($container);
             $uid = strtolower($login_account);
             $active->doSave(array('account' => $fafa_account, 'realName' => $nickName, 'passWord' => $password, 'eno' => $eno, 'ename' => $enInfo["ename"], 'isNew' => '0', 'mailtype' => "1", 'deptid' => "100054", 'isSendMessage' => "N", 'import' => '1'));
             $sql = "update we_staff set ldap_uid=?,mobile=?,mobile_bind=? where login_account=?";
             $params = array((string) $uid, (string) $phoneNumber, (string) $phoneNumber, (string) $fafa_account);
             $dbcon->ExecSQL($sql, $params);
         } else {
             $ldap_uid = $login_account;
             //更新信息
             if ($nickName == $staffinfo["nick_name"]) {
                 $nickName = null;
             }
             if ($phoneNumber == $staffinfo["mobile"]) {
                 $phoneNumber = null;
             }
             if (!empty($nickName) || !empty($phoneNumber)) {
                 try {
                     $staff->checkAndUpdate($nickName, $phoneNumber, null, null, $ldap_uid);
                 } catch (\Exception $e) {
                     $container->get("logger")->err($e->getMessage());
                 }
             }
         }
         $Obj = new \Justsy\BaseBundle\Login\UserProvider($container);
         $user = $Obj->loadUserByUsername($fafa_account, $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"] = $fafa_account;
         $re["ldap_uid"] = $user->ldap_uid;
         $re["jid"] = $user->fafa_jid;
         $re["token"] = $usertoken;
         //用户凭据
         //为了避免用户修改密码后只刷新了所在服务器,im密码实时获取
         $sql = "select password from users where username=?";
         $iminfo = $con_im->GetData("im", $sql, array((string) $user->fafa_jid));
         $re["des"] = count($iminfo["im"]["rows"]) > 0 ? $iminfo["im"]["rows"][0]["password"] : "";
     } catch (\Symfony\Component\Security\Core\Exception\UsernameNotFoundException $e) {
         $re["returncode"] = ReturnCode::$ERROFUSERORPWD;
     } catch (\Exception $e) {
         $re["msg"] = $e->getMessage();
         $re["returncode"] = ReturnCode::$SYSERROR;
     }
     return $re;
 }