// Insert new post type...: // Check that this action request is not a CSRF hacked request: $Session->assert_received_crumb('itemtype'); $edited_Itemtype = new ItemType(); // Check permission: $current_User->check_perm('options', 'edit', true); // load data from request if ($edited_Itemtype->load_from_Request()) { // We could load data from form without errors: if ($edited_Itemtype->is_special()) { // is special post type 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&tab=' . $tab . '&tab3=' . $tab3 . '&action=edit&ityp_ID=' . $q . '"')); } else {