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 _init() { $this->_display = new Display(); $this->_display->attach('Input', $this->input, true); $this->_display->attach('Url', new Url(), true); $this->_display->attach('Time', new Time(), true); $this->_display->attach('Alert', new Alert(), true); $this->_display->attach('Output', new Output(), true); $this->_display->attach('UserSession', new UserSession(), true); $this->_display->attach('MongoDoc', new MongoDoc(), true); $this->_display->attach('_meta', array('back-url' => $this->input->server('HTTP_REFERER'), 'current-url' => Url::current(), 'page-class' => 'none', 'page-body-class' => '', 'page-title' => 'Fluenz.io', 'page-no-menu' => false, 'page-no-sidebar' => false, 'page-css' => array(), 'page-js' => array())); }
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 { $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 _list_remove() { if (UserSession::get('user.type') !== 'brand') { $this->_403(); } try { $brand = new Brand(UserSession::get('user._id')); $binfo = $brand->get(); $list_idx = $this->input->post('list'); if (!($list = MongoDoc::get($binfo, 'lists.' . $list_idx))) { Json::error('Invalid list'); } $list['influencers'] = array_values(array_diff($list['influencers'], array(new \MongoId($this->input->post('id'))))); $redirect = null; if (count($list['influencers'])) { $binfo['lists'][$list_idx] = $list; } else { // Redirect if list is empty, cause we've removed it $redirect = Url::base(Url::current()); unset($binfo['lists'][$list_idx]); $binfo['lists'] = array_values($binfo['lists']); } $brand->update(array('lists' => $binfo['lists'])); $influencers = (new Influencer(null))->filter(array('_id' => array('$in' => $list['influencers'])), array('_id' => true, 'name' => true, 'username' => true)); $body = $this->_display->view(array('main/app/brand/influencer.list.php'), array('influencers' => $influencers), true, false); Json::success('Success', $redirect, array('body' => $body)); } catch (\Exception $e) { Json::error($e->getMessage()); } }
use yii\helpers\Html; /** * @var \yii\web\View $this * @var string $content */ \app\modules\admgoogletools\Module::loadGoogleTools(); \app\modules\admlivechat\Module::loadLiveChat(); if (Yii::$app->params['html.canonical'] === true) { $this->registerLinkTag(['rel' => 'canonical', 'href' => Url::canonical()]); } else { if (Yii::$app->params['html.canonical'] !== false) { $this->registerLinkTag(['rel' => 'canonical', 'href' => Yii::$app->params['html.canonical']]); } } if (!in_array(Yii::$app->controller->getRoute(), ['site/login', 'site/signup', 'site/request-password-reset', 'site/reset-password', 'site/user-approve'])) { Url::remember(Url::current()); } $this->beginPage(); ?> <!DOCTYPE html> <html lang="<?php echo Yii::$app->language; ?> "> <head> <meta charset="<?php echo Yii::$app->charset; ?> "/> <meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1.0"> <?php
/** * @inheritdoc */ public function init() { parent::init(); if (empty($this->tableName)) { throw new InvalidConfigException('The "tableName" property must be set.'); } $view = Yii::$app->getView(); Html::addCssClass($this->buttonOptions, $this->buttonClass); if (!$this->tableColumn) { $this->tableColumn = $this->attribute; } $id = Yii::$app->request->post('id'); $tableColumn = Yii::$app->request->post('tableColumn'); if (Yii::$app->request->isPost && $tableColumn === $this->tableColumn) { /* @var \yii\db\Connection $db */ $db = Yii::$app->get($this->db); $json['r'] = false; $query = new Query(); $row = $query->from($this->tableName)->select(['a' => $this->tableColumn])->where(['id' => $id])->limit(1)->one($db); if ($row) { if ($row['a']) { $active = false; $result = $this->falseIcon; } else { $active = true; $result = $this->trueIcon; } $db->createCommand()->update($this->tableName, [$this->tableColumn => $active], 'id=:id', [':id' => $id])->execute(); $json['r'] = true; $json['res'] = $result; } $response = Yii::$app->getResponse(); $response->clearOutputBuffers(); $response->setStatusCode(200); $response->format = Response::FORMAT_JSON; $response->data = $json; $response->send(); Yii::$app->end(); } $view->registerJs(' $(document).on("click", ".' . $this->buttonClass . '", function(){ var $btn = $(this); $btn.html("' . $this->loading . '"); $btn.attr("disabled", true); $.ajax({ url: "' . Url::current() . '", type: "POST", dataType: "json", data: {id: $btn.attr("data-id"), tableColumn: $btn.attr("data-column")}, }).done(function(d){ if(d.r){ $btn.html(d.res); } }).always(function(jqXHR, textStatus){ $btn.attr("disabled", false); }); }); '); }