Exemple #1
0
 function _notify_discount_applied($discount_percentage, $coupon)
 {
     $username = $this->tank_auth->get_username() ? $this->tank_auth->get_username() : 'creature';
     $domain_discount = get_current_user_discount_domain_info();
     //Notify event for modal pop up
     if ($discount_percentage == 0) {
         $params['title'] = "wrong cheat code";
         $params['body'] = "<strong>{$username}</strong>, either there is no such cheat code like this or it cannot be applied right now.<br>Anyway, we strongly encourage playing games with no cheat codes applied.<br>But here is a hint just for you.<br><br><strong>Hint : Google \"What is the Konami code\"</strong>. ";
     } else {
         if (count($domain_discount)) {
             $params['title'] = $username;
             $params['body'] = "We already gave you <strong>{$domain_discount['how_much']}%</strong> off because you belong to the lands of <strong>{$domain_discount['domain']}</strong>. Now dont push us, we cannot afford to give you anymore discount, that would be unfair for our people. Hope you understand.";
         } else {
             //Personalised message depending on cheat code applied
             switch ($coupon) {
                 case 'frapp_mode':
                     $params['title'] = "Cheat Code Applied {$discount_percentage}% off";
                     $params['body'] = "<strong>{$username}</strong>, We all have been through student life and we all know how important discounts are, wish frapp was there in our times as well. Enjoy your <strong>{$discount_percentage}%</strong> discount. <br><br>Happy gaming/debugging!";
                     break;
                 case 'bin_mode':
                     $params['title'] = "Cheat Code Applied {$discount_percentage}% off";
                     $params['body'] = "Hello, <strong>earthling</strong>, a big thank you from BinBag and Psycho Store for being a responsible creature of earth. For all your good deeds we have applied <strong>{$discount_percentage}%</strong> discount just for you. <br><br>Happy gaming/debugging!";
                     break;
                 default:
                     $params['title'] = "Cheat Code Applied {$discount_percentage}% off";
                     $params['body'] = "<strong>{$username}</strong>, we strongly oppose gaming with cheat codes applied. But anyway, we have made this game <strong>{$discount_percentage}%</strong> easier, just for you.<br><br>Happy gaming/debugging!";
                     break;
             }
         }
     }
     notify_event('apply_discount', $params);
 }
 function execute_events(&$data)
 {
     $ci =& get_instance();
     $ci->load->library('session');
     $events = $ci->session->userdata('events');
     if ($events) {
         foreach ($events as $event_name => $params) {
             $script_params['timeout'] = 0;
             $script_params['button_text'] = 'Close';
             $script_params['event_name'] = $event_name;
             switch ($event_name) {
                 case 'login_done':
                     $discount_domain = get_current_user_discount_domain_info();
                     if (count($discount_domain)) {
                         $domain = $discount_domain['domain'];
                         $discount = $discount_domain['how_much'];
                         $script_params['modal_title'] = $params['title'];
                         $script_params['modal_body'] = "We noticed that you hail from the lands of <strong>{$domain}.</strong> We have huge respect for creatures hailing from that land, because of which we will be giving you <strong>{$discount}%</strong> off on each and every purchase that you make from us.";
                         $data['scripts'][] = array('path' => 'events/modal', 'params' => $script_params);
                     }
                     break;
                 case 'apply_discount':
                     $script_params['modal_title'] = $params['title'];
                     $script_params['modal_body'] = $params['body'];
                     $data['scripts'][] = array('path' => 'events/modal', 'params' => $script_params);
                     break;
                 case 'show_cheat_code':
                     $script_params['modal_title'] = $params['title'];
                     $script_params['modal_body'] = $params['body'];
                     $script_params['timeout'] = $params['timeout'];
                     $script_params['button_text'] = 'Thanks, you guys rock';
                     $data['scripts'][] = array('path' => 'events/modal', 'params' => $script_params);
                     break;
                 case 'register_cart':
                     $script_params['modal_title'] = $params['title'];
                     $script_params['modal_body'] = $params['body'];
                     $data['scripts'][] = array('path' => 'events/modal', 'params' => $script_params);
                     break;
                 case 'alert':
                     $script_params['alert_text'] = $params['alert_text'];
                     $script_params['timeout'] = $params['timeout'];
                     $data['scripts'][] = array('path' => 'events/alert', 'params' => $script_params);
                     break;
                 default:
                     # code...
                     break;
             }
         }
         $ci->session->set_userdata('events', null);
     }
 }