Beispiel #1
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");
 }
Beispiel #2
0
 public function updateAction(Request $request)
 {
     $user = $this->get('security.context')->getToken()->getUser();
     $circleid = $request->get("id");
     $da = $this->get("we_data_access");
     $da_im = $this->get('we_data_access_im');
     $session = $this->get('session');
     $filename120 = $session->get("circle_filename120");
     $filename48 = $session->get("circle_filename48");
     $filename24 = $session->get("circle_filename24");
     $im_sender = $this->container->getParameter('im_sender');
     /*
     $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");
     */
     $fileid = "";
     $fafa_groupid = "";
     //判断是添加还是修改
     $table = $da->GetData("circle", "select circle_id,logo_path,logo_path_small,logo_path_big,fafa_groupid from we_circle where manager=? and circle_id=?", array((string) $user->getUserName(), (string) $circleid));
     if ($table && $table["circle"]["recordcount"] == 0) {
         $circleid = 0;
     } else {
         $fafa_groupid = $table["circle"]["rows"][0]["fafa_groupid"];
     }
     //判断是否能创建圈子
     $ec = new \Justsy\BaseBundle\Management\EnoParamManager($da, $this->get('logger'));
     if ($ec->IsBeyondCreateCircle($user->getUserName())) {
         return $this->render('JustsyBaseBundle:login:index.html.twig', array('name' => 'err'));
     }
     if (!empty($filename120)) {
         if ($table && $table["circle"]["recordcount"] > 0) {
             $this->removeFile($table["circle"]["rows"][0]["logo_path"], $dm);
             $this->removeFile($table["circle"]["rows"][0]["logo_path_small"], $dm);
             $this->removeFile($table["circle"]["rows"][0]["logo_path_big"], $dm);
         }
     }
     $classify = $session->get("classify");
     //$classify_childer = $session->get("classify-childer");
     $classify_childer = $request->get("classify-childer");
     //对数据的操作
     $sqls = "";
     $paras = "";
     if ($circleid == 0) {
         $circle_id = (string) SysSeq::GetSeqNextValue($da, "we_circle", "circle_id");
         $fafa_groupid = SysSeq::GetSeqNextValue($da_im, "im_group", "groupid");
         $network = $circle_id;
         $sqls = array("insert into we_circle(circle_id,circle_name,circle_desc,logo_path,logo_path_big,logo_path_small,create_staff,create_date,manager,join_method,network_domain,allow_copy,circle_class_id,fafa_groupid)value(?,?,?,?,?,?,?,now(),?,?,?,?,?,?)", "insert into we_circle_staff(circle_id,login_account,nick_name)values(?,?,?)");
         $paras = array(array((string) $circle_id, (string) $request->get("txtcircle"), (string) $request->get("txtdesc"), (string) $filename48, (string) $filename120, (string) $filename24, (string) $user->getUsername(), (string) $user->getUsername(), (string) $request->get("radjoin"), $network, (string) $request->get("radcopy"), (string) $classify_childer, (string) $fafa_groupid), array((string) $circle_id, (string) $user->getUsername(), (string) $user->nick_name));
     } else {
         if (!empty($filename120)) {
             $sqls = "update we_circle set circle_name=?,circle_desc=?,logo_path=?,logo_path_big=?,logo_path_small=?,join_method=?,allow_copy=?,circle_class_id=? where circle_id=?";
             $paras = array((string) $request->get("txtcircle"), (string) $request->get("txtdesc"), (string) $filename48, (string) $filename120, (string) $filename24, (string) $request->get("radjoin"), (string) $request->get("radcopy"), (string) $circleid, (string) $classify_childer);
         } else {
             $sqls = "update we_circle set circle_name=?,circle_desc=?,join_method=?,allow_copy=?,circle_class_id=? where circle_id=?";
             $paras = array((string) $request->get("txtcircle"), (string) $request->get("txtdesc"), (string) $request->get("radjoin"), (string) $request->get("radcopy"), (string) $circleid, (string) $classify_childer);
         }
         $circle_id = $circleid;
     }
     try {
         if ($circleid == 0) {
             $da->ExecSQLs($sqls, $paras);
             //创建文档根目录
             $docCtl = new \Justsy\BaseBundle\Controller\DocumentMgrController();
             $docCtl->setContainer($this->container);
             if ($docCtl->createDir("c" . $circle_id, "", $request->get("txtcircle"), $circle_id) > 0) {
                 $docCtl->saveShare("c" . $circle_id, "0", $circle_id, "c", "w");
                 //将圈子目录共享给该圈子成员
             }
         } else {
             $da->ExecSQL($sqls, $paras);
         }
         //给创建者发送创建群组成功出席
         Utils::sendImPresence($im_sender, $user->fafa_jid, "creategroup", json_encode(array("groupid" => $fafa_groupid, "groupname" => $request->get("txtcircle"))), $this->container, "", "", false, Utils::$systemmessage_code);
         //发送邀请邮件
         $circleId = $circle_id;
         $circleName = $request->get("txtcircle");
         $invitedmemebers = $request->get('invitedmemebers');
         if (!empty($invitedmemebers)) {
             $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);
             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) {
                     //1.帐号存在,直接加入圈子
                     //受邀人员帐号,圈子id,邀请人帐号
                     $encode = DES::encrypt("{$invacc},{$circleId}," . $user->getUsername());
                     $activeurl = $this->generateUrl("JustsyBaseBundle_invite_agreejoincircle", array('para' => $encode), true);
                     $rejectactiveurl = $this->generateUrl("JustsyBaseBundle_invite_refuse", array('para' => $encode), 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{$circleId}";
                     $invInfo['inv_title'] = "邀请加入圈子【" . Utils::makeCircleTipHTMLTag($circleid == 0 ? $circle_id : $circleid, $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() . ",{$circleId},{$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},{$circleId}," . $user->getUserName() . "," . $user->ename);
                             $activeurl = $this->generateUrl("JustsyBaseBundle_active_reg_s1", array('account' => $encode), true);
                         }
                         //保存邀请信息 circleid保存到eno字段,以字母'c'开头
                         $invInfo['eno'] = "c{$circleId}";
                         $title = $user->nick_name . " 邀请您加入 " . Utils::makeCircleTipHTMLTag($circleid == 0 ? $circle_id : $circleid, $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']);
                         //Utils::sendMail($this->get('mailer'),$title,$this->container->getParameter('mailer_user'),null,$invacc,$txt);
                     } 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},{$circleId}," . $user->getUserName() . "," . $user->ename);
                         $activeurl = $this->generateUrl("JustsyBaseBundle_active_reg_s1", array('account' => $encode), true);
                         $invInfo['eno'] = "c{$circleId}";
                         $title = $user->nick_name . " 邀请您加入 " . Utils::makeCircleTipHTMLTag($circleid == 0 ? $circle_id : $circleid, $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']);
                         //Utils::sendMail($this->get('mailer'),$title,$this->container->getParameter('mailer_user'),null,$invacc,$txt);
                     }
                 }
             }
         }
         return $this->redirect($this->generateUrl("JustsyBaseBundle_enterprise", array('network_domain' => $circle_id), true));
     } catch (Exception $e) {
         return $this->render('JustsyBaseBundle:login:index.html.twig', array('name' => 'err'));
     }
 }
Beispiel #3
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;
 }