예제 #1
0
 } else {
     // ID is good
     // While inserting into DB, ID property of Userfield object will be set to autogenerated ID
     // So far as we set ID manualy, we need to preserve this value
     // When assignment of wrong value will be fixed, we can skip this
     $entered_itemtype_id = $edited_Itemtype->ID;
     // Insert in DB:
     $DB->begin();
     // because of manual assigning ID,
     // member function ItemType::dbexists() is overloaded for proper functionality
     $q = $edited_Itemtype->dbexists();
     if ($q) {
         // We have a duplicate entry:
         param_error('ityp_ID', sprintf(T_('This post type already exists. Do you want to <a %s>edit the existing post type</a>?'), 'href="?ctrl=itemtypes&amp;tab=' . $tab . '&amp;tab3=' . $tab3 . '&amp;action=edit&amp;ityp_ID=' . $q . '"'));
     } else {
         $edited_Itemtype->dbinsert();
         $Messages->add(T_('New Post Type 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($admin_url . '?ctrl=itemtypes&blog=' . $blog . '&tab=' . $tab . '&tab3=' . $tab3 . '&action=new&ityp_ID=' . $entered_itemtype_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($admin_url . '?ctrl=itemtypes&blog=' . $blog . '&tab=' . $tab . '&tab3=' . $tab3 . '&action=new', 303);