? changes ? plugin_manager-D7.patch Index: ftp.backend.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/plugin_manager/ftp.backend.inc,v retrieving revision 1.3.2.19 diff -u -p -r1.3.2.19 ftp.backend.inc --- ftp.backend.inc 15 Nov 2008 20:49:55 -0000 1.3.2.19 +++ ftp.backend.inc 23 Nov 2008 19:24:02 -0000 @@ -26,19 +26,6 @@ function ftp_plugin_manager_settings() { } /** - * Implementation of user hook plugin_manager_backend. Checks - * if the requirements for the ftp backend are enabled. - * - * @return - * Return 'ftp' if the requirements are available. - */ -function ftp_plugin_manager_backend() { - if (function_exists('ftp_connect') OR ini_get('allow_url_fopen')) { - return 'ftp'; - } -} - -/** * Install the supplied files to the appropriate locations. * * @param $files Index: plugin_manager.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/plugin_manager/plugin_manager.admin.inc,v retrieving revision 1.52.2.58 diff -u -p -r1.52.2.58 plugin_manager.admin.inc --- plugin_manager.admin.inc 20 Nov 2008 23:44:22 -0000 1.52.2.58 +++ plugin_manager.admin.inc 23 Nov 2008 19:24:03 -0000 @@ -52,15 +52,10 @@ function plugin_manager_find($form_state '#type' => 'select', '#options' => array('None' => 'Categories:'), ); - $result = db_query( - "SELECT tag - FROM {plugin_manager_taxonomy} - WHERE tag NOT IN('Modules', 'Translations', 'Themes') - GROUP BY tag - ORDER BY tag" - ); - while ($row = db_fetch_array($result)) { - $form['browse_box']['category']['#options'][$row['tag']] = $row['tag']; + + $result = db_query("SELECT tag FROM {plugin_manager_taxonomy} WHERE tag NOT IN('Modules', 'Translations', 'Themes') GROUP BY tag ORDER BY tag"); + foreach ($result as $record) { + $form['browse_box']['category']['#options'][$record->tag] = $record->tag; } $form[] = array( '#type' => 'submit', @@ -79,14 +74,12 @@ function plugin_manager_find($form_state '#collapsed' => TRUE, ); foreach ($queue AS $item) { - $result = db_fetch_array(db_query( - "SELECT title - FROM {plugin_manager_repository} - WHERE short_name = '%s'", $item)); + $title = db_query("SELECT title FROM {plugin_manager_repository} WHERE short_name = :short_name", array(':short_name' => $item))->fetchField(); + $form['queue_box']['plugin_'. $item] = array( '#type' => 'checkbox', '#name' => 'plugin_'. $item, - '#title' => htmlentities($result['title']), + '#title' => check_plain($title), '#default_value' => TRUE, ); } @@ -107,45 +100,46 @@ function plugin_manager_find($form_state // Build the where clause. $where = array('1'); - $terms = array(); + $args = array(); // If the search string is non-empty, then add it to our where clause. if (!empty($form_state['storage']['search'])) { - $where[] = "title LIKE '%%%s%%'"; - $terms[] = $form_state['storage']['search']; + $where[] = "title LIKE :title"; + $args[':title'] = $form_state['storage']['search']; } // See if a filter has been selected. if ($form_state['storage']['filter'] != 'None') { - $where[] = "tag = '%s'"; - $terms[] = $form_state['storage']['filter']; + $where[] = "tag = :tag"; + $args[':tag'] = $form_state['storage']['filter']; } elseif ($form_state['storage']['category'] != 'None') { - $where[] = "tag = '%s'"; - $terms[] = $form_state['storage']['category']; + $where[] = "tag = :tag"; + $args[':tag'] = $form_state['storage']['category']; } $where = implode(' AND ', $where); // Get a list of the non-installed plugins from the category. + // @todo DBTNG this $result = db_query( "SELECT title, pmr.short_name AS short_name FROM {plugin_manager_repository} pmr LEFT JOIN {plugin_manager_taxonomy} pmt - ON(pmt.short_name = pmr.short_name) + ON (pmt.short_name = pmr.short_name) WHERE $where - ORDER BY title", $terms[0], $terms[1] + ORDER BY title", $args ); $files = module_rebuild_cache(); - while ($row = db_fetch_array($result)) { - if (isset($files[$row['short_name']]))continue; - $form['result_box']['plugin_'. $row['short_name']] = array( + foreach ($result as $record) { + if (isset($files[$record->short_name])) continue; + $form['result_box']['plugin_'. $record->short_name] = array( '#type' => 'checkbox', - '#name' => 'plugin_'. $row['short_name'], - '#title' => htmlentities($row['title']), - '#default_value' => isset($queue[$row['short_name']]), + '#name' => 'plugin_'. $record->short_name, + '#title' => check_plain($record->title), + '#default_value' => isset($queue[$record->short_name]), ); } } @@ -193,12 +187,12 @@ function plugin_manager_find_submit($for } function plugin_manager_modules_redirect() { - drupal_set_message("Search for the modules you want to install, add them to your queue, and then install them."); + drupal_set_message(t("Search for the modules you want to install, add them to your queue, and then install them.")); drupal_goto('admin/plugin_manager/search'); } function plugin_manager_themes_redirect() { - drupal_set_message("Search for the themes you want to install, add them to your queue, and then install them."); + drupal_set_message(t("Search for the themes you want to install, add them to your queue, and then install them.")); drupal_goto('admin/plugin_manager/search'); } @@ -268,24 +262,24 @@ function plugin_manager_manual_submit($f // Then finally install it. $files = plugin_manager_untar($file->filepath); - //plugin_manager_ftp_copy($extracted, $type, $host, $user, $pass); // Copy the extracted files - $copy = call_user_func_array($backend .'_plugin_manager_copy', - array($files, $type, $host, - $user, $pass)); + if (drupal_function_exists($backend .'_plugin_manager_remove')) { + $copy = call_user_func_array($backend .'_plugin_manager_copy', + array($files, $type, $host, + $user, $pass)); + } // If it failed, stop now. if (!$copy) { - drupal_set_message(t("Unable to install ") . $name, 'error'); + drupal_set_message(t("Unable to install @name", array("@name" => $name)), 'error'); return; } foreach (array_reverse($files) AS $file) { // Mark files as installed if ($copy) { - db_query("INSERT INTO {plugin_manager_files} VALUES('%s', '%s')", - $name, $type .'/'. $file); + db_insert('plugin_manager_files')->fields(array('short_name' => $name, 'file_path' => $type .'/'. $file))->execute(); } // Remove the extracted files. @@ -298,7 +292,7 @@ function plugin_manager_manual_submit($f } } - drupal_set_message(t("Successfully installed plugin.") . l(t('Go Here'), 'admin/build/'. strtolower($type)) . t(' to enable it.')); + drupal_set_message(t("Successfully installed plugin.") . l(t('Go Here to enable it'), 'admin/build/'. strtolower($type))); } @@ -401,7 +395,7 @@ function plugin_manager_page_3($form_sta function plugin_manager_page_4($form_state) { update_get_available(TRUE); // refresh the update database $form[] = array( - '#value' => t("Now you're done. Unless it is stated otherwise above, your modules and/or themes should be properly installed now. So what should you do now? ") .'

'. l(t("If you installed new modules, you can enable them here."), 'admin/build/modules') .'

'. l(t('If you installed new themes, you can select them here.'), 'admin/build/themes') .'

', + '#markup' => t("Now you're done. Unless it is stated otherwise above, your modules and/or themes should be properly installed now. So what should you do now? ") .'

'. l(t("If you installed new modules, you can enable them here."), 'admin/build/modules') .'

'. l(t('If you installed new themes, you can select them here.'), 'admin/build/themes') .'

', ); return $form; } @@ -423,7 +417,7 @@ function plugin_manager_install_form($fo // If there aren't any, then just tell the just that. And quit. $queue = variable_get("plugin_manager_queue", array()); if (empty($queue)) { - drupal_set_message("Nothing has been selected to install. ".l("Search for modules to install","admin/plugin_manager/search")); + drupal_set_message(t("Nothing has been selected to install. !search", array("!search", l("Search for modules to install","admin/plugin_manager/search")))); return array(); } @@ -504,7 +498,7 @@ function plugin_manager_install_2($form, foreach ($files AS $name => $file) { $md5 = $form_state['storage'][2][$name .'_md5sum']; if (md5_file($file) != $md5) { - drupal_set_message(t('The md5sum is incorrect for ') . $plugin['title'], 'error'); + drupal_set_message(t('The md5sum is incorrect for @plugin', array('@plugin' => $plugin['title'])), 'error'); $form_state['storage']['page'] = 2; return; } @@ -537,46 +531,40 @@ function plugin_manager_install_3($form, $files = plugin_manager_untar($plugin); // Find out whether the thing is a module or theme. - $row = db_fetch_array( - db_query( - "SELECT lower(tag) AS tag - FROM {plugin_manager_taxonomy} - WHERE short_name = '%s' - AND tag IN('Modules', 'Themes')", $name - ) - ); + $tag = db_query("SELECT lower(tag) AS tag FROM {plugin_manager_taxonomy} WHERE short_name = :short_name AND tag IN ('Modules', 'Themes')", array(':short_name' => $name))->fetchField(); // Copy the extracted files - $copy = call_user_func_array($backend .'_plugin_manager_copy', - array($files, $row['tag'], $form_state['values']['host'], - $form_state['values']['username'], $form_state['values']['password'])); - - foreach (array_reverse($files) AS $file) { - // Mark files as installed - if ($copy) { - db_query("INSERT INTO {plugin_manager_files} VALUES('%s', '%s')", - $name, $row['tag'] .'/'. $file); - } - - // Remove the extracted files. - $file = file_directory_path() .'/plugin_manager_extraction/'. $file; - if (is_dir($file)) { - rmdir($file); - } - else { - unlink($file); + if (drupal_function_exists($backend .'_plugin_manager_copy')) { + $copy = call_user_func_array($backend .'_plugin_manager_copy', + array($files, $tag, $form_state['values']['host'], + $form_state['values']['username'], $form_state['values']['password'])); + + foreach (array_reverse($files) AS $file) { + // Mark files as installed + if ($copy) { + db_insert('plugin_manager_files')->fields(array('short_name' => $name, 'file_path' => $tag . '/' . $file))->execute(); + } + + // Remove the extracted files. + $file = file_directory_path() .'/plugin_manager_extraction/'. $file; + if (is_dir($file)) { + rmdir($file); + } + else { + unlink($file); + } } } // If it failed, stop now. if (!$copy) { - drupal_set_message(t("Unable to install ") . $name, 'error'); + drupal_set_message(t("Unable to install @name", array('@name' => $name)), 'error'); return; } drupal_set_message(t("Successfully installed @name.", array('@name' => $name))); // rebuild caches - drupal_rebuild_theme_registry(); + drupal_theme_rebuild(); node_types_rebuild(); menu_rebuild(); cache_clear_all('schema', 'cache'); @@ -614,56 +602,63 @@ function plugin_manager_install_form_sub function plugin_manager_uninstall_form($form_state) { // Get a list of the non-installed plugins. - $result = db_query( - "SELECT filename,name,type - FROM {system} - WHERE status = 0 - ORDER BY type" - ); - while ($row = db_fetch_array($result)) { - if (strpos($row['filename'],'sites/all/'.$row['type'].'s/'.$row['name'])!==0 || !file_exists($row['filename']))continue; - $info_file = join('.',array_slice(explode('.',$row['filename']),0,-1)).'.info'; + $result = db_query("SELECT filename,name,type FROM {system} WHERE status = 0 ORDER BY type"); + + $form = array(); + + $count = 0; + foreach ($result as $record) { + if (strpos($record->filename, 'sites/all/' . $record->type . 's/' . $record->name) !== 0 || !file_exists($record->filename)) continue; + $info_file = join('.', array_slice(explode('.', $record->filename),0,-1)) . '.info'; $info = drupal_parse_info_file($info_file); - if (!$info['name'])$info['name'] = $row['name']; - if (!$form[$row['type']]){ - $form[$row['type']] = array( + if (!$info['name']) $info['name'] = $record->name; + if (!isset($form[$record->type])) { + $form[$record->type] = array( '#type' => 'fieldset', - '#title' => htmlentities('Disabled '.ucwords($row['type']).'s'), + '#title' => t('Disabled @types', array('@type' => ucwords($record->type))), '#collapsible' => FALSE, '#collapsed' => FALSE, - ); + ); } - $form[$row['type']][$row['name']] = array( + $form[$record->type][$record->name] = array( '#type' => 'checkbox', - '#name' => $row['name'], - '#title' => htmlentities($info['name']), + '#name' => $record->name, + '#title' => check_plain($info['name']), ); + $count ++; + } + + if ($count > 0) { + $form['backend'] = array( + '#title' => t('Removal method'), + '#type' => 'select', + '#options' => plugin_manager_backends(), + ); + $form['host'] = array( + '#title' => t('Hostname'), + '#type' => 'textfield', + '#default_value' => variable_get('plugin_manager_hostname', 'localhost'), + ); + $form['username'] = array( + '#type' => 'textfield', + '#title' => t('Username'), + '#default_value' => variable_get('plugin_manager_username', ''), + ); + $form['password'] = array( + '#type' => 'password', + '#title' => t('Password'), + '#default_value' => '', + ); + $form[] = array( + '#type' => 'submit', + '#value' => t('Uninstall'), + ); + return $form; + } + else { + drupal_set_message(t('No modules found to uninstall.')); + return array(); } - $form['backend'] = array( - '#title' => t('Removal method'), - '#type' => 'select', - '#options' => plugin_manager_backends(), - ); - $form['host'] = array( - '#title' => t('Hostname'), - '#type' => 'textfield', - '#default_value' => variable_get('plugin_manager_hostname', 'localhost'), - ); - $form['username'] = array( - '#type' => 'textfield', - '#title' => t('Username'), - '#default_value' => variable_get('plugin_manager_username', ''), - ); - $form['password'] = array( - '#type' => 'password', - '#title' => t('Password'), - '#default_value' => '', - ); - $form[] = array( - '#type' => 'submit', - '#value' => t('Uninstall'), - ); - return $form; } /** @@ -681,28 +676,25 @@ function plugin_manager_uninstall_form_s } // Get the files to remove. - /*$result = db_query( - "SELECT file_path - FROM {plugin_manager_files} - WHERE short_name = '%s' - ORDER BY file_path DESC", $plugin - );*/ - $row = db_fetch_array(db_query( - "SELECT filename, name, type - FROM {system} - WHERE name='%s'",array($plugin))); - if (strpos($row['filename'],'sites/all/'.$row['type'].'s/'.$row['name'].'/')!==0 || !file_exists($row['filename'])){ - drupal_set_message("Illegal Uninstall. Please report this bug."); + $record = db_query("SELECT filename, name, type FROM {system} WHERE name = :name", array(':name' => $plugin))->fetch(); + + if (strpos($record->filename, 'sites/all/' . $record->type . 's/' . $record->name . '/') !== 0 || !file_exists($record->filename)){ + drupal_set_message(t("Illegal Uninstall. Please report this bug.")); return; } + // Remove the files / folders requested. - $remove = call_user_func_array($backend .'_plugin_manager_remove', - array('sites/all/'.$row['type'].'s/'.$row['name'], $form_state['values']['host'], - $form_state['values']['username'], $form_state['values']['password'])); + if (drupal_function_exists($backend .'_plugin_manager_remove')) { + $remove = call_user_func_array($backend .'_plugin_manager_remove', + array('sites/all/' . $record->type . 's/' . $record->name, $form_state['values']['host'], + $form_state['values']['username'], $form_state['values']['password'])); + db_delete('plugin_manager_files')->condition('short_name', $record->name)->execute(); + } + if ($remove){ - drupal_set_message("Successfully uninstalled $plugin."); + drupal_set_message(t("Successfully uninstalled @plugin.", array('@plugin' => $plugin))); }else - drupal_set_message("Unable to uninstall $plugin.",'error'); + drupal_set_message(t("Unable to uninstall @plugin.", array('@plugin', $plugin)), 'error'); } } @@ -720,16 +712,17 @@ function plugin_manager_update_form() { $some = FALSE; foreach ($projects as $name => $project) { if ($project['status'] == UPDATE_NOT_CURRENT) { - $some=TRUE; + $some = TRUE; $form[$name] = array( '#type' => 'checkbox', '#title' => $project['title'], '#default_value' => 'true' ); } - }//} - if (!$some) - drupal_set_message("There are no available updates for your drupal installation."); + } + if (!$some) { + drupal_set_message(t("There are no available updates for your drupal installation.")); + } $form['submit'] = array( '#type' => 'submit', '#value' => 'Install Updates' @@ -745,26 +738,12 @@ function plugin_manager_update_form_subm } } if ($queue) { - drupal_set_message("Queue: ". join(", ", $queue)); + drupal_set_message(t("Queue: @queue", array('@queue' => join(", ", $queue)))); variable_set("plugin_manager_queue", $queue); drupal_goto("admin/plugin_manager/install"); } } -/** - * Alert the user to outdated plugins, and give them an opporunity to - * automatically update them. - * @alters the system_modules and system_themes pages (admin/modules | themes) - */ -function plugin_manager_form_alter(&$form, $form_state, $form_id) { - if ($form_id == 'system_modules' || $form_id == 'system_themes' ) { - $reqs = update_requirements('runtime'); - if (isset($reqs['update_contrib']['reason'])) { - drupal_set_message('It looks like you have some outdated modules. '. l('Go Here', 'admin/plugin_manager/update') .' to update your site automatically.'); - } - } -} - /** Plugin Manager Search Section **/ /** @@ -788,16 +767,10 @@ function plugin_manager_search() { $html .= ""; $html .= "
BrowseBy Category:
"; $html .= "Alphabetical: "; @@ -819,7 +792,7 @@ function plugin_manager_search() { function plugin_manager_search_form() { $queue = variable_get("plugin_manager_queue",array()); foreach($queue as $name=>$value){ - $form[$name] = array('#type'=>'hidden','#value'=>'true'); + $form[$name] = array('#type'=>'hidden','#value'=>'true'); } $form['submit'] = array('#type' => 'submit', '#value' => 'Install Queued Plugins'); return $form; @@ -828,12 +801,12 @@ function plugin_manager_search_form() { function plugin_manager_search_form_submit($form, &$form_state) { $queue = array(); foreach ($form['#post'] AS $name => $value) { - if ($value=='true') { + if ($value == 'true') { $queue[$name] = $name; } } if ($queue) { - drupal_set_message("Queue: ". join(", ", $queue)); + drupal_set_message(t("Queue: @queue", array('@queue' => join(", ", $queue)))); variable_set("plugin_manager_queue", $queue); drupal_goto("admin/plugin_manager/install"); } @@ -841,28 +814,20 @@ function plugin_manager_search_form_subm function plugin_manager_search_ajax_callback(){ - $result = db_query( - "SELECT title, short_name - FROM {plugin_manager_repository} - ORDER BY title" - ); + $result = db_query("SELECT title, short_name FROM {plugin_manager_repository} ORDER BY title"); $files = module_rebuild_cache(); - while ($row = db_fetch_array($result)) { - if (isset($files[$row['short_name']]))continue; - $tags_res = db_query( - "SELECT pmt.tag AS tag - FROM {plugin_manager_taxonomy} pmt - WHERE pmt.short_name='%s' - ORDER BY tag", array($row['short_name']) - ); + foreach ($result as $record) { + if (isset($files[$record->short_name])) continue; + + $tags_result = db_query("SELECT pmt.tag AS tag FROM {plugin_manager_taxonomy} pmt WHERE pmt.short_name = :short_name ORDER BY tag", array(':short_name' => $record->short_name)); $tags = array(); - while ($tag = db_fetch_array($tags_res)) { - $tags[] = $tag['tag']; + foreach ($tags_result as $tag_record) { + $tags[] = $tag_record->tag; } - echo $row['short_name'].":".$row['title'] .":". join(' | ', $tags)."\n"; + echo $record->short_name . ":" . $record->title . ":" . join(' | ', $tags)."\n"; } exit(0); } @@ -878,7 +843,6 @@ function plugin_manager_settings_form() $form = array(); - $form['plugin_manager_username'] = array( '#title' => t('Stored Username'), '#type' => 'textfield', @@ -905,7 +869,7 @@ function plugin_manager_settings_form() '#collapsible' => TRUE, '#collapsed' => FALSE, ); - if (function_exists($backend .'_plugin_manager_settings')) { + if (drupal_function_exists($backend .'_plugin_manager_settings')) { $form[$backend][] = call_user_func($backend .'_plugin_manager_settings'); } else { Index: plugin_manager.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/plugin_manager/plugin_manager.info,v retrieving revision 1.2.2.5 diff -u -p -r1.2.2.5 plugin_manager.info --- plugin_manager.info 23 Sep 2008 02:25:53 -0000 1.2.2.5 +++ plugin_manager.info 23 Nov 2008 19:24:03 -0000 @@ -1,6 +1,13 @@ ; $Id: plugin_manager.info,v 1.2.2.5 2008/09/23 02:25:53 jabapyth Exp $ name = Plugin Manager description = Enables the automated installation of modules and themes from drupal.org -core = 6.x +core = 7.x php = 5 +version = VERSION package = Administration +dependencies[] = update +files[] = plugin_manager.module +files[] = plugin_manager.install +files[] = plugin_manager.admin.inc +files[] = ftp.backend.inc +files[] = ssh.backend.inc \ No newline at end of file Index: plugin_manager.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/plugin_manager/plugin_manager.install,v retrieving revision 1.13.2.8 diff -u -p -r1.13.2.8 plugin_manager.install --- plugin_manager.install 8 Oct 2008 03:03:00 -0000 1.13.2.8 +++ plugin_manager.install 23 Nov 2008 19:24:03 -0000 @@ -99,12 +99,11 @@ function plugin_manager_uninstall() { drupal_uninstall_schema('plugin_manager'); // Remove the variables that have been set with time. - $result = db_query("SELECT name FROM {variable} WHERE name LIKE 'plugin_manager%%'"); - while ($row = db_fetch_array($result)) { - variable_del($row['name']); - } + // @todo test this query + db_delete('variable')->condition('name', 'plugin_manager%', 'LIKE')->execute(); + cache_clear_all('variables', 'cache'); - // Remove the files and folders craeted by the plugin_manager. + // Remove the files and folders created by the plugin_manager. plugin_manager_delete(file_directory_path() .'/plugin_manager_extraction/'); plugin_manager_delete(file_directory_path() .'/plugin_manager_cache/'); } Index: plugin_manager.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/plugin_manager/plugin_manager.module,v retrieving revision 1.51.2.35 diff -u -p -r1.51.2.35 plugin_manager.module --- plugin_manager.module 20 Nov 2008 03:06:23 -0000 1.51.2.35 +++ plugin_manager.module 23 Nov 2008 19:24:03 -0000 @@ -19,7 +19,6 @@ function plugin_manager_menu() { 'page callback' => 'drupal_get_form', 'page arguments' => array('plugin_manager_find'), 'access arguments' => array('access plugin manager'), - 'file' => 'plugin_manager.admin.inc', 'position' => 'right', 'weight' => -7, ); @@ -28,7 +27,6 @@ function plugin_manager_menu() { 'description' => 'Search for new themes and modules to queue for installation.', 'page callback' => 'plugin_manager_search', 'access arguments' => array('install plugins'), - 'file' => 'plugin_manager.admin.inc', 'block callback' => 'system_admin_theme_settings', ); $items['admin/plugin_manager/search/ajax'] = array( @@ -36,7 +34,6 @@ function plugin_manager_menu() { 'description' => 'AJAX callback.', 'page callback' => 'plugin_manager_search_ajax_callback', 'access arguments' => array('install plugins'), - 'file' => 'plugin_manager.admin.inc', 'type' => MENU_CALLBACK, ); $items['admin/plugin_manager/install'] = array( @@ -45,7 +42,6 @@ function plugin_manager_menu() { 'page callback' => 'drupal_get_form', 'page arguments' => array('plugin_manager_install_form'), 'access arguments' => array('install plugins'), - 'file' => 'plugin_manager.admin.inc', 'block callback' => 'system_admin_theme_settings', ); $items['admin/plugin_manager/find'] = array( @@ -54,7 +50,6 @@ function plugin_manager_menu() { 'page callback' => 'drupal_get_form', 'page arguments' => array('plugin_manager_find'), 'access arguments' => array('install plugins'), - 'file' => 'plugin_manager.admin.inc', 'block callback' => 'system_admin_theme_settings', ); $items['admin/plugin_manager/settings'] = array( @@ -63,7 +58,6 @@ function plugin_manager_menu() { 'page callback' => 'drupal_get_form', 'page arguments' => array('plugin_manager_settings_form'), 'access arguments' => array('plugin manager settings'), - 'file' => 'plugin_manager.admin.inc', 'block callback' => 'system_admin_theme_settings', ); $items['admin/plugin_manager/uninstall'] = array( @@ -72,7 +66,6 @@ function plugin_manager_menu() { 'page callback' => 'drupal_get_form', 'page arguments' => array('plugin_manager_uninstall_form'), 'access arguments' => array('uninstall plugins'), - 'file' => 'plugin_manager.admin.inc', 'block callback' => 'system_admin_theme_settings', ); $items['admin/plugin_manager/update'] = array( @@ -81,7 +74,6 @@ function plugin_manager_menu() { 'page callback' => 'drupal_get_form', 'page arguments' => array('plugin_manager_update_form'), 'access arguments' => array('install modules'), - 'file' => 'plugin_manager.admin.inc', 'block callback' => 'system_admin_theme_settings', ); $items['admin/plugin_manager/manual'] = array( @@ -89,7 +81,6 @@ function plugin_manager_menu() { 'page callback' => 'drupal_get_form', 'page arguments' => array('plugin_manager_manual'), 'access arguments' => array('manual install plugins'), - 'file' => 'plugin_manager.admin.inc', 'type' => MENU_CALLBACK, ); $items['admin/plugin_manager/reload'] = array( @@ -97,7 +88,6 @@ function plugin_manager_menu() { 'page callback' => 'drupal_get_form', 'page arguments' => array('plugin_manager_reload'), 'access arguments' => array('install plugins'), - 'file' => 'plugin_manager.admin.inc', 'type' => MENU_CALLBACK, ); $items['admin/build/modules/install'] = array( @@ -105,7 +95,6 @@ function plugin_manager_menu() { 'access arguments' => array('install plugins'), 'page callback' => 'drupal_get_form', 'page arguments' => array('plugin_manager_find'), - 'file' => 'plugin_manager.admin.inc', 'weight' => 9, 'type' => MENU_LOCAL_TASK, ); @@ -114,7 +103,6 @@ function plugin_manager_menu() { 'access arguments' => array('install plugins'), 'page callback' => 'drupal_get_form', 'page arguments' => array('plugin_manager_find'), - 'file' => 'plugin_manager.admin.inc', 'weight' => 9, 'type' => MENU_LOCAL_TASK, ); @@ -142,39 +130,81 @@ function plugin_manager_help($path, $arg * Implementation of hook_perm(). */ function plugin_manager_perm() { - return array('access plugin manager','manual install plugins', 'install plugins', 'plugin manager settings', 'uninstall plugins'); + return array( + 'access plugin manager' => array( + 'title' => t('Access plugin manager'), + 'description' => t('Description access plugin manager.'), + ), + 'manual install plugins' => array( + 'title' => t('Manual Install plugins'), + 'description' => t('Description manual install plugins.'), + ), + 'install plugins' => array( + 'title' => t('Install plugins'), + 'description' => t('Description install plugins.'), + ), + 'plugin manager settings' => array( + 'title' => t('Plugin manager settings'), + 'description' => t('Description plugin manager settings.'), + ), + 'uninstall plugins' => array( + 'title' => t('Uninstall plugins'), + 'description' => t('Description uninstall plugins.'), + ), + ); +} + +/** + * Implementation of hook_form_alter(). + * + * Alert the user to outdated plugins, and give them an opportunity to + * automatically update them. + * @alters the system_modules and system_themes pages (admin/modules | themes) + */ +function plugin_manager_form_alter(&$form, $form_state, $form_id) { + if ($form_id == 'system_modules' || $form_id == 'system_themes' ) { + include_once DRUPAL_ROOT . '/includes/install.inc'; + $reqs = update_requirements('runtime'); + if (isset($reqs['update_contrib']['reason'])) { + drupal_set_message(t('It looks like you have some outdated modules. !link to update your site automatically.', array('!link' => l('Go Here', 'admin/plugin_manager/update')))); + } + } } /** * Get a list of all available backends that can upload files onto our system. * * @return - * Array containing the names of all available frontends. + * Array containing the names of all available backends. */ function plugin_manager_backends() { - $backend = array(); - // Open that directory to view the contained files / folders - if ($handle = opendir(dirname(__FILE__))) { - // Look through the modules of that folder - while ($current = readdir($handle)) { - // If the file is a backend file then load it. - if (strstr($current, ".backend.inc") == ".backend.inc") { - include_once($current); - // If there is a backend hook, then run it. - $name = str_replace('.backend.inc', '', $current); - if (function_exists($name .'_plugin_manager_backend')) { - $output = call_user_func($name .'_plugin_manager_backend'); - // If the backend is available, note it. - if (!empty($output)) { - $backend[$output] = $output; - } - } - } + $backends = array(); + foreach (module_implements('backend_plugin') as $module) { + if ($data = module_invoke($module, 'backend_plugin')) { + $backends = array_merge($data, $backends); } } + sort($backends); + return $backends; +} + +/** + * Implementation of hook_backend_plugin(). + */ +function plugin_manager_backend_plugin() { + $backends = array(); - sort($backend); - return $backend; + // FTP backend + if (function_exists('ftp_connect') OR ini_get('allow_url_fopen')) { + $backends[] = 'ftp'; + } + + // SSH2 lib backend + if (function_exists('ssh2_connect')) { + $backends[] = 'ssh'; + } + + return $backends; } /** @@ -192,12 +222,11 @@ function plugin_manager_get($path) { // Check the cache and download the file if needed if (!file_exists($local)) { - // $result->data is the actual contents of the downloaded file. This saves it // into a local file, whose path is stored in $local. $local is stored relative // to the drupal installation. $result = drupal_http_request($path); - if ($result->code != 200 OR !file_save_data($result->data, $local)) { + if ($result->code != 200 || !file_save_data($result->data, $local)) { drupal_set_message(t('@remote could not be saved.', array('@remote' => $path)), 'error'); return FALSE; } @@ -264,7 +293,7 @@ function plugin_manager_untar($file) { */ function plugin_manager_reload() { // Download a new copy of the project-list. - $file = drupal_http_request("http://updates.drupal.org/release-history/project-list/all"); + $file = drupal_http_request(UPDATE_DEFAULT_URL . '/project-list/all'); if (isset($file->error)) { drupal_set_message(t($file->error), 'error'); return array(); @@ -277,9 +306,9 @@ function plugin_manager_reload() { } // Clear the current cache. - db_query("DELETE FROM {plugin_manager_repository}"); - db_query("DELETE FROM {plugin_manager_taxonomy}"); - + db_delete('plugin_manager_repository')->execute(); + db_delete('plugin_manager_taxonomy')->execute(); + // Look at each project node. $drupal_version = constant("DRUPAL_CORE_COMPATIBILITY"); foreach ($xml->project AS $project) { @@ -296,15 +325,12 @@ function plugin_manager_reload() { } // Toss it in the database - $short_name = $project->short_name; - db_query("INSERT INTO {plugin_manager_repository} (title, short_name, links) - VALUES('%s', '%s', '%s')", $project->title, $short_name, $project->link); + db_insert('plugin_manager_repository')->fields(array('title' => $project->title, 'short_name' => $project->short_name, 'links' => $project->link))->execute(); // Find the appropriate taxonomy terms. if (isset($project->terms)) { foreach ($project->terms->term AS $term) { - db_query("INSERT INTO {plugin_manager_taxonomy} (short_name, tag) - VALUES('%s', '%s')", $short_name, $term->value); + db_insert('plugin_manager_taxonomy')->fields(array('short_name' => $project->short_name, 'tag' => $term->value))->execute(); } } } @@ -332,7 +358,7 @@ function plugin_manager_get_release_hist // Look up the data for every project requested. foreach ($projects AS $project) { - $file = drupal_http_request("http://updates.drupal.org/release-history/$project/$version"); + $file = drupal_http_request(UPDATE_DEFAULT_URL . "/$project/$version"); $xml = simplexml_load_string($file->data); // If it failed, then quit. Index: ssh.backend.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/plugin_manager/ssh.backend.inc,v retrieving revision 1.3.2.5 diff -u -p -r1.3.2.5 ssh.backend.inc --- ssh.backend.inc 3 Nov 2008 20:40:30 -0000 1.3.2.5 +++ ssh.backend.inc 23 Nov 2008 19:24:03 -0000 @@ -7,19 +7,6 @@ */ /** - * Implementation of user hook plugin_manager_backend. Checks - * if the requirements for the ssh backend are enabled. - * - * @return - * Return 'ssh' if the requirements are available. - */ -function ssh_plugin_manager_backend() { - if (function_exists('ssh2_connect')) { - return 'ssh'; - } -} - -/** * Install the supplied files to the appropriate locations. * * @param $files