[19] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | load_plugin_textdomain('xpressme', 'wp-content/plugins/xpressme/language');
|
---|
| 4 |
|
---|
| 5 | class XPressME_Class{
|
---|
| 6 | var $pluginName = 'xpressme';
|
---|
| 7 | var $is_use_xoops_upload_path;
|
---|
[26] | 8 | var $is_theme_sidebar_disp;
|
---|
[28] | 9 | var $is_save_post_revision;
|
---|
[32] | 10 | var $is_postnavi_title_disp;
|
---|
| 11 | var $is_left_postnavi_old;
|
---|
| 12 | var $old_post_link_text;
|
---|
| 13 | var $newer_post_link_text;
|
---|
[51] | 14 | var $is_author_view_count;
|
---|
[76] | 15 | var $groupe_role_serial;
|
---|
| 16 | var $groupe_role;
|
---|
[32] | 17 |
|
---|
[19] | 18 | //constructor
|
---|
[20] | 19 | function XPressME_Class()
|
---|
[19] | 20 | {
|
---|
[76] | 21 | global $xoops_db;
|
---|
| 22 |
|
---|
[19] | 23 | $this->setdefault(); //not setting propaty load
|
---|
| 24 | $this->SettingValueRead();
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 |
|
---|
| 28 | function add_option_page()
|
---|
| 29 | {
|
---|
| 30 | add_options_page('XPressME', __('XPressME Settings', 'xpressme'), 8, 'xpressme_config', array(&$this, 'option_page'));
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | function add_admin_head()
|
---|
| 34 | {
|
---|
| 35 | // add header text
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 |
|
---|
| 39 | //Set Default Value
|
---|
| 40 | function setDefault()
|
---|
| 41 | {
|
---|
| 42 | $this->is_use_xoops_upload_path = true;
|
---|
[26] | 43 | $this->is_theme_sidebar_disp = true;
|
---|
[28] | 44 | $this->is_save_post_revision = true;
|
---|
[32] | 45 | $this->is_postnavi_title_disp = true;
|
---|
| 46 | $this->is_left_postnavi_old = true;
|
---|
[79] | 47 | $this->old_post_link_text = __('to Old Post', 'xpressme');
|
---|
| 48 | $this->newer_post_link_text = __('to Newer Post', 'xpressme');
|
---|
[51] | 49 | $this->is_author_view_count = false;
|
---|
[19] | 50 | }
|
---|
| 51 |
|
---|
| 52 | function SettingValueRead()
|
---|
| 53 | {
|
---|
[76] | 54 | global $xoops_db;
|
---|
[19] | 55 | $options = get_option('xpressme_option');
|
---|
| 56 | if (!$options) {
|
---|
| 57 | $this->setDefault();
|
---|
| 58 | $this->SettingValueWrite('add_new');
|
---|
| 59 | } else {
|
---|
| 60 | foreach ($options as $option_name => $option_value){
|
---|
| 61 | $this-> {$option_name} = $option_value;
|
---|
| 62 | }
|
---|
| 63 | }
|
---|
[81] | 64 | if (!empty($xoops_db)) // at install trap
|
---|
| 65 | $this->GroupeRoleRead();
|
---|
[19] | 66 | }
|
---|
| 67 |
|
---|
| 68 | // mode 0:add 1:update
|
---|
| 69 | function SettingValueWrite($mode)
|
---|
| 70 | {
|
---|
| 71 | $write_options = array (
|
---|
[26] | 72 | 'is_use_xoops_upload_path' => $this->is_use_xoops_upload_path ,
|
---|
[32] | 73 | 'is_theme_sidebar_disp' => $this->is_theme_sidebar_disp ,
|
---|
| 74 | 'is_save_post_revision' => $this->is_save_post_revision ,
|
---|
| 75 | 'is_postnavi_title_disp' => $this->is_postnavi_title_disp ,
|
---|
| 76 | 'is_left_postnavi_old' => $this->is_left_postnavi_old ,
|
---|
| 77 | 'old_post_link_text' => $this->old_post_link_text ,
|
---|
[51] | 78 | 'newer_post_link_text' => $this->newer_post_link_text,
|
---|
[79] | 79 | 'is_author_view_count' => $this->is_author_view_count
|
---|
[19] | 80 | );
|
---|
| 81 | if ($mode == 'add_new') {
|
---|
| 82 | add_option('xpressme_option', $write_options);
|
---|
| 83 | } else {
|
---|
| 84 | update_option("xpressme_option", $write_options);
|
---|
| 85 | }
|
---|
| 86 | }
|
---|
[20] | 87 |
|
---|
[76] | 88 | function GroupeRoleRead() {
|
---|
| 89 | global $xoops_db;
|
---|
| 90 |
|
---|
| 91 | // table sync
|
---|
| 92 | $table = get_wp_prefix() . 'group_role';
|
---|
| 93 | $xoops_group = get_xoops_prefix() . 'groups';
|
---|
| 94 | $sql= "SELECT * FROM $table";
|
---|
| 95 | $before_groupes = $xoops_db->get_results($sql);
|
---|
| 96 |
|
---|
| 97 | $sql = "DELETE FROM $table";
|
---|
| 98 | $xoops_db->query($sql);
|
---|
| 99 |
|
---|
| 100 |
|
---|
| 101 | $sql= "SELECT * FROM $xoops_group WHERE group_type <> 'Anonymous'";
|
---|
| 102 | $groupes = $xoops_db->get_results($sql);
|
---|
| 103 | $insert_sql = '';
|
---|
| 104 | foreach ($groupes as $groupe) {
|
---|
| 105 | $role = '';
|
---|
| 106 | foreach ($before_groupes as $before_groupe) {
|
---|
[81] | 107 | if ($groupe->groupid == $before_groupe->groupid) {
|
---|
| 108 | $role = $before_groupe->role;
|
---|
| 109 | $login_all = $before_groupe->login_all;
|
---|
| 110 | }
|
---|
[76] | 111 | }
|
---|
| 112 |
|
---|
| 113 | $insert_sql = "INSERT INTO $table ";
|
---|
[81] | 114 | $insert_sql .= "(groupid , name , description , group_type , role , login_all) ";
|
---|
[76] | 115 | $insert_sql .= "VALUES (";
|
---|
| 116 | $insert_sql .= $groupe->groupid . ', ';
|
---|
| 117 | $insert_sql .= "'" . $groupe->name . "' , ";
|
---|
| 118 | $insert_sql .= "'" . $groupe->description . "' , ";
|
---|
| 119 | $insert_sql .= "'" . $groupe->group_type . "' , ";
|
---|
[81] | 120 | $insert_sql .= "'" . $role . "' , ";
|
---|
| 121 | $insert_sql .= $login_all . ")";
|
---|
[76] | 122 | $xoops_db->query($insert_sql);
|
---|
| 123 | }
|
---|
| 124 |
|
---|
| 125 | $sql= "SELECT * FROM $table";
|
---|
| 126 |
|
---|
| 127 | $this->groupe_role = $xoops_db->get_results($sql);
|
---|
| 128 | $sql= "SELECT * FROM $table";
|
---|
| 129 | }
|
---|
| 130 |
|
---|
[20] | 131 | function ReadPostData()
|
---|
| 132 | {
|
---|
| 133 | $this->is_use_xoops_upload_path = stripslashes(trim($_POST['ch_is_use_xoops_upload_path']));
|
---|
[26] | 134 | $this->is_theme_sidebar_disp = stripslashes(trim($_POST['ch_is_theme_sidebar_disp']));
|
---|
[28] | 135 | $this->is_save_post_revision = stripslashes(trim($_POST['ch_is_save_post_revision']));
|
---|
[32] | 136 | $this->is_postnavi_title_disp = stripslashes(trim($_POST['ch_is_postnavi_title_disp']));
|
---|
| 137 | $this->is_left_postnavi_old = stripslashes(trim($_POST['ch_is_left_postnavi_old']));
|
---|
| 138 | $this->old_post_link_text = stripslashes($_POST['ch_old_post_link_text']);
|
---|
[79] | 139 | if(empty($this->old_post_link_text)) $this->old_post_link_text = __('to Old Post', 'xpressme');
|
---|
[32] | 140 | $this->newer_post_link_text = stripslashes($_POST['ch_newer_post_link_text']);
|
---|
[79] | 141 | if(empty($this->newer_post_link_text)) $this->newer_post_link_text = __('to Newer Post', 'xpressme');
|
---|
[51] | 142 | $this->is_author_view_count = stripslashes(trim($_POST['ch_is_author_view_count']));
|
---|
[32] | 143 |
|
---|
[81] | 144 | global $xoops_db;
|
---|
| 145 | $table = get_wp_prefix() . 'group_role';
|
---|
| 146 | // $sql= "SELECT * FROM $table";
|
---|
| 147 | // $this->groupe_role = $xoops_db->get_results($sql); // before Read
|
---|
| 148 |
|
---|
| 149 | foreach ($this->groupe_role as $groupe) {
|
---|
| 150 | $post_name = 'role_gid_' . $groupe->groupid;
|
---|
| 151 | $role = stripslashes(trim($_POST[$post_name]));
|
---|
| 152 | $post_name = 'login_all_gid_' . $groupe->groupid;
|
---|
| 153 | $login_all = stripslashes(trim($_POST[$post_name]));
|
---|
| 154 | if (empty($login_all)) $login_all = '0';
|
---|
| 155 | $groupe->role = $role;
|
---|
| 156 | $groupe->login_all = $login_all;
|
---|
| 157 | $update_sql = "UPDATE $table ";
|
---|
| 158 | $update_sql .= 'SET ';
|
---|
| 159 | $update_sql .= "role = '$role' , ";
|
---|
| 160 | $update_sql .= "login_all = $login_all ";
|
---|
| 161 | $update_sql .= "WHERE (groupid = '$groupe->groupid' )";
|
---|
| 162 | $xoops_db->query($update_sql);
|
---|
| 163 | }
|
---|
[20] | 164 | }
|
---|
[21] | 165 |
|
---|
| 166 | function yes_no_radio_option($option_name,$option_desc,$yes = '',$no= ''){
|
---|
[32] | 167 | if (empty( $yes )) $yes = __('YES','xpressme') ;
|
---|
| 168 | if (empty( $no )) $no = __('NO','xpressme') ;
|
---|
| 169 | $value = $this->{$option_name};
|
---|
| 170 | $ans_name = 'ch_' . $option_name;
|
---|
| 171 |
|
---|
| 172 | $form = "<tr>\n";
|
---|
| 173 | $form .= '<th><label for="images_to_link">' . $option_desc . "</label></th>\n";
|
---|
| 174 | $form .= "<td>\n";
|
---|
| 175 | if ($value){
|
---|
| 176 | $form .= "<label><input type='radio' name='". $ans_name . "' value='1' checked='checked' />" . $yes ."</label><br />\n";
|
---|
| 177 | $form .= "<label><input type='radio' name='". $ans_name . "' value='0' />". $no . "</label>\n";
|
---|
| 178 | }else{
|
---|
| 179 | $form .= "<label><input type='radio' name='". $ans_name . "' value='1' />" . $yes . "</label><br />\n";
|
---|
| 180 | $form .= "<label><input type='radio' name='". $ans_name . "' value='0' checked='checked' />". $no ."</label>\n";
|
---|
| 181 | }
|
---|
| 182 | $form .= "</td>\n";
|
---|
| 183 | $form .= "</tr><tr>\n";
|
---|
| 184 |
|
---|
| 185 | return $form;
|
---|
[21] | 186 |
|
---|
| 187 | }
|
---|
[32] | 188 |
|
---|
| 189 | function text_option($option_name,$option_desc){
|
---|
| 190 | $value = $this->{$option_name};
|
---|
| 191 | $ans_name = 'ch_' . $option_name;
|
---|
[19] | 192 |
|
---|
[32] | 193 | $form = "<tr>\n";
|
---|
| 194 | $form .= '<th><label for="images_to_link">' . $option_desc . "</label></th>\n";
|
---|
| 195 | $form .= "<td>\n";
|
---|
| 196 | $form .= '<label> <input name="'. $ans_name . '" type="text" size="25" maxlength="50" value="' . $value . '" /></label>'."\n";
|
---|
| 197 | $form .= "</td>\n";
|
---|
| 198 | $form .= "</tr><tr>\n";
|
---|
| 199 |
|
---|
| 200 | return $form;
|
---|
[21] | 201 |
|
---|
[32] | 202 | }
|
---|
[76] | 203 |
|
---|
| 204 | function groupe_role_option(){
|
---|
| 205 | global $wp_roles , $xoops_db;
|
---|
[21] | 206 |
|
---|
[76] | 207 | $form = '';
|
---|
[79] | 208 | $form .= '<tr><th><label for="role">' .__('Role Setting at Login', 'xpressme') . '</label></th>';
|
---|
[76] | 209 | $form .= '<td>';
|
---|
| 210 | $form .= "<table>\n";
|
---|
[81] | 211 | $form .= '<tr><td>' . __('XOOPS Groupe', 'xpressme') . '</td><td>' . __('WordPress Role', 'xpressme') . '</td><td>' . __('Role is set at each login', 'xpressme') . "</td></tr>\n";
|
---|
[76] | 212 | foreach ($this->groupe_role as $groupe) {
|
---|
| 213 | $form .= "<tr>";
|
---|
| 214 | $form .= "<td> $groupe->name </td>";
|
---|
| 215 | $form .= "<td>\n" . '<select name="role_gid_'.$groupe->groupid . '" id="role_gid_' . $groupe->groupid . '">' . "\n";
|
---|
| 216 | $role_list = '';
|
---|
| 217 | $group_has_role = false;
|
---|
| 218 |
|
---|
| 219 | $select_value = $groupe->role;
|
---|
| 220 |
|
---|
| 221 | foreach($wp_roles->role_names as $role => $name) {
|
---|
| 222 | $name = translate_with_context($name);
|
---|
| 223 | if ( $role == $select_value) {
|
---|
| 224 | $selected = ' selected="selected"';
|
---|
| 225 | $group_has_role = true;
|
---|
| 226 | } else {
|
---|
| 227 | $selected = '';
|
---|
| 228 | }
|
---|
| 229 | $role_list .= "<option value=\"{$role}\"{$selected}>{$name}</option>\n";
|
---|
| 230 | }
|
---|
[81] | 231 | if ( $group_has_role ) {
|
---|
| 232 | $role_list .= '<option value="default">' . __('Default Role of WordPress', 'xpressme') . "</option>\n";
|
---|
| 233 | $role_list .= '<option value="">' . __('Group User Doesn\'t Register', 'xpressme') . "</option>\n";
|
---|
| 234 | } else {
|
---|
| 235 | if ($select_value == 'default'){
|
---|
| 236 | $role_list .= '<option value="default" selected="selected">' . __('Default Role of WordPress', 'xpressme') . "</option>\n";
|
---|
| 237 | $role_list .= '<option value="">' . __('Group User Doesn\'t Register', 'xpressme') . "</option>\n";
|
---|
| 238 | } else {
|
---|
| 239 | $role_list .= '<option value="default">' . __('Default Role of WordPress', 'xpressme') . "</option>\n";
|
---|
| 240 | $role_list .= '<option value="" selected="selected">' . __('Group User Doesn\'t Register', 'xpressme') . "</option>\n";
|
---|
| 241 | }
|
---|
| 242 | }
|
---|
| 243 | $form .= $role_list . "</select>\n</td>";
|
---|
| 244 | if ($groupe->login_all){
|
---|
| 245 | $form .= '<td> <input type="checkbox" name="login_all_gid_' . $groupe->groupid . '" value="1" checked ></td>';
|
---|
| 246 | } else {
|
---|
| 247 | $form .= '<td> <input type="checkbox" name="login_all_gid_' . $groupe->groupid . '" value="1"></td>';
|
---|
| 248 | }
|
---|
| 249 | $form .= "</tr>\n";
|
---|
[76] | 250 | }
|
---|
| 251 | $form .= "</table></td></tr>\n";
|
---|
| 252 | return $form;
|
---|
| 253 |
|
---|
| 254 | }
|
---|
| 255 |
|
---|
[19] | 256 | function option_page()
|
---|
| 257 | {
|
---|
[76] | 258 |
|
---|
[20] | 259 | if (!empty($_POST['submit_update'])) {
|
---|
| 260 | $this->ReadPostData();
|
---|
| 261 | $this->SettingValueWrite('update');
|
---|
| 262 | } else if (isset($_POST['submit_reset'])) {
|
---|
| 263 | $this->fck_setDefault();
|
---|
| 264 | $this->SettingValueWrite('update');
|
---|
| 265 | }
|
---|
[19] | 266 |
|
---|
[20] | 267 |
|
---|
[21] | 268 | echo '<div class="wrap">'."\n";
|
---|
| 269 | echo '<div id="icon-options-general" class="icon32"><br /></div>'."\n";
|
---|
| 270 | echo '<h2>' . __('XPressME Configuration Page', 'xpressme') . "</h2>\n";
|
---|
| 271 | echo '<form method="post" action="' . $_SERVER["REQUEST_URI"] . '">'."\n" ;
|
---|
| 272 | echo '<table class="form-table">'."\n";
|
---|
| 273 | echo $this->yes_no_radio_option('is_use_xoops_upload_path',
|
---|
| 274 | __('Media Upload Base Path','xpressme'),
|
---|
| 275 | __('Use XOOPS UPLOAD PATH','xpressme'),
|
---|
[22] | 276 | __('USE WordPress BASE_PATH','xpressme')
|
---|
[21] | 277 | );
|
---|
[26] | 278 | echo $this->yes_no_radio_option('is_theme_sidebar_disp',
|
---|
| 279 | __('Thema Sidebar Display','xpressme'),
|
---|
| 280 | __('YES','xpressme'),
|
---|
| 281 | __('NO','xpressme')
|
---|
| 282 | );
|
---|
[28] | 283 | echo $this->yes_no_radio_option('is_save_post_revision',
|
---|
| 284 | __('The change tracking of the post is preserved','xpressme'),
|
---|
| 285 | __('YES','xpressme'),
|
---|
| 286 | __('NO','xpressme')
|
---|
| 287 | );
|
---|
[79] | 288 | echo $this->text_option('old_post_link_text',
|
---|
| 289 | __('Display Navi Title of Old Post Link','xpressme')
|
---|
| 290 | );
|
---|
| 291 | echo $this->text_option('newer_post_link_text',
|
---|
| 292 | __('Display Navi Title of Newer Post Link','xpressme')
|
---|
| 293 | );
|
---|
[32] | 294 | echo $this->yes_no_radio_option('is_postnavi_title_disp',
|
---|
| 295 | __('Select Display name of PostNavi Link','xpressme'),
|
---|
| 296 | __('Title of post','xpressme'),
|
---|
[79] | 297 | __('Title of Navi','xpressme')
|
---|
[32] | 298 | );
|
---|
| 299 | echo $this->yes_no_radio_option('is_left_postnavi_old',
|
---|
| 300 | __('Adjustment of Navi link display position','xpressme'),
|
---|
| 301 | __("'Old Post Link' is displayed in the left, and 'Newer Post Link' is displayed in the right",'xpressme'),
|
---|
| 302 | __("'Newer Post Link' is displayed in the left, and 'Old Post Link' is displayed in the right",'xpressme')
|
---|
| 303 | );
|
---|
[51] | 304 | echo $this->yes_no_radio_option('is_author_view_count',
|
---|
| 305 | __('Is the posts author views counted?','xpressme'),
|
---|
| 306 | __('YES','xpressme'),
|
---|
| 307 | __('NO','xpressme')
|
---|
[76] | 308 | );
|
---|
| 309 | echo $this->groupe_role_option();
|
---|
[21] | 310 | // $this->is_use_xoops_upload_path_html();
|
---|
| 311 | echo "</table>\n";
|
---|
[20] | 312 |
|
---|
[21] | 313 | echo '<p class="submit">'."\n";
|
---|
| 314 | echo '<input type="submit" value= "' . __('Update Config', 'xpressme') . '" name="submit_update" />' ."\n";
|
---|
| 315 | echo '<input type="submit" value= "' . __('Preset Config', 'xpressme') . '" name="submit_reset" />' ."\n";
|
---|
| 316 | echo "</p>\n";
|
---|
[19] | 317 |
|
---|
[21] | 318 | echo "</form>\n" ;
|
---|
| 319 | echo "</div>\n";
|
---|
[19] | 320 | }
|
---|
| 321 |
|
---|
| 322 | function xpress_upload_filter($uploads)
|
---|
| 323 | {
|
---|
| 324 | if ($this->is_use_xoops_upload_path){
|
---|
| 325 | if (!defined("XOOPS_UPLOAD_PATH"))
|
---|
| 326 | define("XOOPS_UPLOAD_PATH", XOOPS_ROOT_PATH."/uploads");
|
---|
| 327 | if (!defined("XOOPS_UPLOAD_URL"))
|
---|
| 328 | define("XOOPS_UPLOAD_URL", XOOPS_URL."/uploads");
|
---|
| 329 |
|
---|
| 330 | $wordpress_dir = ABSPATH ;
|
---|
| 331 | $xoops_dir = XOOPS_UPLOAD_PATH . '/';
|
---|
| 332 | $wordpress_base_url = get_option( 'siteurl' );
|
---|
| 333 | $xoops_upload_url = XOOPS_UPLOAD_URL;
|
---|
| 334 |
|
---|
| 335 | $uploads[path] = str_replace ($wordpress_dir, $xoops_dir, $uploads[path]);
|
---|
| 336 | $uploads[basedir] = str_replace ($wordpress_dir, $xoops_dir, $uploads[basedir]);
|
---|
| 337 | $uploads[url] = str_replace ($wordpress_base_url, $xoops_upload_url, $uploads[url]);
|
---|
| 338 | $uploads[baseurl] = str_replace ($wordpress_base_url, $xoops_upload_url, $uploads[baseurl]);
|
---|
| 339 | }
|
---|
| 340 | return $uploads;
|
---|
| 341 | }
|
---|
[28] | 342 |
|
---|
[19] | 343 | }
|
---|
| 344 | ?> |
---|