1 | <?php |
---|
2 | |
---|
3 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
4 | |
---|
5 | global $template, $user; |
---|
6 | |
---|
7 | $page['section'] = 'additional_page'; |
---|
8 | $identifier = $page['is_homepage'] ? $conf['additional_pages']['homepage'] : $tokens[1]; |
---|
9 | |
---|
10 | load_language('plugin.lang.php', AP_PATH); |
---|
11 | |
---|
12 | if (function_exists('get_extended_desc')) |
---|
13 | add_event_handler('AP_render_content', 'get_extended_desc'); |
---|
14 | |
---|
15 | // Récupération des données de la page |
---|
16 | $query = 'SELECT id, title , content, users, groups, permalink, standalone |
---|
17 | FROM ' . ADD_PAGES_TABLE . ' |
---|
18 | '; |
---|
19 | $query .= is_numeric($identifier) ? |
---|
20 | 'WHERE id = '.$identifier.';' : |
---|
21 | 'WHERE permalink = "'.$identifier.'";'; |
---|
22 | |
---|
23 | $row = mysql_fetch_assoc(pwg_query($query)); |
---|
24 | |
---|
25 | if (empty($row)) |
---|
26 | { |
---|
27 | if ($page['is_homepage']) return; |
---|
28 | page_not_found('Requested page does not exist'); |
---|
29 | } |
---|
30 | |
---|
31 | if (is_numeric($identifier) and !empty($row['permalink']) and !$page['is_homepage']) |
---|
32 | { |
---|
33 | redirect(make_index_url().'/page/' . $row['permalink']); |
---|
34 | } |
---|
35 | |
---|
36 | $page['additional_page'] = array( |
---|
37 | 'id' => $row['id'], |
---|
38 | 'permalink' => @$row['permalink'], |
---|
39 | 'title' => trigger_event('AP_render_content', $row['title']), |
---|
40 | 'content' => trigger_event('AP_render_content', $row['content']), |
---|
41 | 'standalone' => ($row['standalone'] == 'true') |
---|
42 | ); |
---|
43 | |
---|
44 | // Utilisateurs autorisés |
---|
45 | if (!empty($row['users'])) |
---|
46 | { |
---|
47 | $authorized_users = explode(',', $row['users']); |
---|
48 | if (!is_admin() and $conf['additional_pages']['user_perm'] and !in_array($user['status'], $authorized_users)) |
---|
49 | { |
---|
50 | if ($page['is_homepage']) return; |
---|
51 | page_forbidden(l10n('You are not authorized to access the requested page')); |
---|
52 | } |
---|
53 | } |
---|
54 | |
---|
55 | // Groupe autorisé |
---|
56 | if (!empty($row['groups'])) |
---|
57 | { |
---|
58 | $q = 'SELECT * |
---|
59 | FROM ' . USER_GROUP_TABLE . ' |
---|
60 | WHERE user_id = ' . $user['id'] . ' AND group_id IN (' . $row['groups'] . ');'; |
---|
61 | $array = mysql_fetch_array(pwg_query($q)); |
---|
62 | if (!is_admin() and $conf['additional_pages']['group_perm'] and empty($array)) |
---|
63 | { |
---|
64 | if ($page['is_homepage']) return; |
---|
65 | page_forbidden(l10n('You are not authorized to access the requested page')); |
---|
66 | } |
---|
67 | } |
---|
68 | |
---|
69 | if ($page['additional_page']['standalone']) |
---|
70 | { |
---|
71 | echo $page['additional_page']['content']; |
---|
72 | exit; |
---|
73 | } |
---|
74 | |
---|
75 | add_event_handler('loc_end_index', 'ap_set_index'); |
---|
76 | |
---|
77 | function ap_set_index() |
---|
78 | { |
---|
79 | global $template, $page, $conf; |
---|
80 | |
---|
81 | $template->assign(array( |
---|
82 | 'TITLE' => $page['additional_page']['title'], |
---|
83 | 'PLUGIN_INDEX_CONTENT_BEGIN' => $page['additional_page']['content'], |
---|
84 | ) |
---|
85 | ); |
---|
86 | |
---|
87 | if ($conf['additional_pages']['show_home']) |
---|
88 | { |
---|
89 | $template->assign('PLUGIN_INDEX_ACTIONS' , ' |
---|
90 | <li><a href="'.make_index_url().'/categories" title="' . l10n('return to homepage') . '"> |
---|
91 | <img src="' . $template->get_themeconf('icon_dir') . '/home.png" class="button" alt="' . l10n('home') . '"/></a> |
---|
92 | </li>'); |
---|
93 | } |
---|
94 | if (is_admin()) |
---|
95 | { |
---|
96 | $template->assign('U_EDIT', PHPWG_ROOT_PATH.'admin.php?page=plugin&section='.AP_DIR.'%2Fadmin%2Fadmin.php&tab=edit_page&edit='.$page['additional_page']['id'].'&redirect=true'); |
---|
97 | } |
---|
98 | $template->clear_assign(array('U_MODE_POSTED', 'U_MODE_CREATED')); |
---|
99 | } |
---|
100 | |
---|
101 | ?> |
---|