[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); |
---|
| 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 | |
---|
[11070] | 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'])) |
---|
[11017] | 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']:''), |
---|
[11070] | 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']:''), |
---|
[11017] | 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; |
---|
[11070] | 61 | $ValidComm1 = -1; |
---|
| 62 | $ValidComm2 = -1; |
---|
[11017] | 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 | } |
---|
[11069] | 82 | |
---|
| 83 | //configuration value for users group allowed to post comments |
---|
| 84 | if (isset($conf_CM[5]) and $conf_CM[5] == $row['id']) |
---|
| 85 | { |
---|
[11070] | 86 | $ValidComm1 = $row['id']; |
---|
[11069] | 87 | } |
---|
[11070] | 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 | } |
---|
[11017] | 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 | ); |
---|
[11069] | 104 | //Template initialization for validated group for comments |
---|
| 105 | $template->assign( |
---|
[11070] | 106 | 'ValidComm_Group1', |
---|
[11069] | 107 | array( |
---|
| 108 | 'group_options'=> $groups, |
---|
[11070] | 109 | 'group_selected' => $ValidComm1 |
---|
[11069] | 110 | ) |
---|
| 111 | ); |
---|
[11070] | 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 | ); |
---|
[11017] | 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, |
---|
[11070] | 129 | 'CM_CFA' => $conf['comments_forall'], |
---|
[11254] | 130 | 'CM_VALIDATION' => $conf['comments_validation'], |
---|
[11017] | 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], |
---|
[11070] | 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], |
---|
[11017] | 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 | ?> |
---|