| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* bbPress PHPWind Converter |
| 5 |
* |
| 6 |
* @package bbPress |
| 7 |
* @subpackage Converters |
| 8 |
*/ |
| 9 |
|
| 10 |
/** |
| 11 |
* Implementation of PHPWind Forum converter. |
| 12 |
* |
| 13 |
* @since 2.5.0 bbPress (r5142) |
| 14 |
* |
| 15 |
* @link Codex Docs https://codex.bbpress.org/import-forums/phpwind |
| 16 |
*/ |
| 17 |
class PHPWind extends BBP_Converter_Base { |
| 18 |
|
| 19 |
/** |
| 20 |
* Sets up the field mappings |
| 21 |
*/ |
| 22 |
public function setup_globals() { |
| 23 |
|
| 24 |
/** Forum Section *****************************************************/ |
| 25 |
|
| 26 |
// Old forum id (Stored in postmeta) |
| 27 |
$this->field_map[] = array( |
| 28 |
'from_tablename' => 'bbs_forum', |
| 29 |
'from_fieldname' => 'fid', |
| 30 |
'to_type' => 'forum', |
| 31 |
'to_fieldname' => '_bbp_old_forum_id' |
| 32 |
); |
| 33 |
|
| 34 |
// Forum parent id (If no parent, then 0, Stored in postmeta) |
| 35 |
$this->field_map[] = array( |
| 36 |
'from_tablename' => 'bbs_forum', |
| 37 |
'from_fieldname' => 'parentid', |
| 38 |
'to_type' => 'forum', |
| 39 |
'to_fieldname' => '_bbp_old_forum_parent_id' |
| 40 |
); |
| 41 |
|
| 42 |
// Forum topic count (Stored in postmeta) |
| 43 |
// Note: We join the 'bbs_forum_statistics' table because 'bbs_forum' table does not include topic and reply counts. |
| 44 |
$this->field_map[] = array( |
| 45 |
'from_tablename' => 'bbs_forum_statistics', |
| 46 |
'from_fieldname' => 'threads', |
| 47 |
'join_tablename' => 'bbs_forum', |
| 48 |
'join_type' => 'LEFT', |
| 49 |
'join_expression' => 'USING (fid)', |
| 50 |
'to_type' => 'forum', |
| 51 |
'to_fieldname' => '_bbp_topic_count' |
| 52 |
); |
| 53 |
|
| 54 |
// Forum reply count (Stored in postmeta) |
| 55 |
// Note: We join the 'bbs_forum_statistics' table because 'bbs_forum' table does not include topic and reply counts. |
| 56 |
$this->field_map[] = array( |
| 57 |
'from_tablename' => 'bbs_forum_statistics', |
| 58 |
'from_fieldname' => 'posts', |
| 59 |
'join_tablename' => 'bbs_forum', |
| 60 |
'join_type' => 'LEFT', |
| 61 |
'join_expression' => 'USING (fid)', |
| 62 |
'to_type' => 'forum', |
| 63 |
'to_fieldname' => '_bbp_reply_count' |
| 64 |
); |
| 65 |
|
| 66 |
// Forum total topic count (Stored in postmeta) |
| 67 |
// Note: We join the 'bbs_forum_statistics' table because 'bbs_forum' table does not include topic and reply counts. |
| 68 |
$this->field_map[] = array( |
| 69 |
'from_tablename' => 'bbs_forum_statistics', |
| 70 |
'from_fieldname' => 'threads', |
| 71 |
'join_tablename' => 'bbs_forum', |
| 72 |
'join_type' => 'LEFT', |
| 73 |
'join_expression' => 'USING (fid)', |
| 74 |
'to_type' => 'forum', |
| 75 |
'to_fieldname' => '_bbp_total_topic_count' |
| 76 |
); |
| 77 |
|
| 78 |
// Forum total reply count (Stored in postmeta) |
| 79 |
// Note: We join the 'bbs_forum_statistics' table because 'bbs_forum' table does not include topic and reply counts. |
| 80 |
$this->field_map[] = array( |
| 81 |
'from_tablename' => 'bbs_forum_statistics', |
| 82 |
'from_fieldname' => 'posts', |
| 83 |
'join_tablename' => 'bbs_forum', |
| 84 |
'join_type' => 'LEFT', |
| 85 |
'join_expression' => 'USING (fid)', |
| 86 |
'to_type' => 'forum', |
| 87 |
'to_fieldname' => '_bbp_total_reply_count' |
| 88 |
); |
| 89 |
|
| 90 |
// Forum title. |
| 91 |
$this->field_map[] = array( |
| 92 |
'from_tablename' => 'bbs_forum', |
| 93 |
'from_fieldname' => 'name', |
| 94 |
'to_type' => 'forum', |
| 95 |
'to_fieldname' => 'post_title' |
| 96 |
); |
| 97 |
|
| 98 |
// Forum slug (Clean name to avoid conflicts) |
| 99 |
$this->field_map[] = array( |
| 100 |
'from_tablename' => 'bbs_forum', |
| 101 |
'from_fieldname' => 'name', |
| 102 |
'to_type' => 'forum', |
| 103 |
'to_fieldname' => 'post_name', |
| 104 |
'callback_method' => 'callback_slug' |
| 105 |
); |
| 106 |
|
| 107 |
// Forum description. |
| 108 |
$this->field_map[] = array( |
| 109 |
'from_tablename' => 'bbs_forum', |
| 110 |
'from_fieldname' => 'descrip', |
| 111 |
'to_type' => 'forum', |
| 112 |
'to_fieldname' => 'post_content', |
| 113 |
'callback_method' => 'callback_null' |
| 114 |
); |
| 115 |
|
| 116 |
// Forum display order (Starts from 1) |
| 117 |
$this->field_map[] = array( |
| 118 |
'from_tablename' => 'bbs_forum', |
| 119 |
'from_fieldname' => 'vieworder', |
| 120 |
'to_type' => 'forum', |
| 121 |
'to_fieldname' => 'menu_order' |
| 122 |
); |
| 123 |
|
| 124 |
// Forum type (Category = category or Forum = forum, sub or sub2, Stored in postmeta) |
| 125 |
$this->field_map[] = array( |
| 126 |
'from_tablename' => 'bbs_forum', |
| 127 |
'from_fieldname' => 'type', |
| 128 |
'to_type' => 'forum', |
| 129 |
'to_fieldname' => '_bbp_forum_type', |
| 130 |
'callback_method' => 'callback_forum_type' |
| 131 |
); |
| 132 |
|
| 133 |
// Forum status (Set a default value 'open', Stored in postmeta) |
| 134 |
$this->field_map[] = array( |
| 135 |
'to_type' => 'forum', |
| 136 |
'to_fieldname' => '_bbp_status', |
| 137 |
'default' => 'open' |
| 138 |
); |
| 139 |
// Forum dates. |
| 140 |
$this->field_map[] = array( |
| 141 |
'to_type' => 'bbs_forum', |
| 142 |
'to_fieldname' => 'post_date', |
| 143 |
'default' => date( 'Y-m-d H:i:s' ) // phpcs:ignore |
| 144 |
); |
| 145 |
$this->field_map[] = array( |
| 146 |
'to_type' => 'bbs_forum', |
| 147 |
'to_fieldname' => 'post_date_gmt', |
| 148 |
'default' => gmdate( 'Y-m-d H:i:s' ) |
| 149 |
); |
| 150 |
$this->field_map[] = array( |
| 151 |
'to_type' => 'bbs_forum', |
| 152 |
'to_fieldname' => 'post_modified', |
| 153 |
'default' => date( 'Y-m-d H:i:s' ) // phpcs:ignore |
| 154 |
); |
| 155 |
$this->field_map[] = array( |
| 156 |
'to_type' => 'bbs_forum', |
| 157 |
'to_fieldname' => 'post_modified_gmt', |
| 158 |
'default' => gmdate( 'Y-m-d H:i:s' ) |
| 159 |
); |
| 160 |
|
| 161 |
/** Topic Section *****************************************************/ |
| 162 |
|
| 163 |
// Old topic id (Stored in postmeta) |
| 164 |
$this->field_map[] = array( |
| 165 |
'from_tablename' => 'bbs_threads', |
| 166 |
'from_fieldname' => 'tid', |
| 167 |
'to_type' => 'topic', |
| 168 |
'to_fieldname' => '_bbp_old_topic_id' |
| 169 |
); |
| 170 |
|
| 171 |
// Topic reply count (Stored in postmeta) |
| 172 |
$this->field_map[] = array( |
| 173 |
'from_tablename' => 'bbs_threads', |
| 174 |
'from_fieldname' => 'replies', |
| 175 |
'to_type' => 'topic', |
| 176 |
'to_fieldname' => '_bbp_reply_count', |
| 177 |
'callback_method' => 'callback_topic_reply_count' |
| 178 |
); |
| 179 |
|
| 180 |
// Topic total reply count (Includes unpublished replies, Stored in postmeta) |
| 181 |
$this->field_map[] = array( |
| 182 |
'from_tablename' => 'bbs_threads', |
| 183 |
'from_fieldname' => 'replies', |
| 184 |
'to_type' => 'topic', |
| 185 |
'to_fieldname' => '_bbp_total_reply_count', |
| 186 |
'callback_method' => 'callback_topic_reply_count' |
| 187 |
); |
| 188 |
|
| 189 |
// Topic parent forum id (If no parent, then 0. Stored in postmeta) |
| 190 |
$this->field_map[] = array( |
| 191 |
'from_tablename' => 'bbs_threads', |
| 192 |
'from_fieldname' => 'fid', |
| 193 |
'to_type' => 'topic', |
| 194 |
'to_fieldname' => '_bbp_forum_id', |
| 195 |
'callback_method' => 'callback_forumid' |
| 196 |
); |
| 197 |
|
| 198 |
// Topic author. |
| 199 |
$this->field_map[] = array( |
| 200 |
'from_tablename' => 'bbs_threads', |
| 201 |
'from_fieldname' => 'created_userid', |
| 202 |
'to_type' => 'topic', |
| 203 |
'to_fieldname' => 'post_author', |
| 204 |
'callback_method' => 'callback_userid' |
| 205 |
); |
| 206 |
|
| 207 |
// Topic Author ip (Stored in postmeta) |
| 208 |
$this->field_map[] = array( |
| 209 |
'from_tablename' => 'bbs_threads', |
| 210 |
'from_fieldname' => 'created_ip', |
| 211 |
'to_type' => 'topic', |
| 212 |
'to_fieldname' => '_bbp_author_ip' |
| 213 |
); |
| 214 |
|
| 215 |
// Topic content. |
| 216 |
// Note: We join the 'bbs_threads_content' table because 'bbs_threads' table does not have content. |
| 217 |
$this->field_map[] = array( |
| 218 |
'from_tablename' => 'bbs_threads_content', |
| 219 |
'from_fieldname' => 'content', |
| 220 |
'join_tablename' => 'bbs_threads', |
| 221 |
'join_type' => 'INNER', |
| 222 |
'join_expression' => 'USING (tid)', |
| 223 |
'to_type' => 'topic', |
| 224 |
'to_fieldname' => 'post_content', |
| 225 |
'callback_method' => 'callback_html' |
| 226 |
); |
| 227 |
|
| 228 |
// Topic title. |
| 229 |
$this->field_map[] = array( |
| 230 |
'from_tablename' => 'bbs_threads', |
| 231 |
'from_fieldname' => 'subject', |
| 232 |
'to_type' => 'topic', |
| 233 |
'to_fieldname' => 'post_title' |
| 234 |
); |
| 235 |
|
| 236 |
// Topic slug (Clean name to avoid conflicts) |
| 237 |
$this->field_map[] = array( |
| 238 |
'from_tablename' => 'bbs_threads', |
| 239 |
'from_fieldname' => 'subject', |
| 240 |
'to_type' => 'topic', |
| 241 |
'to_fieldname' => 'post_name', |
| 242 |
'callback_method' => 'callback_slug' |
| 243 |
); |
| 244 |
|
| 245 |
// Topic parent forum id (If no parent, then 0) |
| 246 |
$this->field_map[] = array( |
| 247 |
'from_tablename' => 'bbs_threads', |
| 248 |
'from_fieldname' => 'fid', |
| 249 |
'to_type' => 'topic', |
| 250 |
'to_fieldname' => 'post_parent', |
| 251 |
'callback_method' => 'callback_forumid' |
| 252 |
); |
| 253 |
|
| 254 |
// Topic dates. |
| 255 |
$this->field_map[] = array( |
| 256 |
'from_tablename' => 'bbs_threads', |
| 257 |
'from_fieldname' => 'created_time', |
| 258 |
'to_type' => 'topic', |
| 259 |
'to_fieldname' => 'post_date', |
| 260 |
'callback_method' => 'callback_datetime' |
| 261 |
); |
| 262 |
$this->field_map[] = array( |
| 263 |
'from_tablename' => 'bbs_threads', |
| 264 |
'from_fieldname' => 'created_time', |
| 265 |
'to_type' => 'topic', |
| 266 |
'to_fieldname' => 'post_date_gmt', |
| 267 |
'callback_method' => 'callback_datetime' |
| 268 |
); |
| 269 |
$this->field_map[] = array( |
| 270 |
'from_tablename' => 'bbs_threads', |
| 271 |
'from_fieldname' => 'lastpost_time', |
| 272 |
'to_type' => 'topic', |
| 273 |
'to_fieldname' => 'post_modified', |
| 274 |
'callback_method' => 'callback_datetime' |
| 275 |
); |
| 276 |
$this->field_map[] = array( |
| 277 |
'from_tablename' => 'bbs_threads', |
| 278 |
'from_fieldname' => 'lastpost_time', |
| 279 |
'to_type' => 'topic', |
| 280 |
'to_fieldname' => 'post_modified_gmt', |
| 281 |
'callback_method' => 'callback_datetime' |
| 282 |
); |
| 283 |
$this->field_map[] = array( |
| 284 |
'from_tablename' => 'bbs_threads', |
| 285 |
'from_fieldname' => 'lastpost_time', |
| 286 |
'to_type' => 'topic', |
| 287 |
'to_fieldname' => '_bbp_last_active_time', |
| 288 |
'callback_method' => 'callback_datetime' |
| 289 |
); |
| 290 |
|
| 291 |
// Topic status (Open or Closed, PHPWind v9.x 0=no, 1=closed & 2=open) |
| 292 |
$this->field_map[] = array( |
| 293 |
'from_tablename' => 'bbs_threads', |
| 294 |
'from_fieldname' => 'tpcstatus', |
| 295 |
'to_type' => 'topic', |
| 296 |
'to_fieldname' => '_bbp_old_closed_status_id', |
| 297 |
'callback_method' => 'callback_topic_status' |
| 298 |
); |
| 299 |
|
| 300 |
/** Tags Section ******************************************************/ |
| 301 |
|
| 302 |
/** |
| 303 |
* PHPWind v9.x Forums do not support topic tags out of the box |
| 304 |
*/ |
| 305 |
|
| 306 |
/** Reply Section *****************************************************/ |
| 307 |
|
| 308 |
// Old reply id (Stored in postmeta) |
| 309 |
$this->field_map[] = array( |
| 310 |
'from_tablename' => 'bbs_posts', |
| 311 |
'from_fieldname' => 'pid', |
| 312 |
'to_type' => 'reply', |
| 313 |
'to_fieldname' => '_bbp_old_reply_id' |
| 314 |
); |
| 315 |
|
| 316 |
// Reply parent forum id (If no parent, then 0. Stored in postmeta) |
| 317 |
$this->field_map[] = array( |
| 318 |
'from_tablename' => 'bbs_posts', |
| 319 |
'from_fieldname' => 'fid', |
| 320 |
'to_type' => 'reply', |
| 321 |
'to_fieldname' => '_bbp_forum_id', |
| 322 |
'callback_method' => 'callback_forumid' |
| 323 |
); |
| 324 |
|
| 325 |
// Reply parent topic id (If no parent, then 0. Stored in postmeta) |
| 326 |
$this->field_map[] = array( |
| 327 |
'from_tablename' => 'bbs_posts', |
| 328 |
'from_fieldname' => 'tid', |
| 329 |
'to_type' => 'reply', |
| 330 |
'to_fieldname' => '_bbp_topic_id', |
| 331 |
'callback_method' => 'callback_topicid' |
| 332 |
); |
| 333 |
|
| 334 |
// Reply author ip (Stored in postmeta) |
| 335 |
$this->field_map[] = array( |
| 336 |
'from_tablename' => 'bbs_posts', |
| 337 |
'from_fieldname' => 'created_ip', |
| 338 |
'to_type' => 'reply', |
| 339 |
'to_fieldname' => '_bbp_author_ip' |
| 340 |
); |
| 341 |
|
| 342 |
// Reply author. |
| 343 |
$this->field_map[] = array( |
| 344 |
'from_tablename' => 'bbs_posts', |
| 345 |
'from_fieldname' => 'created_userid', |
| 346 |
'to_type' => 'reply', |
| 347 |
'to_fieldname' => 'post_author', |
| 348 |
'callback_method' => 'callback_userid' |
| 349 |
); |
| 350 |
|
| 351 |
// Reply content. |
| 352 |
$this->field_map[] = array( |
| 353 |
'from_tablename' => 'bbs_posts', |
| 354 |
'from_fieldname' => 'content', |
| 355 |
'to_type' => 'reply', |
| 356 |
'to_fieldname' => 'post_content', |
| 357 |
'callback_method' => 'callback_html' |
| 358 |
); |
| 359 |
|
| 360 |
// Reply parent topic id (If no parent, then 0) |
| 361 |
$this->field_map[] = array( |
| 362 |
'from_tablename' => 'bbs_posts', |
| 363 |
'from_fieldname' => 'tid', |
| 364 |
'to_type' => 'reply', |
| 365 |
'to_fieldname' => 'post_parent', |
| 366 |
'callback_method' => 'callback_topicid' |
| 367 |
); |
| 368 |
|
| 369 |
// Reply dates. |
| 370 |
$this->field_map[] = array( |
| 371 |
'from_tablename' => 'bbs_posts', |
| 372 |
'from_fieldname' => 'created_time', |
| 373 |
'to_type' => 'reply', |
| 374 |
'to_fieldname' => 'post_date', |
| 375 |
'callback_method' => 'callback_datetime' |
| 376 |
); |
| 377 |
$this->field_map[] = array( |
| 378 |
'from_tablename' => 'bbs_posts', |
| 379 |
'from_fieldname' => 'created_time', |
| 380 |
'to_type' => 'reply', |
| 381 |
'to_fieldname' => 'post_date_gmt', |
| 382 |
'callback_method' => 'callback_datetime' |
| 383 |
); |
| 384 |
$this->field_map[] = array( |
| 385 |
'from_tablename' => 'bbs_posts', |
| 386 |
'from_fieldname' => 'created_time', |
| 387 |
'to_type' => 'reply', |
| 388 |
'to_fieldname' => 'post_modified', |
| 389 |
'callback_method' => 'callback_datetime' |
| 390 |
); |
| 391 |
$this->field_map[] = array( |
| 392 |
'from_tablename' => 'bbs_posts', |
| 393 |
'from_fieldname' => 'created_time', |
| 394 |
'to_type' => 'reply', |
| 395 |
'to_fieldname' => 'post_modified_gmt', |
| 396 |
'callback_method' => 'callback_datetime' |
| 397 |
); |
| 398 |
|
| 399 |
/** User Section ******************************************************/ |
| 400 |
|
| 401 |
// Store old user id (Stored in usermeta) |
| 402 |
$this->field_map[] = array( |
| 403 |
'from_tablename' => 'user', |
| 404 |
'from_fieldname' => 'uid', |
| 405 |
'to_type' => 'user', |
| 406 |
'to_fieldname' => '_bbp_old_user_id' |
| 407 |
); |
| 408 |
|
| 409 |
// Store old user password (Stored in usermeta serialized with salt) |
| 410 |
$this->field_map[] = array( |
| 411 |
'from_tablename' => 'user', |
| 412 |
'from_fieldname' => 'password', |
| 413 |
'to_type' => 'user', |
| 414 |
'to_fieldname' => '_bbp_password' |
| 415 |
// 'callback_method' => 'callback_savepass' |
| 416 |
); |
| 417 |
|
| 418 |
// Store old user salt (This is only used for the SELECT row info for the above password save) |
| 419 |
/* |
| 420 |
$this->field_map[] = array( |
| 421 |
'from_tablename' => 'user', |
| 422 |
'from_fieldname' => 'pass', |
| 423 |
'to_type' => 'user', |
| 424 |
'to_fieldname' => '' |
| 425 |
); |
| 426 |
*/ |
| 427 |
|
| 428 |
// User password verify class (Stored in usermeta for verifying password) |
| 429 |
$this->field_map[] = array( |
| 430 |
'to_type' => 'user', |
| 431 |
'to_fieldname' => '_bbp_class', |
| 432 |
'default' => 'PHPWind' |
| 433 |
); |
| 434 |
|
| 435 |
// User name. |
| 436 |
$this->field_map[] = array( |
| 437 |
'from_tablename' => 'user', |
| 438 |
'from_fieldname' => 'username', |
| 439 |
'to_type' => 'user', |
| 440 |
'to_fieldname' => 'user_login' |
| 441 |
); |
| 442 |
|
| 443 |
// User nice name. |
| 444 |
$this->field_map[] = array( |
| 445 |
'from_tablename' => 'user', |
| 446 |
'from_fieldname' => 'username', |
| 447 |
'to_type' => 'user', |
| 448 |
'to_fieldname' => 'user_nicename' |
| 449 |
); |
| 450 |
|
| 451 |
// User email. |
| 452 |
$this->field_map[] = array( |
| 453 |
'from_tablename' => 'user', |
| 454 |
'from_fieldname' => 'email', |
| 455 |
'to_type' => 'user', |
| 456 |
'to_fieldname' => 'user_email' |
| 457 |
); |
| 458 |
|
| 459 |
// User registered. |
| 460 |
$this->field_map[] = array( |
| 461 |
'from_tablename' => 'user', |
| 462 |
'from_fieldname' => 'regdate', |
| 463 |
'to_type' => 'user', |
| 464 |
'to_fieldname' => 'user_registered', |
| 465 |
'callback_method' => 'callback_datetime' |
| 466 |
); |
| 467 |
|
| 468 |
// User display name. |
| 469 |
$this->field_map[] = array( |
| 470 |
'from_tablename' => 'user', |
| 471 |
'from_fieldname' => 'realname', |
| 472 |
'to_type' => 'user', |
| 473 |
'to_fieldname' => 'display_name' |
| 474 |
); |
| 475 |
} |
| 476 |
|
| 477 |
/** |
| 478 |
* This method allows us to indicates what is or is not converted for each |
| 479 |
* converter. |
| 480 |
*/ |
| 481 |
public function info() { |
| 482 |
return ''; |
| 483 |
} |
| 484 |
|
| 485 |
/** |
| 486 |
* This method is to save the salt and password together. That |
| 487 |
* way when we authenticate it we can get it out of the database |
| 488 |
* as one value. Array values are auto sanitized by WordPress. |
| 489 |
*/ |
| 490 |
public function callback_savepass( $field, $row ) { |
| 491 |
$pass_array = array( |
| 492 |
'hash' => $field, |
| 493 |
'salt' => $row['salt'] |
| 494 |
); |
| 495 |
|
| 496 |
return $pass_array; |
| 497 |
} |
| 498 |
|
| 499 |
/** |
| 500 |
* This method is to take the pass out of the database and compare |
| 501 |
* to a pass the user has typed in. |
| 502 |
*/ |
| 503 |
public function authenticate_pass( $password, $serialized_pass ) { |
| 504 |
|
| 505 |
// Unserialize the password, with safeguards |
| 506 |
$pass_array = unserialize( |
| 507 |
$serialized_pass, |
| 508 |
array( |
| 509 |
'allowed_classes' => false, |
| 510 |
'max_depth' => 1, |
| 511 |
) |
| 512 |
); |
| 513 |
|
| 514 |
// Bail if missing values |
| 515 |
if ( ! is_array( $pass_array ) || ! isset( $pass_array['hash'], $pass_array['salt'] ) ) { |
| 516 |
return false; |
| 517 |
} |
| 518 |
|
| 519 |
// Return comparison |
| 520 |
return hash_equals( |
| 521 |
$pass_array['hash'], |
| 522 |
md5( md5( $password ) . $pass_array['salt'] ) |
| 523 |
); |
| 524 |
} |
| 525 |
|
| 526 |
/** |
| 527 |
* Translate the forum type from PHPWind v9.x Capitalised case to WordPress's non-capatilise case strings. |
| 528 |
* |
| 529 |
* @param int $status PHPWind v9.x numeric forum type |
| 530 |
* @return string WordPress safe |
| 531 |
*/ |
| 532 |
public function callback_forum_type( $status = 1 ) { |
| 533 |
switch ( $status ) { |
| 534 |
case 'category' : |
| 535 |
$status = 'category'; |
| 536 |
break; |
| 537 |
|
| 538 |
case 'sub' : |
| 539 |
$status = 'forum'; |
| 540 |
break; |
| 541 |
|
| 542 |
case 'sub2' : |
| 543 |
$status = 'forum'; |
| 544 |
break; |
| 545 |
|
| 546 |
case 'forum' : |
| 547 |
default : |
| 548 |
$status = 'forum'; |
| 549 |
break; |
| 550 |
} |
| 551 |
return $status; |
| 552 |
} |
| 553 |
|
| 554 |
/** |
| 555 |
* Translate the post status from PHPWind v9.x numerics to WordPress's strings. |
| 556 |
* |
| 557 |
* @param int $status PHPWind v9.x numeric topic status |
| 558 |
* @return string WordPress safe |
| 559 |
*/ |
| 560 |
public function callback_topic_status( $status = 2 ) { |
| 561 |
switch ( $status ) { |
| 562 |
case 1 : |
| 563 |
$status = 'closed'; |
| 564 |
break; |
| 565 |
|
| 566 |
case 2 : |
| 567 |
default : |
| 568 |
$status = 'publish'; |
| 569 |
break; |
| 570 |
} |
| 571 |
return $status; |
| 572 |
} |
| 573 |
|
| 574 |
/** |
| 575 |
* Verify the topic/reply count. |
| 576 |
* |
| 577 |
* @param int $count PHPWind v9.x topic/reply counts |
| 578 |
* @return string WordPress safe |
| 579 |
*/ |
| 580 |
public function callback_topic_reply_count( $count = 1 ) { |
| 581 |
$count = absint( (int) $count - 1 ); |
| 582 |
return $count; |
| 583 |
} |
| 584 |
} |
| 585 |
|