Example #1
0
 public function update($data)
 {
     if (isset($data['state']) && !in_array($data['state'], $this->_states)) {
         throw new \Exception('Invalid state: ' . $data['state']);
     }
     parent::update($data);
 }
 public function create($id)
 {
     $campaign = new Campaign($id);
     $cinfo = $campaign->get();
     $buser = new User($cinfo['brand']);
     $binfo = $buser->get();
     $this->mail_enqueue(array('to' => $binfo['email'], 'from' => $this->_from_email, 'subject' => 'Campaign Created', 'message' => $this->_mail_body($this->_prefix . __FUNCTION__ . '.php', array('user' => $binfo, 'campaign' => $cinfo))));
     // Send notification to admins
     $admin = new Admin(null);
     $emails = array();
     $recipients = array();
     foreach ($admin->filter(array()) as $doc) {
         $emails[$doc['email']] = true;
         $recipients[] = $doc['_id'];
     }
     $this->add(array('sender' => $binfo['_id'], 'recipients' => $recipients, 'text' => $this->_body('admin.' . $this->_prefix . __FUNCTION__ . '.php', array('brand' => $binfo)), 'type' => $this->_prefix . __FUNCTION__, 'url' => Url::base('admin/campaign/view/' . $id)));
     $this->mail_enqueue(array('to' => array_keys($emails), 'from' => $this->_from_email, 'subject' => 'New Campaign Approval', 'message' => $this->_mail_body('admin.' . $this->_prefix . __FUNCTION__ . '.php', array('brand' => $binfo, 'campaign' => $cinfo))));
 }
Example #3
0
 protected function _get_campaigns($filter = array())
 {
     $campaign = new Campaign(null);
     $find = array_replace(array('brand' => UserSession::get('user._id')), $filter);
     return $campaign->filter($find);
 }