コード例 #1
0
     param_error('ityp_ID', sprintf(T_('Post types with ID from %d to %d are reserved. Please use another ID.'), $special_range[0], $special_range[1]));
     // Set to 0 in order to display an edit input box for name field
     $edited_Itemtype->ID = 0;
     // Set name from request
     $edited_Itemtype->set('name', param('ityp_name', 'string', ''));
 } 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