[geeklog-cvs] Geeklog-1.x/public_html/admin/plugins/calendar install.php, 1.12, 1.13

Dirk Haun dhaun at qs1489.pair.com
Sun Mar 16 12:02:55 EDT 2008


Update of /cvsroot/geeklog/Geeklog-1.x/public_html/admin/plugins/calendar
In directory qs1489.pair.com:/tmp/cvs-serv41622/calendar

Modified Files:
	install.php 
Log Message:
Make the common installation code identical for all bundled plugins


Index: install.php
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/public_html/admin/plugins/calendar/install.php,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** install.php	16 Mar 2008 12:22:01 -0000	1.12
--- install.php	16 Mar 2008 16:02:53 -0000	1.13
***************
*** 166,178 ****
  
  // Only let Root users access this page
! if (!SEC_inGroup ('Root')) {
      // Someone is trying to illegally access this page
!     COM_accessLog ("Someone has tried to illegally access the {$pi_display_name} install/uninstall page.  User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: {$_SERVER['REMOTE_ADDR']}", 1);
  
!     $display = COM_siteHeader ('menu', $LANG_ACCESS['accessdenied'])
!              . COM_startBlock ($LANG_ACCESS['accessdenied'])
               . $LANG_ACCESS['plugin_access_denied_msg']
!              . COM_endBlock ()
!              . COM_siteFooter ();
  
      echo $display;
--- 166,178 ----
  
  // Only let Root users access this page
! if (!SEC_inGroup('Root')) {
      // Someone is trying to illegally access this page
!     COM_accessLog("Someone has tried to illegally access the {$pi_display_name} install/uninstall page.  User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: {$_SERVER['REMOTE_ADDR']}", 1);
  
!     $display = COM_siteHeader('menu', $LANG_ACCESS['accessdenied'])
!              . COM_startBlock($LANG_ACCESS['accessdenied'])
               . $LANG_ACCESS['plugin_access_denied_msg']
!              . COM_endBlock()
!              . COM_siteFooter();
  
      echo $display;
***************
*** 191,211 ****
             $pi_name, $pi_display_name, $pi_version, $gl_version, $pi_url;
  
!     COM_errorLog ("Attempting to install the $pi_display_name plugin", 1);
  
      // create the plugin's groups
      $admin_group_id = 0;
      foreach ($GROUPS as $name => $desc) {
!         COM_errorLog ("Attempting to create $name group", 1);
  
-         $grp_name = addslashes ($name);
-         $grp_desc = addslashes ($desc);
-         DB_query ("INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr) VALUES ('$grp_name', '$grp_desc')", 1);
-         if (DB_error ()) {
-             PLG_uninstall ($pi_name);
              return false;
          }
  
          // replace the description with the new group id so we can use it later
!         $GROUPS[$name] = DB_insertId ();
  
          // assume that the first group is the plugin's Admin group
--- 191,212 ----
             $pi_name, $pi_display_name, $pi_version, $gl_version, $pi_url;
  
!     COM_errorLog("Attempting to install the $pi_display_name plugin", 1);
  
      // create the plugin's groups
      $admin_group_id = 0;
      foreach ($GROUPS as $name => $desc) {
!         COM_errorLog("Attempting to create $name group", 1);
! 
!         $grp_name = addslashes($name);
!         $grp_desc = addslashes($desc);
!         DB_query("INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr) VALUES ('$grp_name', '$grp_desc')", 1);
!         if (DB_error()) {
!             PLG_uninstall($pi_name);
  
              return false;
          }
  
          // replace the description with the new group id so we can use it later
!         $GROUPS[$name] = DB_insertId();
  
          // assume that the first group is the plugin's Admin group
***************
*** 216,240 ****
  
      // Create the plugin's table(s)
!     $_SQL = array ();
!     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') &&
!             (DB_getItem ($_TABLES['vars'], 'value', "name = 'database_engine'")
                  == 'InnoDB')) {
              $use_innodb = true;
          }
          foreach ($_SQL as $sql) {
!             $sql = str_replace ('#group#', $admin_group_id, $sql);
              if ($use_innodb) {
!                 $sql = str_replace ('MyISAM', 'InnoDB', $sql);
              }
!             DB_query ($sql);
!             if (DB_error ()) {
!                 COM_errorLog ('Error creating table', 1);
!                 PLG_uninstall ($pi_name);
  
                  return false;
--- 217,241 ----
  
      // Create the plugin's table(s)
!     $_SQL = array();
!     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') &&
!             (DB_getItem($_TABLES['vars'], 'value', "name = 'database_engine'")
                  == 'InnoDB')) {
              $use_innodb = true;
          }
          foreach ($_SQL as $sql) {
!             $sql = str_replace('#group#', $admin_group_id, $sql);
              if ($use_innodb) {
!                 $sql = str_replace('MyISAM', 'InnoDB', $sql);
              }
!             DB_query($sql);
!             if (DB_error()) {
!                 COM_errorLog('Error creating table', 1);
!                 PLG_uninstall($pi_name);
  
                  return false;
***************
*** 244,268 ****
  
      // Add the plugin's features
!     COM_errorLog ("Attempting to add $pi_display_name feature(s)", 1);
  
      foreach ($FEATURES as $feature => $desc) {
!         $ft_name = addslashes ($feature);
!         $ft_desc = addslashes ($desc);
!         DB_query ("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr) "
!                   . "VALUES ('$ft_name', '$ft_desc')", 1);
!         if (DB_error ()) {
!             PLG_uninstall ($pi_name);
  
              return false;
          }
  
!         $feat_id = DB_insertId ();
  
!         if (isset ($MAPPINGS[$feature])) {
              foreach ($MAPPINGS[$feature] as $group) {
!                 COM_errorLog ("Adding $feature feature to the $group group", 1);
!                 DB_query ("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ($feat_id, {$GROUPS[$group]})");
!                 if (DB_error ()) {
!                     PLG_uninstall ($pi_name);
  
                      return false;
--- 245,269 ----
  
      // Add the plugin's features
!     COM_errorLog("Attempting to add $pi_display_name feature(s)", 1);
  
      foreach ($FEATURES as $feature => $desc) {
!         $ft_name = addslashes($feature);
!         $ft_desc = addslashes($desc);
!         DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr) "
!                  . "VALUES ('$ft_name', '$ft_desc')", 1);
!         if (DB_error()) {
!             PLG_uninstall($pi_name);
  
              return false;
          }
  
!         $feat_id = DB_insertId();
  
!         if (isset($MAPPINGS[$feature])) {
              foreach ($MAPPINGS[$feature] as $group) {
!                 COM_errorLog("Adding $feature feature to the $group group", 1);
!                 DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ($feat_id, {$GROUPS[$group]})");
!                 if (DB_error()) {
!                     PLG_uninstall($pi_name);
  
                      return false;
***************
*** 274,283 ****
      // Add plugin's Admin group to the Root user group
      // (assumes that the Root group's ID is always 1)
!     COM_errorLog ("Attempting to give all users in the Root group access to the $pi_display_name's Admin group", 1);
  
!     DB_query ("INSERT INTO {$_TABLES['group_assignments']} VALUES "
!               . "($admin_group_id, NULL, 1)");
!     if (DB_error ()) {
!         PLG_uninstall ($pi_name);
  
          return false;
--- 275,284 ----
      // Add plugin's Admin group to the Root user group
      // (assumes that the Root group's ID is always 1)
!     COM_errorLog("Attempting to give all users in the Root group access to the $pi_display_name's Admin group", 1);
  
!     DB_query("INSERT INTO {$_TABLES['group_assignments']} VALUES "
!              . "($admin_group_id, NULL, 1)");
!     if (DB_error()) {
!         PLG_uninstall($pi_name);
  
          return false;
***************
*** 285,294 ****
  
      // Pre-populate tables or run any other SQL queries
!     COM_errorLog ('Inserting default data', 1);
      foreach ($DEFVALUES as $sql) {
!         $sql = str_replace ('#group#', $admin_group_id, $sql);
!         DB_query ($sql, 1);
!         if (DB_error ()) {
!             PLG_uninstall ($pi_name);
  
              return false;
--- 286,295 ----
  
      // Pre-populate tables or run any other SQL queries
!     COM_errorLog('Inserting default data', 1);
      foreach ($DEFVALUES as $sql) {
!         $sql = str_replace('#group#', $admin_group_id, $sql);
!         DB_query($sql, 1);
!         if (DB_error()) {
!             PLG_uninstall($pi_name);
  
              return false;
***************
*** 300,303 ****
--- 301,305 ----
          if (!plugin_load_configuration()) {
              PLG_uninstall($pi_name);
+ 
              return false;
          }
***************
*** 305,318 ****
  
      // Finally, register the plugin with Geeklog
!     COM_errorLog ("Registering $pi_display_name plugin with Geeklog", 1);
  
      // silently delete an existing entry
!     DB_delete ($_TABLES['plugins'], 'pi_name', $pi_name);
  
      DB_query("INSERT INTO {$_TABLES['plugins']} (pi_name, pi_version, pi_gl_version, pi_homepage, pi_enabled) VALUES "
          . "('$pi_name', '$pi_version', '$gl_version', '$pi_url', 1)");
  
!     if (DB_error ()) {
!         PLG_uninstall ($pi_name);
  
          return false;
--- 307,320 ----
  
      // Finally, register the plugin with Geeklog
!     COM_errorLog("Registering $pi_display_name plugin with Geeklog", 1);
  
      // silently delete an existing entry
!     DB_delete($_TABLES['plugins'], 'pi_name', $pi_name);
  
      DB_query("INSERT INTO {$_TABLES['plugins']} (pi_name, pi_version, pi_gl_version, pi_homepage, pi_enabled) VALUES "
          . "('$pi_name', '$pi_version', '$gl_version', '$pi_url', 1)");
  
!     if (DB_error()) {
!         PLG_uninstall($pi_name);
  
          return false;
***************
*** 320,326 ****
  
      // give the plugin a chance to perform any post-install operations
!     if (function_exists ('plugin_postinstall')) {
!         if (!plugin_postinstall ()) {
!             PLG_uninstall ($pi_name);
  
              return false;
--- 322,328 ----
  
      // give the plugin a chance to perform any post-install operations
!     if (function_exists('plugin_postinstall')) {
!         if (!plugin_postinstall()) {
!             PLG_uninstall($pi_name);
  
              return false;
***************
*** 328,332 ****
      }
  
!     COM_errorLog ("Successfully installed the $pi_display_name plugin!", 1);
  
      return true;
--- 330,334 ----
      }
  
!     COM_errorLog("Successfully installed the $pi_display_name plugin!", 1);
  
      return true;
***************
*** 339,374 ****
  if ($_REQUEST['action'] == 'uninstall') {
      $uninstall_plugin = 'plugin_uninstall_' . $pi_name;
!     if ($uninstall_plugin ()) {
!         $display = COM_refresh ($_CONF['site_admin_url']
!                                 . '/plugins.php?msg=45');
      } else {
!         $display = COM_refresh ($_CONF['site_admin_url']
!                                 . '/plugins.php?msg=73');
      }
! } else if (DB_count ($_TABLES['plugins'], 'pi_name', $pi_name) == 0) {
      // plugin not installed
  
!     if (plugin_compatible_with_this_geeklog_version ()) {
!         if (plugin_install_now ()) {
!             $display = COM_refresh ($_CONF['site_admin_url']
!                                     . '/plugins.php?msg=44');
          } else {
!             $display = COM_refresh ($_CONF['site_admin_url']
!                                     . '/plugins.php?msg=72');
          }
      } else {
          // plugin needs a newer version of Geeklog
!         $display .= COM_siteHeader ('menu', $LANG32[8])
!                  . COM_startBlock ($LANG32[8])
                   . '<p>' . $LANG32[9] . '</p>'
!                  . COM_endBlock ()
!                  . COM_siteFooter ();
      }
  } else {
      // plugin already installed
!     $display .= COM_siteHeader ('menu', $LANG01[77])
!              . COM_startBlock ($LANG32[6])
               . '<p>' . $LANG32[7] . '</p>'
!              . COM_endBlock ()
               . COM_siteFooter();
  }
--- 341,376 ----
  if ($_REQUEST['action'] == 'uninstall') {
      $uninstall_plugin = 'plugin_uninstall_' . $pi_name;
!     if ($uninstall_plugin()) {
!         $display = COM_refresh($_CONF['site_admin_url']
!                                . '/plugins.php?msg=45');
      } else {
!         $display = COM_refresh($_CONF['site_admin_url']
!                                . '/plugins.php?msg=73');
      }
! } else if (DB_count($_TABLES['plugins'], 'pi_name', $pi_name) == 0) {
      // plugin not installed
  
!     if (plugin_compatible_with_this_geeklog_version()) {
!         if (plugin_install_now()) {
!             $display = COM_refresh($_CONF['site_admin_url']
!                                    . '/plugins.php?msg=44');
          } else {
!             $display = COM_refresh($_CONF['site_admin_url']
!                                    . '/plugins.php?msg=72');
          }
      } else {
          // plugin needs a newer version of Geeklog
!         $display .= COM_siteHeader('menu', $LANG32[8])
!                  . COM_startBlock($LANG32[8])
                   . '<p>' . $LANG32[9] . '</p>'
!                  . COM_endBlock()
!                  . COM_siteFooter();
      }
  } else {
      // plugin already installed
!     $display .= COM_siteHeader('menu', $LANG01[77])
!              . COM_startBlock($LANG32[6])
               . '<p>' . $LANG32[7] . '</p>'
!              . COM_endBlock()
               . COM_siteFooter();
  }




More information about the geeklog-cvs mailing list