コード例 #1
0
ファイル: controller.php プロジェクト: annggeel/tienda
 /**
  * Changes the value of a boolean in the database
  * Expects the task to be in the format: {field}_{action}
  * where {field} = the name of the field in the database
  * and {action} is either switch/enable/disable
  *
  * @return unknown_type
  */
 function boolean()
 {
     $error = false;
     $this->messagetype = '';
     $this->message = '';
     $redirect = 'index.php?option=com_tienda&view=' . $this->get('suffix');
     $redirect = JRoute::_($redirect, false);
     $model = $this->getModel($this->get('suffix'));
     $row = $model->getTable();
     $cids = JRequest::getVar('cid', array(0), 'post', 'array');
     $task = JRequest::getVar('shippingTask');
     $id = JRequest::getInt('id');
     $vals = explode('.', $task);
     $field = $vals['0'];
     $action = $vals['1'];
     $database = JFactory::getDBO();
     $query = "SELECT `params` FROM `#__plugins` WHERE `id` = '{$id}'";
     $database->setQuery($query);
     $jparams = new DSCParameter($database->loadObject()->params);
     foreach (@$params_arr as $param => $val) {
         $jparams->set($param, $val);
     }
     $query = "UPDATE `#__plugins` SET `params`= '" . $jparams->toString() . "' WHERE `id`= '{$plg_id}'";
     $database->setQuery($query);
     switch (strtolower($action)) {
         case "switch":
             $switch = '1';
             break;
         case "disable":
             $enable = '0';
             $switch = '0';
             break;
         case "enable":
             $enable = '1';
             $switch = '0';
             break;
         default:
             $this->messagetype = 'notice';
             $this->message = JText::_('COM_TIENDA_INVALID_TASK');
             $this->setRedirect($redirect, $this->message, $this->messagetype);
             return;
             break;
     }
     if (!in_array($field, array_keys($row->getProperties()))) {
         $this->messagetype = 'notice';
         $this->message = JText::_('COM_TIENDA_INVALID_FIELD') . ": {$field}";
         $this->setRedirect($redirect, $this->message, $this->messagetype);
         return;
     }
     foreach (@$cids as $cid) {
         unset($row);
         $row = $model->getTable();
         $row->load($cid);
         switch ($switch) {
             case "1":
                 $row->{$field} = $row->{$field} ? '0' : '1';
                 break;
             case "0":
             default:
                 $row->{$field} = $enable;
                 break;
         }
         if (!$row->save()) {
             $this->message .= $row->getError();
             $this->messagetype = 'notice';
             $error = true;
         }
     }
     if ($error) {
         $this->message = JText::_('COM_TIENDA_ERROR') . ": " . $this->message;
     } else {
         $this->message = JText::_('COM_TIENDA_STATUS_CHANGED');
     }
     $this->setRedirect($redirect, $this->message, $this->messagetype);
 }
コード例 #2
0
ファイル: geozones.php プロジェクト: joomlacorner/citruscart
 /**
  * Method to add/remove the geozone to plugin parameter
  */
 function plugin_switch()
 {
     $app = JFactory::getApplication();
     $error = false;
     $this->messagetype = '';
     $this->message = '';
     $type = $app->input->get('type');
     Citruscart::load("CitruscartHelperPlugin", 'helpers.plugin');
     $suffix = CitruscartHelperPlugin::getSuffix($type);
     $id = $app->input->get('id', 0);
     $cids = $app->input->get('cid', array(0), 'request', 'array');
     $task = $app->input->getString('task');
     $vals = explode('_', $task);
     $field = $vals['0'];
     $action = $vals['1'];
     switch (strtolower($action)) {
         case "switch":
             $switch = '1';
             break;
         case "disable":
             $enable = '0';
             $switch = '0';
             break;
         case "enable":
             $enable = '1';
             $switch = '0';
             break;
         default:
             $this->messagetype = 'notice';
             $this->message = JText::_('COM_CITRUSCART_INVALID_TASK');
             $this->setRedirect($redirect, $this->message, $this->messagetype);
             return;
             break;
     }
     $model = $this->getModel($suffix);
     $keynames = array();
     foreach ($cids as $cid) {
         $row = $model->getTable();
         if (version_compare(JVERSION, '1.6.0', 'ge')) {
             // Joomla! 1.6+ code here
             $keynames["extension_id"] = $cid;
         } else {
             // Joomla! 1.5 code here
             $keynames["id"] = $cid;
         }
         $row->load($keynames);
         $params = new DSCParameter($row->params);
         $geozones = explode(',', $params->get('geozones'));
         if ($switch) {
             if (in_array($id, $geozones)) {
                 $geozones = explode(',', $params->get('geozones'));
                 $geozones = array_diff($geozones, array($id));
             } else {
                 $geozones[] = $id;
             }
         } else {
             switch ($enable) {
                 case "1":
                     $geozones[] = $id;
                     break;
                 case "0":
                 default:
                     $geozones = explode(',', $params->get('geozones'));
                     $geozones = array_diff($geozones, array($id));
                     break;
             }
         }
         $geozones = array_filter($geozones, 'strlen');
         //remove empty values
         $params->set('geozones', implode(',', array_unique($geozones)));
         //remove duplicate
         $row->params = trim($params->__toString());
         if (!$row->save()) {
             $this->message .= $cid . ': ' . $row->getError() . '<br/>';
             $this->messagetype = 'notice';
             $error = true;
         }
     }
     $model->clearCache();
     if ($error) {
         $this->message = JText::_('COM_CITRUSCART_ERROR') . ": " . $this->message;
     }
     $redirect = JRoute::_("index.php?option=com_citruscart&controller=geozones&task=selectplugins&type={$type}&tmpl=component&id=" . $id, false);
     $this->setRedirect($redirect, $this->message, $this->messagetype);
 }
コード例 #3
0
ファイル: googleproducts.php プロジェクト: annggeel/tienda
 /**
  * If enabled, insert or update product on google
  * @param $product
  */
 function onAfterStoreProducts($product)
 {
     // Check if it's enabled automatic syncing and the user has defined the account id for google
     if (!$this->params->get('auto_sync', '1') || !$this->account_id) {
         return false;
     }
     // Now let's get serious: was this product already saved on google?
     //$params = new DSCParameter(trim($product->product_params));
     $params = new DSCParameter(trim($product->product_params));
     $upgrade = $params->get('sent_to_google', '0');
     // Do an upgrade request
     if ($upgrade) {
         if ($this->updateProduct($product)) {
             return true;
         } else {
             // Something went wrong
             JError::raiseWarning('GOOGLE_UPDATE_ERR', JText::_('COM_TIENDA_ERROR_WHILE_UPDATING_ON_GOOGLE_PRODUCTS') . $this->getError());
             return false;
         }
     } else {
         if ($this->insertProduct($product)) {
             $params->set('sent_to_google', '1');
             $product->product_params = trim($params->toString());
             $product->save();
             return true;
         } else {
             // Something went wrong
             JError::raiseWarning('GOOGLE_INSERT_ERR', JText::_('COM_TIENDA_ERROR_WHILE_INSERTING_IN_GOOGLE_PRODUCTS') . $this->getError());
             return false;
         }
     }
 }
コード例 #4
0
ファイル: products.php プロジェクト: joomlacorner/citruscart
 /**
  * Verifies the fields in a submitted form.
  * Then adds the item to the users cart
  *
  * @return unknown_type
  */
 function addToCart()
 {
     $input = JFactory::getApplication()->input;
     JSession::checkToken() or jexit('Invalid Token');
     $product_id = $input->getInt('product_id');
     $product_qty = $input->getInt('product_qty');
     $filter_category = $input->getInt('filter_category');
     Citruscart::load("CitruscartHelperRoute", 'helpers.route');
     $router = new CitruscartHelperRoute();
     if (!($itemid = $router->product($product_id, $filter_category, true))) {
         $itemid = $router->category(1, true);
         if (!$itemid) {
             $itemid = $input->getInt('Itemid', 0);
         }
     }
     // set the default redirect URL
     $redirect = "index.php?option=com_citruscart&view=products&task=view&id={$product_id}&filter_category={$filter_category}&Itemid=" . $itemid;
     $redirect = JRoute::_($redirect, false);
     Citruscart::load('CitruscartHelperBase', 'helpers._base');
     $helper = CitruscartHelperBase::getInstance();
     if (!Citruscart::getInstance()->get('shop_enabled', '1')) {
         $this->messagetype = 'notice';
         $this->message = JText::_('COM_CITRUSCART_SHOP_DISABLED');
         $this->setRedirect($redirect, $this->message, $this->messagetype);
         return;
     }
     // convert elements to array that can be binded
     $values = $input->getArray($_POST);
     if (isset($values['elements'])) {
         $elements = json_decode(preg_replace('/[\\n\\r]+/', '\\n', $values['elements']));
         unset($values['elements']);
         // convert elements to array that can be binded
         $values = array_merge(CitruscartHelperBase::elementsToArray($elements), $values);
         $intpu->set($values, 'POST');
     }
     $files = $input->files->get('files');
     $attributes = array();
     foreach ($values as $key => $value) {
         if (substr($key, 0, 10) == 'attribute_') {
             $attributes[] = $value;
         }
     }
     sort($attributes);
     $attributes_csv = implode(',', $attributes);
     // Integrity checks on quantity being added
     if ($product_qty < 0) {
         $product_qty = '1';
     }
     // using a helper file to determine the product's information related to inventory
     $availableQuantity = Citruscart::getClass('CitruscartHelperProduct', 'helpers.product')->getAvailableQuantity($product_id, $attributes_csv);
     if ($availableQuantity->product_check_inventory && $product_qty > $availableQuantity->quantity) {
         $this->messagetype = 'notice';
         $this->message = JText::_(JText::sprintf("COM_CITRUSCART_NOT_AVAILABLE_QUANTITY", $availableQuantity->product_name, $product_qty));
         $this->setRedirect($redirect, $this->message, $this->messagetype);
         return;
     }
     // do the item's charges recur? does the cart already have a subscription in it?  if so, fail with notice
     $product = JTable::getInstance('Products', 'CitruscartTable');
     $product->load(array('product_id' => $product_id), true, false);
     // if product notforsale, fail
     if ($product->product_notforsale) {
         $this->messagetype = 'notice';
         $this->message = JText::_('COM_CITRUSCART_PRODUCT_NOT_FOR_SALE');
         $this->setRedirect($redirect, $this->message, $this->messagetype);
         return;
     }
     $user = JFactory::getUser();
     $cart_id = $user->id;
     $id_type = "user_id";
     if (empty($user->id)) {
         $session = JFactory::getSession();
         $cart_id = $session->getId();
         $id_type = "session";
     }
     Citruscart::load('CitruscartHelperCarts', 'helpers.carts');
     $carthelper = new CitruscartHelperCarts();
     $cart_recurs = $carthelper->hasRecurringItem($cart_id, $id_type);
     if ($product->product_recurs && $cart_recurs) {
         $this->messagetype = 'notice';
         $this->message = JText::_('COM_CITRUSCART_CART_ALREADY_RECURS');
         $this->setRedirect($redirect, $this->message, $this->messagetype);
         return;
     }
     if ($product->product_recurs) {
         $product_qty = '1';
     }
     // create cart object out of item properties
     $item = new JObject();
     $item->user_id = JFactory::getUser()->id;
     $item->product_id = (int) $product_id;
     $item->product_qty = (int) $product_qty;
     $item->product_attributes = $attributes_csv;
     $item->vendor_id = '0';
     // vendors only in enterprise version
     // if ther is another product_url, put it into the cartitem_params, to allow custom redirect
     if (array_key_exists('product_url', $values)) {
         $params = new DSCParameter(trim(@$item->cartitem_params));
         $params->set('product_url', $values['product_url']);
         $item->cartitem_params = trim($params->__toString());
     }
     // onAfterCreateItemForAddToCart: plugin can add values to the item before it is being validated /added
     // once the extra field(s) have been set, they will get automatically saved
     $dispatcher = JDispatcher::getInstance();
     $results = JFactory::getApplication()->triggerEvent("onAfterCreateItemForAddToCart", array($item, $values, $files));
     foreach ($results as $result) {
         foreach ($result as $key => $value) {
             $item->set($key, $value);
         }
     }
     // does the user/cart match all dependencies?
     $canAddToCart = $carthelper->canAddItem($item, $cart_id, $id_type);
     if (!$canAddToCart) {
         $this->messagetype = 'notice';
         $this->message = JText::_('COM_CITRUSCART_CANNOT_ADD_ITEM_TO_CART') . " - " . $carthelper->getError();
         $this->setRedirect($redirect, $this->message, $this->messagetype);
         return;
     }
     // no matter what, fire this validation plugin event for plugins that extend the checkout workflow
     $results = array();
     $dispatcher = JDispatcher::getInstance();
     $results = JFactory::getApplication()->triggerEvent("onBeforeAddToCart", array(&$item, $values));
     for ($i = 0; $i < count($results); $i++) {
         $result = $results[$i];
         if (!empty($result->error)) {
             $this->messagetype = 'notice';
             $this->message = $result->message;
             $this->setRedirect($redirect, $this->message, $this->messagetype);
             return;
         }
     }
     // if here, add to cart
     // After login, session_id is changed by Joomla, so store this for reference
     $session = JFactory::getSession();
     $session->set('old_sessionid', $session->getId());
     // add the item to the cart
     Citruscart::load('CitruscartHelperCarts', 'helpers.carts');
     $cart_helper = new CitruscartHelperCarts();
     $cartitem = $cart_helper->addItem($item);
     // fire plugin event
     $dispatcher = JDispatcher::getInstance();
     JFactory::getApplication()->triggerEvent('onAfterAddToCart', array($cartitem, $values));
     // get the 'success' redirect url
     switch (Citruscart::getInstance()->get('addtocartaction', 'redirect')) {
         case "checkout":
             // if a base64_encoded url is present as return, use that as the return url
             // otherwise return == the product view page
             $returnUrl = base64_encode($redirect);
             if ($return_url = $input->getBase64('return')) {
                 $return_url = base64_decode($return_url);
                 if (JURI::isInternal($return_url)) {
                     $returnUrl = base64_encode($return_url);
                 }
             }
             // if a base64_encoded url is present as redirect, redirect there,
             // otherwise redirect to the checkout
             $itemid_checkout = $router->findItemid(array('view' => 'checkout'));
             $itemid_opc = $router->findItemid(array('view' => 'opc'));
             $checkout_view = "checkout";
             $itemid = null;
             if ($itemid_opc) {
                 $itemid = $itemid_opc;
                 $checkout_view = "opc";
             } elseif ($itemid_checkout) {
                 $itemid = $itemid_checkout;
             }
             if (!$itemid) {
                 $itemid = $input->getInt('Itemid', 0);
             }
             $redirect = JRoute::_("index.php?option=com_citruscart&view=" . $checkout_view . "&Itemid=" . $itemid, false);
             if ($redirect_url = $input->getBase64('redirect')) {
                 $redirect_url = base64_decode($redirect_url);
                 if (JURI::isInternal($redirect_url)) {
                     $redirect = $redirect_url;
                 }
             }
             if (strpos($redirect, '?') === false) {
                 $redirect .= "?return=" . $returnUrl;
             } else {
                 $redirect .= "&return=" . $returnUrl;
             }
             break;
         case "0":
         case "none":
             // redirects back to product page
             break;
         case "samepage":
             // redirects back to the page it came from (category, content, etc)
             // Take only the url without the base domain (index.php?option.....)
             if ($return_url = $input->getBase64('return')) {
                 $return_url = base64_decode($return_url);
                 $uri = JURI::getInstance();
                 $uri->parse($return_url);
                 $redirect = $uri->__toString(array('path', 'query', 'fragment'));
                 $redirect = JRoute::_($redirect, false);
             }
             break;
         case "lightbox":
         case "redirect":
         default:
             // if a base64_encoded url is present as return, use that as the return url
             // otherwise return == the product view page
             $returnUrl = base64_encode($redirect);
             if ($return_url = $input->getBase64('return')) {
                 $return_url = base64_decode($return_url);
                 if (JURI::isInternal($return_url)) {
                     $returnUrl = base64_encode($return_url);
                 }
             }
             // if a base64_encoded url is present as redirect, redirect there,
             // otherwise redirect to the cart
             $itemid = $router->findItemid(array('view' => 'carts'));
             if (!$itemid) {
                 $itemid = $input->getInt('Itemid', 0);
             }
             $redirect = JRoute::_("index.php?option=com_citruscart&view=carts&Itemid=" . $itemid, false);
             if ($redirect_url = $input->getBase64('redirect')) {
                 $redirect_url = base64_decode($redirect_url);
                 if (JURI::isInternal($redirect_url)) {
                     $redirect = $redirect_url;
                 }
             }
             //$returnUrl = base64_encode( $redirect );
             //$itemid = $router->findItemid( array('view'=>'checkout') );
             //$redirect = JRoute::_( "index.php?option=com_citruscart&view=carts&Itemid=".$itemid, false );
             if (strpos($redirect, '?') === false) {
                 $redirect .= "?return=" . $returnUrl;
             } else {
                 $redirect .= "&return=" . $returnUrl;
             }
             break;
     }
     $this->messagetype = 'message';
     $this->message = JText::_('COM_CITRUSCART_ITEM_ADDED_TO_YOUR_CART');
     $this->setRedirect($redirect, $this->message, $this->messagetype);
     return;
 }
コード例 #5
0
ファイル: tienda.php プロジェクト: annggeel/tienda
 function onBeforeK2Save(&$item, $isNew)
 {
     //Check if Tienda is installed
     if (!$this->_isInstalled()) {
         return;
     }
     //Get Tienda plugin variables
     $tiendaParams = new K2Parameter($item->plugins, '', $this->_name);
     //Get All plugins variables
     $plugins = new DSCParameter($item->plugins);
     //Handle assignment
     if (JRequest::getBool('tiendaAssign')) {
         $plugins->merge($tiendaParams);
         $item->plugins = $plugins->toString();
         return;
     }
     //Handle unassignment
     if (JRequest::getBool('tiendaUnassign')) {
         $plugins->set('tiendaproductID', NULL);
         $plugins->set('tiendaproductName', NULL);
         $plugins->set('tiendaproductSKU', NULL);
         $plugins->set('tiendaproductTax', NULL);
         $plugins->set('tiendaproductManufacturer', NULL);
         $plugins->set('tiendaproductWeight', NULL);
         $plugins->set('tiendaproductLength', NULL);
         $plugins->set('tiendaproductWidth', NULL);
         $plugins->set('tiendaproductHeight', NULL);
         $plugins->set('tiendaproductShipping', NULL);
         $plugins->set('tiendaproductEnabled', NULL);
         $item->plugins = $plugins->toString();
         return;
     }
     //Handle unassignment
     if (JRequest::getBool('tiendaRemove')) {
         JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
         $product = JTable::getInstance('Products', 'TiendaTable');
         $product->delete($plugins->get('tiendaproductID'));
         $plugins->set('tiendaproductID', NULL);
         $plugins->set('tiendaproductName', NULL);
         $plugins->set('tiendaproductSKU', NULL);
         $plugins->set('tiendaproductTax', NULL);
         $plugins->set('tiendaproductManufacturer', NULL);
         $plugins->set('tiendaproductWeight', NULL);
         $plugins->set('tiendaproductLength', NULL);
         $plugins->set('tiendaproductWidth', NULL);
         $plugins->set('tiendaproductHeight', NULL);
         $plugins->set('tiendaproductShipping', NULL);
         $plugins->set('tiendaproductEnabled', NULL);
         $item->plugins = $plugins->toString();
         return;
     }
     //Handle form
     if ($tiendaParams->get('productName', NULL) && $tiendaParams->get('productSKU', NULL)) {
         JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
         $product = JTable::getInstance('Products', 'TiendaTable');
         $product->product_id = $tiendaParams->get('productID', NULL);
         $product->product_name = $tiendaParams->get('productName', NULL);
         $product->product_sku = $tiendaParams->get('productSKU', NULL);
         $product->manufacturer_id = $tiendaParams->get('productManufacturer', 0);
         $product->tax_class_id = $tiendaParams->get('productTax');
         $product->product_weight = $tiendaParams->get('productWeight', NULL);
         $product->product_length = $tiendaParams->get('productLength', NULL);
         $product->product_width = $tiendaParams->get('productWidth', NULL);
         $product->product_height = $tiendaParams->get('productHeight', NULL);
         $product->product_ships = $tiendaParams->get('productShipping', 0);
         $product->product_enabled = $tiendaParams->get('productEnabled', 1);
         $product->save();
         $tiendaParams->set('tiendaproductID', $product->product_id);
         $price = $tiendaParams->get('productPrice', NULL);
         if ($price) {
             $price = JTable::getInstance('ProductPrices', 'TiendaTable');
             $price->product_id = $product->product_id;
             $price->product_price = $tiendaParams->get('productPrice', NULL);
             $price->save();
         }
         $plugins->merge($tiendaParams);
         $item->plugins = $plugins->toString();
     }
 }
コード例 #6
0
 function onAfterCreateItemForAddToCart($item, $values, $files)
 {
     if (empty($values["hasCustomFields"])) {
         return array();
     }
     //generate a new custom fields id
     $newCustomFieldsID = $this->getNewCustomFieldsID();
     if ($newCustomFieldsID == false) {
         JError::raiseNotice('onAfterCreateItemForAddToCart', JText::_('TIENDA_PRODUCT_CUSTOMFIELDS_AFTER_CREATE_ITEM_FAILED') . '(No max custom_fields_id retrieved)');
     }
     //get custom field values
     $params = new DSCParameter('');
     foreach ($values as $key => $value) {
         if (substr($key, 0, 13) == 'custom_field_') {
             $params->set($key, $value);
         }
     }
     //custom fields of type 'file': files being uploaded
     if (!empty($files)) {
         $user_id = JFactory::getUser()->id;
         jimport('joomla.filesystem.file');
         foreach ($files as $key => $file) {
             if (substr($key, 0, 13) == 'custom_field_') {
                 $destination_webfolder = Tienda::getUrl('cartitems_files') . $user_id . '/' . $newCustomFieldsID . '/';
                 $destination_folder = Tienda::getPath('cartitems_files') . DS . $user_id . DS . $newCustomFieldsID . DS;
                 if (!JFolder::exists($destination_folder)) {
                     JFolder::create($destination_folder);
                 }
                 $dest_file = $file['name'];
                 if (!JFile::upload($file['tmp_name'], $destination_folder . $dest_file)) {
                     JError::raiseNotice('onAfterCreateItemForAddToCart', JText::_('TIENDA_PRODUCT_CUSTOMFIELDS_AFTER_CREATE_ITEM_FAILED') . '(unable to upload)');
                 }
                 $params->set($key, $destination_webfolder . $dest_file);
             }
         }
     }
     return array('cartitem_customfields_id' => $newCustomFieldsID, 'cartitem_customfields' => trim($params->toString()));
 }
コード例 #7
0
ファイル: products.php プロジェクト: joomlacorner/citruscart
 /**
  *
  * A separate space for working through all the different integrations
  */
 function prepareParameters(&$row)
 {
     $app = JFactory::getApplication();
     // this row's product_params has already been set from the textarea's POST
     // so we need to add to it
     $params = new DSCParameter(trim($row->product_params));
     $params->set('amigos_commission_override', $app->input->get('amigos_commission_override'));
     $params->set('billets_ticket_limit_increase', $app->input->get('billets_ticket_limit_increase'));
     $params->set('billets_ticket_limit_exclusion', $app->input->get('billets_ticket_limit_exclusion'));
     $params->set('billets_hour_limit_increase', $app->input->get('billets_hour_limit_increase'));
     $params->set('billets_hour_limit_exclusion', $app->input->get('billets_hour_limit_exclusion'));
     $params->set('juga_group_csv_add', $app->input->get('juga_group_csv_add'));
     $params->set('juga_group_csv_remove', $app->input->get('juga_group_csv_remove'));
     $params->set('juga_group_csv_add_expiration', $app->input->get('juga_group_csv_add_expiration'));
     $params->set('juga_group_csv_remove_expiration', $app->input->get('juga_group_csv_remove_expiration'));
     $params->set('core_user_change_gid', $app->input->get('core_user_change_gid'));
     $params->set('core_user_new_gid', $app->input->get('core_user_new_gid'));
     $params->set('ambrasubs_type_id', $app->input->get('ambrasubs_type_id'));
     $params->set('hide_quantity_input', $app->input->get('param_hide_quantity_input'));
     $params->set('default_quantity', $app->input->get('param_default_quantity'));
     $params->set('hide_quantity_cart', $app->input->get('param_hide_quantity_cart'));
     $params->set('show_product_compare', $app->input->getInt('param_show_product_compare', 1));
     $row->product_params = trim($params->__toString());
     return $row;
 }
コード例 #8
0
ファイル: ambrasubs.php プロジェクト: annggeel/tienda
 /**
  * Event is triggered after product is saved in Tienda
  * and updates the AS subscription type's record
  * 
  * @param $product
  * @return unknown_type
  */
 function onAfterSaveProducts($product)
 {
     $model = JModel::getInstance('Products', 'TiendaModel');
     $model->setId($product->product_id);
     $product = $model->getItem();
     $ambrasubs_type_id = $product->product_parameters->get('ambrasubs_type_id');
     if (!empty($ambrasubs_type_id)) {
         $db = JFactory::getDBO();
         $db->setQuery("SELECT * FROM #__ambrasubs_types WHERE `id` = '{$ambrasubs_type_id}';");
         $type = $db->loadObject();
         $params = new DSCParameter(trim($type->params));
         $params->set('tienda_product_id', $product->product_id);
         $type_params = $db->getEscaped(trim($params->toString()));
         $db->setQuery("UPDATE #__ambrasubs_types SET `params` = '{$type_params}' WHERE `id` = '{$ambrasubs_type_id}';");
         $db->query();
     }
 }