Changeset 3751971 for mxchat-basic/trunk/includes/class-mxchat-privacy.php
- Timestamp:
- 10/17/2026 01:47:11 PM (13 days ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
mxchat-basic/trunk/includes/class-mxchat-privacy.php
r3724923 r3751971 258 258 $data = array_merge($data, self::export_click_fields($sid)); 259 259 260 // The satisfaction rating and the feedback the visitor typed 261 // (plan 79c1be) — the eraser removes them, so the export shows them. 262 $data = array_merge($data, self::export_rating_fields($sid)); 263 260 264 $items[] = self::export_item($sid, $data); 261 265 } … … 315 319 } 316 320 317 $data = array_merge($data, self::export_consent_fields($sid), self::export_click_fields($sid) );321 $data = array_merge($data, self::export_consent_fields($sid), self::export_click_fields($sid), self::export_rating_fields($sid)); 318 322 319 323 if (count($data) < 2) { … … 378 382 ); 379 383 } 384 } 385 386 return $fields; 387 } 388 389 /** 390 * Satisfaction rating fields for one session: the thumbs-up/down, the 391 * free-text feedback when the visitor left any, and when it was given. 392 * Empty when the session was never rated or the table does not exist 393 * (plan 79c1be). 394 */ 395 private static function export_rating_fields($sid) { 396 global $wpdb; 397 static $table_exists = null; 398 399 $table = $wpdb->prefix . 'mxchat_session_ratings'; 400 if ($table_exists === null) { 401 $table_exists = ($wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $table)) === $table); 402 } 403 if (!$table_exists) { 404 return array(); 405 } 406 407 $row = $wpdb->get_row($wpdb->prepare( 408 "SELECT rating_value, rating_feedback, created_at FROM {$table} WHERE session_id = %s LIMIT 1", 409 $sid 410 )); 411 if (!$row) { 412 return array(); 413 } 414 415 $fields = array( 416 array( 417 'name' => __('Satisfaction rating', 'mxchat'), 418 'value' => ((int) $row->rating_value === 1) ? __('Positive', 'mxchat') : __('Negative', 'mxchat'), 419 ), 420 ); 421 if ($row->rating_feedback !== null && $row->rating_feedback !== '') { 422 $fields[] = array('name' => __('Rating feedback', 'mxchat'), 'value' => (string) $row->rating_feedback); 423 } 424 if (!empty($row->created_at)) { 425 $fields[] = array('name' => __('Rated on', 'mxchat'), 'value' => (string) $row->created_at); 380 426 } 381 427 … … 452 498 } 453 499 454 self::erase_session($sid); 455 $items_removed++; 500 // One item for the conversation, plus one for its satisfaction 501 // rating when there was one (plan 79c1be). 502 $items_removed += 1 + self::erase_session($sid); 456 503 $deleted_this_batch++; 457 504 } … … 477 524 * chat-deleted lead preservation, agent name, session owner), per-session 478 525 * upload transients, any uploaded PDF/Word temp file those transients 479 * still point at, and the session's row cache. 526 * still point at, the satisfaction rating with its feedback (79c1be), and 527 * the session's row cache. 528 * 529 * @return int Rating rows removed (0 or 1), reported as erased items. 480 530 */ 481 531 private static function erase_session($sid) { … … 518 568 } 519 569 570 // The thumbs-up/down and the free-text feedback the visitor typed 571 // (up to 1,000 characters) are personal data about this conversation. 572 $ratings_removed = function_exists('mxchat_delete_session_ratings') 573 ? (int) mxchat_delete_session_ratings(array($sid)) 574 : 0; 575 520 576 foreach (self::$session_option_prefixes as $prefix) { 521 577 delete_option($prefix . $sid); … … 529 585 530 586 wp_cache_delete('chat_session_' . $sid, 'mxchat_chat_sessions'); 587 588 return $ratings_removed; 531 589 } 532 590
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)