Example #1
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;
 }
Example #2
0
 public function sendMsg2($from, $to, $msg, $type, $isCheckTo = false, $cctomail = "0", $msg_id = "")
 {
     $pre_code = '/&quot;code&quot;:&quot;.*?&quot;/i';
     preg_match($pre_code, $msg, $result);
     if (count($result) > 0) {
         $type = str_replace("&quot;", "", $result[0]);
         $type = str_replace("code:", "", $type);
     }
     //获取发送人和接收人jid或者openid
     $from = trim($from);
     $msg = urlencode(trim($msg));
     if (empty($from)) {
         $domain = $this->container->getParameter('edomain');
         $from = "admin@" . $domain;
     }
     if (empty($msg)) {
         return array('returncode' => '9999', 'msg' => '消息内容不能为空');
     }
     $da = $this->get("we_data_access");
     $senderMail = "admin@" . $this->container->getParameter('edomain');
     if (!strpos($from, "@")) {
         //获取opendid对应的jid,没找到则返回错误
         if (Utils::validateMobile($from)) {
             //手机号
             $table = $da->GetData("staff", "select fafa_jid,login_account from we_staff where mobile_bind=? ", array((string) $from, (string) $from));
         } else {
             $table = $da->GetData("staff", "select fafa_jid,login_account from we_staff where openid=? or ldap_uid=?", array((string) $from, (string) $from));
         }
         if (count($table["staff"]["rows"]) == 0) {
             return array('returncode' => '9999', 'msg' => '消息发送者参数不能为空');
         }
         $from = $table["staff"]["rows"][0]["fafa_jid"];
         $senderMail = $table["staff"]["rows"][0]["login_account"];
     } else {
         if (strpos($from, "admin") === false) {
             //jid
             $table = $da->GetData("staff", "select fafa_jid,login_account from we_staff where fafa_jid=? or login_account=?", array((string) $from, (string) $from));
             if (count($table["staff"]["rows"]) == 0) {
                 return array('returncode' => '9999', 'msg' => '消息发送者参数不能为空');
             }
             $from = $table["staff"]["rows"][0]["fafa_jid"];
             $senderMail = $table["staff"]["rows"][0]["login_account"];
         }
     }
     //-------------check To--------------
     if (empty($to)) {
         return array('returncode' => '9999', 'msg' => '消息接收者参数不能为空');
     }
     $arr = is_array($to) ? $to : explode(",", $to);
     $regUrl = $this->container->getParameter("FAFA_REG_JID_URL");
     $toLst = array();
     $nosendLst = array();
     foreach ($arr as $key => $value) {
         $to2 = $value;
         if ($isCheckTo === false && $cctomail != "1") {
             $toLst[] = $to2;
             continue;
             //是否需要检查接收人是否有效。当内部调用且100%能确定有效且不抄送邮箱(要抄送时还是得去查询一次)时,可设置为不再检查
         }
         if (!strpos($to2, "@")) {
             //获取opendid对应的jid,没找到则返回错误
             if (Utils::validateMobile($to2)) {
                 //手机号
                 $table = $da->GetData("staff", "select fafa_jid,login_account from we_staff where mobile_bind=? ", array((string) $to2));
             } else {
                 $table = $da->GetData("staff", "select fafa_jid,login_account from we_staff where openid=? or ldap_uid=?", array((string) $to2, (string) $to2));
             }
             if (count($table["staff"]["rows"]) == 0) {
                 $nosendLst[] = $to2;
                 continue;
             }
             $to2 = $table["staff"]["rows"][0]["fafa_jid"];
             if ($cctomail == "1") {
                 Utils::saveMail($da, $senderMail, $table["staff"]["rows"][0]["login_account"], $title, $msg);
             }
         } else {
             if (strpos($to2, "admin") === false) {
                 //jid
                 $staffMgr = new Staff($da, $this->get("we_data_access_im"), $to2, $this->get("logger"), $this->container);
                 $staffinfo = $staffMgr->getInfo();
                 if (!empty($staffinfo)) {
                     $to2 = $staffinfo["fafa_jid"];
                 } else {
                     $table = $da->GetData("staff", "select fafa_jid,login_account from we_staff where fafa_jid=?", array((string) $to2));
                     if (count($table["staff"]["rows"]) == 0) {
                         $nosendLst[] = $to2;
                         continue;
                     }
                     $to2 = $table["staff"]["rows"][0]["fafa_jid"];
                     if ($cctomail == "1") {
                         Utils::saveMail($da, $senderMail, $table["staff"]["rows"][0]["login_account"], urldecode(iconv('UTF-8', 'GBK', $title)), urldecode(iconv('UTF-8', 'GBK', $msg)), "business-message");
                     }
                 }
             }
         }
         $toLst[] = $to2;
     }
     $regUrlOrg = $regUrl . "/service.yaws";
     $data = "sendMicroMsg=1&from={$from}&to=" . implode(",", $toLst) . "&msg={$msg}&type={$type}&busdata={$msg_id}";
     //$this->get("logger")->alert("SEND MSG URL:$regUrlOrg?$data");
     $re = Utils::do_post_request($regUrlOrg, $data);
     if (count($nosendLst) == 0) {
         return array('returncode' => '0000', 'nosend' => '');
     } else {
         return array('returncode' => '0000', 'nosend' => implode(",", $nosendLst));
     }
 }
Example #3
0
 public function applyJoinAction()
 {
     $da = $this->get("we_data_access");
     $user = $this->get('security.context')->getToken()->getUser();
     $circleId = $this->get('request')->request->get('circleId');
     $apply = new \Justsy\BaseBundle\Management\ApplyMgr($da, null);
     //判断是否已加入该圈子
     $sql = "select count(1) as cnt from we_circle_staff where circle_id=? and login_account=?";
     $ds = $da->GetData('we_circle_staff', $sql, array((string) $circleId, (string) $user->getUserName()));
     if (!$ds || $ds['we_circle_staff']['recordcount'] == 0) {
         //已经是该圈子成员
         return new Response("-1");
     }
     //判断是否已超出加入圈子数量的限制
     $ec = new \Justsy\BaseBundle\Management\EnoParamManager($da, $this->get('logger'));
     if ($ec->IsBeyondJoinCircle($user->getUserName())) {
         return new Response("-2");
     }
     //判断改圈子成员数是否已满
     if ($ec->IsBeyondCircleMembers($circleId)) {
         return new Response("-3");
     }
     //判断是否已申请或者超出申请限制
     $result = $apply->ApplyJoinCircle($user->getUsername(), $circleId, "");
     if ($result == 0 || $result == 99999) {
         return new Response((string) $result);
     }
     $circleObj = new \Justsy\BaseBundle\Management\CircleMgr($da, null, $circleId);
     $circle = $circleObj->Get();
     if ($circle == null) {
         return new Response("0");
     }
     $createStaff = $circle["create_staff"];
     $circleName = $circle["circle_name"];
     //para 圈子ID,申请人帐号,申请人姓名,圈子名称 DES加密
     $para = DES::encrypt($circleId . "," . $user->getUserName() . "," . $user->nick_name . "," . $circleName);
     $addurl = $this->generateUrl("JustsyBaseBundle_publicpage_agreejoincircle", array('para' => $para), true);
     $refuseurl = $this->generateUrl("JustsyBaseBundle_circle_refusejoincircle", array(), true);
     $txt = $this->renderView("JustsyBaseBundle:Circle:mail_apply_join.html.twig", array("ename" => $user->ename, "realName" => $user->nick_name, "account" => DES::encrypt($user->getUserName()), "activeurl" => $addurl, "circlename" => $circleName, "refuseurl" => $refuseurl, "para" => $para));
     //发送站内消息
     $sqls = array();
     $paras = array();
     $msgId = SysSeq::GetSeqNextValue($da, "we_message", "msg_id");
     $sqls[] = "insert into we_message(msg_id,sender,recver,send_date,title,content)values(?,?,?,now(),?,?)";
     //$sqls[] = "insert into we_notify(notify_type, msg_id,notify_staff)values('01',?,?)";
     $paras[] = array((int) $msgId, (string) $user->getUserName(), (string) $createStaff, "申请加入圈子", $txt);
     //$paras[] = array((int)$msgId,(string)$createStaff);
     $da->ExecSQLs($sqls, $paras);
     Utils::saveMail($da, $user->getUsername(), $createStaff, "申请加入圈子", $txt, $circleId);
     //Utils::sendMail($this->get('mailer'),"申请加入微发发企业社交圈子",$this->container->getParameter('mailer_user'),null,$createStaff,$txt);
     //发送即时消息
     $im_sender = $this->container->getParameter('im_sender');
     $fafa_jid = $circle["fafa_jid"];
     $message = Utils::makeHTMLElementTag('employee', $user->fafa_jid, $user->nick_name) . "申请加入您的圈子【" . $circleName . "】";
     $buttons = array();
     $buttons[] = array("text" => "拒绝", "code" => "agree", "value" => "0", "link" => $refuseurl . "?para=" . $para);
     $buttons[] = array("text" => "同意", "code" => "agree", "value" => "1", "link" => $addurl);
     Utils::sendImMessage($im_sender, $fafa_jid, "申请加入圈子", $message, $this->container, "", Utils::makeBusButton($buttons), false, Utils::$systemmessage_code);
     return new Response("1");
 }
Example #4
0
 public function reSendInvitationAction()
 {
     $im_sender = $this->container->getParameter('im_sender');
     $da = $this->get('we_data_access');
     $user = $this->get('security.context')->getToken()->getUser();
     $eno = $this->get("request")->request->get("eno");
     $invite_recv_email = $this->get("request")->request->get("invite_recv_email");
     $invInfo = array('inv_send_acc' => $user->getUsername(), 'inv_recv_acc' => $invite_recv_email, 'eno' => $eno, 'inv_rela' => '', 'inv_title' => '', 'inv_content' => '', 'active_addr' => '');
     //被邀请帐号是否存在,存在则update we_invite,不存在 取we_invite的数据,重发邮件
     $sql = "select fafa_jid from we_staff where login_account=?";
     $ds = $da->GetData("we_staff", $sql, array((string) $invite_recv_email));
     if ($ds && $ds['we_staff']['recordcount'] > 0) {
         InviteController::saveWeInvInfo($da, $invInfo);
         //发送即时消息
         $fafa_jid = $ds['we_staff']['rows'][0]['fafa_jid'];
         $message = $user->nick_name . "邀请您加入圈子,请登录微发发进行确认。";
         Utils::sendImMessage($im_sender, $fafa_jid, "邀请加入圈子", $message, $this->container, "", "", false, Utils::$systemmessage_code);
     } else {
         $sql = "select inv_title,inv_content from we_invite where invite_recv_email=? and invite_send_email=? and eno=?";
         $ds = $da->GetData("we_invite", $sql, array((string) $invite_recv_email, (string) $user->getUsername(), (string) $eno));
         if ($ds && $ds['we_invite']['recordcount'] > 0) {
             Utils::saveMail($da, $user->getUsername(), $invite_recv_email, $ds['we_invite']['rows'][0]['inv_title'], $ds['we_invite']['rows'][0]['inv_content'], $eno);
             //Utils::sendMail($this->get('mailer'),$ds['we_invite']['rows'][0]['inv_title'],$this->container->getParameter('mailer_user'),null,$invite_recv_email,$ds['we_invite']['rows'][0]['inv_content']);
         }
         InviteController::saveWeInvInfo($da, $invInfo);
     }
     return new Response("1");
 }
Example #5
0
 public function invitedmemebersAction()
 {
     $re = array("returncode" => ReturnCode::$SUCCESS);
     $user = $this->get('security.context')->getToken()->getUser();
     $request = $this->getRequest();
     $circle_id = $request->get("circle_id");
     $invitedmemebers = $request->get("invitedmemebers");
     $da = $this->get('we_data_access');
     $da_im = $this->get('we_data_access_im');
     try {
         if (empty($invitedmemebers) || empty($circle_id)) {
             $re["returncode"] = ReturnCode::$SYSERROR;
             $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
             $response->headers->set('Content-Type', 'text/json');
             return $response;
         }
         $circlename = "";
         $fafa_groupid = "";
         $user = $this->get('security.context')->getToken()->getUser();
         $invInfo = array('inv_send_acc' => $user->getUsername(), 'inv_recv_acc' => '', 'eno' => '', 'inv_rela' => '', 'inv_title' => '', 'inv_content' => '', 'active_addr' => '');
         $invitedmemebersLst = explode(";", $invitedmemebers);
         $circleStaffs = array();
         $sql = "select login_account from we_circle_staff where circle_id=?";
         $ds = $da->GetData("circle_staffs", $sql, array($circle_id));
         if ($ds && $ds["circle_staffs"]["recordcount"] > 0) {
             foreach ($ds["circle_staffs"]["rows"] as &$row) {
                 $circleStaffs[] = $row['login_account'];
             }
         }
         $sql = "select circle_name,fafa_groupid from we_circle where circle_id=?";
         $ds = $da->GetData("circle", $sql, array($circle_id));
         if ($ds && $ds["circle"]["recordcount"] > 0) {
             $circlename = $ds["circle"]["rows"][0]['circle_name'];
             $fafa_groupid = $ds["circle"]["rows"][0]['fafa_groupid'];
         }
         foreach ($invitedmemebersLst as $key => $value) {
             $invacc = trim($value);
             if (empty($invacc)) {
                 continue;
             }
             $invInfo['inv_recv_acc'] = $invacc;
             $sql = "select eno,fafa_jid from we_staff where login_account=?";
             $ds = $da->GetData("we_staff", $sql, array((string) $invacc));
             //帐号存在
             if ($ds && $ds['we_staff']['recordcount'] > 0) {
                 if (count($circleStaffs) > 0 && in_array($invacc, $circleStaffs)) {
                     continue;
                 }
                 //1.帐号存在,直接加入圈子
                 //受邀人员帐号,圈子id,邀请人帐号
                 $encode = DES::encrypt("{$invacc},{$circle_id}," . $user->getUsername());
                 $activeurl = $this->generateUrl("JustsyBaseBundle_invite_agreejoincircle", array('para' => $encode, 'eno' => 'c' . $circle_id), true);
                 $rejectactiveurl = $this->generateUrl("JustsyBaseBundle_invite_refuse", array('para' => $encode, 'eno' => 'c' . $circle_id), true);
                 $txt = $this->renderView('JustsyBaseBundle:Invite:circle_invitation_msg.html.twig', array("ename" => $user->ename, "nick_name" => $user->nick_name, "activeurl" => $activeurl, 'circle_name' => $circlename, 'invMsg' => '', 'staff' => array()));
                 $invInfo['eno'] = "c{$circle_id}";
                 $invInfo['inv_title'] = "邀请您加入圈子【" . Utils::makeCircleTipHTMLTag($circle_id, $circlename) . "】";
                 $invInfo['inv_content'] = '';
                 $invInfo['active_addr'] = $activeurl;
                 //保存邀请信息
                 InviteController::saveWeInvInfo($da, $invInfo);
                 //发送即时消息
                 $fafa_jid = $ds['we_staff']['rows'][0]['fafa_jid'];
                 $message = Utils::makeHTMLElementTag('employee', $user->fafa_jid, $user->nick_name) . "邀请您加入圈子【" . Utils::makeHTMLElementTag('circle', $fafa_groupid, $circlename) . "】";
                 $buttons = array();
                 $buttons[] = array("text" => "拒绝", "code" => "agree", "value" => "0", "link" => $rejectactiveurl);
                 $buttons[] = array("text" => "立即加入", "code" => "agree", "value" => "1", "link" => $activeurl);
                 Utils::sendImMessage($im_sender, $fafa_jid, "邀请加入圈子", $message, $this->container, "", Utils::makeBusButton($buttons), false, Utils::$systemmessage_code);
             } else {
                 //2.帐号不存在
                 $tmp = explode("@", $invacc);
                 $tmp = count($tmp) > 1 ? $tmp[1] : 'fafatime.com';
                 $sql = "select count(1) as cnt from we_public_domain where domain_name=?";
                 $ds = $da->GetData("we_public_domain", $sql, array((string) $tmp));
                 if ($ds && $ds['we_public_domain']['rows'][0]['cnt'] == 0) {
                     //2.1企业邮箱
                     $sql = "select eno from we_enterprise where edomain=?";
                     $ds = $da->GetData("we_enterprise", $sql, array((string) $tmp));
                     if ($ds && $ds['we_enterprise']['recordcount'] > 0) {
                         //2.1.1企业已创建 帐号,圈子id,企业edomain des encode
                         $eno = $ds['we_enterprise']['rows'][0]['eno'];
                         $encode = DES::encrypt($user->getUsername() . ",{$circle_id},{$eno}");
                         $activeurl = $this->generateUrl("JustsyBaseBundle_active_inv_s1", array('account' => DES::encrypt($invacc), 'invacc' => $encode), true);
                     } else {
                         //2.1.2企业未创建
                         $sql = "insert into we_register (login_account,ename,credential_path,active_code,ip,email_type,first_reg_date,last_reg_date,register_date,state_id)" . " values (?,?,?,?,?,?,now(),now(),now(),'0')";
                         $para = array($invacc, '', '', strtoupper(substr(uniqid(), 3, 10)), $_SERVER['REMOTE_ADDR'], '1');
                         $da->ExecSQL($sql, $para);
                         //发送邮件 帐号,圈子id,邀请发送者帐号,邀请人企业名 des encode
                         $encode = DES::encrypt("{$invacc},{$circle_id}," . $user->getUserName() . "," . $user->ename);
                         $activeurl = $this->generateUrl("JustsyBaseBundle_active_reg_s1", array('account' => $encode), true);
                     }
                     //保存邀请信息 circleid保存到eno字段,以字母'c'开头
                     $invInfo['eno'] = "c{$circle_id}";
                     $title = $user->nick_name . " 邀请您加入 " . Utils::makeCircleTipHTMLTag($circle_id, $circlename) . " 协作网络";
                     $txt = $this->renderView('JustsyBaseBundle:Invite:circle_invitation.html.twig', array("ename" => $user->ename, "nick_name" => $user->nick_name, "activeurl" => $activeurl, 'circle_name' => $circlename, 'invMsg' => '', 'staff' => array()));
                     $invInfo['inv_title'] = $title;
                     $invInfo['inv_content'] = $txt;
                     $invInfo['active_addr'] = $activeurl;
                     InviteController::saveWeInvInfo($da, $invInfo);
                     Utils::saveMail($da, $user->getUsername(), $invacc, $title, $txt, $invInfo['eno']);
                 } else {
                     //公共邮箱
                     $sql = "insert into we_register (login_account,ename,credential_path,active_code,ip,email_type,first_reg_date,last_reg_date,register_date,state_id) " . "select ?,'','','" . strtoupper(substr(uniqid(), 3, 10)) . "','" . $_SERVER['REMOTE_ADDR'] . "','0',now(),now(),now(),'2' from dual " . "where not exists (select 1 from we_register where login_account=?)";
                     $para = array($invacc, $invacc);
                     $da->ExecSQL($sql, $para);
                     //发送邮件 帐号,圈子id,邀请发送者帐号,邀请人企业名 des encode
                     $encode = DES::encrypt("{$invacc},{$circle_id}," . $user->getUserName() . "," . $user->ename);
                     $activeurl = $this->generateUrl("JustsyBaseBundle_active_reg_s1", array('account' => $encode), true);
                     $invInfo['eno'] = "c{$circle_id}";
                     $title = $user->nick_name . " 邀请您加入 " . Utils::makeCircleTipHTMLTag($circle_id, $circlename) . " 协作网络";
                     $txt = $this->renderView('JustsyBaseBundle:Invite:circle_invitation.html.twig', array("ename" => $user->ename, "nick_name" => $user->nick_name, "activeurl" => $activeurl, 'circle_name' => $circlename, 'invMsg' => '', 'staff' => array()));
                     //保存邀请信息
                     $invInfo['inv_title'] = $title;
                     $invInfo['inv_content'] = $txt;
                     $invInfo['active_addr'] = $activeurl;
                     InviteController::saveWeInvInfo($da, $invInfo);
                     Utils::saveMail($da, $user->getUsername(), $invacc, $title, $txt, $invInfo['eno']);
                 }
             }
         }
         $re["returncode"] = ReturnCode::$SUCCESS;
     } catch (\Exception $e) {
         $re["returncode"] = ReturnCode::$SYSERROR;
         $this->get('logger')->err($e);
     }
     $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }
Example #6
0
 public function saveRetrieveReq_3GAction()
 {
     $da = $this->get('we_data_access');
     $login_account = $this->get('request')->request->get('login_account');
     $sql = "select nick_name from we_staff where login_account=?";
     $ds = $da->GetData('we_staff', $sql, array((string) $login_account));
     if (!$ds || $ds['we_staff']['recordcount'] == 0) {
         return $this->render('JustsyBaseBundle:Register:retrieve_pwd_index_3g.html.twig', array('err' => '您输入的帐号不存在!', 'login_account' => $login_account));
     }
     $nick_name = $ds['we_staff']['rows'][0]['nick_name'];
     $id = SysSeq::GetSeqNextValue($da, "we_retrieve_password", "id");
     $sql = "insert into we_retrieve_password (id,login_account,req_date,valid_date,valid) values (?,?,now(),adddate(now(),1),'1')";
     $da->ExecSQL($sql, array($id, $login_account));
     $req_date = getdate();
     //帐号,申请id
     $repwd_url = $this->generateUrl("JustsyBaseBundle_reg_resetpwd", array('para' => DES::encrypt("{$login_account},{$id}")), true);
     $txt = $this->renderView("JustsyBaseBundle:Register:retrieve_pwd_mail.html.twig", array("nick_name" => $nick_name, "req_date" => $req_date['year'] . '年' . $req_date['mon'] . '月' . $req_date['mday'] . '日' . $req_date['hours'] . '时' . $req_date['minutes'] . '分', "repwd_url" => $repwd_url));
     $title = "Wefafa密码找回邮件";
     Utils::saveMail($da, $this->container->getParameter('mailer_user'), $login_account, $title, $txt);
     $tmp = explode("@", $login_account);
     if (count($tmp) > 1) {
         $tmp = $tmp[1];
     }
     $mailaddr = "http://mail.{$tmp}";
     return $this->render('JustsyBaseBundle:Register:retrieve_pwd_req_end_3g.html.twig', array('login_account' => $login_account, 'mailaddr' => $mailaddr));
 }