Exemplo n.º 1
0
     // Check permission:
     $current_User->check_perm('options', 'edit', true);
     // Make sure we got an subrg_ID:
     param('subrg_ID', 'integer', true);
     // load data from request
     if ($edited_Subregion->load_from_Request()) {
         // We could load data from form without errors:
         // Update 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->dbupdate();
             $Messages->add(T_('Region updated.'), 'success');
         }
         $DB->commit();
         if (empty($q)) {
             // If no error, Redirect so that a reload doesn't write to the DB twice:
             header_redirect('?ctrl=subregions', 303);
             // Will EXIT
             // We have EXITed already at this point!!
         }
     }
     break;
 case 'delete':
     // Delete subregion:
     // Check that this action request is not a CSRF hacked request:
     $Session->assert_received_crumb('subregion');