/** * Sets up "is_selected" in false, and also "is_active" in false in all * modules, except the passed in ones. It sets "is_selected" in true in all * passed modules,that exist in the database. It adds the modules, that don't * exist in the table. So that it should be specified in the inputted data * which data should be added as "active", and which of them shouldn't. * * Parameters have a complicated structure, because words Selected and Active * for modules depend: if a module is not Selected, it can't be Active. * And also because the status Selected/non-Selected is usually changed for * several modules at once. Administrator choses, which modules should be * Selected, which of them are non-Selected and then presses the button: * save the changes. */ function setSelectedModules($modules, $modulesType, $b_settings_table_is_empty = false) { global $application; //The list of modules,which should become selected. $selected_modules_ids = array(); foreach ($modules as $module_id => $module_settings) { $selected_modules_ids[] = "'" . $module_id . "'"; } $tables = Checkout::getTables(); $columns = $tables['checkout_pm_sm_settings']['columns']; $YES = "1"; $NO = "2"; //Sets up "is_selected" in false, and also "is_active" in false in all modules, except the passed in ones. if (count($selected_modules_ids) != 0) { $query = new DB_Update('checkout_pm_sm_settings'); $query->addUpdateExpression($columns['status_selected_value_id'], $NO); $query->addUpdateExpression($columns['status_active_value_id'], $NO); $query->WhereField($columns['module_id'], DB_NIN, "(" . implode(",", $selected_modules_ids) . ")"); $query->WhereAnd(); $query->WhereValue($columns['module_group'], DB_EQ, $modulesType); $application->db->getDB_Result($query); } //Set "is_selected" in true, and also sort_order in all passed modules that exist in the database. //It adds the modules, that don't exist in the table. So that it should be specified in the inputted data //which data should be added as "active", and which of them shouldn't. //First get the list of modules, entered to the database: //_print($selected_modules_ids);die("full stop"); if ($b_settings_table_is_empty === true) { $modules_already_in_db = array(); } else { $modules_already_in_db = $this->getSelectedModules($modulesType); } foreach ($modules as $module_id => $module_settings) { if (!array_key_exists($module_id, $modules_already_in_db)) { //The module doesn't exist in the database. //Add module settings to the database. // Checkout::getPaymentModuleInfo() , // , isActive() // , checkout_pm_sm_settings. $mm_info = Checkout::getInstalledModulesListData($modulesType, NULL, true); $m_name = ""; foreach ($mm_info as $key => $info) { if ($info->UUID == $module_settings['module_id']) { $m_name = $info->name; break; } } $db_insert = new DB_Insert('checkout_pm_sm_settings'); $db_insert->addInsertValue($module_settings['module_id'], $columns['module_id']); $db_insert->addInsertValue($m_name, $columns['module_class_name']); $db_insert->addInsertValue($module_settings['module_group'], $columns['module_group']); $db_insert->addInsertValue($NO, $columns['status_active_value_id']); $db_insert->addInsertValue($module_settings['b_is_selected'] === true ? $YES : $NO, $columns['status_selected_value_id']); $db_insert->addInsertValue($module_settings['sort_order'], $columns['sort_order']); $application->db->PrepareSQL($db_insert); //_print($modules);_print($module_settings);_print($application->db->QueryString);die; $application->db->DB_Exec(); Checkout::update_pm_sm_currency_settings($module_settings['module_id'], modApiStaticFunc($m_name, "getInitialCurrencySettings")); } else { //The module exists in the database. Update sort_order and is_selected. $query = new DB_Update('checkout_pm_sm_settings'); $query->addUpdateExpression($columns['status_selected_value_id'], $YES); $query->addUpdateExpression($columns['sort_order'], $module_settings['sort_order']); $query->WhereValue($columns['module_id'], DB_EQ, $module_id); $application->db->getDB_Result($query); } } }
function updateModuleSettings($uid, $key_name, $value) { global $application; $tables = TransactionTracking::getTables(); $columns = $tables['transaction_tracking_modules_settings']['columns']; $query = new DB_Update('transaction_tracking_modules_settings'); $query->addUpdateValue($columns["value"], $value); $query->WhereValue($columns["key_name"], DB_EQ, $key_name); $query->WhereAnd(); $query->WhereValue($columns["module_id"], DB_EQ, $uid); $result = $application->db->getDB_Result($query); }
/** * * * @param * @return */ function encrypt($name, $string) { if (!$name && !$string) { return $string; } global $application; $session_id = session_id(); $key = md5($session_id . $this->uuid()); $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']) { $query = new DB_Update($table); $query->addUpdateValue($k["key"], $key); $query->addUpdateValue($k['lifetime'], time() + 600); $query->WhereValue($k["id"], DB_EQ, $session_id); $query->WhereAnd(); $query->WhereValue($k["name"], DB_EQ, $name); $application->db->getDB_Result($query); } else { $query = new DB_Insert($table); $query->addInsertValue($session_id, $k['id']); $query->addInsertValue($name, $k['name']); $query->addInsertValue($key, $k['key']); $query->addInsertValue(time() + 600, $k['lifetime']); $application->db->getDB_Result($query); } $blowfish = new Crypt_Blowfish($key); $encrypted_string = $blowfish->encrypt($string); return $encrypted_string; }
/** * Saves the attribute sort in the variant to the DB. * * @author Oleg Vlasenko * @param array $attrSortOrderArray the array of attribute ids, the sequence * of which is defined by sort_order of attributes. * @param integer $variantId the Id of the attribute variant. * @return void */ function setAttributesSortOrder($attrSortOrderArray, $variantId) { global $application; $i = 1; foreach ($attrSortOrderArray as $attrId) { $tables = $this->getTables(); $columns = $tables['person_info_variants_to_attributes']['columns']; $query = new DB_Update('person_info_variants_to_attributes'); $query->addUpdateValue($columns['sort'], $i); $query->WhereValue($columns['variant_id'], DB_EQ, $variantId); $query->WhereAnd(); $query->WhereValue($columns['attribute_id'], DB_EQ, $attrId); $application->db->getDB_Result($query); $i++; } modApiFunc('EventsManager', 'throwEvent', 'CheckoutAttributesSortOrderUpdated', $attrSortOrderArray, $variantId); }
/** * Update notification info in the database. * *@param array $data - the array of features taken from the form * *@return */ function updateNotification($data) { global $application; $tables = $this->getTables(); $n = $tables['notifications']['columns']; $query = new DB_Update('notifications'); $query->addUpdateValue($n['na_id'], $data['Action']); $query->addMultiLangUpdateValue($n['name'], $data['Name'], $n['id'], '', 'Notifications'); $query->addMultiLangUpdateValue($n['subject'], $data['Subject'], $n['id'], '', 'Notifications'); $query->addMultiLangUpdateValue($n['body'], $data['Body'], $n['id'], '', 'Notifications'); if (key($data['SendFrom']) === 'EMAIL_ADMINISTRATOR') { $query->addUpdateValue($n['from_email_admin_id'], $data['SendFrom'][key($data['SendFrom'])]); $query->addUpdateValue($n['from_email_custom_address'], ""); } else { $query->addUpdateValue($n['from_email_admin_id'], DB_NULL); $query->addUpdateValue($n['from_email_custom_address'], $data['SendFrom'][key($data['SendFrom'])]); } $query->addUpdateValue($n['from_email_code'], key($data['SendFrom'])); $query->addUpdateValue($n['active'], $data['Active']); $query->WhereValue($n['id'], DB_EQ, $data['Id']); $application->db->getDB_Result($query); $nst = $tables['notification_send_to']['columns']; $query = new DB_Delete('notification_send_to'); $query->WhereValue($nst['n_id'], DB_EQ, $data['Id']); $application->db->getDB_Result($query); foreach ($data['SendTo'] as $email) { $query = new DB_Insert('notification_send_to'); $query->addInsertValue($data['Id'], $nst['n_id']); $query->addInsertValue($email[key($email)], $nst['email']); $query->addInsertValue(key($email), $nst['code']); $application->db->getDB_Result($query); } if ($data['OptionsValues']) { $ov2n = $tables['option_values_to_notification']['columns']; $query = new DB_Delete('option_values_to_notification'); $query->WhereValue($ov2n['n_id'], DB_EQ, $data['Id']); $application->db->getDB_Result($query); foreach ($data['OptionsValues'] as $key => $val) { $query = new DB_Insert('option_values_to_notification'); $query->addInsertValue($key, $ov2n['naov_id']); $query->addInsertValue($data['Id'], $ov2n['n_id']); $query->addInsertValue('true', $ov2n['value']); $application->db->getDB_Result($query); } } if ($data['BlockBodies']) { $nbb = $tables['notification_blocktag_bodies']['columns']; foreach ($data['BlockBodies'] as $block_id => $body) { $query = new DB_Update('notification_blocktag_bodies'); $query->addMultiLangUpdateValue($nbb['body'], $body, $nbb['id'], '', 'Notifications'); $query->WhereValue($nbb['nb_id'], DB_EQ, $block_id); $query->WhereAnd(); $query->WhereValue($nbb['n_id'], DB_EQ, $data['Id']); $application->db->getDB_Result($query); } } }