Skip to content

Commit

Permalink
tweak - remove media from ad manager if it gets archived.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Gagnon committed Jan 28, 2014
1 parent dba7e27 commit 40ed6f8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions controllers/obadmanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

}
2 changes: 1 addition & 1 deletion module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 40ed6f8

Please sign in to comment.