function saveLicense($option) { DOCMAN_token::check() or die('Invalid Token'); global $task; $database = JFactory::getDBO(); $mainframe = JFactory::getApplication(); $row = new mosDMLicenses($database); $isNew = $row->id == 0; if (!$row->bind(DOCMAN_Utils::stripslashes($_POST))) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$row->check()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$row->store()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } $row->checkin(); if ($task == 'save') { $url = 'index.php?option=com_docman§ion=licenses'; } else { // $task = 'apply' $url = 'index.php?option=com_docman§ion=licenses&task=edit&cid[0]=' . $row->id; } $mainframe->redirect($url, _DML_SAVED_CHANGES); }