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"); }