forked from pollen8/fabrik
-
Notifications
You must be signed in to change notification settings - Fork 380
/
connection.php
64 lines (55 loc) · 1.44 KB
/
connection.php
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
<?php
/**
* Connection controller class
*
* @package Joomla.Administrator
* @subpackage Fabrik
* @copyright Copyright (C) 2005-2016 Media A-Team, Inc. - All rights reserved.
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
*/
// No direct access
defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.controllerform');
require_once 'fabcontrollerform.php';
/**
* Connection controller class.
*
* @package Joomla.Administrator
* @subpackage Fabrik
* @since 1.6
*/
class FabrikAdminControllerConnection extends FabControllerForm
{
/**
* The prefix to use with controller messages.
*
* @var string
*/
protected $text_prefix = 'COM_FABRIK_CONNECTION';
/**
* Tries to connection to the database
*
* @return string connection message
*/
public function test()
{
JSession::checkToken() or die('Invalid Token');
$app = JFactory::getApplication();
$input = $app->input;
$cid = $input->get('cid', array(), 'array');
$cid = array((int) $cid[0]);
$link = 'index.php?option=com_fabrik&view=connections';
foreach ($cid as $id)
{
$model = JModelLegacy::getInstance('Connection', 'FabrikFEModel');
$model->setId($id);
if ($model->testConnection() == false)
{
JError::raiseWarning(500, FText::_('COM_FABRIK_UNABLE_TO_CONNECT'));
$this->setRedirect($link);
return;
}
}
$this->setRedirect($link, FText::_('COM_FABRIK_CONNECTION_SUCESSFUL'));
}
}