public static function getDomainsSettings() { $cache = new waSerializeCache('shopPricePlugin'); if ($cache && $cache->isCached()) { $domains_settings = $cache->get(); } else { $app_settings_model = new waAppSettingsModel(); $routing = wa()->getRouting(); $domains_routes = $routing->getByApp('shop'); $app_settings_model->get(shopPricePlugin::$plugin_id, 'domains_settings'); $domains_settings = json_decode($app_settings_model->get(shopPricePlugin::$plugin_id, 'domains_settings'), true); if (empty($domains_settings)) { $domains_settings = array(); } foreach ($domains_routes as $domain => $routes) { foreach ($routes as $route) { $domain_route = md5($domain . '/' . $route['url']); if (empty($domains_settings[$domain_route])) { $domains_settings[$domain_route] = shopPricePlugin::$default_settings; } } if ($domains_settings && $cache) { $cache->set($domains_settings); } } } return $domains_settings; }
/** * * @return waInstallerApps */ public static function &getInstaller() { if (!self::$model) { self::$model = new waAppSettingsModel(); } if (!self::$installer) { self::$installer = new waInstallerApps(self::$model->get('webasyst', 'license', false), wa()->getLocale(), 600, waRequest::get('refresh') ? true : false); } return self::$installer; }
public static function getDefaultFrom($sender = true) { if (!isset(self::$wa_config['from'])) { $app_settings_model = new waAppSettingsModel(); $email = $app_settings_model->get('webasyst', 'sender'); if ($email) { self::$wa_config['from'] = array($email => $app_settings_model->get('webasyst', 'name')); } else { self::$wa_config['from'] = array(); } } return self::$wa_config['from']; }
public function execute() { $app_settings_model = new waAppSettingsModel(); $background = $app_settings_model->get('webasyst', 'auth_form_background'); $stretch = $app_settings_model->get('webasyst', 'auth_form_background_stretch'); if ($background) { $background = 'wa-data/public/webasyst/' . $background; } $this->view->assign('stretch', $stretch); $this->view->assign('background', $background); $this->view->assign('env', wa()->getEnv()); $this->template = wa()->getAppPath('templates/layouts/Login.html', 'webasyst'); }
protected function load() { $this->settings = array(); if ($this->name) { //load settings from database $settings = self::$model->get($this->name); foreach ($settings as $field => $value) { if ($field != 'update_time') { $this->loadSetting($field, $value); } } } return $this; }
public function execute() { $app_settings_model = new waAppSettingsModel(); $settings = $app_settings_model->get(shopDiscountcardsPlugin::$plugin_id); if (!empty($settings['amounts'])) { $settings['amounts'] = json_decode($settings['amounts'], true); } else { $settings['amounts'] = array(); } $this->view->assign('settings', $settings); $templates = array(); foreach ($this->templates as $template_id => $template) { $tpl_full_path = $template['tpl_path'] . $template['tpl_name'] . '.' . $template['tpl_ext']; $template_path = wa()->getDataPath($tpl_full_path, $template['public'], 'shop', true); if (file_exists($template_path)) { $template['template'] = file_get_contents($template_path); $template['change_tpl'] = 1; } else { $template_path = wa()->getAppPath($tpl_full_path, 'shop'); $template['template'] = file_get_contents($template_path); $template['change_tpl'] = 0; } $templates[$template_id] = $template; } $this->view->assign('templates', $templates); }
public function postExecute($order_id = null, $result = null) { $data = parent::postExecute($order_id, $result); if ($order_id != null) { $log_model = new waLogModel(); $log_model->add('order_delete', $order_id); $order_model = new shopOrderModel(); $app_settings_model = new waAppSettingsModel(); if ($data['before_state_id'] != 'refunded') { $update_on_create = $app_settings_model->get('shop', 'update_stock_count_on_create_order'); // for logging changes in stocks shopProductStocksLogModel::setContext(shopProductStocksLogModel::TYPE_ORDER, 'Order %s was deleted', array('order_id' => $order_id)); if ($update_on_create) { $order_model->returnProductsToStocks($order_id); } else { if (!$update_on_create && $data['before_state_id'] != 'new') { $order_model->returnProductsToStocks($order_id); } } shopProductStocksLogModel::clearContext(); } $order = $order_model->getById($order_id); if ($order && $order['paid_date']) { // Remember paid_date in log params for Restore action $olpm = new shopOrderLogParamsModel(); $olpm->insert(array('name' => 'paid_date', 'value' => $order['paid_date'], 'order_id' => $order_id, 'log_id' => $data['id'])); // Empty paid_date and update stats so that deleted orders do not affect reports $order_model->updateById($order_id, array('paid_date' => null, 'paid_year' => null, 'paid_month' => null, 'paid_quarter' => null)); $order_model->recalculateProductsTotalSales($order_id); shopCustomers::recalculateTotalSpent($order['contact_id']); } } return $data; }
public function execute() { $messages = installerMessage::getInstance()->handle(waRequest::get('msg')); installerHelper::checkUpdates($messages); if ($m = $this->view->getVars('messages')) { $messages = array_merge($m, $messages); } $this->view->assign('messages', $messages); $plugins = 'wa-plugins/payment'; $apps = wa()->getApps(); if (isset($apps['shop'])) { $plugins = 'shop'; } else { ksort($apps); foreach ($apps as $app => $info) { if (!empty($info['plugins'])) { $plugins = $app; break; } } } $model = new waAppSettingsModel(); $this->view->assign('update_counter', $model->get($this->getApp(), 'update_counter')); $this->view->assign('module', waRequest::get('module', 'backend')); $this->view->assign('default_query', array('plugins' => $plugins)); }
function execute() { try { $message = array(); $settings = waRequest::get('setting'); if ($settings) { $model = new waAppSettingsModel(); $changed = false; foreach ((array) $settings as $setting) { if (in_array($setting, array('auth_form_background'))) { if ($value = $model->get('webasyst', $setting)) { waFiles::delete(wa()->getDataPath($value, true, 'webasyst')); $message[] = _w('Image deleted'); } } else { $changed = true; } $model->set('webasyst', $setting, false); } if ($changed) { $message[] = _w('Settings saved'); } } $params = array('module' => 'settings', 'msg' => installerMessage::getInstance()->raiseMessage(implode(', ', $message))); $this->redirect($params); } catch (waException $ex) { $msg = installerMessage::getInstance()->raiseMessage($ex->getMessage(), installerMessage::R_FAIL); $params = array('module' => 'settings', 'msg' => $msg); $this->redirect($params); } }
public function postExecute($order_id = null, $result = null) { $data = parent::postExecute($order_id, $result); if ($order_id != null) { $log_model = new waLogModel(); $log_model->add('order_restore', $order_id); $order_model = new shopOrderModel(); $app_settings_model = new waAppSettingsModel(); if ($this->state_id != 'refunded') { // for logging changes in stocks shopProductStocksLogModel::setContext(shopProductStocksLogModel::TYPE_ORDER, 'Order %s was restored', array('order_id' => $order_id)); $update_on_create = $app_settings_model->get('shop', 'update_stock_count_on_create_order'); if ($update_on_create) { $order_model->reduceProductsFromStocks($order_id); } else { if (!$update_on_create && $this->state_id != 'new') { $order_model->reduceProductsFromStocks($order_id); } } shopProductStocksLogModel::clearContext(); } $order = $order_model->getById($order_id); if ($order && $order['paid_date']) { shopAffiliate::applyBonus($order_id); shopCustomers::recalculateTotalSpent($order['contact_id']); } } return $data; }
/** * Получение и обработка данных об отзывах из кабинета WA * Получение и обработка идет до тех пор, пока не будут обраотаны либо все страницы * либо пока не будет найден отзыв который уже есть в БД в таблице wacab_reviews */ public function getReviews() { $settings_model = new waAppSettingsModel(); $settings = $settings_model->get('wacab'); $model = new wacabReviewModel(); $auth = new wacabWaauth(); $count = 0; while (true) { if (!isset($url)) { $url = 'https://www.webasyst.ru/my/?action=developerReviews'; } $rvs = wacabReviewsparseController::getReviews($url, $auth); $url = $rvs[0]; unset($rvs[0]); foreach ($rvs as $rv) { $check_rv = array('rv_id' => $rv['rv_id']); $exist_rv = $model->getByField($check_rv); if (count($exist_rv) > 0) { if ($rv['date'] == $exist_rv['date'] && $rv['text'] == $exist_rv['text']) { break 2; } else { $model->updateById($exist_rv['id'], $rv); $count++; continue; } } $model->insert($rv); $count++; } if ($url == 'false') { break; } } return $count; }
/** * Получение и обработка данных оп платежах из кабинета WA * Получение и обработка идет до тех пор, пока не будут обраотаны либо все страницы * либо пока не будет найден платеж который уже есть в БД в таблице wacab_payments * @param object wacabWaauth */ public function getPayment($auth) { $settings_model = new waAppSettingsModel(); $settings = $settings_model->get('wacab'); $model = new wacabPaymentModel(); $count = 0; while (true) { if (!isset($url)) { $url = 'https://www.webasyst.ru/my/?action=checkingaccountInfo&id=' . $settings['account']; } $pays = wacabPaymentparseController::getPayments($url, $auth); $url = $pays[0]; unset($pays[0]); foreach ($pays as $pay) { $check_pay = array('date' => $pay['date'], 'order' => $pay['order'], 'description' => $pay['description']); $exist_pay = $model->getByField($check_pay); if (count($exist_pay) > 0) { break 2; } /* Привязываем платеж к плагину/приложению */ $pay['type'] = self::checkType($pay); if ($pay['type'] == 'payin') { $pay['apps_id'] = self::checkApps($pay); } /* EOF Привязываем платеж к плагину/приложению */ $model->insert($pay); $count++; } if ($url == 'false') { break; } } return $count; }
public function postExecute($order_id = null, $result = null) { $data = parent::postExecute($order_id, $result); $log_model = new waLogModel(); $log_model->add('order_complete', $order_id); $order_model = new shopOrderModel(); if (is_array($order_id)) { $order = $order_id; $order_id = $order['id']; } else { $order = $order_model->getById($order_id); } shopCustomers::recalculateTotalSpent($order['contact_id']); if ($order !== null) { $log_model = new shopOrderLogModel(); $state_id = $log_model->getPreviousState($order_id); $app_settings_model = new waAppSettingsModel(); $update_on_create = $app_settings_model->get('shop', 'update_stock_count_on_create_order'); if (!$update_on_create && $state_id == 'new') { // jump through 'processing' state - reduce // for logging changes in stocks shopProductStocksLogModel::setContext(shopProductStocksLogModel::TYPE_ORDER, 'Order %s was completed', array('order_id' => $order_id)); $order_model = new shopOrderModel(); $order_model->reduceProductsFromStocks($order_id); shopProductStocksLogModel::clearContext(); } $order_model->recalculateProductsTotalSales($order_id); } return $data; }
public function execute() { try { $app_settings_model = new waAppSettingsModel(); if (waRequest::post('cancel')) { wa()->getStorage()->set('shop/discountcard', ''); } else { if ($discountcard_number = waRequest::post('discountcard')) { $model = new shopDiscountcardsPluginModel(); if ($app_settings_model->get(shopDiscountcardsPlugin::$plugin_id, 'binding_customer')) { $contact_id = wa()->getUser()->getId(); $discountcard = $model->getByField(array('contact_id' => $contact_id, 'discountcard' => $discountcard_number)); if (empty($discountcard)) { $discountcard = $model->getByField(array('contact_id' => 0, 'discountcard' => $discountcard_number)); } } else { $discountcard = $model->getByField('discountcard', $discountcard_number); } if ($discountcard) { wa()->getStorage()->set('shop/discountcard', $discountcard['discountcard']); } else { throw new waException('Дисконтная карта не найдена'); } } else { throw new waException('Укажите номер дисконтной карты'); } } } catch (Exception $ex) { $this->setError($ex->getMessage()); } }
public static function prepareSkus($skus = array(), $contact_id = null, $currency = null) { $app_settings_model = new waAppSettingsModel(); if ($app_settings_model->get(self::$plugin_id, 'status') && shopPrice::getDomainSetting('status')) { $category_ids = self::getUserCategoryId($contact_id); $domain_hash = shopPrice::getRouteHash(); $params = array('domain_hash' => $domain_hash, 'category_id' => $category_ids); $price_model = new shopPricePluginModel(); $prices = $price_model->getPriceByParams($params, true); if ($prices) { foreach ($skus as &$sku) { foreach ($prices as $price) { $price_field = "price_plugin_{$price['id']}"; if (!empty($sku[$price_field]) && $sku[$price_field] > 0) { //if (!empty($sku['unconverted_currency']) && !empty($sku['currency'])) { // $sku['price'] = shop_currency($sku[$price_field], $sku['unconverted_currency'], $sku['currency'], false); //} else { if (!$currency) { $sku['price'] = $sku[$price_field]; } else { $product_model = new shopProductModel(); $product = $product_model->getById($sku['product_id']); $sku['price'] = shop_currency($sku[$price_field], $product['currency'], $currency, false); } //} break; } } } unset($sku); } } return $skus; }
public function execute() { $app_settings_model = new waAppSettingsModel(); $settings = $app_settings_model->get(shopPricePlugin::$plugin_id); $ccm = new waContactCategoryModel(); $categories = array(array('id' => 0, 'name' => 'Все покупатели')); foreach ($ccm->getAll() as $c) { if ($c['app_id'] == 'shop') { $categories[$c['id']] = $c; } } $price_model = new shopPricePluginModel(); $prices = $price_model->getAll(); $_prices = array(); foreach ($prices as $price) { $_prices[$price['domain_hash']][] = $price; } $domain_routes = wa()->getRouting()->getByApp('shop'); $domains_settings = shopPrice::getDomainsSettings(); $this->view->assign('prices', $_prices); $this->view->assign('domain_routes', $domain_routes); $this->view->assign('categories', $categories); $this->view->assign('settings', $settings); $this->view->assign('domain_settings', $domains_settings); }
public function onCount() { return; $settings_model = new waAppSettingsModel(); $settings = $settings_model->get('wacab'); if (!isset($settings['count']) || $settings['count'] == 0) { return null; } if (!isset($settings['count_ts'])) { $settings_model->set('wacab', 'count_ts', time()); return null; } if (!isset($settings['timeout'])) { $settings['timeout'] = 60; } if (time() - $settings['count_ts'] < $settings['timeout'] * 60) { return null; } $auth = new wacabWaauth(); $new = new wacabGetpayment(); $ps = $new->getPayment($auth); if (isset($settings['new_count'])) { $newcount = $settings['new_count'] + $ps; } else { $newcount = 0; } $settings_model->set('wacab', 'new_count', $newcount); $settings['count_ts'] = time(); unset($auth); if ($newcount == 0) { return null; } else { return array('count' => $newcount, 'url' => wa()->getUrl(true) . 'wacab/#/transactions/'); } }
/** * @param array $options */ public function __construct($options = array()) { if (is_array($options)) { foreach ($options as $k => $v) { $this->options[$k] = $v; } } if (!isset($this->options['login'])) { $this->options['login'] = wa()->getEnv() == 'backend' ? 'login' : 'email'; } if (!isset($this->options['is_user'])) { // only contacts with is_user = 1 can auth $this->options['is_user'] = wa()->getEnv() == 'backend'; } if (!isset($this->options['remember_enabled'])) { if (wa()->getEnv() == 'backend') { try { $app_settings_model = new waAppSettingsModel(); $this->options['remember_enabled'] = $app_settings_model->get('webasyst', 'rememberme', true); } catch (waException $e) { $this->options['remember_enabled'] = true; } } else { $this->options['remember_enabled'] = true; } } }
public function execute() { $settings_model = new waAppSettingsModel(); $settings = $settings_model->get('wacab'); $this->view->assign('settings', $settings); $this->setTemplate(wacabHelper::getAppPath() . '/templates/actions/settings/Settings_page.html'); }
private function initRouting() { $routing = wa()->getRouting(); $app_id = $this->getAppId(); $domain_routes = $routing->getByApp($app_id); $success = false; foreach ($domain_routes as $domain => $routes) { foreach ($routes as $route) { if ($domain . '/' . $route['url'] == $this->data['domain']) { $routing->setRoute($route, $domain); $this->data['type_id'] = ifempty($route['type_id'], array()); if ($this->data['type_id']) { $this->data['type_id'] = array_map('intval', $this->data['type_id']); } waRequest::setParam($route); $this->data['base_url'] = parse_url('http://' . preg_replace('@https?://@', '', $domain), PHP_URL_HOST); $success = true; break; } } } if (!$success) { throw new waException('Error while select routing'); } $app_settings_model = new waAppSettingsModel(); $this->data['app_settings'] = array('ignore_stock_count' => $app_settings_model->get($app_id, 'ignore_stock_count', 0)); }
public function execute() { $model_settings = new waAppSettingsModel(); $settings = $model_settings->get($key = array('shop', 'deliveryshop')); $model = new waModel(); $domains = $model->query("SELECT * FROM site_domain")->fetchAll(); $prices = $model->query("SELECT * FROM shop_deliveryshop_delivery")->fetchAll('domain'); foreach ($domains as $d) { $tab = explode('.', $d['name']); $info[$d['name']]['tab_name'] = $tab[0]; $template_path = wa()->getDataPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka' . $d['id'] . '.html', false, 'shop', true); $change_tpl[$d['name']] = true; if (!file_exists($template_path)) { $template_path = wa()->getAppPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka.html', 'shop'); $change_tpl[$d['name']] = false; } $template_content[$d['name']] = file_get_contents($template_path); unset($template_path); } $this->view->assign('info', $info); $this->view->assign('prices', $prices); $this->view->assign('change_tpl', $change_tpl); $this->view->assign('template', $template_content); $this->view->assign('settings', $settings); }
public function execute() { $app_settings_model = new waAppSettingsModel(); $query = waRequest::get('term'); $count = $app_settings_model->get($this->plugin_id, 'autocomplete_count'); $collection = new shopProductsCollection('search/query=' . $query); $products = $collection->getProducts('*', 0, $count); $result = array(); foreach ($products as $product) { $size = $app_settings_model->get($this->plugin_id, 'img_size'); $product['value'] = $product['name']; $product['price_str'] = shop_currency($product['price']); $product['img_url'] = $product['image_id'] ? shopImage::getUrl(array('id' => $product['image_id'], 'product_id' => $product['id'], 'filename' => $product['image_filename'], 'ext' => $product['ext']), $size) : ''; array_push($result, $product); } $this->response = $result; }
public function execute() { list($start_date, $end_date, $group_by) = shopReportsSalesAction::getTimeframeParams(); $checkout_flow = new shopCheckoutFlowModel(); $stat = $checkout_flow->getStat($start_date, $end_date); $app_settings_model = new waAppSettingsModel(); $this->view->assign(array('stat' => $stat, 'checkout_flow_changed' => $app_settings_model->get('shop', 'checkout_flow_changed', 0))); }
public function execute() { $route_id = waRequest::get('route'); $routes = wa()->getRouting()->getRoutes(siteHelper::getDomain()); if (!isset($routes[$route_id])) { throw new waException('Route not found', 404); } $route = $routes[$route_id]; $app_id = $routes[$route_id]['app']; $path = $this->getConfig()->getAppsPath($app_id, 'lib/config/site.php'); $app = wa()->getAppInfo($app_id); if (file_exists($path)) { // load locale of the app if ($app_id != 'site') { waSystem::getInstance($app_id)->setActive($app_id); } $app['site'] = (include $path); // return old locale of the site if ($app_id != 'site') { waSystem::setActive('site'); } } if (isset($app['site']['params'])) { $params = $this->getParams($route_id, $app['site']['params'], $route); } else { $params = array(); } $themes = siteHelper::getThemes($app_id); if (!isset($route['theme']) && $themes) { $route['theme'] = 'default'; } if (!isset($route['theme_mobile']) && $themes) { $route['theme_mobile'] = $route['theme']; } if (!isset($route['locale'])) { $route['locale'] = ''; } if (!isset($route['_name'])) { if ($app_id == 'site') { if ($title = siteHelper::getDomain('title')) { $route['_name'] = $title; } else { $app_settings_model = new waAppSettingsModel(); $route['_name'] = $app_settings_model->get('webasyst', 'name', 'Webasyst'); } } else { $route['_name'] = $app['name']; } } $this->view->assign('route_id', $route_id); $this->view->assign('route', $route); $this->view->assign('params', $params); $this->view->assign('app_id', $app_id); $this->view->assign('app', $app); $this->view->assign('domain_id', siteHelper::getDomainId()); $this->view->assign('domain', siteHelper::getDomain()); $this->view->assign('locales', array('' => _w('Auto')) + waLocale::getAll('name')); }
public static function getDomainsSettings() { $cache = new waSerializeCache('shopOnestepPlugin'); if ($cache && $cache->isCached()) { $domains_settings = $cache->get(); } else { $app_settings_model = new waAppSettingsModel(); $routing = wa()->getRouting(); $domains_routes = $routing->getByApp('shop'); $app_settings_model->get(shopOnestepPlugin::$plugin_id, 'domains_settings'); $domains_settings = json_decode($app_settings_model->get(shopOnestepPlugin::$plugin_id, 'domains_settings'), true); if (empty($domains_settings)) { $domains_settings = array(); } foreach ($domains_routes as $domain => $routes) { foreach ($routes as $route) { $domain_route = md5($domain . '/' . $route['url']); if (empty($domains_settings[$domain_route])) { $domains_settings[$domain_route] = shopOnestepPlugin::$default_settings; } foreach (shopOnestepPlugin::$default_settings['templates'] as $tpl_name => $tpl) { $domains_settings[$domain_route]['templates'][$tpl_name] = $tpl; $tpl_full_path = $tpl['tpl_path'] . $domain_route . '_' . $tpl['tpl_name'] . '.' . $tpl['tpl_ext']; $domains_settings[$domain_route]['templates'][$tpl_name]['tpl_full_path'] = $tpl_full_path; $template_path = wa()->getDataPath($tpl_full_path, $tpl['public'], 'shop', true); if (file_exists($template_path)) { $domains_settings[$domain_route]['templates'][$tpl_name]['template_path'] = $template_path; $domains_settings[$domain_route]['templates'][$tpl_name]['template'] = file_get_contents($template_path); $domains_settings[$domain_route]['templates'][$tpl_name]['change_tpl'] = 1; } else { $domains_settings[$domain_route]['templates'][$tpl_name]['tpl_full_path'] = $tpl['tpl_path'] . $tpl['tpl_name'] . '.' . $tpl['tpl_ext']; $template_path = wa()->getAppPath($tpl['tpl_path'] . $tpl['tpl_name'] . '.' . $tpl['tpl_ext'], 'shop'); $domains_settings[$domain_route]['templates'][$tpl_name]['template_path'] = $template_path; $domains_settings[$domain_route]['templates'][$tpl_name]['template'] = file_get_contents($template_path); $domains_settings[$domain_route]['templates'][$tpl_name]['change_tpl'] = 0; } } } if ($domains_settings && $cache) { $cache->set($domains_settings); } } } return $domains_settings; }
public function execute() { $settings_model = new waAppSettingsModel(); $settings = $settings_model->get('wacab'); $model = new wacabPaymentModel(); $reviews = $model->query('SELECT * FROM wacab_review ORDER BY date DESC')->fetchAll(); $this->view->assign('reviews', $reviews); $this->setTemplate(wacabHelper::getAppPath() . '/templates/actions/reviews/reviews_page.html'); }
public function execute() { $app_settings_model = new waAppSettingsModel(); $settings = $app_settings_model->get(shopOrderantispamPlugin::$plugin_id); $workflow = new shopWorkflow(); $actions = $workflow->getAvailableActions(); $this->view->assign('actions', $actions); $this->view->assign('settings', $settings); }
public function execute() { $app_settings_model = new waAppSettingsModel(); $settings = $app_settings_model->get(shopPhmaskPlugin::$plugin_id); $domain_routes = wa()->getRouting()->getByApp('shop'); $domains_settings = shopPhmask::getDomainsSettings(); $this->view->assign('settings', $settings); $this->view->assign('domain_settings', $domains_settings); $this->view->assign('domain_routes', $domain_routes); }
public function execute() { $app_settings_model = new waAppSettingsModel(); $settings = $app_settings_model->get(array('shop', 'yoss')); if ($settings['status'] === 'on') { $query = waRequest::post('query', '', waRequest::TYPE_STRING_TRIM); $page = waRequest::post('page', 1, 'int'); $result = array(); $result['products'] = array(); $result['product_count'] = 0; $collection = new shopProductsCollection('search/query=' . $query); $product_limit = $settings['product_limit']; if (!$product_limit) { $product_limit = $this->getConfig()->getOption('products_per_page'); } $products = $collection->getProducts('*', ($page - 1) * $product_limit, $product_limit); if ($products) { $brands = array(); $categories = array(); $feature_model = new shopFeatureModel(); $result['searh_all_url'] = wa()->getRouteUrl('/frontend/search/query=') . '?query=' . $query; foreach ($products as $p) { $brand_feature = $feature_model->getByCode('brand'); $brand = ''; if ($brand_feature) { $feature_value_model = $feature_model->getValuesModel($brand_feature['type']); $product_brands = $feature_value_model->getProductValues($p['id'], $brand_feature['id']); $brands = array(); foreach ($product_brands as $k => $v) { $brand_id = $feature_value_model->getValueId($brand_feature['id'], $v); $brands[] = array('id' => $brand_id, 'brand' => '<a href="' . wa()->getRouteUrl('shop/frontend/brand', array('brand' => str_replace('%2F', '/', urlencode($v)))) . '">' . $v . '</a>'); } } $category_model = new shopCategoryModel(); $category = $category_model->getById($p['category_id']); $res_category = ''; if ($category) { $res_category = '<a href="' . wa()->getRouteUrl('/frontend/category', array('category_url' => $category['full_url'])) . '">' . $category['name'] . '</a>'; } $result['products'][] = array("name" => $p['name'], "url" => $p['frontend_url'], "image" => $p['image_id'] ? "<img src='" . shopImage::getUrl(array("product_id" => $p['id'], "id" => $p['image_id'], "ext" => $p['ext']), "48x48") . "' />" : "", "price" => shop_currency_html($p['price'], true), "brands" => $brands, "category" => $res_category); } $product_model = new shopProductModel(); $product_count = $collection->count(); $result['product_count'] = $product_count; if ($product_count > ($page - 1) * $product_limit + $product_limit) { $result['next_page'] = $page + 1; } else { $result['next_page'] = false; } } $this->response = $result; } else { $this->response = false; } }
/** * This method is called upon successful creation of a new contact * It sends a welcome message to the new user * * Этот метод вызывается после успешного создания нового контакта * В нём будет отправлено приветственное письмо новому пользователю * * @param waContact $contact */ public function afterSignup(waContact $contact) { // Adding contact to system category guestbook2 (named by the app ID) // to be able to easily view all contacts registered in the guestbook // or who have left a comment, in the Contacts app // Добавляем контакт в системную категорию guestbook2 (по ID приложения) // Чтобы в приложении Контакты можно было легко посмотреть все контакты, // которые были зарегистрированы в гостевой книге, либо что-то написали в ней $contact->addToCategory($this->getAppId()); // Getting contact's main email address // Получаем главный email контакта $email = $contact->get('email', 'default'); // If not specified, do nothing // Если он не задан, ничего не делаем if (!$email) { return; } // Generating random hash // Генерируем случайный хэш $hash = md5(uniqid(time(), true)); // Saving the hash in contact info table with the app id // Сохраняем этот хэш в таблице свойств контакта, указывая приложение $contact->setSettings($this->getAppId(), 'confirm_hash', $hash); // Adding contact id to the hash for easier search and verification by hash (see guestbook2FrontendConfirmAction) // Добавляем в хэш номер контакта, чтобы было проще искать и проверять по хэшу (см. guestbook2FrontendConfirmAction) $hash = substr($hash, 0, 16) . $contact->getId() . substr($hash, 16); // Creating confirmation link with an absolute URL // Формируем абсолютную ссылку подтверждения $confirmation_url = wa()->getRouteUrl('/frontend/confirm', true) . "?hash=" . $hash; // Creating a link to the app's home page with an absolute URL // Формируем абсолютную ссылку на главную страницу приложения $root_url = wa()->getRouteUrl('/frontend', true); // Getting account name // Получаем название аккаунта $app_settings_model = new waAppSettingsModel(); $account_name = htmlspecialchars($app_settings_model->get('webasyst', 'name', 'Webasyst')); // Generating message body // Формируем тело письма $body = _w('Hi') . ' ' . htmlspecialchars($contact->getName()) . ',<br> <br> ' . sprintf(_w('Please confirm your account at %s by clicking this link:'), $account_name) . '<br> <a href="' . $confirmation_url . '"><strong>' . $confirmation_url . '</strong></a><br> <br> --<br> ' . $account_name . '<br> <a href="' . $root_url . '">' . $root_url . '</a>'; $subject = _w('Confirm your account'); // Sending email message // Отправляем письмо $message = new waMailMessage($subject, $body); $message->setTo($email, $contact->getName()); $message->send(); }