| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace EventEspresso\core\domain\services\admin\privacy\erasure; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use EEM_Answer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use EEM_Question; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use EventEspresso\core\services\privacy\erasure\PersonalDataEraserInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * Class EraseAnswers | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * Erases answers for registrations with the specified email address | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * @package        Event Espresso | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * @author         Mike Nelson | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * @since          $VID:$ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | class EraseAnswers implements PersonalDataEraserInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |      * @var EEM_Answer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     protected $answer_model; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |      * @var EEM_Question | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     protected $question_model; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      * EraseAnswers constructor. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      * @param EEM_Answer   $answer_model | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      * @param EEM_Question $question_model | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     public function __construct(EEM_Answer $answer_model, EEM_Question $question_model) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         $this->answer_model = $answer_model; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         $this->question_model = $question_model; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      * Gets a translated string name for the data eraser | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      * @return string | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 46 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |     public function name() | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |         return esc_html__('Event Espresso Registration Answers', 'event_espresso'); | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      * Erases a "page" of personal user data | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |      * @return array { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |      * @type boolean $items_removed  whether items were removed successfully or not | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      * @type boolean $items_retained whether any items were skipped or not | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      * @type array   $messages       values are messages to show | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * @type boolean $done           whether this eraser is done or has more pages | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      *               } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     public function erase($email_address, $page = 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         $multi_answer_enum_question_types = $this->question_model->question_types_in_category('multi-answer-enum'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         $normal_questions_updated = $this->answer_model->update( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |                 'ANS_value' => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |                 array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |                     'Registration.Attendee.ATT_email' => $email_address, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |                     'Question.QST_type'               => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |                         'NOT_IN', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |                         $multi_answer_enum_question_types, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |                     ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         $multi_value_questions_updated = $this->answer_model->update( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |                 'ANS_value' => array(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |                 array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |                     'Registration.Attendee.ATT_email' => $email_address, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |                     'Question.QST_type'               => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |                         'IN', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |                         $multi_answer_enum_question_types, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |                     ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |             'items_removed'  => (bool) $normal_questions_updated || (bool) $multi_value_questions_updated, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |             'items_retained' => false, // always false in this example | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |             'messages'       => array(), // no messages in this example | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |             'done'           => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | // End of file EraseAnswers.php | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 103 |  |  | // Location: EventEspresso\core\domain\services\privacy\erasure/EraseAnswers.php | 
            
                                                        
            
                                    
            
            
                | 104 |  |  |  |