diff --git a/controllers/obadmanager.php b/controllers/obadmanager.php index 7c7c336..ffd91c6 100644 --- a/controllers/obadmanager.php +++ b/controllers/obadmanager.php @@ -82,5 +82,20 @@ public function adjust_media() $this->model('adjust_media'); return array(true,'Media adjusted.'); } + + // if media is archived, remove from ad manager. + public function media_archive_callback($hook,$position) + { + $ids = $this->data('id'); + + // if we just have a single ID, make it into an array so we can proceed on that assumption. + if(!is_array($ids)) $ids = array($ids); + + foreach($ids as $id) + { + $this->db->where('media_id',$id); + $this->db->delete('ob_ad_manager'); + } + } } diff --git a/module.php b/module.php index b8a90a4..328eca7 100644 --- a/module.php +++ b/module.php @@ -8,7 +8,7 @@ class ObAdManagerModule extends OBFModule public function callbacks() { - + $this->callback_handler->register_callback('ObAdManager.media_archive_callback','Media.archive','return',0); } public function install()