/** * @param $post (array('ab_test_id', 'ab_test_updated_by')) submitted values from ab test delete form * @return response (array) */ public function delete($post) { // set the ID $this->ab_test['ab_test_id'] = $post['ab_test_id']; // get the AB Test $ab_test = new Enp_quiz_AB_test($post['ab_test_id']); // check if the user who submitted the form is valid if ((int) $post['ab_test_updated_by'] !== (int) $ab_test->get_ab_test_owner()) { // owner isn't valid $this->add_error('You are not the owner of this AB Test.'); } // we need to include these for the response $this->ab_test['quiz_id_a'] = $ab_test->get_quiz_id_a(); $this->ab_test['quiz_id_b'] = $ab_test->get_quiz_id_b(); $this->ab_test['ab_test_updated_by'] = $post['ab_test_updated_by']; // set the updated at time $date_time = date("Y-m-d H:i:s"); $this->ab_test['ab_test_updated_at'] = $date_time; $this->ab_test['ab_test_is_deleted'] = '1'; $if_errors = $this->check_for_errors(); if ($if_errors === false) { // actually delete it $this->delete_ab_test($this->ab_test); } // return the response return $this->response; }