plugins/polls/autoinstall.php
author Dirk Haun <dirk@haun-online.de>
Sat, 03 Oct 2009 15:53:36 +0200
branchHEAD
changeset 7348 696d17bec61e
parent 7228 5524c9cdb063
child 7413 5db714583481
permissions -rw-r--r--
The Polls plugin requires Geeklog 1.6.1 now
     1 <?php
     2 
     3 /* Reminder: always indent with 4 spaces (no tabs). */
     4 // +---------------------------------------------------------------------------+
     5 // | Polls Plugin 2.1                                                          |
     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 Polls plugin
    34 *
    35 * @package Polls
    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_polls($pi_name)
    46 {
    47     $pi_name         = 'polls';
    48     $pi_display_name = 'Polls';
    49     $pi_admin        = $pi_display_name . ' Admin';
    50 
    51     $info = array(
    52         'pi_name'         => $pi_name,
    53         'pi_display_name' => $pi_display_name,
    54         'pi_version'      => '2.1.1',
    55         'pi_gl_version'   => '1.6.1',
    56         'pi_homepage'     => 'http://www.geeklog.net/'
    57     );
    58 
    59     $groups = array(
    60         $pi_admin => 'Has full access to ' . $pi_display_name . ' features'
    61     );
    62 
    63     $features = array(
    64         $pi_name . '.edit'      => 'Access to ' . $pi_name . ' editor'
    65     );
    66 
    67     $mappings = array(
    68         $pi_name . '.edit'      => array($pi_admin)
    69     );
    70 
    71     $tables = array(
    72         'pollanswers',
    73         'pollquestions',
    74         'polltopics',
    75         'pollvoters'
    76     );
    77 
    78     $inst_parms = array(
    79         'info'      => $info,
    80         'groups'    => $groups,
    81         'features'  => $features,
    82         'mappings'  => $mappings,
    83         'tables'    => $tables
    84     );
    85 
    86     return $inst_parms;
    87 }
    88 
    89 /**
    90 * Load plugin configuration from database
    91 *
    92 * @param    string  $pi_name    Plugin name
    93 * @return   boolean             true on success, otherwise false
    94 * @see      plugin_initconfig_polls
    95 *
    96 */
    97 function plugin_load_configuration_polls($pi_name)
    98 {
    99     global $_CONF;
   100 
   101     $base_path = $_CONF['path'] . 'plugins/' . $pi_name . '/';
   102 
   103     require_once $_CONF['path_system'] . 'classes/config.class.php';
   104     require_once $base_path . 'install_defaults.php';
   105 
   106     return plugin_initconfig_polls();
   107 }
   108 
   109 /**
   110 * Check if the plugin is compatible with this Geeklog version
   111 *
   112 * @param    string  $pi_name    Plugin name
   113 * @return   boolean             true: plugin compatible; false: not compatible
   114 *
   115 */
   116 function plugin_compatible_with_this_version_polls($pi_name)
   117 {
   118     global $_CONF, $_DB_dbms;
   119 
   120     // check if we support the DBMS the site is running on
   121     $dbFile = $_CONF['path'] . 'plugins/' . $pi_name . '/sql/'
   122             . $_DB_dbms . '_install.php';
   123     if (! file_exists($dbFile)) {
   124         return false;
   125     }
   126 
   127     if (function_exists('COM_showPoll') || function_exists('COM_pollVote')) {
   128         // if these functions exist, then someone's trying to install the
   129         // plugin on Geeklog 1.3.11 or older - sorry, but that won't work
   130         return false;
   131     }
   132 
   133     if (! function_exists('SEC_getGroupDropdown')) {
   134         return false;
   135     }
   136 
   137     if (! function_exists('SEC_createToken')) {
   138         return false;
   139     }
   140 
   141     if (! function_exists('COM_showMessageText')) {
   142         return false;
   143     }
   144 
   145     if (! isset($_CONF['meta_tags'])) {
   146         return false;
   147     }
   148 
   149     return true;
   150 }
   151 
   152 ?>