source: extensions/GuestBook/main.inc.php @ 24889

Last change on this file since 24889 was 24889, checked in by mistic100, 11 years ago

use my plugin architecture, add options to hide the page for guests, fix admin links in mails

File size: 2.3 KB
Line 
1<?php
2/*
3Plugin Name: GuestBook
4Version: auto
5Description: Add a guestbook to the gallery
6Plugin URI: auto
7Author: Mistic
8Author URI: http://www.strangeplanet.fr
9*/
10
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12
13global $prefixeTable;
14
15
16defined('GUESTBOOK_ID') or define('GUESTBOOK_ID', basename(dirname(__FILE__)));
17define('GUESTBOOK_PATH' ,   PHPWG_PLUGINS_PATH . GUESTBOOK_ID . '/');
18define('GUESTBOOK_TABLE' ,  $prefixeTable . 'guestbook');
19define('GUESTBOOK_ADMIN',   get_root_url().'admin.php?page=plugin-' . GUESTBOOK_ID);
20define('GUESTBOOK_URL',     get_absolute_root_url() . make_index_url(array('section' => 'guestbook')));
21define('GUESTBOOK_VERSION', 'auto');
22
23
24include_once(GUESTBOOK_PATH . 'include/events.inc.php');
25
26add_event_handler('init', 'guestbook_init');
27
28// admin page
29if (defined('IN_ADMIN'))
30{
31  add_event_handler('get_admin_plugin_menu_links', 'gb_admin_menu');
32}
33
34// menu entry
35add_event_handler('blockmanager_apply', 'gb_menubar_apply', EVENT_HANDLER_PRIORITY_NEUTRAL+10);
36
37// guestbook section
38add_event_handler('loc_end_section_init', 'gb_section_init');
39add_event_handler('loc_end_index', 'gb_index');
40
41// stuff
42// add_event_handler('get_stuffs_modules', 'gb_register_stuffs_module')
43
44
45function guestbook_init()
46{
47  global $conf, $pwg_loaded_plugins;
48 
49  // apply upgrade if needed
50  if (
51    GUESTBOOK_VERSION == 'auto' or
52    $pwg_loaded_plugins[GUESTBOOK_ID]['version'] == 'auto' or
53    version_compare($pwg_loaded_plugins[GUESTBOOK_ID]['version'], GUESTBOOK_VERSION, '<')
54  )
55  {
56    // call install function
57    include_once(GUESTBOOK_PATH . 'include/install.inc.php');
58    guestbook_install();
59   
60    // update plugin version in database
61    if ( $pwg_loaded_plugins[GUESTBOOK_ID]['version'] != 'auto' and GUESTBOOK_VERSION != 'auto' )
62    {
63      $query = '
64UPDATE '. PLUGINS_TABLE .'
65SET version = "'. GUESTBOOK_VERSION .'"
66WHERE id = "'. GUESTBOOK_ID .'"';
67      pwg_query($query);
68     
69      $pwg_loaded_plugins[GUESTBOOK_ID]['version'] = GUESTBOOK_VERSION;
70     
71      if (defined('IN_ADMIN'))
72      {
73        $_SESSION['page_infos'][] = 'GuestBook updated to version '. GUESTBOOK_VERSION;
74      }
75    }
76  }
77 
78  // load plugin language file
79  load_language('plugin.lang', GUESTBOOK_PATH);
80 
81  // prepare plugin configuration
82  $conf['guestbook'] = unserialize($conf['guestbook']);
83}
Note: See TracBrowser for help on using the repository browser.