예제 #1
0
 function getUserInfo($username)
 {
     $DataAccess = $this->container->get('we_data_access');
     $curuser = $this->get('security.context')->getToken()->getUser();
     if (Utils::validateEmail($username)) {
         //帐号
         $sqls = "select f_checkAttentionWithAccount(?,a.login_account) attention,a.login_account, a.nick_name, a.photo_path_big, a.password, a.dept_id, a.eno,a.fafa_jid,a.duty,a.work_phone,a.mobile,date_format(a.birthday,'%Y-%c-%d') birthday, b.edomain, b.ename, b.eshortname, c.dept_name ,\n\t\t\t\t\tifnull(a.self_desc,'未设置个性签名') self_desc,ifnull(a.we_level, 0) we_level,b.vip_level,a.auth_level,a.total_point, a.attenstaff_num, a.fans_num, a.publish_num,ifnull(d.id,0) addcard from we_staff a\n\t\t\t\t\t  join we_enterprise b on a.eno=b.eno\n\t\t\t\t\t  left join we_department c on a.eno=c.eno and a.dept_id=c.dept_id \n\t\t\t\t\t  left join we_addrlist_main d on d.owner=? and d.typeid='M001' and d.addr_account=a.login_account\n\t\t\t\t\twhere a.login_account=? ";
         $params = array($curuser->getUsername(), $curuser->getUsername(), (string) $username);
     } else {
         $userNameAry = $this->parseUserName($username);
         $sqls = "select f_checkAttentionWithAccount(?,a.login_account) attention,a.login_account, a.nick_name, a.photo_path_big, a.password, a.dept_id, a.eno,a.fafa_jid,a.duty,a.work_phone,a.mobile,date_format(a.birthday,'%Y-%c-%d') birthday, b.edomain, b.ename, b.eshortname, c.dept_name ,\n\t\t\t\t\tifnull(a.self_desc,'未设置个性签名') self_desc,ifnull(a.we_level, 0) we_level,b.vip_level,a.auth_level,a.total_point, a.attenstaff_num, a.fans_num, a.publish_num,ifnull(d.id,0) addcard from we_staff a\n\t\t\t\t\t  join we_enterprise b on a.eno=b.eno\n\t\t\t\t\t  left join we_department c on a.eno=c.eno and a.dept_id=c.dept_id \n\t\t\t\t\t  left join we_addrlist_main d on d.owner=? and d.typeid='M001' and d.addr_account=a.login_account\n\t\t\t\t\twhere a.nick_name=? and b.eshortname=?";
         $params = array($curuser->getUsername(), $curuser->getUsername(), (string) $userNameAry[0], (string) $userNameAry[1]);
     }
     $dataset = $DataAccess->GetData("we_staff", $sqls, $params);
     if ($dataset && $dataset["we_staff"]["recordcount"] > 0) {
         $this->isSelf = $curuser->getUsername() == $dataset["we_staff"]["rows"][0]["login_account"];
         $dataset["we_staff"]["rows"][0]["vip_level"] = $dataset["we_staff"]["rows"][0]["auth_level"] != 'S' ? \Justsy\BaseBundle\Common\ExperienceLevel::getLevel($dataset["we_staff"]["rows"][0]["total_point"]) : "1";
         return $dataset["we_staff"]["rows"][0];
     } else {
         return "";
     }
 }
예제 #2
0
 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;
                     $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) {
                                             $pwd_index = $col;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     $titleAry[] = "eno";
                     $err_list = array();
                     $da = $this->get("we_data_access");
                     $dm = $this->get("we_data_access_im");
                     //获取数据行
                     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($da, $dm, $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' => $ds["t"]["rows"][0]["ename"], 'isNew' => '0', 'mailtype' => "1", 'isSendMessage' => "N", 'import' => '1'));
                                 $staffmgr = new Staff($da, $dm, $account);
                                 $importData = $staffmgr->getImportInfo();
                                 $staffmgr->updateByImport($importData);
                                 $staffmgr->deleteImportPhy();
                             } else {
                                 if ($isImport === false) {
                                     //发送邮件
                                     $activeurl = $this->generateUrl("JustsyBaseBundle_empimport_setpass", array('account' => DES::encrypt($account)), true);
                                     $txt = $this->renderView('JustsyBaseBundle:Register:mail.html.twig', array('realName' => $user->nick_name, 'account' => $account, 'activeurl' => $activeurl));
                                     Utils::saveMail($da, $this->container->getParameter('mailer_user'), $account, "欢迎加入Wefafa企业协作网络", $txt);
                                 }
                             }
                         } 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;
 }
예제 #3
0
 public function resetpwdAction()
 {
     $request = $this->getRequest();
     $account = $request->get("account");
     $txtvaildcode = $request->get("txtvaildcode");
     $pwd = $request->get("txtnewpwd");
     $pwd_im = $pwd;
     $da = $this->get("we_data_access");
     $da_im = $this->get("we_data_access_im");
     $re = array("returncode" => ReturnCode::$SUCCESS);
     if (empty($account)) {
         return $this->responseJson(Utils::WrapResultError("帐号不能为空"), $request->get('jsoncallback'));
     }
     if (empty($txtvaildcode)) {
         return $this->responseJson(Utils::WrapResultError("验证码不能为空"), $request->get('jsoncallback'));
     }
     //验证帐号及验证码
     $isEmail = Utils::validateEmail($account);
     $isMobile = Utils::validateMobile($account);
     if (!$isEmail && !$isMobile) {
         return $this->responseJson(Utils::WrapResultError("帐号格式不正确,仅支持邮箱或手机帐号"), $request->get('jsoncallback'));
     }
     $u_staff = new \Justsy\BaseBundle\Management\Staff($da, $da_im, $account, $this->get('logger'), $this->container);
     $targetStaffInfo = $u_staff->getInfo();
     if (empty($targetStaffInfo)) {
         return $this->responseJson(Utils::WrapResultError("帐号无效"), $request->get('jsoncallback'));
     }
     $sysparam = new \Justsy\BaseBundle\DataAccess\SysParam($this->container);
     $wn_code = $sysparam->GetSysParam("mobile_active_code");
     if ($txtvaildcode != $wn_code) {
         $sql = "select * from we_mobilebind_validcode where login_account=? and actiontype='FP' and valid_date>now() order by valid_date desc limit 0,1";
         $ds = $da->GetData('t', $sql, array((string) $account));
         if ($txtvaildcode != $ds["t"]["rows"][0]["validcode"]) {
             return $this->responseJson(Utils::WrapResultError("验证码无效"), $request->get('jsoncallback'));
         }
     }
     try {
         $login_account = $targetStaffInfo['login_account'];
         $re = $u_staff->changepassword($login_account, $pwd, $this->get('security.encoder_factory'));
         return $this->responseJson($re, $request->get('jsoncallback'));
     } catch (Exception $e) {
         return $this->responseJson(Utils::WrapResultError("重置密码失败,请稍后重试"), $request->get('jsoncallback'));
     }
 }
예제 #4
0
 public function mailtypeAction(Request $request)
 {
     $mail = $request->get("id");
     $vcode = strtolower($request->get("vcode"));
     //var_dump( $vcode);
     $session = $this->get('session');
     //var_dump( $session->get("code"));
     if (!empty($vcode)) {
         //检查验证码
         if ($vcode != $session->get("code")) {
             $this->get("logger")->err("{$vcode}:" . $vcode . "========session code:" . $session->get("code"));
             $array = array("succeed" => false, "msg" => "error11");
             $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($array) . ");" : json_encode($array));
             $response->headers->set('Content-Type', 'text/json');
             return $response;
         }
     }
     //检查地址是否合法
     if (!Utils::validateEmail($mail)) {
         //$response = new Response(json_encode(array("succeed"=>false,"msg"=>"error01")));
         $array = array("succeed" => false, "msg" => "error01");
         $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($array) . ");" : json_encode($array));
         $response->headers->set('Content-Type', 'text/json');
         return $response;
     }
     $DataAccess = $this->container->get('we_data_access');
     //    	 $domain = substr($mail,strpos($mail,'@')+1);
     //       $dataset = $DataAccess->GetData("domain","select domain_name from we_public_domain where domain_name=?",array((String)$domain));
     //       if ($dataset && $dataset["domain"]["recordcount"] > 0 )  //公共邮箱
     //       	   $array['type'] = "0";
     //       }
     $array['type'] = "1";
     $array['succeed'] = true;
     //默认为正常
     //$response = new Response(json_encode($array));
     //判断邮箱是否已经使用
     $sql = "select count(0) cnt from we_staff where login_account=? ";
     $result = $DataAccess->GetData("checkresult", $sql, array((string) $mail));
     if ($result["checkresult"]["rows"][0]["cnt"] > 0) {
         $array = array("succeed" => false, "msg" => "error03");
         $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($array) . ");" : json_encode($array));
         $response->headers->set('Content-Type', 'text/json');
         return $response;
     }
     //检查是否被列为黑名单
     $sql = "select count(0) cnt from we_blacklist where blacklist_type ='02' and blacklist_value =?";
     $result = $DataAccess->GetData("checkresult", $sql, array((string) $mail));
     if ($result["checkresult"]["rows"][0]["cnt"] > 0) {
         $array = array("succeed" => false, "msg" => "error03");
         $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($array) . ");" : json_encode($array));
         $response->headers->set('Content-Type', 'text/json');
         return $response;
     }
     $mailDomain = explode("@", $mail);
     $sql = "select count(0) cnt from we_blacklist where blacklist_type ='01' and blacklist_value =?";
     $result = $DataAccess->GetData("checkresult", $sql, array((string) $mailDomain[1]));
     if ($result["checkresult"]["rows"][0]["cnt"] > 0) {
         $array = array("succeed" => false, "msg" => "error05");
         $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($array) . ");" : json_encode($array));
         $response->headers->set('Content-Type', 'text/json');
         return $response;
     }
     //未激活注册,检查是否已提交及审核情况
     $sql = "select * from we_register where login_account=?";
     $result = $DataAccess->GetData("checkresult", $sql, array((string) $mail));
     $Rec = $result && $result['checkresult']['recordcount'] > 0 ? $result["checkresult"]["rows"][0] : 0;
     if ($Rec["state_id"] == "2") {
         $array = array("succeed" => false, "msg" => "error0403");
         //已审核通过
         //$response = new Response(json_encode());
     } else {
         if ($Rec["submit_num"] > 9) {
             //判断提交次数
             $array = array("succeed" => false, "msg" => "error0402");
             //
             //$response = new Response(json_encode(array("succeed"=>false,"msg"=>"error0402")));
         }
     }
     $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($array) . ");" : json_encode($array));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
예제 #5
0
 public function RestartPasswordAction()
 {
     $da = $this->get("we_data_access");
     $request = $this->getRequest();
     $login_account = $request->get("login_account");
     $success = true;
     $msg = "";
     if (empty($login_account)) {
         $success = false;
         $msg = "请输入用户账号!";
     } else {
         if (!Utils::validateEmail($login_account)) {
             $success = false;
             $msg = "请输入正确的用户账号!";
         } else {
             $sql = "delete from mb_salary_staff where login_account=?;";
             try {
                 $da->ExecSQL($sql, array((string) $login_account));
                 //记录用户操作日志
                 $syslog = new \Justsy\AdminAppBundle\Controller\SysLogController();
                 $syslog->setContainer($this->container);
                 $desc = "清除用户账号:" . $login_account . "工资独立密码!";
                 $syslog->AddSysLog($desc, "工资密码");
             } catch (\Exception $e) {
                 $success = false;
                 $msg = "重置用户工资密码错误!";
                 $this->get("logger")->err($e->getMessage());
             }
         }
     }
     $result = array("success" => $success, "msg" => $msg);
     $response = new Response(json_encode($result));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }