diff -r 3f2dfdb99be4 -r b2fb50d572c7 plugins/admin/PluginManager.php --- a/plugins/admin/PluginManager.php Tue Apr 08 20:32:30 2008 -0400 +++ b/plugins/admin/PluginManager.php Wed Apr 09 19:27:02 2008 -0400 @@ -255,9 +255,160 @@ } // decide if it's a system plugin $plugin_meta['system plugin'] = in_array($dh, $plugins->system_plugins); + // reset installed variable + $plugin_meta['installed'] = false; + $plugin_meta['status'] = 0; // all checks passed $plugin_list[$dh] = $plugin_meta; } } - echo '
' . print_r($plugin_list, true) . '
'; + // gather info about installed plugins + $q = $db->sql_query('SELECT plugin_filename, plugin_version, plugin_flags FROM ' . table_prefix . 'plugins;'); + if ( !$q ) + $db->_die(); + while ( $row = $db->fetchrow() ) + { + if ( !isset($plugin_list[ $row['plugin_filename'] ]) ) + { + // missing plugin file, don't report (for now) + continue; + } + $filename =& $row['plugin_filename']; + $plugin_list[$filename]['installed'] = true; + $plugin_list[$filename]['status'] = PLUGIN_INSTALLED; + if ( $row['plugin_version'] != $plugin_list[$filename]['version'] ) + { + $plugin_list[$filename]['status'] |= PLUGIN_OUTOFDATE; + $plugin_list[$filename]['version installed'] = $row['plugin_version']; + } + if ( $row['plugin_flags'] & PLUGIN_DISABLED ) + { + $plugin_list[$filename]['status'] |= PLUGIN_DISABLED; + } + } + $db->free_result(); + + // sort it all out by filename + ksort($plugin_list); + + // start printing things out + acp_start_form(); + ?> +
+ + $data ) + { + // print out all plugins + $rowid = ( $rowid == '1' ) ? '2' : '1'; + $plugin_name = ( preg_match('/^[a-z0-9_]+$/', $data['plugin name']) ) ? $lang->get($data['plugin name']) : $data['plugin name']; + $plugin_basics = $lang->get('acppl_lbl_plugin_name', array( + 'plugin' => $plugin_name, + 'author' => $data['author'] + )); + $color = ''; + $buttons = ''; + if ( $data['system plugin'] ) + { + $status = $lang->get('acppl_lbl_status_system'); + } + else if ( $data['installed'] && !( $data['status'] & PLUGIN_DISABLED ) && !( $data['status'] & PLUGIN_OUTOFDATE ) ) + { + // this plugin is all good + $color = '_green'; + $status = $lang->get('acppl_lbl_status_installed'); + $buttons = 'uninstall|disable'; + } + else if ( $data['installed'] && $data['status'] & PLUGIN_OUTOFDATE ) + { + $color = '_red'; + $status = $lang->get('acppl_lbl_status_need_upgrade'); + $buttons = 'uninstall|update'; + } + else if ( $data['installed'] && $data['status'] & PLUGIN_DISABLED ) + { + $color = '_red'; + $status = $lang->get('acppl_lbl_status_disabled'); + $buttons = 'uninstall|enable'; + } + else + { + $color = '_red'; + $status = $lang->get('acppl_lbl_status_uninstalled'); + $buttons = 'install'; + } + $uuid = md5($data['plugin name'] . $data['version'] . $filename); + $desc = ( preg_match('/^[a-z0-9_]+$/', $data['description']) ) ? $lang->get($data['description']) : $data['description']; + $desc = sanitize_html($desc); + + $additional = ''; + + // filename + $additional .= '' . $lang->get('acppl_lbl_filename') . ' ' . "{$filename}
"; + + // plugin's site + $data['plugin uri'] = htmlspecialchars($data['plugin uri']); + $additional .= '' . $lang->get('acppl_lbl_plugin_site') . ' ' . "{$data['plugin uri']}
"; + + // author's site + $data['author uri'] = htmlspecialchars($data['author uri']); + $additional .= '' . $lang->get('acppl_lbl_author_site') . ' ' . "{$data['author uri']}
"; + + // version + $additional .= '' . $lang->get('acppl_lbl_version') . ' ' . "{$data['version']}
"; + + // installed version + if ( $data['status'] & PLUGIN_OUTOFDATE ) + { + $additional .= '' . $lang->get('acppl_lbl_installed_version') . ' ' . "{$data['version installed']}
"; + } + + // build list of buttons + $buttons_html = ''; + if ( !empty($buttons) ) + { + $filename_js = addslashes($filename); + $buttons = explode('|', $buttons); + $colors = array( + 'install' => 'green', + 'disable' => 'blue', + 'enable' => 'blue', + 'upgrade' => 'green', + 'uninstall' => 'red' + ); + foreach ( $buttons as $button ) + { + $btnface = $lang->get("acppl_btn_$button"); + $buttons_html .= "$btnface\n"; + } + } + + echo " + + "; + } + ?> +
+
+ $status +
+
+ +
+ $desc +
+ $additional +
+ $buttons_html +
+ +
+
+
+
+ '; }