Пример #1
0
 private function onVote(GWF_VoteMulti $poll, $user)
 {
     $opts = Common::getPostArray('opt', array());
     $taken = array();
     $max = $poll->getNumChoices();
     foreach ($opts as $i => $stub) {
         $i = (int) $i;
         if ($i < 1 || $i > $max) {
             continue;
         }
         if (!in_array($i, $taken, true)) {
             $taken[] = $i;
         }
     }
     $count = count($taken);
     //		if ($count === 0) {
     //			return $this->module->error('err_no_options');
     //		}
     if (!$poll->isMultipleChoice() && $count !== 1) {
         return $this->module->error('err_no_multi');
     }
     if (false === $poll->onVote($user, $taken)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_voted', array(htmlspecialchars(GWF_Session::getLastURL())));
 }
Пример #2
0
 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);
 }
Пример #3
0
 private function onDeleteFolders()
 {
     if (false !== ($error = GWF_Form::validateCSRF_WeakS())) {
         return GWF_HTML::error('PM', $error, false);
     }
     $back = '';
     foreach (Common::getPostArray('folder', array()) as $folderid => $stub) {
         $back .= $this->onDeleteFolder($folderid);
     }
     return $back;
 }
Пример #4
0
 public function execute()
 {
     GWF_Module::loadModuleDB('Forum', true);
     if (false !== ($array = Common::getPostArray('part'))) {
         return $this->onPart($array) . $this->templateGroups();
     }
     if (false !== ($array = Common::getPostArray('join'))) {
         return $this->onJoin($array) . $this->templateGroups();
     }
     return $this->templateGroups();
 }
Пример #5
0
 private function onSolve()
 {
     $take = array();
     foreach (Common::getPostArray('password', array()) as $flagid => $pass) {
         if ($pass !== '') {
             $take[$flagid] = $pass;
         }
     }
     $back = '';
     if (count($take) === 1) {
         $back .= $this->onSolveB(key($take), $take[key($take)]);
     } elseif (count($take) > 1) {
         $back .= 'ONE AT A TIME!';
     }
     return $back . $this->templateOverview();
 }
Пример #6
0
 /**
  * @todo try to get Navi-Name
  * @todo rethink
  */
 public function execute()
 {
     $nid = Common::getGetInt('nid');
     $name = Common::getGetString('nname', 'unknown');
     $back = '';
     # Delete a Navigation?
     if ('delete' === ($action = Common::getGet('action'))) {
         if ($nid <= 0 || false === $this->onDelete($nid)) {
             # couldnt delete the navi! does it exists?
             $back = $this->module->error('err_delete', $name);
         } else {
             $back = $this->module->message('succ_delete', $name);
         }
     } elseif ('copy' === $action) {
         $back = $this->onCopy();
     } elseif (false !== ($delete = Common::getPostArray('delete'))) {
         $back .= $this->onEdit($delete);
     }
     return $back . $this->templateAdmin();
 }
Пример #7
0
 public static function multi($name, $selected = true, $allow_empty = true, $own_groups_only = true)
 {
     $user = GWF_User::getStaticOrGuest();
     if (false === ($groups = GDO::table('GWF_Group')->select('group_id, group_name'))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if ($selected === true) {
         $selected = Common::getPostArray($name, array());
     }
     $data = array();
     if ($allow_empty) {
         $data[] = array('0', GWF_HTML::lang('sel_group'));
     }
     while (false !== ($group = GDO::table('GWF_Group')->fetch($groups, GDO::ARRAY_N))) {
         if ($own_groups_only && !$user->isInGroupName($group[1])) {
             continue;
         }
         $data[] = $group;
     }
     return GWF_Select::multi($name, $data, $selected);
 }
Пример #8
0
 public static function wizard_6_1()
 {
     $names = Common::getPostArray('mod', array());
     // Nothing to install Oo
     if (count($names) === 0) {
         return self::wizard_error('err_no_mods_selected') . self::wizard_6();
     }
     $back = self::wizard_h2('6_1');
     $modules = GWF_ModuleLoader::loadModulesFS();
     $names = Common::getPostArray('mod', array());
     foreach ($modules as $id => $module) {
         $module instanceof GWF_Module;
         $name = $module->getName();
         if (!isset($names[$name]) && !$module->isCoreModule()) {
             unset($modules[$id]);
         }
     }
     GWF_ModuleLoader::sortModules($modules, 'module_priority', 'ASC');
     $back .= GWF_InstallFunctions::modules($modules, false);
     $back .= self::wizard_btn('7');
     return $back;
 }
Пример #9
0
 private function onAddPoll()
 {
     $form = $this->getForm();
     if (false !== ($errors = $form->validate($this->module))) {
         return $errors . $this->templateAddPoll();
     }
     $opts = Common::getPostArray('opt', array());
     if (count($opts) === 0) {
         return $this->module->error('err_no_options') . $this->templateAddPoll();
     }
     $user = GWF_Session::getUser();
     $name = GWF_VoteMulti::createPollName(GWF_Session::getUser());
     $title = $form->getVar('title');
     $gid = $form->getVar('gid');
     $level = $form->getVar('level');
     $reverse = isset($_POST['reverse']);
     $is_multi = isset($_POST['multi']);
     $guest_votes = isset($_POST['guests']);
     $is_public = isset($_POST['public']);
     $result = (int) $form->getVar('view');
     if ($is_public && !$this->module->mayAddGlobalPoll($user)) {
         return $this->module->error('err_global_poll') . $this->templateAddPoll();
     }
     GWF_Session::remove(self::SESS_OPTIONS);
     return Module_Votes::installPollTable($user, $name, $title, $opts, $gid, $level, $is_multi, $guest_votes, $is_public, $result, $reverse);
 }
Пример #10
0
 private function getPostLangID($field)
 {
     if (false === ($lid = Common::getPostArray($field, false))) {
         return false;
     }
     unset($_POST[$field]);
     $lid = key($lid);
     if (false === GWF_Language::getByID($lid)) {
         return false;
     }
     return (int) $lid;
 }
Пример #11
0
 private function onAdd()
 {
     $form = $this->formAdd();
     if (false !== ($error = $form->validate($this->module))) {
         return $error . $this->templateAdd();
     }
     $page = $this->getPageObject($form);
     $gstring = $page->getVar('page_groups');
     $tags = $page->getVar('page_meta_tags');
     if (false === $page->insert()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $page->saveVars(array('page_otherid' => $page->getID()))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === GWF_PageGID::updateGIDs($page, Common::getPostArray('groups', array()))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === GWF_PageTags::updateTags($page, $tags, $form->getVar('lang'))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (isset($_POST['home_page']) && $this->is_author) {
         $this->module->setHomePage($page->getID());
     }
     if (false === $this->module->writeHTA()) {
         return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__));
     }
     if ($this->locked_mode) {
         $this->module->sendModMails($page);
     } else {
         GWF_PageHistory::push($page);
     }
     return $this->locked_mode ? $this->module->message('msg_added_locked') : $this->module->message('msg_added', array(GWF_WEB_ROOT . $page->getVar('page_url'), $page->getVar('page_title')));
 }
Пример #12
0
 private static function mergePostVars()
 {
     $errors = array();
     $postvars = Common::getPostArray(self::POSTVARS, array());
     foreach ($postvars as $key => $value) {
         $value = trim($value);
         if (!isset(self::$vars[$key])) {
             $errors[] = self::$lang->lang('err_unknown_var', array(htmlspecialchars($key)));
             continue;
         }
         if (false !== ($error = self::testVar($key, $value))) {
             $errors[] = $error;
             continue;
         }
         self::setVar($key, $value);
     }
     if (count($errors) > 0) {
         echo GWF_HTML::error(self::$lang->lang('wizard'), $errors);
     }
 }