/** * Returns the current context * * @param boolean $locale True to add locale object to context, false if not (deprecated, use \Aimeos\Shop\Base\Locale) * @param string $type Configuration type, i.e. "frontend" or "backend" (deprecated, use \Aimeos\Shop\Base\Config) * @return \Aimeos\MShop\Context\Item\Iface Context object */ public function get($locale = true, $type = 'frontend') { $config = $this->config->get($type); if ($this->context === null) { $context = new \Aimeos\MShop\Context\Item\Standard(); $context->setConfig($config); $this->addDataBaseManager($context); $this->addFilesystemManager($context); $this->addMessageQueueManager($context); $this->addLogger($context); $this->addCache($context); $this->addMailer($context); $this->addSession($context); $this->addUser($context); $this->addGroups($context); $this->context = $context; } $this->context->setConfig($config); if ($locale === true) { $localeItem = $this->locale->get($this->context); $this->context->setLocale($localeItem); $this->context->setI18n($this->i18n->get(array($localeItem->getLanguageId()))); } return $this->context; }
/** * Returns the current context. * * @param \TYPO3\Flow\Mvc\RequestInterface $request Request object * @return \Aimeos\MShop\Context\Item\Iface */ public function get(\TYPO3\Flow\Mvc\RequestInterface $request = null, $type = 'frontend') { $config = $this->config->get($type); if (self::$context === null) { $context = new \Aimeos\MShop\Context\Item\Standard(); $context->setConfig($config); $this->addDataBaseManager($context); $this->addFilesystemManager($context); $this->addMessageQueueManager($context); $this->addLogger($context); $this->addCache($context); $this->addMailer($context); self::$context = $context; } $context = self::$context; $context->setConfig($config); if ($request !== null) { $localeItem = $this->locale->get($context, $request); $context->setI18n($this->i18n->get(array($localeItem->getLanguageId()))); $context->setLocale($localeItem); } $this->addSession($context); $this->addUser($context); return $context; }
/** * Single entry point for all JSON admin requests. */ public function doAction() { $context = $this->context->get(null, 'backend'); $context->setLocale($this->locale->getBackend($context, 'default')); $context->setView($this->viewcontainer->create($context, $this->uriBuilder, array(), $this->request)); $cntlPaths = $this->aimeos->get()->getCustomPaths('controller/extjs'); $controller = new \Aimeos\Controller\ExtJS\JsonRpc($context, $cntlPaths); if (($content = file_get_contents('php://input')) === false) { throw new \Exception('Unable to get request content'); } return $controller->process($this->request->getArguments(), $content); }
/** * Checks if the user with the given ID is in the specified group * * @param string $userid Unique user ID * @param string|array $groupcodes Unique user/customer group codes that are allowed * @return boolean True if user is part of the group, false if not */ public function checkGroup($userid, $groupcodes) { $site = Route::current() ? Route::input('site', Input::get('site', 'default')) : 'default'; $context = $this->context->get(false); $context->setLocale($this->locale->getBackend($context, $site)); $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/group'); $search = $manager->createSearch(); $search->setConditions($search->compare('==', 'customer.group.code', (array) $groupcodes)); $groupItems = $manager->searchItems($search); $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists'); $search = $manager->createSearch(); $expr = array($search->compare('==', 'customer.lists.parentid', $userid), $search->compare('==', 'customer.lists.refid', array_keys($groupItems)), $search->compare('==', 'customer.lists.domain', 'customer/group')); $search->setConditions($search->combine('&&', $expr)); $search->setSlice(0, 1); return (bool) count($manager->searchItems($search)); }
/** * Returns the resource controller * * @param string $sitecode Unique site code * @return \Aimeos\MShop\Context\Item\Iface Context item */ protected function createClient($sitecode, $resource) { $lang = $this->request->hasArgument('lang') ? $this->request->getArgument('lang') : 'en'; $templatePaths = $this->aimeos->get()->getCustomPaths('admin/jqadm/templates'); $context = $this->context->get(null, 'backend'); $context->setI18n($this->i18n->get(array($lang, 'en'))); $context->setLocale($this->locale->getBackend($context, $sitecode)); $context->setView($this->viewbase->create($context, $this->uriBuilder, $templatePaths, $this->request, $lang)); return \Aimeos\Admin\JQAdm\Factory::createClient($context, $templatePaths, $resource); }