function &amGetAttributeManagerInstance($get) { if (!is_numeric($get['products_id']) || AM_ATOMIC_PRODUCT_UPDATES) { // first time visiting the page - delete the session var and start again if ('new_product' == $get[AM_PAGE_ACTION_NAME] && !tep_not_null($get[AM_ACTION_GET_VARIABLE])) { amSessionUnregister(AM_SESSION_VAR_NAME); } amSessionRegister(AM_SESSION_VAR_NAME, array()); $attributeManager = new attributeManagerAtomic(amGetSesssionVariable(AM_SESSION_VAR_NAME)); } else { $attributeManager = new attributeManagerInstant($_GET['products_id']); } return $attributeManager; }
/** * Sets Template order * @param $get $_GET (optional) * @access public * @author Tomasz Iwanow aka TomaszBG - microvision@gmail.com * @return void */ function setTemplateOrder($get = array()) { if (count($get) > 0) { if (isset($get['templateOrder'])) { amSessionRegister(AM_SESSION_CURRENT_TEMPLATE_ORDER); amSetSessionVariable(AM_SESSION_CURRENT_TEMPLATE_ORDER, $get['templateOrder']); $this->strTemplateOrder = $get['templateOrder']; } } else { $templateOrder = amGetSesssionVariable(AM_SESSION_CURRENT_TEMPLATE_ORDER); if (false !== $templateOrder) { $this->strTemplateOrder = $templateOrder; } else { $this->strTemplateOrder = AM_DEFAULT_TEMPLATE_ORDER; } } }
/** * Sets the global session variable * @static authorise() * @access public * @author Sam West aka Nimmit - osc@kangaroopartners.com * @param $sessionVar string session variable name * @return void */ function authorise($sessionVar) { amSessionRegister($sessionVar); $GLOBALS[$sessionVar] = stopDirectAccess::makeSessionId(); }
function installMoreProductWeight() { if ($this->getValue('AM_USE_MPW') && !amSessionIsRegistered($this->getValue('AM_SESSION_MORE_PRODUCT_WEIGHT_INSTALL_CHECKED'))) { // check that the fields are in the weights table $weightFields = amDB::query("SHOW COLUMNS FROM " . TABLE_PRODUCTS_ATTRIBUTES); while ($field = amDB::fetchArray($weightFields)) { $pa_fields[] = $field['Field']; } $weightFields = amDB::query("SHOW COLUMNS FROM " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES); while ($field = amDB::fetchArray($weightFields)) { $opa_Fields[] = $field['Field']; } $weightFields = amDB::query("SHOW COLUMNS FROM " . $this->getValue('AM_TABLE_ATTRIBUTES_TO_TEMPLATES')); while ($field = amDB::fetchArray($weightFields)) { $tmpl_Fields[] = $field['Field']; } $p_Type = ''; $weightFields = amDB::query("SHOW COLUMNS FROM " . TABLE_PRODUCTS); while ($field = amDB::fetchArray($weightFields)) { if ($field['Field'] == 'products_weight') { $p_Type = $field['Type']; break; } } // if not add them if (!in_array('weight_prefix', $pa_fields)) { amDB::query("ALTER TABLE " . TABLE_PRODUCTS_ATTRIBUTES . " ADD COLUMN `weight_prefix` CHAR (1) NOT NULL"); } if (!in_array('attributes_stock', $pa_fields)) { amDB::query("ALTER TABLE " . TABLE_PRODUCTS_ATTRIBUTES . " ADD COLUMN `attributes_stock` int(5) DEFAULT 0"); } if (!in_array('options_values_weight', $pa_fields)) { amDB::query("ALTER TABLE " . TABLE_PRODUCTS_ATTRIBUTES . " ADD COLUMN `options_values_weight` DECIMAL (6,3) DEFAULT '0.000' NOT NULL"); } if (!in_array('weight_prefix', $opa_Fields)) { amDB::query("ALTER TABLE " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " ADD COLUMN `weight_prefix` CHAR (1) NOT NULL"); } if (!in_array('options_values_weight', $opa_Fields)) { amDB::query("ALTER TABLE " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " ADD COLUMN `options_values_weight` DECIMAL (6,3) DEFAULT '0.000' NOT NULL"); } if (!in_array('attributes_stock', $tmpl_Fields) && $this->getValue('AM_USE_SORT_ORDER')) { amDB::query("ALTER TABLE " . $this->getValue('AM_TABLE_ATTRIBUTES_TO_TEMPLATES') . " ADD COLUMN `attributes_stock` int(5) DEFAULT 0"); } if (!in_array('weight_prefix', $tmpl_Fields) && $this->getValue('AM_USE_SORT_ORDER')) { amDB::query("ALTER TABLE " . $this->getValue('AM_TABLE_ATTRIBUTES_TO_TEMPLATES') . " ADD COLUMN `weight_prefix` CHAR (1) NOT NULL default '+'"); } if (!in_array('options_values_weight', $tmpl_Fields) && $this->getValue('AM_USE_SORT_ORDER')) { amDB::query("ALTER TABLE " . $this->getValue('AM_TABLE_ATTRIBUTES_TO_TEMPLATES') . " ADD COLUMN `options_values_weight` DECIMAL (6,3) DEFAULT '0.000' NOT NULL"); } // change field size of product weight if ($p_Type != '' && $p_Type != strtoupper('DECIMAL(6,3)')) { amDB::query("ALTER TABLE " . TABLE_PRODUCTS . " CHANGE `products_weight` `products_weight` DECIMAL(6,3) DEFAULT '0.000' NOT NULL"); } // register the checked session so that this check is only done once per session amSessionRegister($this->getValue('AM_SESSION_MORE_PRODUCT_WEIGHT_INSTALL_CHECKED'), true); } }
/** * Sets the interface language * @param $get $_GET (optional) * @access public * @author Sam West aka Nimmit - osc@kangaroopartners.com * @return void */ function setInterfaceLanguage($get = array()) { // setting new interface language if (count($get) > 0) { if (is_numeric($get['language_id'])) { amSessionRegister(AM_SESSION_CURRENT_LANG_VAR_NAME); amSetSessionVariable(AM_SESSION_CURRENT_LANG_VAR_NAME, $get['language_id']); $this->intLanguageId = $get['language_id']; } } else { $langId = amGetSesssionVariable(AM_SESSION_CURRENT_LANG_VAR_NAME); if (false !== $langId) { $this->intLanguageId = $langId; } else { $this->intLanguageId = AM_DEFAULT_LANGUAGE_ID; } } }
function installSortOrder() { if ($this->getValue('AM_USE_SORT_ORDER') && !amSessionIsRegistered($this->getValue('AM_SESSION_SORT_ORDER_INSTALL_CHECKED'))) { // register the checked session so that this check is only done once per session amSessionRegister($this->getValue('AM_SESSION_SORT_ORDER_INSTALL_CHECKED'), true); // check that the fields are in the attributes table $attributeFields = amDB::query("SHOW COLUMNS FROM " . TABLE_PRODUCTS_ATTRIBUTES); while ($field = amDB::fetchArray($attributeFields)) { $fields[] = $field['Field']; } $oInstalled = in_array($this->getValue('AM_FIELD_OPTION_SORT_ORDER'), $fields); $ovInstalled = in_array($this->getValue('AM_FIELD_OPTION_VALUE_SORT_ORDER'), $fields); // if not add them if (!$oInstalled) { amDB::query("ALTER TABLE " . TABLE_PRODUCTS_ATTRIBUTES . " ADD COLUMN " . $this->getValue('AM_FIELD_OPTION_SORT_ORDER') . " INT UNSIGNED NOT NULL DEFAULT '0'"); } if (!$ovInstalled) { amDB::query("ALTER TABLE " . TABLE_PRODUCTS_ATTRIBUTES . " ADD COLUMN " . $this->getValue('AM_FIELD_OPTION_VALUE_SORT_ORDER') . " INT UNSIGNED NOT NULL DEFAULT '0'"); } // now reset all of the sort orders if (!$oInstalled || !$ovInstalled) { $allAttributes = amDB::getAll("select * from " . TABLE_PRODUCTS_ATTRIBUTES . " order by products_id, options_id, options_values_id"); $productId = $optionId = null; $oCount = $ovCount = 1; $updateValues = array(); if (is_array($allAttributes)) { foreach ($allAttributes as $attrib) { if ($productId != $attrib['products_id']) { $oCount = $ovCount = 0; } if ($optionId != $attrib['options_id']) { $oCount++; $ovCount = 0; } /** for dev only $updateValues[$attrib['products_attributes_id']]['prdoucts_id'] = $attrib['products_id']; $updateValues[$attrib['products_attributes_id']]['options_id'] = $attrib['options_id']; $updateValues[$attrib['products_attributes_id']]['options_values_id'] = $attrib['options_values_id']; **/ $updateValues[$attrib['products_attributes_id']]['option_sort'] = $oCount; $updateValues[$attrib['products_attributes_id']]['option_value_sort'] = ++$ovCount; $productId = $attrib['products_id']; $optionId = $attrib['options_id']; } foreach ($updateValues as $attributeId => $sorts) { amDB::query("update " . TABLE_PRODUCTS_ATTRIBUTES . " set " . $this->getValue('AM_FIELD_OPTION_SORT_ORDER') . " = '{$sorts['option_sort']}', " . $this->getValue('AM_FIELD_OPTION_VALUE_SORT_ORDER') . " = '{$sorts['option_value_sort']}' where products_attributes_id = '{$attributeId}' limit 1"); } } //echo '<pre style="text-align:left">'.print_r($updateValues,true); } } }