// Record goal and create new // Record goal and create new case 'create_copy': // Record goal and create similar // Insert new file type...: $edited_Goal = new Goal(); // Check that this action request is not a CSRF hacked request: $Session->assert_received_crumb('goal'); // Check permission: $current_User->check_perm('stats', 'edit', true); // load data from request if ($edited_Goal->load_from_Request()) { // We could load data from form without errors: // Insert in DB: $DB->begin(); $q = $edited_Goal->dbexists(); if ($q) { // We have a duplicate entry: param_error('goal_key', sprintf(T_('This goal already exists. Do you want to <a %s>edit the existing goal</a>?'), 'href="?ctrl=goals&action=edit&goal_ID=' . $q . '"')); } else { $edited_Goal->dbinsert(); $Messages->add(T_('New goal created.'), 'success'); } $DB->commit(); if (empty($q)) { // What next? switch ($action) { case 'create_copy': // Redirect so that a reload doesn't write to the DB twice: header_redirect('?ctrl=goals&action=new&goal_ID=' . $edited_Goal->ID, 303); // Will EXIT