private function sanitize() { if (false === ($this->group = GWF_Group::getByID(Common::getGetString('gid')))) { return $this->module->error('err_group'); } return false; }
public function execute() { if (false === ($group = GWF_Group::getByID(Common::getGet('gid')))) { return $this->module->error('err_unk_group'); } if ($group->isOptionEnabled(GWF_Group::VISIBLE_MEMBERS)) { } else { switch ($group->getVisibleMode()) { case GWF_Group::VISIBLE: break; case GWF_Group::COMUNITY: if (!GWF_Session::isLoggedIn()) { return GWF_HTML::err('ERR_NO_PERMISSION'); } break; case GWF_Group::HIDDEN: case GWF_Group::SCRIPT: if (!GWF_User::isInGroupS($group->getVar('group_name'))) { return $this->module->error('err_not_invited'); } break; default: return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__)); } } return $this->templateUsers($group); }
public function execute() { $user = GWF_Session::getUser(); if (false === ($this->group = GWF_Group::getByID(Common::getGet('gid')))) { return $this->module->error('err_unk_group'); } $group = $this->group; $groupname = $group->getVar('group_name'); if (!$user->isInGroupName($groupname)) { return $this->module->error('err_unk_group'); } // $gid = $group->getID(); // $groups = $user->getGroups(); // $ugo = $groups[(string)($gid)]['ug_options']; $ugo = $user->getUserGroupOptions($group->getID()); // var_dump($ugo); if (($ugo & (GWF_UserGroup::LEADER | GWF_UserGroup::CO_LEADER)) === 0) { return $this->module->error('err_unk_group'); } if (false !== ($array = Common::getPostArray('kick'))) { return $this->onKick($group, $array) . $this->templateEdit($group); } if (false !== ($array = Common::getPostArray('accept'))) { return $this->onAccept($group, $array) . $this->templateEdit($group); } if (false !== ($array = Common::getPostArray('co'))) { return $this->onSetPriv($group, $array, GWF_UserGroup::CO_LEADER, true); } if (false !== ($array = Common::getPostArray('unco'))) { return $this->onSetPriv($group, $array, GWF_UserGroup::CO_LEADER, false); } if (false !== ($array = Common::getPostArray('mod'))) { return $this->onSetPriv($group, $array, GWF_UserGroup::MODERATOR, true); } if (false !== ($array = Common::getPostArray('unmod'))) { return $this->onSetPriv($group, $array, GWF_UserGroup::MODERATOR, false); } if (false !== ($array = Common::getPostArray('hide'))) { return $this->onSetPriv($group, $array, GWF_UserGroup::HIDDEN, true); } if (false !== ($array = Common::getPostArray('unhide'))) { return $this->onSetPriv($group, $array, GWF_UserGroup::HIDDEN, false); } if (false !== Common::getPost('invite')) { return $this->onInvite($group); } if (false !== Common::getPost('edit')) { return $this->onEdit($group); } if (false !== Common::getPost('delete')) { return $this->onDelete($group); } if (false !== Common::getPost('del_confirm')) { return $this->onDeleteConfirm($group); } return $this->templateEdit($group); }
private function onJoin($array) { if (false !== ($error = GWF_Form::validateCSRF_WeakS())) { return GWF_HTML::error('Join Group', $error); } if (false === ($group = GWF_Group::getByID(key($array)))) { return $this->module->error('err_unk_group'); } return $this->module->getMethod('Join')->onQuickJoin($group, GWF_User::getStaticOrGuest()); }
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 onJoin($gid) { if (false === ($group = GWF_Group::getByID($gid))) { return $this->module->error('err_unk_group'); } if ($group->getFounderID() === '0') { return $this->module->error('err_no_join'); } $user = GWF_Session::getUser(); if ($user->isInGroupName($group->getName())) { return $this->module->error('err_join_twice'); } switch ($group->getJoinMode()) { case GWF_Group::FREE: return $this->onQuickJoin($group, $user); case GWF_Group::MODERATE: return $this->onRequestJoin($group, $user); case GWF_Group::INVITE: return $this->onInviteJoin($group, $user); default: return $this->module->error('err_no_join'); } }
public function mayDownload($user, GWF_Download $download) { if ($user === false) { # Guest if (!$download->isEnabled()) { return $this->error('err_disabled'); } if ($download->isAdult()) { return $this->error('err_adult'); } if (!$download->isOptionEnabled(GWF_Download::GUEST_DOWNLOAD)) { return $this->error('err_guest'); } if (!$this->cfgAnonDown()) { return $this->error('err_guest'); } return false; } else { $user instanceof GWF_User; # Admin if ($user->isAdmin()) { return false; } if (!$download->isEnabled()) { return $this->error('err_disabled'); } if ($download->isAdult() && !$user->wantsAdult()) { return $this->error('err_adult'); } # Level if ($download->getVar('dl_level') > $user->getVar('user_level')) { return $this->error('err_level', $download->getVar('dl_level')); } # Group $gid = $download->getVar('dl_gid'); if (false === ($group = GWF_Group::getByID($gid))) { } elseif ($gid > 0 && !$user->isInGroupID($download->getVar('dl_gid'))) { return $this->error('err_group', $group->display('group_name')); } return false; } }
/** * Validate a group ID. * @param GWF_Module $m * @param $key * @param $arg * @param boolean $unset * @param boolean $allow_zero */ public static function validateGroupID($m, $key, $arg, $unset = true, $allow_zero = false) { $_POST[$key] = $arg = trim($arg); if ($allow_zero && $arg == 0) { $arg = '0'; return false; } if (false !== GWF_Group::getByID($arg)) { return false; } if ($unset) { unset($_POST[$key]); } return $m->lang('err_' . $key, array(3, GWF_Group::NAME_LEN)); }
/** * Check if we have permission to view that link. In case we do, return empty string. else return verbose permission text. * @param Module_Links $module * @param GWF_User $user * @return string */ public function getPermissionText(Module_Links $module, $user) { static $text = NULL; if ($text === NULL) { $text = array($module->lang('permtext_in_mod'), $module->lang('permtext_score', array('%1%')), $module->lang('permtext_member'), $module->lang('permtext_group', array('%1%'))); } if ($this->isInModeration()) { return $text[0]; } $score = $user === false ? 0 : $user->getLevel(); # Check score $need_score = $this->getVar('link_score'); if ($score < $need_score) { return str_replace('%1%', $need_score, $text[1]); } # Check memberlink if ($user === false && $this->isMemberLink()) { return $text[2]; } # Check group $need_gid = $this->getGroupID(); if ($need_gid > 0) { if ($user === false || !$user->isInGroupID($need_gid)) { return str_replace('%1%', GWF_Group::getByID($need_gid)->displayName(), $text[3]); } } return ''; }
public function validate_groupid($arg) { $arg = (int) $arg; if ($arg === 0) { return false; } if (false === ($group = GWF_Group::getByID($arg))) { return $this->lang('err_groupid'); } return false; }