function delete($oid = null, $doReconciliation = true) { $k = $this->_tbl_key; if ($oid) { $this->{$k} = intval($oid); } $id = $this->{$k}; if ($return = parent::delete($oid)) { if ($id) { $query = "UPDATE #__citruscart_wishlistitems SET wishlist_id = '0' WHERE wishlist_id = '" . $id . "'"; $db = $this->getDBO(); $db->setQuery($query); $db->query(); } } return parent::check(); }
/** * Delete also the prices linked to this group */ function delete($oid = null) { $k = $this->_tbl_key; $default_user_group = Citruscart::getInstance()->get('default_user_group', '1'); if ($oid) { $key = $oid; } else { $key = $this->{$k}; } if ($key != $default_user_group) { $return = parent::delete($oid); if ($return) { // Delete user group relationships $model = JModelLegacy::getInstance('UserGroups', 'CitruscartModel'); $model->setState('filter_group', $this->{$k}); $links = $model->getList(); if ($links) { $table = JTable::getInstance('UserGroups', 'CitruscartTable'); foreach ($links as $link) { $table->delete($link->user_id); } } // Delete prices $model = JModelLegacy::getInstance('ProductPrices', 'CitruscartModel'); $model->setState('filter_user_group', $this->{$k}); $prices = $model->getList(); if ($prices) { $table = JTable::getInstance('ProductPrices', 'CitruscartTable'); foreach ($prices as $price) { $table->delete($price->user_id); } } } } else { $this->setError(JText::_('COM_CITRUSCART_COM_CITRUSCART_YOU_CANT_DELETE_THE_DEFAULT_USER_GROUP')); return false; } return $return; }
/** * Run function after deleteing */ function delete($oid = null, $doReconciliation = true) { $k = $this->_tbl_key; if ($oid) { $this->{$k} = intval($oid); } if ($doReconciliation) { if ($oid) { $row = JTable::getInstance('ProductAttributes', 'CitruscartTable'); $row->load($oid); $product_id = $row->product_id; } else { $product_id = $this->product_id; } } $db = $this->getDBO(); $db->setQuery('SET foreign_key_checks = 0;'); $db->query(); if ($return = parent::delete($oid)) { DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models'); $model = DSCModel::getInstance('ProductAttributeOptions', 'CitruscartModel'); $model->setState('filter_attribute', $this->{$k}); if ($items = $model->getList()) { $table = $model->getTable(); foreach ($items as $item) { if (!$table->delete($item->productattributeoption_id)) { $this->setError($table->getError()); } } } if ($doReconciliation) { Citruscart::load("CitruscartHelperProduct", 'helpers.product'); CitruscartHelperProduct::doProductQuantitiesReconciliation($product_id); } } $db->setQuery('SET foreign_key_checks = 1;'); $db->query(); return parent::check(); }
/** * * @param $oid * @return unknown_type */ function delete($oid = null, $doReconciliation = true) { $k = $this->_tbl_key; if ($oid) { $this->{$k} = intval($oid); } if ($doReconciliation) { if ($oid) { $row = JTable::getInstance('ProductComments', 'CitruscartTable'); $row->load($oid); $product_id = $row->product_id; } else { $product_id = $this->product_id; } } if (parent::delete($oid)) { DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models'); $model = DSCModel::getInstance('ProductCommentsHelpfulness', 'CitruscartModel'); $model->setState('filter_comment', $this->{$k}); if ($items = $model->getList()) { $table = $model->getTable(); foreach ($items as $item) { if (!$table->delete($item->productcommentshelpfulness_id)) { $this->setError($table->getError()); } } } if ($doReconciliation) { $product = JTable::getInstance('Products', 'CitruscartTable'); $product->load($product_id); $product->updateOverallRating(); if (!$product->save()) { $this->setError($product->getError()); } } } return parent::check(); }
/** * (non-PHPdoc) * @see Citruscart/admin/tables/CitruscartTable#delete($oid) */ function delete($oid = '') { $app = JFactory::getApplication(); $before = JFactory::getApplication()->triggerEvent('onBeforeDelete' . $this->get('_suffix'), array($this, $oid)); if (in_array(false, $before, true)) { return false; } if ($return = parent::delete($oid)) { // Delete also the values for that product in EAV tables $key = $this->_tbl_key; $id = $this->{$key}; // Get the custom fields for this entities Citruscart::load('CitruscartHelperEav', 'helpers.eav'); $eavs = CitruscartHelperEav::getAttributes($this->get('_suffix'), $id, false, '-1'); $error = false; $msg = ''; foreach ($eavs as $eav) { // get the value table $table = JTable::getInstance('EavValues', 'CitruscartTable'); // set the type based on the attribute $table->setType($eav->eavattribute_type); // load the value based on the entity id $keynames = array(); $keynames['eavattribute_id'] = $eav->eavattribute_id; $keynames['eaventity_id'] = $id; // If the value exists for this entity if ($table->load($keynames)) { // delete the value $result = $table->delete(); if (!$result) { $error = true; $msg = $table->getError(); } } } // log eav errors if ($error) { $this->setError(JText::_('COM_CITRUSCART_EAV_DELETE_FAILED') . $msg); return false; } JFactory::getApplication()->triggerEvent('onAfterDelete' . $this->get('_suffix'), array($this, $oid)); } return $return; }
public function delete($oid = null) { // Check the table activation status first if (!$this->active) { // Activate it with a default value $this->setType(''); } return parent::delete($oid); }
function delete($oid = null) { $k = $this->_tbl_key; if ($oid) { $this->{$k} = intval($oid); } if ($return = parent::delete($oid)) { $query = new CitruscartQuery(); $query->delete(); $query->from('#__citruscart_productdownloads'); $query->where('productfile_id = ' . $this->{$k}); $this->_db->setQuery((string) $query); $this->_db->query(); $query = new CitruscartQuery(); $query->delete(); $query->from('#__citruscart_productdownloadlogs'); $query->where('productfile_id = ' . $this->{$k}); $this->_db->setQuery((string) $query); $this->_db->query(); } return parent::check(); }
public function delete($oid = null) { $delete = array(); $k = $this->_tbl_key; if ($oid) { $this->{$k} = intval($oid); } // this should all be a transaction... // Delete all the orderitems, orderpayments, ordershipping, etc $delete['items'] = $this->deleteItems('items', $oid); $delete['payments'] = $this->deleteItems('payments', $oid); $delete['info'] = $this->deleteItems('info', $oid); $delete['shippings'] = $this->deleteItems('shippings', $oid); $delete['history'] = $this->deleteItems('history', $oid); $delete['taxclasses'] = $this->deleteItems('taxclasses', $oid); $delete['taxrates'] = $this->deleteItems('taxrates', $oid); $delete['coupons'] = $this->deleteItems('coupons', $oid); $delete['order'] = parent::delete($oid); $this->deleteResults = $delete; return parent::check(); }
/** * * @param $oid * @return unknown_type */ function delete($oid = null) { // if this record changed the user credits, then change them back $this->load($oid); if (!empty($this->credits_updated)) { // this record cause a credit change for the user // so deduct their value from the users total $userdata = JTable::getInstance('Userdata', 'CitruscartTable'); $userdata->load(array('user_id' => $this->user_id)); $userdata->user_id = $this->user_id; $userdata->credits_total = $userdata->credits_total - $this->credit_amount; if ($this->credit_withdrawable) { $userdata->credits_withdrawable_total = $userdata->credits_withdrawable_total - $this->credit_amount; } if (!$userdata->save()) { $this->setError($userdata->getError()); } } return parent::delete($oid); }