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