analytics.php
4 years ago
apiban.php
4 years ago
apilog.php
4 years ago
apiplugin.php
4 years ago
apiuser.php
4 years ago
backup.php
4 years ago
calendar.php
4 years ago
city.php
4 years ago
closure.php
1 month ago
configapp.php
4 years ago
configcldays.php
2 years ago
configcron.php
4 years ago
configemp.php
4 years ago
configsmsapi.php
4 years ago
configuration.php
1 month ago
conversion.php
1 year ago
country.php
4 years ago
coupon.php
4 years ago
coupongroup.php
4 years ago
cronjob.php
2 years ago
cronjoblog.php
4 years ago
customer.php
5 months ago
customf.php
1 year ago
dashboard.php
4 years ago
emplocwdays.php
4 years ago
employee.php
1 year ago
emprates.php
4 years ago
export.php
4 years ago
exportres.php
4 years ago
file.php
5 months ago
findreservation.php
1 month ago
group.php
4 years ago
import.php
4 years ago
index.html
4 years ago
invoice.php
1 month ago
langcustomf.php
4 years ago
langemployee.php
4 years ago
langgroup.php
4 years ago
langmedia.php
4 years ago
langoption.php
4 years ago
langoptiongroup.php
4 years ago
langpackage.php
4 years ago
langpackgroup.php
4 years ago
langpayment.php
4 years ago
langservice.php
4 years ago
langstatuscode.php
4 years ago
langsubscr.php
4 years ago
langtax.php
4 years ago
location.php
4 years ago
mailtext.php
2 years ago
makerecurrence.php
1 month ago
media.php
4 years ago
multiorder.php
4 years ago
option.php
5 months ago
optiongroup.php
4 years ago
package.php
2 years ago
packgroup.php
4 years ago
packorder.php
1 year ago
payment.php
4 years ago
rate.php
4 years ago
reportsemp.php
4 years ago
reportsser.php
4 years ago
reservation.php
1 month ago
restriction.php
4 years ago
review.php
4 years ago
service.php
1 year ago
serworkday.php
5 months ago
state.php
4 years ago
statuscode.php
4 years ago
subscription.php
4 years ago
subscrorder.php
4 years ago
tag.php
4 years ago
tax.php
4 years ago
usernote.php
4 years ago
waitinglist.php
4 years ago
webhook.php
4 years ago
wizard.php
1 year ago
export.php
134 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package VikAppointments |
| 4 | * @subpackage core |
| 5 | * @author E4J s.r.l. |
| 6 | * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved. |
| 7 | * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL |
| 8 | * @link https://vikwp.com |
| 9 | */ |
| 10 | |
| 11 | // No direct access |
| 12 | defined('ABSPATH') or die('No script kiddies please!'); |
| 13 | |
| 14 | VAPLoader::import('libraries.mvc.controllers.admin'); |
| 15 | |
| 16 | /** |
| 17 | * VikAppointments export controller. |
| 18 | * |
| 19 | * @since 1.7 |
| 20 | */ |
| 21 | class VikAppointmentsControllerExport extends VAPControllerAdmin |
| 22 | { |
| 23 | /** |
| 24 | * Downloads a sample file for the requested import type. |
| 25 | * |
| 26 | * @return void |
| 27 | */ |
| 28 | public function download() |
| 29 | { |
| 30 | $app = JFactory::getApplication(); |
| 31 | $input = $app->input; |
| 32 | |
| 33 | /** |
| 34 | * Added token validation. |
| 35 | * |
| 36 | * @since 1.7 |
| 37 | */ |
| 38 | if (!JSession::checkToken()) |
| 39 | { |
| 40 | // raise error, missing CSRF-proof token |
| 41 | throw new Exception(JText::translate('JINVALID_TOKEN'), 403); |
| 42 | } |
| 43 | |
| 44 | $type = $input->getString('import_type'); |
| 45 | $class = $input->getString('export_class'); |
| 46 | $name = $input->getString('filename'); |
| 47 | |
| 48 | VAPLoader::import('libraries.import.factory'); |
| 49 | |
| 50 | // get object handler |
| 51 | $handler = ImportFactory::getObject($type); |
| 52 | |
| 53 | if (!$handler) |
| 54 | { |
| 55 | throw new Exception('Import type not supported.', 404); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Load list of columns to export and raw format. |
| 60 | * |
| 61 | * @since 1.7 |
| 62 | */ |
| 63 | $options = array(); |
| 64 | $options['columns'] = $input->getString('columns', array()); |
| 65 | $options['raw'] = $input->getBool('raw', false); |
| 66 | |
| 67 | // Inject driver parameters within options array. |
| 68 | // Drivers must take care of not using any reserved keys. |
| 69 | $options = array_merge($options, $input->get('import_args', array(), 'array')); |
| 70 | |
| 71 | // get export handler |
| 72 | $exportable = ImportFactory::getExportable($class, $options); |
| 73 | |
| 74 | if (!$exportable) |
| 75 | { |
| 76 | throw new Exception('Export handler not supported.', 404); |
| 77 | } |
| 78 | |
| 79 | // finalise export using the specified class |
| 80 | $handler->export($exportable, $name); |
| 81 | |
| 82 | // terminate request |
| 83 | $app->close(); |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Returns a form including the parameters of the requested export driver. |
| 88 | * |
| 89 | * @return void |
| 90 | */ |
| 91 | public function params() |
| 92 | { |
| 93 | $app = JFactory::getApplication(); |
| 94 | $input = $app->input; |
| 95 | |
| 96 | /** |
| 97 | * Added token validation. |
| 98 | * |
| 99 | * @since 1.7 |
| 100 | */ |
| 101 | if (!JSession::checkToken()) |
| 102 | { |
| 103 | // missing CSRF-proof token |
| 104 | UIErrorFactory::raiseError(403, JText::translate('JINVALID_TOKEN')); |
| 105 | } |
| 106 | |
| 107 | $type = $input->getString('import_type'); |
| 108 | $class = $input->getString('export_class'); |
| 109 | |
| 110 | VAPLoader::import('libraries.import.factory'); |
| 111 | |
| 112 | // get object handler |
| 113 | $handler = ImportFactory::getObject($type); |
| 114 | |
| 115 | if (!$handler) |
| 116 | { |
| 117 | throw new Exception('Import type not supported.', 404); |
| 118 | } |
| 119 | |
| 120 | // get export handler |
| 121 | $form = ImportFactory::getExportableForm($class); |
| 122 | |
| 123 | $html = ''; |
| 124 | |
| 125 | if ($form) |
| 126 | { |
| 127 | $html = $form->renderFieldset(null); |
| 128 | } |
| 129 | |
| 130 | // send form to caller |
| 131 | $this->sendJSON(json_encode($html)); |
| 132 | } |
| 133 | } |
| 134 |