Esempio n. 1
0
 private function onRequestJoin(GWF_Group $group, GWF_User $user)
 {
     $userid = $user->getID();
     $groupid = $group->getID();
     if (false !== ($request = GWF_UsergroupsInvite::getInviteRow($userid, $groupid))) {
         return $this->module->error('err_request_twice');
     }
     if (false === GWF_UsergroupsInvite::request($userid, $groupid)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === ($request = GWF_UsergroupsInvite::getRequestRow($userid, $groupid))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $this->onRequestMail($group, $user, $request)) {
         return GWF_HTML::err('ERR_MAIL_SENT');
     }
     return $this->module->message('msg_requested', array($group->getName()));
 }
Esempio n. 2
0
 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()));
 }
Esempio n. 3
0
 public function onAccept(GWF_Group $group, $array)
 {
     if (!is_array($array)) {
         return '';
     }
     $username = key($array);
     //		foreach ($array as $username => $stub) { break; }
     if (false === ($user = GWF_User::getByName($username))) {
         return GWF_HTML::err('ERR_UNKNOWN_USER');
     }
     if (false === ($requst = GWF_UsergroupsInvite::getRequestRow($user->getID(), $group->getID()))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === GWF_UserGroup::addToGroup($user->getID(), $group->getID())) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $requst->delete()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_accepted', array($user->displayUsername(), $group->display('group_name')));
 }