Esempio n. 1
0
/**
 * Callback to build possible actions depending on post type id
 *
 */
function get_actions_for_itemtype($id)
{
    global $default_ids;
    $action = action_icon(T_('Duplicate this Post Type...'), 'copy', regenerate_url('action', 'ityp_ID=' . $id . '&action=new'));
    if (!ItemType::is_reserved($id)) {
        // Edit all post types except of not reserved post type
        $action = action_icon(T_('Edit this Post Type...'), 'edit', regenerate_url('action', 'ityp_ID=' . $id . '&action=edit')) . $action;
    }
    if (!ItemType::is_special($id) && !in_array($id, $default_ids)) {
        // Delete only the not reserved and not default post types
        $action .= action_icon(T_('Delete this Post Type!'), 'delete', regenerate_url('action', 'ityp_ID=' . $id . '&action=delete&' . url_crumb('itemtype') . ''));
    }
    return $action;
}
Esempio n. 2
0
 // Record new Itemtype
 case 'create_new':
     // Record Itemtype and create new
 // Record Itemtype and create new
 case 'create_copy':
     // Record Itemtype and create similar
     // 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,