示例#1
0
 case 'create':
     // Record new region
 // Record new region
 case 'create_new':
     // Record region and create new
 // Record region and create new
 case 'create_copy':
     // Record region and create similar
     // Insert new region:
     $edited_Region = new Region();
     // Check that this action request is not a CSRF hacked request:
     $Session->assert_received_crumb('region');
     // Check permission:
     $current_User->check_perm('options', 'edit', true);
     // Load data from request
     if ($edited_Region->load_from_Request()) {
         // We could load data from form without errors:
         // Insert in DB:
         $DB->begin();
         $q = $edited_Region->dbexists();
         if ($q) {
             // We have a duplicate entry:
             param_error('rgn_code', sprintf(T_('This region already exists. Do you want to <a %s>edit the existing region</a>?'), 'href="?ctrl=regions&amp;action=edit&amp;rgn_ID=' . $q . '"'));
         } else {
             $edited_Region->dbinsert();
             $Messages->add(T_('New region created.'), 'success');
         }
         $DB->commit();
         if (empty($q)) {
             // What next?
             switch ($action) {