Only in /var/www/media_mover: CVS Common subdirectories: /var/www/media_mover/contrib and ../mm_d6/contrib Common subdirectories: /var/www/media_mover/drivers and ../mm_d6/drivers diff -u /var/www/media_mover/media_mover_api.info ../mm_d6/media_mover_api.info --- /var/www/media_mover/media_mover_api.info 2007-09-04 20:42:20.000000000 -0400 +++ ../mm_d6/media_mover_api.info 2008-09-22 02:11:06.000000000 -0400 @@ -2,3 +2,5 @@ name = Media Mover API description = Core of the Media Mover system package = "Media Mover" +core=6.x +php = 5.0 \ No newline at end of file diff -u /var/www/media_mover/media_mover_api.install ../mm_d6/media_mover_api.install --- /var/www/media_mover/media_mover_api.install 2008-09-03 10:27:46.000000000 -0400 +++ ../mm_d6/media_mover_api.install 2008-09-22 03:04:59.000000000 -0400 @@ -2,245 +2,118 @@ /* $Id: media_mover_api.install,v 1.1.2.16 2008/09/03 14:27:46 arthuregg Exp $ */ -/* - @ TODO make psql correct +/** + * @FILE media mover db files + * NOTE, this will only upgrade a D5 version of media mover from the > 1-0-BETA1 release */ // media_mover.install -function media_mover_api_install() { - switch ($GLOBALS['db_type']) { - case 'mysqli': - case 'mysql': - db_query("CREATE TABLE {media_mover_files} ( - `mmfid` int(11) DEFAULT NULL, - `nid` int(11) DEFAULT NULL, - `fid` int(11) NOT NULL DEFAULT 0, - `cid` int(11) DEFAULT NULL, - `harvest_file` varchar(255) DEFAULT NULL, - `harvest_type` varchar(20) NOT NULL DEFAULT 'local', - `process_file` varchar(255) DEFAULT NULL, - `storage_file` varchar(255) DEFAULT NULL, - `complete_file` VARCHAR(225) DEFAULT NULL, - `url` varchar(255) NOT NULL DEFAULT '', - `status` VARCHAR(48) NOT NULL DEFAULT '', - `date` int(11) DEFAULT NULL, - `data` blob NOT NULL, - PRIMARY KEY (`mmfid`) - ) DEFAULT CHARACTER SET=utf8"); - - // stores the configuration config data - db_query("CREATE TABLE {media_mover_configurations} ( - `cid` int(11) NOT NULL default '0', - `verb` varchar(128) DEFAULT null, - `module` varchar(255) NOT NULL default '', - `action` varchar(255) NOT NULL default '', - `configuration` blob NOT NULL - )"); - - // stores the configuration meta data - db_query("CREATE TABLE {media_mover_config_list} ( - `cid` int(11) NOT NULL default '0', - `name` varchar(255) default NULL, - `description` varchar(255) default NULL, - `status` VARCHAR(48) NOT NULL default 'disabled', - `start_time` int(11) NOT null DEFAULT 0, - `last_start_time` int(11) NOT null DEFAULT 0, - `settings` blob NOT null, - `cron` int(2) NOT null DEFAULT 0, - `weight` int(3) NOT null DEFAULT 0, - PRIMARY KEY (`cid`) - ) DEFAULT CHARACTER SET=utf8"); - - // create a cache - db_query("CREATE TABLE IF NOT EXISTS {cache_media_mover} ( - `cid` varchar(255) NOT NULL default '', - `data` longblob, - `expire` int(11) NOT NULL default '0', - `created` int(11) NOT NULL default '0', - `headers` text, - PRIMARY KEY (`cid`), - KEY `expire` (`expire`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"); - break; - - //@TODO pgsql - case 'pgsql': - break; - } +/** +* Implementation of hook_install(). +*/ +function media_mover_install() { + // Create tables. + drupal_install_schema('media_mover_api'); } + /** * Implementation of hook_uninstall * deletes all media mover tables */ function media_mover_api_uninstall() { - db_query('DROP TABLE {media_mover_files}'); - db_query('DROP TABLE {media_mover_configurations}'); - db_query('DROP TABLE {media_mover_config_list}'); -} - -/** - * addes a status col to the configuration table - */ -function media_mover_api_update_1() { - switch ($GLOBALS['db_type']) { - case 'mysqli': - case 'mysql': - $ret[] = update_sql("ALTER TABLE {media_mover_config_list} CHANGE status status VARCHAR(48) NOT NULL DEFAULT 'disabled'"); - break; - } - - return $ret; -} - -/** - * adds data col to the files table - */ -function media_mover_api_update_2() { - switch ($GLOBALS['db_type']) { - case 'mysqli': - case 'mysql': - $ret[] = update_sql('ALTER TABLE {media_mover_files} ADD data BLOB NOT NULL AFTER status'); - break; - } - return $ret; -} - -/** - * Creates the file harvest comparison table - */ -function media_mover_api_update_3() { - switch ($GLOBALS['db_type']) { - case 'mysqli': - case 'mysql': - $ret[] = update_sql('ALTER TABLE {media_mover_config_list} ADD start_time int(11) NOT null DEFAULT 0 AFTER status'); - $ret[] = update_sql('ALTER TABLE {media_mover_config_list} ADD last_start_time int(11) NOT null DEFAULT 0 AFTER start_time'); - - break; - } - if ($ret) {return $ret;} -} - -/** - * adds data col to the files table - */ -function media_mover_api_update_4() { - switch ($GLOBALS['db_type']) { - case 'mysqli': - case 'mysql': - $ret[] = update_sql('ALTER TABLE {media_mover_files} ADD mmfid int(11) DEFAULT null FIRST'); - $ret[] = update_sql('ALTER TABLE {media_mover_files} DROP INDEX nid'); - $ret[] = update_sql('ALTER TABLE {media_mover_files} DROP PRIMARY KEY'); - break; - } - return $ret; -} - -/** - * increases the size of the file tables - */ -function media_mover_api_update_5() { - switch ($GLOBALS['db_type']) { - case 'mysqli': - case 'mysql': - $ret[] = update_sql('ALTER TABLE {media_mover_files} CHANGE `harvest_file` `harvest_file` VARCHAR( 225 ) '); - $ret[] = update_sql('ALTER TABLE {media_mover_files} CHANGE `process_file` `process_file` VARCHAR( 225 ) '); - $ret[] = update_sql('ALTER TABLE {media_mover_files} CHANGE `storage_file` `storage_file` VARCHAR( 225 ) '); - break; - } - return $ret; -} - -/** - * add the completion stuff - */ -function media_mover_api_update_6() { - switch ($GLOBALS['db_type']) { - case 'mysqli': - case 'mysql': - $ret[] = update_sql('ALTER TABLE {media_mover_files} ADD `complete_file` VARCHAR(225) NOT NULL AFTER `storage_file`'); - $ret[] = update_sql('ALTER TABLE {media_mover_files} ADD `complete_action` VARCHAR(225) NOT NULL AFTER `storage_file`'); - $ret[] = update_sql('ALTER TABLE {media_mover_files} ADD `complete_module` VARCHAR(225) NOT NULL AFTER `storage_file` '); - break; - } - return $ret; + drupal_uninstall_schema('media_mover_api'); } /** - * add dates for when files were harvested + * implementation of hook_schema() */ -function media_mover_api_update_9() { - switch ($GLOBALS['db_type']) { - case 'mysqli': - case 'mysql': - $ret[] = update_sql('ALTER TABLE {media_mover_files} ADD `date` int(11) DEFAULT 0 AFTER `status`'); - $ret[] = update_sql('UPDATE {media_mover_files} SET date = '. time() .' WHERE date = 0'); - break; +function media_mover_api_schema() { + $schema['media_mover_files'] = array( + 'fields' => array ( + 'mmfid' => array('type' => 'serial'), + 'nid' => array('type' => 'int', 'unsigned' => TRUE), + 'fid' => array('type' => 'int', 'unsigned' => TRUE), + 'cid' => array('type' => 'int', 'unsigned' => TRUE), + 'harvest_file' => array('type' => 'varchar', 'length' => 255, 'default' => ''), + 'process_file' => array('type' => 'varchar', 'length' => 255, 'default' => ''), + 'storage_file' => array('type' => 'varchar', 'length' => 255, 'default' => ''), + 'complete_file' => array('type' => 'varchar', 'length' => 225, 'default' => ''), + 'status' => array('type' => 'int', 'unsigned' => TRUE), + 'date' => array('type' => 'int', 'unsigned' => TRUE), + 'data' => array('type' => 'text', 'size' => 'medium'), + ), + 'indexes' => array ( + 'mmfid' => array('mmfid'), + 'nid' => array('nid'), + ), + 'primary key' => array ('mmfid'), + ); + + $schema['media_mover_configurations'] = array( + 'fields' => array ( + 'cid' => array('type' => 'int', 'int', 'unsigned' => TRUE, 'description' => 'Configuration id'), + 'verb' => array('type' => 'varchar', 'length' => 255, 'default' => ''), + 'module' => array('type' => 'varchar', 'length' => 255, 'default' => ''), + 'action' => array('type' => 'varchar', 'length' => 255, 'default' => ''), + 'configuration' => array('type' => 'text', 'size' => 'medium'), + ), + 'indexes' => array ( + 'cid' => array('cid'), + ), + ); + + $schema['media_mover_config_list'] = array( + 'fields' => array ( + 'cid' => array('type' => 'serial'), + 'name' => array('type' => 'varchar', 'length' => 255, 'default' => ''), + 'description' => array('type' => 'text', 'size' => 'normal'), + 'status' => array('type' => 'varchar', 'length' => 255, 'default' => ''), + 'start_time' => array('type' => 'int', 'unsigned' => TRUE), + 'last_start_time' => array('type' => 'int', 'unsigned' => TRUE), + 'settings' => array('type' => 'text', 'size' => 'medium'), + 'cron' => array('type' => 'int', 'unsigned' => TRUE), + 'weight' => array('type' => 'int', 'unsigned' => TRUE), + ), + 'indexes' => array ( + 'cid' => array('cid'), + ), + 'primary key' => array('cid'), + ); + + $schema['cache_media_mover'] = array( + 'fields' => array ( + 'cid' => array('type' => 'text', size => 'small'), + 'data' => array('type' => 'text', 'size' => 'medium'), + 'expire' => array('type' => 'int', 'unsigned' => TRUE), + 'created' => array('type' => 'int', 'unsigned' => TRUE), + 'headers' => array('type' => 'text'), + ), + 'indexes' => array ( + 'cid' => array('cid'), + ), + 'primary key' => array('cid'), + ); + + return $schema; +} + + +/** + * updates for 5x -> 6x + */ +function media_mover_api_update_6000() { + if (db_column_exists('media_mover_files', 'url')) { + $ret[] = update_sql('ALTER TABLE {media_mover_files} DROP url'); } - return $ret; - } - - /** - * changes the names of modules to reflect the new module naming scheme - */ -function media_mover_api_update_10() { - switch ($GLOBALS['db_type']) { - case 'mysqli': - case 'mysql': - $ret[] = update_sql('UPDATE {media_mover_files} SET harvest_module = "mm_node" WHERE harvest_module = "media_mover" AND harvest_action != 1'); - $ret[] = update_sql('UPDATE {media_mover_files} SET storage_module = "mm_node" WHERE storage_module = "media_mover" AND storage_action != 1'); - $ret[] = update_sql('UPDATE {media_mover_files} SET process_module = "mm_node" WHERE process_module = "media_mover" AND process_action != 1'); - $ret[] = update_sql('UPDATE {media_mover_files} SET storage_module = "mm_node" WHERE storage_module = "media_mover" AND storage_action != 1'); - $ret[] = update_sql('UPDATE {media_mover_configurations} SET module = "mm_node" WHERE module = "media_mover" AND action != 1'); - $ret[] = update_sql('UPDATE {media_mover_configurations} SET module = "media_mover_api" WHERE module = "media_mover" AND action = 1'); - break; + if (db_column_exists('media_mover_files', 'harvest_type')) { + $ret[] = update_sql('ALTER TABLE {media_mover_files} DROP harvest_type'); } return $ret; } -/** - * renumbers the action id values in the mm_node module - */ -function media_mover_api_update_11() { - switch ($GLOBALS['db_type']) { - case 'mysqli': - case 'mysql': - // move action id 6 to 1 - $ret[] = update_sql('UPDATE {media_mover_configurations} SET action = 1 WHERE action = 6 AND module = "mm_node"'); - $ret[] = update_sql('UPDATE {media_mover_files} SET harvest_action = 1 WHERE harvest_action = 6 AND harvest_module = "mm_node"'); - break; - } - return $ret; -} - -/** - * drops the cols for data that can be recreated from the configuration tables - */ -function media_mover_api_update_12() { - switch ($GLOBALS['db_type']) { - case 'mysqli': - case 'mysql': - $ret[] = update_sql('ALTER TABLE {media_mover_files} DROP harvest_module, DROP harvest_action, DROP process_module, DROP process_action, DROP storage_module, DROP storage_action, DROP complete_module, DROP complete_action'); - break; - } - return $ret; -} - -/** - * adds a rss col to a configuraiton description - */ -function media_mover_api_update_13() { - switch ($GLOBALS['db_type']) { - case 'mysqli': - case 'mysql': - $ret[] = update_sql('ALTER TABLE {media_mover_config_list} ADD `rss` int(2) NOT NULL default "0"'); - $ret[] = update_sql('ALTER TABLE {media_mover_config_list} ADD `cron` int(2) NOT NULL default "0"'); - break; - } - return $ret; -} /** * creates the media mover file info caches diff -u /var/www/media_mover/media_mover_api.module ../mm_d6/media_mover_api.module --- /var/www/media_mover/media_mover_api.module 2008-09-26 11:04:04.000000000 -0400 +++ ../mm_d6/media_mover_api.module 2008-09-26 11:46:50.000000000 -0400 @@ -1,6 +1,6 @@ 'admin/media_mover', - 'title' => t('Media Mover'), - 'callback' => 'media_mover_api_page', - 'access' => user_access('administer media_mover'), + $items['admin/media_mover'] = array( + 'title' => 'Media Mover', + 'page callback' => 'media_mover_api_page', + 'access arguments' => array('administer media_mover'), 'type' => MENU_NORMAL_ITEM, ); @@ -74,81 +73,73 @@ // MAIN TABS for admin/media_mover // main page - $items[] = array( - 'path' => 'admin/media_mover/default', - 'title' => t('Overview'), - 'callback' => 'media_mover_api_page', - 'access' => user_access('administer media_mover'), + $items['admin/media_mover/default'] = array( + 'title' => 'Overview', + 'page callback' => 'media_mover_api_page', + 'access arguments' => array('administer media_mover'), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10, ); // settings as a tab - $items[] = array( - 'path' => 'admin/media_mover/settings', - 'title' => t('Settings'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('media_mover_api_admin_settings'), - 'access' => user_access('administer media_mover'), + $items['admin/media_mover/settings'] = array( + 'title' => 'Settings', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('media_mover_api_admin_settings'), + 'access arguments' => array('administer media_mover'), 'type' => MENU_LOCAL_TASK, ); // settings in the normal place - $items[] = array( - 'path' => 'admin/settings/media_mover', - 'title' => t('Media Mover admin settings'), - 'description' => t('Configure default settings for Media Mover modules.'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('media_mover_api_admin_settings'), - 'access' => user_access('administer media_mover'), + $items['admin/settings/media_mover'] = array( + 'title' => 'Media Mover admin settings', + 'description' => 'Configure default settings for Media Mover modules.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('media_mover_api_admin_settings'), + 'access arguments' => array('administer media_mover'), ); // add a new configuration - $items[] = array( - 'path' => 'admin/media_mover/config/add', - 'title' => t('Add Config'), - 'callback' => 'drupal_get_form', - 'access' => user_access('administer media_mover'), - 'callback arguments' => array('media_mover_api_add_config_form', arg(4)), + $items['admin/media_mover/add'] = array( + 'title' => 'Add Config', + 'page callback' => 'drupal_get_form', + 'access arguments' => array('administer media_mover'), + 'page arguments' => array('media_mover_api_add_config_form', arg(3)), 'type' => MENU_LOCAL_TASK, ); // show all files - $items[] = array( - 'path' => 'admin/media_mover/files', - 'title' => t('All Files'), - 'callback' => 'media_mover_api_files_list', - 'callback arguments' => array(arg(3)), - 'access' => user_access('administer media_mover'), + $items['admin/media_mover/files'] = array( + 'title' => 'All Files', + 'page callback' => 'media_mover_api_files_list', + 'page arguments' => array(arg(3)), + 'access arguments' => array('administer media_mover'), 'type' => MENU_LOCAL_TASK, 'weight' => -9, ); // files status - $items[] = array( - 'path' => 'admin/media_mover/files/status', - 'title' => t('File Status'), - 'callback' => 'media_mover_api_files_status', - 'access' => user_access('administer media_mover'), + $items['admin/media_mover/files/status'] = array( + 'title' => 'File Status', + 'page callback' => 'media_mover_api_files_status', + 'access arguments' => array('administer media_mover'), 'type' => MENU_LOCAL_TASK, ); // import a configuration - $items[] = array( - 'path' => 'admin/media_mover/import', - 'title' => t('Import'), - 'callback' => 'media_mover_api_import_config', - 'access' => user_access('administer media_mover'), + $items['admin/media_mover/import'] = array( + 'title' => 'Import', + 'page callback' => 'media_mover_api_import_config', + 'access arguments' => array('administer media_mover'), 'type' => MENU_LOCAL_TASK, 'weight' => 10, ); // export a configuration - $items[] = array( - 'path' => 'admin/media_mover/export', - 'title' => t('Export'), - 'callback' => 'media_mover_api_export', - 'access' => user_access('administer media_mover'), + $items['admin/media_mover/export'] = array( + 'title' => 'Export', + 'page callback' => 'media_mover_api_export', + 'access arguments' => array('administer media_mover'), 'type' => MENU_LOCAL_TASK, 'weight' => 10, ); @@ -156,99 +147,88 @@ // ------------------------------------------------------- // Individual Configuration functions - // only add these to the menu if we're on a config page - if (arg(2) == 'config' && is_numeric(arg(3))) { + // landing page for an individual configuration + $items['admin/media_mover/config'] = array( + 'title' => t('Description'), + 'page callback' => 'media_mover_api_configuration_view', + 'access arguments' => array('administer media_mover'), + 'page arguments' => array(3), + 'type' => MENU_DEFAULT_LOCAL_TASK, + 'weight' => -9, + ); - // landing page for an individual configuration - $items[] = array( - 'path' => 'admin/media_mover/config/'. arg(3), - 'title' => t('View'), - 'callback' => 'media_mover_api_configuration_view', - 'access' => user_access('administer media_mover'), - 'callback arguments' => array(arg(3)), - 'type' => MENU_DEFAULT_LOCAL_TASK, - 'weight' => -9, - ); - - // landing page for an individual configuration - $items[] = array( - 'path' => 'admin/media_mover/config/'. arg(3) .'/view', - 'title' => t('Details'), - 'callback' => 'media_mover_api_configuration_view', - 'access' => user_access('administer media_mover'), - 'callback arguments' => array(arg(3)), - 'type' => MENU_LOCAL_TASK, - 'weight' => -10, - ); - - // edit tab for a configuration - $items[] = array( - 'path' => 'admin/media_mover/config/'. arg(3) .'/edit', - 'title' => t('Edit'), - 'callback' => 'drupal_get_form', - 'access' => user_access('administer media_mover'), - 'callback arguments' => array('media_mover_api_config_edit_form', arg(3)), - 'type' => MENU_LOCAL_TASK, - ); - - // file tab for a configuration - $items[] = array( - 'path' => 'admin/media_mover/config/'. arg(3) .'/files', - 'title' => t('Files'), - 'callback' => 'media_mover_api_files_list', - 'access' => user_access('administer media_mover'), - 'callback arguments' => array(arg(3)), - 'type' => MENU_LOCAL_TASK, - ); + + // landing page for an individual configuration + $items['admin/media_mover/config/%/view'] = array( + 'title' => t('Description'), + 'page callback' => 'media_mover_api_configuration_view', + 'access arguments' => array('administer media_mover'), + 'page arguments' => array(3), + 'type' => MENU_DEFAULT_LOCAL_TASK, + 'weight' => -9, + ); + + // Edit a configuration + $items['admin/media_mover/config/%/edit'] = array( + 'title' => 'Edit Configuration', + 'page callback' => 'drupal_get_form', + 'access arguments' => array('administer media_mover'), + 'page arguments' => array('media_mover_api_config_edit_form', 3), + 'type' => MENU_LOCAL_TASK, + ); + + // run tab for a configuration + $items['admin/media_mover/config/%/run'] = array( + 'title' => 'Run', + 'page callback' => 'media_mover_api_run_configuration', + 'access arguments' => array('administer media_mover'), + 'page arguments' => array(3), + 'type' => MENU_LOCAL_TASK, + ); + + // stop an existing configuration + $items['admin/media_mover/config/%/stop'] = array( + 'title' => 'Confirm Configuration Stop', + 'page callback' => 'drupal_get_form', + 'access arguments' => array('administer media_mover'), + 'type' => MENU_CALLBACK, + 'page arguments' => array('media_mover_api_config_stop_confirm', 3), + ); + + // file tab for a configuration + $items['admin/media_mover/config/%/files'] = array( + 'title' => 'Files', + 'page callback' => 'media_mover_api_files_list', + 'access arguments' => array('administer media_mover'), + 'page arguments' => array(3), + 'type' => MENU_LOCAL_TASK, + ); // clear non finished files for a config - $items[] = array( - 'path' => 'admin/media_mover/config/'. arg(3) .'/files/clear', - 'title' => t('Files'), - 'callback' => 'media_mover_api_config_files_clear', - 'access' => user_access('administer media_mover'), - 'callback arguments' => array(arg(3)), + $items['admin/media_mover/config/'. '%' .'/files/clear'] = array( + 'title' => 'Files', + 'page callback' => 'media_mover_api_config_files_clear', + 'access arguments' => array('administer media_mover'), + 'page arguments' => array(arg(3)), 'type' => MENU_LOCAL_TASK, ); - // run tab for a configuration - $items[] = array( - 'path' => 'admin/media_mover/config/'. arg(3) .'/run', - 'title' => t('Run'), - 'callback' => 'media_mover_api_run_configuration', - 'access' => user_access('administer media_mover'), - 'callback arguments' => array(arg(3)), - 'type' => MENU_LOCAL_TASK, - ); - } - - // stop an existing configuration - $items[] = array( - 'path' => 'admin/media_mover/config/'. arg(3) .'/stop', - 'title' => t('Confirm Configuration Stop'), - 'callback' => 'drupal_get_form', - 'access' => user_access('administer media_mover'), - 'type' => MENU_CALLBACK, - 'callback arguments' => array('media_mover_api_config_stop_confirm', arg(3)), - ); // delete an existing configuration - $items[] = array( - 'path' => 'admin/media_mover/config/'. arg(3) .'/delete', - 'title' => t('Confirm Configuration Deletion'), - 'callback' => 'drupal_get_form', - 'access' => user_access('administer media_mover'), - 'callback arguments' => array('media_mover_api_config_delete_confirm', arg(3)), + $items['admin/media_mover/config/'. '%' .'/delete'] = array( + 'title' => 'Confirm Configuration Deletion', + 'page callback' => 'drupal_get_form', + 'access arguments' => array('administer media_mover'), + 'page arguments' => array('media_mover_api_config_delete_confirm', arg(3)), 'type' => MENU_CALLBACK, ); // Empty an existing configuration of files - $items[] = array( - 'path' => 'admin/media_mover/config/'. arg(3) .'/empty', - 'title' => t('Confirm Configuration Deletion'), - 'callback' => 'drupal_get_form', - 'access' => user_access('administer media_mover'), - 'callback arguments' => array('media_mover_api_config_empty_confirm', arg(3)), + $items['admin/media_mover/config/'. '%' .'/empty'] = array( + 'title' => 'Confirm Configuration Deletion', + 'page callback' => 'drupal_get_form', + 'access arguments' => array('administer media_mover'), + 'page arguments' => array('media_mover_api_config_empty_confirm', arg(3)), 'type' => MENU_CALLBACK, ); @@ -256,48 +236,44 @@ // Configuration tasks // change a configuration status - $items[] = array( - 'path' => 'admin/media_mover/config/'. arg(3). '/status/'. arg(5), - 'title' => t('Update configuration status'), - 'callback' => 'drupal_get_form', - 'access' => user_access('administer media_mover'), + $items['admin/media_mover/config/'. arg(3). '/status/'. '%'] = array( + 'title' => 'Update configuration status', + 'page callback' => 'drupal_get_form', + 'access arguments' => array('administer media_mover'), 'type' => MENU_CALLBACK, - 'callback arguments' => array('media_mover_api_config_status_change_confirm', arg(3), arg(5) ), + 'page arguments' => array('media_mover_api_config_status_change_confirm', arg(3), arg(5) ), ); // ------------------------------------------------------- // File tasks // edit a file - $items[] = array( - 'path' => 'admin/media_mover/file/edit', - 'title' => t('Edit File'), - 'callback' => 'drupal_get_form', - 'access' => user_access('administer media_mover'), + $items['admin/media_mover/file/edit'] = array( + 'title' => 'Edit File', + 'page callback' => 'drupal_get_form', + 'access arguments' => array('administer media_mover'), 'type' => MENU_CALLBACK, - 'callback arguments' => array('media_mover_api_edit_file_form', arg(4)), + 'page arguments' => array('media_mover_api_edit_file_form', 4), ); // delete a file - $items[] = array( - 'path' => 'admin/media_mover/file/delete', - 'title' => t('Delete File'), - 'callback' => 'drupal_get_form', - 'access' => user_access('administer media_mover'), + $items['admin/media_mover/file/delete'] = array( + 'title' => 'Delete File', + 'page callback' => 'drupal_get_form', + 'access arguments' => array('administer media_mover'), 'type' => MENU_CALLBACK, - 'callback arguments' => array('media_mover_api_file_delete_confirm_form', arg(4)), + 'page arguments' => array('media_mover_api_file_delete_confirm_form', 4), ); // ------------------------------------------------------- // File tasks - $items[] = array( - 'path' => 'media_mover/rerun/'. arg(2) .'/node', - 'title' => t('Rerun process'), - 'callback' => 'drupal_get_form', - 'access' => user_access('administer media_mover'), + $items['media_mover/rerun/'. '%' .'/node'] = array( + 'title' => 'Rerun process', + 'page callback' => 'drupal_get_form', + 'access arguments' => array('administer media_mover'), 'type' => MENU_CALLBACK, - 'callback arguments' => array('media_mover_api_rerun_node_form', arg(2), arg(4)), + 'page arguments' => array('media_mover_api_rerun_node_form', arg(2), arg(4)), ); return $items; @@ -324,10 +300,10 @@ foreach ($configurations as $config) { // check to see if we should run on cron for this configuration if (isset($config->config->mma_cron_run) ? $config->config->mma_cron_run : variable_get('mma_cron_run', true)) { - // now we check and see there is a hard override of this cron - if (! constant("MEDIA_MOVER_CRON_OFF_". $config->cid)) { + // now we check and see there is a hard override of this cron + if (! constant("MEDIA_MOVER_CRON_OFF_". $config->cid)) { media_mover_api_run_config($config, null, null, true); - } + } } } } @@ -356,7 +332,7 @@ case "delete": // invoke MM modules here and delete files associated with this node if (variable_get('mma_node_file_delete', false)) { - media_mover_api_node_file_delete($node); + media_mover_api_node_files_delete($node); } break; @@ -378,7 +354,7 @@ * @param string $form_id * @param array $form drupal form array */ -function media_mover_api_form_alter($form_id, &$form) { +function media_mover_api_form_alter(&$form, $form_state, $form_id) { // check and see if this is a node delete form if ($form_id == 'node_delete_confirm') { // load the node @@ -515,20 +491,20 @@ * @return array or string */ function media_mover_api_item_status($status = null) { - static $states; - if (! $states) { + static $states; + if (! $states) { $states = array( MMA_FILE_ERROR => t('Error'), - MMA_FILE_STATUS_HARVESTED => t('Harvested'), - MMA_FILE_STATUS_IN_PROCESS => t('Processing'), - MMA_FILE_STATUS_PROCESS_COMPLETE => t('Processed'), - MMA_FILE_STATUS_IN_STORAGE => t('Storing'), - MMA_FILE_STATUS_STORAGE_COMPLETE => t('Stored'), - MMA_FILE_STATUS_IN_COMPLETE => t('Finishing'), - MMA_FILE_STATUS_COMPLETE_COMPLETE => t('Finished'), - ); - } - if ($status) {return $states[$status];} + MMA_FILE_STATUS_HARVESTED => t('Harvested'), + MMA_FILE_STATUS_IN_PROCESS => t('Processing'), + MMA_FILE_STATUS_PROCESS_COMPLETE => t('Processed'), + MMA_FILE_STATUS_IN_STORAGE => t('Storing'), + MMA_FILE_STATUS_STORAGE_COMPLETE => t('Stored'), + MMA_FILE_STATUS_IN_COMPLETE => t('Finishing'), + MMA_FILE_STATUS_COMPLETE_COMPLETE => t('Finished'), + ); + } + if ($status) {return $states[$status];} return $states; } @@ -544,27 +520,27 @@ * @return string */ function media_mover_api_verb_base_status($verb, $id = null) { - static $status; - if (! $status) { - $status = array( - // note that the harvest is a special case as the file - // would not exist previous to the harvest - 'harvest' => 0, - 'process' => MMA_FILE_STATUS_HARVESTED, - 'storage' => MMA_FILE_STATUS_PROCESS_COMPLETE, - 'complete' => MMA_FILE_STATUS_STORAGE_COMPLETE - ); - } + static $status; + if (! $status) { + $status = array( + // note that the harvest is a special case as the file + // would not exist previous to the harvest + 'harvest' => 0, + 'process' => MMA_FILE_STATUS_HARVESTED, + 'storage' => MMA_FILE_STATUS_PROCESS_COMPLETE, + 'complete' => MMA_FILE_STATUS_STORAGE_COMPLETE + ); + } - // do we need to hand back verbs or ids? + // do we need to hand back verbs or ids? if ($id) { - // return the $verb for the ID - $return = array_flip($status); - } + // return the $verb for the ID + $return = array_flip($status); + } else { - $return = $status; + $return = $status; } - return $return[$verb]; + return $return[$verb]; } @@ -605,7 +581,6 @@ else { // load up the configuration object $config = media_mover_api_get_configuration($cid); - if ($config->status == MMA_CONFIG_STATUS_RUNNING) { $output = t('This configuration is already running. Please wait for it to finish.'); } @@ -634,13 +609,13 @@ */ function media_mover_api_run_config($config, $debug = true, $nid = null, $cron = false) { $output = t('Running') .' '. l($config->name, 'admin/media_mover/config/'. $config->cid) ."
"; - /** + /** * first, lock config, harvest files, store files, unlock config * get all files ready for processing, process one file at a time * lock each file to prevent overrunning */ - // check to make sure that we have all directories + // check to make sure that we have all directories media_mover_api_check_config_dirs($config); // start the loop where we run all the verbs @@ -648,13 +623,13 @@ // we make a special case for harvesting // @ TODO refactor harvest to work the same way that all the other steps do. if ($verb == 'harvest') { - $output = media_mover_api_run_config_harvest($config, $verb, $nid); + $output = media_mover_api_run_config_harvest($config, $verb, $nid); } else { // ----------------------------------------------------- // run all the other configuration actions - // pass back the stuatus of the previous step to get the previous files - $output .= media_mover_api_run_config_verb($config, $verb, media_mover_api_verb_base_status($verb), $cron); + // pass back the stuatus of the previous step to get the previous files + $output .= media_mover_api_run_config_verb($config, $verb, media_mover_api_verb_base_status($verb), $cron); } } // end verb loop @@ -678,7 +653,7 @@ // and make sure that no other harvest is running. if (! media_mover_api_harvest_lock($config->cid)) { // set some output display - $output .= t('Harvesting.... ') .'
'; + $output .= t('Harvesting.... ') .'
'; $files = module_invoke($config->{$verb}->module, 'media_mover', $verb, $config->{$verb}->action, $config->{$verb}->configuration, null, $config, $nid); $output .= t('Configurationg process: harvest found !count files', array('!count' => count($files))) .'
'; // store the harvested files @@ -719,10 +694,10 @@ $output = t('Configuration process: %verb is acting on !count files', array('%verb' => $verb, '!count' => count($files))) .'
'; // loop through all of the found files for this status foreach ($files as $file) { - // only run this if cron isn't requeseting this OR cpu check doesn't report a high condition - if (! $cron || ( $cron && ! media_mover_api_cpu_check() )) { + // only run this if cron isn't requeseting this OR cpu check doesn't report a high condition + if (! $cron || ( $cron && ! media_mover_api_cpu_check() )) { media_mover_api_run_config_verb_file($file, $config, $verb); - } + } } return $output; } @@ -925,17 +900,16 @@ // figure out how long ago the job started $time = intval( (time() - $config['start_time']) / 60); - $message = t('Media Mover detected a MM job (!name) that has been running for !time minutes. You may want to consider decreasing your cron.php frequency or increase your PHP timeout.', - array('!name' => $config['name'], '!time' => $time) - ); + $message = 'Media Mover detected a MM job (!name) that has been running for !time minutes. You may want to consider decreasing your cron.php frequency or increase your PHP timeout.'; + $params = array('!name' => $config['name'], '!time' => $time); // set watchdog - watchdog('media_mover', $message, 'WATCHDOG_NOTICE' ); + watchdog('media_mover', $message, $params, 'WATCHDOG_WARNING' ); // should we alert an admin? if (variable_get('mma_cron_notify', false) && ($time >= variable_get('mma_cron_notify_time', 10))) { $subject = t('[!sitename] Media Mover Job Stuck', array('!sitename' => variable_get('site_name', false))); - drupal_mail('media_mover_api_job_running', variable_get('mma_cron_notify_email', null), $subject, $message); + drupal_mail('media_mover_api_job_running', variable_get('mma_cron_notify_email', null), $subject, t($message, $params)); } } return $output; @@ -1016,7 +990,7 @@ // are there stuck any to report? if (count($rows)) { $message = theme('media_mover_api_stuck_job', $rows); - watchdog('media_mover', $message, 'WATCHDOG_NOTICE' ); + watchdog('media_mover', $message, array(), 'WATCHDOG_NOTICE' ); // load the configuration to see if we have settings we have to abide by $configuration = media_mover_api_get_configuration($result['cid']); @@ -1048,17 +1022,17 @@ */ function media_mover_api_event_trigger($type, $event, $verb, $data) { switch ($type) { - case 'config': - switch($event) { - case 'run': - if (module_exists('mm_workflow_ng')) { - // fire the harvest method; - workflow_ng_invoke_event('media_mover_'. $verb .'_file', $data); + case 'config': + switch($event) { + case 'run': + if (module_exists('mm_workflow_ng')) { + // fire the harvest method; + workflow_ng_invoke_event('media_mover_'. $verb .'_file', $data); } break; - } - break; - } + } + break; + } } @@ -1107,9 +1081,11 @@ * @param int $status usually "enabled" * @return cid value */ -function media_mover_api_config_name_add($name, $description, $settings, $status) { - $cid = db_next_id("{media_mover_config_list}_cid"); - db_query("INSERT INTO {media_mover_config_list} (cid, name, description, settings, status) VALUES (%d, '%s', '%s', %d, '%s')", $cid, $name, $description, serialize($settings), $status ); +function media_mover_api_config_add($name, $description, $settings, $status) { + db_query("INSERT INTO {media_mover_config_list} (name, description, settings, status) VALUES ('%s', '%s', %d, '%s')", + $name, $description, serialize($settings), $status + ); + $cid = db_last_insert_id('media_mover_config_list', 'cid'); return $cid; } @@ -1125,6 +1101,7 @@ db_query("INSERT INTO {media_mover_configurations} (cid, verb, module, action, configuration) VALUES (%d, '%s', '%s', '%s', '%s')", $cid, $verb, $module, $action, serialize($configuration)); } + /** * adds a newly created media_mover file to the media_mover db table * @@ -1133,19 +1110,14 @@ * @param $verb is what MM processs is calling this * @return $mmfid for this files ID */ -function media_mover_api_file_db_add($file, $config, $verb, $status) { - // get next mmfid - $mmfid = db_next_id("{media_mover_files}_mmfid"); - - // add to db - db_query("INSERT INTO {media_mover_files} - (mmfid, nid, fid, cid, harvest_file, status, date, data) - VALUES (%d, %d, %d, %d, '%s', %d, %d, '%s')", - $mmfid, $file['nid'], $file['fid'], $config->cid, - $file['harvest_file'], $status, time(), serialize($file) +function media_mover_api_file_db_add($file, $config, $verb, $status) { + // add to db + db_query("INSERT INTO {media_mover_files} (nid, fid, cid, harvest_file, status, date, data) VALUES (%d, %d, %d, '%s', %d, %d, '%s')", + $file['nid'], $file['fid'], $config->cid, $file['harvest_file'], $status, time(), serialize($file) ); - return $mmfid; + // return the mmfid + return db_last_insert_id("media_mover_files", 'mmfid'); } @@ -1197,16 +1169,15 @@ // create cache name $cache_name = 'media_mover_files_node_'. $nid; // get data from cache - $data = cache_get($cache_name, 'cache_media_mover'); - $data = unserialize($data->data); + // we can haz cache? - if (! $data) { + if (! $data = cache_get($cache_name, 'cache_media_mover')) { $data = array(); $items = db_query('SELECT mmfid, cid FROM {media_mover_files} WHERE nid= %d ORDER BY cid', $nid); while ($item = db_fetch_array($items)) { $data[$item['cid']][] = media_mover_api_file_fetch($item['mmfid']); } - cache_set($cache_name, 'cache_media_mover', serialize($data), CACHE_TEMPORARY); + cache_set($cache_name, 'cache_media_mover', $data, CACHE_TEMPORARY); } return $data; } @@ -1221,11 +1192,11 @@ * @return string */ function media_mover_api_config_current_file($file, $type = 'previous') { - switch ($type) { - case 'previous': - return $file[media_mover_api_verb_base_status($file['status'] - 2, true) .'_file']; - break; - } + switch ($type) { + case 'previous': + return $file[media_mover_api_verb_base_status($file['status'] - 2, true) .'_file']; + break; + } } @@ -1263,9 +1234,9 @@ // first lock the table so that nobody can get in the mix db_lock_table('media_mover_files'); db_query("UPDATE {media_mover_files} SET ". - "nid = %d, harvest_file = '%s', process_file = '%s', storage_file = '%s', complete_file = '%s', url = '%s', status = %d, data = '%s' WHERE mmfid = %d ", + "nid = %d, harvest_file = '%s', process_file = '%s', storage_file = '%s', complete_file = '%s', status = %d, data = '%s' WHERE mmfid = %d ", $file['nid'], $file['harvest_file'], $file['process_file'], $file['storage_file'], - $file['complete_file'], $file['url'], $status, $file['data'], $file['mmfid'] + $file['complete_file'], $status, $file['data'], $file['mmfid'] ); foreach (media_mover_api_verbs() as $verb) { module_invoke($file["{$verb}_module"], 'media_mover', 'update', $file["{$verb}_action"], null, $file ); @@ -1320,7 +1291,7 @@ * @return array of configuration objects */ function media_mover_api_get_configurations() { - $configurations = array(); + $configurations = array(); // get all active configuration names $results = db_query("SELECT * FROM {media_mover_config_list} mmcl WHERE mmcl.status != 'disabled'"); while ($config_name = db_fetch_array($results)) { @@ -1331,6 +1302,15 @@ /** + * wrapper function for menu arguments + * @param int $cid + * @return object + */ +function media_mover_api_menu_get_configuration_load($cid) { + return media_mover_api_get_configuration($cid); +} + +/** * takes a CID and returns the full configuration object * uses a local cache to store config data to prevent multiple hits the DB * @param int $cid is a configuration id @@ -1346,7 +1326,10 @@ $configurations[$cid] = media_mover_api_build_configuration($result); } } - // return the config + // return false if necessary + + if (! $configurations[$cid]) { return false;} + // return the config return $configurations[$cid]; } @@ -1460,7 +1443,7 @@ $form['admin']['cpu'] = array( '#title' => t('CPU settings'), '#type' => 'fieldset', - '#collapsed' => true, + '#collapsed' => true, ); $form['admin']['cpu']['cpu_limit'] = array( @@ -1499,7 +1482,6 @@ * @return string html */ function media_mover_api_page() { - // add the css file drupal_add_css(drupal_get_path('module', 'media_mover_api') . '/media_mover_api.css'); @@ -1567,7 +1549,7 @@ $row = array(); // build the name and description - $name = l($result['name'], 'admin/media_mover/config/'. $result['cid'] .'/view') .'
'. substr($result['description'], 0, 100) .'...'; + $name = l($result['name'], 'admin/media_mover/config/'. $result['cid'] ) .'
'. substr($result['description'], 0, 100) .'...'; // is this configuration harvesting from another MM config? if ($parent_id = media_mover_api_config_parent_config($result['cid'])) { @@ -1643,13 +1625,16 @@ /** * creates the landing page for an individual configuration * - * @param int $cid is a configuration id + * @param int $cid + * media mover configuration id * @return string html */ function media_mover_api_configuration_view($cid) { + // load the configuration $config = media_mover_api_get_configuration($cid); - drupal_set_title(t('Viewing: !name', array('!name' => $config->name))); + drupal_set_title(t('Viewing: !name', array('!name' => $config->name))); + // create the list of actions you can take with this configuration $actions = array( l(t('Edit configuration'), "admin/media_mover/config/$cid/edit"), @@ -1673,7 +1658,7 @@ $description[] = '

'. t('!count files harvested by this configuration', array('!count' => media_mover_api_configuration_files_count($cid))) .'

'; // get the in process file count - $process_count = media_mover_api_configuration_files_count($result['cid'], true); + $process_count = media_mover_api_configuration_files_count($cid, true); $description[] = '

'. t('!count files are currently being processed by this configuration', array('!count' => $process_count)) .'

'; // get a list of all the modules for this configuration @@ -1697,14 +1682,14 @@ * @param string $id is a cache id for the import functions * @return array drupal form array */ -function media_mover_api_add_config_form($id) { +function media_mover_api_add_config_form($id) { // do we have an incoming cache id that we should load // an imported configuration from? if ($id) { $configuration = cache_get('media_mover_config_'. $id); if ($configuration->data) { - $configuration = unserialize($configuration->data); - drupal_set_message(t('You are now configuring the configuration you just imported. Please make any changes and save the configuration.')); + $configuration = unserialize($configuration->data); + drupal_set_message(t('You are now configuring the configuration you just imported. Please make any changes and save the configuration.')); } } @@ -1734,7 +1719,7 @@ * @return string prefix name */ function media_mover_api_form_prefix($configuration) { - return $configuration['verb'] .'--'. $configuration['module'] .'--'. $configuration['action'] .'--'; + return $configuration['verb'] .'--'. $configuration['module'] .'--'. $configuration['action'] .'--'; } @@ -1746,7 +1731,7 @@ * @return array drupal form array */ function media_mover_api_configuration_base_form($configuration = null) { - $form['config'] = array( + $form['config'] = array( '#type' => 'fieldset', '#title' => t('Configuration Info'), ); @@ -1902,7 +1887,7 @@ * @return array drupal form array */ function media_mover_api_build_add_config($configuration) { - + // add the javascript to show and hide configuration for modules drupal_add_js(drupal_get_path('module', 'media_mover_api') .'/media_mover_api.js'); @@ -1929,19 +1914,19 @@ if ($actions[$verb]) { foreach ($actions[$verb] as $action_id => $action) { - // if we don't have a config, build one - if (! $configuration->{$verb}->configuration) { - $config = array( - 'verb' => $verb, - 'module' => $module, - 'action' => $action_id, - ); - } - // we have a config, use it - else { - $config = $configuration->{$verb}->configuration; - } - + // if we don't have a config, build one + if (! $configuration->{$verb}->configuration) { + $config = array( + 'verb' => $verb, + 'module' => $module, + 'action' => $action_id, + ); + } + // we have a config, use it + else { + $config = $configuration->{$verb}->configuration; + } + // get the config form from the modules if (! $action_form = module_invoke($module, 'media_mover', 'config', $action_id, $config)) { // this action has no config, make a default @@ -2048,8 +2033,8 @@ * @param array $form_values * is the array of form data */ -function media_mover_api_add_config_form_validate($form_id, $form_values) { - media_mover_api_config_form_validate($form_values, true); +function media_mover_api_add_config_form_validate($form, &$form_state) { + media_mover_api_config_form_validate($form_state, true); } @@ -2062,16 +2047,16 @@ * is the array of form data * */ -function media_mover_api_add_config_form_submit($form_id, $form_values) { +function media_mover_api_add_config_form_submit($form, &$form_state) { // Get all of the general configuration data out of this form - $settings = media_mover_api_configuration_get_settings($form_values); + $settings = media_mover_api_configuration_get_settings($form_state['values']); // create the config and get a cid for building the configuration - $cid = media_mover_api_config_name_add($form_values['mm_config_name'], $form_values['mm_config_descript'], $settings , 'enabled'); + $cid = media_mover_api_config_add($form_state['values']['mm_config_name'], $form_state['values']['mm_config_descript'], $settings , 'enabled'); // fish out the data for each item foreach (media_mover_api_verbs() as $verb) { - $configuration[$verb] = media_mover_api_collect_form_data($verb, $form_values); + $configuration[$verb] = media_mover_api_collect_form_data($verb, $form_state['values']); } // add each configuration's config to the db @@ -2079,9 +2064,9 @@ media_mover_api_configuration_process_add($cid, $verb, $config['module'], $config['action'], $config['configuration'], 1 ); } - drupal_set_message(t('Media mover configuration %name created.', array('%name' => $form_values['name']))); + drupal_set_message(t('Media mover configuration %name created.', array('%name' => $form_state['values']['name']))); - return 'admin/media_mover'; + $form_state['redirect'] = 'admin/media_mover/config/'. $cid; } @@ -2123,12 +2108,12 @@ * @return object */ function media_mover_api_configuration_get_settings($form_values) { - foreach ($form_values as $name => $value) { - if (strstr($name, 'mma_')) { - $settings->{$name} = $value; - } - } - return $settings; + foreach ($form_values as $name => $value) { + if (strstr($name, 'mma_')) { + $settings->{$name} = $value; + } + } + return $settings; } @@ -2138,17 +2123,17 @@ * only the specific configurations for the origional configuration * can be change which prevents some potentially bad things from happening * - * @param int $cid is a configuration id + * @param array $form + * @param array $configuration is a configuration id * @return array drupal form */ -function media_mover_api_config_edit_form($cid) { - // get the full configuration object +function media_mover_api_config_edit_form($form, $cid) { $configuration = media_mover_api_get_configuration($cid); - + // check if this configuration is currently running, if it is, return user to config screen if ($configuration->status == 'running') { drupal_set_message(t('This configuration is currently running. You need to wait to modify it until it is complete.'), 'error'); - drupal_goto('admin/media_mover/config/'. $cid); + drupal_goto('admin/media_mover/config/'. $configuration->cid ); } // get the standard elements for the configuration @@ -2171,7 +2156,7 @@ $form['config']['cid']= array( '#type' => 'hidden', - '#value' => $cid, + '#value' => $configuration->cid , ); // we need to build out the existing data @@ -2182,8 +2167,6 @@ ); } - // get the full configuration - $configuration = media_mover_api_get_configuration($cid); // build each form element for this configuration foreach(media_mover_api_verbs() as $weight => $verb) { // get the form for this configuration role @@ -2259,43 +2242,45 @@ * @param string $form_edit * @param array $form_values */ -function media_mover_api_config_edit_form_validate($form_edit, $form_values) { - media_mover_api_config_form_validate($form_values, false); +function media_mover_api_config_edit_form_validate($form, &$form_state) { + media_mover_api_config_form_validate($form, $form_state, false); } /** * saves the edited configuration for data * this pulls apart the prefixed form elements and sorts them into the right configuration - * buckets + * buckets + * @ TODO evaluate different ways of doing this that maybe possible under D6 that make this + * code simpler. * * @param string $form_id * @param array $form_values * @return drupal goto (as all form submits are) */ -function media_mover_api_config_edit_form_submit($form_id, $form_values) { +function media_mover_api_config_edit_form_submit($form, &$form_state) { // check to see if the status was disabled // this is somewhat of a hackish approach here - if (! $form_values['mm_config_status']) { $status = 'disabled'; } - elseif ($form_values['mm_config_status_value'] == 'disabled' ) { $status = 'enabled'; } - else {$status = $form_values['mm_config_status_value']; } + if (! $form_state['values']['mm_config_status']) { $status = 'disabled'; } + elseif ($form_state['values']['mm_config_status_value'] == 'disabled' ) { $status = 'enabled'; } + else {$status = $form_state['values']['mm_config_status_value']; } // get the settings values - $settings = media_mover_api_configuration_get_settings($form_values); + $settings = media_mover_api_configuration_get_settings($form_state['values']); // update the name and description - media_mover_api_configlist_config_update($form_values['cid'], $form_values['mm_config_name'], $form_values['mm_config_descript'], $settings, $status); + media_mover_api_configlist_config_update($form_state['values']['cid'], $form_state['values']['mm_config_name'], $form_state['values']['mm_config_descript'], $settings, $status); $verbs = media_mover_api_verbs(); foreach ($verbs as $verb) { - foreach ($form_values as $key => $value) { - // $key is in format $verb--$module--$action_id--$element + foreach ($form_state['values'] as $key => $value) { + // $key is in format $verb--$module--$action_id--$element $items = explode('--', $key); if ($items[0] == $verb) { $update[$verb] = array( 'module' => $items[1], 'action' => $items[2], - 'configuration' => media_mover_api_config_edit_form_serialize($form_values, $items[1] .'--'. $items[2] .'--', $form_values['cid']), + 'configuration' => media_mover_api_config_edit_form_serialize($form_state['values'], $items[1] .'--'. $items[2] .'--', $form_state['values']['cid']), ); } } @@ -2304,11 +2289,11 @@ // we match on verb and cid to allow for null values to // remove existing configurations foreach ($verbs as $verb) { - media_mover_api_configuration_verb_update($form_values['cid'], $verb, $update[$verb]['configuration'] ? $update[$verb]['configuration'] : serialize(array("cid" => $form_values['cid'])) ); + media_mover_api_configuration_verb_update($form_state['values']['cid'], $verb, $update[$verb]['configuration'] ? $update[$verb]['configuration'] : serialize(array("cid" => $form_state['values']['cid'])) ); } - drupal_set_message(t('Media mover configuration %config_name updated.', array('%config_name' => $form_values['mm_config_name']))); - return 'admin/media_mover/config/'. $form_values['cid']; + drupal_set_message(t('Media mover configuration %config_name updated.', array('%config_name' => $form_state['values']['mm_config_name']))); + return 'admin/media_mover/config/'. $form_state['values']['cid']; } @@ -2317,15 +2302,16 @@ * adding and editing a form. calls the validate hook on each of * the modules that are in this configuration * - * @param array $form_values + * @param array $form + * @param array $form_state * @param boolean $add * controls if we are editing or adding a new form */ -function media_mover_api_config_form_validate($form_values, $add = false) { +function media_mover_api_config_form_validate($form, &$form_state, $add = false) { // first get all the config data out of the form array foreach (media_mover_api_verbs() as $verb) { // get all the config data back for this item - $config = media_mover_api_collect_form_data($verb, $form_values); + $config = media_mover_api_collect_form_data($verb, $form_state['values']); // now pass this back to the module functions for validation if ( $all_errors[$verb] = module_invoke($config['module'], 'media_mover', 'config_validate', $config['action'], $config['configuration'])) { @@ -2342,13 +2328,13 @@ if ($all_errors) { // now loop through and build out the form elements foreach ($all_errors as $verb => $errors) { - if ($errors) { - foreach ($errors as $error) { - // build the id in form {$verb}--{$module}--{$action}--{$element} - $id = $verb .'--'. $error['module'] .'--'. $error['action'] .'--'. $error['element']; - form_set_error($id, $error['message']); - } - } + if ($errors) { + foreach ($errors as $error) { + // build the id in form {$verb}--{$module}--{$action}--{$element} + $id = $verb .'--'. $error['module'] .'--'. $error['action'] .'--'. $error['element']; + form_set_error($id, $error['message']); + } + } } } } @@ -2360,7 +2346,7 @@ * @param $cid is a configuration id * @return array drupal form */ -function media_mover_api_config_stop_confirm($cid) { +function media_mover_api_config_stop_confirm($form_state, $cid) { $config = media_mover_api_get_configuration($cid); $form['markup'] = array( '#type' => 'markup', @@ -2392,10 +2378,10 @@ * @param array $form_values * */ -function media_mover_api_config_stop_confirm_submit($form_id, $form_values) { - db_query('UPDATE {media_mover_config_list} SET status = "%s" WHERE cid = %d', MMA_CONFIG_STATUS_STOPPED, $form_values['cid']); +function media_mover_api_config_stop_confirm_submit($form, &$form_state) { + db_query('UPDATE {media_mover_config_list} SET status = "%s" WHERE cid = %d', MMA_CONFIG_STATUS_STOPPED, $form['cid']['#value']); drupal_set_message('Stopped the configuration.'); - return 'admin/media_mover'; + $form_state['redirect'] = 'admin/media_mover/config/'. $form['cid']['#value'] .'/view'; } @@ -2418,7 +2404,7 @@ '%current' => $config->status, '%new' => $status, )), - 'admin/media_mover/config/'. $cid. '/view', + 'admin/media_mover/config/'. $cid, t('This action cannot be undone.'), t('Change status'), t('Cancel') @@ -2435,7 +2421,7 @@ function media_mover_api_config_status_change_confirm_submit($form_id, $form_values) { db_query('UPDATE {media_mover_config_list} SET status = "%s" WHERE cid = %d', $form_values['status'], $form_values['cid']); drupal_set_message('The configuration\'s status has been updated.'); - return 'admin/media_mover/config/'. $form_values['cid'] .'/view'; + return 'admin/media_mover/config/'. $form_values['cid']; } @@ -2599,9 +2585,9 @@ * @return int */ function media_mover_api_configuration_files_count($cid, $in_process = false) { - if ($in_process) { - $status = ' AND status != -1 AND status != '. MMA_FILE_STATUS_COMPLETE_COMPLETE; - } + if ($in_process) { + $status = ' AND status != -1 AND status != '. MMA_FILE_STATUS_COMPLETE_COMPLETE; + } $count = db_result(db_query('SELECT COUNT(mmfid) FROM {media_mover_files} WHERE cid = %d '. $status, $cid)); return $count; } @@ -2650,7 +2636,7 @@ ); // set up the db order - if (! $_GET['sort']) { $order = 'ORDER BY date DESC';} + if (! $_GET['sort']) { $order = ' ORDER BY date DESC';} else { $order = tablesort_sql($header); } if ($status) { @@ -2677,7 +2663,7 @@ $configuration = media_mover_api_get_configuration($file['cid']); $row[] = array( $file['mmfid'], - l($configuration->name, 'admin/media_mover/config/edit/'. $file['cid']) .'
'. $node, + l($configuration->name, 'admin/media_mover/config/edit/'. $file['cid']) .'
'. $node , media_mover_api_item_status($file['status']), $file['harvest_file'], l(t('Edit ') . $file['mmfid'], 'admin/media_mover/file/edit/'. $file['mmfid']), @@ -2791,24 +2777,25 @@ * @param int $mmfid is a media mover file id * @return array drupal form array */ -function media_mover_api_edit_file_form($mmfid) { - // set the title +function media_mover_api_edit_file_form($form_state, $mmfid) { + // set the title drupal_set_title(t('Media Mover Edit File %id', array('%id'=> $mmfid))); // load the item $item = media_mover_api_file_get($mmfid); // if the file isn't finished set an alert + // @TODO fix this so that this doesn't check on form submit if ($item['status'] != 8) { drupal_set_message(t('This item has not been finished by Media Mover. It is currently in status: !status', array('!status' => media_mover_api_item_status($item['status']))), 'error' ); } - + // get the configuration $configuration = media_mover_api_get_configuration($item['cid']); // get each of the actions for this configuration foreach (media_mover_api_verbs() as $verb) { - $rows[] = array( + $rows[] = array( t('Verb: %name', array('%name' => $verb)), t('Action: %name', array('%name' => media_mover_api_action_name($configuration->{$verb}->module, $verb, $configuration->{$verb}->action)) ), ); @@ -2842,7 +2829,7 @@ '#title' => "Node ID", '#type' => 'textfield', '#default_value' => $item['nid'], - '#description' => t('Sets the status that the file is in. Should be Finished unless the file is stuck or actively being processed.'), + '#description' => t('File is associated with this Node ID. You can assocate a Media Mover file with one NID'), ); $options = media_mover_api_item_status(); @@ -2870,22 +2857,22 @@ /** * implementation of hook form_submit * nid, url, status, fid are incoming vars - * @param string $form_id - * @param array $form_values + * @param array $form + * @param array $form_state * */ -function media_mover_api_edit_file_form_submit($form_id, $form_values) { - switch ($form_values['op']) { +function media_mover_api_edit_file_form_submit($form, &$form_state) { + switch ($form_state['values']['op']) { case t('Save'): - db_query("UPDATE {media_mover_files} SET nid = %d, status = %d, url = '%s' WHERE mmfid = %d", $form_values['nid'], $form_values['status'], $form_values['url'], $form_values['mmfid']); - drupal_set_message(t('Media mover file ID: !id was updated.', array('!id' => $form_values['mmfid']))); - return "admin/media_mover/files"; - break; + db_query("UPDATE {media_mover_files} SET nid = %d, status = %d WHERE mmfid = %d", $form_state['values']['nid'], $form_state['values']['status'], $form_state['values']['mmfid']); + drupal_set_message(t('Media mover file ID: !id was updated.', array('!id' => $form_state['values']['mmfid']))); + $form_state['redirect'] = "admin/media_mover/files"; + break; case t('Delete'): // redirect to the delete confirm - drupal_goto('admin/media_mover/file/delete/'. $form_values['mmfid']); - break; - } + $form_state['redirect'] = 'admin/media_mover/file/delete/'. $form_state['values']['mmfid']; + break; + } } @@ -2894,7 +2881,7 @@ * @param int $mmfid is a media mover field id * @return array drupal confirm */ -function media_mover_api_file_delete_confirm_form($mmfid) { +function media_mover_api_file_delete_confirm_form($form_state, $mmfid) { $form['display_data'] = array( '#type' => 'markup', '#value' => t('You are about to delete file id#: %fid', array('%fid' => $mmfid)), @@ -2919,9 +2906,9 @@ * @param array $form_values is drupal form array * @ */ -function media_mover_api_file_delete_confirm_form_submit($form_id, $form_values) { +function media_mover_api_file_delete_confirm_form_submit($form, &$form_state) { // get the file - $file = media_mover_api_file_get($form_values['mmfid']); + $file = media_mover_api_file_get($form['mmfid']['#value']); // get the configuration that this file was created from $configuration = media_mover_api_get_configuration($file['cid']); @@ -2934,9 +2921,9 @@ cache_clear_all('media_mover_files_node_'. $file['nid'], 'cache_media_mover'); } // now delete the file from the db - db_query('DELETE FROM {media_mover_files} WHERE mmfid = %d', $form_values['mmfid']); + db_query('DELETE FROM {media_mover_files} WHERE mmfid = %d', $form['mmfid']['#value']); drupal_set_message(t('Deleted the file.')); - return "admin/media_mover/files"; + $form_state['redirect'] = 'admin/media_mover/files'; } @@ -3197,7 +3184,7 @@ case 'return': // get files for the running configuration - if ($mmfiles = $node->media_mover[$config]) { + if ($mmfiles = $node->media_mover[$config]) { $items = array(); foreach($mmfiles as $mmfile) { $filepath = $mmfile['complete_file']; Common subdirectories: /var/www/media_mover/media_mover_email and ../mm_d6/media_mover_email Common subdirectories: /var/www/media_mover/media_mover_ftp and ../mm_d6/media_mover_ftp Common subdirectories: /var/www/media_mover/mm_content and ../mm_d6/mm_content Common subdirectories: /var/www/media_mover/mm_ffmpeg and ../mm_d6/mm_ffmpeg Common subdirectories: /var/www/media_mover/mm_node and ../mm_d6/mm_node Common subdirectories: /var/www/media_mover/mm_s3 and ../mm_d6/mm_s3 Common subdirectories: /var/www/media_mover/tests and ../mm_d6/tests