source: extensions/NBC_News/trunk/main.inc.php @ 7690

Last change on this file since 7690 was 5179, checked in by Eric, 14 years ago

[NBC_News]

  • Initial commit for Piwigo 2.0.x : Not fully functionnal and a lot work to do...
  • Property svn:eol-style set to LF
File size: 2.8 KB
Line 
1<?php
2/*
3Plugin Name: NBC News
4Version: 2.0a
5Description: Permet de gerer l'afficher des news sur la 1ere page
6Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=202
7Author: Nicco, Eric
8Author URI: http://gallery-nicco.no-ip.org/ - http://www.infernoweb.net
9*/
10
11
12/*
13
14 ***** TODO List *****
15
16Liste des choses a faire :
17
18-- gestion de la suppression d un groupe
19
20-- gestion d'une partie résumé un peu comme extended Presentation
21*/
22
23
24
25if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
26define('NBC_NEWS_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
27
28include_once(NBC_NEWS_PATH.'include/constants.php');
29include_once(NBC_NEWS_PATH.'include/functions_news.inc.php');
30
31
32
33global $conf, $user, $im_priority;
34
35
36
37if (isset($conf['IndexManager']))
38{
39        include_once( PHPWG_PLUGINS_PATH . 'IndexManager/index_manager.php' );
40        check_indexmanager('NewsOnIndex');
41}
42
43
44
45add_event_handler('get_admin_plugin_menu_links', 'nbc_News_admin_menu');
46
47function nbc_News_admin_menu($menu)
48{
49  array_push($menu,
50    array(
51      'NAME' => 'News',
52      'URL'  => get_admin_plugin_menu_link(NBC_NEWS_PATH.'admin/news_admin.php')
53    )
54  );
55 
56  return $menu;
57}
58
59
60
61
62/* suppression de user */
63add_event_handler('delete_user', 'nbc_News_Deluser');
64
65function nbc_News_Deluser($user_id)
66{
67  $tables = array(
68    NEWS_USER_ACCESS_TABLE,
69    NEWS_USER_REFUSED_TABLE,
70  );
71
72  foreach ($tables as $table)
73  {
74    $query = '
75      DELETE FROM '.$table.'
76      WHERE user_id = '.$user_id.'
77    ;';
78    pwg_query($query);
79  }
80
81}
82
83
84
85if ( script_basename() == 'admin' and isset($_GET['page']) and $_GET['page'] == 'group_list' and isset($_GET['delete']) and is_numeric($_GET['delete']) )
86{
87  add_event_handler('loc_begin_page_tail', 'nbc_News_Delgroup');
88}
89
90function nbc_News_Delgroup()
91{
92  if ( !is_adviser() )
93  {
94    $tables = array(
95      NEWS_GROUP_ACCESS_TABLE,
96      NEWS_GROUP_REFUSED_TABLE,
97    );
98 
99    foreach ($tables as $table)
100    {
101      $query = '
102        DELETE FROM '.$table.'
103        WHERE group_id = '. $_GET['delete'].'
104      ;';
105      pwg_query($query);
106    }
107  }
108}
109
110
111
112add_event_handler('loc_end_index' , 'nbc_NewsOnIndex', isset($im_priority) ? $im_priority['NewsOnIndex'] : 40);
113
114function nbc_NewsOnIndex()
115{
116  global $page, $prefixeTable, $template;
117
118  if (isset($page['body_id']) and $page['section'] == 'categories' and (!isset($page['category'])))
119  {
120    include_once(NBC_NEWS_PATH.'NewsOnIndex.php');
121  }
122}
123
124
125
126add_event_handler('loc_end_page_header', 'nbc_NewsAddCSS' );
127
128function nbc_NewsAddCSS()
129{
130  global $template, $user;
131 
132  $template -> assign(
133    'head_element', array (
134    'CONTENT' => '<link rel="stylesheet" type="text/css" href="'.NBC_NEWS_PATH.'template/news.css">
135                  <link rel="stylesheet" type="text/css" href="'.NBC_NEWS_PATH.'template/'.$user['template'].'/theme/'.$user['theme'].'/news.css">',
136    )
137  );
138}
139
140?>
Note: See TracBrowser for help on using the repository browser.