/**
  * renames the specified template
  * @param $get $_GET
  * @author Sam West aka Nimmit - osc@kangaroopartners.com
  * @return array renamed template
  */
 function renameTemplate($get)
 {
     $this->getAndPrepare('template_name', $get, $templateName);
     $this->getAndPrepare('template_id', $get, $templateId);
     if (strpos($templateName, ':')) {
         $templateNameBits = explode(':', $templateName);
         $templateName = $templateNameBits[1];
     }
     $data = array('template_name' => $templateName);
     amDB::perform(AM_TABLE_TEMPLATES, $data, 'update', "template_id = '{$templateId}'");
     return array('selectedTemplate' => $templateId);
 }
 /**
  * Updates the price and prefix in the products attribute table
  * @author Sam West aka Nimmit - osc@kangaroopartners.com
  * @param $get $_GET
  * @return void
  */
 function update($get)
 {
     $this->getAndPrepare('option_id', $get, $optionId);
     $this->getAndPrepare('option_value_id', $get, $optionValueId);
     $this->getAndPrepare('price', $get, $price);
     $this->getAndPrepare('prefix', $get, $prefix);
     $data = array('options_values_price' => $price, 'price_prefix' => $prefix);
     amDB::perform(TABLE_PRODUCTS_ATTRIBUTES, $data, 'update', "products_id='{$this->intPID}' and options_id='{$optionId}' and options_values_id='{$optionValueId}'");
 }
  
  

  
  
  Copyright © 2006 Kangaroo Partners
  http://kangaroopartners.com
  osc@kangaroopartners.com
*/
require_once 'attributeManager/classes/attributeManagerConfig.class.php';
require_once 'attributeManager/classes/amDB.class.php';
require_once 'attributeManager/classes/stopDirectAccess.class.php';
// Check the session var exists
if (is_array(${AM_SESSION_VAR_NAME}) && is_numeric($products_id)) {
    foreach (${AM_SESSION_VAR_NAME} as $newAttribute) {
        $newAttributeData = array('products_id' => $products_id, 'options_id' => amDB::input($newAttribute['options_id']), 'options_values_id' => amDB::input($newAttribute['options_values_id']), 'options_values_price' => amDB::input($newAttribute['options_values_price']), 'price_prefix' => amDB::input($newAttribute['price_prefix']));
        // insert it into the database
        amDB::perform(TABLE_PRODUCTS_ATTRIBUTES, $newAttributeData);
    }
    /**
     * Delete the temporary session var
     */
    amSessionUnregister(AM_SESSION_VAR_NAME);
    /**
     * remove the direct access authorization so that if the session is hijacked they wont be able
     * access the attributeManagerFile directly without first going to the product addition page.
     * If thats not secured then it doesn't really matter what this script does they have compleate access anyway im not at fault
     */
    stopDirectAccess::deAuthorise(AM_SESSION_VALID_INCLUDE);
}
 function updateSortedProductArray($newArray)
 {
     reset($newArray);
     while (list($key, $val) = each($newArray)) {
         if (!empty($val['products_attributes_id'])) {
             amDB::perform(TABLE_PRODUCTS_ATTRIBUTES, $val, 'update', 'products_attributes_id = ' . $val['products_attributes_id']);
         }
     }
 }