/** * Save an entry * * @return void */ public function saveTask() { // Check for request forgeries Request::checkToken(); $post = array('id' => Request::getInt('id', 0, 'post'), 'title' => Request::getVar('title', '', 'post'), 'alias' => Request::getVar('alias', '', 'post'), 'lag' => Request::getVar('lag', '', 'post'), 'published' => Request::getVar('published', '', 'post'), 'open' => Request::getVar('open', '', 'post')); // Save the poll parent information $db = \App::get('db'); $row = new Poll($db); if (!$row->bind($post)) { throw new Exception($row->getError(), 500); } $isNew = $row->id == 0; if (!$row->check()) { throw new Exception($row->getError(), 500); } if (!$row->store()) { throw new Exception($row->getError(), 500); } $row->checkin(); // Save the poll options $options = Request::getVar('polloption', array(), 'post'); foreach ($options as $i => $text) { //$text = htmlspecialchars($text, ENT_QUOTES, 'UTF-8'); if ($isNew) { $obj = new stdClass(); $obj->pollid = (int) $row->id; $obj->text = $text; $db->insertObject('#__poll_data', $obj); } else { $obj = new stdClass(); $obj->id = (int) $i; $obj->text = $text; $db->updateObject('#__poll_data', $obj, 'id'); } } switch (Request::getVar('task', 'save')) { case 'apply': $msg = Lang::txt('COM_POLL_ITEM_SAVED'); $link = Route::url('index.php?option=com_poll&view=poll&task=edit&cid=' . $row->id, false); break; case 'save': default: $msg = Lang::txt('COM_POLL_ITEM_SAVED'); $link = Route::url('index.php?option=com_poll', false); break; } App::redirect($link, $msg); }