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))));
 }
 public function register($id, $password, $by = null)
 {
     $user = new User($id);
     $uinfo = $user->get();
     $uinfo['password'] = $password;
     $binfo = null;
     if ($by !== null) {
         $buser = new User($by);
         $binfo = $buser->get();
     } else {
         $by = $id;
         $binfo = $uinfo;
     }
     $recipients = array($id);
     $this->add(array('sender' => $by, 'recipients' => $recipients, 'text' => $this->_body($this->_prefix . __FUNCTION__ . '.php', array('user' => $uinfo, 'by' => $binfo)), 'type' => $this->_prefix . __FUNCTION__, 'url' => Url::base('influencer')));
     $this->mail_enqueue(array('to' => $uinfo['email'], 'from' => $this->_from_email, 'subject' => 'User Registered', 'message' => $this->_mail_body($this->_prefix . __FUNCTION__ . '.php', array('user' => $uinfo, 'by' => $binfo))));
     // Send notification to admins
     $admin = new Admin(null);
     $emails = array();
     foreach ($admin->filter(array()) as $doc) {
         $emails[$doc['email']] = true;
     }
     $this->mail_enqueue(array('to' => array_keys($emails), 'from' => $this->_from_email, 'subject' => 'New Influencer Registration', 'message' => $this->_mail_body('admin.' . $this->_prefix . __FUNCTION__ . '.php', array('user' => $uinfo, 'by' => $binfo))));
 }