Back to PhocacartFile class

Method deleteDownloadFolders

public static
deleteDownloadFolders
(mixed $folders, mixed $manager = 'productfile')

Method deleteDownloadFolders - Source code

public static function deleteDownloadFolders($folders, $manager = 'productfile')
{
    if (!empty($folders)) {
        foreach ($folders as $k => $v) {
            $path = PhocacartPath::getPath($manager);
            if (Folder::exists($path['orig_abs_ds'] . $v)) {
                if (Folder::delete($path['orig_abs_ds'] . $v)) {
                    if ($manager == 'attributefile') {
                        Factory::getApplication()->enqueueMessage(Text::_('COM_PHOCACART_SUCCESS_ATTRIBUTE_OPTION_DOWNLOAD_FOLDER_DELETED') . ': ' . $v, 'success');
                    } else {
                        Factory::getApplication()->enqueueMessage(Text::_('COM_PHOCACART_SUCCESS_PRODUCT_DOWNLOAD_FOLDER_DELETED') . ': ' . $v, 'success');
                    }
                } else {
                    if ($manager == 'attributefile') {
                        Factory::getApplication()->enqueueMessage(Text::_('COM_PHOCACART_ERROR_REMOVE_ATTRIBUTE_OPTION_DOWNLOAD_FOLDER') . ': ' . $v, 'error');
                    } else {
                        Factory::getApplication()->enqueueMessage(Text::_('COM_PHOCACART_ERROR_REMOVE_PRODUCT_DOWNLOAD_FOLDER') . ': ' . $v, 'error');
                    }
                }
            }
        }
    }
}