[geeklog-cvs] geeklog-1.3/public_html/admin plugins.php,1.38,1.39

blaine at iowaoutdoors.org blaine at iowaoutdoors.org
Fri Sep 24 23:03:12 EDT 2004


Update of /var/cvs/geeklog-1.3/public_html/admin
In directory www:/tmp/cvs-serv30842/public_html/admin

Modified Files:
	plugins.php 
Log Message:
Added the capability for Plugins to have an update function which will use the existing upgrade PLG function that has not been used to-date. Added a new PLG function to return the current version of code. The plugin Editor now will show the current installed version and the version returned from the current plugin function plugin_chkVersion. Site Admin will now have a way to tell if they have new plugin code in place.

Plugin Editor now has an update option when viewing the plugin details. Option will only appear if the plugin returned a valid version and is > registered installed version.

Admin now clicks on plugin-name instead of the number.

Index: plugins.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/admin/plugins.php,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** plugins.php	17 Jul 2004 17:16:33 -0000	1.38
--- plugins.php	25 Sep 2004 03:03:10 -0000	1.39
***************
*** 115,119 ****
          $admin_img = $_CONF['site_admin_url'] . '/plugins/' . $pi_name
                     . '/images/' . $pi_name . '.gif';
!         $plg_templates->set_var ('pi_icon', $admin_img);
      } else {
          fclose ($fh);
--- 115,125 ----
          $admin_img = $_CONF['site_admin_url'] . '/plugins/' . $pi_name
                     . '/images/' . $pi_name . '.gif';
!         $fh2 = @fopen ($public_img, 'r');
!         if ($fh2 === false) {
!             $default_img = $_CONF['site_url'] . '/images/icons/plugins.gif';
!             $plg_templates->set_var ('pi_icon', $default_img);
!         } else {
!             $plg_templates->set_var ('pi_icon', $admin_img);
!         }
      } else {
          fclose ($fh);
***************
*** 124,127 ****
--- 130,143 ----
                                   . $LANG32[25] . '" name="mode">');
      }
+     $plugin_code_version = PLG_chkVersion($pi_name);
+     if ($plugin_code_version == '') {
+         $plugin_code_version = 'N/A';
+     }
+     if ($plugin_code_version != 'N/A' AND $plugin_code_version > $A['pi_version']) {
+         $plg_templates->set_var ('update_option', '<input type="submit" value="'
+                                  . $LANG32[34] . '" name="mode">');
+     } else {
+         $plg_templates->set_var ('update_option', '');
+     }    
      $plg_templates->set_var('confirmed', $confirmed);
      $plg_templates->set_var('lang_pluginname', $LANG32[26]);
***************
*** 130,136 ****
--- 146,154 ----
      $plg_templates->set_var('pi_homepage', $A['pi_homepage']);
      $plg_templates->set_var('lang_pluginversion', $LANG32[28]);
+     $plg_templates->set_var('lang_plugincodeversion', $LANG32[33]);
      $plg_templates->set_var('pi_version', $A['pi_version']);
      $plg_templates->set_var('lang_geeklogversion', $LANG32[29]);
      $plg_templates->set_var('pi_gl_version', $A['pi_gl_version']);
+     $plg_templates->set_var('pi_codeversion', $plugin_code_version );
      $plg_templates->set_var('lang_enabled', $LANG32[19]);
      if ($A['pi_enabled'] == 1) {
***************
*** 187,194 ****
              $pcount = (PLUGINS_PER_PAGE * ($page - 1)) + $i + 1;
              $A = DB_fetchArray($result);
              $plg_templates->set_var('pi_name', $A['pi_name']);
              $plg_templates->set_var('row_num', $pcount);
              $plg_templates->set_var('pi_url', $A['pi_homepage']);
!             $plg_templates->set_var('pi_version', $A['pi_version']);
              $plg_templates->set_var('pi_gl_version', $A['pi_gl_version']);
              if ($A['pi_enabled'] == 1) {
--- 205,217 ----
              $pcount = (PLUGINS_PER_PAGE * ($page - 1)) + $i + 1;
              $A = DB_fetchArray($result);
+             $plugin_code_version = PLG_chkVersion($A['pi_name']);
+             if ($plugin_code_version == '') {
+                 $plugin_code_version = 'N/A';
+             }
              $plg_templates->set_var('pi_name', $A['pi_name']);
              $plg_templates->set_var('row_num', $pcount);
              $plg_templates->set_var('pi_url', $A['pi_homepage']);
!             $plg_templates->set_var('pi_installed_version', $A['pi_version']);
!             $plg_templates->set_var('pi_code_version', $plugin_code_version);
              $plg_templates->set_var('pi_gl_version', $A['pi_gl_version']);
              if ($A['pi_enabled'] == 1) {
***************
*** 366,369 ****
--- 389,433 ----
  
  /**
+ * Updates a plugin (call its upgrade function).
+ *
+ * @param    pi_name   string   name of the plugin to uninstall
+ * @return             string   HTML for error or success message
+ *
+ */
+ function do_update ($pi_name)
+ {
+     global $_CONF, $LANG32, $LANG08, $MESSAGE;
+ 
+     $retval = '';
+ 
+     if (strlen ($pi_name) == 0) {
+         $retval .= COM_startBlock ($LANG32[13], '',
+                             COM_getBlockTemplate ('_msg_block', 'header'));
+         $retval .= COM_errorLog ($LANG32[12]);
+         $retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
+ 
+         return $retval;
+     }
+ 
+     if (PLG_upgrade ($pi_name)) {
+         $retval .= COM_showMessage (60);
+     } else {
+         $timestamp = strftime ($_CONF['daytime']);
+         $retval .= COM_startBlock ($MESSAGE[40] . ' - ' . $timestamp, '',
+                            COM_getBlockTemplate ('_msg_block', 'header'))
+                 . '<img src="' . $_CONF['layout_url']
+                 . '/images/sysmessage.gif" border="0" align="top" alt="">'
+                 . $LANG08[6] . '<br><br>'
+                 . COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
+     }
+ 
+     return $retval;
+ }
+ 
+ 
+ 
+ 
+ 
+ /**
  * Uninstall a plugin (call its uninstall function).
  *
***************
*** 374,378 ****
  function do_uninstall ($pi_name)
  {
!     global $_CONF, $LANG32, $MESSAGE;
  
      $retval = '';
--- 438,442 ----
  function do_uninstall ($pi_name)
  {
!     global $_CONF, $LANG32, $LANG08, $MESSAGE;
  
      $retval = '';
***************
*** 431,438 ****
--- 495,509 ----
          $display .= COM_siteFooter ();
      }
+ 
+ } else if ($mode == $LANG32[34]) {
+         $display .= COM_siteHeader ('menu');
+         $display .= do_update ($pi_name);
+         $display .= COM_siteFooter ();
+ 
  } else if ($mode == 'edit') {
      $display .= COM_siteHeader ('menu');
      $display .= plugineditor (COM_applyFilter ($HTTP_GET_VARS['pi_name']));
      $display .= COM_siteFooter ();
+ 
  } else if (($mode == $LANG32[23]) && !empty ($LANG32[23])) { // save
      $display .= saveplugin (COM_applyFilter ($HTTP_POST_VARS['pi_name']),




More information about the geeklog-cvs mailing list