コード例 #1
0
 /**
  * Sets the model's state
  *
  * @return array()
  */
 function _setModelState()
 {
     $state = parent::_setModelState();
     $app = JFactory::getApplication();
     $model = $this->getModel($this->get('suffix'));
     $ns = $this->getNamespace();
     $state['order'] = $app->getUserStateFromRequest($ns . '.filter_order', 'filter_order', 'tbl.created_datetime', 'cmd');
     $state['direction'] = $app->getUserStateFromRequest($ns . '.filter_direction', 'filter_direction', 'DESC', 'word');
     $state['filter_orderid'] = $app->getUserStateFromRequest($ns . 'filter_orderid', 'filter_orderid', '', '');
     $state['filter_type'] = $app->getUserStateFromRequest($ns . 'filter_type', 'filter_type', '', '');
     $state['filter_transactionid'] = $app->getUserStateFromRequest($ns . 'filter_transactionid', 'filter_transactionid', '', '');
     $state['filter_user'] = $app->getUserStateFromRequest($ns . 'filter_user', 'filter_user', '', '');
     $state['filter_userid'] = $app->getUserStateFromRequest($ns . 'filter_userid', 'filter_userid', '', '');
     $state['filter_id_from'] = $app->getUserStateFromRequest($ns . 'id_from', 'filter_id_from', '', '');
     $state['filter_id_to'] = $app->getUserStateFromRequest($ns . 'id_to', 'filter_id_to', '', '');
     $state['filter_date_from'] = $app->getUserStateFromRequest($ns . 'date_from', 'filter_date_from', '', '');
     $state['filter_date_from_expires'] = $app->getUserStateFromRequest($ns . 'date_from_expires', 'filter_date_from_expires', '', '');
     $state['filter_date_to_expires'] = $app->getUserStateFromRequest($ns . 'date_to_expires', 'filter_date_to_expires', '', '');
     $state['filter_date_to'] = $app->getUserStateFromRequest($ns . 'date_to', 'filter_date_to', '', '');
     $state['filter_datetype'] = 'created';
     $state['filter_total_from'] = $app->getUserStateFromRequest($ns . 'filter_total_from', 'filter_total_from', '', '');
     $state['filter_total_to'] = $app->getUserStateFromRequest($ns . 'filter_total_to', 'filter_total_to', '', '');
     $state['filter_enabled'] = $app->getUserStateFromRequest($ns . 'filter_enabled', 'filter_enabled', '', '');
     $state['filter_lifetime'] = $app->getUserStateFromRequest($ns . 'filter_lifetime', 'filter_lifetime', '', '');
     if (Citruscart::getInstance()->get('display_subnum', 0)) {
         $state['filter_subnum'] = $app->getUserStateFromRequest($ns . 'filter_subnum', 'filter_subnum', '', '');
     }
     foreach ($state as $key => $value) {
         $model->setState($key, $value);
     }
     return $state;
 }
コード例 #2
0
 /**
  * Saves an item and redirects based on task
  * @return void
  */
 function save()
 {
     $app = JFactory::getApplication();
     if (!($row = parent::save())) {
         return $row;
     }
     $model = $this->getModel($this->get('suffix'));
     $error = false;
     $row->manufacturer_description = $app->input->getString('manufacturer_name');
     $row->manufacturer_description = $app->input->getString('manufacturer_description');
     $fieldname = 'manufacturer_image_new';
     $userfile = $app->input->files->get($fieldname, '', 'files', 'array');
     //$userfile = JRequest::getVar( $fieldname, '', 'files', 'array' );
     if (!empty($userfile['size'])) {
         if ($upload = $this->addfile($fieldname)) {
             $row->manufacturer_image = $upload->getPhysicalName();
         } else {
             $error = true;
         }
     }
     if ($row->save()) {
         $model->setId($row->id);
         $this->messagetype = 'message';
         $this->message = JText::_('COM_CITRUSCART_SAVED');
         if ($error) {
             $this->messagetype = 'notice';
             $this->message .= " :: " . $this->getError();
         }
         JFactory::getApplication()->triggerEvent('onAfterSave' . $this->get('suffix'), array($row));
     } else {
         $this->messagetype = 'notice';
         $this->message = JText::_('COM_CITRUSCART_SAVE_FAILED') . " - " . $row->getError();
     }
 }
コード例 #3
0
 /**
  * Sets the model's state
  *
  * @return array()
  */
 function _setModelState()
 {
     $state = parent::_setModelState();
     $app = JFactory::getApplication();
     $model = $this->getModel($this->get('suffix'));
     $ns = $this->getNamespace();
     $state['order'] = $app->getUserStateFromRequest($ns . '.filter_order', 'filter_order', 'o.created_date', 'cmd');
     $state['direction'] = $app->getUserStateFromRequest($ns . '.filter_direction', 'filter_direction', 'DESC', 'word');
     $state['filter_orderid'] = $app->getUserStateFromRequest($ns . 'filter_orderid', 'filter_orderid', '', '');
     $state['filter_type'] = $app->getUserStateFromRequest($ns . 'filter_type', 'filter_type', '', '');
     $state['filter_transaction'] = $app->getUserStateFromRequest($ns . 'filter_transaction', 'filter_transaction', '', '');
     $state['filter_product_name'] = $app->getUserStateFromRequest($ns . 'filter_product_name', 'filter_product_name', '', '');
     $state['filter_id_from'] = $app->getUserStateFromRequest($ns . 'id_from', 'filter_id_from', '', '');
     $state['filter_id_to'] = $app->getUserStateFromRequest($ns . 'id_to', 'filter_id_to', '', '');
     $state['filter_date_from'] = $app->getUserStateFromRequest($ns . 'date_from', 'filter_date_from', '', '');
     $state['filter_date_to'] = $app->getUserStateFromRequest($ns . 'date_to', 'filter_date_to', '', '');
     $state['filter_datetype'] = 'created';
     $state['filter_total_from'] = $app->getUserStateFromRequest($ns . 'filter_total_from', 'filter_total_from', '', '');
     $state['filter_total_to'] = $app->getUserStateFromRequest($ns . 'filter_total_to', 'filter_total_to', '', '');
     $state['filter_paymentstatus'] = $app->getUserStateFromRequest($ns . 'filter_paymentstatus', 'filter_paymentstatus', '', '');
     foreach ($state as $key => $value) {
         $model->setState($key, $value);
     }
     return $state;
 }
コード例 #4
0
ファイル: dashboard.php プロジェクト: joomlacorner/citruscart
 public function display($cachable = false, $urlparams = false)
 {
     $model = $this->getModel($this->get('suffix'));
     $state = $model->getState();
     $app = JFactory::getApplication();
     $state->stats_interval = $app->input->getString('stats_interval', 'last_thirty');
     $model->setState('stats_interval', $state->stats_interval);
     $cache = JFactory::getCache('com_citruscart');
     $cache->setCaching(true);
     $cache->setLifeTime('900');
     $orders = $cache->call(array($model, 'getOrdersChartData'), $state->stats_interval);
     //$models = JModelLegacy::getInstance( 'Dashboard', 'CitruscartModel' );
     //$models = JModelItem::getInstance('OrderItems', 'CitruscartModel');
     $models = JModelLegacy::getInstance('Dashboard', 'CitruscartModel');
     $totalorderitems = count($models->getOrderedItemsChartData());
     $revenue = $cache->call(array($model, 'getRevenueChartData'), $state->stats_interval);
     $total = $cache->call(array($model, 'getSumChartData'), $orders);
     $sum = $cache->call(array($model, 'getSumChartData'), $revenue);
     $interval = $model->getStatIntervalValues($state->stats_interval);
     //print_r($interval);
     $view = $this->getView($this->get('suffix'), 'html');
     $view->assign('orders', $orders);
     $view->assign('revenue', $revenue);
     $view->assign('total', $total);
     $view->assign('orderedItems', $totalorderitems);
     $view->assign('sum', $sum);
     $view->assign('interval', $interval);
     parent::display($cachable, $urlparams);
 }
コード例 #5
0
ファイル: catalog.php プロジェクト: joomlacorner/citruscart
 /**
  * constructor
  */
 function __construct()
 {
     parent::__construct();
     $app = JFactory::getApplication();
     $app->redirect("index.php?option=com_citruscart&view=products");
     return;
 }
コード例 #6
0
ファイル: credits.php プロジェクト: joomlacorner/citruscart
 /**
  * Sets the model's state
  *
  * @return array()
  */
 function _setModelState()
 {
     $state = parent::_setModelState();
     $app = JFactory::getApplication();
     $model = $this->getModel($this->get('suffix'));
     $ns = $this->getNamespace();
     $state['order'] = $app->getUserStateFromRequest($ns . '.filter_order', 'filter_order', 'tbl.created_date', 'cmd');
     $state['direction'] = $app->getUserStateFromRequest($ns . '.filter_direction', 'filter_direction', 'DESC', 'word');
     $state['filter_type'] = $app->getUserStateFromRequest($ns . 'filter_type', 'filter_type', '', '');
     $state['filter_enabled'] = $app->getUserStateFromRequest($ns . 'filter_enabled', 'filter_enabled', '', '');
     $state['filter_user'] = $app->getUserStateFromRequest($ns . 'user', 'filter_user', '', '');
     $state['filter_userid'] = $app->getUserStateFromRequest($ns . 'userid', 'filter_userid', '', '');
     $state['filter_id_from'] = $app->getUserStateFromRequest($ns . 'id_from', 'filter_id_from', '', '');
     $state['filter_id_to'] = $app->getUserStateFromRequest($ns . 'id_to', 'filter_id_to', '', '');
     $state['filter_amount_from'] = $app->getUserStateFromRequest($ns . 'filter_amount_from', 'filter_amount_from', '', '');
     $state['filter_amount_to'] = $app->getUserStateFromRequest($ns . 'filter_amount_to', 'filter_amount_to', '', '');
     $state['filter_date_from'] = $app->getUserStateFromRequest($ns . 'date_from', 'filter_date_from', '', '');
     $state['filter_date_to'] = $app->getUserStateFromRequest($ns . 'date_to', 'filter_date_to', '', '');
     $state['filter_datetype'] = $app->getUserStateFromRequest($ns . 'datetype', 'filter_datetype', '', '');
     $state['filter_withdraw'] = $app->getUserStateFromRequest($ns . 'withdraw', 'filter_withdraw', '', '');
     foreach ($state as $key => $value) {
         $model->setState($key, $value);
     }
     return $state;
 }
コード例 #7
0
ファイル: coupons.php プロジェクト: joomlacorner/citruscart
 /**
  * Loads view for assigning products to coupons
  *
  * @return unknown_type
  * @enterprise
  */
 function selectproducts()
 {
     $this->set('suffix', 'products');
     $state = parent::_setModelState();
     $app = JFactory::getApplication();
     $model = $this->getModel($this->get('suffix'));
     $ns = $this->getNamespace();
     $state['filter_category'] = $app->getUserStateFromRequest($ns . 'category', 'filter_category', '', '');
     foreach ($state as $key => $value) {
         $model->setState($key, $value);
     }
     //$id = JRequest::getInt( 'id', 0 );
     $id = $app->input->getInt('id', 0);
     $row = $model->getTable('coupons');
     $row->load($id);
     $view = $this->getView('coupons', 'html');
     $view->set('_controller', 'coupons');
     $view->set('_view', 'coupons');
     $view->set('_action', "index.php?option=com_citruscart&controller=coupons&task=selectproducts&tmpl=component&id=" . $id);
     $view->setModel($model, true);
     $view->assign('state', $model->getState());
     $view->assign('row', $row);
     $view->setLayout('selectproducts');
     $view->setTask(true);
     //JRequest::setVar( 'hidemainmenu', '1' );
     $app->input->set('hidemainmenu', '1');
     $view->display();
 }
コード例 #8
0
 /**
  * Loads view for assigning entities to attributes
  *
  * @return unknown_type
  */
 function selectentities()
 {
     $app = JFactory::getApplication();
     $type = $app->input->get('eaventity_type', 'products');
     //$type = JRequest::getVar('eaventity_type', 'products');
     $this->set('suffix', $type);
     $state = parent::_setModelState();
     $model = $this->getModel($this->get('suffix'));
     $ns = $this->getNamespace();
     foreach ($state as $key => $value) {
         $model->setState($key, $value);
     }
     $id = $app->input->get('id', 0);
     $row = $model->getTable('eavattributes');
     $row->load($id);
     $view = $this->getView('eavattributes', 'html');
     $view->set('_controller', 'eavattributes');
     $view->set('_view', 'eavattributes');
     $view->set('_action', "index.php?option=com_citruscart&controller=eavattributes&task=selectentities&tmpl=component&eaventity_type={$type}&id=" . $model->getId());
     $view->setModel($model, true);
     $view->assign('state', $model->getState());
     $view->assign('row', $row);
     $view->setLayout('select' . $type);
     $view->setTask(true);
     $view->display();
 }
コード例 #9
0
ファイル: orders.php プロジェクト: joomlacorner/citruscart
 /**
  * (non-PHPdoc)
  * @see Citruscart/admin/CitruscartController#display($cachable)
  */
 function display($cachable = false, $urlparams = '')
 {
     $app = JFactory::getApplication();
     if (empty(JFactory::getUser()->id)) {
         $url = JRoute::_("index.php?option=com_citruscart&view=orders");
         Citruscart::load("CitruscartHelperUser", 'helpers.user');
         $redirect = JRoute::_(CitruscartHelperUser::getUserLoginUrl($url), false);
         $app->redirect($redirect);
         return;
     }
     $model = $this->getModel($this->get('suffix'));
     $this->_setModelState();
     $config = Citruscart::getInstance();
     $model->setState('filter_orderstates', $config->get('orderstates_csv', '2, 3, 5, 17'));
     $list = $model->getList();
     $view = $this->getView('orders', 'html');
     $view->set('_controller', 'orders');
     $view->set('_view', 'orders');
     $view->set('_doTask', true);
     $view->set('hidemenu', false);
     $view->setModel($model, true);
     $view->setLayout('view');
     $app->input->set('view', $this->get('suffix'));
     $app->input->set('layout', 'default');
     parent::display($cachable, $urlparams);
 }
コード例 #10
0
 /**
  * delete the object and updates the product quantities
  */
 function delete()
 {
     $app = JFactory::getApplication();
     $this->message = '';
     $this->messagetype = '';
     $error = false;
     $cids = $app->input->get('cid', array(0), 'request', 'array');
     // Get the ProductQuantities model
     $qmodel = JModelLegacy::getInstance('ProductQuantities', 'CitruscartModel');
     // Filter the quantities
     $qmodel->setState('filter_attributes', implode(',', $cids));
     $quantities = $qmodel->getList();
     $qtable = $qmodel->getTable();
     // Delete the product quantities
     foreach ($quantities as $q) {
         if (!$qtable->delete($q->productquantity_id)) {
             $this->message .= $qtable->getError();
             $this->messagetype = 'notice';
             $error = true;
         }
     }
     if ($error) {
         $this->message = JText::_('COM_CITRUSCART_ERROR') . " - " . $this->message;
     } else {
         $this->message = JText::_('COM_CITRUSCART_ITEMS_DELETED');
     }
     // delete the option itself
     parent::delete();
 }
コード例 #11
0
ファイル: addresses.php プロジェクト: joomlacorner/citruscart
 /**
  * @return void
  */
 function edit()
 {
     $input = JFactory::getApplication()->input;
     $redirect = "index.php?option=com_citruscart&view=addresses";
     $redirect = JRoute::_($redirect, false);
     $user = JFactory::getUser();
     $model = $this->getModel($this->get('suffix'));
     $row = $model->getTable();
     $row->load($model->getId());
     if (empty($row)) {
         $row = JTable::getInstance('Addresses', 'CitruscartTable');
     }
     // if id is present then user is editing, check if user can edit this item
     if (!empty($row->address_id) && $row->user_id != JFactory::getUser()->id) {
         $this->message = JText::_('COM_CITRUSCART_CANNOT_EDIT_ADDRESS_NOTICE');
         $this->messagetype = 'notice';
         $this->setRedirect($redirect, $this->message, $this->messagetype);
         return;
     }
     // else creating new item
     $input->set('hidemainmenu', '1');
     $input->set('view', $this->get('suffix'));
     $input->set('layout', 'form');
     $view = $this->getView('addresses', 'html');
     $view->assign('form_inner', $this->getInnerAddressForm($row->address_id));
     parent::display();
 }
コード例 #12
0
ファイル: tools.php プロジェクト: joomlacorner/citruscart
 /**
  * Displays item
  * @return void
  */
 function view($cachable = false, $urlparams = false)
 {
     $model = $this->getModel($this->get('suffix'));
     $model->getId();
     $row = $model->getItem();
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         // Joomla! 1.6+ code here
         if (empty($row->enabled)) {
             $table = $model->getTable();
             $table->load($row->id);
             $table->enabled = 1;
             if ($table->save()) {
                 $redirect = "index.php?option=com_citruscart&view=" . $this->get('suffix') . "&task=view&id=" . $model->getId();
                 $redirect = JRoute::_($redirect, false);
                 $this->setRedirect($redirect);
                 return;
             }
         }
     } else {
         // Joomla! 1.5 code here
         if (empty($row->published)) {
             $table = $model->getTable();
             $table->load($row->id);
             $table->published = 1;
             if ($table->save()) {
                 $redirect = "index.php?option=com_citruscart&view=" . $this->get('suffix') . "&task=view&id=" . $model->getId();
                 $redirect = JRoute::_($redirect, false);
                 $this->setRedirect($redirect);
                 return;
             }
         }
     }
     parent::view($cachable, $urlparams);
 }
コード例 #13
0
ファイル: opc.php プロジェクト: joomlacorner/citruscart
 public function display($cachable = false, $urlparams = false)
 {
     $session = JFactory::getSession();
     $session->clear('citruscart.opc.method');
     $session->clear('citruscart.opc.billingAddress');
     $session->clear('citruscart.opc.shippingAddress');
     $session->clear('citruscart.opc.shippingRates');
     $session->clear('citruscart.opc.shippingMethod');
     $session->clear('citruscart.opc.userCoupons');
     $session->clear('citruscart.opc.userCredit');
     $session->clear('citruscart.opc.requireShipping');
     if (!$this->user->id) {
         $session->set('old_sessionid', $session->getId());
     }
     $view = $this->getView($this->get('suffix'), 'html');
     $view->setTask(true);
     $order = $this->_order;
     $order = $this->populateOrder();
     $view->assign('order', $order);
     $view->assign('user', $this->user);
     JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models');
     $model = JModelLegacy::getInstance('addresses', 'CitruscartModel');
     $model->setState("filter_userid", $this->user->id);
     $model->setState("filter_deleted", 0);
     $addresses = $model->getList();
     $view->assign('addresses', $addresses);
     $view->setModel($model);
     $showShipping = $order->isShippingRequired();
     $view->assign('showShipping', $showShipping);
     $session->set('citruscart.opc.requireShipping', serialize($showShipping));
     $view->assign('default_country', $this->default_country);
     $view->assign('default_country_id', $this->default_country_id);
     CitruscartController::display($cachable, $urlparams);
 }
コード例 #14
0
ファイル: accounts.php プロジェクト: joomlacorner/citruscart
 /**
  * @return void
  */
 function edit()
 {
     $input = JFactory::getApplication()->input;
     $model = $this->getModel($this->get('suffix'));
     $row = $model->getTable();
     $row->load(array('user_id' => JFactory::getUser()->id));
     $input->set('id', $row->user_info_id);
     $input->set('view', 'accounts');
     $input->set('layout', 'form');
     parent::display();
 }
コード例 #15
0
 /**
  * (non-PHPdoc)
  * @see Citruscart/Citruscart/site/CitruscartController::display()
  */
 function display($cachable = false, $urlparams = false)
 {
     $app = JFactory::getApplication();
     $this->hidefooter = true;
     $object = $app->input->get('object');
     //$object = JRequest::getVar('object');
     $view = $this->getView($this->get('suffix'), 'html');
     $view->assign('object', $object);
     $view->setTask(true);
     parent::display($cachable, $urlparams);
 }
コード例 #16
0
ファイル: dashboard.php プロジェクト: joomlacorner/citruscart
 /**
  * constructor
  */
 function __construct()
 {
     if (empty(JFactory::getUser()->id)) {
         $url = JRoute::_("index.php?option=com_citruscart&view=dashboard");
         Citruscart::load("CitruscartHelperUser", 'helpers.user');
         $redirect = JRoute::_(CitruscartHelperUser::getUserLoginUrl($url), false);
         JFactory::getApplication()->redirect($redirect);
         return;
     }
     parent::__construct();
     $this->set('suffix', 'dashboard');
 }
コード例 #17
0
ファイル: addresses.php プロジェクト: joomlacorner/citruscart
 /**
  * @Sets the model's state
  *
  * @return array()
  */
 function _setModelState()
 {
     $state = parent::_setModelState();
     $app = JFactory::getApplication();
     $model = $this->getModel($this->get('suffix'));
     $ns = $this->getNamespace();
     $state['filter_userid'] = $app->getUserStateFromRequest($ns . 'userid', 'filter_userid', '', '');
     $state['filter_user'] = $app->getUserStateFromRequest($ns . 'user', 'filter_user', '', '');
     $state['filter_address'] = $app->getUserStateFromRequest($ns . 'address', 'filter_address', '', '');
     foreach ($state as $key => $value) {
         $model->setState($key, $value);
     }
     return $state;
 }
コード例 #18
0
 /**
  * Sets the model's state
  *
  * @return array()
  */
 function _setModelState()
 {
     $state = parent::_setModelState();
     $app = JFactory::getApplication();
     $model = $this->getModel($this->get('suffix'));
     $ns = $this->getNamespace();
     $state['filter_id_from'] = $app->getUserStateFromRequest($ns . 'id_from', 'filter_id_from', '', '');
     $state['filter_id_to'] = $app->getUserStateFromRequest($ns . 'id_to', 'filter_id_to', '', '');
     $state['filter_name'] = $app->getUserStateFromRequest($ns . 'name', 'filter_name', '', '');
     $state['filter_code'] = $app->getUserStateFromRequest($ns . 'code', 'filter_code', '', '');
     foreach ($state as $key => $value) {
         $model->setState($key, $value);
     }
     return $state;
 }
コード例 #19
0
 /**
  * Sets the model's state
  *
  * @return array()
  */
 function _setModelState()
 {
     $state = parent::_setModelState();
     $model = $this->getModel($this->get('suffix'));
     $user = JFactory::getUser();
     $state['filter_user'] = $user->id;
     if (empty($user->id)) {
         $session = JFactory::getSession();
         $state['filter_session'] = $session->getId();
     }
     foreach ($state as $key => $value) {
         $model->setState($key, $value);
     }
     return $state;
 }
コード例 #20
0
ファイル: zones.php プロジェクト: joomlacorner/citruscart
 /**
  * Sets the model's state
  *
  * @return array()
  */
 function _setModelState()
 {
     $state = parent::_setModelState();
     $app = JFactory::getApplication();
     $model = $this->getModel($this->get('suffix'));
     $ns = $this->getNamespace();
     $state['order'] = $app->getUserStateFromRequest($ns . '.filter_order', 'filter_order', 'c.country_name', 'cmd');
     $state['filter_id_from'] = $app->getUserStateFromRequest($ns . 'id_from', 'filter_id_from', '', '');
     $state['filter_id_to'] = $app->getUserStateFromRequest($ns . 'id_to', 'filter_id_to', '', '');
     $state['filter_name'] = $app->getUserStateFromRequest($ns . 'name', 'filter_name', '', '');
     $state['filter_code'] = $app->getUserStateFromRequest($ns . 'code', 'filter_code', '', '');
     $state['filter_countryid'] = $app->getUserStateFromRequest($ns . 'countryid', 'filter_countryid', '', '');
     foreach ($state as $key => $value) {
         $model->setState($key, $value);
     }
     $query = $model->getQuery();
     $query->order('tbl.zone_name');
     $model->setQuery($query);
     return $state;
 }
コード例 #21
0
ファイル: search.php プロジェクト: joomlacorner/citruscart
 /**
  * Displays search results
  *
  * (non-PHPdoc)
  * @see Citruscart/admin/CitruscartController#display($cachable)
  */
 function display($cachable = false, $urlparams = false)
 {
     $input = JFactory::getApplication()->input;
     $input->set('view', $this->get('suffix'));
     $view = $this->getView($this->get('suffix'), JFactory::getDocument()->getType());
     $model = $this->getModel($this->get('suffix'));
     $this->_setModelState();
     if ($items = $model->getList()) {
         foreach ($items as $row) {
             $row->category_id = 0;
             $categories = Citruscart::getClass('CitruscartHelperProduct', 'helpers.product')->getCategories($row->product_id);
             if (!empty($categories)) {
                 $row->category_id = $categories[0];
             }
             $itemid = Citruscart::getClass("CitruscartHelperRoute", 'helpers.route')->product($row->product_id, $row->category_id, true);
             $row->itemid = empty($itemid) ? $input->getInt('Itemid') : $itemid;
         }
     }
     parent::display($cachable, $urlparams);
 }
コード例 #22
0
ファイル: users.php プロジェクト: joomlacorner/citruscart
 /**
  * Sets the model's state
  *
  * @return array()
  */
 function _setModelState()
 {
     $state = parent::_setModelState();
     $app = JFactory::getApplication();
     $model = $this->getModel($this->get('suffix'));
     $ns = $this->getNamespace();
     $state['filter_id_from'] = $app->getUserStateFromRequest($ns . 'id_from', 'filter_id_from', '', '');
     $state['filter_id_to'] = $app->getUserStateFromRequest($ns . 'id_to', 'filter_id_to', '', '');
     $state['filter_name'] = $app->getUserStateFromRequest($ns . 'name', 'filter_name', '', '');
     $state['filter_username'] = $app->getUserStateFromRequest($ns . 'username', 'filter_username', '', '');
     $state['filter_email'] = $app->getUserStateFromRequest($ns . 'email', 'filter_email', '', '');
     $state['filter_group'] = $app->getUserStateFromRequest($ns . 'group', 'filter_group', '', '');
     if (Citruscart::getInstance()->get('display_subnum', 0)) {
         $state['filter_subnum'] = $app->getUserStateFromRequest($ns . 'subnum', 'filter_subnum', '', '');
     }
     foreach ($state as $key => $value) {
         $model->setState($key, $value);
     }
     return $state;
 }
コード例 #23
0
ファイル: carts.php プロジェクト: joomlacorner/citruscart
 /**
  * Sets the model's state
  *
  * @return array()
  */
 function _setModelState()
 {
     $state = parent::_setModelState();
     $app = JFactory::getApplication();
     $model = $this->getModel($this->get('suffix'));
     $ns = $this->getNamespace();
     $session = JFactory::getSession();
     $user = JFactory::getUser();
     $state['filter_user'] = $user->id;
     if (empty($user->id)) {
         $state['filter_session'] = $session->getId();
     }
     Citruscart::load('CitruscartHelperUser', 'helpers.user');
     $filter_group = CitruscartHelperUser::getUserGroup($user->id);
     $state['filter_group'] = $filter_group;
     foreach (@$state as $key => $value) {
         $model->setState($key, $value);
     }
     return $state;
 }
コード例 #24
0
 /**
  *
  * @return unknown_type
  */
 function _setModelState()
 {
     $state = parent::_setModelState();
     $app = JFactory::getApplication();
     $model = $this->getModel($this->get('suffix'));
     $ns = $this->getNamespace();
     $config = Citruscart::getInstance();
     // adjust offset for when filter has changed
     if ($app->getUserState($ns . 'product_id') != $app->getUserStateFromRequest($ns . 'product_id', 'filter_product_id', '', '')) {
         $state['limitstart'] = '0';
     }
     $state['order'] = $app->getUserStateFromRequest($ns . '.filter_order', 'filter_order', 'tbl.productdownload_startdate', 'cmd');
     $state['direction'] = $app->getUserStateFromRequest($ns . '.filter_direction', 'filter_direction', 'DESC', 'word');
     $state['filter_product_id'] = $app->getUserStateFromRequest($ns . 'product_id', 'filter_product_id', '', 'integer');
     $state['filter_user'] = JFactory::getUser()->id;
     $state['filter'] = $app->getUserStateFromRequest($ns . 'filter', 'filter', '', 'word');
     foreach ($state as $key => $value) {
         $model->setState($key, $value);
     }
     return $state;
 }
コード例 #25
0
 function setrates()
 {
     $this->set('suffix', 'shippingrates');
     $state = parent::_setModelState();
     $app = JFactory::getApplication();
     $model = $this->getModel($this->get('suffix'));
     $ns = $this->getNamespace();
     foreach ($state as $key => $value) {
         $model->setState($key, $value);
     }
     $row = JTable::getInstance('ShippingMethods', 'CitruscartTable');
     $row->load($model->getId());
     $model->setState('filter_shippingmethod', $model->getId());
     $view = $this->getView('shippingrates', 'html');
     $view->set('_controller', 'shippingmethods');
     $view->set('_view', 'shippingmethods');
     $view->set('_action', "index.php?option=com_citruscart&controller=shippingmethods&task=setrates&id={$model->getId()}&tmpl=component");
     $view->setModel($model, true);
     $view->assign('state', $model->getState());
     $view->assign('row', $row);
     $view->setLayout('default');
     $view->setTask(true);
     $view->display();
 }
コード例 #26
0
ファイル: checkout.php プロジェクト: joomlacorner/citruscart
 /**
  * (non-PHPdoc)
  *
  * see citruscart/site/CitruscartController#view()
  */
 function display($cachable = false, $urlparams = false)
 {
     $app = JFactory::getApplication();
     $input = JFactory::getApplication()->input;
     $user = $this->user;
     $input->set('view', $this->get('suffix'));
     //check if we have one page checkout
     if ($this->onepage_checkout) {
         if (!$user->id) {
             $session = JFactory::getSession();
             $session->set('old_sessionid', $session->getId());
         }
         // Display the onepage checkout view
         $opc_layout = $this->defines->get('one_page_checkout_layout', 'onepage-opc');
         $input->set('layout', $opc_layout);
         $view = $this->getView($this->get('suffix'), 'html');
         $order = $this->_order;
         $order = $this->populateOrder();
         //get order summarry
         $html = $this->getOrderSummary();
         $view->assign('orderSummary', $html);
         $view->assign('order', $order);
         $view->setTask(true);
         $view->assign('user', $user);
         if (!$user->id) {
             $view->form_user_register = $this->getAdditionalInfoUser();
         }
         //get addresses
         JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models');
         $model = JModelLegacy::getInstance('addresses', 'CitruscartModel');
         $model->setState("filter_userid", $this->user->id);
         $model->setState("filter_deleted", 0);
         $addresses = $model->getList();
         // Checking whether shipping is required
         $showShipping = false;
         $cartsModel = $this->getModel('carts');
         if ($isShippingEnabled = $cartsModel->getShippingIsEnabled()) {
             $showShipping = true;
         }
         $billingAddress = $order->getBillingAddress();
         $billing_address_form = $this->getAddressForm($this->billing_input_prefix, !$user->id);
         $view->assign('billing_address_form', $billing_address_form);
         $view->assign('showShipping', $showShipping);
         $view->assign('billing_address', $billingAddress);
         if ($showShipping) {
             $shippingAddress = $order->getShippingAddress();
             $shipping_address_form = $this->getAddressForm($this->shipping_input_prefix, !$user->id, true);
             $view->assign('shipping_address', $shippingAddress);
             $view->assign('shipping_address_form', $shipping_address_form);
         }
         Citruscart::load('CitruscartHelperPlugin', 'helpers.plugin');
         $dispatcher = JDispatcher::getInstance();
         JPluginHelper::importPlugin('citruscart');
         if ($showShipping) {
             $rates = $this->getShippingRates();
             $default_rate = array();
             if (count($rates) == 1) {
                 $default_rate = $rates[0];
             }
             $shipping_layout = "shipping_yes";
             if (empty($shippingAddress)) {
                 $shipping_layout = "shipping_calculate";
             }
             $shipping_method_form = $this->getShippingHtml($shipping_layout);
             $view->assign('showShipping', $showShipping);
             $view->assign('shipping_method_form', $shipping_method_form);
             $view->assign('rates', $rates);
         }
         $view->assign('payment_options_html', $this->getPaymentOptionsHtml());
         $view->assign('order', $order);
         // are there any enabled coupons?
         $coupons_present = false;
         $model = JModelLegacy::getInstance('Coupons', 'CitruscartModel');
         $model->setState('filter_enabled', '1');
         if ($coupons = $model->getList()) {
             $coupons_present = true;
         }
         $view->assign('coupons_present', $coupons_present);
         // assign userinfo for credits
         $userinfo = JTable::getInstance('UserInfo', 'CitruscartTable');
         $userinfo->load(array('user_id' => $this->user->id));
         $userinfo->credits_total = (double) $userinfo->credits_total;
         $view->assign('userinfo', $userinfo);
         $view->assign('addresses', $addresses);
         $dispatcher = JDispatcher::getInstance();
         ob_start();
         $app->triggerEvent('onBeforeDisplaySelectPayment', array($order));
         $view->assign('onBeforeDisplaySelectPayment', ob_get_contents());
         ob_end_clean();
         ob_start();
         $app->triggerEvent('onAfterDisplaySelectPayment', array($order));
         $view->assign('onAfterDisplaySelectPayment', ob_get_contents());
         ob_end_clean();
     } else {
         $guest_var = $input->getInt('guest', '0');
         $guest = false;
         if ($guest_var == '1') {
             $guest = true;
         }
         $register_var = $input->getInt('register', '0');
         $form_register = '';
         $register = false;
         if ($register_var == '1') {
             $register = true;
             $form_register = $this->getRegisterForm();
         }
         // determine layout based on login status
         // Login / Register / Checkout as a guest
         if (empty($user->id) && !($guest || $register)) {
             // Display a form for selecting either to register or to login
             $input->set('layout', 'form');
             Citruscart::load("CitruscartHelperRoute", 'helpers.route');
             $helper = new CitruscartHelperRoute();
             $view = $this->getView('checkout', 'html');
             $checkout_itemid = $helper->findItemid(array('view' => 'checkout'));
             if (empty($checkout_itemid)) {
                 $checkout_itemid = $input->getInt('Itemid');
             }
             $view->assign('checkout_itemid', $checkout_itemid);
             parent::display();
             return;
         }
         if ($guest && $this->defines->get('guest_checkout_enabled') || $register) {
             // Checkout as a Guest
             $order = $this->_order;
             $order = $this->populateOrder(true);
             // now that the order object is set, get the orderSummary html
             $html = $this->getOrderSummary();
             // Get the current step
             $progress = $this->getProgress();
             // get address forms
             $billing_address_form = $this->getAddressForm($this->billing_input_prefix, true);
             $shipping_address_form = $this->getAddressForm($this->shipping_input_prefix, true, true);
             // get all the enabled shipping plugins
             Citruscart::load('CitruscartHelperPlugin', 'helpers.plugin');
             $plugins = CitruscartHelperPlugin::getPluginsWithEvent('onGetShippingPlugins');
             $dispatcher = JDispatcher::getInstance();
             JPluginHelper::importPlugin('citruscart');
             $rates = array();
             if ($plugins) {
                 foreach ($plugins as $plugin) {
                     $results = JFactory::getApplication()->triggerEvent("onGetShippingRates", array($plugin->element, $order));
                     foreach ($results as $result) {
                         if (is_array($result)) {
                             foreach ($result as $r) {
                                 $rates[] = $r;
                             }
                         }
                     }
                     // endforeach results
                 }
                 // endforeach plugins
             }
             // endif plugins
             // now display the entire checkout page
             $view = $this->getView('checkout', 'html');
             $view->set('hidemenu', false);
             $view->assign('order', $order);
             $view->assign('register', $register);
             $view->assign('form_register', $form_register);
             $view->assign('billing_address_form', $billing_address_form);
             $view->assign('shipping_address_form', $shipping_address_form);
             $view->assign('orderSummary', $html);
             $view->assign('progress', $progress);
             //$view->assign( 'default_billing_address', $default_billing_address );
             //$view->assign( 'default_shipping_address', $default_shipping_address );
             $view->assign('rates', $rates);
             // Checking whether shipping is required
             $showShipping = false;
             $shipping_layout = "shipping_no";
             $cartsModel = $this->getModel('carts');
             if ($isShippingEnabled = $cartsModel->getShippingIsEnabled()) {
                 $showShipping = true;
             }
             if ($showShipping) {
                 $shipping_layout = "shipping_yes";
                 if (empty($shippingAddress)) {
                     $shipping_layout = "shipping_calculate";
                 }
             }
             $shipping_method_form = $this->getShippingHtml($shipping_layout);
             $view->assign('showShipping', $showShipping);
             $view->assign('shipping_method_form', $shipping_method_form);
             $input->set('layout', 'guest');
         } else {
             // Already Logged in, a traditional checkout
             $order = $this->_order;
             $order = $this->populateOrder(false);
             // now that the order object is set, get the orderSummary html
             $html = $this->getOrderSummary();
             // Get the current step
             $progress = $this->getProgress();
             $user_id = $this->user->id;
             $addresses = array();
             JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models');
             $model = JModelLegacy::getInstance('addresses', 'CitruscartModel');
             if (!empty($user_id)) {
                 $model->setState("filter_userid", $user_id);
                 $model->setState("filter_deleted", 0);
                 $addresses = $model->getList();
             }
             $billingAddress = $order->getBillingAddress();
             $shippingAddress = $order->getShippingAddress();
             // get address forms
             $billing_address_form = $this->getAddressForm($this->billing_input_prefix);
             $shipping_address_form = $this->getAddressForm($this->shipping_input_prefix, false, true);
             // get the default shipping and billing addresses, if possible
             $default_billing_address = $this->getAddressHtml($billingAddress->address_id);
             $default_shipping_address = $this->getAddressHtml($shippingAddress->address_id);
             // now display the entire checkout page
             $view = $this->getView('checkout', 'html');
             $view->set('hidemenu', false);
             $view->assign('order', $order);
             $view->assign('addresses', $addresses);
             $view->assign('billing_address', $billingAddress);
             $view->assign('shipping_address', $shippingAddress);
             $view->assign('billing_address_form', $billing_address_form);
             $view->assign('shipping_address_form', $shipping_address_form);
             $view->assign('orderSummary', $html);
             $view->assign('progress', $progress);
             $view->assign('default_billing_address', $default_billing_address);
             $view->assign('default_shipping_address', $default_shipping_address);
             // Check whether shipping is required
             $showShipping = false;
             $shipping_layout = "shipping_no";
             $cartsModel = $this->getModel('carts');
             if ($isShippingEnabled = $cartsModel->getShippingIsEnabled()) {
                 $showShipping = true;
             }
             if ($showShipping) {
                 $shipping_layout = "shipping_yes";
                 if (empty($shippingAddress)) {
                     $shipping_layout = "shipping_calculate";
                 }
             }
             $shipping_method_form = $this->getShippingHtml($shipping_layout);
             $view->assign('showShipping', $showShipping);
             $view->assign('shipping_method_form', $shipping_method_form);
             $input->set('layout', 'default');
         }
         $dispatcher = JDispatcher::getInstance();
         ob_start();
         JFactory::getApplication()->triggerEvent('onBeforeDisplaySelectShipping', array($order));
         $view->assign('onBeforeDisplaySelectShipping', ob_get_contents());
         ob_end_clean();
         ob_start();
         JFactory::getApplication()->triggerEvent('onAfterDisplaySelectShipping', array($order));
         $view->assign('onAfterDisplaySelectShipping', ob_get_contents());
         ob_end_clean();
     }
     $view->setTask(true);
     $view->assign('default_country', $this->default_country);
     $view->assign('default_country_id', $this->default_country_id);
     parent::display();
     return;
 }
コード例 #27
0
ファイル: shipping.php プロジェクト: joomlacorner/citruscart
 /**
  * Will execute a task within a shipping plugin
  *
  * (non-PHPdoc)
  * @see application/component/JController::execute()
  */
 function execute($task)
 {
     $app = JFactory::getApplication();
     $shippingTask = $app->input->getString('shippingTask');
     // Check if we are in a shipping method view. If it is so,
     // Try lo load the shipping plugin controller (if any)
     if ($task == "view" && $shippingTask != '') {
         $model = $this->getModel('Shipping', 'CitruscartModel');
         $id = $app->input->getInt('id', 0);
         if (!$id) {
             parent::execute($task);
         }
         $model->setId($id);
         // get the data
         // not using getItem here to enable ->checkout (which requires JTable object)
         $row = $model->getTable();
         $row->load((int) $model->getId());
         $element = $row->element;
         // The name of the Shipping Controller should be the same of the $_element name,
         // without the shipping_ prefix and with the first letter Uppercase, and should
         // be placed into a controller.php file inside the root of the plugin
         // Ex: shipping_standard => CitruscartControllerShippingStandard in shipping_standard/controller.php
         $controllerName = str_ireplace('shipping_', '', $element);
         $controllerName = ucfirst($controllerName);
         $path = JPATH_SITE . '/plugins/citruscart/';
         if (version_compare(JVERSION, '1.6.0', 'ge')) {
             // Joomla! 1.6+ code here
             $controllerPath = $path . $element . '/' . $element . '/controller.php';
         } else {
             // Joomla! 1.5 code here
             $controllerPath = $path . $element . '/controller.php';
         }
         if (file_exists($controllerPath)) {
             require_once $controllerPath;
         } else {
             $controllerName = '';
         }
         $className = 'CitruscartControllerShipping' . $controllerName;
         if ($controllerName != '' && class_exists($className)) {
             // Create the controller
             $controller = new $className();
             // Add the view Path
             //$controller->addViewPath($path);
             $controller->addViewPath($path);
             // Perform the requested task
             $controller->execute($shippingTask);
             // Redirect if set by the controller
             $controller->redirect();
         } else {
             parent::execute($task);
         }
     } else {
         parent::execute($task);
     }
 }
コード例 #28
0
 /**
  * constructor
  */
 function __construct()
 {
     parent::__construct();
     $this->set('suffix', 'shippingrates');
 }
コード例 #29
0
 /**
  * constructor
  */
 function __construct()
 {
     parent::__construct();
     $this->set('suffix', 'productattributes');
 }
コード例 #30
0
ファイル: geozones.php プロジェクト: joomlacorner/citruscart
 /**
  * Method to assign payment/shipping methods to the geozones
  */
 function selectplugins()
 {
     $app = JFactory::getApplication();
     $type = $app->input->get('type');
     Citruscart::load("CitruscartHelperPlugin", 'helpers.plugin');
     $suffix = CitruscartHelperPlugin::getSuffix($type);
     $state = parent::_setModelState();
     $app = JFactory::getApplication();
     $model = $this->getModel($suffix);
     $ns = $app->getName() . '::' . 'com.citruscart.model.' . $model->getTable()->get('_suffix');
     $id = $app->input->get('id', 0);
     $row = $model->getTable('geozones');
     $row->load($id);
     $state['filter_enabled'] = '1';
     $state['filter_name'] = $app->getUserStateFromRequest($ns . 'name', 'filter_name', '', '');
     $state['order'] = $app->getUserStateFromRequest($ns . '.filter_order', 'filter_order', 'tbl.name', 'cmd');
     foreach ($state as $key => $value) {
         $model->setState($key, $value);
     }
     $view = $this->getView('geozones', 'html');
     $view->set('_controller', 'geozones');
     $view->set('_view', 'geozones');
     $view->set('leftMenu', false);
     $view->set('_action', "index.php?option=com_citruscart&controller=geozones&task=selectplugins&type={$type}&tmpl=component&id=" . $model->getId());
     $view->setModel($model, true);
     $items = $model->getList();
     foreach ($items as $item) {
         $params = new DSCParameter($item->params);
         $item->geozones = explode(',', $params->get('geozones'));
     }
     $view->assign('suffix', $suffix);
     $view->assign('state', $model->getState());
     $view->assign('row', $row);
     $view->setLayout('selectplugins');
     $view->setTask(true);
     $view->display();
 }