Example #1
0
 function CitruscartTableUsers(&$db)
 {
     $tbl_key = 'id';
     $tbl_suffix = 'users';
     $this->set('_suffix', $tbl_suffix);
     parent::__construct("#__{$tbl_suffix}", $tbl_key, $db);
 }
 /**
  * Stores the object
  * @param object
  * @return boolean
  */
 function store($updateNulls = false)
 {
     $date = JFactory::getDate();
     $this->modified_date = $date->toSql();
     $store = parent::store($updateNulls);
     return $store;
 }
 function CitruscartTableZonerelations(&$db)
 {
     $tbl_key = 'zonerelation_id';
     $tbl_suffix = 'zonerelations';
     $this->set('_suffix', $tbl_suffix);
     $name = 'citruscart';
     parent::__construct("#__{$name}_{$tbl_suffix}", $tbl_key, $db);
 }
Example #4
0
 function CitruscartTableTaxclasses(&$db)
 {
     $tbl_key = 'tax_class_id';
     $tbl_suffix = 'taxclasses';
     $this->set('_suffix', $tbl_suffix);
     $name = 'citruscart';
     parent::__construct("#__{$name}_{$tbl_suffix}", $tbl_key, $db);
 }
Example #5
0
 function __construct(&$db)
 {
     $tbl_key = 'config_id';
     $tbl_suffix = 'config';
     $this->set('_suffix', $tbl_suffix);
     $name = "citruscart";
     parent::__construct("#__{$name}_{$tbl_suffix}", $tbl_key, $db);
 }
Example #6
0
 function CitruscartTableGeozonetypes(&$db)
 {
     $tbl_key = 'geozonetype_id';
     $tbl_suffix = 'geozonetypes';
     $this->set('_suffix', $tbl_suffix);
     $name = 'citruscart';
     parent::__construct("#__{$name}_{$tbl_suffix}", $tbl_key, $db);
 }
 function CitruscartTableShippingMethods(&$db)
 {
     $tbl_key = 'shipping_method_id';
     $tbl_suffix = 'shippingmethods';
     $this->set('_suffix', $tbl_suffix);
     $name = 'citruscart';
     parent::__construct("#__{$name}_{$tbl_suffix}", $tbl_key, $db);
 }
 function CitruscartTableOrderTaxRates(&$db)
 {
     $tbl_key = 'ordertaxrate_id';
     $tbl_suffix = 'ordertaxrates';
     $this->set('_suffix', $tbl_suffix);
     $name = 'citruscart';
     parent::__construct("#__{$name}_{$tbl_suffix}", $tbl_key, $db);
 }
 function CitruscartTableProductQuantities(&$db)
 {
     $tbl_key = 'productquantity_id';
     $tbl_suffix = 'productquantities';
     $this->set('_suffix', $tbl_suffix);
     $name = 'citruscart';
     parent::__construct("#__{$name}_{$tbl_suffix}", $tbl_key, $db);
 }
 function CitruscartTableOrderShippings(&$db)
 {
     $tbl_key = 'ordershipping_id';
     $tbl_suffix = 'ordershippings';
     $this->set('_suffix', $tbl_suffix);
     $name = 'citruscart';
     parent::__construct("#__{$name}_{$tbl_suffix}", $tbl_key, $db);
 }
Example #11
0
 function CitruscartTableVendors(&$db)
 {
     $tbl_key = 'vendor_id';
     $tbl_suffix = 'vendors';
     $this->set('_suffix', $tbl_suffix);
     $name = 'citruscart';
     parent::__construct("#__{$name}_{$tbl_suffix}", $tbl_key, $db);
 }
 function CitruscartTableProductCommentsHelpfulness(&$db)
 {
     $tbl_key = 'productcommentshelpfulness_id';
     $tbl_suffix = 'productcommentshelpfulness';
     $this->set('_suffix', $tbl_suffix);
     $name = "citruscart";
     parent::__construct("#__{$name}_{$tbl_suffix}", $tbl_key, $db);
 }
Example #13
0
 function __construct(&$db)
 {
     $tbl_key = 'eavattribute_id';
     $tbl_suffix = 'eavattributes';
     $this->set('_suffix', $tbl_suffix);
     $name = 'citruscart';
     parent::__construct("#__{$name}_{$tbl_suffix}", $tbl_key, $db);
 }
 function CitruscartTableProductDownloadLogs(&$db)
 {
     $tbl_key = 'productdownloadlog_id';
     $tbl_suffix = 'productdownloadlogs';
     $this->set('_suffix', $tbl_suffix);
     $name = 'citruscart';
     parent::__construct("#__{$name}_{$tbl_suffix}", $tbl_key, $db);
 }
 function CitruscartTableReviewHelpfulness(&$db)
 {
     $tbl_key = 'helpfulness_id';
     $tbl_suffix = 'reviewhelpfulness';
     $this->set('_suffix', $tbl_suffix);
     $name = "citruscart";
     parent::__construct("#__{$name}_{$tbl_suffix}", $tbl_key, $db);
 }
Example #16
0
 function CitruscartTablePosRequests(&$db)
 {
     $tbl_key = 'pos_id';
     $tbl_suffix = 'posrequests';
     $this->set('_suffix', $tbl_suffix);
     $name = 'citruscart';
     parent::__construct("#__{$name}_{$tbl_suffix}", $tbl_key, $db);
 }
Example #17
0
 function CitruscartTableUserInfo(&$db)
 {
     $tbl_key = 'user_info_id';
     $tbl_suffix = 'userinfo';
     $this->set('_suffix', $tbl_suffix);
     $name = 'citruscart';
     parent::__construct("#__{$name}_{$tbl_suffix}", $tbl_key, $db);
 }
 /**
  * 
  * @param unknown_type $updateNulls
  * @return unknown_type
  */
 function store($updateNulls = false)
 {
     if ($return = parent::store($updateNulls)) {
         if ($this->notify_customer == '1') {
             Citruscart::load("CitruscartHelperBase", 'helpers._base');
             $helper = CitruscartHelperBase::getInstance('Email');
             $model = Citruscart::getClass("CitruscartModelSubscriptions", "models.subscriptions");
             $model->setId($this->subscription_id);
             $subscription = $model->getItem();
             $helper->sendEmailNotices($subscription, 'subscription');
         }
     }
     return $return;
 }
Example #19
0
 function CitruscartTableTools(&$db)
 {
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         // Joomla! 1.6+ code here
         $tbl_key = 'extension_id';
         $tbl_suffix = 'extensions';
     } else {
         // Joomla! 1.5 code here
         $tbl_key = 'id';
         $tbl_suffix = 'plugins';
     }
     $this->set('_suffix', $tbl_suffix);
     parent::__construct("#__{$tbl_suffix}", $tbl_key, $db);
 }
Example #20
0
 function save($src = '', $orderingFilter = '', $ignore = '')
 {
     if ($return = parent::save($src, $orderingFilter, $ignore)) {
         if ($this->_increase_coupon_uses) {
             $coupon = JTable::getInstance('Coupons', 'CitruscartTable');
             $coupon->load(array('coupon_id' => $this->coupon_id));
             $coupon->coupon_uses = $coupon->coupon_uses + 1;
             if (!$coupon->save()) {
                 JFactory::getApplication()->enqueueMessage($coupon->getError());
             }
         }
     }
     return $return;
 }
Example #21
0
 /**
  * 
  * @param unknown_type $updateNulls
  * @return unknown_type
  */
 function store($updateNulls = false)
 {
     if ($return = parent::store($updateNulls)) {
         if ($this->notify_customer == '1') {
             Citruscart::load("CitruscartHelperBase", 'helpers._base');
             $helper = CitruscartHelperBase::getInstance('Email');
             $model = Citruscart::getClass("CitruscartModelOrders", "models.orders");
             $model->setId($this->order_id);
             // this isn't necessary because you specify the requested PK id as a getItem() argument
             $order = $model->getItem($this->order_id, true);
             $helper->sendEmailNotices($order, 'order');
         }
     }
     return $return;
 }
Example #22
0
 function save($src = '', $orderingFilter = '', $ignore = '')
 {
     $prev = clone $this;
     if (!empty($this->id)) {
         $prev->load($this->id);
     }
     if ($save = parent::save($src, $orderingFilter, $ignore)) {
         if ($prev->subscription_enabled && empty($this->subscription_enabled)) {
             // if it was previously enabled and now is disabled
             Citruscart::load('CitruscartHelperJuga', 'helpers.juga');
             $helper = new CitruscartHelperJuga();
             $helper->doExpiredSubscription($this);
         }
     }
     return $save;
 }
Example #23
0
 public function __construct($db = null, $tbl_name = null, $tbl_key = null)
 {
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         // Joomla! 1.6+ code here
         $tbl_key = 'extension_id';
         $tbl_suffix = 'extensions';
     } else {
         // Joomla! 1.5 code here
         $tbl_key = 'id';
         $tbl_suffix = 'plugins';
     }
     $this->set('_suffix', 'shipping');
     if (empty($db)) {
         $db = JFactory::getDBO();
     }
     parent::__construct("#__{$tbl_suffix}", $tbl_key, $db);
 }
Example #24
0
 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();
 }
Example #25
0
 /**
  * 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;
 }
Example #26
0
 /**
  * Checks the entry to maintain DB integrity
  * @return unknown_type
  */
 function check()
 {
     $config = Citruscart::getInstance();
     if (!$this->addresstype_id) {
         $this->addresstype_id = '1';
     }
     $address_type = $this->addresstype_id;
     if (empty($this->user_id)) {
         $this->user_id = JFactory::getUser()->id;
         if (empty($this->user_id)) {
             $this->setError(JText::_('COM_CITRUSCART_USER_REQUIRED'));
         }
     }
     Citruscart::load('CitruscartHelperAddresses', 'helpers.addresses');
     $elements = CitruscartHelperAddresses::getAddressElementsData($address_type);
     if (empty($this->address_name)) {
         $this->address_name = $this->address_1;
     }
     if (empty($this->address_name) && $elements['address_name'][1]) {
         $this->setError(JText::_("COM_CITRUSCART_PLEASE_INCLUDE_AN_ADDRESS_TITLE" . $address_type));
     }
     $address_checks = array(array('first_name', 'name', "COM_CITRUSCART_FIRST_NAME_REQUIRED"), array('middle_name', 'middle', "COM_CITRUSCART_MIDDLE_NAME_REQUIRED"), array('last_name', 'last', "COM_CITRUSCART_LAST_NAME_REQUIRED"), array('address_1', 'address1', "COM_CITRUSCART_AT_LEAST_ONE_ADDRESS_LINE_IS_REQUIRED"), array('address_2', 'address2', "COM_CITRUSCART_SECOND_ADDRESS_LINE_IS_REQUIRED"), array('company', 'company', "COM_CITRUSCART_COMPANY_REQUIRED"), array('tax_number', 'tax_number', "COM_CITRUSCART_COMPANY_TAX_NUMBER_REQUIRED"), array('city', 'city', "COM_CITRUSCART_CITY_REQUIRED"), array('postal_code', 'zip', "COM_CITRUSCART_POSTAL_CODE_REQUIRED"), array('phone_1', 'phone', "COM_CITRUSCART_PHONE_REQUIRED"));
     for ($i = 0, $c = count($address_checks); $i < $c; $i++) {
         $current = $address_checks[$i];
         if (empty($this->{$current}[0]) && $elements[$current[1]][1]) {
             $this->setError(JText::_($current[2]));
         }
     }
     if (empty($this->country_id)) {
         if ($elements['country'][1]) {
             $this->setError(JText::_('COM_CITRUSCART_COUNTRY_REQUIRED'));
         } else {
             $this->country_id = 9999;
         }
     }
     $countryA = explode(',', trim($config->get('ignored_countries', '83,188,190')));
     if (empty($this->zone_id) && !in_array($this->country_id, $countryA)) {
         if (isset($elements['zone'][1])) {
             $this->setError(JText::_('COM_CITRUSCART_ZONE_REQUIRED'));
         } else {
             $this->zone_id = 9999;
         }
     }
     return parent::check();
 }
Example #27
0
 /**
  * (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;
 }
 /**
  * (non-PHPdoc)
  * @see DSCTable::save()
  */
 function save($src = '', $orderingFilter = '', $ignore = '')
 {
     $isNew = false;
     if (empty($this->productcomment_id)) {
         $isNew = true;
     }
     if ($save = parent::save($src, $orderingFilter, $ignore)) {
         if ($this->productcomment_enabled && empty($this->rating_updated)) {
             // get the product row
             $product = JTable::getInstance('Products', 'CitruscartTable');
             $product->load($this->product_id);
             $product->updateOverallRating();
             if (!$product->save()) {
                 $this->setError($product->getError());
             } else {
                 $this->rating_updated = '1';
                 parent::store();
             }
         } elseif (!$this->productcomment_enabled && !empty($this->rating_updated)) {
             // comment has been disabled after it already updated the overall rating
             // so remove it from the overall rating
             // get the product row
             $product = JTable::getInstance('Products', 'CitruscartTable');
             $product->load($this->product_id);
             $product->updateOverallRating();
             if (!$product->save()) {
                 $this->setError($product->getError());
             } else {
                 $this->rating_updated = '0';
                 parent::store();
             }
         }
     }
     return $save;
 }
Example #29
0
 public function bind($from, $ignore = array())
 {
     // Check the table activation status first
     if (!$this->active) {
         // Activate it with a default value
         $this->setType('');
     }
     return parent::bind($from, $ignore);
 }
 /**
  * Run function when deleting
  * @see Citruscart/admin/tables/CitruscartTable#save()
  */
 function delete($oid = null, $doReconciliation = true)
 {
     $k = $this->_tbl_key;
     if ($oid) {
         $this->{$k} = intval($oid);
     }
     if ($doReconciliation) {
         $pa = JTable::getInstance('ProductAttributes', 'CitruscartTable');
         if ($oid) {
             $row = JTable::getInstance('ProductAttributeOptions', 'CitruscartTable');
             $row->load($oid);
             $pa->load($row->productattribute_id);
         } else {
             $pa->load($this->productattribute_id);
         }
         $product_id = $pa->product_id;
     }
     if ($return = parent::delete($oid)) {
         DSCModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models');
         $model = DSCModel::getInstance('ProductAttributeOptionValues', 'CitruscartModel');
         $model->setState('filter_option', $this->{$k});
         if ($items = $model->getList()) {
             $table = $model->getTable();
             foreach ($items as $item) {
                 if (!$table->delete($item->productattributeoptionvalue_id)) {
                     $this->setError($table->getError());
                 }
             }
         }
         if ($doReconciliation) {
             Citruscart::load("CitruscartHelperProduct", 'helpers.product');
             CitruscartHelperProduct::doProductQuantitiesReconciliation($product_id);
         }
     }
     return parent::check();
 }