plugins/spamx/autoinstall.php
author Dirk Haun <dirk@haun-online.de>
Sun, 17 May 2009 16:30:39 +0200
branchHEAD
changeset 7033 9089a0c77860
parent 6840 05f2aee29a2d
child 7690 e48c1d426d72
permissions -rw-r--r--
Added a check to all plugins to see if they support the DBMS the site is running on
     1 <?php
     2 
     3 /* Reminder: always indent with 4 spaces (no tabs). */
     4 // +---------------------------------------------------------------------------+
     5 // | Spam-X Plugin 1.2                                                         |
     6 // +---------------------------------------------------------------------------+
     7 // | autoinstall.php                                                           |
     8 // |                                                                           |
     9 // | This file provides helper functions for the automatic plugin install.     |
    10 // +---------------------------------------------------------------------------+
    11 // | Copyright (C) 2008-2009 by the following authors:                         |
    12 // |                                                                           |
    13 // | Authors: Dirk Haun         - dirk AT haun-online DOT de                   |
    14 // +---------------------------------------------------------------------------+
    15 // |                                                                           |
    16 // | This program is free software; you can redistribute it and/or             |
    17 // | modify it under the terms of the GNU General Public License               |
    18 // | as published by the Free Software Foundation; either version 2            |
    19 // | of the License, or (at your option) any later version.                    |
    20 // |                                                                           |
    21 // | This program is distributed in the hope that it will be useful,           |
    22 // | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
    23 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
    24 // | GNU General Public License for more details.                              |
    25 // |                                                                           |
    26 // | You should have received a copy of the GNU General Public License         |
    27 // | along with this program; if not, write to the Free Software Foundation,   |
    28 // | Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           |
    29 // |                                                                           |
    30 // +---------------------------------------------------------------------------+
    31 
    32 /**
    33 * Autoinstall API functions for the Spam-X plugin
    34 *
    35 * @package Spam-X
    36 */
    37 
    38 /**
    39 * Plugin autoinstall function
    40 *
    41 * @param    string  $pi_name    Plugin name
    42 * @return   array               Plugin information
    43 *
    44 */
    45 function plugin_autoinstall_spamx($pi_name)
    46 {
    47     $pi_name         = 'spamx';
    48     $pi_display_name = 'Spam-X';
    49     $pi_admin        = $pi_name . ' Admin';
    50 
    51     $info = array(
    52         'pi_name'         => $pi_name,
    53         'pi_display_name' => $pi_display_name,
    54         'pi_version'      => '1.2.0',
    55         'pi_gl_version'   => '1.6.0',
    56         'pi_homepage'     => 'http://www.pigstye.net/gplugs/staticpages/index.php/spamx'
    57     );
    58 
    59     $groups = array(
    60         $pi_admin => 'Users in this group can administer the '
    61                      . $pi_display_name . ' plugin'
    62     );
    63 
    64     $features = array(
    65         $pi_name . '.admin'    => 'Full access to ' . $pi_display_name
    66                                   . ' plugin'
    67     );
    68 
    69     $mappings = array(
    70         $pi_name . '.admin'     => array($pi_admin)
    71     );
    72 
    73     $tables = array(
    74         'spamx'
    75     );
    76 
    77     $inst_parms = array(
    78         'info'      => $info,
    79         'groups'    => $groups,
    80         'features'  => $features,
    81         'mappings'  => $mappings,
    82         'tables'    => $tables
    83     );
    84 
    85     return $inst_parms;
    86 }
    87 
    88 /**
    89 * Load plugin configuration from database
    90 *
    91 * @param    string  $pi_name    Plugin name
    92 * @return   boolean             true on success, otherwise false
    93 * @see      plugin_initconfig_spamx
    94 *
    95 */
    96 function plugin_load_configuration_spamx($pi_name)
    97 {
    98     global $_CONF;
    99 
   100     $base_path = $_CONF['path'] . 'plugins/' . $pi_name . '/';
   101 
   102     require_once $_CONF['path_system'] . 'classes/config.class.php';
   103     require_once $base_path . 'install_defaults.php';
   104 
   105     return plugin_initconfig_spamx();
   106 }
   107 
   108 /**
   109 * Check if the plugin is compatible with this Geeklog version
   110 *
   111 * @param    string  $pi_name    Plugin name
   112 * @return   boolean             true: plugin compatible; false: not compatible
   113 *
   114 */
   115 function plugin_compatible_with_this_version_spamx($pi_name)
   116 {
   117     global $_CONF, $_DB_dbms;
   118 
   119     // check if we support the DBMS the site is running on
   120     $dbFile = $_CONF['path'] . 'plugins/' . $pi_name . '/sql/'
   121             . $_DB_dbms . '_install.php';
   122     if (! file_exists($dbFile)) {
   123         return false;
   124     }
   125 
   126     if (! function_exists('PLG_spamAction')) {
   127         return false;
   128     }   
   129     
   130     if (! function_exists('SEC_createToken')) {
   131         return false;
   132     }
   133 
   134     if (! function_exists('COM_showMessageText')) {
   135         return false;
   136     }
   137 
   138     return true;
   139 }
   140 
   141 ?>