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