Exemplo n.º 1
0
        }
    }
    //
    // Update attachments
    //
    if ($mode == 'update') {
        if (!empty($_REQUEST['attachment_data'])) {
            fn_update_attachments($_REQUEST['attachment_data'], $_REQUEST['attachment_id'], $_REQUEST['object_type'], $_REQUEST['object_id']);
        }
    }
    return array(CONTROLLER_STATUS_OK);
    // redirect should be performed via redirect_url always
}
if ($mode == 'getfile') {
    if (!empty($_REQUEST['attachment_id']) && !empty($_REQUEST['object_type']) && !empty($_REQUEST['object_id'])) {
        $data = fn_get_attachment($_REQUEST['attachment_id'], $_REQUEST['object_type'], $_REQUEST['object_id']);
        if (!empty($data['path'])) {
            fn_get_file($data['path']);
        }
    }
    exit;
} elseif ($mode == 'delete') {
    fn_delete_attachments(array($_REQUEST['attachment_id']), $_REQUEST['object_type'], $_REQUEST['object_id']);
    $attachments = fn_get_attachments($_REQUEST['object_type'], $_REQUEST['object_id']);
    if (empty($attachments)) {
        $view->display('addons/attachments/views/attachments/manage.tpl');
    }
    exit;
} elseif ($mode == 'update') {
    // Assign attachments files for products
    $attachments = fn_get_attachments($_REQUEST['object_type'], $_REQUEST['object_id']);
Exemplo n.º 2
0
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    //
    // Create/update attachments
    //
    if ($mode == 'update') {
        if (!empty($_REQUEST['attachment_data'])) {
            fn_update_attachments($_REQUEST['attachment_data'], $_REQUEST['attachment_id'], $_REQUEST['object_type'], $_REQUEST['object_id'], 'M', null, DESCR_SL);
        }
    }
    if ($mode == 'delete') {
        fn_delete_attachments(array($_REQUEST['attachment_id']), $_REQUEST['object_type'], $_REQUEST['object_id']);
        $attachments = fn_get_attachments($_REQUEST['object_type'], $_REQUEST['object_id']);
        if (empty($attachments)) {
            Tygh::$app['view']->display('addons/attachments/views/attachments/manage.tpl');
        }
        exit;
    }
    return array(CONTROLLER_STATUS_OK);
    // redirect should be performed via redirect_url always
}
if ($mode == 'getfile') {
    if (!empty($_REQUEST['attachment_id'])) {
        fn_get_attachment($_REQUEST['attachment_id']);
    }
    exit;
} elseif ($mode == 'update') {
    // Assign attachments files for products
    $attachments = fn_get_attachments($_REQUEST['object_type'], $_REQUEST['object_id'], 'M', DESCR_SL);
    Registry::set('navigation.tabs.attachments', array('title' => __('attachments'), 'js' => true));
    Tygh::$app['view']->assign('attachments', $attachments);
}