? 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 .= "