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)); } }