[geeklog-cvs] geeklog: Implemented Links autoinstall

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Mon Jan 5 05:06:22 EST 2009


details:   http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/fb55acb618e1
changeset: 6598:fb55acb618e1
user:      Dirk Haun <dirk at haun-online.de>
date:      Sat Dec 27 15:31:21 2008 +0100
description:
Implemented Links autoinstall

diffstat:

3 files changed, 160 insertions(+), 399 deletions(-)
plugins/links/autoinstall.php               |  153 ++++++++++
plugins/links/functions.inc                 |   11 
public_html/admin/plugins/links/install.php |  395 ---------------------------

diffs (truncated from 592 to 300 lines):

diff -r e02ca493ee9a -r fb55acb618e1 plugins/links/autoinstall.php
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/links/autoinstall.php	Sat Dec 27 15:31:21 2008 +0100
@@ -0,0 +1,153 @@
+<?php
+
+/* Reminder: always indent with 4 spaces (no tabs). */
+// +---------------------------------------------------------------------------+
+// | Links Plugin 2.1                                                          |
+// +---------------------------------------------------------------------------+
+// | autoinstall.php                                                           |
+// |                                                                           |
+// | This file provides helper functions for the automatic plugin install.     |
+// +---------------------------------------------------------------------------+
+// | Copyright (C) 2008 by the following authors:                              |
+// |                                                                           |
+// | Authors: Dirk Haun         - dirk AT haun-online DOT de                   |
+// +---------------------------------------------------------------------------+
+// |                                                                           |
+// | 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.                    |
+// |                                                                           |
+// | 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.           |
+// |                                                                           |
+// +---------------------------------------------------------------------------+
+
+function plugin_autoinstall_links($pi_name)
+{
+    $pi_name         = 'links';
+    $pi_display_name = 'Links';
+    $pi_admin        = $pi_display_name . ' Admin';
+
+    $info = array(
+        'pi_name'         => $pi_name,
+        'pi_display_name' => $pi_display_name,
+        'pi_version'      => '2.1.0',
+        'pi_gl_version'   => '1.6.0',
+        'pi_homepage'     => 'http://www.geeklog.net/'
+    );
+
+    $groups = array(
+        $pi_admin => 'Has full access to ' . $pi_display_name . ' features'
+    );
+
+    $features = array(
+        $pi_name . '.edit'      => 'Access to links editor',
+        $pi_name . '.moderate'  => 'Ability to moderate pending links',
+        $pi_name . '.submit'    => 'May skip the links submission queue'
+    );
+
+    $mappings = array(
+        $pi_name . '.edit'      => array($pi_admin),
+        $pi_name . '.moderate'  => array($pi_admin),
+        $pi_name . '.submit'    => array($pi_admin)
+    );
+
+    $tables = array(
+        'linkcategories',
+        'links',
+        'linksubmission'
+    );
+
+    $inst_parms = array(
+        'info'      => $info,
+        'groups'    => $groups,
+        'features'  => $features,
+        'mappings'  => $mappings,
+        'tables'    => $tables
+    );
+
+    return $inst_parms;
+}
+
+function plugin_load_configuration_links($pi_name)
+{
+    global $_CONF, $base_path;
+
+    $base_path = $_CONF['path'] . 'plugins/' . $pi_name . '/';
+
+    require_once $_CONF['path_system'] . 'classes/config.class.php';
+    require_once $base_path . 'install_defaults.php';
+
+    return plugin_initconfig_links();
+}
+
+/**
+* Plugin postinstall
+*
+* We're inserting our default data here since it depends on other stuff that
+* has to happen first ...
+*
+* @return   boolean     true = proceed with install, false = an error occured
+*
+*/
+function plugin_postinstall_links($pi_name)
+{
+    global $_CONF, $_TABLES;
+
+    require_once $_CONF['path_system'] . 'classes/config.class.php';
+
+    $li_config = config::get_instance();
+    $_LI_CONF = $li_config->get_config('links');
+
+    $inst_parms = plugin_autoinstall_links($pi_name);
+    $pi_admin = key($inst_parms['groups']);
+
+    $admin_group_id = DB_getItem($_TABLES['groups'], 'grp_id',
+                                 "grp_name = '{$pi_admin}'");
+    $blockadmin_id = DB_getItem($_TABLES['groups'], 'grp_id',
+                                "grp_name = 'Block Admin'");
+
+    $L_SQL = array();
+    $L_SQL[] = "INSERT INTO {$_TABLES['linkcategories']} (cid, pid, category, description, tid, created, modified, group_id, owner_id, perm_owner, perm_group, perm_members, perm_anon) VALUES ('{$_LI_CONF['root']}', 'root', 'Root', 'Website root', '', NOW(), NOW(), #group#, 2, 3, 3, 2, 2)";
+
+    $L_SQL[] = "INSERT INTO {$_TABLES['linkcategories']} (cid, pid, category, description, tid, created, modified, group_id, owner_id, perm_owner, perm_group, perm_members, perm_anon) VALUES ('geeklog-sites', '{$_LI_CONF['root']}', 'Geeklog Sites', 'Sites using or related to the Geeklog CMS', NULL, NOW(), NOW(), #group#, 2, 3, 3, 2, 2)";
+
+    $L_SQL[] = "INSERT INTO {$_TABLES['links']} (lid, cid, url, description, title, hits, date, owner_id, group_id, perm_owner, perm_group, perm_members, perm_anon) VALUES ('geeklog.net', 'geeklog-sites', 'http://www.geeklog.net/', 'Visit the Geeklog homepage for support, FAQs, updates, add-ons, and a great community.', 'Geeklog Project Homepage', 123, NOW(), 1, #group#, 3, 3, 2, 2);";
+
+    foreach ($L_SQL as $sql) {
+        $sql = str_replace('#group#', $admin_group_id, $sql);
+        DB_query($sql, 1);
+        if (DB_error()) {
+            COM_error("SQL error in Links plugin postinstall, SQL: " . $sql);
+            return false;
+        }
+    }
+
+    return true;
+}
+
+function plugin_compatible_with_this_version_links($pi_name)
+{
+    if (!function_exists('COM_truncate') || !function_exists('MBYTE_strpos')) {
+        return false;
+    }
+
+    if (!function_exists('SEC_createToken')) {
+        return false;
+    }
+
+    if (!function_exists('COM_showMessageText')) {
+        return false;
+    }
+
+    return true;
+}
+
+?>
diff -r e02ca493ee9a -r fb55acb618e1 plugins/links/functions.inc
--- a/plugins/links/functions.inc	Sat Dec 27 11:46:10 2008 +0100
+++ b/plugins/links/functions.inc	Sat Dec 27 15:31:21 2008 +0100
@@ -2,7 +2,7 @@
 
 // Reminder: always indent with 4 spaces (no tabs).
 // +---------------------------------------------------------------------------+
-// | Links Plugin 2.0                                                          |
+// | Links Plugin 2.1                                                          |
 // +---------------------------------------------------------------------------+
 // | functions.inc                                                             |
 // |                                                                           |
@@ -59,7 +59,6 @@
     $_LI_CONF = $li_config->get_config('links');
 }
 
-$_LI_CONF['version'] = '2.0.0';
 
 // +---------------------------------------------------------------------------+
 // | Geeklog Plugin API Implementation                                         |
@@ -207,9 +206,13 @@
 */
 function plugin_chkVersion_links ()
 {
-    global $_LI_CONF;
+    global $_CONF;
 
-    return $_LI_CONF['version'];
+    require_once $_CONF['path'] . 'plugins/links/autoinstall.php';          
+
+    $inst_parms = plugin_autoinstall_links('links'); 
+
+    return $inst_parms['info']['pi_version'];
 }
 
 /**
diff -r e02ca493ee9a -r fb55acb618e1 public_html/admin/plugins/links/install.php
--- a/public_html/admin/plugins/links/install.php	Sat Dec 27 11:46:10 2008 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,395 +0,0 @@
-<?php
-
-// Reminder: always indent with 4 spaces (no tabs).
-// +---------------------------------------------------------------------------+
-// | Links plugin 2.0 for Geeklog                                              |
-// +---------------------------------------------------------------------------+
-// | install.php                                                               |
-// |                                                                           |
-// | This file installs and removes the data structures for the                |
-// | Links plugin for Geeklog.                                                 |
-// +---------------------------------------------------------------------------+
-// | Based on the Universal Plugin and prior work by the following authors:    |
-// |                                                                           |
-// | Copyright (C) 2002-2008 by the following authors:                         |
-// |                                                                           |
-// | Authors: Tony Bibbs         - tony AT tonybibbs DOT com                   |
-// |          Tom Willett        - tom AT pigstye DOT net                      |
-// |          Blaine Lang        - blaine AT portalparts DOT com               |
-// |          Dirk Haun          - dirk AT haun-online DOT de                  |
-// |          Vincent Furia      - vinny01 AT users DOT sourceforge DOT net    |
-// |          Oliver Spiesshofer - oliver AT spiesshofer DOT com               |
-// |          Euan McKay         - info AT heatherengineering DOT com          |
-// +---------------------------------------------------------------------------+
-// |                                                                           |
-// | 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.                    |
-// |                                                                           |
-// | 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.php,v 1.26 2008/05/23 13:36:12 dhaun Exp $
-
-require_once '../../../lib-common.php';
-
-// Plugin information
-//
-// ----------------------------------------------------------------------------
-//
-$pi_display_name = 'Links';
-$pi_name         = 'links';
-$pi_version      = '2.0.0';
-$gl_version      = '1.5.0';
-$pi_url          = 'http://www.geeklog.net/';
-
-$base_path = $_CONF['path'] . 'plugins/' . $pi_name . '/';
-
-// name of the Admin group
-$pi_admin        = $pi_display_name . ' Admin';
-
-// the plugin's groups - assumes first group to be the Admin group
-$GROUPS = array();
-$GROUPS[$pi_admin] = 'Has full access to ' . $pi_name . ' features';
-
-$FEATURES = array();
-$FEATURES['links.edit']         = 'Access to links editor';
-$FEATURES['links.moderate']     = 'Ability to moderate pending links';
-$FEATURES['links.submit']       = 'May skip the links submission queue';
-
-$MAPPINGS = array();
-$MAPPINGS['links.edit']         = array ($pi_admin);
-$MAPPINGS['links.moderate']     = array ($pi_admin);
-$MAPPINGS['links.submit']       = array ($pi_admin);
-
-// (optional) data to pre-populate tables with
-// Insert table name and sql to insert default data for your plugin.
-// Note: '#group#' will be replaced with the id of the plugin's admin group.
-$DEFVALUES = array(); // not used here - see plugin_postinstall
-
-
-/**
- * Checks the requirements for this plugin and if it is compatible with this
- * version of Geeklog.
- *
- * @return   boolean     true = proceed with install, false = not compatible
- *
- */
-function plugin_compatible_with_this_geeklog_version()
-{
-    if (!function_exists('COM_truncate') || !function_exists('MBYTE_strpos')) {
-        return false;
-    }
-
-    if (!function_exists('SEC_createToken')) {
-        return false;
-    }
-
-    if (!function_exists('COM_showMessageText')) {
-        return false;
-    }
-
-    return true;
-}
-



More information about the geeklog-cvs mailing list