Example #1
0
$cmf = HaddockProjectOrganisation_ConfigManagerFactory::get_instance();
$tsm_cm = $cmf->get_config_manager('plug-ins', 'trackit-stock-management');
/*
 * Find out if there is an instance of this file already running.
 */
#$lock_file_name = $tsm_cm->get_dlntf_lock_file_name();
#
#if (!is_file($lock_file_name)) {
#	/*
#	 * Lock the process.
#	 */
#	if ($fh = fopen($lock_file_name, 'w')) {
#		fwrite($fh, date('c') . "\n");
#		fwrite($fh, getmypid() . "\n");
#	}
$download_non_text_files_lock_file = TrackitStockManagement_FeedFilesHelper::get_download_non_text_files_lock_file();
if ($download_non_text_files_lock_file->is_locked()) {
    throw new Exception('The download-non-text-files script is locked!');
} else {
    $download_non_text_files_lock_file->lock();
    /*
     * Create the database objects.
     */
    $muf = Database_MySQLUserFactory::get_instance();
    $mu = $muf->get_for_this_project();
    $database = $mu->get_database();
    $feed_files_table = $database->get_table('hpi_trackit_stock_management_feed_files');
    /*
     * Get the list of non-text files to download.
     */
    $fs = $feed_files_table->get_non_text_files_to_download();