Example #1
0
 static function init()
 {
     global $advman_engine, $advman_list;
     $advman_list = new Advman_Template_Table_List();
     //Detect when a bulk action is being triggered...
     $action = OX_Tools::sanitize_request_var('action');
     // Perform actions
     if ($action) {
         $ads = Advman_Tools::get_current_ads();
         if ($ads) {
             if (count($ads) == 1) {
                 // If there is a single ad selected, then perform the action on that ad.  Notice messages and workflow are different in this case
                 foreach ($ads as $ad) {
                     Advman_Admin::ad_action($action, $ad);
                 }
             } else {
                 // These are bulk actions
                 switch ($action) {
                     case 'copy':
                         foreach ($ads as $ad) {
                             if ($ad) {
                                 $advman_engine->copyAd($ad->id);
                             }
                         }
                         Advman_Admin::add_notice('advman-notice-once', __("Ads copied"), false);
                         break;
                     case 'delete':
                         foreach ($ads as $ad) {
                             if ($ad) {
                                 $advman_engine->deleteAd($ad->id);
                             }
                         }
                         Advman_Admin::add_notice('advman-notice-once', __("Ads deleted"), false);
                         break;
                 }
             }
         } else {
             $ad = Advman_Tools::get_current_ad();
             if ($ad) {
                 Advman_Admin::ad_action($action, $ad);
             }
         }
         $url = remove_query_arg(array('action', 'ad', 'network', '_wpnonce'));
         wp_redirect($url);
     }
 }
Example #2
0
 static function preview_ad()
 {
     $ad = Advman_Tools::get_current_ad();
     $template = Advman_Tools::get_template('Ad_Preview', $ad);
     $template->display($ad);
 }