/** * {@inheritDoc} */ public function processPost($request) { $shoppingCart = $this->get('shoppingCart'); $checkoutHelper = $shoppingCart->getCheckoutHelper(); $settingsService = $this->container->get('settingsService'); if (!$checkoutHelper->verifyHash($request)) { return $this->findView('check_cart'); } if ('free_free' == $_SESSION['shipping']) { // <johnny> When does this actually happen? $this->get('logger')->warn('fixing free_free shipping method info'); $translator = $this->get('translator'); $_SESSION['shipping'] = array('title' => $translator->trans('Free Shipping'), 'cost' => 0, 'id' => 'free_free'); } if (null !== ($viewId = $checkoutHelper->validateCheckout($request, false))) { return $this->findView($viewId); } if (null !== ($viewId = $checkoutHelper->validateAddresses($request, true))) { return $this->findView($viewId); } if (null != ($comments = $request->request->get('comments'))) { $shoppingCart->setComments($comments); } if ($settingsService->get('isConditionsMessage') && !Toolbox::asBoolean($request->request->get('conditions'))) { $this->get('session.flash_bag')->error($translator->trans('Please confirm the terms and conditions bound to this order by ticking the box below.')); return $this->findView(); } if (null != ($paymentMethod = $request->request->get('payment'))) { $request->getSession()->set('payment', $paymentMethod); } return $this->processGet($request); }
/** * {@inheritDoc} */ public function execute() { if (!$plugin || !$plugin->isEnabled()) { return true; } $plugin = $this->getPlugin(); $scheduledOrders = self::findScheduledOrders(); $scheduleEmailTemplate = Runtime::getSettings()->get('plugins.subscriptions.email.templates.schedule', 'checkout'); $orderService = $this->container->get('orderService'); $translator = $this->container->get('translator'); foreach ($scheduledOrders as $scheduledOrderId) { // 1) copy $newOrder = self::copyOrder($scheduledOrderId); // load the new order as proper ZenMagick\StoreBundle\Entity\Order\Order instance for further use $order = $orderService->getOrderForId($newOrder->getOrderId(), $this->container->get('session')->getLanguageId()); if (null === $order) { $this->container->get('logger')->err('copy order failed for scheduled order: ' . $scheduledOrderId); continue; } // 2) update shipping/billing from account to avoid stale addresses if ('account' == $plugin->get('addressPolicy')) { $account = $this->container->get('accountService')->getAccountForId($order->getAccountId()); if (null === $account) { $this->container->get('logger')->warn('invalid accountId on order: ' . $order->getId()); continue; } $defaultAddressId = $account->getDefaultAddressId(); $defaultAddress = $this->container->get('addressService')->getAddressForId($defaultAddressId); $order->setShippingAddress($defaultAddress); $orderService->updateOrder($order); } // 3) update subscription specific data $order->set('subscriptionOrderId', $scheduledOrderId); $order->set('subscription', false); $order->setStatus($plugin->get('orderStatus')); $orderService->updateOrder($order); // 4) Create history entry if enabled if (Toolbox::asBoolean($plugin->get('orderHistory'))) { $status = Beans::getBean('ZenMagick\\StoreBundle\\Entity\\Order\\OrderStatusHistory'); $status->setId($plugin->get('orderStatus')); $status->setOrderId($order->getId()); $status->setOrderStatusId($order->getOrderStatusId()); $status->setCustomerNotified(!Toolbox::isEmpty($scheduleEmailTemplate)); $comment = $translator->trans('Scheduled order for subscription #%s', array('%id%' => $scheduledOrderId)); $status->setComment($comment); $orderService->createOrderStatusHistory($status); } // 5) Update subscription order with next schedule date // calculate new subscription_next_order based on current subscription_next_order, as we might not run on the same day $sql = "UPDATE %table.orders%\n SET subscription_next_order = DATE_ADD(subscription_next_order, INTERVAL " . zm_subscriptions::schedule2SQL($order->get('schedule')) . ")\n WHERE orders_id = :orderId"; $args = array('orderId' => $scheduledOrderId); ZMRuntime::getDatabase()->updateObj($sql, $args, 'orders'); if (!Toolbox::isEmpty($scheduleEmailTemplate)) { $this->sendOrderEmail($order, $scheduleEmailTemplate); } // event $this->container->get('event_dispatcher')->dispatch('create_order', new GenericEvent($this, array('orderId' => $order->getId()))); } return true; }
/** * Event callback to add required JS. */ public function onFinaliseContent($event) { $request = $event->getArgument('request'); if ('store_locator' == $request->getRequestId()) { $storeKey = $this->get('storeKey'); $location = $this->get('location'); $zoom = $this->get('zoom'); $markerText = $this->get('marker_text'); $controls = Toolbox::asBoolean($this->get('controls')); $script = ' <script type="text/javascript" src="http://www.google.com/jsapi?key=' . $storeKey . '"></script> <script type="text/javascript"> google.load("maps", "2.x"); function load_locator_map() { var map = new GMap2(document.getElementById("locator_map")); ' . ($controls ? 'map.addControl(new GLargeMapControl());/*map.addControl(new GMapTypeControl());*/' : '') . ' map.setCenter(new GLatLng(' . $location . '), ' . $zoom . '); var marker = new GMarker(map.getCenter()); map.addOverlay(marker); ' . (!empty($markerText) ? 'marker.openInfoWindowHtml("' . $markerText . '")' : '') . ' } google.setOnLoadCallback(load_locator_map); </script> '; $content = $event->getArgument('content'); $content = preg_replace('/<\\/body>/', $script . '</body>', $content, 1); $event->setArgument('content', $content); } }
/** * {@inheritDoc} */ public function processPost($request) { $globalProductSubscriber = Toolbox::asBoolean($request->request->get('product_global', false)); $account = $this->getUser(); $isGlobalUpdate = false; if ($globalProductSubscriber != $account->isGlobalProductSubscriber()) { $account->setGlobalProductSubscriber($globalProductSubscriber); $this->container->get('accountService')->setGlobalProductSubscriber($account->getId(), $globalProductSubscriber); $isGlobalUpdate = true; } $notifyType = $request->request->get('notify_type'); $subscribedProducts = $request->request->get('notify', array()); if (!$isGlobalUpdate && 'set' == $notifyType) { // if global update is on, products are not listed in the form, // therefore, they would all be removed if updated! $account = $this->container->get('accountService')->setSubscribedProductIds($account, $subscribedProducts); } $message = $this->get('translator')->trans('Your product subscriptions have been updated.'); $this->get('session.flash_bag')->success($message); switch ($notifyType) { case 'add': $account = $this->container->get('accountService')->addSubscribedProductIds($account, $subscribedProducts); return new RedirectResponse($request->headers->get('referer')); break; case 'remove': $account = $this->container->get('accountService')->removeSubscribedProductIds($account, $subscribedProducts); return new RedirectResponse($request->headers->get('referer')); break; } return $this->findView('success', array('currentAccount' => $account)); }
/** * {@inheritDoc} */ public function processPost($request) { $newsletterSubscriber = Toolbox::asBoolean($request->request->get('newsletter_general', false)); $account = $this->getUser(); if ($newsletterSubscriber != $account->isNewsletterSubscriber()) { $account->setNewsletterSubscriber($newsletterSubscriber); $this->container->get('accountService')->updateAccount($account); } $this->get('session.flash_bag')->success($this->get('translator')->trans('Your newsletter subscription has been updated.')); return $this->findView('success', array('currentAccount' => $account)); }
/** * {@inheritDoc} */ public function processGet($request) { //TODO: this should be POST!! $productGroupPricing = Beans::getBean('ZenMagick\\plugins\\productGroupPricing\\model\\ProductGroupPricing'); if (Toolbox::asBoolean($request->getParameter('delete'))) { $productGroupPricing->populate($request); // delete $this->container->get('productGroupPricingService')->updateProductGroupPricing($productGroupPricing); } return $this->findView(null, array('productGroupPricing' => $productGroupPricing)); }
/** * Run cron. * * <p>This method is used by all methods to execute cron jobs.</p> * * <p>All output is captured and logged.</p> */ public function runCron() { ob_start(); $cron = new CronJobs($this->getConfigPath('etc/crontab.txt'), $this->getConfigPath('etc/cronhistory.txt')); if ($cron->isTimeToRun()) { // update timestamp to stop other instances from running $cron->updateTimestamp(); foreach ($cron->getJobs(false, Toolbox::asBoolean($this->get('missedRuns'))) as $job) { $cron->runJob($job); } } $this->container->get('logger')->debug('Cron: ' . ob_get_clean()); }
/** * {@inheritDoc} * * @todo allow cancel at any time */ public function processGet($request) { $translator = $this->get('translator'); if (!Toolbox::asBoolean($this->getPlugin()->get('customerCancel'))) { $this->get('session.flash_bag')->error($translator->trans('Insufficient permission')); return $this->findView(); } $orderId = $request->query->getInt('orderId'); $order = $this->container->get('orderService')->getOrderForId($orderId, $request->getSession()->getLanguageId()); $account = $order->getAccount(); // make sure this is an allowed order if ($order->getAccountId() != $order->getAccountId()) { $this->get('session.flash_bag')->error($translator->trans('Invalid order selected')); return $this->findView(); } $plugin = $this->getPlugin(); // check for number of scheduled orders $sql = "SELECT COUNT(orders_id) AS total FROM %table.orders%\n WHERE subscription_order_id = :subscriptionOrderId"; $results = \ZMRuntime::getDatabase()->querySingle($sql, array('subscriptionOrderId' => $orderId), 'orders', Connection::MODEL_RAW); if ($results['total'] < $plugin->get('minOrders')) { $message = $translator->trans('This subscription can only be canceled after a minimum of %count% orders', array('%count%' => $plugin->get('minOrders'))); $this->get('session.flash_bag')->error($message); return $this->findView(); } $cancelDeadline = $plugin->get('cancelDeadline'); if (0 < $cancelDeadline) { // this will return only a result if subscription_next_order is more than $cancelDeadline days in the future $sql = "SELECT orders_id\n FROM %table.orders%\n WHERE orders_id = :orderId\n AND DATE_SUB(subscription_next_order, INTERVAL " . $cancelDeadline . " DAY) >= CURDATE()"; $result = \ZMRuntime::getDatabase()->querySingle($sql, array('orderId' => $orderId), 'orders', Connection::MODEL_RAW); if (null == $result) { $message = $translator->trans("Can't cancel less than %count% days before next subscription", array('%count%' => $cancelDeadline)); $this->get('session.flash_bag')->error($message); return $this->findView(); } } $sql = "UPDATE %table.orders%\n SET is_subscription_canceled = :subscriptionCanceled\n WHERE orders_id = :orderId"; \ZMRuntime::getDatabase()->updateObj($sql, array('orderId' => $orderId, 'subscriptionCanceled' => true), 'orders'); $this->get('session.flash_bag')->success($translator->trans('Subscription canceled!')); $settingsService = $this->container->get('settingsService'); $emailTemplate = $settingsService->get('plugins.subscriptions.email.templates.cancel', 'subscription_cancel'); $this->sendCancelEmail($order, $emailTemplate, $account->getEmail()); $adminEmail = $plugin->get('adminEmail'); if (empty($adminEmail)) { $adminEmail = $settingsService->get('storeEmail'); } if (!Toolbox::isEmpty($adminEmail)) { $this->sendCancelEmail($order, $cancelEmailTemplate, $adminEmail); } return $this->findView(); }
/** * Event handler. */ public function onFinaliseContent($event) { $request = $event->getArgument('request'); $trackerCode = $this->getTrackerCodeGa($request); $checkoutCode = $this->getCheckoutCodeGa($request); $code = !empty($checkoutCode) ? $checkoutCode : $trackerCode; $code .= $this->getConversionCode($request); if (Toolbox::asBoolean($this->get('debug'))) { $code = str_replace('<script', '<!--script', $code); $code = str_replace('</script>', '/script-->', $code); } $content = $event->getArgument('content'); $content = preg_replace('/<\\/body>/', $code . '</body>', $content, 1); $event->setArgument('content', $content); }
/** * {@inheritDoc} */ public function getViewData($request) { if (!Toolbox::asBoolean($request->getParameter('other', false))) { $sql = "SELECT count(ci.customers_info_source_id) AS count, s.sources_name AS name, s.sources_id as sourceId\n FROM %table.customers_info% ci LEFT JOIN %table.sources% s ON s.sources_id = ci.customers_info_source_id\n GROUP BY s.sources_id\n ORDER BY ci.customers_info_source_id DESC"; $isOther = false; } else { $sql = "SELECT count(ci.customers_info_source_id) as count, so.sources_other_name as name\n FROM %table.customers_info% ci, %table.sources_other% so\n WHERE ci.customers_info_source_id = " . ID_SOURCE_OTHER . " AND so.customers_id = ci.customers_info_id\n GROUP BY so.sources_other_name\n ORDER BY so.sources_other_name DESC"; $isOther = true; } $sourceStats = \ZMRuntime::getDatabase()->fetchAll($sql, array(), array('sources'), 'ZenMagick\\Base\\ZMObject'); $resultSource = new ZMArrayResultSource('ZenMagick\\Base\\ZMObject', $sourceStats); $resultList = Beans::getBean('ZMResultList'); $resultList->setResultSource($resultSource); $resultList->setPageNumber($request->query->get('page', 1)); return array('resultList' => $resultList, 'isOther' => $isOther); }
/** * Populate all available fields from the given request. * * @param ZenMagick\Http\Request request The current request. */ public function populate($request) { $this->id = $request->getParameter('groupPricingId', '0'); $this->productId = $request->get('productId'); $this->groupId = $request->getParameter('groupId', '0'); $this->discount = $request->getParameter('discount', '0'); $this->type = $request->getParameter('type', '%'); $this->allowSaleSpecial = Toolbox::asBoolean($request->getParameter('allowSaleSpecial', false)); $startDate = $request->getParameter('startDate'); if (empty($startDate)) { // default to current date $startDate = new \DateTime(); } $localeService = $this->container->get('localeService'); $this->startDate = \DateTime::createFromFormat($localeService->getFormat('date', 'short'), $startDate); $this->endDate = \DateTime::createFromFormat($localeService->getFormat('date', 'short'), $request->getParameter('endDate')); }
/** * Pull either a Gravatar URL or complete image tag for a specified email address. * * @param string $email The email address * @param string $s Size in pixels, defaults to 80px [ 1 - 512 ] * @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ] * @param string $r Maximum rating (inclusive) [ g | pg | r | x ] * @param boole $img True to return a complete IMG tag False for just the URL * @param array $atts Optional, additional key/value attributes to include in the IMG tag * @return String containing either just a URL or a complete image tag * @source http://gravatar.com/site/implement/images/php/ */ private function pullGravatar($email, $s = 80, $d = 'mm', $r = 'g', $img = false, $atts = array()) { $request = $this->container->get('request'); $url = $request->isSecure() ? 'https://secure.gravatar.com/avatar/' : 'http://www.gravatar.com/avatar/'; $url .= md5(strtolower(trim($email))); $url .= "?s={$s}&d={$d}&r={$r}"; if (Toolbox::asBoolean($this->get('forceReload'))) { $url .= '&ts=' . time(); } if ($img) { $url = '<img src="' . $url . '"'; foreach ($atts as $key => $val) { $url .= ' ' . $key . '="' . $val . '"'; } $url .= ' />'; } return $url; }
/** * {@inheritDoc} */ public function processPost($request) { $orderId = $request->request->getInt('orderId'); $cancel = $request->request->get('cancel'); $hard = Toolbox::asBoolean($request->request->get('hard'), false); if (0 != $orderId && 'cancel' == $cancel) { $sql = "UPDATE %table.orders%\n SET is_subscription_canceled = :subscriptionCanceled, is_subscription = :subscription\n WHERE orders_id = :orderId"; \ZMRuntime::getDatabase()->updateObj($sql, array('orderId' => $orderId, 'subscriptionCanceled' => true, 'subscription' => !$hard), 'orders'); $this->get('session.flash_bag')->success($this->get('translator')->trans("Subscription canceled!")); } $order = $this->container->get('orderService')->getOrderForId($orderId, $request->getSession()->getLanguageId()); $emailTemplate = $this->container->get('settingsService')->get('plugins.subscriptions.email.templates.cancel', 'subscription_cancel'); $email = $order->getAccount()->getEmail(); if (!Toolbox::isEmpty($email)) { $this->sendCancelEmail($order, $emailTemplate, $email); } return $this->findView('success'); }
/** * Init done callback. * * <p>Setup additional validation rules; this is done here to avoid getting in the way of * custom global/theme validation rule setups.</p> */ public function onContainerReady($event) { $request = $event->getArgument('request'); $disableRegistered = Toolbox::asBoolean($this->get('disableRegistered')); if ($disableRegistered && $request->getSession()->isRegistered()) { // skip return; } // check if we need to do anything for this request... $requestId = $request->getRequestId(); if (true == $this->get($requestId) && isset($this->pageConfig[$requestId])) { $form = $this->pageConfig[$requestId][1]; // active for this page $this->captchaEnabled = true; $rules = array(array('ZMRequiredRule', RECAPTCHA_FIELD, 'Please enter the captcha.'), array("ZMWrapperRule", RECAPTCHA_FIELD, 'The entered captcha is not correct.', array($this, 'vRecaptcha'))); $this->container->get('zmvalidator')->addRules($form, $rules); } }
/** * Update plugin status. */ public function setPluginStatus($rpcRequest) { $data = $rpcRequest->getData(); $pluginId = $data->pluginId; $status = Toolbox::asBoolean($data->status); $rpcResponse = $rpcRequest->createResponse(); $pluginService = $this->container->get('pluginService'); $translator = $this->get('translator'); if (null == ($plugin = $pluginService->getPluginForId($pluginId, true))) { $rpcResponse->setStatus(false); $rpcResponse->addMessage($translator->trans('Invalid plugin id'), 'error'); } else { $configPrefix = PluginsController::prefix($plugin); $configService = $this->container->get('configService'); $this->container->get('configService')->updateConfigValue($configPrefix . PluginOptionsLoader::KEY_ENABLED, $status); $rpcResponse->addMessage($translator->trans('Status updated'), 'success'); } $this->container->get('pluginStatusMapBuilder')->getStatusMap(true); return $rpcResponse; }
/** * Set page property. */ public function setEZPageProperty($rpcRequest) { $data = $rpcRequest->getData(); $pageId = $data->pageId; $languageId = $data->languageId; $property = $data->property; $value = $data->value; if (in_array($property, array('NewWin', 'SSL', 'header', 'sidebox', 'footer', 'toc'))) { $value = Toolbox::asBoolean($value); } $rpcResponse = $rpcRequest->createResponse(); $ezPageService = $this->container->get('ezPageService'); if (null != ($ezPage = $ezPageService->getPageForId($pageId, $languageId))) { Beans::setAll($ezPage, array($property => $value)); $ezPageService->updatePage($ezPage); $rpcResponse->setStatus(true); } else { $rpcResponse->setStatus(false); } return $rpcResponse; }
/** * Check if prices are tax inclusive. * * @return boolean <code>true</code> if included, <code>false</code> if not. */ public function isIncludeTax() { return Toolbox::asBoolean($this->get('includeTax')); }
/** * Check if guest checkout should be handled as well. * * @return boolean <code>true</code> if enabled. */ public function isEnableOnGuestCheckout() { return Toolbox::asBoolean($this->get('enableOnGuestCheckout')); }
/** * Set the auto search flag. * * <p>If enabled, the controller will automatically run a search even if only the keyword is set. * This allows to create simple URLs that run a search.</p> * * @param boolean autoSearch The new value. */ public function setAutoSearch($autoSearch) { $this->autoSearch = Toolbox::asBoolean($autoSearch); }
/** * Returns <code>true</code> if the account has subscribed to newsletter. * * @return boolean <code>true</code> if newsletter subsricption ias active, <code>false</code> if not. */ public function isNewsletterSubscriber() { return Toolbox::asBoolean($this->newsletter); }
/** * Check if this request is an Ajax request. * * <p>This default implementation will check for a 'X-Requested-With' header. Subclasses are free to * extend and override this method for custom Ajax detecting.</p> * * @return boolean <code>true</code> if this request is considered an Ajax request. */ public function isXmlHttpRequest() { $ajax = $this->getParameter('ajax', null); return $ajax != null ? Toolbox::asBoolean($ajax) : parent::isXmlHttpRequest(); }
/** * Enable/disable displaying all available banners in the given group. * * @param boolean value The new value. */ public function setShowAll($value) { $this->showAll = Toolbox::asBoolean($value); }
/** * Set secure flag. * * @param boolean secure <code>true</code> to create a secure redirect. */ public function setSecure($secure) { $this->secure = Toolbox::asBoolean($secure); }
/** * Event callback to inject the required JS. */ public function onFinaliseContent($event) { $request = $event->getArgument('request'); $trackingType = $this->get('trackingType'); if (in_array($request->getRequestId(), array('product_info', 'shopping_cart')) && null !== $this->recommendationsLoadedFor) { // TODO: won't work with minify $scriptFile = 'ga' == $trackingType ? 'liftsuggest.js' : 'liftsuggest_traditional.js'; $protocol = $request->isSecure() ? 'https://' : 'http://'; $code1 = sprintf('<script type="text/javascript" src="%swww.liftsuggest.com/js/%s?cache=%s"></script>', $protocol, $scriptFile, Toolbox::random(10, Toolbox::RANDOM_DIGITS)); $code2 = $this->getTrackerCode($request); if (Toolbox::asBoolean($this->get('debug'))) { $code1 = str_replace('<script', '<!--script', $code1); $code1 = str_replace('</script>', '/script-->', $code1); $code2 = str_replace('<script', '<!--script', $code2); $code2 = str_replace('</script>', '/script-->', $code2); } $content = $event->getArgument('content'); if ('ga' == $trackingType) { $content = preg_replace('/<\\/head>/', $code1 . '</head>', $content, 1); $content = preg_replace('/pageTracker._trackPageview\\(/', $code2 . 'pageTracker._trackPageview(', $content, 1); } elseif ('as' == $trackingType) { $content = preg_replace('/<\\/body>/', $code1 . $code2 . '</body>', $content, 1); } $event->setArgument('content', $content); } }
/** * Get the formatted attribute string. * * @param ZenMagick\Http\Request request The current request. * @param boolean addValue Optional flag to include/exclude the value; default is <code>true</code>. * @param boolean addName Optional flag to include/exclude the name; default is <code>true</code>. * @return string All set (and allowed) attributes as formatted HTML string. */ public function getAttributeString($request, $addValue = true, $addName = true) { $html = Runtime::getContainer()->get('htmlTool'); $attr = ''; if ($addName) { $attr = ' name="' . $this->getName() . ($this->isMultiValue() ? '[]' : '') . '"'; } $class = $this->getClass(); if (!empty($class)) { $attr .= ' class="' . $class . '"'; } foreach ($this->getProperties() as $name => $value) { if (in_array($name, $this->attributeNames)) { if (in_array($name, self::$NO_VAL_ATTR)) { if (Toolbox::asBoolean($this->get($name))) { $attr .= ' ' . $name . '="' . $name . '"'; } } else { $value = $this->encode ? $html->encode($value) : $value; $attr .= ' ' . $name . '="' . $value . '"'; } } } if ($addValue) { $value = $this->encode ? $html->encode($this->getValue()) : $this->getValue(); $attr .= ' value="' . $value . '"'; } return $attr; }
/** * {@inheritDoc} */ public function processPost($request) { $role = $request->request->get('role'); // changed permissions $permissons = $request->request->get('perm'); // new permissions $requestIds = $request->request->get('requestId', array()); $nperms = $request->request->get('nperm', array()); for ($ii = 0; $ii < count($requestIds); ++$ii) { if (!empty($requestIds[$ii]) && Toolbox::asBoolean($nperms[$ii])) { $permissons[] = $requestIds[$ii]; } } // figure out the overlap between the current perms and the submitted ones $this->container->get('sacsPermissionService')->setPermissionsForRole($role, $permissons); return $this->findView(); }
/** * {@inheritDoc} */ public function processPost($request) { $action = $request->request->get('action'); $multiAction = $request->request->get('multiAction'); $pluginId = $request->request->get('pluginId'); $multiPluginId = $request->request->get('multiPluginId'); // convert single action into multi if (null != $action && null != $pluginId) { $multiPluginId = array($pluginId); } else { $action = $multiAction; $multiPluginId = explode(',', $multiPluginId); } $pluginService = $this->container->get('pluginService'); // force loading all $pluginService->getAllPlugins(false); $viewId = null; $loggingService = $this->container->get('logger'); $translator = $this->get('translator'); foreach ($multiPluginId as $pluginId) { if ('install' == $action) { if (null != ($plugin = $pluginService->getPluginForId($pluginId)) && !$plugin->isInstalled()) { $loggingService->debug('install plugin: ' . $plugin->getId()); $this->install($plugin); $message = $translator->trans('Plugin %name% installed successfully', array('%name%' => $plugin->getName())); $this->get('session.flash_bag')->success($message); $this->get('session.flash_bag')->addAll($plugin->getMessages()); $viewId = 'success-install'; } } elseif ('uninstall' == $action) { $keepSettings = Toolbox::asBoolean($request->request->get('keepSettings', false)); if (null != ($plugin = $pluginService->getPluginForId($pluginId)) && $plugin->isInstalled()) { $loggingService->debug('un-install plugin: ' . $plugin->getId() . '; keepSettings: ' . ($keepSettings ? 'true' : 'false')); $this->remove($plugin, $keepSettings); $message = $translator->trans('Plugin %name% un-installed successfully', array('%name%' => $plugin->getName())); $this->get('session.flash_bag')->success($message); $this->get('session.flash_bag')->addAll($plugin->getMessages()); $viewId = 'success-uninstall'; } } elseif ('upgrade' == $action) { if (null != ($plugin = $pluginService->getPluginForId($pluginId)) && $plugin->isInstalled()) { $loggingService->debug('upgrade plugin: ' . $plugin->getId()); $this->upgrade($plugin); $message = $translator->trans('Plugin %name% upgraded successfully', array('%name%' => $plugin->getName())); $this->get('session.flash_bag')->success($message); $this->get('session.flash_bag')->addAll($plugin->getMessages()); $viewId = 'success-upgrade'; } } elseif ('update' == $action) { if (null != ($plugin = $pluginService->getPluginForId($pluginId)) && $plugin->isInstalled()) { $configPrefix = self::prefix($plugin); $configService = $this->container->get('configWidgetService'); foreach ($this->widgets($plugin->getOptions()) as $widget) { if ($widget instanceof FormWidget && null !== ($value = $request->request->get($widget->getName()))) { if (!$widget->compare($value)) { // value changed, use widget to (optionally) format value $widget->setValue($value); $configService->updateConfigValue(strtoupper($configPrefix . $widget->getName()), $widget->getStringValue()); } } } } } elseif ('enable' == $action) { if (null != ($plugin = $pluginService->getPluginForId($pluginId)) && $plugin->isInstalled()) { $loggingService->debug('enable plugin: ' . $plugin->getId()); $this->setStatus($plugin, true); $message = $translator->trans('Plugin %name% enabled successfully', array('%name%' => $plugin->getName())); $this->get('session.flash_bag')->success($message); $this->get('session.flash_bag')->addAll($plugin->getMessages()); $viewId = 'success-enable'; } } elseif ('disable' == $action) { if (null != ($plugin = $pluginService->getPluginForId($pluginId)) && $plugin->isInstalled()) { $loggingService->debug('disable plugin: ' . $plugin->getId()); $this->setStatus($plugin, false); $message = $translator->trans('Plugin %name% disabled successfully', array('%name%' => $plugin->getName())); $this->get('session.flash_bag')->success($message); $this->get('session.flash_bag')->addAll($plugin->getMessages()); $viewId = 'success-disable'; } } } // do this last once all changes are made $this->container->get('pluginStatusMapBuilder')->getStatusMap(true); return $this->findView($viewId); }
/** * Set create default address flag. * * @param boolean value The new value. */ public function setCreateDefaultAddress($value) { // make sure we convert to boolean; typically this would be set via a bean definition $this->createDefaultAddress = Toolbox::asBoolean($value); $this->container->get('logger')->debug('createDefaultAddress set to: ' . $this->createDefaultAddress); }
public function setSsl($value) { $this->ssl = Toolbox::asBoolean($value); return $this; }
/** * Set the open flag. * * @parm boolean open The new value. */ public function setOpen($open) { $this->open = Toolbox::asBoolean($open); }