plugins/calendar/autoinstall.php
author Dirk Haun <dirk@haun-online.de>
Sun, 17 May 2009 16:30:39 +0200
branchHEAD
changeset 7033 9089a0c77860
parent 6602 e85cfa6ea9fe
child 7344 3e03947c0624
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 // | Calendar Plugin 1.1                                                       |
     6 // +---------------------------------------------------------------------------+
     7 // | autoinstall.php                                                           |
     8 // |                                                                           |
     9 // | This file provides helper functions for the automatic plugin install.     |
    10 // +---------------------------------------------------------------------------+
    11 // | Copyright (C) 2008 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 function plugin_autoinstall_calendar($pi_name)
    33 {
    34     $pi_name         = 'calendar';
    35     $pi_display_name = 'Calendar';
    36     $pi_admin        = $pi_display_name . ' Admin';
    37 
    38     $info = array(
    39         'pi_name'         => $pi_name,
    40         'pi_display_name' => $pi_display_name,
    41         'pi_version'      => '1.1.0',
    42         'pi_gl_version'   => '1.6.0',
    43         'pi_homepage'     => 'http://www.geeklog.net/'
    44     );
    45 
    46     $groups = array(
    47         $pi_admin => 'Has full access to ' . $pi_display_name . ' features'
    48     );
    49 
    50     $features = array(
    51         $pi_name . '.moderate'  => 'Ability to moderate pending events',
    52         $pi_name . '.edit'      => 'Access to event editor',
    53         $pi_name . '.submit'    => 'May skip the event submission queue'
    54     );
    55 
    56     $mappings = array(
    57         $pi_name . '.moderate'  => array($pi_admin),
    58         $pi_name . '.edit'      => array($pi_admin),
    59         $pi_name . '.submit'    => array($pi_admin)
    60     );
    61 
    62     $tables = array(
    63         'events',
    64         'eventsubmission',
    65         'personal_events'
    66     );
    67 
    68     $inst_parms = array(
    69         'info'      => $info,
    70         'groups'    => $groups,
    71         'features'  => $features,
    72         'mappings'  => $mappings,
    73         'tables'    => $tables
    74     );
    75 
    76     return $inst_parms;
    77 }
    78 
    79 function plugin_load_configuration_calendar($pi_name)
    80 {
    81     global $_CONF;
    82 
    83     $base_path = $_CONF['path'] . 'plugins/' . $pi_name . '/';
    84 
    85     require_once $_CONF['path_system'] . 'classes/config.class.php';
    86     require_once $base_path . 'install_defaults.php';
    87 
    88     return plugin_initconfig_calendar();
    89 }
    90 
    91 function plugin_postinstall_calendar($pi_name)
    92 {
    93     return true;
    94 }
    95 
    96 function plugin_compatible_with_this_version_calendar($pi_name)
    97 {
    98     global $_CONF, $_DB_dbms;
    99 
   100     // check if we support the DBMS the site is running on
   101     $dbFile = $_CONF['path'] . 'plugins/' . $pi_name . '/sql/'
   102             . $_DB_dbms . '_install.php';
   103     if (! file_exists($dbFile)) {
   104         return false;
   105     }
   106 
   107     if (function_exists('COM_printUpcomingEvents')) {
   108         // if this function exists, then someone's trying to install the
   109         // plugin on Geeklog 1.4.0 or older - sorry, but that won't work
   110         return false;
   111     }   
   112 
   113     if (!function_exists('MBYTE_strpos')) {
   114         // the plugin requires the multi-byte functions
   115         return false; 
   116     }   
   117 
   118     if (!function_exists('COM_createLink')) {
   119         return false;
   120     }
   121 
   122     if (!function_exists('SEC_createToken')) {
   123         return false;
   124     }
   125 
   126     if (!function_exists('COM_showMessageText')) {
   127         return false;
   128     }
   129 
   130     return true;
   131 }
   132 
   133 ?>