protected function _finish() { $id = $this->input->post('id'); try { $selected = array(); if ($s = $this->input->post('selected_influencers')) { $selected = explode(',', $s); } if (!$selected) { throw new \Exception('At least one influencer must be selected'); } foreach ($selected as &$s) { $s = new \MongoId($s); } $campaign = new Campaign($id); $cinfo = $campaign->filter_one(array('_id' => $campaign->id, 'state' => array('$in' => array('pending', 'rejected')))); if (!$cinfo) { throw new \Exception('Invalid Campaign'); } $campaign->update(array('state' => 'active', 'influencers_select' => $selected, 'points' => (int) $this->input->post('points'), 'global' => (bool) $this->input->post('global'))); Alert::once('success', 'Campaign is now active', Url::base('admin/campaign/view/' . $id)); } catch (\Exception $e) { Alert::once('error', $e->getMessage(), Url::base('admin/campaign/view/' . $id)); } }
protected function _channel_influencer() { try { $id = $this->input->post('id'); $campaign = new Campaign($id); $cinfo = $campaign->get(); if (!$cinfo) { throw new \Exception('Invalid campaign'); } if (!($influencer = $this->input->post('influencer'))) { throw new \Exception('Invalid influencer'); } $comment = $this->input->post('comment'); if (empty($comment)) { throw new \Exception('Comment must not be empty'); } $comments = MongoDoc::get($cinfo, 'comments.brand_influencer', array()); if (!isset($comments[$influencer])) { $comments[$influencer] = array(); } $comments[$influencer][] = array('from' => UserSession::get('user._id'), 'from_username' => UserSession::get('user.username'), 'user' => 'brand', 'created_at' => time(), 'text' => $comment); $comments[$influencer] = array_slice($comments[$influencer], -20); $campaign->update(array('comments.brand_influencer' => $comments)); Alert::once('success', 'Comment added', Url::referrer()); } catch (\Exception $e) { Alert::once('error', $e->getMessage(), Url::referrer()); } }
public function post() { try { (new NotifyBrandCampaign())->create($id); Alert::once('success', 'Campaign queued for admin approval', Url::current()); } catch (\Exception $e) { Alert::once('error', $e->getMessage(), Url::current()); } }
protected function _remove() { try { if (!($id = $this->input->post('id'))) { Alert::once('success', 'Invalid ID!', Url::current()); } $user = new PartnerModel($id); $user->remove(); Alert::once('success', 'Account removed successfully!', Url::current()); } catch (\Exception $e) { Alert::once('error', $e->getMessage(), Url::current()); } }
public function post() { try { $campaign = new Campaign(null); $cinfo = $campaign->find_modify_one(array('_id' => new \MongoId($this->input->post('id')), 'state' => array('$in' => array('pending', 'active'))), array('$set' => array('state' => 'rejected'))); if (!$cinfo) { $this->_403(); } Alert::once('success', 'Campaign has been removed', Url::base('admin/campaign/pending')); } catch (\Exception $e) { Alert::once('error', $e->getMessage(), Url::referrer()); } }
protected function _remove() { try { $influencer = new Influencer(UserSession::get('user._id')); $iinfo = $influencer->get(); if ($social = MongoDoc::get($iinfo, 'social')) { unset($social['instagram']); $influencer->update(array('social' => $social)); } } catch (\Exception $e) { Alert::once('error', 'Failed to remove account: ' . $e->getMessage(), Url::base('influencer/social')); } Alert::once('success', 'Account remove successfully', Url::base('influencer/social')); }
protected function _remove() { try { $brand = new Brand(UserSession::get('user._id')); $iinfo = $brand->get(); if ($social = MongoDoc::get($iinfo, 'social')) { unset($social['twitter']); $brand->update(array('social' => $social)); } } catch (\Exception $e) { Alert::once('error', 'Failed to remove account: ' . $e->getMessage(), Url::base('brand/social')); } Alert::once('success', 'Account remove successfully', Url::base('brand/social')); }
public function post() { try { $brand = new Brand(UserSession::get('user._id')); $binfo = $brand->get(); $data = $this->_get_data($binfo); $campaign = new Campaign(null); $id = $campaign->create($data); (new NotifyBrandCampaign())->create($id); Alert::once('success', 'Campaign queued for admin approval', Url::current()); } catch (\Exception $e) { Alert::once('error', $e->getMessage(), Url::current()); } }
protected function _remove() { try { if (!($id = $this->input->post('id'))) { Alert::once('success', 'Invalid ID!', Url::current()); } $user = new BrandModel($id); $user->remove(); $partner = new Partner(UserSession::get('user._id')); $partner->remove_brand($id); Alert::once('success', 'Brand removed successfully!', Url::current()); } catch (\Exception $e) { Alert::once('error', $e->getMessage(), Url::current()); } }
protected function _remove() { if (!UserSession::get('user.superadmin')) { $this->_403(); } try { if (!($id = $this->input->post('id'))) { Alert::once('success', 'Invalid ID!', Url::current()); } $user = new AdminModel($id); $user->remove(); Alert::once('success', 'Account removed successfully!', Url::current()); } catch (\Exception $e) { Alert::once('error', $e->getMessage(), Url::current()); } }
protected function _save_river($key) { try { $user = new Brand(UserSession::get('user._id')); $uinfo = $user->get(); $auto = !!$this->input->post('auto'); if ($auto) { if (($r = MongoDoc::get($uinfo, 'social_river.data_custom')) && isset($r[$key])) { unset($r[$key]); $user->update(array('social_river.data_custom' => (object) $r)); } } else { if (($u = $this->input->post('url')) && !empty($u)) { $user->update(array('social_river.data_custom.' . $key => trim($u))); } } Alert::once('success', 'URL updated successfully', Url::current()); } catch (\Exception $e) { Alert::once('error', $e->getMessage(), Url::current()); } }
protected function _logout() { $this->_check_login(); // If login as feature is used if ($u = UserSession::get('main_user')) { UserSession::set('user', $u); UserSession::erase('main_user'); Alert::once('warning', 'Logged in as ' . $u['username'], Url::base('')); } UserSession::destroy(); Alert::once('warning', 'You have been logged out!', Url::base('auth/login')); }