source: extensions/AdditionalPages/additional_page.php @ 8804

Last change on this file since 8804 was 8132, checked in by patdenice, 13 years ago

Extended description tags can be used in additional pages.

File size: 2.2 KB
Line 
1<?php
2
3if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
4
5global $template, $conf, $user;
6
7load_language('plugin.lang.php', AP_PATH);
8
9$ap_id = explode('additional_page/' , $_SERVER['REQUEST_URI']);
10$ap_id = explode('&' , $ap_id[1]);
11$ap_conf = explode ("," , $conf['additional_pages']);
12
13// Récupération des données de la page
14$q = 'SELECT title , pos , text
15FROM ' . ADD_PAGES_TABLE . '
16WHERE id = ' . $ap_id[0] . ';';
17$result = mysql_fetch_assoc(pwg_query($q));
18
19if (empty($result))
20{
21  page_not_found('This page does not exist', 'index.php?');
22}
23
24// Utilisateurs autorisés
25if (strpos($result['title'] , 'user_id='))
26{
27  $array = explode('/user_id=' , $result['title']);
28  $result['title'] = $array[0];
29  $authorized_users = explode(',', $array[1]);
30  if (!is_admin() and $ap_conf[7] == 'on' and !in_array($user['status'], $authorized_users))
31  {
32        page_not_found('User not allowed', 'index.php?');
33  }
34}
35
36// Groupe autorisé
37if (strpos($result['title'] , 'group_id='))
38{
39  $array = explode('/group_id=' , $result['title']);
40  $result['title'] = $array[0];
41  $authorized_groups = $array[1];
42
43  $q = 'SELECT *
44FROM ' . USER_GROUP_TABLE . '
45WHERE user_id = ' . $user['id'] . ' AND group_id IN (' . $authorized_groups . ');';
46  $array = mysql_fetch_array(pwg_query($q));
47  if (!is_admin() and $ap_conf[6] == 'on' and empty($array))
48  {
49        page_not_found('User not allowed', 'index.php?');
50  }
51}
52
53// Envoi de la page
54// Extended description
55if (function_exists('get_extended_desc'))
56  add_event_handler('AP_render_content', 'get_extended_desc');
57
58$template->assign(array(
59  'TITLE' => trigger_event('AP_render_content', $result['title']),
60  'PLUGIN_INDEX_CONTENT_BEGIN' => trigger_event('AP_render_content', $result['text'])));
61if (isset($ap_conf[2]) and $ap_conf[2] == 'on')
62{
63  $template->assign('PLUGIN_INDEX_ACTIONS' , '
64    <li><a href="' . make_index_url() . '" title="' . l10n('return to homepage') . '">
65      <img src="' . $template->get_themeconf('icon_dir') . '/home.png" class="button" alt="' . l10n('home') . '"/></a>
66    </li>');
67}
68if (is_admin())
69{
70  $template->assign('U_EDIT', PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . AP_DIR . '%2Fadmin%2Fadd_page.php&amp;edit=' . $ap_id[0]);
71}
72
73$template->clear_assign(array('U_MODE_POSTED', 'U_MODE_CREATED'));
74
75?>
Note: See TracBrowser for help on using the repository browser.