source: extensions/Comments_on_Albums/main.inc.php @ 19396

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

update with Piwigo 2.5 features (website url, email, mandatory email and username)

File size: 3.9 KB
Line 
1<?php
2/*
3Plugin Name: Comments on Albums
4Version: auto
5Description: Activate comments on albums pages
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=512
7Author: Mistic
8Author URI: http://www.strangeplanet.fr
9*/
10
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12
13global $prefixeTable;
14
15// +-----------------------------------------------------------------------+
16//          Global variables
17// +-----------------------------------------------------------------------+
18defined('COA_ID') or define('COA_ID', basename(dirname(__FILE__)));
19define('COA_PATH' ,   PHPWG_PLUGINS_PATH . COA_ID . '/');
20define('COA_TABLE' ,  $prefixeTable . 'comments_categories');
21define('COA_ADMIN',   get_root_url().'admin.php?page=plugin-' . COA_ID);
22define('COA_VERSION', 'auto');
23
24
25// +-----------------------------------------------------------------------+
26//          Triggers
27// +-----------------------------------------------------------------------+
28add_event_handler('init', 'coa_init');
29function coa_init()
30{
31  global $user, $conf, $pwg_loaded_plugins;
32 
33  // luciano doesn't use comments
34  // incompatible with dynamic display of Stripped & Collumns
35  if ($user['theme'] == 'luciano' or $user['theme'] == 'stripped_black_bloc') return;
36 
37  // apply upgrade if needed
38  if (
39    COA_VERSION == 'auto' or
40    $pwg_loaded_plugins[COA_ID]['version'] == 'auto' or
41    version_compare($pwg_loaded_plugins[COA_ID]['version'], COA_VERSION, '<')
42  )
43  {
44    // call install function
45    include_once(COA_PATH . 'include/install.inc.php');
46    coa_install();
47   
48    // update plugin version in database
49    if ( $pwg_loaded_plugins[COA_ID]['version'] != 'auto' and COA_VERSION != 'auto' )
50    {
51      $query = '
52UPDATE '. PLUGINS_TABLE .'
53SET version = "'. COA_VERSION .'"
54WHERE id = "'. COA_ID .'"';
55      pwg_query($query);
56     
57      $pwg_loaded_plugins[COA_ID]['version'] = COA_VERSION;
58     
59      if (defined('IN_ADMIN'))
60      {
61        $_SESSION['page_infos'][] = 'Comments on Albums updated to version '. COA_VERSION;
62      }
63    }
64  }
65 
66  // add events handlers
67  if (defined('IN_ADMIN'))
68  {
69    add_event_handler('loc_begin_admin_page', 'coa_admin_intro');
70    add_event_handler('loc_end_admin', 'coa_admin_comments');
71  }
72  else
73  {
74    add_event_handler('loc_after_page_header', 'coa_albums');
75    add_event_handler('loc_after_page_header', 'coa_comments_page');
76  } 
77  add_event_handler('get_stuffs_modules', 'coa_register_stuffs_module');
78}
79
80
81// +-----------------------------------------------------------------------+
82//          Functions
83// +-----------------------------------------------------------------------+
84
85function coa_albums() 
86{
87  global $template, $page, $conf, $pwg_loaded_plugins;
88 
89  if ( !empty($page['section']) AND $page['section'] == 'categories' AND isset($page['category']) AND $page['body_id'] == 'theCategoryPage' )
90  {   
91    trigger_action('loc_begin_coa');
92    include(COA_PATH . 'include/coa_albums.php');
93  }
94}
95
96function coa_comments_page() 
97{
98  global $template, $page, $conf, $user;
99 
100  if (isset($page['body_id']) AND $page['body_id'] == 'theCommentsPage') 
101  {
102    include(COA_PATH . 'include/coa_comments_page.php');
103  }
104}
105
106function coa_admin_intro() 
107{
108  global $page;
109 
110  if ($page['page'] == 'intro') 
111  { 
112    include(COA_PATH . 'include/coa_admin_intro.php');
113  } 
114}
115
116function coa_admin_comments() 
117{
118  global $page;
119 
120  if ($page['page'] == 'comments') 
121  { 
122    include(COA_PATH . 'include/coa_admin_comments.php');
123  }
124}
125
126function coa_register_stuffs_module($modules) 
127{
128  load_language('plugin.lang', COA_PATH);
129 
130  array_push($modules, array(
131    'path' => COA_PATH . '/stuffs_module',
132    'name' => l10n('Last comments on albums'),
133    'description' => l10n('Display last posted comments on albums'),
134  ));
135
136  return $modules;
137}
138
139?>
Note: See TracBrowser for help on using the repository browser.