public function getUrl() { $params = array(); // user name $params['merchant'] = $this->getConfigValue('merchant'); if ($this->getConfigValue('test')) { $params['test'] = 'yes'; } // A seller reference number for a transaction $params['orderid'] = $this->details->invoiceID->get(); $params['uniqueoid'] = $this->details->invoiceID->get(); // The payment amount $params['amount'] = $this->details->amount->get() * 100; // The currency code of the payment amount. $params['currency'] = $this->getCurrency($this->details->currency->get()); //$this->notifyUrl = preg_replace('/currency\=[A-Z]{3}/', '', $this->notifyUrl); $params['callbackurl'] = $this->notifyUrl; $params['accepturl'] = $this->returnUrl; $params['cancelurl'] = $this->siteUrl; $params['lang'] = ActiveRecordModel::getApplication()->getLocaleCode(); $params['skiplastpage'] = 1; $params['md5key'] = $this->getMd5Key($params); $pairs = array(); foreach ($params as $key => $value) { $pairs[] = $key . '=' . urlencode($value); } return 'https://payment.architrade.com/paymentweb/start.action?' . implode('&', $pairs); }
/** * * @return array('manufacturers'=> array of manufacturers, 'counts'=> manufacturer product count, 'count'=> count of manufacturers) */ public static function getActiveProductManufacturers($context) { $context = $context + array('startingWith' => null, 'currentPage' => 1); extract($context); // creates $startingWith and $currentPage $config = ActiveRecordModel::getApplication()->getConfig(); $listStyle = $config->get('MANUFACTURER_PAGE_LIST_STYLE'); $perPage = $config->get('MANUFACTURER_PAGE_PER_PAGE'); // get filter to select manufacturers of active products only $f = new ARSelectFilter(); $ids = $counts = $letters = array(); $sql = !self::getApplication()->getConfig()->get('MANUFACTURER_PAGE_DISPLAY_ACTIVE') ? 'SELECT DISTINCT(ID) as manufacturerID, 1 AS cnt FROM Manufacturer ' . $f->createString() . ' GROUP BY manufacturerID' : 'SELECT DISTINCT(manufacturerID), COUNT(*) AS cnt FROM Product ' . $f->createString() . ' GROUP BY manufacturerID'; foreach (ActiveRecordModel::getDataBySQL($sql) as $row) { $ids[] = $row['manufacturerID']; $counts[$row['manufacturerID']] = $row['cnt']; } $f = new ARSelectFilter(new InCond(new ARFieldHandle('Manufacturer', 'ID'), $ids)); $f->addField('UPPER(LEFT(TRIM(Manufacturer.name),1))', '', 'FirstLetter'); $f->mergeCondition(new NotEqualsCond(new ARFieldHandle('Manufacturer', 'name'), '')); if ($startingWith) { $f->mergeCondition(new LikeCond(new ARFieldHandle('Manufacturer', 'name'), $startingWith . '%')); } $f->setOrder(new ARFieldHandle('Manufacturer', 'name')); if ($perPage > 0) { $offsetStart = ($currentPage - 1) * $perPage + 1; $offsetEnd = $currentPage * $perPage; $f->setLimit($perPage, $offsetStart - 1); } $manufacturers = ActiveRecordModel::getRecordSetArray(__CLASS__, $f); foreach ($manufacturers as $item) { $letters[$item['FirstLetter']] = $item['FirstLetter']; } return array('manufacturers' => $manufacturers, 'counts' => $counts, 'count' => ActiveRecordModel::getRecordCount(__CLASS__, $f)); }
public function getNumber() { $config = ActiveRecordModel::getApplication()->getConfig(); $startAt = $config->get('SequentialInvoiceNumber_START_AT'); $prefix = $config->get('SequentialInvoiceNumber_PREFIX'); $suffix = $config->get('SequentialInvoiceNumber_SUFFIX'); // get last finalized order $last = array_pop(ActiveRecord::getRecordSetArray('CustomerOrder', $this->getSelectFilter())); $lastNumber = $last ? $last['invoiceNumber'] : $startAt; if (substr($lastNumber, 0, strlen($prefix)) == $prefix) { $lastNumber = substr($lastNumber, strlen($prefix)); } if (substr($lastNumber, -1 * strlen($suffix)) == $suffix) { $lastNumber = substr($lastNumber, 0, -1 * strlen($suffix)); } preg_match('/[0-9]+/', $lastNumber, $matches); $lastNumber = array_shift($matches); if ($lastNumber < $startAt) { $lastNumber = $startAt; } // avoid selecting the same order if the invoice number is already taken $this->getSelectFilter()->mergeCondition(neq('CustomerOrder.ID', $last['ID'])); $lastNumber += max($config->get('SequentialInvoiceNumber_STEP'), 1); $lastNumber = str_pad($lastNumber, $config->get('SequentialInvoiceNumber_MIN_LENGTH'), '0', STR_PAD_LEFT); $lastNumber = $prefix . $lastNumber . $suffix; return $lastNumber; }
private function getLanguageIDs() { if (!$this->langIDs) { $this->langIDs = ActiveRecordModel::getApplication()->getLanguageArray(true); } return $this->langIDs; }
public function setUp() { ActiveRecordModel::getApplication()->clearCachedVars(); ActiveRecordModel::beginTransaction(); if (empty($this->autoincrements)) { foreach ($this->getUsedSchemas() as $table) { $res = $this->db->executeQuery("SHOW TABLE STATUS LIKE '{$table}'"); $res->next(); $this->autoincrements[$table] = (int) $res->getInt("Auto_increment"); } } if ($this instanceof BackendControllerTestCase) { ClassLoader::import('application.model.user.SessionUser'); ClassLoader::import('application.model.user.UserGroup'); // set up user $group = UserGroup::getNewInstance('Unit tester'); $group->save(); $group->setAllRoles(); $group->save(); $user = User::getNewInstance('*****@*****.**', null, $group); $user->save(); SessionUser::setUser($user); } if ($this instanceof ControllerTestCase) { $this->request = self::getApplication()->getRequest(); } }
public function getSelectFilter($disableFilters = false) { $selectFilter = $this->category->getProductsFilter($this, false); $selectFilter->merge($this->productFilter); $cond = null; if ($disableFilters == false) { $list = array(); // group filters by class foreach ($this->filters as $filter) { $id = $filter instanceof SpecificationFilterInterface ? $filter->getFilterGroup()->getID() : ''; $list[get_class($filter) . '_' . $id][] = $filter->getCondition(); $filter->defineJoin($selectFilter); } // convert filter group to OrChainCondition foreach ($list as &$filterGroup) { $filterGroup = new OrChainCondition($filterGroup); } if ($fCond = $selectFilter->getCondition()) { $list[] = $fCond; } $selectFilter->setCondition(new AndChainCondition($list)); // all merged with and } ActiveRecordModel::getApplication()->processInstancePlugins('finalProductFilter', $selectFilter); return $selectFilter; }
public function getCondition() { // analyze search query // find exact phrases first $query = $this->query; preg_match_all('/"(.*)"/sU', $query, $matches); $phrases = array(); if ($matches[1]) { $phrases = $matches[1]; } $query = $this->getCleanedQuery($query); $phrases = array_merge($phrases, explode(' ', $query)); $searchFields = array('name', 'keywords', 'shortDescription', 'longDescription', 'sku'); $conditions = array(); foreach ($phrases as $phrase) { $searchCond = null; foreach ($searchFields as $field) { $cond = new LikeCond(new ARFieldHandle('Product', $field), '%' . $phrase . '%'); if (!$searchCond) { $searchCond = $cond; } else { $searchCond->addOr($cond); } } $conditions[] = $searchCond; } $condition = new AndChainCondition($conditions); $vc = new IsNotNullCond(f('Product.parentID')); $vc->addAND(new LikeCond(new ARExpressionHandle('(SELECT name FROM Product as searchvar WHERE Product.parentID=searchvar.ID)'), '%' . $phrase . '%')); ActiveRecordModel::getApplication()->variationCond = $vc; ActiveRecordModel::getApplication()->processInstancePlugins('searchFilter', $condition); return $condition; }
public function testApply() { $livecart = ActiveRecordModel::getApplication(); $compat = new GodaddySharedHostingCompat($livecart); $compat->apply(); $this->assertEqual($livecart->getConfig()->get('PROXY_HOST'), 'proxy.shr.secureserver.net'); $this->assertEqual($livecart->getConfig()->get('PROXY_PORT'), 3128); }
public function toArray() { $arr = array(); $arr['class'] = $this->getClassName(); $arr['template'] = 'custom:search/block/result_' . $arr['class'] . '.tpl'; $arr['name'] = ActiveRecordModel::getApplication()->translate($arr['class']); return $arr; }
public static function destroy() { $app = ActiveRecordModel::getApplication(); $app->processRuntimePlugins('session/before-logout'); $session = new Session(); $session->unsetValue('User'); $session->unsetValue('CustomerOrder'); $app->processRuntimePlugins('session/logout'); }
public function applyToOrder(CustomerOrder $order) { $taxClassID = $this->getFieldValue('taxClassID', -1); if ($taxClassID > 0) { ActiveRecordModel::getApplication()->getConfig()->setRuntime('DELIVERY_TAX_CLASS', $taxClassID); } else { ActiveRecordModel::getApplication()->getConfig()->resetRuntime('DELIVERY_TAX_CLASS'); } }
public function delete() { if (ActiveRecordModel::getApplication()->getConfig()->get('CLONE_STORE_TYPE') == 'CLONE_STORE_MASTER') { return parent::delete(); } else { ActiveRecordModel::executeUpdate('SET FOREIGN_KEY_CHECKS=0'); ActiveRecordModel::executeUpdate('UPDATE ' . __CLASS__ . ' SET productID=NULL, variationID=NULL, protectedFields="|productID||variationID|" WHERE ID=' . $this->getID()); } }
public function getPastOrders() { if (!is_null($this->pastOrders)) { return $this->pastOrders; } if (!$this->user) { return array(); } $sessionUser = SessionUser::getUser(); if ($this->isSessionCacheUsable()) { $session = new Session(); $sessionHandler = ActiveRecordModel::getApplication()->getSessionHandler(); $pastOrders = $session->get('pastOrders'); if (!$pastOrders || $pastOrders['cacheUpdated'] != $sessionHandler->getCacheUpdateTime()) { unset($pastOrders); } } if (empty($pastOrders)) { $f = select(eq('CustomerOrder.userID', $this->user->getID()), eq('CustomerOrder.isFinalized', true), eq('CustomerOrder.isCancelled', 0), eq('CustomerOrder.isPaid', true)); $f->setOrder(f('OrderedItem.customerOrderID'), 'DESC'); $records = ActiveRecordModel::getRecordSetArray('OrderedItem', $f, array('CustomerOrder', 'Product')); // load variation parent products separately $parentIDs = array(); foreach ($records as $record) { if ($record['Product']['parentID']) { //$parentIDs[$record['Product']['parentID']] = true; } } if ($parentIDs) { $parents = array(); foreach (ActiveRecordModel::getRecordSetArray('Product', select(in('Product.ID', array_keys($parentIDs)))) as $parent) { $parents[$parent['ID']] = $parent; } foreach ($records as &$record) { if ($record['Product']['parentID']) { $record['Product']['Parent'] = $parents[$record['Product']['parentID']]; } } } // split records by orders $orders = array(); foreach ($records as $record) { $orders[$record['customerOrderID']][] = $record; } $pastOrders = array(); foreach ($orders as $order) { $pastOrders[] = new RuleOrderContainer($order); } $pastOrders = array('cacheUpdated' => time(), 'orders' => $pastOrders); } if ($this->isSessionCacheUsable()) { $session->set('pastOrders', $pastOrders); $sessionHandler->updateCacheTimestamp(); } $this->pastOrders = $pastOrders; return $this->pastOrders; }
private static function getGeneratorFiles() { $files = array(); foreach (ActiveRecordModel::getApplication()->getConfigContainer()->getDirectoriesByMountPath('application.model.order.invoiceNumber') as $dir) { foreach (glob($dir . '/*.php') as $file) { $files[basename($file, '.php')] = $file; } } return $files; }
public static function createFromArray(array $array) { ActiveRecordModel::getApplication()->loadPluginClass('application.model.businessrule.action', $array['actionClass']); $inst = new $array['actionClass'](); if (!empty($array['condition'])) { $condition = isset($array['instance']) ? $array['instance'] : RuleCondition::createFromArray($array['condition'], true); $inst->setCondition($condition); } unset($array['condition']); $inst->setParams($array); return $inst; }
public function process() { try { $usd = Currency::getInstanceByID('USD', true); } catch (Exception $e) { return; } if (!$usd->isEnabled->get()) { return; } $app = ActiveRecordModel::getApplication(); $request = $app->getRequest(); $request->set('currency', $usd->getID()); $app->getRouter()->removeAutoAppendVariable('currency'); }
public function getFields() { $app = ActiveRecordModel::getApplication(); $app->loadLanguageFile('backend/Settings'); $app->loadLanguageFiles(); $config = $app->getConfig(); $handlers = array(); foreach (array_merge($app->getPaymentHandlerList(true), array($config->get('CC_HANDLER')), $app->getExpressPaymentHandlerList(true)) as $class) { $handlers[$class] = $app->translate($class); } foreach (OfflineTransactionHandler::getEnabledMethods() as $offline) { $handlers[$offline] = OfflineTransactionHandler::getMethodName($offline); } return array(array('type' => 'select', 'label' => '_payment_method', 'name' => 'method', 'options' => $handlers)); }
public static function buildIndexIfNeeded() { $application = ActiveRecordModel::getApplication(); $localesToTestForReindexAll = array(); $locCount = array(); foreach (array_unique(array($application->getLocaleCode(), $application->getDefaultLanguageCode())) as $localeCode) { $count = self::getSearchableItemCount($localeCode); if ($count == 0) { $localesToTestForReindexAll[] = $localeCode; } } if (count($localesToTestForReindexAll) > 0) { $sc = new SearchableConfigurationIndexing($application->getConfig(), $application, $localesToTestForReindexAll); $sc->buildIndex(null); } }
public function getSelectFilter($searchTerm) { // create initial index if (0 && !SearchableItem::getRecordCount()) { $app = ActiveRecordModel::getApplication(); $sc = new SearchableConfigurationIndexing($app->getConfig(), $app); $sc->buildIndex(null); } $c = new ARExpressionHandle($this->getWeighedSearchCondition(array('value' => 1), $searchTerm)); $app = ActiveRecordModel::getApplication(); $f = new ARSelectFilter(new MoreThanCond($c, 0)); $f->mergeCondition(new OrChainCondition(array(eq(f('SearchableItem.locale'), $app->getDefaultLanguageCode()), eq(f('SearchableItem.locale'), $app->getLocaleCode()), isnull(f('SearchableItem.locale'))))); $f->setOrder(f('SearchableItem.sort'), 'DESC'); $f->setOrder($c, 'DESC'); return $f; }
/** * Creates a handle string that is usually used as part of URL to uniquely * identify some record. * * Basically it simply removes reserved URL characters and does some basic formatting * * @param string $str * @return string * @package application.helper * @author Integry Systems * @todo test with multibyte strings */ function createHandleString($str) { static $cache = array(); static $replaceSpecialChars = null; static $table = array('Š' => 'S', 'š' => 's', 'Đ' => 'Dj', 'đ' => 'dj', 'Ž' => 'Z', 'ž' => 'z', 'Č' => 'C', 'č' => 'c', 'Ć' => 'C', 'ć' => 'c', 'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Å' => 'A', 'Æ' => 'A', 'Ç' => 'C', 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I', 'Ñ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ö' => 'O', 'Ø' => 'O', 'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ü' => 'U', 'Ý' => 'Y', 'Þ' => 'B', 'ß' => 'Ss', 'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'a', 'å' => 'a', 'æ' => 'a', 'ç' => 'c', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ð' => 'o', 'ñ' => 'n', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ø' => 'o', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ý' => 'y', 'ý' => 'y', 'þ' => 'b', 'ÿ' => 'y', 'Ŕ' => 'R', 'ŕ' => 'r', 'ā' => 'a', 'č' => 'c', 'ē' => 'e', 'ģ' => 'g', 'ī' => 'i', 'ķ' => 'k', 'ļ' => 'l', 'ņ' => 'n', 'ō' => 'o', 'ŗ' => 'r', 'š' => 's', 'ū' => 'u', 'ž' => 'z', 'Ā' => 'A', 'Č' => 'C', 'Ē' => 'E', 'Ģ' => 'G', 'Ī' => 'I', 'Ķ' => 'K', 'Ļ' => 'L', 'Ņ' => 'N', 'Ō' => 'O', 'Ŗ' => 'R', 'Š' => 'S', 'Ū' => 'U', 'Ž' => 'Z', 'ą' => 'a', 'ę' => 'e', 'ė' => 'e', 'į' => 'i', 'ų' => 'u', 'Ą' => 'A', 'Ę' => 'E', 'Ė' => 'E', 'Į' => 'I', 'Ų' => 'U'); if (isset($cache[$str])) { return $cache[$str]; } if (is_null($replaceSpecialChars)) { $replaceSpecialChars = ActiveRecordModel::getApplication()->getConfig()->get('URL_REPLACE_SPECIAL_CHARS'); } if ($replaceSpecialChars) { $str = strtr($str, $table); } // optimized for performance return $cache[$str] = preg_replace('/ {1,}/', '-', trim(strtr($str, '$&+\\/:;=?@."\'#*><-,', ' '))); }
public function process() { if (ActiveRecordModel::getApplication()->getConfig()->get('CLONE_STORE_TYPE') == 'CLONE_STORE_MASTER') { return; } if (!ClonedStoreUpdater::isTableSynced(get_class($this->object))) { return; } $protectedFields = array(); foreach ($this->object->getSchema()->getFieldList() as $fieldName => $field) { $val = $this->object->getFieldValue($fieldName); $isModified = $this->object->getField($fieldName)->isModified(); if ($isModified && $val) { if (is_array($val)) { // empty serialized array if (!array_filter($val)) { continue; } $initial = $this->object->getField($fieldName)->getInitialValue(); if (is_array($initial)) { foreach ($val as $key => $value) { $val[$key] = strip_tags($value); } foreach ($initial as $key => $value) { $initial[$key] = strip_tags($value); } if (!array_diff($val, $initial)) { continue; } } } $protectedFields[] = $fieldName; } } if ('SpecificationStringValue' == get_class($this->object) && $this->object->value->isModified()) { $protectedFields[] = 'value'; } if (!$protectedFields) { return; } $f = new ARUpdateFilter(); foreach ($protectedFields as $key => $field) { $f->addModifier('protectedFields' . str_repeat(' ', $key), new ARExpressionHandle('IF(LOCATE("|' . $field . '|", protectedFields) > 0, protectedFields, CONCAT(COALESCE(protectedFields, ""), "|' . $field . '|"))')); } $this->object->updateFilter = $f; }
public function getUrl() { $params = array(); $params['merchantid'] = $this->getConfigValue('merchantid'); $params['projectid'] = $this->getConfigValue('projectid'); $params['orderid'] = $this->details->invoiceID->get(); $params['amount'] = $this->details->amount->get() * 100; $params['currency'] = $this->details->currency->get(); $params['country'] = $this->getConfigValue('country'); $params['lang'] = ActiveRecordModel::getApplication()->getLocaleCode(); $params['lang'] = 'LIT'; $params['callbackurl'] = $this->notifyUrl; $params['accepturl'] = $this->returnUrl; $params['cancelurl'] = $this->cancelUrl; // customer information $params['p_firstname'] = $this->details->firstName->get(); $params['p_lastname'] = $this->details->lastName->get(); $params['p_street'] = $this->details->address->get(); $params['p_city'] = $this->details->city->get(); $params['p_state'] = $this->details->state->get(); $params['p_postcode'] = $this->details->postalCode->get(); $params['p_country'] = $this->details->country->get(); $params['p_email'] = $this->details->email->get(); $params['p_phone'] = $this->details->phone->get(); if ($this->getConfigValue('test')) { $params['test'] = '1'; } $params['payment'] = $params['logo'] = $params['p_zip'] = $params['p_countrycode'] = ''; # -- Value -- $arrFields = array('merchantid' => $params['merchantid'], 'orderid' => $params['orderid'], 'lang' => $params['lang'], 'amount' => $params['amount'], 'currency' => $params['currency'], 'accepturl' => $params['accepturl'], 'cancelurl' => $params['cancelurl'], 'callbackurl' => $params['callbackurl'], 'payment' => $params['payment'], 'country' => $params['country'], 'logo' => $params['logo'], 'p_firstname' => $params['p_firstname'], 'p_lastname' => $params['p_lastname'], 'p_email' => $params['p_email'], 'p_street' => $params['p_street'], 'p_city' => $params['p_city'], 'p_state' => $params['p_state'], 'p_zip' => $params['p_zip'], 'p_countrycode' => $params['p_countrycode'], 'test' => $params['test']); // -- Do sign -- $data = ''; foreach ($arrFields as $num => $value) { if (trim($value) != '') { $data .= sprintf("%03d", strlen($value)) . strtolower($value); } } $params['sign'] = md5($data . $this->getConfigValue('signaturepassword')); // -- Do sign, END -- $pairs = array(); foreach ($params as $key => $value) { $pairs[] = $key . '=' . urlencode($value); } return 'https://www.webtopay.com/pay/?' . implode('&', $pairs); }
/** * @return RequestValidator */ public static function createUserFormValidator(StoreManagementController $controller, $user = false) { $inst = new UserController(ActiveRecordModel::getApplication()); $validator = $inst->getValidator("UserForm", $controller->getRequest()); $validator->addCheck('email', new IsNotEmptyCheck($controller->translate('_err_email_empty'))); $validator->addCheck('email', new IsValidEmailCheck($controller->translate('_err_invalid_email'))); $validator->addCheck('firstName', new IsNotEmptyCheck($controller->translate('_err_first_name_empty'))); $validator->addCheck('lastName', new IsNotEmptyCheck($controller->translate('_err_last_name_empty'))); $passwordLengthStart = 6; $passwordLengthEnd = 30; $allowEmpty = $user; $validator->addCheck('password', new IsLengthBetweenCheck(sprintf($controller->translate('_err_password_lenght_should_be_in_interval'), $passwordLengthStart, $passwordLengthEnd), $passwordLengthStart, $passwordLengthEnd, $allowEmpty)); $validator->addCheck('userGroupID', new IsNumericCheck($controller->translate('_err_invalid_group'))); if (!$user) { $user = ActiveRecordModel::getNewInstance('User'); } return $validator; }
public function notify($requestArray) { if (1 == $requestArray['x_response_code']) { $result = new TransactionResult(); $result->gatewayTransactionID->set($requestArray['x_trans_id']); $result->amount->set($requestArray['x_amount']); $result->currency->set('USD'); $result->rawResponse->set($requestArray); $result->setTransactionType(TransactionResult::TYPE_SALE); } else { $result = new TransactionError($requestArray['x_response_reason_text'], $requestArray); $url = ActiveRecordModel::getApplication()->getRouter()->createUrl(array('controller' => 'checkout', 'action' => 'pay', 'query' => array('error' => $requestArray['x_response_reason_text']))); ob_clean(); echo '<html><head><meta http-equiv="REFRESH" content="0;url=' . $url . '"></HEAD></html>'; exit; } return $result; }
public function getSelectFilter($disableFilters = false) { $selectFilter = $this->category->getProductsFilter($this, false); $selectFilter->merge($this->productFilter); $cond = null; if ($disableFilters == false) { $list = array(); // group filters by class foreach ($this->filters as $filter) { $id = $filter instanceof SpecificationFilterInterface ? $filter->getFilterGroup()->getID() : ''; $list[get_class($filter) . '_' . $id][] = $filter->getCondition(); $filter->defineJoin($selectFilter); } // convert filter group to OrChainCondition foreach ($list as &$filterGroup) { $filterGroup = new OrChainCondition($filterGroup); } if ($fCond = $selectFilter->getCondition()) { $list[] = $fCond; } $selectFilter->setCondition(new AndChainCondition($list)); // all merged with and } if (!empty(ActiveRecordModel::getApplication()->variationCond)) { $c = ActiveRecordModel::getApplication()->variationCond; $c->addAND(eq(f('Product.isEnabled'), true)); $noOrphans = new IsNotNullCond(f('Product.categoryID')); $orphanVariations = new IsNotNullCond(f('Product.parentID')); $orphanVariations->addAND(new IsNotNullCond(new ARExpressionHandle('(SELECT categoryID FROM Product AS par WHERE par.ID=Product.parentID)'))); $noOrphans->addOr($orphanVariations); $c->addAND($noOrphans); //$c->addAND(gt(f('Product.stockCount'), 0)); $conds = array($selectFilter->getCondition(), $c); $selectFilter->setCondition(new OrChainCondition($conds)); $selectFilter->setOrder(new ARExpressionHandle('(Product.parentID IS NULL)'), 'DESC'); //var_dump($selectFilter->createString()); } ActiveRecordModel::getApplication()->processInstancePlugins('finalProductFilter', $selectFilter); return $selectFilter; }
public function getUrl() { $params = array(); // Your affiliation name in our system, chosen by yourself when opening your account with us. This is a unique identifier and can’t ever be changed. $params['PSPID'] = $this->getConfigValue('pspid'); // a unique order id from your program. (128 characters max) $params['orderID'] = $this->details->invoiceID->get() . '_' . time(); // the total amount to be billed, in decimal form, without a currency symbol. $params['amount'] = $this->details->amount->get() * 100; $params['currency'] = $this->details->currency->get(); $params['accepturl'] = $this->notifyUrl; $params['accepturl'] = $this->returnUrl; $params['cancelurl'] = $this->cancelUrl; $params['catalogurl'] = $this->siteUrl; $params['declineurl'] = $this->cancelUrl; $params['exceptionurl'] = $this->cancelUrl; $params['homeurl'] = $this->siteUrl; // customer information $params['CN'] = $this->details->getName(); $params['owneraddress'] = $this->details->address->get(); $params['ownertown'] = $this->details->city->get(); $params['state'] = $this->details->state->get(); $params['ownerZIP'] = $this->details->postalCode->get(); $params['ownercty'] = $this->details->country->get(); $params['EMAIL'] = $this->details->email->get(); $params['ownertelno'] = $this->details->phone->get(); $params['language'] = ActiveRecordModel::getApplication()->getLocaleCode() . '_BE'; if ($secretWord = $this->getConfigValue('secretWord')) { $params['SHASign'] = strtoupper(sha1($params['orderID'] . $params['amount'] . $params['currency'] . $params['PSPID'] . $secretWord)); } $pairs = array(); foreach ($params as $key => $value) { $pairs[] = $key . '=' . urlencode($value); } return 'https://secure.ogone.com/ncol/' . ($this->getConfigValue('test') ? 'test' : 'prod') . '/orderstandard.asp?' . implode('&', $pairs); }
protected function getBackups($prettyBackupNames = true) { $application = ActiveRecordModel::getApplication(); $locale = $application->getLocale(); $result = array(); $path = $this->getBackupPath() . $this->getFileName() . DIRECTORY_SEPARATOR; foreach (glob($path . '*') as $file) { if (preg_match('/(\\d{4}\\-\\d{2}\\-\\d{2}\\-\\d{2}\\-\\d{2}\\-\\d{2})$/', $file, $z)) { if ($prettyBackupNames) { list($y, $m, $d, $h, $min, $s) = explode('-', $z[1]); $ts = strtotime($y . '-' . $m . '-' . $d . ' ' . $h . ':' . $min . ':' . $s); $formatted = $locale->getFormattedTime($ts); $result[$ts] = $formatted['date_medium'] . ' ' . $formatted['time_short']; } else { $result[$z[1]] = $file; } } } ksort($result); if ($prettyBackupNames) { $result[-1] = $application->translate('_previous_file_versions'); } return array_reverse($result, true); }
public static function addOptionValidation(RequestValidator $validator, $option, $fieldName) { $app = ActiveRecordModel::getApplication(); if (ProductOption::TYPE_FILE == $option['type']) { $checks = array(new IsFileUploadedCheck($app->translate('_err_option_upload')), new IsNotEmptyCheck($app->translate('_err_option_upload'))); $validator->addCheck($fieldName, new OrCheck(array('upload_' . $fieldName, $fieldName), $checks, $validator->getRequest())); if ($types = ProductOption::getFileExtensions($option['fileExtensions'])) { $validator->addCheck('upload_' . $fieldName, new IsFileTypeValidCheck($app->maketext('_err_option_filetype', implode(', ', $types)), $types)); } $validator->addCheck('upload_' . $fieldName, new MaxFileSizeCheck($app->maketext('_err_option_filesize', $option['maxFileSize']), $option['maxFileSize'])); } else { $validator->addCheck($fieldName, new IsNotEmptyCheck($app->translate('_err_option_' . $option['type']))); } }
public static function getDefaultEstimateAddress() { $config = ActiveRecordModel::getApplication()->getConfig(); $address = UserAddress::getNewInstance(); $address->countryID->set($config->get('DEF_COUNTRY')); if ($state = $config->get('DEF_STATE')) { $address->state->set(State::getInstanceByID($config->get('DEF_STATE'))); } return $address; }
public function getCountByManufacturers($includeAppliedFilters) { $selectFilter = $this->productFilter->getSelectFilter(!$includeAppliedFilters); $selectFilter->removeFieldList(); $selectFilter->setLimit(0); $selectFilter->setOrder(new ARExpressionHandle('cnt'), 'DESC'); $selectFilter->setGrouping(new ARFieldHandle('Product', 'manufacturerID')); $selectFilter->mergeHavingCondition(new MoreThanCond(new ARExpressionHandle('cnt'), 0)); $selectFilter->mergeHavingCondition(new NotEqualsCond(new ARFieldHandle('Manufacturer', 'name'), '')); $selectFilter->resetOrder(); $selectFilter->setOrder(new ARFieldHandle('Manufacturer', 'name')); $query = new ARSelectQueryBuilder(); $query->includeTable('Product'); $query->joinTable('Manufacturer', 'Product', 'ID', 'manufacturerID'); $query->joinTable('Category', 'Product', 'ID', 'categoryID'); $query->addField('COUNT(Product.manufacturerID)', null, 'cnt'); $query->addField('ID', 'Manufacturer'); $query->addField('name', 'Manufacturer'); $query->setFilter($selectFilter); ActiveRecordModel::getApplication()->processInstancePlugins('manufacturerCountQuery', $query); $data = ActiveRecordModel::getDataBySQL($query->getPreparedStatement(ActiveRecord::getDBConnection())); return $data; }