예제 #1
0
 /**
  * Sets the ad to ACTIVE and sends out emails to users
  * @param Integer $ad_id
  */
 private function approve_payment($ad_id)
 {
     if (is_numeric($ad_id) && $ad_id > 0) {
         $ad = ORM::factory('ad', $ad_id);
         // Set ad to active
         if ($ad) {
             $ad->active = 1;
             $ad->_valid = TRUE;
             $ad->save();
             $ad = ORM::factory('ad', $ad_id);
             // Updates Facebook & twitter
             Helper_Utils::send_tweet($ad);
             // Sends an email notification to the user
             $title = "Your job ad is ready [{$ad->title}]";
             $name = 'User';
             if ($ad->company_name) {
                 $name = $ad->company_name;
             }
             $amount = $this->config['paypal'][$ad->discount_code]['price_base'];
             if (1 == $ad->highlight) {
                 $amount += $this->config['paypal'][$ad->discount_code]['price_highlight'];
             }
             $template = View::factory('emails/new_ad', array('title' => $title, 'name' => $name, 'url' => Helper_Utils::get_ad_url($ad->title, $ad->id), 'ad_title' => $ad->title, 'id' => $ad->id, 'highlight' => $ad->highlight, 'discount_code' => $ad->discount_code, 'price_base' => $this->config['paypal'][$ad->discount_code]['price_base'], 'price_highlight' => $this->config['paypal'][$ad->discount_code]['price_highlight'], 'amount' => $amount))->render();
             Email::send($ad->email, $this->config['global']['email_support'], $title, $template, TRUE);
             // Send a copy to admin
             Email::send($this->config['global']['email_support'], $this->config['global']['email_support'], $title, $template, TRUE);
         }
     }
 }
예제 #2
0
 private function add_ad($fields)
 {
     $ad = ORM::factory('ad');
     $fields = array('title' => $fields['title'], 'description' => $fields['description'], 'budget' => null, 'category_id' => null, 'jobtype_id' => $fields['jobtype_id'], 'contact' => $fields['contact'], 'category_id' => 2, 'location' => $fields['location'], 'company_name' => $fields['company_name'], 'company_url' => $fields['company_url'], 'telecommute' => $fields['telecommute'], 'created_at' => $fields['created_at'], 'email' => '*****@*****.**', 'company_logo' => $fields['company_logo'], 'jobboard_id' => $fields['jobboard_id']);
     $ad->set_fields($fields);
     $ad->active = 1;
     $ad->_valid = TRUE;
     $ad->save();
     // Updates Facebook & twitter
     if ($this->config['stage'] == 'production') {
         $ad = ORM::factory('ad')->order_by('id', 'desc')->limit(1)->find();
         Helper_Utils::send_tweet($ad);
     }
 }