Plugin Directory


Ignore:
Timestamp:
10/17/2026 01:47:11 PM (13 days ago)
Author:
mxchat
Message:

Release 3.2.26 - security hardening, new models (GPT-6.1 Sol, Claude 5.5 family, Grok 4.7, Gemini 4 Argon, DeepSeek Flash), automatic moves off discontinued models, token usage in Transcripts, page-builder and ACF Blocks imports

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mxchat-basic/trunk/includes/class-mxchat-privacy.php

    r3724923 r3751971  
    258258            $data = array_merge($data, self::export_click_fields($sid));
    259259
     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
    260264            $items[] = self::export_item($sid, $data);
    261265        }
    … …  
    315319        }
    316320
    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));
    318322
    319323        if (count($data) < 2) {
    … …  
    378382                );
    379383            }
     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);
    380426        }
    381427
    … …  
    452498            }
    453499
    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);
    456503            $deleted_this_batch++;
    457504        }
    … …  
    477524     * chat-deleted lead preservation, agent name, session owner), per-session
    478525     * 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.
    480530     */
    481531    private static function erase_session($sid) {
    … …  
    518568        }
    519569
     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
    520576        foreach (self::$session_option_prefixes as $prefix) {
    521577            delete_option($prefix . $sid);
    … …  
    529585
    530586        wp_cache_delete('chat_session_' . $sid, 'mxchat_chat_sessions');
     587
     588        return $ratings_removed;
    531589    }
    532590
Note: See TracChangeset for help on using the changeset viewer.