require_login(SITEID, false); if (!has_capability('local/amos:stage', get_system_context())) { header('HTTP/1.1 403 Forbidden'); die; } if (!confirm_sesskey()) { header('HTTP/1.1 403 Forbidden'); die; } $stringid = optional_param('stringid', null, PARAM_ALPHANUMEXT); $text = optional_param('text', null, PARAM_RAW); if (is_null($stringid) or is_null($text)) { header('HTTP/1.1 400 Bad Request'); die; } list($lang, $originalid, $translationid) = local_amos_translator::decode_identifier($stringid); $record = $DB->get_record('amos_repository', array('id' => $originalid), 'id,stringid,component,branch', MUST_EXIST); $version = mlang_version::by_code($record->branch); $component = new mlang_component($record->component, $lang, $version); if ($version->code < mlang_version::MOODLE_20) { header('HTTP/1.1 400 Bad Request'); die; } $string = new mlang_string($record->stringid, $text); $string->clean_text(); $component->add_string($string); $stage = mlang_persistent_stage::instance_for_user($USER->id, sesskey()); $stage->add($component, true); $stage->store(); mlang_stash::autosave($stage); header('Content-Type: application/json; charset: utf-8');
// it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Handles submission of the whole translation table * * This adds the submitted strings into the user's instance of mlang_persistent_stage * and redirects back to view.php * * @package local-amos * @copyright 2010 David Mudrak <*****@*****.**> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once dirname(dirname(dirname(__FILE__))) . '/config.php'; require_once dirname(__FILE__) . '/locallib.php'; require_login(SITEID, false); require_capability('local/amos:stage', get_system_context()); require_sesskey(); $fields = required_param('fields', PARAM_ALPHANUMEXT); foreach ($fields as $field) { list($originalid, $translationid) = local_amos_translator::decode_identifier($field); } redirect(new moodle_url('/local/amos/view.php'));