public function validate_view(Module_Votes $m, $arg) { return GWF_VoteMulti::isValidViewFlag($arg) ? false : $m->lang('err_multiview'); }
public static function installPollTableB($user, $name, $title, array $options, $gid = 0, $level = 0, $is_multi, $guest_votes, $is_public = false, $result = GWF_VoteMulti::SHOW_RESULT_ALWAYS, $reverse = true) { if (false === ($module = GWF_Module::getModule('Votes'))) { return GWF_HTML::err('ERR_MODULE_MISSING', array('Votes')); } // Poll exists if (false !== ($poll = GWF_VoteMulti::getByName($name))) { return $module->error('err_pollname_taken'); } // View flag ok if (!GWF_VoteMulti::isValidViewFlag($result)) { return $module->error('err_multiview'); } $taken = array(); $errors = array(); foreach ($options as $i => $option) { if ('' === ($option = trim($option))) { $errors[] = $module->lang('err_option_empty', array($i + 1)); } elseif (in_array($option, $taken, true)) { $errors[] = $module->lang('err_option_twice', array(GWF_HTML::display($option))); } else { $taken[] = $option; } } if (count($taken) === 0) { $errors[] = $module->lang('err_no_options'); } if (count($errors) > 0) { return GWF_HTML::error('Votes', $errors); } $flags = 0; $flags |= GWF_VoteMulti::ENABLED; $flags |= $is_multi ? GWF_VoteMulti::MULTIPLE_CHOICE : 0; $flags |= $guest_votes ? GWF_VoteMulti::GUEST_VOTES : 0; $flags |= $is_public ? 0 : GWF_VoteMulti::INTERNAL_VOTE; $flags |= $reverse === false ? GWF_VoteMulti::IRREVERSIBLE : 0; $flags |= $result; if (false === ($poll = GWF_VoteMulti::fakePoll($name, $title, $user, $flags, $gid, $level))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === $poll->insertPoll($taken)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } return ''; }