1 | <?php |
---|
2 | |
---|
3 | global $lang, $conf, $errors; |
---|
4 | |
---|
5 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | Check Access and exit when user status is not ok | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | check_status(ACCESS_ADMINISTRATOR); |
---|
10 | |
---|
11 | if (!defined('CM_PATH')) define('CM_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
12 | |
---|
13 | //ini_set('error_reporting', E_ALL); |
---|
14 | //ini_set('display_errors', true); |
---|
15 | |
---|
16 | include_once (PHPWG_ROOT_PATH.'/include/constants.php'); |
---|
17 | |
---|
18 | load_language('plugin.lang', CM_PATH); |
---|
19 | load_language('help/plugin.lang', CM_PATH); |
---|
20 | |
---|
21 | |
---|
22 | // +-----------------------------------------------------------------------+ |
---|
23 | // | Getting plugin version | |
---|
24 | // +-----------------------------------------------------------------------+ |
---|
25 | $plugin = CM_Infos(CM_PATH); |
---|
26 | $version = $plugin['version']; |
---|
27 | |
---|
28 | |
---|
29 | // ************************************************************************* |
---|
30 | // +-----------------------------------------------------------------------+ |
---|
31 | // | Plugin Config | |
---|
32 | // +-----------------------------------------------------------------------+ |
---|
33 | // ************************************************************************* |
---|
34 | |
---|
35 | if (isset($_POST['submit']) and isset($_POST['CM_No_Comment_Anonymous']) and isset($_POST['CM_GroupComm'])) |
---|
36 | { |
---|
37 | |
---|
38 | $newconf_CM = array( |
---|
39 | $version, |
---|
40 | $_POST['CM_No_Comment_Anonymous'], |
---|
41 | $_POST['CM_GroupComm'], |
---|
42 | (isset($_POST['CM_AllowComm_Group'])?$_POST['CM_AllowComm_Group']:''), |
---|
43 | ); |
---|
44 | |
---|
45 | $conf['CommentsManager'] = serialize($newconf_CM); |
---|
46 | |
---|
47 | conf_update_param('CommentsManager', pwg_db_real_escape_string($conf['CommentsManager'])); |
---|
48 | |
---|
49 | array_push($page['infos'], l10n('CM_save_config')); |
---|
50 | } |
---|
51 | |
---|
52 | $conf_CM = unserialize($conf['CommentsManager']); |
---|
53 | |
---|
54 | |
---|
55 | //Group setting |
---|
56 | $groups[-1] = '---------'; |
---|
57 | $AllowComm = -1; |
---|
58 | |
---|
59 | //Check groups list in database |
---|
60 | $query = ' |
---|
61 | SELECT id, name |
---|
62 | FROM '.GROUPS_TABLE.' |
---|
63 | ORDER BY name ASC |
---|
64 | ;'; |
---|
65 | |
---|
66 | $result = pwg_query($query); |
---|
67 | |
---|
68 | while ($row = pwg_db_fetch_assoc($result)) |
---|
69 | { |
---|
70 | $groups[$row['id']] = $row['name']; |
---|
71 | |
---|
72 | //configuration value for users group allowed to post comments |
---|
73 | if (isset($conf_CM[3]) and $conf_CM[3] == $row['id']) |
---|
74 | { |
---|
75 | $AllowComm = $row['id']; |
---|
76 | } |
---|
77 | } |
---|
78 | |
---|
79 | //Template initialization for allowed group for comments |
---|
80 | $template->assign( |
---|
81 | 'AllowComm_Group', |
---|
82 | array( |
---|
83 | 'group_options'=> $groups, |
---|
84 | 'group_selected' => $AllowComm |
---|
85 | ) |
---|
86 | ); |
---|
87 | |
---|
88 | |
---|
89 | // Template initialization for forms and data |
---|
90 | $themeconf=$template->get_template_vars('themeconf'); |
---|
91 | $CM_theme=$themeconf['id']; |
---|
92 | |
---|
93 | $template->assign( |
---|
94 | array( |
---|
95 | 'CM_PATH' => CM_PATH, |
---|
96 | 'CM_VERSION' => $conf_CM[0], |
---|
97 | 'CM_NO_COMMENT_ANO_TRUE' => $conf_CM[1]=='true' ? 'checked="checked"' : '' , |
---|
98 | 'CM_NO_COMMENT_ANO_FALSE' => $conf_CM[1]=='false' ? 'checked="checked"' : '' , |
---|
99 | 'CM_GROUPCOMM_TRUE' => $conf_CM[2]=='true' ? 'checked="checked"' : '' , |
---|
100 | 'CM_GROUPCOMM_FALSE' => $conf_CM[2]=='false' ? 'checked="checked"' : '' , |
---|
101 | 'CM_ALLOWCOMM_GROUP' => $conf_CM[3], |
---|
102 | ) |
---|
103 | ); |
---|
104 | |
---|
105 | |
---|
106 | // +-----------------------------------------------------------------------+ |
---|
107 | // | errors display | |
---|
108 | // +-----------------------------------------------------------------------+ |
---|
109 | if (isset ($errors) and count($errors) != 0) |
---|
110 | { |
---|
111 | $template->assign('errors',array()); |
---|
112 | foreach ($errors as $error) |
---|
113 | { |
---|
114 | array_push($page['errors'], $error); |
---|
115 | } |
---|
116 | } |
---|
117 | |
---|
118 | // +-----------------------------------------------------------------------+ |
---|
119 | // | templates display | |
---|
120 | // +-----------------------------------------------------------------------+ |
---|
121 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/admin.tpl'); |
---|
122 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
123 | ?> |
---|