public function getPaymentMethod() { if (!$this->paymentMethod) { $this->paymentMethod = \XLite\Core\Database::getRepo('XLite\\Model\\Payment\\Method')->findOneBy(array('class' => self::MODEL_PATH)); } return $this->paymentMethod; }
/** * Update list * * @return void */ protected function doActionVolumeDiscountsUpdate() { $list = new \XLite\Module\CDev\VolumeDiscounts\View\ItemsList\VolumeDiscounts(); $list->processQuick(); // Additional correction to re-define end of subtotal range for each discount \XLite\Core\Database::getRepo('XLite\\Module\\CDev\\VolumeDiscounts\\Model\\VolumeDiscount')->correctSubtotalRangeEnd(); }
/** * Get item * * @return \XLite\Model\OrderItem */ public function getItem() { if (!isset($this->item)) { // Initialize order item from request param item_id if (is_numeric(\XLite\Core\Request::getInstance()->item_id)) { $item = \XLite\Core\Database::getRepo('XLite\\Model\\OrderItem')->find(\XLite\Core\Request::getInstance()->item_id); if ($item && $item->getProduct() && $item->hasAttributeValues()) { $this->item = $item; } } } if (!isset($this->item) && \XLite\Core\Request::getInstance()->productId) { // Initialize order item from productId param $product = \XLite\Core\Database::getRepo('XLite\\Model\\Product')->find(\XLite\Core\Request::getInstance()->productId); if ($product) { $this->item = new \XLite\Model\OrderItem(); $this->item->setProduct($product); $this->item->setAttributeValues($product->prepareAttributeValues()); } } if (!isset($this->item)) { // Order item was not initialized: set to false to prevent re-initialization $this->item = false; } return $this->item; }
protected function getPaymentMethod() { if ($this->paymentMethod == null) { $this->paymentMethod = \XLite\Core\Database::getRepo('XLite\\Model\\Payment\\Method')->findOneBy(array('class' => \XLite\Module\Heartland\Securesubmit\Core\Securesubmit::MODEL_PATH)); } return $this->paymentMethod; }
/** * This object will be used if another one is not passed * * @return \XLite\Module\XC\AuctionInc\Model\ProductAuctionInc */ protected function getDefaultModelObject() { $model = $this->getModelId() ? \XLite\Core\Database::getRepo('XLite\\Module\\XC\\AuctionInc\\Model\\ProductAuctionInc')->findOneBy(array('product' => $this->getModelId())) : null; $model = $model ?: new \XLite\Module\XC\AuctionInc\Model\ProductAuctionInc(); $model->setProduct($this->getProduct()); return $model; }
/** * Preprocessor for no-action run * * @return void */ protected function doNoAction() { if (\XLite\Core\Request::getInstance()->completed) { \XLite\Core\Database::getRepo('XLite\\Model\\Category')->removeProductFilterCache(); } parent::doNoAction(); }
/** * Return the category name for the title * * @return string */ public function getCategory() { if (is_null($this->category)) { $this->category = \XLite\Core\Database::getRepo('XLite\\Model\\Category')->find($this->getCategoryId()); } return $this->category; }
/** * Read config options * * @param mixed $force ____param_comment____ OPTIONAL * * @return void */ public function readConfig($force = false) { if (!isset($this->config) || $force) { $this->config = \XLite\Core\Database::getRepo('XLite\\Model\\Config')->getAllOptions($force); } return $this->config; }
/** * Switch state * * @return void */ protected function doActionSwitch() { $value = !\XLite\Core\Config::getInstance()->XC->ThemeTweaker->edit_mode; \XLite\Core\Database::getRepo('XLite\\Model\\Config')->createOption(array('category' => 'XC\\ThemeTweaker', 'name' => 'edit_mode', 'value' => $value)); \XLite\Core\TopMessage::addInfo($value ? 'Webmaster mode is enabled' : 'Webmaster mode is disabled'); $this->setReturnURL($this->buildURL('theme_tweaker_templates')); }
/** * Execute certain hook handle * * @return void */ public function executeHookHandler() { if (\XLite\Upgrade\Cell::getInstance()->isUpgraded()) { $entries = \XLite\Upgrade\Cell::getInstance()->getEntries(); if ($entries) { \Includes\Utils\Operator::showMessage('', true, false); /** @var \XLite\Upgrade\Entry\AEntry $entry */ foreach ($entries as $entry) { if (!$entry->isPostUpgradeActionsCalled()) { $message = '...Invoke actions for ' . $entry->getActualName(); \Includes\Decorator\Utils\CacheManager::logMessage(PHP_EOL); \Includes\Decorator\Utils\CacheManager::logMessage($message); $isInvoked = \XLite\Upgrade\Cell::getInstance()->runHelper($entry, 'post_rebuild'); if ($isInvoked && \XLite\Upgrade\Cell::getInstance()->getHookRedirect()) { break; } if (!\XLite\Upgrade\Cell::getInstance()->hasUnfinishedUpgradeHooks('post_rebuild', $entry)) { // All post-rebuild hooks completed, run the rest actions... \XLite\Upgrade\Cell::getInstance()->runCommonHelper($entry, 'add_labels'); \XLite\Upgrade\Cell::getInstance()->callInstallEvent($entry); $entry->setPostUpgradeActionsCalled(); } if (\Includes\Decorator\Utils\CacheManager::isTimeExceeds(static::STEP_TTL)) { break; } } } } } \Includes\Decorator\Utils\CacheManager::logMessage(PHP_EOL); \XLite\Core\Database::getEM()->flush(); \XLite\Core\Database::getEM()->clear(); }
/** * Return params list to use for search * * @return \XLite\Core\CommonCell */ protected function getSearchCondition() { $result = parent::getSearchCondition(); $productId = $this->getProductId(); $result->{\XLite\Module\XC\Reviews\Model\Repo\Review::SEARCH_PRODUCT} = \XLite\Core\Database::getRepo('XLite\\Model\\Product')->find($productId); return $result; }
/** * Action of license key registration * * @return void */ protected function doActionRegisterKey() { $key = \XLite\Core\Request::getInstance()->key; $addonsInfo = \XLite\Core\Marketplace::getInstance()->checkAddonKey($key); if ($addonsInfo && $addonsInfo[$key]) { $addonsInfo = $addonsInfo[$key]; $repo = \XLite\Core\Database::getRepo('\\XLite\\Model\\ModuleKey'); foreach ($addonsInfo as $info) { $module = \XLite\Core\Database::getRepo('\\XLite\\Model\\Module')->findOneBy(array('author' => $info['author'], 'name' => $info['name'])); if ($module) { $entity = $repo->findKey($info['author'], $info['name']); if ($entity) { $entity->setKeyValue($key); $repo->update($entity); } else { $entity = $repo->insert($info + array('keyValue' => $key)); } \XLite\Core\Database::getEM()->flush(); // Clear cache for proper installation \XLite\Core\Marketplace::getInstance()->clearActionCache(\XLite\Core\Marketplace::ACTION_GET_ADDONS_LIST); $this->showInfo(__FUNCTION__, 'License key has been successfully verified for "{{name}}" module by "{{author}}" author', array('name' => $module->getModuleName(), 'author' => $module->getAuthorName())); } else { $this->showError(__FUNCTION__, 'Key is validated, but the module [' . implode(',', $info) . '] was not found'); } } } else { $error = \XLite\Core\Marketplace::getInstance()->getError(); if ($error) { $this->showError(__FUNCTION__, 'Response from marketplace: ' . $error); } else { $this->showError(__FUNCTION__, 'Response from marketplace is not received'); } } $this->setReturnURL($this->buildURL('addons_list_marketplace')); }
/** * Execute certain hook handle * * @return void */ public function executeHookHandler() { foreach (\Includes\Decorator\Plugin\Doctrine\Utils\FixturesManager::getFixtures() as $fixture) { \XLite\Core\Database::getInstance()->loadFixturesFromYaml($fixture); } \Includes\Decorator\Plugin\Doctrine\Utils\FixturesManager::removeFixtures(); }
/** * Get product class * * @return \XLite\Model\ProductClass */ public function getProductClass() { if (is_null($this->productClass) && \XLite\Core\Request::getInstance()->product_class_id) { $this->productClass = \XLite\Core\Database::getRepo('XLite\\Model\\ProductClass')->find(intval(\XLite\Core\Request::getInstance()->product_class_id)); } return $this->productClass; }
/** * Define widget params * * @return void */ protected function getOrder() { if ($this->getParam(self::PARAM_ORDER_ID) && is_null($this->order)) { $this->order = \XLite\Core\Database::getRepo('\\XLite\\Model\\Order')->find($this->getParam(self::PARAM_ORDER_ID)); } return $this->order; }
/** * Returns shipping method * * @return \XLite\Model\Shipping\Method */ protected function getMethod() { if (null === $this->method) { $this->method = \XLite\Core\Database::getRepo('XLite\\Model\\Shipping\\Method')->find(\XLite\Core\Request::getInstance()->methodId); } return $this->method; }
/** * Get order * * @return \XLite\Model\Order */ public function getOrder() { if (!isset($this->order)) { $this->order = \XLite\Core\Database::getRepo('XLite\\Model\\Order')->find(\XLite\Core\Request::getInstance()->order_id); } return $this->order; }
/** * Check field validity * * @return boolean */ protected function checkFieldValidity() { $result = parent::checkFieldValidity(); if ($result && $this->getValue()) { $length = strlen($this->getValue()); // Check size if (static::MIN_SIZE > $length) { // Too small $result = false; $this->errorMessage = static::t('The length of X field must be greater than Y', array('name' => $this->getLabel(), 'min' => static::MIN_SIZE)); } elseif (static::MAX_SIZE < $length) { // Too big $result = false; $this->errorMessage = static::t('The length of X field must be less than Y', array('name' => $this->getLabel(), 'max' => static::MAX_SIZE)); } else { // Check duplicate $modelId = \XLite\Core\Request::getInstance()->id; $model = $modelId ? \XLite\Core\Database::getRepo('XLite\\Module\\CDev\\Coupons\\Model\\Coupon')->find($modelId) : null; $duplicates = \XLite\Core\Database::getRepo('XLite\\Module\\CDev\\Coupons\\Model\\Coupon')->findDuplicates($this->getValue(), $model); if ($duplicates) { $result = false; $this->errorMessage = static::t('X code is already used for other coupon, please specify a different code', array('code' => $this->getValue())); } } } return $result; }
/** * testCreate * * @return void * @access public * @see ____func_see____ * @since 1.0.0 */ public function testCreate() { $c = new \XLite\Model\Country(); foreach ($this->entityData as $field => $testValue) { $setterMethod = 'set' . \XLite\Core\Converter::getInstance()->convertToCamelCase($field); $getterMethod = 'get' . \XLite\Core\Converter::getInstance()->convertToCamelCase($field); $c->{$setterMethod}($testValue); $value = $c->{$getterMethod}(); $this->assertEquals($testValue, $value, 'Creation checking (' . $field . ')'); } $s = new \XLite\Model\State(); $s->setState('test state'); $s->setCode('ttt'); $c->addStates($s); $em = \XLite\Core\Database::getEM(); $em->persist($c); $em->flush(); $em->clear(); $c = \XLite\Core\Database::getEM()->merge($c); foreach ($this->entityData as $field => $testValue) { $getterMethod = 'get' . \XLite\Core\Converter::getInstance()->convertToCamelCase($field); $this->assertEquals($testValue, $c->{$getterMethod}(), 'Creation checking (' . $field . ') #2'); } $this->assertEquals($s->getStateId(), $c->getStates()->get(0)->getStateId(), 'check state'); $em->remove($c); $em->flush(); }
/** * Update payment method * * @return void */ protected function doActionUpdate() { $settings = \XLite\Core\Request::getInstance()->settings; $method = $this->getPaymentMethod(); if (!$method) { \XLite\Core\TopMessage::addError('An attempt to update settings of unknown payment method'); } else { if (is_array($settings)) { foreach ($settings as $name => $value) { $method->setSetting($name, trim($value)); } } $properties = \XLite\Core\Request::getInstance()->properties; if (is_array($properties) && !empty($properties)) { $method->map($properties); } \XLite\Core\Database::getRepo('\\XLite\\Model\\Payment\\Method')->update($method); // If "just added" method is configured and can be enabled then we enable it if (\XLite\Core\Request::getInstance()->just_added && $method->isConfigured() && $method->canEnable()) { $method->setEnabled(true); \XLite\Core\Database::getEM()->flush(); } if ($method->isConfigured()) { \XLite\Core\TopMessage::addInfo('The settings of payment method successfully updated'); $this->setReturnURL($this->buildURL('payment_settings')); } else { \XLite\Core\TopMessage::addWarning('Payment method has not been configured properly'); } } }
/** * Get product modifier types * * @return array */ protected function getProductModifierTypes() { $additional = null; $additionalVariants = null; $wholesale = null; if (!isset($this->productModifierTypes)) { if (\Includes\Utils\ModulesManager::isActiveModule('XC\\ProductVariants')) { // ProductVariants module detected $additional = \XLite\Core\Database::getRepo('XLite\\Module\\XC\\ProductVariants\\Model\\ProductVariant')->getModifierTypesByProduct($this->getProduct()); $additionalVariants = \XLite\Core\Database::getRepo('XLite\\Module\\CDev\\Wholesale\\Model\\ProductVariantWholesalePrice')->getModifierTypesByProduct($this->getProduct()); } if ((!isset($additional) || empty($additional['price'])) && (!isset($additionalVariants) || empty($additionalVariants['price']))) { // ProductVariants module is not detected or product has not variants $wholesale = \XLite\Core\Database::getRepo('XLite\\Module\\CDev\\Wholesale\\Model\\WholesalePrice')->getModifierTypesByProduct($this->getProduct()); } } $result = parent::getProductModifierTypes(); foreach (array($additional, $additionalVariants, $wholesale) as $modifierTypes) { if (isset($modifierTypes)) { $result += $modifierTypes; if (!$result['price'] && $modifierTypes['price']) { $result['price'] = true; } $this->productModifierTypes = $result; } } return $result; }
/** * Return AvaTax Module link * * @return string */ protected function getAvaTaxLink() { list(, $limit) = $this->getWidget(array(), 'XLite\\View\\Pager\\Admin\\Module\\Install')->getLimitCondition()->limit; list($author, $module) = explode('\\', 'XC\\AvaTax'); $pageId = \XLite\Core\Database::getRepo('XLite\\Model\\Module')->getMarketplacePageId($author, $module, $limit); return $this->buildURL('addons_list_marketplace', '', array('clearCnd' => 1, 'clearSearch' => 1, \XLite\View\Pager\APager::PARAM_PAGE_ID => $pageId, \XLite\View\ItemsList\AItemsList::PARAM_SORT_BY => \XLite\View\ItemsList\Module\AModule::SORT_OPT_ALPHA)) . '#' . $module; }
/** * Handles the request. * Create installation timestamp if empty (at first software launch) * * @return string */ public function handleRequest() { if (empty(\XLite\Core\Config::getInstance()->Version->timestamp)) { \XLite\Core\Database::getRepo('XLite\\Model\\Config')->createOption(array('category' => 'Version', 'name' => 'timestamp', 'value' => time())); } parent::handleRequest(); }
/** * getProduct * * @return \XLite\Model\Product * @see ____func_see____ * @since 1.0.24 */ protected function getProduct() { $product = \XLite\Core\Database::getRepo('XLite\\Model\\Product')->find(22); // Find Binary Mom $this->assertNotNull($product, 'Product #22 (Binary Mom) not found'); return $product; }
/** * Get pages length * * @return integer * @see ____func_see____ * @since 1.0.12 */ protected function getPagesLength() { if (!isset($this->pagesLength)) { $this->pagesLength = \XLite\Core\Database::getRepo('XLite\\Module\\CDev\\SimpleCMS\\Model\\Page')->countPagesAsSitemapsLinks(); } return $this->pagesLength; }
/** * @param bool $new_order * @return XLite\Model\Order */ protected function getTestOrder($new_order = false) { $order = parent::getTestOrder($new_order); $order->setPaymentMethod($this->getTestMethod()); \XLite\Core\Database::getEM()->flush(); return $order; }
/** * Update user's Drupal roles * * @param array $newDrupalRoles Array of Drupal role IDs * * @return void */ public function updateDrupalRoles($newDrupalRoles) { $processedRoles = array(); $drupalRoles = $this->getDrupalRoles(); if ($drupalRoles) { // Remove roles that is not in new roles array foreach ($this->getDrupalRoles() as $key => $drupalRole) { if (!in_array($drupalRole->getDrupalRoleId(), $newDrupalRoles)) { $this->drupalRoles->remove($key); \XLite\Core\Database::getEM()->remove($drupalRole); } else { $processedRoles[] = $drupalRole->getDrupalRoleId(); } } } // Get roles to add $rolesToAdd = array_diff($newDrupalRoles, $processedRoles); // Create new roles foreach ($rolesToAdd as $roleId) { $newDrupalRole = new \XLite\Module\CDev\DrupalConnector\Model\DrupalRole(); $newDrupalRole->setProfile($this); $newDrupalRole->setDrupalRoleId($roleId); $this->addDrupalRoles($newDrupalRole); } }
/** * Return currencies collection to use * * @return void */ public function getCurrencies() { if (!isset($this->currencies)) { $this->currencies = \XLite\Core\Database::getRepo('XLite\\Model\\Currency')->findAll(); } return $this->currencies; }
/** * Preprocessor for no-action reaction * * @return void */ protected function doNoAction() { parent::doNoAction(); $content = \XLite\Core\Request::getInstance()->id ? \XLite\Core\Database::getRepo('XLite\\Model\\IframeContent')->find(\XLite\Core\Request::getInstance()->id) : null; if ($content) { $method = $content->getMethod(); $url = $content->getUrl(); $body = $this->assembleFormBody($content); $html = <<<HTML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body onload="javascript: document.getElementById('payment_form').submit();"> <form method="{$method}" id="payment_form" name="payment_form" action="{$url}"> <fieldset style="display: none;"> {$body} </fieldset> </form> </body> </html> HTML; print $html; exit; } else { $this->redirect(\XLite\Core\Converter::buildURL('checkout')); } }
/** * Get orders * * @return array(\XLite\Model\Order) */ public function getOrders(\XLite\Core\CommonCell $cnd = null) { if (!isset($this->orders)) { $this->orders = \XLite\Core\Database::getRepo('\\XLite\\Model\\Order')->search($this->getConditions($cnd)); } return $this->orders; }