예제 #1
0
 public function createGroupAction()
 {
     $re = array("returncode" => ReturnCode::$SUCCESS, 'msg' => '');
     $request = $this->getRequest();
     $da = $this->get("we_data_access");
     $da_im = $this->get('we_data_access_im');
     $user = $this->get('security.context')->getToken()->getUser();
     $eno = $user->eno;
     $login_account = $user->getUserName();
     $circleId = $request->get('circleId');
     if (empty($circleId)) {
         //获取内部圈子
         $sql = "select circle_id from we_circle where enterprise_no=?";
         $params = array($eno);
         $ds = $da->Getdata('circle', $sql, $params);
         $circleId = $ds['circle']['rows'][0]['circle_id'];
     }
     $isCreate = "0";
     $groups = $this->getGroupByCircle($circleId, $user->getUserName());
     $joinMethod = $request->get('radjoin');
     if (empty($joinMethod)) {
         $joinMethod = '0';
     }
     $gname = $request->get('gname');
     $des = $request->get('des');
     $typeid = $request->get('classify');
     $typeid = '';
     try {
         //群组名称不能为空,加入方式验证
         if ($gname != '' || $joinMethod != '' && preg_match("^/[0|1]\$/", $joinMethod)) {
             //判断重名
             $sql = "select 1 from we_groups where group_name=?";
             $params = array($gname);
             $ds = $da->Getdata('gp', $sql, $params);
             if ($ds['gp']['recordcount'] == 0) {
                 //根据typeid取出typename
                 $sql = "select typename from im_grouptype where typeid=?";
                 $ds = $da_im->GetData('im_grouptype', $sql, array($typeid));
                 $typename = '';
                 if ($ds['im_grouptype']["recordcount"] > 0) {
                     $typename = $ds["im_grouptype"]['rows'][0]["typename"];
                 }
                 //注册fafa_group
                 $sqls = array();
                 $paras = array();
                 $fafa_groupid = SysSeq::GetSeqNextValue($da_im, "im_group", "groupid");
                 $sqls[] = "insert into im_group (groupid, groupname, groupclass, groupdesc, creator, add_member_method, accessright) \n        values (?, ?, ?, ?, ?, ?, 'any')";
                 $paras[] = array((string) $fafa_groupid, (string) $gname, (string) $typename, (string) $des, (string) $user->fafa_jid, (string) $joinMethod);
                 $sqls[] = "insert into im_groupemployee (employeeid, groupid, employeenick, grouprole) values (?,?,?,'owner')";
                 $paras[] = array((string) $user->fafa_jid, (string) $fafa_groupid, (string) $user->nick_name);
                 //跟新群组版本号
                 $sqls[] = "delete from im_group_version where us=?";
                 $paras[] = array((string) $user->fafa_jid);
                 $da_im->ExecSQLs($sqls, $paras);
                 //保存图标
                 $fileid = '';
                 //$fileid = $session->get("group_logo_id");
                 //if (!empty($filename120)) $fileid = Utils::saveFile($filename120,$this->get('doctrine.odm.mongodb.document_manager'));
                 //保存
                 $sqls = array();
                 $paras = array();
                 $groupId = SysSeq::GetSeqNextValue($da, "we_groups", "group_id");
                 $sqls[] = "insert into we_groups (group_id,circle_id,group_name,group_desc,group_photo_path,\n        join_method,create_staff,fafa_groupid,create_date, group_class)\n        values (?,?,?,?,?,?,?,?,now(),?)";
                 $paras[] = array((string) $groupId, (string) $circleId, (string) $gname, (string) $des, (string) $fileid, (string) $joinMethod, (string) $user->getUserName(), (string) $fafa_groupid, (string) $typeid);
                 $sqls[] = "insert into we_group_staff (group_id,login_account) values (?,?)";
                 $paras[] = array((string) $groupId, (string) $user->getUserName());
                 $da->ExecSQLs($sqls, $paras);
                 //创建文档根目录
                 $docCtl = new \Justsy\BaseBundle\Controller\DocumentMgrController();
                 $docCtl->setContainer($this->container);
                 if ($docCtl->createDir("g" . $groupId, "c" . $circleId, $gname, $circleId) > 0) {
                     $docCtl->saveShare("g" . $groupId, "0", $groupId, "g", "w");
                     //将群目录共享给该群组成员
                 }
             } else {
                 $re["returncode"] = ReturnCode::$OTHERERROR;
                 $re["msg"] = "群组名称重复";
             }
         } else {
             $re["returncode"] = ReturnCode::$OTHERERROR;
             $re["msg"] = "参数不能为空或格式错误";
         }
     } catch (\Exception $e) {
         $re["returncode"] = ReturnCode::$SYSERROR;
         $re["msg"] = "系统错误";
         $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;
 }
예제 #2
0
 public function createSaveAction($network_domain)
 {
     $user = $this->get('security.context')->getToken()->getUser();
     $re = array();
     $request = $this->get('request');
     $invs = $request->get('invs');
     $session = $this->get('session');
     $da = $this->get('we_data_access');
     $da_im = $this->get('we_data_access_im');
     $logger = $this->get('logger');
     $this->circleId = $request->get('circleId');
     $this->isCreate = "0";
     $this->groups = $this->getGroupByCircle($this->circleId, $user->getUserName());
     $this->joinMethod = $request->get('radjoin');
     $this->gname = $request->get('gname');
     $this->des = $request->get('des');
     $typeid = "discussgroup";
     // $request->get('classify');
     try {
         //根据typeid取出typename
         /*
 	$sql = "select typename from im_grouptype where typeid=?";
 	$ds = $da_im->GetData('im_grouptype',$sql,array($typeid));    
 	$typename='discussgroup';
 	if($ds['im_grouptype']["recordcount"]>0){
 			$typename=$ds["im_grouptype"]['rows'][0]["typename"];
 	}*/
         $typename = 'discussgroup';
         //全部默认为临时组
         //注册fafa_group
         $sqls = array();
         $paras = array();
         $fafa_groupid = SysSeq::GetSeqNextValue($da_im, "im_group", "groupid");
         $sqls[] = "insert into im_group (groupid, groupname, groupclass, groupdesc, creator, add_member_method, accessright) \r        values (?, ?, ?, ?, ?, ?, 'any')";
         $paras[] = array((string) $fafa_groupid, (string) $this->gname, (string) $typename, (string) $this->des, (string) $user->fafa_jid, (string) $this->joinMethod);
         $sqls[] = "insert into im_groupemployee (employeeid, groupid, employeenick, grouprole) values (?,?,?,'owner')";
         $paras[] = array((string) $user->fafa_jid, (string) $fafa_groupid, (string) $user->nick_name);
         //跟新群组版本号
         $sqls[] = "delete from im_group_version where us=?";
         $paras[] = array((string) $user->fafa_jid);
         $da_im->ExecSQLs($sqls, $paras);
         //保存图标
         $fileid = '';
         $fileid = $session->get("group_logo_id");
         //if (!empty($filename120)) $fileid = Utils::saveFile($filename120,$this->get('doctrine.odm.mongodb.document_manager'));
         //保存
         $sqls = array();
         $paras = array();
         $groupId = SysSeq::GetSeqNextValue($da, "we_groups", "group_id");
         $sqls[] = "insert into we_groups (group_id,circle_id,group_name,group_desc,group_photo_path,\r        join_method,create_staff,fafa_groupid,create_date, group_class)\r        values (?,?,?,?,?,?,?,?,now(),?)";
         $paras[] = array((string) $groupId, (string) $this->circleId, (string) $this->gname, (string) $this->des, (string) $fileid, (string) $this->joinMethod, (string) $user->getUserName(), (string) $fafa_groupid, (string) $typeid);
         $sqls[] = "insert into we_group_staff (group_id,login_account) values (?,?)";
         $paras[] = array((string) $groupId, (string) $user->getUserName());
         $da->ExecSQLs($sqls, $paras);
         //变更版本信息
         $this->get("logger")->err("------------create group -----------");
         $curuser = $this->get('security.context')->getToken()->getUser();
         $eno = $curuser->eno;
         $verchange = new \Justsy\BaseBundle\Management\VersionChange($da, $this->get("logger"));
         $result = $verchange->SetVersionChange(2, (string) $groupId, $eno);
         //创建文档根目录
         $docCtl = new \Justsy\BaseBundle\Controller\DocumentMgrController();
         $docCtl->setContainer($this->container);
         if ($docCtl->createDir("g" . $groupId, "c" . $this->circleId, $this->gname, $this->circleId) > 0) {
             $docCtl->saveShare("g" . $groupId, "0", $groupId, "g", "w");
             //将群目录共享给该群组成员
         }
         $invs = $request->get('invs');
         $im_sender = $this->container->getParameter('im_sender');
         //给创建者发送创建群组成功出席
         Utils::sendImPresence($im_sender, $user->fafa_jid, "creategroup", json_encode(array("groupid" => $fafa_groupid, "logoid" => $fileid, "groupname" => $this->gname)), $this->container, "", "", false, Utils::$systemmessage_code);
         //给邀请人员发送消息 站内和即时消息
         if (!empty($invs)) {
             $invs = explode(";", $invs);
             $title = "群组消息";
             $message = $user->nick_name . "邀请你加入了群组:" . $this->gname;
             foreach ($invs as $key => $value) {
                 if (empty($value)) {
                     continue;
                 }
                 $sqls[] = "insert into we_group_staff (group_id,login_account) values (?,?)";
                 $paras[] = array((string) $groupId, (string) $value);
                 $da->ExecSQLs($sqls, $paras);
                 Utils::sendImPresence($im_sender, $fafa_jid, "creategroup", json_encode(array("groupid" => $fafa_groupid, "logoid" => $fileid, "groupname" => $this->gname)), $this->container, "", "", false, Utils::$systemmessage_code);
                 Utils::sendImMessage($im_sender, $fafa_jid, $title, $message, $this->container, "", false, Utils::$systemmessage_code, "1");
                 /*
       //群编号,被邀请人帐号,network_domain,fafa_groupid
       $encode = DES::encrypt("$groupId,$value,$network_domain,".$fafa_groupid);
예제 #3
0
 public function creategroupAction()
 {
     $re = array("returncode" => ReturnCode::$SUCCESS);
     $user = $this->get('security.context')->getToken()->getUser();
     $request = $this->getRequest();
     $circleid = $request->get("circle_id");
     $groupname = $request->get("group_name");
     $groupdesc = $request->get("group_desc");
     $joinmethod = $request->get("join_method", "0");
     $groupclassid = $request->get("group_class_id");
     $invitedmemebers = $request->get("invitedmemebers");
     $group_photo_path = $request->get("group_photo_path");
     $da = $this->get('we_data_access');
     $da_im = $this->get('we_data_access_im');
     $ec = new \Justsy\BaseBundle\Management\EnoParamManager($da, $this->get('logger'));
     try {
         if ($ec->IsBeyondCreateGroup($user->getUserName())) {
             $re["returncode"] = ReturnCode::$SYSERROR;
             $re["error"] = "创建群组数量已超过限制!";
             $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
             $response->headers->set('Content-Type', 'text/json');
             return $response;
         }
         if (empty($circleid) || empty($groupname)) {
             $re["returncode"] = ReturnCode::$SYSERROR;
             $re["error"] = "参数传递错误!";
             $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
             $response->headers->set('Content-Type', 'text/json');
             return $response;
         }
         if (!$this->hasGroup($da, $groupname)) {
             //根据typeid取出typename
             $sql = "select typename from im_grouptype where typeid=?";
             $ds = $da_im->GetData('im_grouptype', $sql, array($groupclassid));
             $typename = '';
             if ($ds['im_grouptype']["recordcount"] > 0) {
                 $typename = $ds["im_grouptype"]['rows'][0]["typename"];
             } else {
                 $typename = $groupclassid;
             }
             //注册fafa_group
             $sqls = array();
             $paras = array();
             $fafa_groupid = SysSeq::GetSeqNextValue($da_im, "im_group", "groupid");
             $sqls[] = "insert into im_group (groupid, groupname, groupclass, groupdesc, creator, add_member_method, accessright) \n\t\t\t        values (?, ?, ?, ?, ?, ?, 'any')";
             $paras[] = array((string) $fafa_groupid, (string) $groupname, (string) $typename, (string) $groupdesc, (string) $user->fafa_jid, (string) $joinmethod);
             $sqls[] = "insert into im_groupemployee (employeeid, groupid, employeenick, grouprole) values (?,?,?,'owner')";
             $paras[] = array((string) $user->fafa_jid, (string) $fafa_groupid, (string) $user->nick_name);
             //跟新群组版本号
             $sqls[] = "delete from im_group_version where us=?";
             $paras[] = array((string) $user->fafa_jid);
             $da_im->ExecSQLs($sqls, $paras);
             //保存图标
             $sqls = array();
             $paras = array();
             $groupId = SysSeq::GetSeqNextValue($da, "we_groups", "group_id");
             $sqls[] = "insert into we_groups (group_id,circle_id,group_name,group_desc,group_photo_path,join_method,create_staff,fafa_groupid,create_date, group_class)\n\t\t\t        values (?,?,?,?,?,?,?,?,now(),?)";
             $paras[] = array((string) $groupId, (string) $circleid, (string) $groupname, (string) $groupdesc, (string) $group_photo_path, (string) $joinmethod, (string) $user->getUserName(), (string) $fafa_groupid, (string) $groupclassid);
             $sqls[] = "insert into we_group_staff (group_id,login_account) values (?,?)";
             $paras[] = array((string) $groupId, (string) $user->getUserName());
             $da->ExecSQLs($sqls, $paras);
             //创建文档根目录
             $docCtl = new \Justsy\BaseBundle\Controller\DocumentMgrController();
             $docCtl->setContainer($this->container);
             if ($docCtl->createDir("g" . $groupId, "c" . $circleid, $groupname, $circleid) > 0) {
                 $docCtl->saveShare("g" . $groupId, "0", $groupId, "g", "w");
                 //将群目录共享给该群组成员
             }
             $im_sender = $this->container->getParameter('im_sender');
             //给创建者发送创建群组成功出席
             Utils::sendImPresence($im_sender, $user->fafa_jid, "creategroup", json_encode(array("groupid" => $fafa_groupid, "logoid" => $group_photo_path, "groupname" => $groupname)), $this->container, "", "", false, Utils::$systemmessage_code);
             //给邀请人员发送消息 站内和即时消息
             if (!empty($invitedmemebers)) {
                 $invitedmemebers = str_replace(";", ";", $invitedmemebers);
                 $invs = explode(";", $invitedmemebers);
                 $title = "邀请加入群组";
                 foreach ($invs as $key => $value) {
                     if (empty($value)) {
                         continue;
                     }
                     //群编号,被邀请人帐号,network_domain,fafa_groupid
                     $encode = DES::encrypt("{$groupId},{$value},{$circleid}," . $fafa_groupid);
                     $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' => $groupname));
                     //发送站内消息
                     $msgId = SysSeq::GetSeqNextValue($da, "we_message", "msg_id");
                     $sql = "insert into we_message(msg_id,sender,recver,title,content,send_date)values(?,?,?,?,?,now())";
                     $da->ExecSQL($sql, array((int) $msgId, (string) $user->getUserName(), (string) $value, "邀请加入群组", $txt));
                     //发送即时消息
                     $fafa_jid = Utils::getJidByAccount($da, $value);
                     //$this->get("logger")->info(Utils::makeHTMLElementTag('employee',$user->fafa_jid,$user->nick_name));
                     $message = Utils::makeHTMLElementTag('employee', $user->fafa_jid, $user->nick_name) . "邀请您加入群组【" . Utils::makeHTMLElementTag('group', $fafa_groupid, $groupname) . "】";
                     $buttons = array();
                     $buttons[] = array("text" => "立即加入", "code" => "agree", "value" => "1");
                     $buttons[] = array("text" => "拒绝", "code" => "agree", "value" => "0");
                     Utils::sendImMessage($im_sender, $fafa_jid, $title, $message, $this->container, $activeurl . "?invite_user="******"1");
                 }
             }
             $re["group"] = $this->getGroup($da, $user, $circleid, $groupId);
             //变更版本信息
             $eno = $user->eno;
             $verchange = new \Justsy\BaseBundle\Management\VersionChange($da, $this->get("logger"));
             $result = $verchange->SetVersionChange(2, $groupId, $eno);
         } else {
             $re["returncode"] = ReturnCode::$SYSERROR;
             $re["error"] = "群组名称已存在!";
         }
     } catch (Exception $e) {
         $re["returncode"] = ReturnCode::$SYSERROR;
         $re["error"] = "系统错误,创建群组失败!";
         $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;
 }
예제 #4
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'));
     }
 }
예제 #5
0
 public function createcircleAction()
 {
     $re = array("returncode" => ReturnCode::$SUCCESS);
     $user = $this->get('security.context')->getToken()->getUser();
     $request = $this->getRequest();
     $circlename = $request->get("circle_name");
     $circledesc = $request->get("circle_desc");
     $joinmethod = $request->get("join_method", "0");
     $allowcopy = $request->get("allow_copy", "0");
     $circleclassid = $request->get("circle_class_id");
     $invitedmemebers = $request->get("invitedmemebers");
     $logo_path = $request->get("logo_path");
     $logo_path_small = $request->get("logo_path_small");
     $logo_path_big = $request->get("logo_path_big");
     $da = $this->get('we_data_access');
     $da_im = $this->get('we_data_access_im');
     try {
         if (empty($circlename) || empty($circleclassid)) {
             $re["returncode"] = ReturnCode::$SYSERROR;
             $re["error"] = "参数传递错误!";
             $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
             $response->headers->set('Content-Type', 'text/json');
             return $response;
         }
         if (!$this->hasCircle($da, $circlename)) {
             $ec = new \Justsy\BaseBundle\Management\EnoParamManager($da, $this->get('logger'));
             if ($ec->IsBeyondCreateCircle($user->getUserName())) {
                 $re["returncode"] = ReturnCode::$SYSERROR;
                 $re["error"] = "创建圈子数量已超过限制!";
             } else {
                 $circle_id = (string) SysSeq::GetSeqNextValue($da, "we_circle", "circle_id");
                 //创建圈子不再同步创建群组
                 //liling 2015-1-18
                 $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) $circlename, (string) $circledesc, (string) $logo_path, (string) $logo_path_big, (string) $logo_path_small, (string) $user->getUsername(), (string) $user->getUsername(), (string) $joinmethod, $network, (string) $allowcopy, (string) $circleclassid, (string) $fafa_groupid), array((string) $circle_id, (string) $user->getUsername(), (string) $user->nick_name));
                 $da->ExecSQLs($sqls, $paras);
                 //创建文档根目录
                 $docCtl = new \Justsy\BaseBundle\Controller\DocumentMgrController();
                 $docCtl->setContainer($this->container);
                 if ($docCtl->createDir("c" . $circle_id, "", $circlename, $circle_id) > 0) {
                     $docCtl->saveShare("c" . $circle_id, "0", $circle_id, "c", "w");
                     //将圈子目录共享给该圈子成员
                 }
                 //给创建者发送创建群组成功出席
                 //Utils::sendImPresence($user->fafa_jid,$user->fafa_jid,"creategroup",json_encode(array("groupid"=> $fafa_groupid,"groupname"=> $circlename)),$this->container,"","",false,Utils::$systemmessage_code);
                 //发送邀请邮件
                 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' => '');
                     $invitedmemebers = str_replace(";", ";", $invitedmemebers);
                     $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},{$circle_id}," . $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{$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["circle"] = $this->getCricle($da, $circle_id);
             }
         } else {
             $re["returncode"] = ReturnCode::$SYSERROR;
             $re["error"] = "圈子名称已存在!";
         }
     } catch (\Exception $e) {
         $re["returncode"] = ReturnCode::$SYSERROR;
         $re["error"] = "系统错误,创建圈子失败!";
         $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;
 }