| @@ -12,17 +12,18 @@ | ||
| 12 | 12 | |
| 13 | 13 | // import Joomla view library |
| 14 | 14 | jimport('joomla.application.component.view'); |
| 15 | 15 | |
| 16 | -class VikBookingViewPrices extends JViewVikBooking { | |
| 17 | - | |
| 18 | - function display($tpl = null) { | |
| 16 | +class VikBookingViewPrices extends JViewVikBooking | |
| 17 | +{ | |
| 18 | + public function display($tpl = null) | |
| 19 | + { | |
| 19 | 20 | // Set the toolbar |
| 20 | 21 | $this->addToolBar(); |
| 21 | 22 | |
| 22 | 23 | $navbut = ""; |
| 24 | + $app = JFactory::getApplication(); | |
| 23 | 25 | $dbo = JFactory::getDbo(); |
| 24 | - $mainframe = JFactory::getApplication(); | |
| 25 | 26 | |
| 26 | 27 | // wizard |
| 27 | 28 | $wizard = VikRequest::getInt('wizard', 0, 'request'); |
| 28 | 29 | $rplanpub1 = VikRequest::getInt('rplanpub1', 0, 'request'); |
| @@ -29,8 +30,11 @@ | ||
| 29 | 30 | $rplanpub2 = VikRequest::getInt('rplanpub2', 0, 'request'); |
| 30 | 31 | $rplanbk1 = VikRequest::getInt('rplanbk1', 0, 'request'); |
| 31 | 32 | $rplanbk2 = VikRequest::getInt('rplanbk2', 0, 'request'); |
| 32 | 33 | if ($wizard) { |
| 34 | + if (!JSession::checkToken()) { | |
| 35 | + throw new Exception(JText::translate('JINVALID_TOKEN'), 403); | |
| 36 | + } | |
| 33 | 37 | if ($rplanpub1) { |
| 34 | 38 | $q = "INSERT INTO `#__vikbooking_prices` (`name`, `idiva`, `breakfast_included`, `free_cancellation`, `minlos`) VALUES (" . $dbo->quote(JText::translate('VBOSTANDARDRATE')) . ", 0, $rplanbk1, 1, 0);"; |
| 35 | 39 | $dbo->setQuery($q); |
| 36 | 40 | $dbo->execute(); |
| @@ -39,16 +43,15 @@ | ||
| 39 | 43 | $q = "INSERT INTO `#__vikbooking_prices` (`name`, `idiva`, `breakfast_included`, `free_cancellation`, `canc_deadline`, `minlos`) VALUES (" . $dbo->quote(JText::translate('VBONONREFRATE')) . ", 0, $rplanbk2, 0, 7, 0);"; |
| 40 | 44 | $dbo->setQuery($q); |
| 41 | 45 | $dbo->execute(); |
| 42 | 46 | } |
| 43 | - $mainframe->redirect('index.php?option=com_vikbooking&wizard=1'); | |
| 47 | + $app->redirect('index.php?option=com_vikbooking&wizard=1'); | |
| 44 | 48 | exit; |
| 45 | 49 | } |
| 46 | - // | |
| 47 | - | |
| 48 | - $lim = $mainframe->getUserStateFromRequest("com_vikbooking.limit", 'limit', $mainframe->get('list_limit'), 'int'); | |
| 50 | + | |
| 51 | + $lim = $app->getUserStateFromRequest("com_vikbooking.limit", 'limit', $app->get('list_limit'), 'int'); | |
| 49 | 52 | $lim0 = VikRequest::getVar('limitstart', 0, '', 'int'); |
| 50 | - $q = "SELECT SQL_CALC_FOUND_ROWS * FROM `#__vikbooking_prices`"; | |
| 53 | + $q = "SELECT SQL_CALC_FOUND_ROWS * FROM `#__vikbooking_prices` ORDER BY `derived_id` ASC, `id` ASC"; | |
| 51 | 54 | $dbo->setQuery($q, $lim0, $lim); |
| 52 | 55 | $rows = $dbo->loadAssocList(); |
| 53 | 56 | if ($rows) { |
| 54 | 57 | $dbo->setQuery('SELECT FOUND_ROWS();'); |
| @@ -55,13 +58,13 @@ | ||
| 55 | 58 | jimport('joomla.html.pagination'); |
| 56 | 59 | $pageNav = new JPagination( $dbo->loadResult(), $lim0, $lim ); |
| 57 | 60 | $navbut="<table align=\"center\"><tr><td>".$pageNav->getListFooter()."</td></tr></table>"; |
| 58 | 61 | } |
| 59 | - | |
| 62 | + | |
| 60 | 63 | $this->rows = $rows; |
| 61 | 64 | $this->lim0 = $lim0; |
| 62 | 65 | $this->navbut = $navbut; |
| 63 | - | |
| 66 | + | |
| 64 | 67 | // Display the template |
| 65 | 68 | parent::display($tpl); |
| 66 | 69 | } |
| 67 | 70 | |
| @@ -67,9 +70,10 @@ | ||
| 67 | 70 | |
| 68 | 71 | /** |
| 69 | 72 | * Sets the toolbar |
| 70 | 73 | */ |
| 71 | - protected function addToolBar() { | |
| 74 | + protected function addToolBar() | |
| 75 | + { | |
| 72 | 76 | JToolBarHelper::title(JText::translate('VBMAINPRICETITLE'), 'vikbooking'); |
| 73 | 77 | if (JFactory::getUser()->authorise('core.create', 'com_vikbooking')) { |
| 74 | 78 | JToolBarHelper::addNew('newprice', JText::translate('VBMAINPRICENEW')); |
| 75 | 79 | JToolBarHelper::spacer(); |
| @@ -82,6 +86,5 @@ | ||
| 82 | 86 | JToolBarHelper::deleteList(JText::translate('VBDELCONFIRM'), 'removeprice', JText::translate('VBMAINPRICEDEL')); |
| 83 | 87 | JToolBarHelper::spacer(); |
| 84 | 88 | } |
| 85 | 89 | } |
| 86 | - | |
| 87 | 90 | } |