[geeklog-cvs] Geeklog-1.x/plugins/links install_defaults.php, NONE, 1.1 functions.inc, 1.103, 1.104 config.php, 1.24, NONE

Dirk Haun dhaun at qs1489.pair.com
Sun Feb 3 14:11:52 EST 2008


Update of /cvsroot/geeklog/Geeklog-1.x/plugins/links
In directory qs1489.pair.com:/tmp/cvs-serv13605/plugins/links

Modified Files:
	functions.inc 
Added Files:
	install_defaults.php 
Removed Files:
	config.php 
Log Message:
Added Links plugin config to the configuration GUI


Index: functions.inc
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/plugins/links/functions.inc,v
retrieving revision 1.103
retrieving revision 1.104
diff -C2 -d -r1.103 -r1.104
*** functions.inc	2 Jan 2008 09:42:07 -0000	1.103
--- functions.inc	3 Feb 2008 19:11:50 -0000	1.104
***************
*** 3,11 ****
  // Reminder: always indent with 4 spaces (no tabs).
  // +---------------------------------------------------------------------------+
! // | Links Plugin 2.0  functions.inc                                           |
  // +---------------------------------------------------------------------------+
  // |                                                                           |
! // | This program is free software; you can redistribute it and/or             |
! // | modify it under the terms of the GNU General Public License               |
  // | as published by the Free Software Foundation; either version 2            |
  // | of the License, or (at your option) any later version.                    |
--- 3,26 ----
  // Reminder: always indent with 4 spaces (no tabs).
  // +---------------------------------------------------------------------------+
! // | Links Plugin 2.0                                                          |
  // +---------------------------------------------------------------------------+
+ // | functions.inc                                                             |
  // |                                                                           |
! // | This file does two things: 1) it implements the necessary Geeklog Plugin  |
! // | API method and 2) implements all the common code needed by the Links      |
! // | Plugins' PHP files.                                                       |
! // +---------------------------------------------------------------------------+
! // | Copyright (C) 2000-2008 by the following authors:                         |
! // |                                                                           |
! // | Authors: Tony Bibbs         - tony AT tonybibbs DOT com                   |
! // |          Mark Limburg       - mlimburg AT users.sourceforge DOT net       |
! // |          Jason Whittenburg  - jwhitten AT securitygeeks DOT com           |
! // |          Dirk Haun          - dirk AT haun-online DOT de                  |
! // |          Trinity Bays       - trinity93 AT steubentech DOT com            |
! // |          Oliver Spiesshofer - oliver AT spiesshofer DOT com               |
! // |          Euan McKay         - info AT heatherengineering DOT com          |
! // +---------------------------------------------------------------------------+
! // |                                                                           |
! // | This program is licensed under the terms of the GNU General Public License|
  // | as published by the Free Software Foundation; either version 2            |
  // | of the License, or (at your option) any later version.                    |
***************
*** 13,18 ****
  // | This program is distributed in the hope that it will be useful,           |
  // | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
! // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
! // | GNU General Public License for more details.                              |
  // |                                                                           |
  // | You should have received a copy of the GNU General Public License         |
--- 28,33 ----
  // | This program is distributed in the hope that it will be useful,           |
  // | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
! // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                      |
! // | See the GNU General Public License for more details.                      |
  // |                                                                           |
  // | You should have received a copy of the GNU General Public License         |
***************
*** 24,63 ****
  // $Id$
  
  
! /**
!  * This file does two things: 1) it implements the necessary Geeklog Plugin
!  * API method and 2) implements all the common code needed by the links
!  * Plugins' PHP files.
!  *
!  * @package Links
!  * @filesource
!  * @version 2.0
!  * @since GL 1.4.0
!  * @copyright Copyright © 2005-2008
!  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
!  * @author Trinity Bays <trinity93 AT steubentech DOT com>
!  * @author Tony Bibbs <tony AT tonybibbs DOT com>
!  * @author Tom Willett <tom AT pigstye DOT net>
!  * @author Blaine Lang <langmail AT sympatico DOT ca>
!  * @author Dirk Haun <dirk AT haun-online DOT de>
!  *
!  */
  
  
! if (strpos ($_SERVER['PHP_SELF'], 'functions.inc') !== false) {
!     die ('This file can not be used on its own.');
  }
  
! $langfile = $_CONF['path'] . 'plugins/links/language/'
!           . $_CONF['language'] . '.php';
  
! if (file_exists ($langfile)) {
!     require_once ($langfile);
! } else {
!     require_once ($_CONF['path'] . 'plugins/links/language/english.php');
  }
  
! require_once ($_CONF['path'] . 'plugins/links/config.php');
! 
  
  // +---------------------------------------------------------------------------+
--- 39,74 ----
  // $Id$
  
+ if (strpos($_SERVER['PHP_SELF'], 'functions.inc') !== false) {
+     die('This file can not be used on its own.');
+ }
  
! $plugin_path = $_CONF['path'] . 'plugins/links/';
! $langfile = $plugin_path . 'language/' . $_CONF['language'] . '.php';
  
+ if (file_exists($langfile)) {
+     require_once $langfile;
+ } else {
+     require_once $plugin_path . 'language/english.php';
+ }
  
! /*
! * As of Geeklog 1.5, the plugin's config.php is not needed any more and
! * should be removed after upgrading.
! */
! if (file_exists($plugin_path . 'config.php')) {
!     include_once $plugin_path . 'config.php';
  }
  
! /*
! * Check and see if we need to load the plugin configuration
! */
! if (!isset($_LI_CONF['linksloginrequired'])) {
!     require_once $_CONF['path_system'] . 'classes/config.class.php';
  
!     $li_config = config::get_instance();
!     $_LI_CONF = $li_config->get_config('links');
  }
  
! $_LI_CONF['version'] = '2.0.0';
  
  // +---------------------------------------------------------------------------+
***************
*** 707,733 ****
  {
      global $_CONF, $_TABLES, $_LI_CONF, $_DB_dbms;
      // the plugin needs these functions so complain when they doesn't exist
!     if (!function_exists ('COM_truncate') || !function_exists ('MBYTE_strpos')) {
          return 3002;
      }
-     // include SQL required for upgrade
-     $blockadmin_id = DB_GetItem ($_TABLES['groups'], 'grp_id', "grp_name='Block Admin'");
-     include ($_CONF['path'] . 'plugins/links/sql/upgrade_1.0.1_2.'.$_DB_dbms.'.php');
  
  
      // get current version
!     $currentVersion = DB_getItem($_TABLES['plugins'],'pi_version',"pi_name='links'");
!     switch( $currentVersion ) {
  
!         case "1.0" :
!         case "1.0.1" :
          // do DB changes:
  
          // create categories table
  
!         COM_errorLog ("Adding categories table to the links plugin", 1);
!         DB_Query($LINKS_SQL['linkcategories'],1);
!         if (DB_error ()) {
!             COM_errorLog ("There was an error adding categories table to the links plugin", 1);
              return false;
          }
--- 718,747 ----
  {
      global $_CONF, $_TABLES, $_LI_CONF, $_DB_dbms;
+ 
      // the plugin needs these functions so complain when they doesn't exist
!     if (!function_exists('COM_truncate') || !function_exists('MBYTE_strpos')) {
          return 3002;
      }
  
+     // include SQL required for upgrade
+     $blockadmin_id = DB_getItem($_TABLES['groups'], 'grp_id',
+                                 "grp_name = 'Block Admin'");
+     include $_CONF['path'] . 'plugins/links/sql/upgrade_1.0.1_2.'.$_DB_dbms.'.php';
  
      // get current version
!     $currentVersion = DB_getItem($_TABLES['plugins'], 'pi_version',
!                                  "pi_name = 'links'");
!     switch ($currentVersion) {
  
!         case "1.0":
!         case "1.0.1":
          // do DB changes:
  
          // create categories table
  
!         COM_errorLog("Adding categories table to the links plugin", 1);
!         DB_query($LINKS_SQL['linkcategories'], 1);
!         if (DB_error()) {
!             COM_errorLog("There was an error adding categories table to the links plugin", 1);
              return false;
          }
***************
*** 745,749 ****
  
          // get Links admin group number
!         $group_id = DB_getItem($_TABLES['groups'],'grp_id',"grp_name='Links Admin'");
  
          // loop through adding to category table, then update links table with cids
--- 759,764 ----
  
          // get Links admin group number
!         $group_id = DB_getItem($_TABLES['groups'], 'grp_id',
!                                "grp_name = 'Links Admin'");
  
          // loop through adding to category table, then update links table with cids
***************
*** 754,759 ****
                  $category = addslashes($A['category']);
                  $cid = addslashes(COM_makeSid());
!                 DB_query ("INSERT INTO {$_TABLES['linkcategories']} (cid,pid,category,owner_id,group_id,created,modified) VALUES ('{$cid}','{$_LI_CONF['root']}','{$category}','2','{$group_id}',NOW(),NOW())",1);
!                 DB_query ("UPDATE {$_TABLES['links']} SET category='{$cid}' WHERE category='{$category}'",1);
                  if (DB_error()) {
                      COM_errorLog("Error inserting categories into linkcategories table",1);
--- 769,774 ----
                  $category = addslashes($A['category']);
                  $cid = addslashes(COM_makeSid());
!                 DB_query("INSERT INTO {$_TABLES['linkcategories']} (cid,pid,category,owner_id,group_id,created,modified) VALUES ('{$cid}','{$_LI_CONF['root']}','{$category}','2','{$group_id}',NOW(),NOW())",1);
!                 DB_query("UPDATE {$_TABLES['links']} SET category='{$cid}' WHERE category='{$category}'",1);
                  if (DB_error()) {
                      COM_errorLog("Error inserting categories into linkcategories table",1);
***************
*** 765,786 ****
  
          // update the links and linksubmission table structures
!         COM_errorLog ("Updating linksubmission table for the links plugin (a)", 1);
!         DB_Query($LINKS_SQL['linksubmission1'],1);
!         if (DB_error ()) {
!             COM_errorLog ("There was an error updating the linksubmission table of the links plugin (a)", 1);
              return false;
          }
!         COM_errorLog ("Updating linksubmission table for the links plugin (b)", 1);
!         DB_Query($LINKS_SQL['linksubmission2'],1);
!         if (DB_error ()) {
!             COM_errorLog ("There was an error updating the linksubmission table of the links plugin (b)", 1);
              return false;
          }
          COM_errorLog("Success - updated linksubmission table for the links plugin",1);
  
!         COM_errorLog ("Updating links table for the links plugin", 1);
!         DB_Query($LINKS_SQL['links'],1);
!         if (DB_error ()) {
!             COM_errorLog ("There was an error updating the links table of the links plugin", 1);
              return false;
          }
--- 780,801 ----
  
          // update the links and linksubmission table structures
!         COM_errorLog("Updating linksubmission table for the links plugin (a)", 1);
!         DB_query($LINKS_SQL['linksubmission1'],1);
!         if (DB_error()) {
!             COM_errorLog("There was an error updating the linksubmission table of the links plugin (a)", 1);
              return false;
          }
!         COM_errorLog("Updating linksubmission table for the links plugin (b)", 1);
!         DB_query($LINKS_SQL['linksubmission2'],1);
!         if (DB_error()) {
!             COM_errorLog("There was an error updating the linksubmission table of the links plugin (b)", 1);
              return false;
          }
          COM_errorLog("Success - updated linksubmission table for the links plugin",1);
  
!         COM_errorLog("Updating links table for the links plugin", 1);
!         DB_query($LINKS_SQL['links'],1);
!         if (DB_error()) {
!             COM_errorLog("There was an error updating the links table of the links plugin", 1);
              return false;
          }
***************
*** 788,794 ****
  
          // add root category
!         DB_Query($LINKS_SQL['root'],1);
!         if (DB_error ()) {
!             COM_errorLog ("There was an error adding the root category to the links plugin", 1);
              return false;
          }
--- 803,809 ----
  
          // add root category
!         DB_query($LINKS_SQL['root'],1);
!         if (DB_error()) {
!             COM_errorLog("There was an error adding the root category to the links plugin", 1);
              return false;
          }
***************
*** 796,802 ****
  
          // add php links block
!         DB_Query($LINKS_SQL['linksblock'],1);
!         if (DB_error ()) {
!             COM_errorLog ("There was an error adding the phplinksblock to the links plugin", 1);
              return false;
          }
--- 811,817 ----
  
          // add php links block
!         DB_query($LINKS_SQL['linksblock'],1);
!         if (DB_error()) {
!             COM_errorLog("There was an error adding the phplinksblock to the links plugin", 1);
              return false;
          }
***************
*** 804,810 ****
  
          // add php categories block
!         DB_Query($LINKS_SQL['categoriesblock'],1);
!         if (DB_error ()) {
!             COM_errorLog ("There was an error adding the phpcategoriesblock to the links plugin", 1);
              return false;
          }
--- 819,825 ----
  
          // add php categories block
!         DB_query($LINKS_SQL['categoriesblock'],1);
!         if (DB_error()) {
!             COM_errorLog("There was an error adding the phpcategoriesblock to the links plugin", 1);
              return false;
          }
***************
*** 812,816 ****
  
          // update the version numbers
!         DB_query ("UPDATE {$_TABLES['plugins']} SET pi_version = '{$_LI_CONF['version']}', pi_gl_version='1.5.0' WHERE pi_name='links'");
          break;
  
--- 827,831 ----
  
          // update the version numbers
!         DB_query("UPDATE {$_TABLES['plugins']} SET pi_version = '{$_LI_CONF['version']}', pi_gl_version='1.5.0' WHERE pi_name='links'");
          break;
  

--- config.php DELETED ---

--- NEW FILE: install_defaults.php ---
<?php

// Reminder: always indent with 4 spaces (no tabs).
// +---------------------------------------------------------------------------+
// | Links Plugin 2.0                                                          |
// +---------------------------------------------------------------------------+
// | install_defaults.php                                                      |
// |                                                                           |
// | Initial Installation Defaults used when loading the online configuration  |
// | records. These settings are only used during the initial installation     |
// | and not referenced any more once the plugin is installed.                 |
// +---------------------------------------------------------------------------+
// | Copyright (C) 2000-2008 by the following authors:                         |
// |                                                                           |
// | Authors: Tony Bibbs         - tony AT tonybibbs DOT com                   |
// |          Mark Limburg       - mlimburg AT users.sourceforge DOT net       |
// |          Jason Whittenburg  - jwhitten AT securitygeeks DOT com           |
// |          Dirk Haun          - dirk AT haun-online DOT de                  |
// |          Trinity Bays       - trinity93 AT steubentech DOT com            |
// |          Oliver Spiesshofer - oliver AT spiesshofer DOT com               |
// |          Euan McKay         - info AT heatherengineering DOT com          |
// +---------------------------------------------------------------------------+
// |                                                                           |
// | This program is licensed under the terms of the GNU General Public License|
// | as published by the Free Software Foundation; either version 2            |
// | of the License, or (at your option) any later version.                    |
// |                                                                           |
// | This program is distributed in the hope that it will be useful,           |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                      |
// | See the GNU General Public License for more details.                      |
// |                                                                           |
// | You should have received a copy of the GNU General Public License         |
// | along with this program; if not, write to the Free Software Foundation,   |
// | Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           |
// |                                                                           |
// +---------------------------------------------------------------------------+
//
// $Id: install_defaults.php,v 1.1 2008/02/03 19:11:50 dhaun Exp $

if (strpos($_SERVER['PHP_SELF'], 'install_defaults.php') !== false) {
    die('This file can not be used on its own!');
}

/*
 * Links default settings
 *
 * Initial Installation Defaults used when loading the online configuration
 * records. These settings are only used during the initial installation
 * and not referenced any more once the plugin is installed
 *
 */

global $_LI_DEFAULT;

/**
* the link plugin's config array
*/
$_LI_DEFAULT = array();

/**
 * this lets you select which functions are available for registered users only
 */
$_LI_DEFAULT['linksloginrequired'] = 0;

/**
 * Submission Settings
 * enable (set to 1) or disable (set to 0) submission queues:
 */
$_LI_DEFAULT['linksubmission']  = 1;

/**
 * Following times are in seconds
 */
$_LI_DEFAULT['newlinksinterval']    = 1209600; // = 14 days

/**
 * Set to 1 to hide a section from the What's New block:
 */
$_LI_DEFAULT['hidenewlinks']    = 0;

/**
 * Set to 1 to hide the "Links" entry from the top menu:
 */
$_LI_DEFAULT['hidelinksmenu']    = 0;

/**
 * categories per column
 * You can set this and $_LI_DEFAULT['linksperpage'] to 0 to get back the old
 * (pre-1.3.6) style of the links section. Setting only linkcols to 0 will hide
 * the categories but keep the paging. Setting only linksperpage to 0 will list
 * all the links of the selected category on one page.
 */
$_LI_DEFAULT['linkcols']     =  3;

/**
 * links per page
 * You can set this and $_LI_DEFAULT['linkcols'] to 0 to get back the old
 * (pre-1.3.6) style of the links section. Setting only linkcols to 0 will hide
 * the categories but keep the paging. Setting only linksperpage to 0 will list
 * all the links of the selected category on one page.
 */
$_LI_DEFAULT['linksperpage'] = 10;

/**
 * show top ten links
 * Whether to show the Top Ten Links on the main page or not.
 */
$_LI_DEFAULT['show_top10']   = true;

/**
 * notify when a new link was submitted
 */
$_LI_DEFAULT['notification'] = 0;

/**
 * should we remove links submited by users if account is removed? (1)
 * or change owner to root (0)
 */
$_LI_DEFAULT['delete_links'] = 0;

/** What to show after a link has been saved? Possible choices:
 * 'item' -> forward to the target of the link
 * 'list' -> display the admin-list of links
 * 'plugin' -> display the public homepage of the links plugin
 * 'home' -> display the site homepage
 * 'admin' -> display the site admin homepage
 */
$_LI_DEFAULT['aftersave'] = 'list';

/**
 * show category descriptions
 * Whether to show subcategory descriptions when viewing a category or not.
 */
$_LI_DEFAULT['show_category_descriptions'] = true;

/**
 * Links root category id
 */
$_LI_DEFAULT['root'] = 'site';

/**
 * Define default permissions for new links created from the Admin panel.
 * Permissions are perm_owner, perm_group, perm_members, perm_anon (in that
 * order). Possible values:<br>
 * - 3 = read + write permissions (perm_owner and perm_group only)
 * - 2 = read-only
 * - 0 = neither read nor write permissions
 * (a value of 1, ie. write-only, does not make sense and is not allowed)
 */
$_LI_DEFAULT['default_permissions'] = array (3, 2, 2, 2);


/**
* Initialize Links plugin configuration
*
* Creates the database entries for the configuation if they don't already
* exist. Initial values will be taken from $_LI_CONF if available (e.g. from
* an old config.php), uses $_LI_DEFAULT otherwise.
*
* @return   boolean     true: success; false: an error occurred
*
*/
function plugin_initconfig_links()
{
    global $_LI_CONF, $_LI_DEFAULT;

    if (is_array($_LI_CONF) && (count($_LI_CONF) > 1)) {
        $_LI_DEFAULT = $_LI_CONF;
    }

    $c = config::get_instance();
    if (!$c->group_exists('links')) {

        $c->add('linksloginrequired', $_LI_DEFAULT['linksloginrequired'],
                'select', 0, 0, 0, 10, true, 'links');
        $c->add('linkcols', $_LI_DEFAULT['linkcols'], 'text',
                0, 0, 0, 20, true, 'links');
        $c->add('linksperpage', $_LI_DEFAULT['linksperpage'], 'text',
                0, 0, 0, 30, true, 'links');
        $c->add('show_top10', $_LI_DEFAULT['show_top10'], 'select',
                0, 0, 1, 40, true, 'links');
        $c->add('show_category_descriptions', $_LI_DEFAULT['show_category_descriptions'], 'select', 0, 0, 1, 50, true, 'links');

        $c->add('hidenewlinks', $_LI_DEFAULT['hidenewlinks'], 'select',
                0, 1, 0, 60, true, 'links');
        $c->add('newlinksinterval', $_LI_DEFAULT['newlinksinterval'], 'text',
                0, 1, 0, 70, true, 'links');
        $c->add('hidelinksmenu', $_LI_DEFAULT['hidelinksmenu'], 'select',
                0, 1, 0, 80, true, 'links');
        $c->add('linksubmission', $_LI_DEFAULT['linksubmission'], 'select',
                0, 1, 0, 90, true, 'links');
        $c->add('notification', $_LI_DEFAULT['notification'], 'select',
                0, 1, 0, 100, true, 'links');
        $c->add('delete_links', $_LI_DEFAULT['delete_links'], 'select',
                0, 1, 0, 110, true, 'links');
        $c->add('aftersave', $_LI_DEFAULT['aftersave'], 'select',
                0, 1, 9, 120, true, 'links');
        $c->add('root', $_LI_DEFAULT['root'], 'text',
                0, 1, 0, 130, true, 'links');

        $c->add('default_permissions', $_LI_DEFAULT['default_permissions'],
                '@select', 0, 2, 12, 140, true, 'links');

    }

    return true;
}

?>




More information about the geeklog-cvs mailing list