plugins/staticpages/autoinstall.php
author Dirk Haun <dirk@haun-online.de>
Sun, 17 May 2009 16:30:39 +0200
branchHEAD
changeset 7033 9089a0c77860
parent 6841 8d868290493d
child 7228 5524c9cdb063
child 7917 c503da16c16c
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 // | Static Pages Plugin 1.6                                                   |
     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 Static Pages plugin
    34 *
    35 * @package StaticPages
    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_staticpages($pi_name)
    46 {
    47     $pi_name         = 'staticpages';
    48     $pi_display_name = 'Static Pages';
    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'      => '1.6.0',
    55         'pi_gl_version'   => '1.6.0',
    56         'pi_homepage'     => 'http://www.geeklog.net/'
    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 . '.edit'      => 'Access to ' . $pi_display_name . ' editor',
    66         $pi_name . '.delete'    => 'Ability to delete static pages',
    67         $pi_name . '.PHP'       => 'Ability to use PHP in static pages'
    68     );
    69 
    70     $mappings = array(
    71         $pi_name . '.edit'      => array($pi_admin),
    72         $pi_name . '.delete'    => array($pi_admin)
    73         // Note: 'staticpages.PHP' is not assigned to any group by default
    74     );
    75 
    76     $tables = array(
    77         'staticpage'
    78     );
    79 
    80     $inst_parms = array(
    81         'info'      => $info,
    82         'groups'    => $groups,
    83         'features'  => $features,
    84         'mappings'  => $mappings,
    85         'tables'    => $tables
    86     );
    87 
    88     return $inst_parms;
    89 }
    90 
    91 /**
    92 * Load plugin configuration from database
    93 *
    94 * @param    string  $pi_name    Plugin name
    95 * @return   boolean             true on success, otherwise false
    96 * @see      plugin_initconfig_staticpages
    97 *
    98 */
    99 function plugin_load_configuration_staticpages($pi_name)
   100 {
   101     global $_CONF;
   102 
   103     $base_path = $_CONF['path'] . 'plugins/' . $pi_name . '/';
   104 
   105     require_once $_CONF['path_system'] . 'classes/config.class.php';
   106     require_once $base_path . 'install_defaults.php';
   107 
   108     return plugin_initconfig_staticpages();
   109 }
   110 
   111 /**
   112 * Check if the plugin is compatible with this Geeklog version
   113 *
   114 * @param    string  $pi_name    Plugin name
   115 * @return   boolean             true: plugin compatible; false: not compatible
   116 *
   117 */
   118 function plugin_compatible_with_this_version_staticpages($pi_name)
   119 {
   120     global $_CONF, $_DB_dbms;
   121 
   122     // check if we support the DBMS the site is running on
   123     $dbFile = $_CONF['path'] . 'plugins/' . $pi_name . '/sql/'
   124             . $_DB_dbms . '_install.php';
   125     if (! file_exists($dbFile)) {
   126         return false;
   127     }
   128 
   129     if (! function_exists('SEC_getGroupDropdown')) {
   130         return false;
   131     }
   132 
   133     if (! function_exists('SEC_createToken')) {
   134         return false;
   135     }
   136 
   137     if (! function_exists('COM_showMessageText')) {
   138         return false;
   139     }
   140 
   141     if (! function_exists('COM_setLangIdAndAttribute')) {
   142         return false;
   143     }
   144 
   145     return true;
   146 }
   147 
   148 ?>