Ejemplo n.º 1
0
 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;
     }
 }
Ejemplo n.º 2
0
 public function exitcircleAction()
 {
     $re = array("returncode" => ReturnCode::$SUCCESS);
     $user = $this->get('security.context')->getToken()->getUser();
     $request = $this->getRequest();
     $circle_id = $request->get("circle_id");
     $da = $this->get('we_data_access');
     $da = $this->get('we_data_access');
     $da_im = $this->get('we_data_access_im');
     try {
         if (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;
         }
         $sql = "call p_quitcircle(?, ?, 0)";
         $params = array();
         $params[] = (string) $circle_id;
         $params[] = (string) $user->getUserName();
         $ds = $da->GetData("p_quitcircle", $sql, $params);
         if ($ds["p_quitcircle"]["rows"][0]["recode"] == "0") {
             //向成员发送通知
             $msgJson = array();
             $msgJson["circle_id"] = $circle_id;
             $msgJson["member"] = $user->getUserName();
             $message = Utils::makeHTMLElementTag('employee', $user->fafa_jid, $user->nick_name) . "退出了圈子【" . $circleObj["circle_name"] . "】";
             $msgJson["text"] = $message;
             $circleCtl = new \Justsy\BaseBundle\Controller\CircleController();
             $circleCtl->setContainer($this->container);
             $circleCtl->sendPresenceCirlce($circle_id, "circle_deletemeber", json_encode($msgJson));
         } else {
             $re["returncode"] = ReturnCode::$SYSERROR;
             $logger = $this->container->get('logger');
             $logger->err("quitCircle Error circle_id:" . $circle_id . " msg:" . $ds["p_quitgroup"]["rows"][0]["remsg"]);
         }
     } 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;
 }