function addPoll($p) { if (empty($p['poll_q'])) { return; } if (!empty($p['poll_start_man'])) { $pollId = PollItem::addPollExactPeriod(SITE, 0, $p['poll_q'], $p['poll_start_man'], $p['poll_end_man']); } else { $pollId = PollItem::add(SITE, 0, $p['poll_q'], $p['poll_dur'], $p['poll_start']); } for ($i = 1; $i <= 8; $i++) { if (empty($p['poll_a' . $i])) { continue; } $item = new CategoryItem(POLL); $item->owner = $pollId; $item->title = $p['poll_a' . $i]; $item->store(); } js_redirect('a/polls/list'); }