public function onQuickJoin(GWF_Group $group, GWF_User $user) { if ($user->getID() === '0' || $group->getID() === '0') { 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__)); } return $this->module->message('msg_joined', array($group->getName())); }
public function onAddToGroup(GWF_User $user) { $form = $this->getFormAdd($user); if (false !== ($error = $form->validate($this->module))) { return $error; } $user->loadGroups(); if (false === ($group = GWF_Group::getByID($form->getVar('groups')))) { return $this->module->error('err_group'); } if ($user->isInGroupName($group->getName())) { return $this->module->error('err_in_group'); } if (false === GWF_UserGroup::addToGroup($user->getID(), $group->getID())) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } return $this->module->message('msg_added_to_grp', array($user->displayUsername(), $group->display('group_name'))); }
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())); }
private function onCreate() { $form = $this->formCreate(); if (false !== ($errors = $form->validate($this->module))) { return $errors . $this->templateCreate(); } $user = GWF_Session::getUser(); $groupname = $form->getVar('name'); $options = 0; $options |= intval(Common::getPost('join', 0)); $options |= intval(Common::getPost('view', 0)); $group = new GWF_Group(array('group_id' => 0, 'group_name' => $groupname, 'group_options' => $options, 'group_lang' => $user->getLangID(), 'group_country' => $user->getCountryID(), 'group_founder' => $user->getID(), 'group_memberc' => 0, 'group_bid' => 0, 'group_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND))); if (false === $group->insert()) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === GWF_UserGroup::addToGroup($user->getID(), $group->getID(), GWF_UserGroup::LEADER)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false !== ($error = $this->createBoard($group))) { return $error; } return $this->module->message('msg_created'); }
/** * Make Admin and Staff moderators. return error message or empty string. * @param Module_Forum $module * @return string */ private static function installAdminToMod(Module_Forum $module) { $table = GDO::table('GWF_UserGroup'); if (false === ($userids = $table->selectColumn('DISTINCT(ug_userid)', "group_name='staff' OR group_name='admin'", '', array('group')))) { return GWF_HTML::err('ERR_DATABASE', __FILE__, __LINE__); } foreach ($userids as $userid) { if (false === GWF_UserGroup::addToGroup($userid, 'moderator')) { return GWF_HTML::err('ERR_DATABASE', __FILE__, __LINE__); } } return ''; }
public static function createAdmin($username, $password, $email, &$output) { if (false === ($user = GWF_User::getByName($username))) { $user = new GWF_User(array('user_name' => $username, 'user_email' => $email, 'user_password' => GWF_Password::hashPasswordS($password), 'user_regdate' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'user_regip' => GWF_IP6::getIP(GWF_IP_EXACT), 'user_lastactivity' => time())); if (false === $user->insert()) { return false; } } $userid = $user->getID(); if (false === GWF_UserGroup::addToGroup($userid, GWF_Group::getByName(GWF_Group::ADMIN)->getID())) { return false; } if (false === GWF_UserGroup::addToGroup($userid, GWF_Group::getByName(GWF_Group::STAFF)->getID())) { return false; } $output .= GWF_HTML::message('Install Wizard', sprintf('Added new admin user: %s - Password: [censored]', $username)); return true; }
public function onRemFromGroup($uid) { $uid = (int) $uid; $gid = $this->group->getID(); if (false === GDO::table('GWF_UserGroup')->deleteWhere("ug_userid={$uid} AND ug_groupid={$gid}")) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === GWF_UserGroup::fixGroupMC()) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } return $this->module->message('msg_removed_from_grp', array(GWF_User::getByID($uid)->displayUsername(), $this->group->display('group_name'))); }
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'))); }