function poll_on_add(&$api) { include dirname(__FILE__) . '/poll_controller.class.php'; $controller = new PollController($api); $posting = new Posting(); $poll = new Poll($posting, $api); $poll->set_forum_id($api->forum()->get_id()); $api->breadcrumbs()->add_text(_('Start a Poll')); $max_polls = cfg('max_polls', 2); $max_polls_time = time() - cfg('max_polls_time', 60 * 60 * 24); if (_n_polls_since($api->db(), $api->user(), $max_polls_time) >= $max_polls) { $msg = _('You have reached your poll limit. Sorry.'); return $controller->show_error($msg); } $controller->show_form($poll); }