id}.csv"; } /** * Ensure that all cache files are writable or can be created * * @return bool */ public static function ensureWritable() { foreach (self::$all_files as $type) { $filename = self::_createFileName($type); if (file_exists($filename) && !is_writable($filename)) { return false; } elseif (!is_writable(dirname($filename))) { return false; } } return true; } /** * Returns the duplicates filename (the ones used to download to csv file * * @return string filename */ public static function getDuplicateFileName() { return self::_createFileName(self::FILE_DUPLICATES); } /** * Returns the duplicates display filename (the one used for display in html) * * @return string filename */ public static function getDuplicateFileDisplayName() { return self::_createFileName(self::FILE_DUPLICATES_DISPLAY); } /** * Returns the error filename * * @return string filename */ public static function getErrorFileName() { return self::_createFileName(self::FILE_ERRORS); } /** * Returns the error records filename * * @return string filename */ public static function getErrorRecordsFileName() { return self::_createFileName(self::FILE_ERROR_RECORDS); } /** * Returns the error records filename * * @return string filename */ public static function getErrorRecordsWithoutErrorFileName() { return self::_createFileName(self::FILE_ERROR_RECORDS_ONLY); } /** * Returns the status filename * * @return string filename */ public static function getStatusFileName() { return self::_createFileName(self::FILE_STATUS); } /** * Clears out all cache files in the import directory */ public static function clearCacheFiles() { global $sugar_config; $importdir = self::getImportDir(); if ( is_dir($importdir) ) { $files = dir($importdir); while (false !== ($file = $files->read())) { if ( !is_dir($file) && stristr($file,'.csv') ) unlink("$importdir/$file"); } } } }