Exemple #1
0
 protected function displayEdit()
 {
     $item = $this->getItem();
     if (empty($item) || $item->product_type != 'giftcards') {
         \Dsc\System::addMessage('Item is not a giftcard', 'error');
         $this->app->reroute('/admin/shop/giftcards');
     }
     $f3 = \Base::instance();
     $flash = \Dsc\Flash::instance();
     $variants = array();
     if ($flashed_variants = $flash->old('variants')) {
         foreach ($flashed_variants as $variant) {
             $key = implode("-", (array) $variant['attributes']);
             if (empty($key)) {
                 $key = $variant['id'];
             }
             $variants[$key] = $variant;
         }
     }
     $old = array_merge($flash->get('old'), array('variants' => $variants));
     $flash->store($old);
     $model = new \Shop\Models\Categories();
     $categories = $model->getList();
     \Base::instance()->set('categories', $categories);
     \Base::instance()->set('selected', 'null');
     $all_tags = $this->getModel()->getTags();
     \Base::instance()->set('all_tags', $all_tags);
     $this->app->set('meta.title', 'Edit Gift Card | Shop');
     $view = \Dsc\System::instance()->get('theme');
     $view->event = $view->trigger('onDisplayShopProductsEdit', array('item' => $this->getItem(), 'tabs' => array(), 'content' => array()));
     echo $view->render('Shop\\Admin\\Views::giftcards/edit.php');
 }
Exemple #2
0
 protected function displayCreate()
 {
     $f3 = \Base::instance();
     $item = $this->getItem();
     $model = new \Pages\Models\Categories();
     $categories = $model->getList();
     \Base::instance()->set('categories', $categories);
     \Base::instance()->set('selected', 'null');
     $selected = array();
     $flash = \Dsc\Flash::instance();
     $input = $flash->old('category_ids');
     if (!empty($input)) {
         foreach ($input as $id) {
             $id = $this->inputfilter->clean($id, 'alnum');
             $selected[] = array('id' => $id);
         }
     }
     $flash->store((array) $flash->get('old') + array('categories' => $selected));
     $all_tags = $this->getModel()->getTags();
     \Base::instance()->set('all_tags', $all_tags);
     $this->app->set('meta.title', 'Create Page');
     $view = \Dsc\System::instance()->get('theme');
     $view->event = $view->trigger('onDisplayPagesEdit', array('item' => $item, 'tabs' => array(), 'content' => array()));
     echo $view->render('Pages/Admin/Views::pages/create.php');
 }
Exemple #3
0
 protected function displayEdit()
 {
     $model = new \Shop\Models\Coupons();
     $flash = \Dsc\Flash::instance();
     $this->app->set('meta.title', 'Edit Coupon | Shop');
     $view = \Dsc\System::instance()->get('theme');
     $view->event = $view->trigger('onDisplayShopCouponsEdit', array('item' => $this->getItem(), 'tabs' => array(), 'content' => array()));
     echo $view->render('Shop/Admin/Views::coupons/edit.php');
 }
Exemple #4
0
 protected function displayEdit()
 {
     $item = $this->getItem();
     $flash = \Dsc\Flash::instance();
     $this->app->set('meta.title', 'Edit Product Review | Shop');
     $view = \Dsc\System::instance()->get('theme');
     $view->event = $view->trigger('onDisplayShopProductReviewsEdit', array('item' => $item, 'tabs' => array(), 'content' => array()));
     echo $view->render('Shop\\Admin\\Views::productreviews/edit.php');
 }
Exemple #5
0
 protected function displayEdit()
 {
     $f3 = \Base::instance();
     $model = new \Pages\Models\Categories();
     $categories = $model->emptyState()->getList();
     \Base::instance()->set('categories', $categories);
     $flash = \Dsc\Flash::instance();
     $selected = $flash->old('parent');
     \Base::instance()->set('selected', $selected);
     $this->app->set('meta.title', 'Edit Category | Pages');
     $view = \Dsc\System::instance()->get('theme');
     echo $view->render('Pages/Admin/Views::categories/edit.php');
 }
Exemple #6
0
 protected function displayEdit()
 {
     $f3 = \Base::instance();
     $model = $this->getModel();
     $manufacturers = $model->emptyState()->getList();
     \Base::instance()->set('manufacturers', $manufacturers);
     $flash = \Dsc\Flash::instance();
     $selected = $flash->old('parent');
     \Base::instance()->set('selected', $selected);
     $this->app->set('meta.title', 'Edit Manufacturer | Shop');
     $view = \Dsc\System::instance()->get('theme');
     $view->event = $view->trigger('onDisplayShopManufacturersEdit', array('item' => $this->getItem(), 'tabs' => array(), 'content' => array()));
     echo $view->render('Shop/Admin/Views::manufacturers/edit.php');
 }
Exemple #7
0
 protected function displayEdit()
 {
     $this->app->set('pagetitle', 'Edit Category');
     $model = new \Shop\Models\Categories();
     $categories = $model->emptyState()->getList();
     \Base::instance()->set('categories', $categories);
     $flash = \Dsc\Flash::instance();
     $selected = $flash->old('parent');
     \Base::instance()->set('selected', $selected);
     $this->app->set('allow_preview', $this->canPreview(true));
     $view = \Dsc\System::instance()->get('theme');
     $view->event = $view->trigger('onDisplayShopCategoriesEdit', array('item' => $this->getItem(), 'tabs' => array(), 'content' => array()));
     $this->app->set('meta.title', 'Edit Category | Shop');
     echo $view->render('Shop/Admin/Views::categories/edit.php');
 }
 /**
  * Target for POST to create new record
  */
 public function add()
 {
     $f3 = \Base::instance();
     $flash = \Dsc\Flash::instance();
     $data = \Base::instance()->get('REQUEST');
     //\Dsc\System::addMessage( \Dsc\Debug::dump($data) );
     if (!$this->canCreate($data)) {
         throw new \Exception('Not allowed to add record');
     }
     $__customers = explode(",", \Dsc\ArrayHelper::get($data, '__customers'));
     $__emails = explode(",", \Dsc\ArrayHelper::get($data, '__emails'));
     $emails = array_filter(array_unique(array_merge(array(), $__customers, $__emails)));
     if (!empty($emails)) {
         try {
             $this->getModel()->issueToEmails($data, $emails);
             switch ($data['submitType']) {
                 case "save_new":
                     $route = $this->create_item_route;
                     break;
                 case "save_close":
                 default:
                     $route = $this->list_route;
                     break;
             }
             $this->setRedirect($route);
         } catch (\Exception $e) {
             \Dsc\System::instance()->addMessage('Save failed with the following errors:', 'error');
             \Dsc\System::instance()->addMessage($e->getMessage(), 'error');
             if (\Base::instance()->get('DEBUG')) {
                 \Dsc\System::instance()->addMessage($e->getTraceAsString(), 'error');
             }
             // redirect back to the create form with the fields pre-populated
             \Dsc\System::instance()->setUserState('use_flash.' . $this->create_item_route, true);
             $flash->store($data);
             $this->setRedirect($this->create_item_route);
         }
     } else {
         // create just a single gift card
         $this->doAdd($data);
     }
     \Dsc\System::addMessage('Gift cards issued');
     if ($route = $this->getRedirect()) {
         \Base::instance()->reroute($route);
     }
     return;
 }
Exemple #9
0
 public function edit()
 {
     $flash = \Dsc\Flash::instance();
     $this->app->set('flash', $flash);
     $hash = $this->app->get('PARAMS.hash');
     $crontab = new \Dsc\Cron\Crontab();
     try {
         $job = $crontab->getJobByHash($hash);
         $flash->store($job->cast());
         //\Dsc\System::addMessage( \Dsc\Debug::dump($job->cast()) );
     } catch (\Exception $e) {
         \Dsc\System::addMessage($e->getMessage(), 'error');
         $this->app->reroute('/admin/cron');
         return;
     }
     $this->app->set('meta.title', 'Edit | Cron');
     echo \Dsc\System::instance()->get('theme')->renderTheme('Admin/Views::cron/edit.php');
 }
Exemple #10
0
 protected function displayCreate()
 {
     $identity = $this->getIdentity();
     if (empty($identity->id)) {
         \Dsc\System::instance()->get('session')->set('site.login.redirect', '/shop/account/addresses/create');
         \Base::instance()->reroute('/sign-in');
         return;
     }
     $flash = \Dsc\Flash::instance();
     $use_flash = \Dsc\System::instance()->getUserState('use_flash.' . $this->create_item_route);
     if (!$use_flash) {
         // this is a brand-new create, so store the prefab data
         $flash->store($this->getModel()->cast());
     }
     $this->app->set('meta.title', 'New Address');
     $view = \Dsc\System::instance()->get('theme');
     echo $view->render('Shop/Site/Views::addresses/create.php');
 }
 public function getCheckboxes()
 {
     $model = $this->getModel()->populateState();
     $categories = $model->getList();
     \Base::instance()->set('categories', $categories);
     $selected = array();
     $data = \Base::instance()->get('REQUEST');
     $input = $data['category_ids'];
     foreach ($input as $id) {
         $id = $this->inputfilter->clean($id, 'alnum');
         $selected[] = array('id' => $id);
     }
     $flash = \Dsc\Flash::instance();
     $flash->store(array('metadata' => array('categories' => $selected)));
     \Base::instance()->set('flash', $flash);
     $view = \Dsc\System::instance()->get('theme');
     $html = $view->renderLayout('Forums/Admin/Views::categories/checkboxes.php');
     return $this->outputJson($this->getJsonResponse(array('result' => $html)));
 }
Exemple #12
0
 public function createFromEvent()
 {
     // get the event_id
     $event_id = $this->inputfilter->clean($this->app->get('PARAMS.event_id'), 'alnum');
     try {
         $event = (new \Mailer\Models\Events())->setState('filter.id', $event_id)->getItem();
         if (empty($event->id)) {
             throw new \Exception('Invalid Event');
         }
     } catch (\Exception $e) {
         \Dsc\System::addMessage($e->getMessage(), 'error');
         $this->app->reroute($this->list_route);
     }
     $item = (new \Mailer\Models\Templates())->set('event_id', $event_id)->bind(array('event_subject' => $event->event_subject, 'event_html' => $event->event_html, 'event_text' => $event->event_text));
     $this->app->set('item', $item);
     $flash = \Dsc\Flash::instance();
     $flash->store($item->cast());
     $this->app->set('flash', $flash);
     $this->app->set('meta.title', 'Create Template | Mailer');
     $view = \Dsc\System::instance()->get('theme');
     echo $view->render('Mailer\\Admin\\Views::templates/create.form.php');
 }
Exemple #13
0
 /**
  * Displays the thumb
  */
 public function thumb()
 {
     $flash = \Dsc\Flash::instance();
     $this->app->set('flash', $flash);
     $slug = $this->inputfilter->clean($this->app->get('PARAMS.slug'), 'PATH');
     $item = $this->getItem();
     if ($item == null) {
         $this->app->reroute(\Assets\Models\Settings::fetch()->get('images.default_thumb'));
         exit(0);
     }
     switch ($item->storage) {
         case "s3":
         case "cloudfiles":
         case "cdn":
             $this->app->reroute($item->thumb);
             break;
         case "gridfs":
         default:
             try {
                 $thumb = \Dsc\Mongo\Collections\Assets::cachedThumb($slug);
                 if (empty($thumb['bin'])) {
                     throw new \Exception();
                 }
             } catch (\Exception $e) {
                 return $this->app->error(404, 'Invalid Thumb');
             }
             $height = $this->app->get('PARAMS.height');
             $width = $this->app->get('PARAMS.width');
             if ($height && $width) {
                 $this->app->set('height', $height);
                 $this->app->set('width', $width);
             }
             $flash->store($thumb);
             echo $this->theme->renderView('Assets/Site/Views::assets/thumb.php');
             break;
     }
 }
Exemple #14
0
 protected function displayEdit()
 {
     $item = $this->getItem();
     $flash = \Dsc\Flash::instance();
     $variants = array();
     if ($flashed_variants = $flash->old('variants')) {
         foreach ($flashed_variants as $variant) {
             $key = implode("-", (array) $variant['attributes']);
             if (empty($key)) {
                 $key = $variant['id'];
             }
             $variants[$key] = $variant;
         }
     }
     $old = array_merge($flash->get('old'), array('variants' => $variants));
     $flash->store($old);
     $model = new \Shop\Models\Categories();
     $categories = $model->getList();
     $this->app->set('categories', $categories);
     $this->app->set('selected', 'null');
     $all_tags = $this->getModel()->getTags();
     $this->app->set('all_tags', $all_tags);
     $this->app->set('meta.title', 'Edit Product | Shop');
     $this->app->set('allow_preview', $this->canPreview(true));
     $view = \Dsc\System::instance()->get('theme');
     $view->event = $view->trigger('onDisplayShopProductsEdit', array('item' => $item, 'tabs' => array(), 'content' => array()));
     switch ($item->product_type) {
         case "giftcard":
         case "giftcards":
             echo $view->render('Shop\\Admin\\Views::giftcards/edit.php');
             break;
         default:
             echo $view->render('Shop\\Admin\\Views::products/edit.php');
             break;
     }
 }
Exemple #15
0
 protected function displayEdit()
 {
     $f3 = \Base::instance();
     $all_tags = $this->getModel()->getTags();
     \Base::instance()->set('all_tags', $all_tags);
     $this->app->set('meta.title', 'Edit Asset');
     $flash = \Dsc\Flash::instance();
     $flash->store($this->getItem()->castBinarySafe());
     $view = \Dsc\System::instance()->get('theme');
     $view->event = $view->trigger('onDisplayAdminAssetEdit', array('item' => $this->getItem(), 'tabs' => array(), 'content' => array()));
     echo $view->renderTheme('Assets/Admin/Views::assets/edit.php');
 }
Exemple #16
0
 public function register()
 {
     $f3 = \Base::instance();
     $checkout_method = strtolower($this->input->get('checkout_method', null, 'alnum'));
     switch ($checkout_method) {
         // if $checkout_method == guest
         // store email in cart object and then continue
         // create a guest mongoid
         case "guest":
             $real_email = trim(strtolower($this->input->get('email_address', null, 'string')));
             if (\Users\Models\Users::emailExists($real_email)) {
                 \Dsc\System::addMessage('This email is already registered. Please login to continue.  <a href="./user/forgot-password">If necessary, you can recover your password here.</a>', 'error');
                 $this->app->reroute('/shop/checkout');
                 return;
             }
             $mongo_id = (string) new \MongoId();
             $email = 'guest-' . $mongo_id . '@' . $mongo_id . '.' . $mongo_id;
             $password = \Users\Models\Users::generateRandomString();
             $data = array('first_name' => 'Guest', 'last_name' => 'User', 'email' => $email, 'guest_email' => $real_email, 'new_password' => $password, 'confirm_new_password' => $password);
             $user = (new \Users\Models\Users())->bind($data);
             try {
                 // this will handle other validations, such as username uniqueness, etc
                 $user->guest = true;
                 $user->active = false;
                 $user->save();
             } catch (\Exception $e) {
                 \Dsc\System::addMessage('Could not create guest account', 'error');
                 \Dsc\System::addMessage($e->getMessage(), 'error');
                 \Dsc\System::instance()->setUserState('shop.checkout.register.flash_filled', true);
                 $flash = \Dsc\Flash::instance();
                 $flash->store(array());
                 $this->app->reroute('/shop/checkout');
                 return;
             }
             // if we have reached here, then all is right with the form
             $flash = \Dsc\Flash::instance();
             $flash->store(array());
             // login the user, trigger Listeners
             \Dsc\System::instance()->get('auth')->login($user);
             $this->app->reroute('/shop/checkout');
             break;
             // if $checkout_method == register
             // validate data
             // create user
             // redirect back to checkout
         // if $checkout_method == register
         // validate data
         // create user
         // redirect back to checkout
         case "register":
             $email = trim(strtolower($this->input->get('email_address', null, 'string')));
             $data = array('first_name' => $this->input->get('first_name', null, 'string'), 'last_name' => $this->input->get('last_name', null, 'string'), 'email' => $email, 'new_password' => $this->input->get('new_password', null, 'string'), 'confirm_new_password' => $this->input->get('confirm_new_password', null, 'string'));
             $user = (new \Users\Models\Users())->bind($data);
             // Check if the email already exists and give a custom message if so
             if (!empty($user->email) && ($existing = $user->emailExists($user->email))) {
                 if (empty($user->id) || $user->id != $existing->id) {
                     \Dsc\System::addMessage('This email is already registered.', 'error');
                     \Dsc\System::instance()->setUserState('shop.checkout.register.flash_filled', true);
                     $flash = \Dsc\Flash::instance();
                     $flash->store($user->cast());
                     $this->app->reroute('/shop/checkout');
                     return;
                 }
             }
             try {
                 // this will handle other validations, such as username uniqueness, etc
                 $settings = \Users\Models\Settings::fetch();
                 $registration_action = $settings->{'general.registration.action'};
                 switch ($registration_action) {
                     case "auto_login":
                         $user->active = true;
                         $user->save();
                         break;
                     case "auto_login_with_validation":
                         $user->active = false;
                         $user->save();
                         $user->sendEmailValidatingEmailAddress();
                         break;
                     default:
                         $user->active = false;
                         $user->save();
                         $user->sendEmailValidatingEmailAddress();
                         break;
                 }
             } catch (\Exception $e) {
                 \Dsc\System::addMessage('Could not create account.', 'error');
                 \Dsc\System::addMessage($e->getMessage(), 'error');
                 \Dsc\System::instance()->setUserState('shop.checkout.register.flash_filled', true);
                 $flash = \Dsc\Flash::instance();
                 $flash->store($user->cast());
                 $f3->reroute('/shop/checkout');
                 return;
             }
             // if we have reached here, then all is right with the form
             $flash = \Dsc\Flash::instance();
             $flash->store(array());
             // login the user, trigger Listeners
             \Dsc\System::instance()->get('auth')->login($user);
             $this->app->reroute('/shop/checkout');
             break;
             // if $checkout_method something else,
             // add message?
             // redirect back to checkout
         // if $checkout_method something else,
         // add message?
         // redirect back to checkout
         default:
             \Dsc\System::addMessage('Invalid Checkout Method', 'error');
             $this->app->reroute('/shop/checkout');
             break;
     }
 }
Exemple #17
0
 protected function doAdd($data)
 {
     if (empty($this->list_route)) {
         throw new \Exception('Must define a route for listing the items');
     }
     if (empty($this->create_item_route)) {
         throw new \Exception('Must define a route for creating the item');
     }
     if (empty($this->edit_item_route)) {
         throw new \Exception('Must define a route for editing the item');
     }
     if (!isset($data['submitType'])) {
         $data['submitType'] = "save_edit";
     }
     $f3 = \Base::instance();
     $flash = \Dsc\Flash::instance();
     $model = $this->getModel();
     // save
     try {
         $values = $data;
         $create = array_filter($values['stripe']);
         //make a method for this, convert float to cents
         $create['amount'] = (int) $create['amount'];
         $settings = \Striper\Models\Settings::fetch();
         // Set your secret key: remember to change this to your live secret key in production
         // See your keys here https://manage.stripe.com/account
         \Stripe\Stripe::setApiKey($settings->{$settings->mode . '.secret_key'});
         $plan = \Stripe\Plan::create($create);
         $values['stripe'] = array('id' => $plan->id, 'name' => $plan->name, 'created' => $plan->created, 'amount' => $plan->amount, 'interval' => $plan->interval, 'currency' => $plan->currency, 'interval_count' => $plan->interval_count, 'trial_period_days' => $plan->trial_period_days);
         unset($values['submitType']);
         //\Dsc\System::instance()->addMessage(\Dsc\Debug::dump($values), 'warning');
         $this->item = $model->create($values);
     } catch (\Exception $e) {
         \Dsc\System::instance()->addMessage('Save failed with the following errors:', 'error');
         \Dsc\System::instance()->addMessage($e->getMessage(), 'error');
         if (\Base::instance()->get('DEBUG')) {
             \Dsc\System::instance()->addMessage($e->getTraceAsString(), 'error');
         }
         if ($f3->get('AJAX')) {
             // output system messages in response object
             return $this->outputJson($this->getJsonResponse(array('error' => true, 'message' => \Dsc\System::instance()->renderMessages())));
         }
         // redirect back to the create form with the fields pre-populated
         \Dsc\System::instance()->setUserState('use_flash.' . $this->create_item_route, true);
         $flash->store($data);
         $this->setRedirect($this->create_item_route);
         return false;
     }
     // redirect to the editing form for the new item
     \Dsc\System::instance()->addMessage('Item saved', 'success');
     if (method_exists($this->item, 'cast')) {
         $this->item_data = $this->item->cast();
     } else {
         $this->item_data = \Joomla\Utilities\ArrayHelper::fromObject($this->item);
     }
     if ($f3->get('AJAX')) {
         return $this->outputJson($this->getJsonResponse(array('message' => \Dsc\System::instance()->renderMessages(), 'result' => $this->item_data)));
     }
     switch ($data['submitType']) {
         case "save_new":
             $route = $this->create_item_route;
             break;
         case "save_close":
             $route = $this->list_route;
             break;
         default:
             $flash->store($this->item_data);
             $id = $this->item->get($this->getItemKey());
             $route = str_replace('{id}', $id, $this->edit_item_route);
             break;
     }
     $this->setRedirect($route);
     return $this;
 }
Exemple #18
0
 protected function basics()
 {
     switch ($this->app->get('VERB')) {
         case "POST":
         case "post":
             // do the save and redirect to $this->settings_route
             return $this->save();
             break;
     }
     $flash = \Dsc\Flash::instance();
     $this->app->set('flash', $flash);
     $settings = $this->getModel()->fetch();
     $flash->store($settings->cast());
     $this->app->set('meta.title', 'Configuration | Settings');
 }
Exemple #19
0
 protected function doUpdate(array $data, $key = null)
 {
     if (empty($this->list_route)) {
         throw new \Exception('Must define a route for listing the items');
     }
     if (empty($this->create_item_route)) {
         throw new \Exception('Must define a route for creating the item');
     }
     if (empty($this->edit_item_route)) {
         throw new \Exception('Must define a route for editing the item');
     }
     if (!isset($data['submitType'])) {
         $data['submitType'] = "save_edit";
     }
     $f3 = \Base::instance();
     $flash = \Dsc\Flash::instance();
     $model = $this->getModel();
     $this->item = $this->getItem();
     // save
     $save_as = false;
     try {
         $values = $data;
         unset($values['submitType']);
         //\Dsc\System::instance()->addMessage(\Dsc\Debug::dump($values), 'warning');
         if ($data['submitType'] == 'save_as') {
             $this->item = $model->saveAs($this->item, $values);
             \Dsc\System::instance()->addMessage('Item cloned. You are now editing the new item.', 'success');
         } else {
             $this->item = $model->update($this->item, $values);
             \Dsc\System::instance()->addMessage('Item updated', 'success');
         }
     } catch (\Exception $e) {
         \Dsc\System::instance()->addMessage('Save failed with the following errors:', 'error');
         \Dsc\System::instance()->addMessage($e->getMessage(), 'error');
         foreach ($model->getErrors() as $error) {
             \Dsc\System::instance()->addMessage($error, 'error');
         }
         if ($f3->get('AJAX')) {
             // output system messages in response object
             return $this->outputJson($this->getJsonResponse(array('error' => true, 'message' => \Dsc\System::instance()->renderMessages())));
         }
         // redirect back to the edit form with the fields pre-populated
         \Dsc\System::instance()->setUserState('use_flash.' . $this->edit_item_route, true);
         $flash->store($data);
         $id = $this->item->get($this->getItemKey());
         $route = str_replace('{id}', $id, $this->edit_item_route);
         $this->setRedirect($route);
         return false;
     }
     // redirect to the editing form for the new item
     if (method_exists($this->item, 'cast')) {
         $this->item_data = $this->item->cast();
     } else {
         $this->item_data = \Dsc\ArrayHelper::fromObject($this->item);
     }
     if ($f3->get('AJAX')) {
         return $this->outputJson($this->getJsonResponse(array('message' => \Dsc\System::instance()->renderMessages(), 'result' => $this->item_data)));
     }
     switch ($data['submitType']) {
         case "save_new":
             $route = $this->create_item_route;
             break;
         case "save_close":
             $route = $this->list_route;
             break;
         case "save_as":
         default:
             $flash->store($this->item_data);
             $id = $this->item->get($this->getItemKey());
             $route = str_replace('{id}', $id, $this->edit_item_route);
             break;
     }
     $this->setRedirect($route);
     return $this;
 }
Exemple #20
0
 public function currencies()
 {
     $this->settings_route = '/admin/shop/settings/currencies';
     switch ($this->app->get('VERB')) {
         case "POST":
         case "post":
             // do the save and redirect to $this->settings_route
             return $this->save();
             break;
     }
     $flash = \Dsc\Flash::instance();
     $this->app->set('flash', $flash);
     $settings = \Shop\Models\Settings::fetch();
     $flash->store($settings->cast());
     $this->app->set('meta.title', 'Currencies | Shop');
     echo $this->theme->render('Shop/Admin/Views::settings/currencies.php');
 }
Exemple #21
0
 /**
  * Target for the completeProfileForm submission 
  */
 public function completeProfile()
 {
     $settings = \Users\Models\Settings::fetch();
     // check, if front-end registration is enabled
     if ($settings->{'general.registration.enabled'} == '0') {
         $f3->reroute('/login');
     }
     if (!$settings->isSocialLoginEnabled()) {
         \Dsc\System::addMessage('Social login is not supported.', 'error');
         \Base::instance()->reroute("/login");
     }
     $f3 = \Base::instance();
     try {
         $data = \Dsc\System::instance()->get('session')->get('users.incomplete_provider_data');
         $data['email'] = $this->input->get('email', null, 'string');
         $data['username'] = $this->input->get('username', null, 'string');
         // we just got an email from a customer, so we need to verify it
         $user = \Users\Models\Users::createNewUser($data, 'auto_login_with_validation');
         // social login should always login the user if successful,
         // so login the user if they aren't already logged in
         if (empty($this->getIdentity()->id)) {
             \Dsc\System::instance()->get('auth')->login($user);
         }
         \Dsc\System::instance()->get('session')->set('users.incomplete_provider_data', array());
     } catch (\Exception $e) {
         switch ($e->getCode()) {
             case \Users\Models\Users::E_EMAIL_EXISTS:
                 // This email is already registered
                 // Push the user back to the login page,
                 // and tell them that they must first sign-in using another method (the one they previously setup),
                 // then upon login, they can link this current social provider to their existing account
                 \Dsc\System::addMessage('This email is already registered.', 'error');
                 \Dsc\System::addMessage('Please login using the registered email address or with the other social profile that also uses this email address.', 'error');
                 \Dsc\System::addMessage('Once you are logged in, you may link additional social profiles to your account.', 'error');
                 $f3->reroute('/login');
                 break;
             default:
                 \Dsc\System::addMessage('Registration failed.', 'error');
                 \Dsc\System::addMessage($e->getMessage(), 'error');
                 \Dsc\System::instance()->setUserState('users.site.login.complete_profile.flash_filled', true);
                 $flash = \Dsc\Flash::instance();
                 $flash->store($data);
                 $f3->reroute('/login/completeProfile');
                 break;
         }
         return;
     }
     // if we have reached here, then all is right with the world.
     // redirect to the requested target, or the default if none requested
     $redirect = '/user';
     if ($custom_redirect = \Dsc\System::instance()->get('session')->get('site.login.redirect')) {
         $redirect = $custom_redirect;
     }
     \Dsc\System::instance()->get('session')->set('site.login.redirect', null);
     $f3->reroute($redirect);
 }
Exemple #22
0
 /**
  * Display the form for creating an order from an existing wishlist by wishlist_id
  * Step 2 of 2, Payment -- enter authorization/payment-data manually
  */
 public function createOrderPaymentManually()
 {
     $wishlist_id = $this->inputfilter->clean($this->app->get('PARAMS.id'), 'alnum');
     $flash = \Dsc\Flash::instance();
     $this->app->set('meta.title', 'Payment | Create Order from Wishlist | Shop');
     $item = $this->getItem();
     $this->app->set('wishlist', $item);
     $this->app->set('manual_payment', true);
     $view = $this->theme;
     $view->event = $view->trigger('onShopCreateOrderPaymentManually', array('item' => $item, 'tabs' => array(), 'content' => array()));
     echo $view->render('Shop/Admin/Views::wishlists/create_order_payment.php');
 }
Exemple #23
0
<?php

if (empty($flash)) {
    $flash = \Dsc\Flash::instance();
}
?>

<p class="alert alert-warning"><b>Important:</b> In the "Display" tab, set "Display Title" = No.  This will prevent the module's title from displaying inappropriately.</p> 

<div class="row">
    <div class="col-md-2">
        
        <h3>Display</h3>
                
    </div>
    <!-- /.col-md-2 -->
                
    <div class="col-md-10">

        <div class="form-group">
            <div class="row clearfix">
                <div class="col-md-6">        
                    <label>Display the module's title as the title of the Lightbox?</label>
                    <div class="form-group">
                    <label class="radio-inline">
                        <input type="radio" name="lightbox[title_enabled]" value="1" <?php 
if ($flash->old('lightbox.title_enabled')) {
    echo 'checked';
}
?>
> Yes