public function refuseJoinAction() { $para = $this->getRequest()->get('para'); $paraArr = explode(",", trim(DES::decrypt($para))); $da = $this->get("we_data_access"); $user = $this->get('security.context')->getToken()->getUser(); //检查帐号是否存在 $sql = "select eno from we_staff where login_account=?"; $ds = $da->GetData('we_staff', $sql, array((string) $paraArr[1])); if (!$ds || $ds['we_staff']['recordcount'] == 0) { return new Response("0"); } $eno = $ds['we_staff']['rows'][0]['eno']; $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) $paraArr[0], (string) $paraArr[1])); if ($ds && $ds['we_circle_staff']['rows'][0]['cnt'] > 0) { return new Response("0"); } else { $txt = "您加入圈子【" . $paraArr[3] . "】的请求被拒绝了!"; $msgId = SysSeq::GetSeqNextValue($da, "we_message", "msg_id"); $sql = "insert into we_message(msg_id,sender,recver,send_date,title,content)values(?,?,?,now(),?,?)"; $param = array((int) $msgId, (string) $user->getUserName(), (string) $paraArr[1], "申请加入圈子被拒绝", $txt); $da->ExecSQL($sql, $param); $apply = new \Justsy\BaseBundle\Management\ApplyMgr($da, null); $apply->SetCircleApplyInvalid($paraArr[1], $paraArr[0]); //发送即时消息通知申请人 $im_sender = $this->container->getParameter('im_sender'); $message = $txt; Utils::sendImMessage($im_sender, $paraArr[1], "圈子消息", $message, $this->container, "", "", true, Utils::$systemmessage_code); return new Response("1"); } }
$activeurl = $this->generateUrl("JustsyBaseBundle_group_invjoin", array('para' => $encode), true); $txt = $this->renderView("JustsyBaseBundle:Group:message.html.twig", array("ename" => $user->ename, "realName" => $user->nick_name, "activeurl" => $activeurl, "gname" => $gname, "invMsg" => $invMsg)); $msgId = SysSeq::GetSeqNextValue($da, "we_message", "msg_id"); $sqls[] = "insert into we_message(msg_id,sender,recver,title,content,send_date)values(?,?,?,?,?,now())"; $paras[] = array((string) $msgId, (string) $user->getUsername(), (string) $act, (string) $title, (string) $txt); //发送即时消息 //$message = $user->nick_name."邀请您加入群组【".$gname."】"; $message = Utils::makeHTMLElementTag('employee', $user->fafa_jid, $user->nick_name) . "邀请您加入群组【" . Utils::makeHTMLElementTag('group', $fafa_groupid, $gname) . "】"; $buttons = array(); $buttons[] = array("text" => "拒绝", "code" => "agree", "value" => "0"); $buttons[] = array("text" => "立即加入", "code" => "agree", "value" => "1"); $b &= Utils::sendImMessage($user->fafa_jid, $jid, $title, $message, $this->container, $activeurl . "?invite_user="******"1");
public function agreeJoinCircleAction($para) { if (empty($para)) { return $this->render('JustsyBaseBundle:Error:index.html.twig', array('error' => '参数错误!')); } $da = $this->get('we_data_access'); $res = $this->get('request'); $urlSource = $res->get("_urlSource"); //获取操作源。FaFaWin:从PC客户端操作的 //受邀人员帐号,圈子id,邀请人帐号 $paraArr = explode(",", trim(DES::decrypt($para))); //是否有帐号 $sql = "select nick_name,fafa_jid from we_staff where login_account=?"; $ds = $da->GetData("we_staff", $sql, array((string) $paraArr[0])); if (!$ds || $ds['we_staff']['recordcount'] == 0) { if (empty($urlSource)) { return $this->render('JustsyBaseBundle:Error:index.html.twig', array('error' => '您还没有微发发帐号,请先注册!')); } else { $response = new Response("{\"succeed\":0,\"msg\":\"您还没有微发发帐号,请先注册!\"}"); $response->headers->set('Content-Type', 'text/json'); return $response; } } //判断是否是邀请加入人脉圈子,则在互相关注 if ($paraArr[1] == "9999") { //互相添加好友 $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $this->get('we_data_access_im'), $paraArr[2], $this->get("logger")); try { $staffMgr->attentionTo($paraArr[0]); } catch (\Exception $e) { } try { $staffMgr->attentionMe($paraArr[0]); } catch (\Exception $e) { } try { $staffMgr->bothAddFriend($this->container, $paraArr[0]); } catch (\Exception $e) { } $response = new Response("{\"succeed\":1,\"name\":\"人脉圈\",\"circleurl\":\"" . $this->generateUrl("JustsyBaseBundle_enterprise", array('network_domain' => "9999"), true) . "\"}"); $response->headers->set('Content-Type', 'text/json'); return $response; } $nick_name = $ds['we_staff']['rows'][0]['nick_name']; $fafa_jid = $ds['we_staff']['rows'][0]['fafa_jid']; //圈子是否存在 $sql = "select network_domain,circle_name,fafa_groupid from we_circle where circle_id=?"; $ds = $da->GetData("we_circle", $sql, array((string) $paraArr[1])); if (!$ds || $ds['we_circle']['recordcount'] == 0) { if (empty($urlSource)) { return $this->render('JustsyBaseBundle:Error:index.html.twig', array('error' => '您要加入的圈子不存在!')); } else { $response = new Response("{\"succeed\":0,\"msg\":\"您要加入的圈子不存在!\"}"); $response->headers->set('Content-Type', 'text/json'); return $response; } } $fafa_groupid = $ds['we_circle']['rows'][0]['fafa_groupid']; $network_domain = $ds['we_circle']['rows'][0]['network_domain']; $circle_name = $ds['we_circle']['rows'][0]['circle_name']; //是否已经加入圈子 $sql = "select count(1) cnt from we_circle_staff where login_account=? and circle_id=?"; $ds = $da->GetData("cnt", $sql, array((string) $paraArr[0], (string) $paraArr[1])); if ($ds && $ds['cnt']['rows'][0]['cnt'] > 0) { if (empty($urlSource)) { return $this->render('JustsyBaseBundle:Error:index.html.twig', array('error' => '您已经加入该圈子!')); } else { $response = new Response("{\"succeed\":0,\"msg\":\"您已经加入该圈子!\"}"); $response->headers->set('Content-Type', 'text/json'); return $response; } } //圈子id+nick_name不能重复 $sql = "select count(1) cnt from we_circle_staff where circle_id=? and nick_name=?"; $ds = $da->GetData("cnt", $sql, array((string) $paraArr[1], (string) $nick_name)); if ($ds && $ds['cnt']['rows'][0]['cnt'] > 0) { $user = $this->get('security.context')->getToken()->getUser(); $nick_name = $nick_name . "(" . $user->eshortname . ")"; } //判断圈子是否有人 $sql = "select count(1) as cnt from we_circle_staff where circle_id=?"; $ds = $da->GetData('we_circle_staff', $sql, array((string) $paraArr[1])); if ($ds && $ds['we_circle_staff']['rows'][0]['cnt'] == 0) { $sql = "update we_circle set create_staff=? where circle_id=?"; $da->ExecSQL($sql, array((string) $paraArr[0], (string) $paraArr[1])); } $sql = "insert into we_circle_staff (circle_id,login_account,nick_name) values (?,?,?)"; $da->ExecSQL($sql, array((string) $paraArr[1], (string) $paraArr[0], (string) $nick_name)); //更新邀请信息 $sql = "update we_invite set real_active_email=?,active_date=now() where invite_send_email=? and invite_recv_email=? and eno=?"; $da->ExecSQL($sql, array((string) $paraArr[0], (string) $paraArr[2], (string) $paraArr[0], (string) ("c" . $paraArr[1]))); //10-加入外部圈子-5 $sql = "insert into we_staff_points (login_account,point_type,point_desc,point,point_date) values (?,?,?,?,now())"; $da->ExecSQL($sql, array((string) $paraArr[0], (string) '10', (string) '成功加入外部圈子' . $circle_name . ',获得积分5', (int) 5)); $apply = new \Justsy\BaseBundle\Management\ApplyMgr($da, null); $apply->SetCircleApplyInvalid($paraArr[0], $paraArr[1]); //发送即时消息通知申请人及成员 $circleObj = new \Justsy\BaseBundle\Controller\CircleController(); $circleObj->setContainer($this->container); $message = Utils::makeHTMLElementTag('employee', $fafa_jid, $nick_name) . "加入了圈子【" . Utils::makeHTMLElementTag('circle', $fafa_groupid, $circle_name) . "】"; $circleObj->sendPresenceCirlce($paraArr[1], "circle_addmember", $message); $backurl = $this->generateUrl("JustsyBaseBundle_enterprise", array('network_domain' => $paraArr[0]), true); if (empty($urlSource)) { return $this->render('JustsyBaseBundle:Error:success.html.twig', array('backurl' => $backurl)); } else { $response = new Response("{\"succeed\":1,\"name\":\"" . $circle_name . "\",\"circleurl\":\"" . $backurl . "\"}"); $response->headers->set('Content-Type', 'text/json'); return $response; } }