[5179] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: NBC News |
---|
| 4 | Version: 2.0a |
---|
| 5 | Description: Permet de gerer l'afficher des news sur la 1ere page |
---|
| 6 | Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=202 |
---|
| 7 | Author: Nicco, Eric |
---|
| 8 | Author URI: http://gallery-nicco.no-ip.org/ - http://www.infernoweb.net |
---|
| 9 | */ |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | /* |
---|
| 13 | |
---|
| 14 | ***** TODO List ***** |
---|
| 15 | |
---|
| 16 | Liste 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 | |
---|
| 25 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 26 | define('NBC_NEWS_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
| 27 | |
---|
| 28 | include_once(NBC_NEWS_PATH.'include/constants.php'); |
---|
| 29 | include_once(NBC_NEWS_PATH.'include/functions_news.inc.php'); |
---|
| 30 | |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | global $conf, $user, $im_priority; |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | if (isset($conf['IndexManager'])) |
---|
| 38 | { |
---|
| 39 | include_once( PHPWG_PLUGINS_PATH . 'IndexManager/index_manager.php' ); |
---|
| 40 | check_indexmanager('NewsOnIndex'); |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | add_event_handler('get_admin_plugin_menu_links', 'nbc_News_admin_menu'); |
---|
| 46 | |
---|
| 47 | function 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 */ |
---|
| 63 | add_event_handler('delete_user', 'nbc_News_Deluser'); |
---|
| 64 | |
---|
| 65 | function 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 | |
---|
| 85 | if ( 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 | |
---|
| 90 | function 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 | |
---|
| 112 | add_event_handler('loc_end_index' , 'nbc_NewsOnIndex', isset($im_priority) ? $im_priority['NewsOnIndex'] : 40); |
---|
| 113 | |
---|
| 114 | function 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 | |
---|
| 126 | add_event_handler('loc_end_page_header', 'nbc_NewsAddCSS' ); |
---|
| 127 | |
---|
| 128 | function 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 | ?> |
---|