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