Exemplo n.º 1
0
 // Check that this action request is not a CSRF hacked request:
 $Session->assert_received_crumb('subregion');
 // Check permission:
 $current_User->check_perm('options', 'edit', true);
 // Load data from request
 if ($edited_Subregion->load_from_Request()) {
     // We could load data from form without errors:
     // Insert in DB:
     $DB->begin();
     $q = $edited_Subregion->dbexists();
     if ($q) {
         // We have a duplicate entry:
         param_error('subrg_code', sprintf(T_('This sub-region already exists. Do you want to <a %s>edit the existing sub-region</a>?'), 'href="?ctrl=subregions&amp;action=edit&amp;subrg_ID=' . $q . '"'));
     } else {
         unset($edited_Subregion->dbchanges['subrg_ctry_ID']);
         $edited_Subregion->dbinsert();
         $Messages->add(T_('New region 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=subregions&action=new&subrg_ID=' . $edited_Subregion->ID, 303);
                 // Will EXIT
                 // We have EXITed already at this point!!
                 break;
             case 'create_new':
                 // Redirect so that a reload doesn't write to the DB twice:
                 header_redirect('?ctrl=subregions&action=new', 303);