[geeklog-cvs] geeklog-1.3/public_html/admin plugins.php,1.32,1.33

geeklog-cvs-admin at lists.geeklog.net geeklog-cvs-admin at lists.geeklog.net
Fri Jun 20 11:15:42 EDT 2003


Update of /usr/cvs/geeklog/geeklog-1.3/public_html/admin
In directory internal.geeklog.net:/tmp/cvs-serv2449

Modified Files:
	plugins.php 
Log Message:
Added support for '_admin_block' and '_msg_block' template overrides,
make sure functions.inc is loaded when attempting to uninstall a disabled plugin.


Index: plugins.php
===================================================================
RCS file: /usr/cvs/geeklog/geeklog-1.3/public_html/admin/plugins.php,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** plugins.php	4 Feb 2003 20:31:57 -0000	1.32
--- plugins.php	20 Jun 2003 15:15:40 -0000	1.33
***************
*** 6,11 ****
  // +---------------------------------------------------------------------------+
  // | plugins.php                                                               |
- // | Geeklog plugin administration page.                                       |
  // |                                                                           |
  // +---------------------------------------------------------------------------+
  // | Copyright (C) 2000-2003 by the following authors:                         |
--- 6,11 ----
  // +---------------------------------------------------------------------------+
  // | plugins.php                                                               |
  // |                                                                           |
+ // | Geeklog plugin administration page.                                       |
  // +---------------------------------------------------------------------------+
  // | Copyright (C) 2000-2003 by the following authors:                         |
***************
*** 35,40 ****
  // $Id$
  
! include('../lib-common.php');
! include('auth.inc.php');
  
  // Uncomment the line below if you need to debug the HTTP variables being passed
--- 35,40 ----
  // $Id$
  
! require_once('../lib-common.php');
! require_once('auth.inc.php');
  
  // Uncomment the line below if you need to debug the HTTP variables being passed
***************
*** 46,54 ****
  
  if (!SEC_inGroup('Root')) {
!     $display .= COM_siteHeader('menu');
!     $display .= COM_startBlock($MESSAGE[30]);
      $display .= $MESSAGE[38];
!     $display .= COM_endBlock();
!     $display .= COM_siteFooter();
      COM_errorLog("User {$_USER['username']} tried to illegally access the poll administration screen",1);
      echo $display;
--- 46,55 ----
  
  if (!SEC_inGroup('Root')) {
!     $display .= COM_siteHeader ('menu');
!     $display .= COM_startBlock ($MESSAGE[30], '',
!                                 COM_getBlockTemplate ('_msg_block', 'header'));
      $display .= $MESSAGE[38];
!     $display .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
!     $display .= COM_siteFooter ();
      COM_errorLog("User {$_USER['username']} tried to illegally access the poll administration screen",1);
      echo $display;
***************
*** 72,76 ****
  	}
  
! 	$result = DB_query("SELECT * FROM {$_TABLES['plugins']} WHERE pi_name = '$pi_name'");
      if (DB_numRows($result) <> 1) {
          // Serious problem, we got a pi_name that doesn't exists or returned more than one row
--- 73,77 ----
  	}
  
! 	$result = DB_query("SELECT pi_homepage,pi_version,pi_gl_version,pi_enabled FROM {$_TABLES['plugins']} WHERE pi_name = '$pi_name'");
      if (DB_numRows($result) <> 1) {
          // Serious problem, we got a pi_name that doesn't exists or returned more than one row
***************
*** 88,100 ****
      $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[13]));
      $plg_templates->set_var('lang_save', $LANG32[23]);
      $plg_templates->set_var('lang_cancel', $LANG32[24]);
      $plg_templates->set_var('lang_delete', $LANG32[25]);
!     $public_img = $_CONF['site_url'] . "/" . $pi_name . "/images/" . $pi_name . ".gif";
      $fh = @fopen ($public_img, 'r');
      if ($fh === false) {
!         $admin_img = $_CONF['site_admin_url'] . "/plugins/" . $pi_name
!                    . "/images/" . $pi_name . ".gif";
          $plg_templates->set_var ('pi_icon', $admin_img);
      } else {
--- 89,102 ----
      $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[13],
!             '', COM_getBlockTemplate ('_admin_block', 'header')));
      $plg_templates->set_var('lang_save', $LANG32[23]);
      $plg_templates->set_var('lang_cancel', $LANG32[24]);
      $plg_templates->set_var('lang_delete', $LANG32[25]);
!     $public_img = $_CONF['site_url'] . '/' . $pi_name . '/images/' . $pi_name . '.gif';
      $fh = @fopen ($public_img, 'r');
      if ($fh === false) {
!         $admin_img = $_CONF['site_admin_url'] . '/plugins/' . $pi_name
!                    . '/images/' . $pi_name . '.gif';
          $plg_templates->set_var ('pi_icon', $admin_img);
      } else {
***************
*** 103,107 ****
      }
      if (!empty($pi_name)) {
!         $plg_templates->set_var('delete_option', '<input type="submit" value="' . $LANG32[25] . '" name="mode">');
      }
      $plg_templates->set_var('confirmed', $confirmed);
--- 105,110 ----
      }
      if (!empty($pi_name)) {
!         $plg_templates->set_var ('delete_option', '<input type="submit" value="'
!                                  . $LANG32[25] . '" name="mode">');
      }
      $plg_templates->set_var('confirmed', $confirmed);
***************
*** 120,124 ****
          $plg_templates->set_var('enabled_checked', '');
      }
!     $plg_templates->set_var('end_block', COM_endBlock());
  
      $retval .= $plg_templates->parse('output', 'editor');
--- 123,128 ----
          $plg_templates->set_var('enabled_checked', '');
      }
!     $plg_templates->set_var('end_block',
!             COM_endBlock (COM_getBlockTemplate ('_admin_block', 'footer')));
  
      $retval .= $plg_templates->parse('output', 'editor');
***************
*** 144,148 ****
      $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_pluginlist', COM_startBlock($LANG32[5]));
      $plg_templates->set_var('lang_newplugin', $LANG32[14]);
      $plg_templates->set_var('lang_adminhome', $LANG32[15]);
--- 148,153 ----
      $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_pluginlist', COM_startBlock($LANG32[5],
!             '', COM_getBlockTemplate ('_admin_block', 'header')));
      $plg_templates->set_var('lang_newplugin', $LANG32[14]);
      $plg_templates->set_var('lang_adminhome', $LANG32[15]);
***************
*** 174,178 ****
  		$plg_templates->set_var('lang_nopluginsinstalled', $LANG32[10]);
  	}
!     $plg_templates->set_var('end_block', COM_endBlock());
      $plg_templates->parse('output', 'list');
      $retval .= $plg_templates->finish($plg_templates->get_var('output'));
--- 179,184 ----
  		$plg_templates->set_var('lang_nopluginsinstalled', $LANG32[10]);
  	}
!     $plg_templates->set_var('end_block',
!             COM_endBlock (COM_getBlockTemplate ('_admin_block', 'footer')));
      $plg_templates->parse('output', 'list');
      $retval .= $plg_templates->finish($plg_templates->get_var('output'));
***************
*** 213,225 ****
  }
  
! function removeplugin ($pi_name) {
!     if (PLG_uninstall ($pi_name)) {
!     } else {
!     }
! 
!     return $retval;
! }
! 
! 
  function show_newplugins()
  {
--- 219,228 ----
  }
  
! /**
! * Creates list of uninstalled plugins (if any) and offers install link to them.
! *
! * @return   string   HTML containing list of uninstalled plugins
! *
! */
  function show_newplugins()
  {
***************
*** 266,270 ****
              $newtemplate->set_var ('lang_pluginname', $LANG32[16]);
              $newtemplate->set_var ('start_block_newlist',
!                                    COM_startBlock ($LANG32[14]));
              for ($i = 0; $i < sizeof ($newplugins); $i++) {
                  $newtemplate->set_var ('lang_install', $LANG32[22]);
--- 269,274 ----
              $newtemplate->set_var ('lang_pluginname', $LANG32[16]);
              $newtemplate->set_var ('start_block_newlist',
!                     COM_startBlock ($LANG32[14], '',
!                             COM_getBlockTemplate ('_admin_block', 'header')));
              for ($i = 0; $i < sizeof ($newplugins); $i++) {
                  $newtemplate->set_var ('lang_install', $LANG32[22]);
***************
*** 277,285 ****
                  $newtemplate->parse ('plugin_list', 'row', true);
              }
!             $newtemplate->set_var ('end_block', COM_endBlock ());
              $newtemplate->parse ('output', 'list');
              $retval .= $newtemplate->finish ($newtemplate->get_var ('output'));
          } else {
!             $retval =  COM_startBlock ($LANG32[14]);
              $retval .= '<table border="0">' . LB;
              $retval .= '<tr><th align="left">' . $LANG32[16] .'</th></tr>' . LB;
--- 281,291 ----
                  $newtemplate->parse ('plugin_list', 'row', true);
              }
!             $newtemplate->set_var ('end_block',
!                 COM_endBlock (COM_getBlockTemplate ('_admin_block', 'footer')));
              $newtemplate->parse ('output', 'list');
              $retval .= $newtemplate->finish ($newtemplate->get_var ('output'));
          } else {
!             $retval =  COM_startBlock ($LANG32[14], '',
!                                COM_getBlockTemplate ('_admin_block', 'header'));
              $retval .= '<table border="0">' . LB;
              $retval .= '<tr><th align="left">' . $LANG32[16] .'</th></tr>' . LB;
***************
*** 291,295 ****
              }
              $retval .= '</table>' . LB;
!             $retval .= COM_endBlock ();
          }
      }
--- 297,302 ----
              }
              $retval .= '</table>' . LB;
!             $retval .= COM_endBlock (COM_getBlockTemplate ('_admin_block',
!                                                            'footer'));
          }
      }
***************
*** 298,301 ****
--- 305,341 ----
  }
  
+ /**
+ * Uninstall a plugin (call its uninstall function).
+ *
+ * @param    pi_name   string   name of the plugin to uninstall
+ * @return             string   HTML for error or success message
+ *
+ */
+ function do_uninstall ($pi_name)
+ {
+     global $_CONF, $MESSAGE;
+ 
+     $retval = '';
+ 
+     // if the plugin is disabled, load the functions.inc now
+     if (!function_exists ('plugin_uninstall_' . $pi_name)) {
+         require_once ($_CONF['path'] . 'plugins/' . $pi_name . '/functions.inc');
+     }
+ 
+     if (PLG_uninstall ($pi_name)) {
+         $retval .= COM_showMessage (45);
+     } 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;
+ }
+ 
  ###############################################################################
  # MAIN
***************
*** 303,324 ****
      if ($confirmed == 1) {
          $display .= COM_siteHeader('menu');
!         if (PLG_uninstall ($pi_name)) {
!             $display .= COM_showMessage(45);
!         } else {
!             $timestamp = strftime($_CONF['daytime']);
!             $display .= COM_startBlock($MESSAGE[40] . ' - ' . $timestamp)
!                     . '<img src="' . $_CONF['layout_url']
!                     . '/images/sysmessage.gif" border="0" align="top" alt="">'
!                     . $LANG08[6] . '<br><br>' . COM_endBlock ();
!         }
          $display .= listplugins($page);
          $display .= COM_siteFooter();
!     } else {
!         $display .= COM_siteHeader('menu');
!         $display .= COM_startBlock($LANG32[30]);
          $display .= $LANG32[31];
!         $display .= COM_endBlock();
!         $display .= plugineditor($pi_name,1);
!         $display .= COM_siteFooter();
      }	
  } else if ($mode == 'edit') {
--- 343,357 ----
      if ($confirmed == 1) {
          $display .= COM_siteHeader('menu');
!         $display .= do_uninstall ($pi_name);
          $display .= listplugins($page);
          $display .= COM_siteFooter();
!     } else { // ask user for confirmation
!         $display .= COM_siteHeader ('menu');
!         $display .= COM_startBlock ($LANG32[30], '',
!                             COM_getBlockTemplate ('_msg_block', 'header'));
          $display .= $LANG32[31];
!         $display .= COM_endBlock(COM_getBlockTemplate ('_msg_block', 'footer'));
!         $display .= plugineditor ($pi_name, 1);
!         $display .= COM_siteFooter ();
      }	
  } else if ($mode == 'edit') {





More information about the geeklog-cvs mailing list