profiles.php
3.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
/**
* @copyright Copyright (c) 2009-2020 Ryan Demmer. All rights reserved
* @license GNU/GPL 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* JCE is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses
*/
defined('JPATH_PLATFORM') or die;
class JceControllerProfiles extends JControllerAdmin
{
/**
* Method to import profile data from an XML file.
*
* @since 3.0
*/
public function import()
{
// Check for request forgeries
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
$app = JFactory::getApplication();
$model = $this->getModel();
$result = $model->import();
// Get redirect URL
$redirect_url = JRoute::_('index.php?option=com_jce&view=profiles', false);
// Push message queue to session because we will redirect page by Javascript, not $app->redirect().
// The "application.queue" is only set in redirect() method, so we must manually store it.
$app->getSession()->set('application.queue', $app->getMessageQueue());
header('Content-Type: application/json');
echo new JResponseJson(array('redirect' => $redirect_url), "", !$result);
exit();
}
public function repair()
{
// Check for request forgeries
JSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
$model = $this->getModel('profiles');
try {
$model->repair();
} catch (Exception $e) {
$this->setMessage($e->getMessage(), 'error');
}
$this->setRedirect('index.php?option=com_jce&view=profiles');
}
public function copy()
{
// Check for request forgeries
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
$user = JFactory::getUser();
$cid = $this->input->get('cid', array(), 'array');
// Access checks.
if (!$user->authorise('core.create', 'com_jce')) {
throw new Exception(JText::_('JLIB_APPLICATION_ERROR_CREATE_NOT_PERMITTED'));
}
if (empty($cid)) {
throw new Exception(JText::_('No Item Selected'));
} else {
$model = $this->getModel();
// Copy the items.
try {
$model->copy($cid);
$ntext = $this->text_prefix . '_N_ITEMS_COPIED';
$this->setMessage(JText::plural($ntext, count($cid)));
} catch (Exception $e) {
$this->setMessage($e->getMessage(), 'error');
}
}
$this->setRedirect('index.php?option=com_jce&view=profiles');
}
public function export()
{
// Check for request forgeries
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
$user = JFactory::getUser();
$ids = $this->input->get('cid', array(), 'array');
// Access checks.
if (!$user->authorise('core.create', 'com_jce')) {
throw new Exception(JText::_('JLIB_APPLICATION_ERROR_CREATE_NOT_PERMITTED'));
}
if (empty($ids)) {
throw new Exception(JText::_('No Item Selected'));
} else {
$model = $this->getModel();
// Publish the items.
if (!$model->export($ids)) {
throw new Exception($model->getError());
}
}
}
/**
* Proxy for getModel.
*
* @param string $name The model name. Optional
* @param string $prefix The class prefix. Optional
* @param array $config The array of possible config values. Optional
*
* @return object The model
*
* @since 1.6
*/
public function getModel($name = 'Profile', $prefix = 'JceModel', $config = array('ignore_request' => true))
{
return parent::getModel($name, $prefix, $config);
}
}