[geeklog-cvs] geeklog: Updating plugins.php (and language and template files)

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Sat Jun 20 21:57:05 EDT 2009


details:   http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/2f4176dd3cbf
changeset: 7134:2f4176dd3cbf
user:      tim at tim-ubuntu
date:      Sat Jun 20 21:53:35 2009 -0400
description:
Updating plugins.php (and language and template files)

diffstat:

 language/english.php                                       |   28 +-
 public_html/admin/plugins.php                              |  255 ++++++++++++++++++-
 public_html/layout/professional/admin/plugins/search.thtml |   37 ++
 system/lib-database.php                                    |    2 +
 4 files changed, 316 insertions(+), 6 deletions(-)

diffs (truncated from 412 to 300 lines):

diff -r 84cdcac317cf -r 2f4176dd3cbf language/english.php
--- a/language/english.php	Mon May 11 12:16:47 2009 +0200
+++ b/language/english.php	Sat Jun 20 21:53:35 2009 -0400
@@ -1075,7 +1075,26 @@
     105 => '(undefined error)',
     106 => 'Missing a temporary folder.',
     107 => 'Failed to write file to disk.',
-    108 => 'File upload stopped by extension.'
+    108 => 'File upload stopped by extension.',
+    
+    //
+    // Repository Updates
+    // 
+    300 => 'Search for a plugin',
+    301 => 'Check for Updates',
+    302 => 'List Repositories',
+    303 => 'Add Repository',
+    304 => 'Update Plugin List',
+    305 => 'Search Plugin',
+    306 => 'Filter Results',
+    307 => 'Plugin Name',
+    308 => 'Version',
+    309 => 'Repository',
+    310 => 'All Repositories',
+    311 => 'Install',
+    312 => 'Download',
+    313 => 'State'
+    
 );
 
 ###############################################################################
@@ -1240,7 +1259,9 @@
     100 => 'The plugin file you uploaded was not a GZip or Zip compressed archive.',
     101 => 'There are no topics (that you have access to). You need at least one topic to be able to submit stories.',
     400 => 'Not all required fields have been passed validation', // Error codes in the 400 range reserved for CUSTOM membership
-    401 => 'Please enter Fullname'
+    401 => 'Please enter Fullname',
+    // Error codes in the 500 range reserved for Repository Plugin Management
+    500 => 'Repository Update Successful'
 );
 
 ###############################################################################
@@ -1860,7 +1881,8 @@
     'search_show_limit' => "Show Page Limits?",
     'search_no_data' => "If No Data is Avaliable, Display",
     'search_separator' => "Group Separator",
-    'search_def_keytype' => "Default Search Method"
+    'search_def_keytype' => "Default Search Method",
+    'rmanager_moderated ' => "Plugins and Patches must be approved"
 );
 
 $LANG_configsubgroups['Core'] = array(
diff -r 84cdcac317cf -r 2f4176dd3cbf public_html/admin/plugins.php
--- a/public_html/admin/plugins.php	Mon May 11 12:16:47 2009 +0200
+++ b/public_html/admin/plugins.php	Sat Jun 20 21:53:35 2009 -0400
@@ -15,6 +15,7 @@
 // |          Jason Whittenburg - jwhitten AT securitygeeks DOT com            |
 // |          Dirk Haun         - dirk AT haun-online DOT de                   |
 // |          Matt West         - matt AT mattdanger DOT net                   |
+// |          Tim Patrick       - timpatrick12 AT gmail DOT com                |
 // +---------------------------------------------------------------------------+
 // |                                                                           |
 // | This program is free software; you can redistribute it and/or             |
@@ -419,6 +420,55 @@
 }
 
 /**
+* Bring up plugin search 
+*
+*/
+
+function pluginsearch()
+{
+    global $_CONF, $_TABLES, $_USER, $LANG32, $LANG_ADMIN;
+
+    $retval = '';
+    
+    $plg_templates = new Template($_CONF['path_layout'] . 'admin/plugins');
+    $plg_templates->set_file('search', 'search.thtml');
+    $plg_templates->set_var('xhtml', XHTML);
+    $plg_templates->set_var('site_url', $_CONF['site_url']);
+    $plg_templates->set_var('site_admin_url', $_CONF['site_admin_url']);
+    $plg_templates->set_var('layout_url', $_CONF['layout_url']);
+    $plg_templates->set_var('start_block_editor', COM_startBlock ($LANG32[305],
+            '', COM_getBlockTemplate ('_admin_block', 'header')));
+    $plg_templates->set_var('lang_search', $LANG_ADMIN['search']);
+    $plg_templates->set_var('lang_cancel', $LANG_ADMIN['cancel']);
+    $plg_templates->set_var('lang_306', $LANG32[306]);
+    $plg_templates->set_var('lang_307', $LANG32[307]);
+    $plg_templates->set_var('lang_308', $LANG32[308]);
+    $plg_templates->set_var('lang_309', $LANG32[309]);
+    $plg_templates->set_var('lang_310', $LANG32[310]);
+    
+    // Get DB info about current repositories
+    $result = DB_query("SELECT * FROM {$_TABLES['plugin_repository']};");
+    $d2 = "";
+    
+    while ( ($result2 = DB_fetchArray($result)) !== FALSE) {
+        $d2 .= <<<EOO
+<option value="{$result2['repository_url']}">{$result2['repository_url']}</option>
+EOO;
+    }
+    
+    $plg_templates->set_var('value_0', $d2);
+    
+    $plg_templates->set_var('pi_icon', PLG_getIcon($pi_name));
+    $plg_templates->set_var('end_block',
+            COM_endBlock (COM_getBlockTemplate ('_admin_block', 'footer')));
+
+    $retval .= $plg_templates->finish($plg_templates->parse('output', 'search'));
+
+    return $retval;
+
+}
+
+/**
 * List available plugins
 *
 * @param    string  $token  Security token
@@ -444,7 +494,92 @@
 
     $menu_arr = array (
                     array('url' => $_CONF['site_admin_url'],
-                          'text' => $LANG_ADMIN['admin_home']));
+                          'text' => $LANG_ADMIN['admin_home']),
+                    array('url' => 'plugins.php?mode=splugin',
+                          'text' => $LANG32[300]),
+                    array('url' => 'plugins.php?mode=chkupdates',
+                          'text' => $LANG32[301]),
+                    array('url' => 'plugins.php?mode=lstrepo',
+                          'text' => $LANG32[302]),
+                    array('url' => 'plugins.php?mode=updatelist',
+                          'text' => $LANG32[304]),
+                    array('url' => 'plugins.php?mode=addrepo',
+                          'text' => $LANG32[303])
+                                                );
+
+    $retval .= COM_startBlock($LANG32[5], '',
+                              COM_getBlockTemplate('_admin_block', 'header'));
+
+    $retval .= ADMIN_createMenu(
+        $menu_arr,
+        $LANG32[11],
+        $_CONF['layout_url'] . '/images/icons/plugins.' . $_IMAGE_TYPE
+    );
+
+    $text_arr = array(
+        'has_extras'   => true,
+        'instructions' => $LANG32[11],
+        'form_url'     => $_CONF['site_admin_url'] . '/plugins.php'
+    );
+
+    $query_arr = array(
+        'table' => 'plugins',
+        'sql' => "SELECT pi_name, pi_version, pi_gl_version, "
+                ."pi_enabled, pi_homepage FROM {$_TABLES['plugins']} WHERE 1=1",
+        'query_fields' => array('pi_name'),
+        'default_filter' => ''
+    );
+
+    // this is a dummy variable so we know the form has been used if all plugins
+    // should be disabled in order to disable the last one.
+    $form_arr = array('bottom' => '<input type="hidden" name="pluginenabler" value="true"' . XHTML . '>');
+
+    $retval .= ADMIN_list('plugins', 'ADMIN_getListField_plugins', $header_arr,
+                $text_arr, $query_arr, $defsort_arr, '', $token, '', $form_arr);
+    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
+
+    return $retval;
+}
+
+/**
+* List search results
+*
+* @param    string  $token  Security token
+* @return   string          formatted list of plugins
+*
+*/
+function listsearchedplugins($token)
+{
+    global $_CONF, $_TABLES, $LANG32, $LANG_ADMIN, $_IMAGE_TYPE;
+
+    require_once $_CONF['path_system'] . 'lib-admin.php';
+
+    $retval = '';
+    $header_arr = array(      # display 'text' and use table field 'field'
+        array('text' => $LANG32[311], 'field' => 'install', 'sort' => false),
+        array('text' => $LANG32[312], 'field' => 'download', 'sort' => false),
+        array('text' => $LANG32[16], 'field' => 'pi_name', 'sort' => true),
+        array('text' => $LANG32[17], 'field' => 'pi_version', 'sort' => true),
+	array('text' => $LANG32[313], 'field' => 'state', 'sort' => true),
+
+    );
+
+    $defsort_arr = array('field' => 'pi_name', 'direction' => 'asc');
+
+    $menu_arr = array (
+                    array('url' => $_CONF['site_admin_url'],
+                          'text' => $LANG_ADMIN['admin_home']),
+                    array('url' => 'plugins.php?mode=splugin',
+                          'text' => $LANG32[300]),
+                    array('url' => 'plugins.php?mode=chkupdates',
+                          'text' => $LANG32[301]),
+                    array('url' => 'plugins.php?mode=lstrepo',
+                          'text' => $LANG32[302]),
+                    array('url' => 'plugins.php?mode=updatelist',
+                          'text' => $LANG32[304]),
+                    array('url' => 'plugins.php?mode=addrepo',
+                          'text' => $LANG32[303])
+                                                );
 
     $retval .= COM_startBlock($LANG32[5], '',
                               COM_getBlockTemplate('_admin_block', 'header'));
@@ -961,7 +1096,7 @@
     if (file_exists($base_path . 'sql/' . $_DB_dbms . '_install.php')) {
         require_once $base_path . 'sql/' . $_DB_dbms . '_install.php';
     }
-
+    
     if (count($_SQL) > 0) {
         $use_innodb = false;
         if (($_DB_dbms == 'mysql') &&
@@ -1152,6 +1287,106 @@
 }
 
 
+/**
+* Check for updates to repository (reload)
+*
+*/
+function updaterepositorylist()
+{
+    global $_CONF, $_TABLES, $_USER, $LANG32, $LANG_ADMIN;
+    
+    // For each repository listing
+    $query = "SELECT * FROM {$_TABLES['plugin_repository']} WHERE enabled = 1;";
+    DB_query($query);
+    
+    // Truncate Table
+    DB_query("TRUNCATE {$_TABLES['plugin_repository_list']};");
+    
+    // Loop through listings
+    while ( ($result2 = DB_fetchArray($result)) !== FALSE) {
+        // XML Pull
+        $reader = new XMLReader();
+
+        $reader->open($result2['repository_url']);
+        $plugin = false;
+        $array_of_values = array();
+        $array_of_key_gen = array(
+            'id' => false,
+            'name' => false,
+            'version' => false, 
+            'db' => false, 
+            'dependencies' => false, 
+            'soft_dep' => false, 
+            'short_des' => false, 
+            'long_des' => false, 
+            'credits' => false, 
+            'vett' => false, 
+            'downloads' => false, 
+            'install' => false, 
+            'state' => false, 
+            'ext' => false
+
+        );
+
+        while ($reader->read()) {
+              // Process 
+              if($reader->name == "plugin") {
+                  // New plugin section
+                  if($plugin == false) {
+                      $plugin = true;
+            
+                  }
+                  else {  
+                      $plugin = false; 
+                      
+		      // Insert into the repository listing database the values
+		      $query = <<<OFF
+INSERT INTO {$_TABLES['plugin_repository_list']} (plugin_id, name, repository_name, version, db, dependencies, soft_dep, short_des, long_des, credits, vett, downloads, install, state, ext) VALUES('{$array_of_values['id']}','{$array_of_values['name']}','{$array_of_values['version']}','{$array_of_values['db']}','{$array_of_values['dependencies']}','{$array_of_values['soft_dep']}','{$array_of_values['short_des']}','{$array_of_values['long_des']}','{$array_of_values['credits']}','{$array_of_values['vett']}','{$array_of_values['downloads']}','{$array_of_values['install']}','{$array_of_values['state']}','{$array_of_values['ext']}');
+OFF;
+                      // Insert into database
+		      DB_query($query);
+		      
+                      foreach ($array_of_key_gen as $key => $value) {
+                          $array_of_key_gen[$key] = false;  
+                      }
+              
+                  }
+              }
+
+              switch ($reader->name) {
+                  case "id":
+                  case "name":
+                  case "version":
+                  case "db":
+                  case "dependencies":
+                  case "soft_dep":
+                  case "short_des":



More information about the geeklog-cvs mailing list