public function createIndexAction($network_domain) { $da = $this->get('we_data_access'); $da_im = $this->get('we_data_access_im'); $user = $this->get('security.context')->getToken()->getUser(); $this->circleId = $user->get_circle_id($network_domain); $this->groups = $this->getGroupByCircle($this->circleId, $user->getUserName()); $this->isCreate = "1"; $sql = "select count(1) as cnt from we_circle_staff where circle_id=? and login_account!=?"; $ds = $da->GetData('we_staff', $sql, array((string) $this->circleId, (string) $user->getUserName())); $pages = $ds['we_staff']['rows'][0]['cnt'] / 8; //$members = $this->getCircleMembers($this->circleId, $user->getUserName(), 0); //获取im grouptype $sql = "select typeid, typename from im_grouptype"; $ds = $da_im->GetData('im_grouptype', $sql); $grouptype = $ds && $ds['im_grouptype']['recordcount'] > 0 ? json_encode($ds['im_grouptype']['rows']) : array(); $IsBeyondCreateGroup; $CountCreateGroup = 0; $ec = new \Justsy\BaseBundle\Management\EnoParamManager($da, $this->get('logger')); if ($ec->IsBeyondCreateGroup($user->getUserName())) { $IsBeyondCreateGroup = true; $CountCreateGroup = $ec->getCountCreateGroup($user->getUserName()); } else { $IsBeyondCreateGroup = false; } return $this->render('JustsyBaseBundle:Group:group_create_new.html.twig', array('curr_network_domain' => $network_domain, 'this' => $this, 'pages' => $pages, 'group_c' => $user->IsFunctionCreateGroup($network_domain), 'group_s' => $user->IsExistsFunction("GROUP_S"), 'fileurl' => $this->container->getParameter('FILE_WEBSERVER_URL'), 'circleId' => $this->circleId, 'grouptype' => $grouptype, 'pagecount' => $pages, 'IsBeyondCreateGroup' => $IsBeyondCreateGroup, 'CountCreateGroup' => $CountCreateGroup)); }
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; }