From a057db89cc46f434b59de7bdf35ad33714ffe55b Mon Sep 17 00:00:00 2001 From: Ngo Hoang Date: Wed, 6 Jun 2018 13:03:27 +0700 Subject: [PATCH] add GDPR for je --- .../backend/je-gdpr-controller.php | 152 ++++++++++++++++++ app/models/je-job-model.php | 10 +- jobs-experts.php | 2 + 3 files changed, 162 insertions(+), 2 deletions(-) create mode 100644 app/controllers/backend/je-gdpr-controller.php diff --git a/app/controllers/backend/je-gdpr-controller.php b/app/controllers/backend/je-gdpr-controller.php new file mode 100644 index 0000000..3866dc6 --- /dev/null +++ b/app/controllers/backend/je-gdpr-controller.php @@ -0,0 +1,152 @@ + __( "Jobs & Experts", je()->domain ), + 'callback' => array( $this, 'plugin_eraser' ), + ); + + return $erasers; + } + + public function register_plugin_exporter( $exporters ) { + $exporters['job_plus'] = array( + 'exporter_friendly_name' => __( "Jobs & Experts", je()->domain ), + 'callback' => array( $this, 'plugin_exporter' ), + ); + + return $exporters; + } + + public function plugin_eraser( $email, $page = 1 ) { + $jobs = JE_Job_Model::model()->find_by_attributes( array( + 'contact_email' => $email + ) ); + + $experts = JE_Expert_Model::model()->find_by_attributes( array( + 'contact_email' => $email + ) ); + + if ( count( $jobs ) ) { + foreach ( $jobs as $job ) { + $job->delete(); + } + } + if ( count( $experts ) ) { + foreach ( $experts as $expert ) { + $expert->delete(); + } + } + + return array( + 'items_removed' => count( $jobs ) + count( $experts ), + 'items_retained' => false, // we will remove all + 'messages' => array(), + 'done' => true, + ); + } + + public function plugin_exporter( $email, $page = 1 ) { + $jobs = JE_Job_Model::model()->find_by_attributes( array( + 'contact_email' => $email + ) ); + + $experts = JE_Expert_Model::model()->find_by_attributes( array( + 'contact_email' => $email + ) ); + + $export_items = array(); + if ( count( $jobs ) ) { + foreach ( $jobs as $job ) { + $item = array( + 'group_id' => 'je-jobs', + 'group_label' => __( "Jobs & Experts - Jobs Info", je()->domain ), + 'item_id' => 'je-job-' . $job->ID, + 'data' => array( + array( + 'name' => __( 'Job Name', je()->domain ), + 'value' => $job->job_title, + ), + array( + 'name' => __( 'Email', je()->domain ), + 'value' => $job->contact_email, + ), + array( + 'name' => __( 'Budget', je()->domain ), + 'value' => $job->render_prices( true ), + ), + array( + 'name' => __( 'Open For', je()->domain ), + 'value' => $job->get_due_day(), + ), + array( + 'name' => __( 'Status', je()->domain ), + 'value' => $job->get_status(), + ) + ), + ); + $export_items[] = $item; + } + } + if ( count( $experts ) ) { + foreach ( $experts as $expert ) { + $socials = explode( ',', $expert->social ); + $socials_text = array(); + foreach ( $socials as $social ) { + $model = Social_Wall_Model::model()->get_one( $social, $expert->id ); + if ( is_object( $model ) ) { + $socials_text[] = $model->name . ':' . $model->value; + } + } + $item = array( + 'group_id' => 'je-experts', + 'group_label' => __( "Jobs & Experts - Experts Info", je()->domain ), + 'item_id' => 'je-expert-' . $expert->ID, + 'data' => array( + array( + 'name' => __( 'Expert Name', je()->domain ), + 'value' => $expert->first_name . ' ' . $expert->last_name, + ), + array( + 'name' => __( 'Email', je()->domain ), + 'value' => $expert->contact_email, + ), + array( + 'name' => __( 'Company', je()->domain ), + 'value' => $expert->company, + ), + array( + 'name' => __( 'Company URL', je()->domain ), + 'value' => $expert->company_url, + ), + array( + 'name' => __( 'Location', je()->domain ), + 'value' => $expert->get_location(), + ), + array( + 'name' => __( 'Social', je()->domain ), + 'value' => implode( '
', $socials_text ), + ) + ), + ); + $export_items[] = $item; + } + } + + $export = array( + 'data' => $export_items, + 'done' => true, + ); + + return $export; + } +} \ No newline at end of file diff --git a/app/models/je-job-model.php b/app/models/je-job-model.php index 5795e43..bfae516 100644 --- a/app/models/je-job-model.php +++ b/app/models/je-job-model.php @@ -13,7 +13,7 @@ class JE_Job_Model extends IG_Post_Model { public $budget; public $contact_email; public $dead_line; - public $job_img; + public $job_img; public $open_for; public $portfolios; public $status; @@ -53,7 +53,7 @@ class JE_Job_Model extends IG_Post_Model { 'key' => '_ct_jbp_job_Due', 'map' => 'dead_line' ), - array( + array( 'type' => 'meta', 'key' => '_ct_jbp_job_img', 'map' => 'job_img' @@ -162,6 +162,7 @@ public function get_price() { public function render_prices( $return = '' ) { $prices = $this->get_price(); $currency = je()->settings()->currency; + ob_start(); if ( is_array( $prices ) ) { ?> @@ -176,6 +177,11 @@ public function render_prices( $return = '' ) { budget ) ?> settings()->plugins;