public function sendInvitationAction() { $res = $this->getRequest(); $im_sender = $this->container->getParameter('im_sender'); $acts = $res->get('acts'); $logger = $this->get('logger'); $da = $this->get('we_data_access'); $user = $this->get('security.context')->getToken()->getUser(); $circleId = $res->get("circleId"); $eno = $res->get('eno'); $invMsg = $res->get('invMsg'); $subject = $res->get('subject'); $invRela = $res->get('invRela'); $circleName = ""; if (!empty($circleId)) { $circleMgr = new \Justsy\BaseBundle\Management\CircleMgr($da, $this->get('we_data_access_im'), null); $circleObj = $circleMgr->Get($circleId); if ($circleObj == null && (empty($eno) || $eno == "-1")) { return new Response('1'); } $circleName = $circleObj["circle_name"]; } $invInfo = array('inv_send_acc' => $user->getUsername(), 'inv_recv_acc' => '', 'eno' => '', 'inv_rela' => $invRela, 'inv_title' => '', 'inv_content' => '', 'active_addr' => ''); $photourl = $this->container->getParameter('FILE_WEBSERVER_URL'); $staff_e = array(); $staff_c = array(); $sql = "select c.login_account,c.nick_name,concat('" . $photourl . "',case trim(ifnull(c.photo_path,'')) when '' then null else c.photo_path end) as photo_path \nfrom we_staff c inner join we_circle_staff d on c.login_account=d.login_account where d.circle_id=(\nselect b.circle_id from we_staff a inner join we_circle b on a.eno=b.enterprise_no and a.login_account=?) limit 0,9"; $ds = $da->GetData("staff", $sql, array((string) $user->getUsername())); if ($ds && $ds['staff']['recordcount'] > 0) { $staff_e = $ds['staff']['rows']; } $sql = "select a.login_account,a.nick_name,concat('" . $photourl . "',case trim(ifnull(a.photo_path,'')) when '' then null else a.photo_path end) as photo_path \nfrom we_staff a inner join we_circle_staff b on a.login_account=b.login_account\nwhere a.eno=(select eno from we_staff where login_account=?) and b.circle_id=? limit 0,9"; $ds = $da->GetData("staff", $sql, array((string) $user->getUsername(), (string) $circleId)); if ($ds && $ds['staff']['recordcount'] > 0) { $staff_c = $ds['staff']['rows']; } try { foreach ($acts as $key => $value) { $invacc = trim($value); $invInfo['inv_recv_acc'] = $invacc; //排除自己 if ($invacc == $user->getUsername()) { continue; } $sql = "select fafa_jid from we_staff where login_account=?"; $ds = $da->GetData("we_staff", $sql, array((string) $invacc)); $isReg = $ds && $ds['we_staff']['recordcount'] > 0; //是否已注册 if (empty($eno) || $eno == "-1") { //加入圈子 if ($isReg) { //1.帐号存在,直接加入圈子 //受邀人员帐号,圈子id,邀请人帐号 $encode = DES::encrypt("{$invacc},{$circleId}," . $user->getUsername()); $activeurl = $this->generateUrl("JustsyBaseBundle_invite_agreejoincircle", array('para' => $encode, 'eno' => 'c' . $circleId), true); $rejectactiveurl = $this->generateUrl("JustsyBaseBundle_invite_refuse", array('para' => $encode, 'eno' => 'c' . $circleId), 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' => $invMsg)); $invInfo['eno'] = "c{$circleId}"; if (empty($subject)) { if ($circleId == "9999") { $invInfo['inv_title'] = $user->nick_name . " 邀请您加入TA的人脉圈"; } else { $invInfo['inv_title'] = $user->nick_name . " 邀请您加入圈子【" . Utils::makeCircleTipHTMLTag($circleId, $circleName) . "】"; } } else { $invInfo['inv_title'] = $subject; } $invInfo['inv_content'] = $invMsg; $invInfo['active_addr'] = $activeurl; //保存邀请信息 InviteController::saveWeInvInfo($da, $invInfo); //发送即时消息 $fafa_jid = $ds['we_staff']['rows'][0]['fafa_jid']; if ($circleId == "9999") { $message = Utils::makeHTMLElementTag('employee', $user->fafa_jid, $user->nick_name) . "邀请您加入TA的人脉圈"; } else { $message = Utils::makeHTMLElementTag('employee', $user->fafa_jid, $user->nick_name) . "邀请您加入圈子【" . Utils::makeHTMLElementTag('circle', $circleObj["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($user->fafa_jid, $fafa_jid, "邀请加入圈子", $message, $this->container, "", Utils::makeBusButton($buttons), false, Utils::$systemmessage_code, "1"); } 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}"); $eno = ""; $activeurl = $this->generateUrl("JustsyBaseBundle_active_inv_s1", array('account' => DES::encrypt($invacc), 'invacc' => $encode), true); $staff_t = $staff_e; $has_e = "1"; } 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) " . "select ?,'','','" . strtoupper(substr(uniqid(), 3, 10)) . "','" . $_SERVER['REMOTE_ADDR'] . "','1',now(),now(),now(),'0' 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); $staff_t = array(); $has_e = "0"; } //保存邀请信息 circleid保存到eno字段,以字母'c'开头 if ($circleId == "-1") { $invInfo['eno'] = "-1"; $title = empty($subject) ? $user->nick_name . " 邀请您加入Wefafa企业协作网络" : $subject; $txt = $this->renderView("JustsyBaseBundle:Invite:enterprise_invitation.html.twig", array("ename" => $user->ename, "realName" => $user->nick_name, "activeurl" => $activeurl, "invMsg" => $invMsg, "staff" => $staff_t, "has_e" => $has_e)); } else { if ($invRela == "0") { $has_e = "1"; $staff_t = $staff_e; } else { $has_e = "0"; $staff_t = array(); } $invInfo['eno'] = "c{$circleId}"; $title = empty($subject) ? $user->nick_name . " 邀请您加入 " . Utils::makeCircleTipHTMLTag($circleId, $circleName) . " 协作网络" : $subject; $txt = $this->renderView('JustsyBaseBundle:Invite:circle_invitation.html.twig', array("ename" => $user->ename, "nick_name" => $user->nick_name, "activeurl" => $activeurl, 'circle_name' => $circleName, 'invMsg' => $invMsg, "staff" => $staff_t, "has_e" => $has_e)); } $invInfo['inv_title'] = $title; $invInfo['inv_content'] = $txt; $invInfo['active_addr'] = $activeurl; InviteController::saveWeInvInfo($da, $invInfo); $title = empty($subject) ? $user->nick_name . " 邀请您加入 " . $circleName . " 协作网络" : $subject; 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 { //2.2公共邮箱 if ($invRela == "0") { //邀请同事 $eno = $user->eno; $encode = DES::encrypt($user->getUsername() . ",{$circleId},{$eno}"); $eno = ""; $activeurl = $this->generateUrl("JustsyBaseBundle_active_inv_s1", array('account' => DES::encrypt($invacc), 'invacc' => $encode), true); $txt = $this->renderView('JustsyBaseBundle:Invite:circle_invitation.html.twig', array("ename" => $user->ename, "nick_name" => $user->nick_name, "activeurl" => $activeurl, 'circle_name' => $circleName, 'invMsg' => $invMsg, "staff" => $staff_c, "has_e" => "1")); //保存邀请信息 circleid保存到eno字段,以字母'c'开头 $invInfo['eno'] = "c{$circleId}"; $invInfo['inv_title'] = empty($subject) ? $user->nick_name . " 邀请您加入 " . Utils::makeCircleTipHTMLTag($circleId, $circleName) . " 协作网络" : $subject; $invInfo['inv_content'] = $txt; $invInfo['active_addr'] = $activeurl; InviteController::saveWeInvInfo($da, $invInfo); $invInfo['inv_title'] = empty($subject) ? $user->nick_name . " 邀请您加入 " . $circleName . " 协作网络" : $subject; Utils::saveMail($da, $user->getUsername(), $invacc, $invInfo['inv_title'], $txt, $invInfo['eno']); //Utils::sendMail($this->get('mailer'),"邀请加入圈子【".$circleName."】",$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); if ($circleId == "-1") { $invInfo['eno'] = "-1"; $circleName = "Wefafa企业"; $title = empty($subject) ? $user->nick_name . " 邀请您加入" . $circleName . "协作网络" : $subject; $txt = $this->renderView("JustsyBaseBundle:Invite:enterprise_invitation.html.twig", array("ename" => $user->ename, "realName" => $user->nick_name, "activeurl" => $activeurl, "invMsg" => $invMsg, "staff" => array())); } else { $invInfo['eno'] = "c{$circleId}"; $title = empty($subject) ? $user->nick_name . " 邀请您加入 " . Utils::makeCircleTipHTMLTag($circleId, $circleName) . " 协作网络" : $subject; $txt = $this->renderView('JustsyBaseBundle:Invite:circle_invitation.html.twig', array("ename" => $user->ename, "nick_name" => $user->nick_name, "activeurl" => $activeurl, 'circle_name' => $circleName, 'invMsg' => $invMsg, "staff" => array())); } //保存邀请信息 $invInfo['inv_title'] = $title; $invInfo['inv_content'] = $txt; $invInfo['active_addr'] = $activeurl; InviteController::saveWeInvInfo($da, $invInfo); $invInfo['inv_title'] = empty($subject) ? $user->nick_name . " 邀请您加入 " . $circleName . " 协作网络" : $subject; 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 { //判断受邀请人是否已注册,已注册的不能再邀请加个企业圈子 //与邀请人不同企业域的其他企业邮箱不能加入 if (!$isReg) { //加入企业 $activeurl = $this->generateUrl("JustsyBaseBundle_active_inv_s1", array('account' => DES::encrypt($invacc), 'invacc' => DES::encrypt($user->getUsername())), true); $txt = $this->renderView("JustsyBaseBundle:Invite:enterprise_invitation.html.twig", array("ename" => $user->ename, "realName" => $user->nick_name, "activeurl" => $activeurl, "invMsg" => $invMsg, "staff" => $staff_e, "has_e" => "1")); //保存邀请信息 $invInfo['eno'] = $eno; $invInfo['inv_title'] = empty($subject) ? "您的同事 " . $user->nick_name . " 邀请您加入Wefafa企业协作网络" : $subject; $invInfo['inv_content'] = $txt; $invInfo['active_addr'] = $activeurl; InviteController::saveWeInvInfo($da, $invInfo); Utils::saveMail($da, $user->getUsername(), $invacc, $invInfo['inv_title'], $txt, $invInfo['eno']); } } } } catch (\Exception $e) { $logger->err($e); return new Response('0'); } return new Response('1'); }
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')); } }
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; }