public function createCoupon($key, $pwd) { // Do I have a key/pwd pair? if (!$key || !$pwd) { return array('error' => JText::_('COM_AKEEBASUBS_APICOUPONS_INVALID_CREDENTIALS')); } $table = $this->getTable(); $table->load(array('key' => $key, 'password' => $pwd)); // Are they valid? if (!$table->akeebasubs_apicoupon_id || !$table->enabled) { return array('error' => JText::_('COM_AKEEBASUBS_APICOUPONS_INVALID_CREDENTIALS')); } // Do I hit a limit? if (!$this->performApiChecks($table)) { return array('error' => JText::_('COM_AKEEBASUBS_APICOUPONS_LIMIT_EXCEEDED')); } // If I'm here, I'm clear to go JLoader::import('joomla.user.helper'); $coupon = F0FTable::getAnInstance('Coupon', 'AkeebasubsTable'); $data['akeebasubs_apicoupon_id'] = $table->akeebasubs_apicoupon_id; $data['title'] = 'API coupon for: ' . $table->title; $data['coupon'] = strtoupper(JUserHelper::genRandomPassword(10)); $data['subscriptions'] = $table->subscriptions; // By default I want the coupon to be single-use $data['hitslimit'] = 1; $data['userhits'] = 1; $data['type'] = $table->type; $data['value'] = $table->value; if (!$coupon->save($data)) { return array('error' => JText::_('COM_AKEEBASUBS_APICOUPONS_COUPON_ERROR')); } return array('coupon' => $coupon->coupon); }
public function deleteChildren($oid) { $status = true; //should delete geozonerules $geozonerules = F0FModel::getTmpInstance('GeozoneRules', 'J2StoreModel')->geozone_id($oid)->getList(); $geozonerule = F0FTable::getAnInstance('GeozoneRule', 'J2StoreTable'); if (isset($geozonerules) && count($geozonerules)) { foreach ($geozonerules as $grule) { if (!$geozonerule->delete($grule->j2store_geozonerule_id)) { $status = false; } } } if ($status) { // delete taxrate and also related taxprofile rules... $taxrates = F0FModel::getTmpInstance('Taxrates', 'J2StoreModel')->geozone_id($oid)->getList(); $taxrate = F0FTable::getAnInstance('Taxrate', 'J2StoreTable'); if (isset($taxrates) && count($taxrates)) { foreach ($taxrates as $trate) { if (!$taxrate->delete($trate->j2store_taxrate_id)) { $status = false; } } } } return $status; }
public function update_inventory() { $app = JFactory::getApplication(); $quantity = $app->input->getInt('quantity'); $availability = $app->input->getInt('availability'); $manage_stock = $app->input->getInt('manage_stock'); $variant_id = $app->input->getInt('variant_id'); $json = array(); if ($variant_id > 0) { F0FTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2store/tables'); $productquantities = F0FTable::getInstance('Productquantity', 'J2StoreTable')->getClone(); $productquantities->load(array('variant_id' => $variant_id)); $productquantities->variant_id = $variant_id; $productquantities->quantity = $quantity; if (!$productquantities->store()) { $json['error'] = "Problem in Save"; } $variants_table = F0FTable::getInstance('Variant', 'J2StoreTable')->getClone(); $variants_table->load($variant_id); $variants_table->availability = $availability; $variants_table->manage_stock = $manage_stock; if (!$variants_table->store()) { $json['error'] = "Problem in Save"; } } if (!$json) { $json['success'] = 'index.php?option=com_j2store&view=inventories'; } echo json_encode($json); $app->close(); }
public function save($data) { if (parent::save($data)) { if ($this->otable->j2store_geozone_id) { if (isset($data['zone_to_geo_zone']) && count($data['zone_to_geo_zone'])) { $grtable = F0FTable::getInstance('geozonerule', 'J2StoreTable'); $status = true; foreach ($data['zone_to_geo_zone'] as $georule) { $grtable->load($georule['j2store_geozonerule_id']); $georule['geozone_id'] = $this->otable->j2store_geozone_id; try { $grtable->save($georule); } catch (Exception $e) { $status = false; } if (!$status) { break; } } } else { return true; } } } else { return false; } return true; }
public function save($data) { if (parent::save($data)) { if ($this->otable->j2store_taxprofile_id) { if (isset($data['tax-to-taxrule-row']) && count($data['tax-to-taxrule-row'])) { $trTable = F0FTable::getInstance('taxrules', 'Table'); $status = true; foreach ($data['tax-to-taxrule-row'] as $taxrate) { $trTable->load($taxrate['j2store_taxrule_id']); $taxrate['taxprofile_id'] = $this->otable->j2store_taxprofile_id; try { $trTable->save($taxrate); } catch (Exception $e) { $status = false; } if (!$status) { break; } } } else { return true; } } } else { return false; } return true; }
/** * Instantiate the table object * * @param string $table Param * @param string $key Param * @param JDatabase &$db The Joomla! database object */ public function __construct($table, $key, &$db) { parent::__construct('#__autotweet_automator', 'id', $db); $this->xtform = new JRegistry(); $this->unix_mhdmd = null; $this->repeat_until = null; }
public function __construct($table, $key, &$db, $config = array()) { $table = "#__j2store_productimages"; //important $key = "j2store_productimage_id"; parent::__construct($table, $key, $db, $config); }
protected function onAdd($tpl = null) { $app = JFactory::getApplication(); JRequest::setVar('hidemainmenu', true); $model = $this->getModel(); $this->item = $model->runMyBehaviorFlag(true)->getItem(); $this->currency = J2Store::currency(); $this->form_prefix = $this->input->getString('form_prefix', ''); $this->product_source_view = $this->input->getString('product_source_view', 'article'); $this->product_types = JHtml::_('select.genericlist', $model->getProductTypes(), $this->form_prefix . '[product_type]', array(), 'value', 'text', $this->item->product_type); if ($this->item->j2store_product_id) { //manufacturers $this->manufacturers = J2Html::select()->clearState()->type('genericlist')->name($this->form_prefix . '[manufacturer_id]')->value($this->item->manufacturer_id)->setPlaceHolders(array('' => JText::_('J2STORE_SELECT_OPTION')))->hasOne('Manufacturers')->setRelations(array('fields' => array('key' => 'j2store_manufacturer_id', 'name' => array('company'))))->getHtml(); //vendor $this->vendors = J2Html::select()->clearState()->type('genericlist')->name($this->form_prefix . '[vendor_id]')->value($this->item->vendor_id)->setPlaceHolders(array('' => JText::_('J2STORE_SELECT_OPTION')))->hasOne('Vendors')->setRelations(array('fields' => array('key' => 'j2store_vendor_id', 'name' => array('first_name', 'last_name'))))->getHtml(); //tax profiles $this->taxprofiles = J2Html::select()->clearState()->type('genericlist')->name($this->form_prefix . '[taxprofile_id]')->value($this->item->taxprofile_id)->setPlaceHolders(array('' => JText::_('J2STORE_NOT_TAXABLE')))->hasOne('Taxprofiles')->setRelations(array('fields' => array('key' => 'j2store_taxprofile_id', 'name' => 'taxprofile_name')))->getHtml(); } if ($this->item->j2store_product_id > 0) { $this->product_filters = F0FTable::getAnInstance('ProductFilter', 'J2StoreTable')->getFiltersByProduct($this->item->j2store_product_id); } else { $this->product_filters = array(); } return true; }
public function save() { $task = $this->getTask(); // get the Application Object $app = JFactory::getApplication(); // get the payment id $payment_id = $app->input->getInt('extension_id'); // if payment id exists if ($payment_id) { $data = $app->input->getArray($_POST); $paymentdata = array(); $paymentdata['extension_id'] = $payment_id; $registry = new JRegistry(); $registry->loadArray($data); $paymentdata['params'] = $registry->toString('JSON'); try { F0FTable::getAnInstance('Payment', 'J2StoreTable')->save($paymentdata); } catch (Exception $e) { $msg = $e->getMessage(); } switch ($task) { case 'apply': parent::apply(); break; case 'save': parent::save(); break; case 'savenew': parent::savenew(); break; } } }
public function save($data) { $app = JFactory::getApplication(); $task = $app->input->getString('task'); if ($task == 'saveorder') { return parent::save($data); } if (parent::save($data)) { if (isset($this->otable->j2store_filtergroup_id)) { if (isset($data['filter_value']) && count($data['filter_value'])) { $ovTable = F0FTable::getInstance('filter', 'J2StoreTable'); $status = true; foreach ($data['filter_value'] as $filtervalue) { $ovTable->load($filtervalue['j2store_filter_id']); $filtervalue['group_id'] = $this->otable->j2store_filtergroup_id; if (!$ovTable->save($filtervalue)) { $status = false; } } } else { return true; } } } else { return false; } return true; }
public function save($data) { if (parent::save($data)) { if ($this->otable->j2store_option_id) { if (is_object($data)) { $data = (array) $data; } if (isset($data['option_value']) && count($data['option_value'])) { $ovTable = F0FTable::getInstance('optionvalue', 'Table'); $status = true; foreach ($data['option_value'] as $optionvalue) { $ovTable->load($optionvalue['j2store_optionvalue_id']); $optionvalue['option_id'] = $this->otable->j2store_option_id; if (!$ovTable->save($optionvalue)) { $status = false; } } } else { return true; } } } else { return false; } return true; }
/** * callback. * * @return void */ public function callback() { if ($this->csrfProtection) { $this->_csrfProtection(); } try { // $channelId = $this->input->getUint('channelId'); $session = JFactory::getSession(); $channelId = $session->get('channelId'); // Invalidating $session->set('channelId', false); $code = $this->input->getString('code'); $state = $this->input->getString('state'); if (!empty($code)) { $channel = F0FTable::getAnInstance('Channel', 'AutoTweetTable'); $result = $channel->load($channelId); if (!$result) { throw new Exception('LinkedIn Channel failed to load!'); } $lioauth2ChannelHelper = new LiOAuth2ChannelHelper($channel); $lioauth2ChannelHelper->authenticate($code, $state); // Redirect $url = 'index.php?option=com_autotweet&view=channels&task=edit&id=' . $channelId; $this->setRedirect($url); $this->redirect(); } } catch (Exception $e) { $logger = AutotweetLogger::getInstance(); $logger->log(JLog::ERROR, $e->getMessage()); throw $e; } }
/** * The event which runs before storing (saving) data to the database * * @param boolean $updateNulls Should nulls be saved as nulls (true) or just skipped over (false)? * * @return boolean True to allow saving */ protected function onBeforeStore($updateNulls) { // BLOB/TEXT default value if (!isset($this->params)) { $this->params = ''; } return parent::onBeforeStore($updateNulls); }
/** * Returns the data in $this->_current as a F0FTable instance * * @return F0FTable * * @throws OutOfBoundsException */ protected function getTable() { if (!$this->valid()) { throw new OutOfBoundsException('Cannot get item past iterator\'s bounds', 500); } $this->_tableObject->bind($this->_current); return $this->_tableObject; }
public function &getItem($id = null) { $user = JFactory::getUser(); $this->record = F0FTable::getAnInstance('Vendoruser', 'J2StoreTable'); $this->record->load($user->id); $this->record->products = F0FModel::getTmpInstance('Products', 'J2StoreModel')->vendor_id($this->record->j2store_vendor_id)->enabled(1)->getList(); return $this->record; }
public function check() { $date = new JDate($this->date_from); $this->date_from = $date->toSql(); $date1 = new JDate($this->date_to); $this->date_to = $date1->toSql(); return parent::check(); }
protected function onAfterDelete($oid) { $result = parent::onAfterDelete($oid); if ($result) { $result = $this->deleteScanResults($oid); } return $result; }
public function __construct($table, $key, &$db) { $table = '#__users'; $key = 'id'; $query = $db->getQuery(true)->select($db->qn('#__j2store_vendors') . '.j2store_vendor_id')->select($db->qn('#__j2store_vendors') . '.j2store_user_id')->select($db->qn('#__j2store_vendors') . '.address_id')->select($db->qn('#__j2store_addresses') . '.j2store_address_id')->select($db->qn('#__j2store_addresses') . '.first_name')->select($db->qn('#__j2store_addresses') . '.last_name')->select($db->qn('#__j2store_addresses') . '.address_1')->select($db->qn('#__j2store_addresses') . '.address_2')->select($db->qn('#__j2store_addresses') . '.user_id')->select($db->qn('#__j2store_addresses') . '.email')->select($db->qn('#__j2store_addresses') . '.city')->select($db->qn('#__j2store_addresses') . '.zip')->select($db->qn('#__j2store_addresses') . '.zone_id')->select($db->qn('#__j2store_addresses') . '.country_id')->select($db->qn('#__j2store_addresses') . '.phone_1')->select($db->qn('#__j2store_addresses') . '.phone_2')->select($db->qn('#__j2store_addresses') . '.fax')->select($db->qn('#__j2store_addresses') . '.type')->select($db->qn('#__j2store_addresses') . '.company')->select($db->qn('#__j2store_addresses') . '.tax_number')->select($db->qn('#__j2store_countries') . '.country_name')->select($db->qn('#__j2store_zones') . '.zone_name')->leftJoin('#__j2store_vendors ON #__j2store_vendors.j2store_user_id = #__users.id')->leftJoin('#__j2store_addresses ON #__j2store_addresses.j2store_address_id = #__j2store_vendors.address_id')->leftJoin('#__j2store_countries ON #__j2store_countries.j2store_country_id = #__j2store_addresses.country_id')->leftJoin('#__j2store_zones ON #__j2store_zones.j2store_zone_id = #__j2store_addresses.zone_id'); $this->setQueryJoin($query); parent::__construct($table, $key, $db); }
public function onBeforeSave(&$data, &$table) { $app = JFactory::getApplication(); $addressTable = F0FTable::getInstance('Address', 'J2storeTable'); $addressTable->load($data['address_id']); $addressTable->save($data); $data['address_id'] = $addressTable->j2store_address_id; return true; }
/** * The event which runs before storing (saving) data to the database * * @param boolean $updateNulls Should nulls be saved as nulls (true) or just skipped over (false)? * * @return boolean True to allow saving */ protected function onBeforeStore($updateNulls) { $result = parent::onBeforeStore($updateNulls); if ($result) { $params = json_decode($this->params); $this->evergreentype_id = $params->evergreen; } return $result; }
function delete($oid = null) { $joins = array(array('label' => 'subscriptions', 'name' => '#__akeebasubs_subscriptions', 'idfield' => 'akeebasubs_upgrade_id', 'joinfield' => 'akeebasubs_upgrade_id', 'idalias' => 'upgradeid')); if ($this->canDelete($oid, $joins)) { return parent::delete($oid); } else { return false; } }
public function check() { $status = parent::check(); //to throw error when optionvalue id is empty /* if(!$this->optionvalue_id){ $this->setError(JText::_('J2STORE_PRODUCT_OPTION_VALUE_MISSING')); $status = false; } */ return $status; }
/** * onBeforeDelete event - forbids deleting the default backup profile * * @param int $oid The ID of the profile to delete * * @return boolean True if the deletion is allowed */ protected function onBeforeDelete($oid) { $result = parent::onBeforeDelete($oid); if ($result) { if ($oid == 1) { $this->setError(JText::_('TABLE_PROFILE_CANNOTDELETEDEFAULT')); $result = false; } } return $result; }
public function getAssetParentId($table = null, $id = null) { $db = JFactory::getDbo(); $query = $db->getQuery(true)->select($db->qn('id'))->from($db->qn('#__assets'))->where($db->qn('name') . ' = ' . $db->q('com_todo'))->where($db->qn('parent_id') . ' = 1')->where($db->qn('level') . ' = 1'); $parent_id = $db->setQuery($query)->loadResult(); if (!$parent_id) { return parent::getAssetParentId($table, $id); } else { return $parent_id; } }
function deleteproductfiltervalues() { $o_id = $this->input->getInt('productfiltervalue_id'); $productfilter = F0FTable::getAnInstance('filter', 'J2StoreTable'); $json = array(); $json['success']['msg'] = JText::_('J2STORE_PRODUCT_FILTER_VALUE_DELETE_SUCCESS'); if (!$productfilter->delete($o_id)) { $json['error']['msg'] = JText::_('J2STORE_PRODUCT_FILTER_VALUE_DELETE_ERROR'); } echo json_encode($json); JFactory::getApplication()->close(); }
public function check() { $result = true; if (!$this->title) { $this->setError(JText::_('COM_AKEEBASUBS_APICOUPONS_ERR_TITLE')); $result = false; } if (!$this->key) { $this->key = md5(microtime()); } if (!$this->password) { $this->password = md5(microtime()); } // Make sure assigned subscriptions really do exist and normalize the list if (!empty($this->subscriptions)) { if (is_array($this->subscriptions)) { $subs = $this->subscriptions; } else { $subs = explode(',', $this->subscriptions); } if (empty($subs)) { $this->subscriptions = ''; } else { $subscriptions = array(); foreach ($subs as $id) { $subObject = F0FModel::getTmpInstance('Levels', 'AkeebasubsModel')->setId($id)->getItem(); $id = null; if (is_object($subObject)) { if ($subObject->akeebasubs_level_id > 0) { $id = $subObject->akeebasubs_level_id; } } if (!is_null($id)) { $subscriptions[] = $id; } } $this->subscriptions = implode(',', $subscriptions); } } // Check the type if (!in_array($this->type, array('value', 'percent'))) { $this->type = 'value'; } // Check value if ($this->value < 0) { $this->setError(JText::_('COM_AKEEBASUBS_COUPON_ERR_VALUE')); $result = false; } elseif ($this->value > 100 && $this->type == 'percent') { $this->value = 100; } return parent::check() && $result; }
public function getRepeatable() { $orderinfo = F0FTable::getAnInstance('Orderinfo', 'J2StoreTable'); $orderinfo->load(array('order_id' => $this->item->order_id)); $customer_name = $orderinfo->billing_first_name . ' ' . $orderinfo->billing_last_name; $html = ''; $html .= $customer_name; $html .= '<br>'; $html .= '<small>'; $html .= $this->item->user_email; $html .= '</small>'; return $html; }
public function __construct($table, $key, &$db, $config = array()) { $table = '#__j2store_addresses'; $key = 'j2store_address_id'; parent::__construct($table, $key, $db, $config); $session = JFactory::getSession(); if ($session->has('is_vat_valid', 'j2store')) { $vat_result = $session->get('is_vat_valid', 'invalid', 'j2store'); if (strtolower($vat_result == 'valid')) { $this->set_is_vat_exempt(1); } } }
public function getAddressById($address_id) { static $sets; if (!is_array($sets)) { $sets = array(); } if (!isset($sets[$address_id])) { $address_table = F0FTable::getInstance('Address', 'J2StoreTable'); $address_table->load($address_id); $sets[$address_id] = $address_table; } return $sets[$address_id]; }
public function __construct($table, $key, &$db) { $query = JFactory::getDbo()->getQuery(true); $query->leftJoin('#__j2store_countries as billingcountry ON billingcountry.j2store_country_id = #__j2store_orderinfos.billing_country_id'); $query->select('billingcountry.country_name as billing_country_name'); $query->leftJoin('#__j2store_countries as shippingcountry ON shippingcountry.j2store_country_id = #__j2store_orderinfos.shipping_country_id'); $query->select('shippingcountry.country_name as shipping_country_name'); $query->leftJoin('#__j2store_zones as billingzone ON billingzone.j2store_zone_id = #__j2store_orderinfos.billing_zone_id'); $query->select('billingzone.zone_name as billing_zone_name'); $query->leftJoin('#__j2store_zones as shippingzone ON shippingzone.j2store_zone_id = #__j2store_orderinfos.shipping_zone_id'); $query->select('shippingzone.zone_name as shipping_zone_name'); $this->setQueryJoin($query); parent::__construct($table, $key, $db); }