Пример #1
0
 protected function onBeforeDelete($oid)
 {
     $status = true;
     // load cart items
     $query = $this->_db->getQuery(true);
     $query->select('*')->from('#__j2store_cartitems')->where('cart_id = ' . (int) $oid);
     $this->_db->setQuery($query);
     try {
         $items = $this->_db->loadObjectList();
         // foreach orderitem
         foreach ($items as $item) {
             // remove from user's cart
             if (!F0FTable::getAnInstance('Cartitem', 'J2StoreTable')->delete($item->j2store_cartitem_id)) {
                 //F0FTable::getAnInstance ( 'Cartitem', 'J2StoreTable' )->getError();
                 break;
                 return false;
             } else {
                 J2Store::plugin()->event('RemoveCartItem', array($item));
                 $status = true;
             }
         }
     } catch (Exception $e) {
         // do nothing
     }
     return $status;
 }
Пример #2
0
 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;
 }
Пример #3
0
 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;
 }
Пример #4
0
 /**
  * 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;
     }
 }
Пример #5
0
 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);
 }
Пример #6
0
 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;
         }
     }
 }
Пример #7
0
 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;
 }
Пример #8
0
 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();
 }
Пример #9
0
 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;
 }
Пример #10
0
 /**
  * Method to delete product optionvalues when product option is deleted
  * (non-PHPdoc)
  * @see F0FTable::delete()
  * @result boolean
  */
 protected function onBeforeDelete($oid)
 {
     $status = true;
     //get all the children of product options
     $values = F0FModel::getTmpInstance('Filters', 'J2StoreModel')->group_id($oid)->getList();
     if (count($values)) {
         //loop the productfilters to load and delete the
         foreach ($values as $pfilter) {
             $filter = F0FTable::getAnInstance('Filter', 'J2StoreTable');
             $filter->delete($pfilter->j2store_filter_id);
         }
     }
     return true;
 }
Пример #11
0
 private function deleteChildren($oid)
 {
     $status = true;
     $model = F0FModel::getTmpInstance('Taxrules', 'J2StoreModel');
     $items = $model->taxrate_id($oid)->getList();
     $taxrule = F0FTable::getAnInstance('Taxrule', 'J2StoreTable');
     if (isset($items) && count($items)) {
         foreach ($items as $item) {
             if (!$taxrule->delete($item->j2store_taxrule_id)) {
                 $status = false;
             }
         }
     }
     return $status;
 }
Пример #12
0
 public function getRepeatable()
 {
     $html = '';
     if ($this->item->orderstatus_id != '*') {
         $orderstatus = F0FTable::getAnInstance('Orderstatus', 'J2StoreTable');
         $orderstatus->load($this->item->orderstatus_id);
         $html = '<label class="label">' . JText::_($orderstatus->orderstatus_name);
         if (isset($orderstatus->orderstatus_cssclass) && $orderstatus->orderstatus_cssclass) {
             $html = '<label class="label  ' . $orderstatus->orderstatus_cssclass . '">' . JText::_($orderstatus->orderstatus_name);
         }
     } else {
         $html = '<label class="label label-success">' . JText::_('J2STORE_ALL');
     }
     $html .= '</label>';
     return $html;
 }
Пример #13
0
 public function testtemplate()
 {
     require_once JPATH_ROOT . '/components/com_akeebasubs/helpers/email.php';
     $db = JFactory::getDbo();
     $id = $this->input->getInt('akeebasubs_emailtemplate_id', 0);
     // No id? What??
     if (!$id) {
         $this->setRedirect('index.php?option=com_akeebasubs&view=emailtemplates', JText::_('COM_AKEEBASUBS_EMAILTEMPLATES_CHOOSE_TEMPLATE'), 'notice');
         $this->redirect();
     }
     $url = 'index.php?option=com_akeebasubs&view=emailtemplate&id=' . $id;
     $template = F0FTable::getAnInstance('Emailtemplate', 'AkeebasubsTable');
     $template->load($id);
     // Let's grab the first published level
     $query = $db->getQuery(true)->select('MIN(akeebasubs_level_id)')->from('#__akeebasubs_levels')->where('enabled = 1');
     $level = $db->setQuery($query)->loadResult();
     // No level? So what's the point?
     if (!$level) {
         $this->setRedirect($url, JText::_('COM_AKEEBASUBS_EMAILTEMPLATES_NOENABLEDLEVELS'), 'notice');
         $this->redirect();
     }
     // Let's get a dummy subscription
     $sub = F0FTable::getAnInstance('Subscription', 'AkeebasubsTable');
     $sub->akeebasubs_subscription_id = 999999;
     $sub->user_id = JFactory::getUser()->id;
     $sub->akeebasubs_level_id = $level;
     $sub->publish_up = date('Y-m-d H:i:s');
     $sub->publish_down = date('Y-m-d H:i:s', strtotime('+1 month'));
     $sub->notes = 'This is just a dummy subscription for email testing';
     $sub->enabled = 1;
     $sub->processor = 'Dummy processor';
     $sub->processor_key = 'Dummy processor key';
     $sub->state = 'C';
     $sub->net_amount = 1234.56;
     $sub->tax_amount = 123.456;
     $sub->gross_amount = 1358.016;
     $sub->recurring_amount = 0;
     $sub->tax_percent = 10;
     $sub->created_on = date('Y-m-d H:i:s');
     $mailer = AkeebasubsHelperEmail::getPreloadedMailer($sub, 'plg_akeebasubs_' . $template->key);
     $mailer->addRecipient(JFactory::getUser()->email);
     if ($mailer->Send()) {
         $this->setRedirect($url, JText::_('COM_AKEEBASUBS_EMAILTEMPLATES_TEST_SENT'));
     } else {
         $this->setRedirect($url, JText::_('COM_AKEEBASUBS_EMAILTEMPLATES_TEST_ERROR'), 'notice');
     }
 }
Пример #14
0
 /**
  * Executes before rendering the page for the Add task.
  *
  * @param   string  $tpl  Subtemplate to use
  *
  * @return  boolean  Return true to allow rendering of the page
  */
 protected function onAdd($tpl = null)
 {
     $id = $this->input->getInt('id');
     $this->order = F0FTable::getAnInstance('Order', 'J2StoreTable');
     $this->order->load($id);
     $this->item = $this->order;
     $this->fieldClass = J2Store::getSelectableBase();
     $this->params = J2Store::config();
     $this->currency = J2Store::currency();
     $this->taxes = $this->order->getOrderTaxrates();
     $this->shipping = $this->order->getOrderShippingRate();
     $this->coupons = $this->order->getOrderCoupons();
     $this->vouchers = $this->order->getOrderVouchers();
     $this->orderinfo = $this->order->getOrderInformation();
     $this->orderhistory = $this->order->getOrderHistory();
     parent::onAdd();
 }
Пример #15
0
 /**
  * Method to delete product optionvalues when product option is deleted
  * (non-PHPdoc)
  * @see F0FTable::delete()
  * @result boolean
  */
 public function delete($oid = null)
 {
     $status = true;
     //get all the children of product options
     $productoptions = F0FModel::getTmpInstance('Productoptionvalues', 'J2StoreModel')->productoption_id($oid)->getList();
     if (isset($productoptions) && !empty($productoptions)) {
         //loop the productoptions to load and delete the
         foreach ($productoptions as $poption) {
             $productoption = F0FTable::getAnInstance('Productoptionvalue', 'J2StoreTable');
             $productoption->load($poption->j2store_product_optionvalue_id);
             if (!$productoption->delete($poption->j2store_product_optionvalue_id)) {
                 $status = false;
             }
         }
     }
     $status = parent::delete($oid);
     return $status;
 }
Пример #16
0
 protected function getInput()
 {
     $app = JFactory::getApplication();
     $id = $app->input->getInt('id');
     if ($app->isSite()) {
         $id = $app->input->getInt('a_id');
     }
     $productTable = F0FTable::getAnInstance('Product', 'J2StoreTable');
     $productTable->load(array('product_source' => 'com_content', 'product_source_id' => $id));
     $product_id = isset($productTable->j2store_product_id) ? $productTable->j2store_product_id : '';
     $inputvars = array('task' => 'edit', 'render_toolbar' => '0', 'product_source_id' => $id, 'id' => $product_id, 'product_source' => 'com_content', 'product_source_view' => 'article', 'form_prefix' => 'jform[attribs][j2store]');
     $input = new F0FInput($inputvars);
     @ob_start();
     F0FDispatcher::getTmpInstance('com_j2store', 'product', array('layout' => 'form', 'tmpl' => 'component', 'input' => $input))->dispatch();
     $html = ob_get_contents();
     ob_end_clean();
     return $html;
 }
Пример #17
0
 /**
  * Method to delete product optionvalues when product option is deleted
  * (non-PHPdoc)
  * @see F0FTable::delete()
  * @result boolean
  */
 protected function onBeforeDelete($oid)
 {
     $status = true;
     //get all the children of product options
     $values = F0FModel::getTmpInstance('Filters', 'J2StoreModel')->group_id($oid)->getList();
     $app = JFactory::getApplication();
     if (count($values)) {
         //loop the productfilters to load and delete the
         foreach ($values as $pfilter) {
             $filter = F0FTable::getAnInstance('Filter', 'J2StoreTable');
             if (!$filter->delete($pfilter->j2store_filter_id)) {
                 $app->enqueueMessage(JText::_('J2STORE_FILTER_GROUP_DELETE_ERROR'), 'warning');
                 $status = false;
                 break;
             }
         }
         return $status;
     }
 }
Пример #18
0
 /**
  * The event which runs before deleting a record
  *
  * @param   integer  $oid  The PK value of the record to delete
  *
  * @return  boolean  True to allow the deletion
  */
 protected function onBeforeDelete($oid)
 {
     $status = true;
     $status = $this->isProductAssociated($oid);
     if ($status) {
         //SHOULD ALSO DELETE THE ADDRESS
         // Load the post record
         $item = clone $this;
         $item->load($oid);
         if ($item->address_id) {
             if (F0FTable::getAnInstance('Address', 'J2StoreTable')->load($item->address_id)) {
                 if (!F0FTable::getAnInstance('Address', 'J2StoreTable')->delete($item->address_id)) {
                     $status = false;
                 }
             }
         }
     }
     return $status;
 }
Пример #19
0
 public function history()
 {
     $app = JFactory::getApplication();
     $id = $app->input->getInt('id', 0);
     if ($id > 0) {
         $view = $this->getThisView();
         if ($model = $this->getThisModel()) {
             // Push the model into the view (as default)
             $view->setModel($model, true);
         }
         $voucher = F0FTable::getAnInstance('Voucher', 'J2StoreTable');
         $voucher->load($id);
         $view->assign('voucher', $voucher);
         $voucher_history = $model->getVoucherHistory();
         $view->assign('vouchers', $voucher_history);
         $view->assign('params', J2Store::config());
     }
     $view->setLayout('history');
     $view->display();
 }
Пример #20
0
 public function history()
 {
     $app = JFactory::getApplication();
     $coupon_id = $app->input->getInt('coupon_id');
     $view = $this->getThisView();
     if ($coupon_id > 0) {
         if ($model = $this->getThisModel()) {
             // Push the model into the view (as default)
             $view->setModel($model, true);
         }
         $coupon = F0FTable::getAnInstance('Coupon', 'J2StoreTable');
         $coupon->load($coupon_id);
         $view->assign('coupon', $coupon);
         $coupon_history = $model->getCouponHistory();
         $view->assign('coupon_history', $coupon_history);
         $view->assign('params', J2Store::config());
         $view->assign('currency', J2Store::currency());
     }
     $view->setLayout('history');
     $view->display();
 }
Пример #21
0
 /**
  * callback.
  *
  * @return	void
  */
 public function callback()
 {
     // CSRF prevention disabled, we are trusting in code authentication
     /*
     if ($this->csrfProtection)
     {
     	$this->_csrfProtection();
     }
     */
     try {
         // $channelId = $this->input->getUint('channelId');
         $session = JFactory::getSession();
         $channelId = $session->get('channelId');
         // Invalidating
         $session->set('channelId', false);
         $gpluscode = $this->input->getVar('code');
         $logger = AutotweetLogger::getInstance();
         $logger->log(JLog::INFO, 'GplusChannels callback: ' . $gpluscode);
         // Error throw
         if (!empty($gpluscode)) {
             $channel = F0FTable::getAnInstance('Channel', 'AutoTweetTable');
             $result = $channel->load($channelId);
             if (!$result) {
                 $msg = 'Channel failed to load!';
                 $logger->log(JLog::ERROR, $msg);
                 throw new Exception($msg);
             }
             $gplusChannelHelper = new GplusChannelHelper($channel);
             $gplusChannelHelper->authenticate($gpluscode);
             // 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;
     }
 }
Пример #22
0
 function addCustomer($post)
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     //first save data to the address table
     $row = F0FTable::getAnInstance('Address', 'J2StoreTable');
     //set the id so that it updates the record rather than changing
     if (!$row->bind($post)) {
         $row->setError($row->getError());
         return false;
     }
     if ($user->id) {
         $row->user_id = $user->id;
     }
     $row->type = 'billing';
     if (!$row->store()) {
         $row->setError($row->getError());
         return false;
     }
     return $row->id;
 }
Пример #23
0
 public function getImportedProductOptions($source_product_id, $dest_product_id)
 {
     $source_attributes = F0FModel::getTmpInstance('ProductOptions', 'J2StoreModel')->product_id($source_product_id)->getList();
     //first get the attributes of source product
     if (count($source_attributes) < 1) {
         $this->setError(JText::_('J2STORE_PAI_PRODUCT_DONT_HAVE_ATTRIBUTES'));
         return false;
     }
     //now we have the product options. Loop to insert them
     foreach ($source_attributes as $s_attribute) {
         //load source first
         //$sa_item = JTable::getInstance('ProductOptions', 'Table');
         $sa_item = F0FTable::getAnInstance('ProductOption', 'J2StoreTable');
         $sa_item->load($s_attribute->j2store_productoption_id);
         //now copy it
         $dest_row = F0FTable::getAnInstance('ProductOption', 'J2StoreTable');
         $dest_row = $sa_item;
         $dest_row->j2store_productoption_id = NULL;
         $dest_row->product_id = $dest_product_id;
         $dest_row->store();
         $source_attribute_options = F0FModel::getTmpInstance('ProductOptionvalues', 'J2StoreModel')->productoption_id($s_attribute->j2store_productoption_id)->getList();
         if (count($source_attribute_options)) {
             foreach ($source_attribute_options as $sa_option) {
                 unset($sao_item);
                 //load source
                 $sao_item = F0FTable::getAnInstance('ProductOptionValue', 'J2StoreTable');
                 $sao_item->load($sa_option->j2store_product_optionvalue_id);
                 //now copy it;
                 $dest_sao_row = F0FTable::getAnInstance('ProductOptionValue', 'J2StoreTable');
                 $dest_sao_row = $sao_item;
                 $dest_sao_row->j2store_product_optionvalue_id = NULL;
                 $dest_sao_row->productoption_id = $dest_row->j2store_productoption_id;
                 $dest_sao_row->product_id = $dest_row->product_id;
                 $dest_sao_row->store();
             }
         }
     }
     return true;
 }
Пример #24
0
 /**
  * callback.
  *
  * @return	void
  */
 public function callbackStandalone()
 {
     // CSRF prevention
     if ($this->csrfProtection) {
         $this->_csrfProtection();
     }
     $channelId = $this->input->getUint('channelId');
     $access_token = $this->input->getCmd('access_token');
     $expires_in = $this->input->getCmd('expires_in');
     $user_id = $this->input->getCmd('user_id');
     // Error throw
     if (!empty($access_token)) {
         $channel = F0FTable::getAnInstance('Channel', 'AutoTweetTable');
         $result = $channel->load($channelId);
         if (!$result) {
             throw new Exception('Channel failed to load!');
         }
         $vkChannelHelper = new VkChannelHelper($channel);
         $oAccessToken = new StdClass();
         $oAccessToken->access_token = $access_token;
         $oAccessToken->expires_in = $expires_in;
         $oAccessToken->user_id = $user_id;
         $jsonAccessToken = json_encode($oAccessToken);
         $vkChannelHelper->setJsonAccessToken($jsonAccessToken);
         $userSettings = $vkChannelHelper->getUserSettings();
         if (is_array($userSettings) && ($userSettings['response'] = 65536)) {
             $registry = new JRegistry();
             $registry->loadString($channel->params);
             $registry->set('access_token', $jsonAccessToken);
             $channel->bind(array('params' => (string) $registry));
             $channel->store();
             // Redirect
             $url = 'index.php?option=com_autotweet&view=channels&task=edit&id=' . $channelId;
             $this->setRedirect($url);
             $this->redirect();
         }
     }
 }
Пример #25
0
 public function getDeleteChildren($tablename, $items)
 {
     $status = true;
     foreach ($items as $single) {
         $table = F0FTable::getAnInstance(ucfirst($tablename), 'J2StoreTable');
         $key = $table->getKeyName();
         if (!$table->delete($single->{$key})) {
             $status = false;
         }
     }
     return $status;
 }
Пример #26
0
 public function printShipping()
 {
     $app = JFactory::getApplication();
     $order_id = $this->input->getString('order_id');
     $view = $this->getThisView();
     if ($model = $this->getThisModel()) {
         // Push the model into the view (as default)
         $view->setModel($model, true);
     }
     $order = F0FTable::getInstance('Order', 'J2StoreTable');
     $order->load(array('order_id' => $order_id));
     $orderinfo = F0FTable::getAnInstance('Orderinfo', 'J2StoreTable');
     $orderinfo->load(array('order_id' => $order_id));
     $error = false;
     $view->assign('orderinfo', $orderinfo);
     $view->assign('item', $order);
     $view->assign('params', J2Store::config());
     $view->assign('error', $error);
     $view->setLayout('print_shipping');
     $view->display();
 }
Пример #27
0
 public function getMergedData($user_id = null)
 {
     $state = $this->getFilterValues();
     if (is_null($user_id)) {
         $user_id = $state->user_id;
     }
     // Get a legacy data set from the user parameters
     $userRow = F0FTable::getAnInstance('Juser', 'AkeebasubsTable');
     $userRow->load($user_id);
     if (!$userRow->params instanceof JRegistry) {
         JLoader::import('joomla.registry.registry');
         $params = new JRegistry($userRow->params);
     } else {
         $params = $userRow->params;
     }
     $businessname = $params->get('business_name', '');
     $nativeData = array('isbusiness' => empty($businessname) ? 0 : 1, 'businessname' => $params->get('business_name', ''), 'occupation' => $params->get('occupation', ''), 'vatnumber' => $params->get('vat_number', ''), 'viesregistered' => 0, 'taxauthority' => '', 'address1' => $params->get('address', ''), 'address2' => $params->get('address2', ''), 'city' => $params->get('city', ''), 'state' => $params->get('state', ''), 'zip' => $params->get('zip', ''), 'country' => $params->get('country', ''), 'params' => array());
     $userData = $userRow->getData();
     $myData = $nativeData;
     foreach (array('name', 'username', 'email') as $key) {
         $myData[$key] = $userData[$key];
     }
     $myData['email2'] = $userData['email'];
     unset($userData);
     if ($user_id > 0) {
         $row = F0FModel::getTmpInstance('Users', 'AkeebasubsModel')->user_id($user_id)->getFirstItem();
         if ($row->user_id == $user_id) {
             $myData = array_merge($myData, $row->getData());
             if (is_string($myData['params'])) {
                 $myData['params'] = json_decode($myData['params'], true);
                 if (is_null($myData['params'])) {
                     $myData['params'] = array();
                 }
             }
         }
     } else {
         $myData = array();
     }
     // Finally, merge data coming from the plugins. Note that the
     // plugins only run when a new subscription is in progress, not
     // every time the user data loads.
     JLoader::import('joomla.plugin.helper');
     JPluginHelper::importPlugin('akeebasubs');
     $app = JFactory::getApplication();
     $jResponse = $app->triggerEvent('onAKUserGetData', array((object) $myData));
     if (is_array($jResponse) && !empty($jResponse)) {
         foreach ($jResponse as $pResponse) {
             if (!is_array($pResponse)) {
                 continue;
             }
             if (empty($pResponse)) {
                 continue;
             }
             if (array_key_exists('params', $pResponse)) {
                 if (!empty($pResponse['params'])) {
                     foreach ($pResponse['params'] as $k => $v) {
                         $myData['params'][$k] = $v;
                     }
                 }
                 unset($pResponse['params']);
             }
             foreach ($pResponse as $k => $v) {
                 if (!empty($v)) {
                     $myData[$k] = $v;
                 }
             }
         }
     }
     if (!isset($myData['params'])) {
         $myData['params'] = array();
     }
     $myData['params'] = (object) $myData['params'];
     return (object) $myData;
 }
Пример #28
0
 function display($field, $value, $map, $inside, $options = '', $test = false, $allFields = null, $allValues = null)
 {
     $app = JFactory::getApplication();
     $store = J2Store::storeProfile();
     $stateId = $currentZoneId = $store->get('zone_id') > 0 ? $store->get('zone_id') : '';
     $country_id = $store->get('country_id') > 0 ? $store->get('country_id') : '';
     //if no default value was set in the fields, then use the country id set in the store profile.
     if (empty($field->field_default)) {
         $defaultCountry = $country_id;
     }
     if (empty($value)) {
         $value = $field->field_default;
     }
     if ($field->field_options['zone_type'] == 'country') {
         if (isset($defaultCountry)) {
             $field->field_default = $defaultCountry;
         }
         if (empty($value)) {
             $value = $field->field_default;
         }
     } elseif ($field->field_options['zone_type'] == 'zone') {
         $stateId = str_replace(array('[', ']'), array('_', ''), $map);
         $dropdown = '';
         if ($allFields != null) {
             $country = null;
             foreach ($allFields as $f) {
                 if ($f->field_type == 'zone' && !empty($f->field_options['zone_type']) && $f->field_options['zone_type'] == 'country') {
                     $key = $f->field_namekey;
                     if (!empty($allValues->{$key})) {
                         $country = $allValues->{$key};
                     } else {
                         $country = $f->field_default;
                     }
                     break;
                 }
             }
             //no country id, then load it based on the zone default.
             if (empty($country) && isset($field->field_default)) {
                 F0FTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2store/tables');
                 $table = F0FTable::getAnInstance('Zone', 'J2StoreTable');
                 if ($table->load($field->field_default)) {
                     $country = $table->country_id;
                 }
             }
             //still no. Set it to store default.
             if (empty($country)) {
                 $country = $store->get('country_id');
                 if (empty($value)) {
                     $value = $store->get('zone_id');
                 }
             }
             if (!empty($country)) {
                 $countryType = new j2storeCountryType();
                 $countryType->type = 'zone';
                 $countryType->country_id = $country;
                 $countryType->published = true;
                 $dropdown = $countryType->displayZone($map, $value, true);
             }
         }
         $html = '<span id="' . $stateId . '_container">' . $dropdown . '</span>' . '<input type="hidden" id="' . $stateId . '_default_value" name="' . $stateId . '_default_value" value="' . $value . '"/>';
         return $html;
     }
     return parent::display($field, $value, $map, $inside, $options, $test, $allFields, $allValues);
 }
Пример #29
0
Файл: model.php Проект: 01J/topm
 /**
  * Method to load and return a model object.
  *
  * @param   string  $name    The name of the view
  * @param   string  $prefix  The class prefix. Optional.
  * @param   array   $config  The configuration array to pass to the table
  *
  * @return  F0FTable  Table object or boolean false if failed
  */
 protected function &_createTable($name, $prefix = 'Table', $config = array())
 {
     // Make sure $config is an array
     if (is_object($config)) {
         $config = (array) $config;
     } elseif (!is_array($config)) {
         $config = array();
     }
     $result = null;
     // Clean the model name
     $name = preg_replace('/[^A-Z0-9_]/i', '', $name);
     $prefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix);
     // Make sure we are returning a DBO object
     if (!array_key_exists('dbo', $config)) {
         $config['dbo'] = $this->getDBO();
     }
     $instance = F0FTable::getAnInstance($name, $prefix, $config);
     return $instance;
 }
Пример #30
0
 /**
  * Create objects for the options
  *
  * @return  array  The array of option objects
  */
 protected function getOptions()
 {
     // Field options: title translate and show how much related items
     $countAndShowRelated = (string) $this->element['countAndShowRelated'] == 'true';
     $translateTitle = (string) $this->element['translateTitle'] == 'true';
     $table = $this->form->getModel()->getTable();
     // Get relation definitions from fof.xml
     $key = $table->getConfigProviderKey() . '.relations';
     $relations = $table->getConfigProvider()->get($key, array());
     // Get the relation type:
     $relationType = '';
     foreach ($relations as $relation) {
         if ($relation['itemName'] == $this->name) {
             $relationType = $relation['type'];
             break;
         }
     }
     // Get full relation definitions from F0FTableRelation object:
     $relation = $table->getRelations()->getRelation($this->name, $relationType);
     $dbOptions = array();
     // First implementation: multiple relations. Not using others yet
     if ($relation['type'] == 'multiple') {
         // Guessing the related table name from the given tableclassname followed the naming-conventions:
         list($option, $tableWord, $optItemSingular) = explode('_', F0FInflector::underscore($relation['tableClass']));
         $optionsTableName = '#__' . $option . '_' . F0FInflector::pluralize($optItemSingular);
         // Get the options table object
         $optionsTableObject = F0FTable::getAnInstance($relation['tableClass'], null);
         // Get the Items
         $db = JFactory::getDbo();
         $q = $db->getQuery(true)->select('o.*')->from($db->qn($optionsTableName) . ' as o');
         // Should we count and show related items?
         if ($countAndShowRelated) {
             $q->select('count(' . $db->qn('p.' . $relation['ourPivotKey']) . ') as total');
             $q->leftJoin($db->qn($relation['pivotTable']) . ' as p on ' . $db->qn('o.' . $relation['remoteKey']) . ' = ' . $db->qn('p.' . $relation['theirPivotKey']));
             $q->group($db->qn('o.' . $relation['remoteKey']));
         }
         // todo Language-filtering?
         $dbOptions = $db->setQuery($q)->loadObjectList($relation['remoteKey']);
     }
     $options = array();
     // Get the field $options on top
     foreach ($this->element->children() as $option) {
         // Only add <option /> elements.
         if ($option->getName() != 'option') {
             continue;
         }
         // Create a new option object based on the <option /> element.
         $options[] = JHtml::_('select.option', (string) $option['value'], JText::alt(trim((string) $option), preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)), 'value', 'text', (string) $option['disabled'] == 'true');
     }
     // Loop through the data and prime the $options array
     // Get title column alias:
     $titleField = $optionsTableObject->getColumnAlias('title');
     $keyField = $relation['remoteKey'];
     $enabledField = $optionsTableObject->getColumnAlias('enabled');
     foreach ($dbOptions as $dbOption) {
         $key = $dbOption->{$keyField};
         $value = $dbOption->{$titleField};
         $disabled = !$dbOption->{$enabledField} ? true : false;
         if ($translateTitle) {
             $value = JText::_($value);
         }
         if ($countAndShowRelated) {
             $value = $value . ' (' . $dbOption->total . ')';
         }
         $options[] = JHtml::_('select.option', $key, $value, 'value', 'text', $disabled);
     }
     return $options;
 }