示例#1
0
文件: Accept.php 项目: sinfocol/gwf3
 private function acceptByToken($token)
 {
     $uid = (int) Common::getGet('uid');
     $gid = (int) Common::getGet('gid');
     if (false === ($group = GWF_Group::getByID($gid))) {
         return GWF_HTML::err('ERR_UNKNOWN_GROUP');
     }
     if (false === ($request = GWF_UsergroupsInvite::getRequestRow($uid, $gid))) {
         return GWF_HTML::err('ERR_NO_PERMISSION');
     }
     if (false === ($user = GWF_User::getByID($uid))) {
         return GWF_HTML::err('ERR_UNKNOWN_USER');
     }
     if ($token !== $request->getHashcode()) {
         return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__));
     }
     if (false === GWF_UserGroup::addToGroup($uid, $gid)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_joined', array($group->getName()));
 }
示例#2
0
文件: Join.php 项目: sinfocol/gwf3
 private function onInviteJoin(GWF_Group $group, GWF_User $user)
 {
     if (false === ($invite = GWF_UsergroupsInvite::getInviteRow($user->getID(), $group->getID()))) {
         return $this->module->error('err_not_invited');
     }
     if ($invite->getVar('ugi_type') !== 'invite') {
         return $this->module->error('err_not_invited');
     }
     if (false === $invite->delete()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->onQuickJoin($group, $user);
 }
示例#3
0
文件: Edit.php 项目: sinfocol/gwf3
 public function onInvite(GWF_Group $group)
 {
     $form = $this->getFormInvite($group);
     if (false !== ($errors = $form->validate($this->module))) {
         return $errors . $this->templateEdit($group);
     }
     if (false === ($user = GWF_User::getByName($_POST['username']))) {
         return GWF_HTML::err('ERR_UNKNOWN_USER') . $this->templateEdit($group);
     }
     $back = '';
     if (false === GWF_UsergroupsInvite::getInviteRow($user->getID(), $group->getID())) {
         if (false === GWF_UsergroupsInvite::invite($user->getID(), $group->getID())) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)) . $this->templateEdit($group);
         }
     }
     $back = $this->sendInvitePM($user, $group);
     return $back . $this->module->message('msg_invited', array($user->displayUsername())) . $this->templateEdit($group);
 }