source: extensions/AdditionalPages/additional_page.php @ 4080

Last change on this file since 4080 was 3609, checked in by patdenice, 15 years ago

Convert all php and tpl files in Unix format for my plugins.

File size: 2.0 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$template->assign(array(
55  'TITLE' => $result['title'],
56  'PLUGIN_INDEX_CONTENT_BEGIN' => $result['text']));
57if (isset($ap_conf[2]) and $ap_conf[2] == 'on')
58{
59  $template->assign('PLUGIN_INDEX_ACTIONS' , '
60    <li><a href="' . make_index_url() . '" title="' . l10n('return to homepage') . '">
61      <img src="' . $template->get_themeconf('icon_dir') . '/home.png" class="button" alt="' . l10n('home') . '"/></a>
62    </li>');
63}
64if (is_admin())
65{
66  $template->assign('U_EDIT', PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . AP_DIR . '%2Fadmin%2Fadd_page.php&amp;edit=' . $ap_id[0]);
67}
68
69$template->clear_assign(array('U_MODE_POSTED', 'U_MODE_CREATED'));
70
71?>
Note: See TracBrowser for help on using the repository browser.