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 | |
---|
20 | |
---|
21 | // +-----------------------------------------------------------------------+ |
---|
22 | // | Getting plugin version | |
---|
23 | // +-----------------------------------------------------------------------+ |
---|
24 | $plugin = CM_Infos(CM_PATH); |
---|
25 | $version = $plugin['version']; |
---|
26 | |
---|
27 | |
---|
28 | // ************************************************************************* |
---|
29 | // +-----------------------------------------------------------------------+ |
---|
30 | // | Plugin Config | |
---|
31 | // +-----------------------------------------------------------------------+ |
---|
32 | // ************************************************************************* |
---|
33 | |
---|
34 | if (isset($_POST['submit']) and isset($_POST['CM_No_Comment_Anonymous']) and isset($_POST['CM_GroupComm']) and isset($_POST['CM_GroupValid1']) and isset($_POST['CM_GroupValid2'])) |
---|
35 | { |
---|
36 | |
---|
37 | $newconf_CM = array( |
---|
38 | $version, |
---|
39 | $_POST['CM_No_Comment_Anonymous'], |
---|
40 | $_POST['CM_GroupComm'], |
---|
41 | (isset($_POST['CM_AllowComm_Group'])?$_POST['CM_AllowComm_Group']:''), |
---|
42 | $_POST['CM_GroupValid1'], |
---|
43 | (isset($_POST['CM_ValidComm_Group1'])?$_POST['CM_ValidComm_Group1']:''), |
---|
44 | $_POST['CM_GroupValid2'], |
---|
45 | (isset($_POST['CM_ValidComm_Group2'])?$_POST['CM_ValidComm_Group2']:''), |
---|
46 | ); |
---|
47 | |
---|
48 | $conf['CommentsManager'] = serialize($newconf_CM); |
---|
49 | |
---|
50 | conf_update_param('CommentsManager', pwg_db_real_escape_string($conf['CommentsManager'])); |
---|
51 | |
---|
52 | array_push($page['infos'], l10n('CM_save_config')); |
---|
53 | } |
---|
54 | |
---|
55 | $conf_CM = unserialize($conf['CommentsManager']); |
---|
56 | |
---|
57 | |
---|
58 | //Group setting |
---|
59 | $groups[-1] = '---------'; |
---|
60 | $AllowComm = -1; |
---|
61 | $ValidComm1 = -1; |
---|
62 | $ValidComm2 = -1; |
---|
63 | |
---|
64 | //Check groups list in database |
---|
65 | $query = ' |
---|
66 | SELECT id, name |
---|
67 | FROM '.GROUPS_TABLE.' |
---|
68 | ORDER BY name ASC |
---|
69 | ;'; |
---|
70 | |
---|
71 | $result = pwg_query($query); |
---|
72 | |
---|
73 | while ($row = pwg_db_fetch_assoc($result)) |
---|
74 | { |
---|
75 | $groups[$row['id']] = $row['name']; |
---|
76 | |
---|
77 | //configuration value for users group allowed to post comments |
---|
78 | if (isset($conf_CM[3]) and $conf_CM[3] == $row['id']) |
---|
79 | { |
---|
80 | $AllowComm = $row['id']; |
---|
81 | } |
---|
82 | |
---|
83 | //configuration value for users group allowed to post comments |
---|
84 | if (isset($conf_CM[5]) and $conf_CM[5] == $row['id']) |
---|
85 | { |
---|
86 | $ValidComm1 = $row['id']; |
---|
87 | } |
---|
88 | |
---|
89 | //configuration value for users group allowed to post comments |
---|
90 | if (isset($conf_CM[7]) and $conf_CM[7] == $row['id']) |
---|
91 | { |
---|
92 | $ValidComm2 = $row['id']; |
---|
93 | } |
---|
94 | } |
---|
95 | |
---|
96 | //Template initialization for allowed group for comments |
---|
97 | $template->assign( |
---|
98 | 'AllowComm_Group', |
---|
99 | array( |
---|
100 | 'group_options'=> $groups, |
---|
101 | 'group_selected' => $AllowComm |
---|
102 | ) |
---|
103 | ); |
---|
104 | //Template initialization for validated group for comments |
---|
105 | $template->assign( |
---|
106 | 'ValidComm_Group1', |
---|
107 | array( |
---|
108 | 'group_options'=> $groups, |
---|
109 | 'group_selected' => $ValidComm1 |
---|
110 | ) |
---|
111 | ); |
---|
112 | //Template initialization for validated group for comments |
---|
113 | $template->assign( |
---|
114 | 'ValidComm_Group2', |
---|
115 | array( |
---|
116 | 'group_options'=> $groups, |
---|
117 | 'group_selected' => $ValidComm2 |
---|
118 | ) |
---|
119 | ); |
---|
120 | |
---|
121 | |
---|
122 | // Template initialization for forms and data |
---|
123 | $themeconf=$template->get_template_vars('themeconf'); |
---|
124 | $CM_theme=$themeconf['id']; |
---|
125 | |
---|
126 | $template->assign( |
---|
127 | array( |
---|
128 | 'CM_PATH' => CM_PATH, |
---|
129 | 'CM_CFA' => $conf['comments_forall'], |
---|
130 | 'CM_VALIDATION' => $conf['comments_validation'], |
---|
131 | 'CM_VERSION' => $conf_CM[0], |
---|
132 | 'CM_NO_COMMENT_ANO_TRUE' => $conf_CM[1]=='true' ? 'checked="checked"' : '' , |
---|
133 | 'CM_NO_COMMENT_ANO_FALSE' => $conf_CM[1]=='false' ? 'checked="checked"' : '' , |
---|
134 | 'CM_GROUPCOMM_TRUE' => $conf_CM[2]=='true' ? 'checked="checked"' : '' , |
---|
135 | 'CM_GROUPCOMM_FALSE' => $conf_CM[2]=='false' ? 'checked="checked"' : '' , |
---|
136 | 'CM_ALLOWCOMM_GROUP' => $conf_CM[3], |
---|
137 | 'CM_GROUPVALID1_TRUE' => $conf_CM[4]=='true' ? 'checked="checked"' : '' , |
---|
138 | 'CM_GROUPVALID1_FALSE' => $conf_CM[4]=='false' ? 'checked="checked"' : '' , |
---|
139 | 'CM_VALIDCOMM1_GROUP' => $conf_CM[5], |
---|
140 | 'CM_GROUPVALID2_TRUE' => $conf_CM[6]=='true' ? 'checked="checked"' : '' , |
---|
141 | 'CM_GROUPVALID2_FALSE' => $conf_CM[6]=='false' ? 'checked="checked"' : '' , |
---|
142 | 'CM_VALIDCOMM2_GROUP' => $conf_CM[7], |
---|
143 | ) |
---|
144 | ); |
---|
145 | |
---|
146 | |
---|
147 | // +-----------------------------------------------------------------------+ |
---|
148 | // | errors display | |
---|
149 | // +-----------------------------------------------------------------------+ |
---|
150 | if (isset ($errors) and count($errors) != 0) |
---|
151 | { |
---|
152 | $template->assign('errors',array()); |
---|
153 | foreach ($errors as $error) |
---|
154 | { |
---|
155 | array_push($page['errors'], $error); |
---|
156 | } |
---|
157 | } |
---|
158 | |
---|
159 | // +-----------------------------------------------------------------------+ |
---|
160 | // | templates display | |
---|
161 | // +-----------------------------------------------------------------------+ |
---|
162 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/admin.tpl'); |
---|
163 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
164 | ?> |
---|