source: extensions/AdditionalPages/trunk/admin/config.inc.php @ 9824

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

Compatibility fixed with AMM 2.x

File size: 3.1 KB
Line 
1<?php
2
3if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
4
5$mb_conf = @unserialize($conf['blk_menubar']);
6
7// Enregistrement de la configuration
8if (isset($_POST['submit']))
9{
10  if (!$conf['AP']['user_perm'] and isset($_POST['user_perm']))
11  {
12    pwg_query('UPDATE '.ADD_PAGES_TABLE.' SET users = "guest,generic,normal,admin,webmaster";');
13  }
14  if ($conf['AP']['user_perm'] and !isset($_POST['user_perm']))
15  {
16    pwg_query('UPDATE '.ADD_PAGES_TABLE.' SET users = NULL;');
17  }
18  if ($conf['AP']['level_perm'] and !isset($_POST['level_perm']))
19  {
20    pwg_query('UPDATE '.ADD_PAGES_TABLE.' SET level = 0;');
21  }
22  if ($conf['AP']['group_perm'] and !isset($_POST['group_perm']))
23  {
24    pwg_query('UPDATE '.ADD_PAGES_TABLE.' SET groups = NULL;');
25  }
26  if ($conf['AP']['language_perm'] and !isset($_POST['language_perm']))
27  {
28    pwg_query('UPDATE '.ADD_PAGES_TABLE.' SET lang = NULL;');
29  }
30
31  $params = array('show_home', 'group_perm', 'user_perm', 'level_perm', 'language_perm');
32
33  foreach ($params as $param)
34  {
35    $conf['AP'][$param] = isset($_POST[$param]);
36  }
37
38  $conf['AP']['languages'] = array();
39        foreach($_POST['menu_lang'] as $language_code => $name)
40  {
41                if (!empty($name))
42      $conf['AP']['languages'][$language_code] = $name;
43        }
44
45  conf_update_param('additional_pages', pwg_db_real_escape_string(serialize($conf['AP'])));
46
47  if (!defined('AMM_VERSION') or version_compare(AMM_VERSION, '3.0.0', '<'))
48  {
49    if (isset($_POST['show_menu']) xor (!isset($mb_conf['mbAdditionalPages']) or $mb_conf['mbAdditionalPages'] > 0))
50    {
51      if (!isset($mb_conf['mbAdditionalPages']))
52      {
53        $last = @abs(end($mb_conf));
54        $mb_conf['mbAdditionalPages'] = $last + 50;
55      }
56      $mb_conf['mbAdditionalPages'] = (isset($_POST['show_menu']) ? +1 : -1) * abs($mb_conf['mbAdditionalPages']);
57      conf_update_param('blk_menubar', pwg_db_real_escape_string(serialize($mb_conf)));
58    }
59  }
60
61  array_push($page['infos'], l10n('ap_conf_saved'));
62}
63
64// Gestion des langues pour le bloc menu
65$template->append('language', array(
66  'LANGUAGE_NAME' => l10n('Default'),
67  'LANGUAGE_CODE' => 'default',
68  'VALUE' => @$conf['AP']['languages']['default'],
69  )
70);
71foreach (get_languages() as $language_code => $language_name)
72{
73        $template->append('language', array(
74    'LANGUAGE_NAME' => $language_name,
75    'LANGUAGE_CODE' => $language_code,
76    'VALUE' => isset($conf['AP']['languages'][$language_code]) ? $conf['AP']['languages'][$language_code] : '',
77    )
78  );
79}
80
81// Parametrage du template
82$template->assign(array(
83  'ap_conf' => $conf['AP'],
84  'SHOW_MENU' => (!isset($mb_conf['mbAdditionalPages']) or $mb_conf['mbAdditionalPages'] > 0),
85  'AMM_INSTALLED' => (defined('AMM_VERSION') and version_compare(AMM_VERSION, '3.0.0', '>=')),
86  )
87);
88
89if (defined('AMM_VERSION') and version_compare(AMM_VERSION, '3.0.0', '>='))
90{
91  load_language('plugin.lang', AMM_PATH);
92  $template->assign('AMM_URI', get_admin_plugin_menu_link(AMM_PATH.'admin/plugin_admin.php'));
93}
94
95$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/template/config.tpl'));
96$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
97
98?>
Note: See TracBrowser for help on using the repository browser.