$blog_names = array(); foreach ($default_ids as $blog_ID => $item_type_ID) { if ($edited_Itemtype->ID == $item_type_ID && ($Blog =& $BlogCache->get_by_ID($blog_ID, false, false))) { $blog_names[] = '<a href="' . $admin_url . '?ctrl=coll_settings&tab=features&blog=' . $Blog->ID . '#fieldset_wrapper_post_options"><b>' . $Blog->get('name') . '</b></a>'; } } $Messages->add(sprintf(T_('This Item type is the default for the collections: %s. You can not delete this Item type.'), implode(', ', $blog_names))); } // To don't display a confirmation question $action = 'edit'; } else { // ID is good if (param('confirm', 'integer', 0)) { // confirmed, Delete from DB: $msg = sprintf(T_('Post type «%s» deleted.'), $edited_Itemtype->dget('name')); $edited_Itemtype->dbdelete(); unset($edited_Itemtype); forget_param('ityp_ID'); $Messages->add($msg, 'success'); // Redirect so that a reload doesn't write to the DB twice: header_redirect($admin_url . '?ctrl=itemtypes&blog=' . $blog . '&tab=' . $tab . '&tab3=' . $tab3 . '', 303); // Will EXIT // We have EXITed already at this point!! } else { // not confirmed, Check for restrictions: if (!$edited_Itemtype->check_delete(sprintf(T_('Cannot delete Post Type «%s»'), $edited_Itemtype->dget('name')))) { // There are restrictions: $action = 'view'; } } }
// Delete item type: // Check that this action request is not a CSRF hacked request: $Session->assert_received_crumb('itemtype'); // Check permission: $current_User->check_perm('options', 'edit', true); // Make sure we got an ptyp_ID: param('ptyp_ID', 'integer', true); if ($edited_Itemtype->ID > $reserved_ids[0] && $edited_Itemtype->ID < $reserved_ids[1]) { // is reserved item type param_error('ptyp_ID', sprintf(T_('Item types with ID from %d to %d are reserved. You can not delete this item type'), $reserved_ids[0], $reserved_ids[1])); } else { // ID is good if (param('confirm', 'integer', 0)) { // confirmed, Delete from DB: $msg = sprintf(T_('Item type «%s» deleted.'), $edited_Itemtype->dget('name')); $edited_Itemtype->dbdelete(true); unset($edited_Itemtype); forget_param('ptyp_ID'); $Messages->add($msg, 'success'); // Redirect so that a reload doesn't write to the DB twice: header_redirect('?ctrl=itemtypes&tab=' . $tab . '&tab3=' . $tab3 . '', 303); // Will EXIT // We have EXITed already at this point!! } else { // not confirmed, Check for restrictions: if (!$edited_Itemtype->check_delete(sprintf(T_('Cannot delete item type «%s»'), $edited_Itemtype->dget('name')))) { // There are restrictions: $action = 'view'; } } }