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']) and isset($_POST['CM_GroupValid'])) |
---|
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 | $_POST['CM_GroupValid'], |
---|
44 | (isset($_POST['CM_ValidComm_Group'])?$_POST['CM_ValidComm_Group']:''), |
---|
45 | ); |
---|
46 | |
---|
47 | $conf['CommentsManager'] = serialize($newconf_CM); |
---|
48 | |
---|
49 | conf_update_param('CommentsManager', pwg_db_real_escape_string($conf['CommentsManager'])); |
---|
50 | |
---|
51 | array_push($page['infos'], l10n('CM_save_config')); |
---|
52 | } |
---|
53 | |
---|
54 | $conf_CM = unserialize($conf['CommentsManager']); |
---|
55 | |
---|
56 | |
---|
57 | //Group setting |
---|
58 | $groups[-1] = '---------'; |
---|
59 | $AllowComm = -1; |
---|
60 | $ValidComm = -1; |
---|
61 | |
---|
62 | //Check groups list in database |
---|
63 | $query = ' |
---|
64 | SELECT id, name |
---|
65 | FROM '.GROUPS_TABLE.' |
---|
66 | ORDER BY name ASC |
---|
67 | ;'; |
---|
68 | |
---|
69 | $result = pwg_query($query); |
---|
70 | |
---|
71 | while ($row = pwg_db_fetch_assoc($result)) |
---|
72 | { |
---|
73 | $groups[$row['id']] = $row['name']; |
---|
74 | |
---|
75 | //configuration value for users group allowed to post comments |
---|
76 | if (isset($conf_CM[3]) and $conf_CM[3] == $row['id']) |
---|
77 | { |
---|
78 | $AllowComm = $row['id']; |
---|
79 | } |
---|
80 | |
---|
81 | //configuration value for users group allowed to post comments |
---|
82 | if (isset($conf_CM[5]) and $conf_CM[5] == $row['id']) |
---|
83 | { |
---|
84 | $ValidComm = $row['id']; |
---|
85 | } |
---|
86 | } |
---|
87 | |
---|
88 | //Template initialization for allowed group for comments |
---|
89 | $template->assign( |
---|
90 | 'AllowComm_Group', |
---|
91 | array( |
---|
92 | 'group_options'=> $groups, |
---|
93 | 'group_selected' => $AllowComm |
---|
94 | ) |
---|
95 | ); |
---|
96 | //Template initialization for validated group for comments |
---|
97 | $template->assign( |
---|
98 | 'ValidComm_Group', |
---|
99 | array( |
---|
100 | 'group_options'=> $groups, |
---|
101 | 'group_selected' => $ValidComm |
---|
102 | ) |
---|
103 | ); |
---|
104 | |
---|
105 | |
---|
106 | // Template initialization for forms and data |
---|
107 | $themeconf=$template->get_template_vars('themeconf'); |
---|
108 | $CM_theme=$themeconf['id']; |
---|
109 | |
---|
110 | $template->assign( |
---|
111 | array( |
---|
112 | 'CM_PATH' => CM_PATH, |
---|
113 | 'CM_VERSION' => $conf_CM[0], |
---|
114 | 'CM_NO_COMMENT_ANO_TRUE' => $conf_CM[1]=='true' ? 'checked="checked"' : '' , |
---|
115 | 'CM_NO_COMMENT_ANO_FALSE' => $conf_CM[1]=='false' ? 'checked="checked"' : '' , |
---|
116 | 'CM_GROUPCOMM_TRUE' => $conf_CM[2]=='true' ? 'checked="checked"' : '' , |
---|
117 | 'CM_GROUPCOMM_FALSE' => $conf_CM[2]=='false' ? 'checked="checked"' : '' , |
---|
118 | 'CM_ALLOWCOMM_GROUP' => $conf_CM[3], |
---|
119 | 'CM_GROUPVALID_TRUE' => $conf_CM[4]=='true' ? 'checked="checked"' : '' , |
---|
120 | 'CM_GROUPVALID_FALSE' => $conf_CM[4]=='false' ? 'checked="checked"' : '' , |
---|
121 | 'CM_VALIDCOMM_GROUP' => $conf_CM[5], |
---|
122 | ) |
---|
123 | ); |
---|
124 | |
---|
125 | |
---|
126 | // +-----------------------------------------------------------------------+ |
---|
127 | // | errors display | |
---|
128 | // +-----------------------------------------------------------------------+ |
---|
129 | if (isset ($errors) and count($errors) != 0) |
---|
130 | { |
---|
131 | $template->assign('errors',array()); |
---|
132 | foreach ($errors as $error) |
---|
133 | { |
---|
134 | array_push($page['errors'], $error); |
---|
135 | } |
---|
136 | } |
---|
137 | |
---|
138 | // +-----------------------------------------------------------------------+ |
---|
139 | // | templates display | |
---|
140 | // +-----------------------------------------------------------------------+ |
---|
141 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/admin.tpl'); |
---|
142 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
143 | ?> |
---|