function isActive() { global $application; $tables = Configuration::getTables(); $columns = $tables['store_settings']['columns']; $result_rows = array(); $query = new DB_Select(); $query->addSelectField($columns['value'], 'value'); $query->WhereValue($columns['name'], DB_EQ, 'enable_error_document'); $result_rows = $application->db->getDB_Result($query); return $result_rows[0]['value']; }
/** * Gets a list of receiver addesses together with their languages. * */ function getMLSendTo() { global $application; $tables = Notifications::getTables(); $nst = $tables['notification_send_to']['columns']; $query = new DB_Select(); $query->addSelectField($nst['email'], 'Email'); $query->addSelectField($nst['code'], 'Email_Code'); $query->WhereValue($nst['n_id'], DB_EQ, $this->notificationId); $result = $application->db->getDB_Result($query); $to = array(); foreach ($result as $ToEmail) { if ($ToEmail['Email_Code'] == 'EMAIL_CUSTOMER') { $customerEmail = null; switch ($this->actionId) { case '1': case '2': case '3': case '4': case '5': $pushedCurrency = true; $currencyId = modApiFunc('Localization', 'whichCurrencyToDisplayOrderIn', $this->orderId); $orderInfo = modApiFunc('Checkout', 'getOrderInfo', $this->orderId, $currencyId); modApiFunc('Localization', 'pushDisplayCurrency', $currencyId, $currencyId); $customer_id = $orderInfo['PersonId']; $account_name = modApiFunc('Customer_Account', 'getCustomerAccountNameByCustomerID', $customer_id); $customer_obj =& $application->getInstance('CCustomerInfo', $account_name); /* download links should be sent to shipping email, other info to main email */ $destination = $this->actionId == 5 ? 'Shipping' : 'Customer'; $customerEmail = $customer_obj->getPersonInfo('Email', $destination); if (!$customerEmail) { $customerEmail = $customer_obj->getPersonInfo('Email', 'Customer'); } $customerLng = $customer_obj->getPersonInfo('Notification_Lng'); break; case '6': if (array_key_exists('Email', $this->customerRegData['info'])) { $customerEmail = $this->customerRegData['info']['Email']; $customerLng = modApiFunc('MultiLang', 'getLanguage'); } break; case '7': case '8': case '9': case '10': case '11': case '12': case '13': case '15': $customer_obj =& $application->getInstance('CCustomerInfo', $this->customerAccount); $customerEmail = $customer_obj->getPersonInfo('Email', 'Customer'); $customerLng = $customer_obj->getPersonInfo('Notification_Lng'); break; } if ($customerEmail) { if (!modApiFunc('MultiLang', 'checkLanguage', $customerLng)) { $customerLng = modApiFunc('MultiLang', 'getDefaultLanguage'); } if (!modApiFunc('MultiLang', 'checkLanguage', $customerLng)) { $customerLng = modApiFunc('MultiLang', '_getAnyLanguage'); } $to[] = array($customerEmail, $customerLng); } } else { $email = modApiFunc("Notifications", "getExtendedEmail", $ToEmail['Email'], $ToEmail['Email_Code'], true, NULL, true); if ($email[0]) { $to[] = $email; } } } return $to; }
function getCreditCardSettings($visible_only = true) { // global $application; $tables = $this->getTables(); $columns = $tables['credit_card_settings']['columns']; $query = new DB_Select(); $query->addSelectField($columns["id"], "id"); $query->addSelectField($columns["name"], "name"); $query->addSelectField($columns["tag"], "tag"); $query->addSelectField($columns["sort_order"], "sort_order"); $query->addSelectField($columns["visible"], "visible"); if ($visible_only === true) { $query->WhereValue($columns["visible"], DB_EQ, DB_TRUE); } $query->SelectOrder($columns['sort_order']); $result = $application->db->getDB_Result($query); $res = array(); foreach ($result as $credit_card_info) { $res[$credit_card_info["tag"]] = array("id" => $credit_card_info["id"], "sort_order" => $credit_card_info["sort_order"], "name" => (string) $credit_card_info["name"], "tag" => (string) $credit_card_info["tag"], "visible" => (string) $credit_card_info["visible"]); } return $res; }
function getLetterTopics($letter_id) { global $application; $tables = $this->getTables(); $ntables = modApiFunc('Newsletter', 'getTables'); $ltable = 'newsletter_topics'; $lcolumns =& $ntables[$ltable]['columns']; $query = new DB_Select($ltable); $query->addSelectField($lcolumns['topic_id']); $query->WhereValue($lcolumns['letter_id'], DB_EQ, $letter_id); $res = $application->db->getDB_Result($query); $ids = array(); foreach ($res as $r) { $ids[$r['topic_id']] = $r['topic_id']; } return $ids; }
/** * * * @author Alexandr Girin * @param * @return */ function DeleteOrders($ordersId) { modApiFunc('EventsManager', 'throwEvent', 'OrdersWillBeDeleted', $ordersId); global $application; $tables = $this->getTables(); $on = $tables['order_notes']['columns']; $opd = $tables['order_person_data']['columns']; $opr = $tables['order_prices']['columns']; $otx = $tables['order_taxes']['columns']; $otdo = $tables['order_tax_display_options']['columns']; $op = $tables['order_product']['columns']; $opca = $tables['order_product_custom_attributes']['columns']; $opta = $tables['order_product_to_attributes']['columns']; $opot = $tables['order_product_options']['columns']; $o = $tables['orders']['columns']; $DB_IN_string = "('" . implode("', '", $ordersId) . "')"; $query = new DB_Select(); $query->addSelectField($op['id'], 'id'); $query->WhereField($op['order_id'], DB_IN, $DB_IN_string); $order_products_id = $application->db->getDB_Result($query); foreach ($order_products_id as $key => $order_product_id) { $order_products_id[$key] = $order_product_id['id']; } $query = new DB_Delete('order_notes'); $query->WhereField($on['order_id'], DB_IN, $DB_IN_string); $application->db->getDB_Result($query); $query = new DB_Delete('order_person_data'); $query->WhereField($opd['order_id'], DB_IN, $DB_IN_string); $application->db->getDB_Result($query); $query = new DB_Delete('order_prices'); $query->WhereField($opr['order_id'], DB_IN, $DB_IN_string); $application->db->getDB_Result($query); $query = new DB_Delete('order_taxes'); $query->WhereField($otx['order_id'], DB_IN, $DB_IN_string); $application->db->getDB_Result($query); $query = new DB_Delete('order_tax_display_options'); $query->WhereField($otdo['order_id'], DB_IN, $DB_IN_string); $application->db->getDB_Result($query); $query = new DB_Delete('order_product'); $query->WhereField($op['order_id'], DB_IN, $DB_IN_string); $application->db->getDB_Result($query); $query = new DB_Delete('order_product_custom_attributes'); $query->WhereField($opca['product_id'], DB_IN, "('" . implode("', '", $order_products_id) . "')"); $application->db->getDB_Result($query); $query = new DB_Delete('order_product_to_attributes'); $query->WhereField($opta['product_id'], DB_IN, "('" . implode("', '", $order_products_id) . "')"); $application->db->getDB_Result($query); $query = new DB_Select(); $query->addSelectField($opot['option_value'], 'option_value'); $query->WhereValue($opot['is_file'], DB_EQ, 'Y'); $query->WhereAND(); $query->Where($opot['order_product_id'], DB_IN, "('" . implode("', '", $order_products_id) . "')"); $__res = $application->db->getDB_Result($query); if (count($__res) > 0) { foreach ($__res as $oinfo) { if ($oinfo['option_value'] != '') { modApiFunc('Shell', 'removeDirectory', dirname($oinfo['option_value'])); } } } $query = new DB_Delete('order_product_options'); $query->WhereField($opot['order_product_id'], DB_IN, "('" . implode("', '", $order_products_id) . "')"); $application->db->getDB_Result($query); modApiFunc("PromoCodes", "DeleteOrders", $ordersId); modApiFunc("TaxExempts", "DeleteOrders", $ordersId); modApiFunc('GiftCertificateApi', 'DeleteOrders', $ordersId); $query = new DB_Delete('orders'); $query->WhereField($o['id'], DB_IN, $DB_IN_string); $application->db->getDB_Result($query); }
function dropCustomerPassword($var, $var_type = 'customer_account') { if (!in_array($var_type, array('customer_account', 'customer_id'))) { return false; } global $application; $tables = $this->getTables(); $ca_table = $tables['ca_customers']['columns']; $query = new DB_Select(); $query->addSelectTable('ca_customers'); $query->addSelectField($ca_table['customer_id'], 'customer_id'); $query->addSelectField($ca_table['customer_account'], 'customer_account'); $query->WhereValue($ca_table[$var_type], DB_EQ, $var); $res = $application->db->getDB_Result($query); if (count($res) != 1) { return false; } else { $customer_id = $res[0]['customer_id']; $customer_account = $res[0]['customer_account']; } $query = new DB_Update('ca_customers'); $query->addUpdateValue($ca_table['customer_password'], $this->__genPseudoPasswd()); $query->addUpdateValue($ca_table['customer_status'], 'R'); $query->WhereValue($ca_table['customer_id'], DB_EQ, $customer_id); $application->db->PrepareSQL($query); return $application->db->DB_Exec() and $this->replaceActivationKey($customer_account); }
/** * Gets credit card info by the order. * * @return array - the array of module settings */ function getOrderCCInfoFromDB($order_id) { global $application; $tables = $this->getTables(); $columns = $tables['pm_offline_cc_order_cc_info']['columns']; $query = new DB_Select(); $query->addSelectField($columns["key"], "set_key"); $query->addSelectField($columns["value"], "set_value"); $query->WhereValue($field['order_id'], DB_EQ, $order_id); $result = $application->db->getDB_Result($query); $res = array(); for ($i = 0; $i < sizeof($result); $i++) { $res[$result[$i]['key']] = $result[$i]['value']; } return $res; }
function getOrderCoupons($order_id = NULL, $coupon_id = NULL) { global $application; $tables = $this->getTables(); $tr = $tables['order_promo_codes']['columns']; $result_array = array(); $query = new DB_Select(); $query->addSelectField($tr["order_id"], "order_id"); $query->addSelectField($tr["coupon_id"], "coupon_id"); $query->addSelectField($tr["coupon_promo_code"], "coupon_promo_code"); $query->WhereValue('', '', '1'); if ($order_id !== NULL) { $query->WhereAnd(); $query->WhereValue($tr["order_id"], DB_EQ, $order_id); } if ($coupon_id !== NULL) { $query->WhereAND(); $query->WhereValue($tr["coupon_id"], DB_EQ, $coupon_id); } $result_rows = $application->db->getDB_Result($query); return $result_rows; }
function delAllFilesFromProducts($products_ids) { global $application; $tables = $this->getTables(); $files_table = $tables['pf_files']['columns']; $query = new DB_Select(); $query->addSelectField($files_table['file_path']); $query->Where($files_table['product_id'], DB_IN, "('" . implode("','", $products_ids) . "')"); $query->WhereAND(); $query->WhereValue($files_table['is_uploaded'], DB_EQ, 'Y'); $res = $application->db->getDB_Result($query); $this->unlinkFiles($res); $query = new DB_Delete('pf_files'); $query->Where($files_table['product_id'], DB_IN, "('" . implode("','", $products_ids) . "')"); $application->db->PrepareSQL($query); $application->db->DB_Exec(); return; }
/** * Gets the news list. * * @param string $news_type - 'avactis' or 'store' - defines, if external or * internal news is required. * Added in case news is required not only for the administrator but also * for the Avactis users. * @return array - the latest news array, the length of which is * NEWS_DISPLAY_COUNT parameter of the News module */ function getNewsList($news_type = 'avactis') { global $application; $tables = $this->getTables(); $columns = $tables['news']['columns']; $query = new DB_Select(); $query->AddSelectField($columns['title'], 'NewsTitle'); $query->AddSelectField($columns['link'], 'NewsLink'); $query->AddSelectField($columns['content'], 'NewsContent'); $query->AddSelectField($columns['category'], 'NewsCategory'); $query->AddSelectField($columns['date'], 'NewsDate'); $query->WhereValue($columns['type'], DB_EQ, $news_type); $query->SelectOrder($columns['date'], 'DESC'); $query->SelectLimit(0, $this->settings[NEWS_DISPLAY_COUNT]); return $application->db->getDB_Result($query); }
function validateOrder($orderID) { if (ltrim($_GET[WebToPay::PREFIX . 'orderid'], "0") != $orderID) { exit('Order ID mismatch!'); } global $application; $msg =& $application->getInstance('MessageResources', "payment-module-wtp-messages", "AdminZone"); $moduleData = $this->getSettings(); $query = new DB_Select(); $query->addSelectTable('order_prices'); $query->addSelectField('*'); $query->WhereValue('order_id', DB_EQ, $orderID); $Order = $application->db->getDB_Result($query); try { WebToPay::toggleSS2(true); $response = WebToPay::checkResponse($_GET, array('projectid' => $moduleData['MODULE_METHOD_ID'], 'sign_password' => $moduleData['MODULE_METHOD_PASS'])); } catch (Exception $e) { exit(get_class($e) . ': ' . $e->getMessage()); } if (intval(number_format($Order[0]['order_total'], 2, '', '')) > $_GET[WebToPay::PREFIX . 'amount']) { exit('Bad amount!'); } else { if ($Order[0]['currency_code'] != $_GET[WebToPay::PREFIX . 'currency']) { exit('Bad currency!'); } else { modApiFunc("Checkout", "UpdatePaymentStatusInDB", $orderID, 2, 'Payment accepted.'); exit('OK'); } } }
function __loadOrdersSummary() { if (!$this->search_completed or empty($this->orders_ids)) { return; } // : // , // main_store_currency . // main_store_currency, // . // main_store_currency. global $application; $co_tables = modApiStaticFunc('Checkout', 'getTables'); $orders_table = $co_tables['orders']['columns']; $order_prices_table = $co_tables['order_prices']['columns']; $query = new DB_Select(); $query->addSelectTable('orders'); $query->addSelectField($order_prices_table['order_total'], 'order_total'); $query->addSelectField($orders_table['payment_status_id'], 'payment_status_id'); $query->addSelectField($order_prices_table['currency_code'], 'currency_code'); $query->WhereValue($order_prices_table['currency_type'], DB_EQ, CURRENCY_TYPE_MAIN_STORE_CURRENCY); $query->WhereAnd(); $query->Where($orders_table['id'], DB_IN, "('" . implode("','", $this->orders_ids) . "')"); $query->addLeftJoin('order_prices', $orders_table['id'], DB_EQ, $order_prices_table['order_id']); $rows = $application->db->getDB_Result($query); $amount = 0.0; $fully_paid_amount = 0.0; $main_store_currency = modApiFunc("Localization", "getCurrencyCodeById", modApiFunc("Localization", "getMainStoreCurrency")); foreach ($rows as $order_info) { $order_main_currency = $order_info['currency_code']; $order_total = $order_info['order_total']; if ($order_main_currency != $main_store_currency) { $order_total = modApiFunc('Currency_Converter', 'convert', $order_total, $order_main_currency, $main_store_currency); } $amount += $order_total; if ($order_info['payment_status_id'] == ORDER_PAYMENT_STATUS_FULLY_PAID) { $fully_paid_amount += $order_total; } } $query = new DB_Select(); $query->addSelectTable('orders'); $query->addSelectField($query->fMax($orders_table['date']), 'max_date'); $query->addSelectField($query->fMin($orders_table['date']), 'min_date'); $query->Where($orders_table['id'], DB_IN, "('" . implode("','", $this->orders_ids) . "')"); $res = $application->db->getDB_Result($query); $this->orders_summary = array('amount' => $amount, 'max_date' => $res[0]['max_date'], 'min_date' => $res[0]['min_date'], 'fully_paid_amount' => $fully_paid_amount); }
public static function getActiveSkin() { global $application; $skins = array(); $tables = Configuration::getTables(); $columns = $tables['store_settings']['columns']; $query = new DB_Select('store_settings'); $query->addSelectField($columns["variable_value"], "variable_value"); $query->WhereValue($columns['name'], DB_EQ, STOREFRONT_ACTIVE_SKIN); $skins = $application->db->getDB_Result($query); return $skins[0]['variable_value']; }
/** * Gets information about Tax Classes. */ function getProductTaxClassInfo($ptc_id) { global $application; $MessageResources =& $application->getInstance('MessageResources'); $tables = $this->getTables(); $ptc = $tables['product_tax_classes']['columns']; $query = new DB_Select(); $query->addSelectField($ptc['id'], 'id'); $query->addSelectField($ptc['name'], 'value'); $query->WhereValue($ptc['id'], DB_EQ, $ptc_id); $result = $application->db->getDB_Result($query); return sizeof($result) == 1 ? $result[0] : array('id' => '0', 'value' => $MessageResources->getMessage("PRODUCT_TAX_CLASS_ANY_LABEL")); }
function __getMaxFPSortOrderForCategory($category_id) { global $application; $tables = $this->getTables(); $fp_table = $tables['fp_links']['columns']; $query = new DB_Select(); $query->addSelectTable('fp_links'); $query->addSelectField($query->fMax($fp_table['sort_order']), 'max_so'); $query->WhereValue($fp_table['category_id'], DB_EQ, $category_id); $res = $application->db->getDB_Result($query); if (count($res) == 1) { return $res[0]['max_so']; } else { return 0; } }
function getOrderGCs($order_id = NULL, $gc_code = NULL) { global $application; $tables = $this->getTables(); $tr = $tables['order_gc']['columns']; $result_array = array(); $query = new DB_Select(); $query->addSelectField($tr["order_id"], "order_id"); $query->addSelectField($tr["gc_id"], "gc_id"); $query->addSelectField($tr["gc_code"], "gc_code"); if ($order_id !== NULL) { #$query->WhereAnd(); $query->WhereValue($tr["order_id"], DB_EQ, $order_id); } if ($gc_code !== NULL) { if ($order_id !== NULL) { $query->WhereAND(); } $query->WhereValue($tr["gc_code"], DB_EQ, $gc_code); } $result_rows = $application->db->getDB_Result($query); return $result_rows; }
function getTaxFormulaViewFull($tax_rate_id, $specific_rate = "") { if (!$tax_rate_id || $tax_rate_id == 0) { return ""; } global $application; $MessageResources =& $application->getInstance('MessageResources'); $tables = $this->getTables(); $tr = $tables['tax_rates']['columns']; $tn = $tables['tax_names']['columns']; $query = new DB_Select(); $query->addSelectField($tr['rate'], 'Rate'); $query->addSelectField($tr['formula'], 'Formula'); $query->addSelectField($tr['applicable'], 'Applicable'); $query->addLeftJoin('tax_names', $tn['id'], DB_EQ, $tr['tn_id']); $query->setMultiLangAlias('_name', 'tax_names', $tn['name'], $tn['id'], 'Taxes'); $query->addSelectField($query->getMultiLangAlias('_name'), 'TaxName'); $query->WhereValue($tr['id'], DB_EQ, $tax_rate_id); $result = $application->db->getDB_Result($query); if (sizeof($result) == 0) { return ""; } $result = $result[0]; if ($specific_rate != "") { $result['Rate'] = "[{$specific_rate}]"; } if ($result["Applicable"] == "false") { return prepareHTMLDisplay($result['TaxName']) . " = " . $MessageResources->getMessage('TAX_RATE_NOT_APPLICABLE_LABEL'); } $replace = array(); foreach ($this->getTaxNamesList() as $taxNameInfo) { $replace['{t_' . $taxNameInfo['Id'] . '}'] = prepareHTMLDisplay($taxNameInfo['Name']); } foreach ($this->getTaxCostsList() as $cost) { $replace['{p_' . $cost['id'] . '}'] = $MessageResources->getMessage($cost['name']); } preg_match_all("/([0-9]+\\.?[0-9]+)/", $result['Formula'], $numbers); for ($j = 0; $j < sizeof($numbers[0]); $j++) { $replace[$numbers[0][$j]] = modApiFunc("Localization", "num_format", $numbers[0][$j]); } $result['Formula'] = strtr($result['Formula'], $replace); return prepareHTMLDisplay($result['TaxName']) . " = " . $result['Rate'] . "% * (" . $result['Formula'] . ")"; }
function getProductAttributeId($view_tag_name, $default_value = null) { global $application; if (!is_object($application)) { return $default_value; } $attr_ids_cache = $application->getAttrIdsCache(); $attr_id = $attr_ids_cache->read($view_tag_name); if ($attr_id == null) { if ($application->db->DB_isTableExists($application->getAppIni('DB_TABLE_PREFIX') . "attributes") != null) { $s = new DB_Select(); $s->addSelectTable("attributes"); $s->addSelectField('attribute_id', 'attribute_id'); $s->WhereValue('attribute_view_tag', DB_EQ, $view_tag_name); $m = new DB_MySQL(); $m->PrepareSQL($s); $result = $m->getDB_Result($s); $attr_id = !empty($result) ? $result[0]['attribute_id'] : $default_value; } else { $attr_id = $default_value; } $attr_ids_cache->write($view_tag_name, $attr_id); } return $attr_id; }
function __getMaxInventorySortOrder($parent_entity, $entity_id) { global $application; $tables = $this->getTables(); $ex_table = $tables['po_inventory']['columns']; $query = new DB_Select(); $query->addSelectField($query->fMax($ex_table['sort_order']), 'max_sort_order'); $query->WhereValue($ex_table['parent_entity'], DB_EQ, $parent_entity); $query->WhereAND(); $query->WhereValue($ex_table['entity_id'], DB_EQ, $entity_id); $res = $application->db->getDB_Result($query); return $res[0]['max_sort_order']; }
/** * * * @param * @return */ function decrypt($name, $encrypted_string) { if (!$name && !$encrypted_string) { return $encrypted_string; } global $application; $session_id = session_id(); $tables = $this->getTables(); $table = 'crypto_keys'; $k = $tables[$table]['columns']; $query = new DB_Select(); $query->addSelectField($k["key"], "crypto_key"); $query->WhereValue($k["id"], DB_EQ, $session_id); $query->WhereAnd(); $query->WhereValue($k["name"], DB_EQ, $name); $result = $application->db->getDB_Result($query); if (isset($result[0]['crypto_key']) && $result[0]['crypto_key']) { $key = $result[0]['crypto_key']; $query = new DB_Delete($table); $query->WhereValue($k["id"], DB_EQ, $session_id); $query->WhereAnd(); $query->WhereValue($k["name"], DB_EQ, $name); $application->db->getDB_Result($query); $blowfish = new Crypt_Blowfish($key); $blowfish->setKey($key); $string = $blowfish->decrypt($encrypted_string); } else { return ""; } return $string; }
function initQuery($params) { $key = $params['key']; $otables = Customer_Account::getTables(); $atable = 'ca_person_info_attrs'; $gtable = 'ca_attrs_to_groups'; $dtable = 'ca_person_info_data'; $stables = Subscriptions::getTables(); $stable = 'subscription_temp'; $this->setModifiers(DB_IGNORE); $this->setInsertFields(array($stables[$stable]['columns']['action_key'])); $this->setInsertFields(array($stables[$stable]['columns']['email'])); $squery = new DB_Select($dtable); $squery->addSelectField(DBQuery::quoteValue($key)); $squery->addSelectField(DBQuery::fLower($otables[$dtable]['columns']['data_value'])); $squery->addInnerJoin($gtable, $otables[$dtable]['columns']['ag_id'], DB_EQ, $otables[$gtable]['columns']['ag_id']); $squery->addInnerJoin($atable, $otables[$gtable]['columns']['attr_id'], DB_EQ, $otables[$atable]['columns']['attr_id']); $squery->WhereValue($otables[$atable]['columns']['attr_name'], DB_EQ, 'Email'); $this->setSelectQuery($squery); unset($squery); }
function getCFldValues() { global $application; $values = ""; if ($this->mode == "add") { $values = ""; if (isset($this->field_data['postdata']['customFieldValues'])) { $values = $this->field_data['postdata']['customFieldValues']; } } else { $itid = $this->field_data[0]['input_type_id']; $tables = modAPIFunc("Catalog", "getTables"); $t_input_type_values = $tables['input_type_values']['columns']; $query = new DB_Select(); $query->setMultiLangAlias('_ml_value', 'input_type_values', $t_input_type_values['value'], $t_input_type_values['id'], 'Catalog'); $query->addSelectField($query->getMultiLangAlias('_ml_value'), 'value'); $query->WhereValue($t_input_type_values['it_id'], DB_EQ, $itid); $query->SelectOrder($t_input_type_values['id'], 'ASC'); $result = $application->db->getDB_Result($query); foreach ($result as $r) { $values .= modApiFunc('Catalog', 'getInputTypeActualValue', $r['value']) . "\n"; } } return "<textarea class=\"form-control\"" . $this->HtmlForm->genInputTextAreaField(20, 'customFieldValues', 5) . " id='customFieldValues' disabled=disabled>" . $values . "</textarea>"; }
/** * . PORTION_MAX_EXPORT_TIME . */ function sendMessagesPortion() { global $application; loadCoreFile('ascHtmlMimeMail.php'); $mailer = new ascHtmlMimeMail(); $from = $this->_currentMessage['letter_from_name'] . ' <' . $this->_currentMessage['letter_from_email'] . '>'; $mailer->setFrom($from); $mailer->setSubject($this->_currentMessage['letter_subject']); $html = "<html><head><title>{$this->_currentMessage['letter_subject']}</title></head><body>{$this->_currentMessage['letter_html']}</body></html>"; $mailer->setHtml($html); $start_time = $this->microtime_float(); $sent_count = 0; // // $max_to_send // $table = 'newsletter_temp'; $tables = $this->getTables(); // PORTION_MAX_MESSAGES_NUM , (_sentCountTotal + 1) // , PORTION_MAX_MESSAGES_NUM $query = new DB_Select(); $query->addSelectTable($table); $query->addSelectField($tables[$table]['columns']['recipient_value']); $query->addWhereOpenSection(); $query->WhereValue($tables[$table]['columns']['recipient_num'], DB_GTE, $this->_sentCountTotal + 1); $query->WhereAND(); $query->WhereValue($tables[$table]['columns']['recipient_num'], DB_LTE, $this->_sentCountTotal + PORTION_MAX_MESSAGES_NUM); $query->addWhereCloseSection(); $res = $application->db->getDB_Result($query); $addr_num = count($res); while ($this->microtime_float() - $start_time < PORTION_MAX_EXPORT_TIME && $sent_count < $addr_num) { // // // $mailer->send(array($res[$sent_count]['recipient_value'])); $sent_count++; // : /*debug*/ //usleep(200000); } $this->_sentCountTotal += $sent_count; $sending_status = 'PROCESSING'; if ($this->_sentCountTotal >= $this->_totalRecipients) { $this->_sentCountTotal = $this->_totalRecipients; // // // $table = 'newsletter_temp'; $tables = $this->getTables(); $query = new DB_Delete($table); $application->db->PrepareSQL($query); $application->db->DB_Exec(); $this->updateMessage($this->_currentMessage['letter_id'], array('letter_sent_date' => date('Y-m-d G:i:s'))); $sending_status = 'COMPLETED'; } return array('errors' => '', 'warnings' => '', 'sent_total' => $this->_sentCountTotal, 'sending_status' => $sending_status); }
function __getMaxSortOrderOfProductImages($product_id) { global $application; $tables = $this->getTables(); $imgs_table = $tables['pi_images']['columns']; $query = new DB_Select(); $query->addSelectField($query->fMax($imgs_table['sort_order']), 'max_sort_order'); $query->WhereValue($imgs_table['product_id'], DB_EQ, $product_id); $res = $application->db->getDB_Result($query); return $res[0]['max_sort_order']; }
/** * Returns Module's version if the module with the specified name is installed. */ function getModuleVersion($moduleName) { global $application; $tables = $this->getTables(); $module_tbl = 'module'; $module_columns = $tables[$module_tbl]['columns']; if (!DB_MySQL::DB_isTableExists($application->getAppIni('DB_TABLE_PREFIX') . $module_tbl)) { // the table 'module' doesn't exist, so update should not be performed return '0.0.0'; } static $updated_modules = null; if ($updated_modules == null) { $db_select = new DB_Select(); $db_select->addSelectTable($module_tbl); $db_select->addSelectField($module_columns['version'], 'version'); $db_select->WhereValue($module_columns['name'], DB_EQ, $moduleName); $result = $application->db->getDB_Result($db_select); $updated_modules = array(); foreach ($result as $resultItem) { $resultversion[] = $resultItem['version']; } } if (!empty($resultversion)) { return $resultversion[0]; } else { return '0.0.0'; } }
/** * Gets detailed user info. * * @ * @param * @return */ function getUserInfo($uid) { global $application; $tables = $this->getTables(); $a = $tables["admin"]["columns"]; $query = new DB_Select(); $query->addSelectField($a['id'], 'id'); $query->addSelectField($a['firstname'], 'firstname'); $query->addSelectField($a['lastname'], 'lastname'); $query->addSelectField($a['email'], 'email'); $query->addSelectField($a['lognum'], 'lognum'); $query->addSelectField($a['logdate'], 'logdate'); $query->addSelectField($a['created'], 'created'); $query->addSelectField($a['modified'], 'modified'); $query->addSelectField($a['options'], 'options'); $query->WhereValue($a['id'], DB_EQ, $uid); $user_info = $application->db->getDB_Result($query); return @$user_info[0]; }
function __getNotificationNameById($n_id) { global $application; $tables = $this->getTables(); $actions_table = $tables['notifications']['columns']; $query = new DB_Select(); $query->addSelectField($actions_table['name'], 'notification_name'); $query->addSelectTable('notifications'); $query->WhereValue($actions_table['id'], DB_EQ, $n_id); $res = $application->db->getDB_Result($query); return $res[0]['notification_name']; }
/** * Returnts the full person custom attribute record (person_attributes and person_info_variants_to_attributes) * * @author Andrei V. Zhuravlev * @param $variantId integer variant id * @param $attributeId integer attribute id */ function getPersonCustomAttributeData($attributeId) { global $application; $tables = $this->getTables(); $piva = $tables['person_info_variants_to_attributes']['columns']; $pa = $tables['person_attributes']['columns']; $query = new DB_Select(); foreach ($piva as $k => $v) { if ($k != 'name' && $k != 'descr') { $query->addSelectField($v); } } $query->setMultiLangAlias('_ml_name', 'person_info_variants_to_attributes', $piva['name'], $piva['id'], 'Checkout'); $query->addSelectField($query->getMultiLangAlias('_ml_name'), 'person_attribute_visible_name'); $query->setMultiLangAlias('_ml_descr', 'person_info_variants_to_attributes', $piva['descr'], $piva['id'], 'Checkout'); $query->addSelectField($query->getMultiLangAlias('_ml_descr'), 'person_attribute_description'); foreach ($pa as $v) { $query->addSelectField($v); } $query->WhereField($piva['attribute_id'], DB_EQ, $pa['id']); $query->WhereAnd(); $query->WhereValue($piva['attribute_id'], DB_EQ, $attributeId); $query->WhereAnd(); $query->WhereValue($pa['is_custom'], DB_EQ, "1"); $result = $application->db->getDB_Result($query); return $result; }
/** * @param int $category_id - ID * @param array $period = ('begin' => timestamp, 'end' => timestamp) - * * @param int $limit - ( * , STAT_NO_LIMIT) * @param int $what_category = STAT_CATEGORY_THIS_ONLY || * STAT_CATEGORY_RECURSIVE - * * @param int $what_products = STAT_PRODUCTS_ALL || * STAT_PRODUCTS_EXISTS_ONLY - , * */ function getProductsSellingStat($category_id, $period, $limit = STAT_NO_LIMIT, $what_category = STAT_CATEGORY_THIS_ONLY, $what_products = STAT_PRODUCTS_EXISTS_ONLY) { global $application; $tables = $this->getTables(); $ps_table = $tables['stat_products_sold']['columns']; $categories_ids = array(); if ($what_category == STAT_CATEGORY_RECURSIVE) { $categories = modApiFunc('Catalog', 'getSubcategoriesFullListWithParent', $category_id, false, false); foreach ($categories as $cat_info) { $categories_ids[] = $cat_info['id']; } } else { $categories_ids[] = $category_id; } $query = new DB_Select(); $query->addSelectField($ps_table['product_id'], 'product_id'); $query->addSelectField($query->fSum($ps_table['quantity']), 'sum_quantity'); $query->addSelectTable('stat_products_sold'); $query->WhereValue($ps_table['categories_ids'], DB_REGEXP, '[[.vertical-line.]]' . implode('|', $categories_ids) . '[[.vertical-line.]]'); $query->WhereAND(); $query->Where($ps_table['time'], DB_GTE, $period['begin']); $query->WhereAND(); $query->Where($ps_table['time'], DB_LTE, $period['end']); if ($what_products == STAT_PRODUCTS_EXISTS_ONLY) { $catalog_tables = modApiStaticFunc('Catalog', 'getTables'); $query->addSelectTable('products'); $query->WhereAND(); $query->WhereField($ps_table['product_id'], DB_EQ, $catalog_tables['products']['columns']['id']); } $query->SelectGroup('product_id'); $query->SelectOrder('sum_quantity', 'DESC'); if ($limit != STAT_NO_LIMIT) { $query->SelectLimit(0, $limit); } return $application->db->getDB_Result($query); }