/** * Update function. * Updates an existing resource. * * @return void */ protected function update() { // Check for token JSession::checkToken() or K2Response::throwError(JText::_('JINVALID_TOKEN')); // Ensure we have an id $id = $this->input->get('id', 0, 'int'); if (!$id) { K2Response::throwError(JText::_('K2_INVALID_INPUT')); } // Get input data $data = $this->getInputData(); // Pass data to the model $this->model->setState('data', $data); // Save $result = $this->model->save(); // Handle save result if ($result) { // Save was successful try to checkin the row if (!$this->model->checkin($this->model->getState('id'))) { // An error occured while trying to checkin. Notify the client. K2Response::throwError($this->model->getError()); } K2Response::setStatus(true); } else { // An error occured while saving. Notify the client. K2Response::throwError($this->model->getError()); } }
/** * Saves a new recurring date for the given event * * @param object $row - The event * * @return mixed * * @throws Exception */ public static function saveRecurringDateForEvent($row) { // Add to dates // Insert date into recurring table $robj = new stdClass(); $robj->event_id = $row->id; $robj->semnum = $row->semnum; $robj->begin = $row->begin; $robj->end = $row->end; $robj->booked = $row->booked; $robj->published = $row->published; $rect = JTable::getInstance('Recurring', 'MatukioTable'); if (!$rect->bind($robj)) { throw new Exception($rect->getError(), 42); } if (!$rect->check()) { throw new Exception($rect->getError(), 42); } if (!$rect->store()) { throw new Exception($rect->getError(), 42); } $row->checkin(); return $rect->id; }