2021-03-05 03:08:47 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @package Joomla.Component.Builder
|
|
|
|
*
|
|
|
|
* @created 30th April, 2015
|
2024-03-02 20:10:30 +00:00
|
|
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
|
|
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
2021-03-05 03:08:47 +00:00
|
|
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
|
|
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
// No direct access to this file
|
|
|
|
defined('_JEXEC') or die('Restricted access');
|
|
|
|
?>
|
|
|
|
###BOM###
|
|
|
|
|
|
|
|
// No direct access to this file
|
|
|
|
defined('_JEXEC') or die('Restricted access');
|
|
|
|
|
2024-03-02 20:10:30 +00:00
|
|
|
use Joomla\CMS\Factory;
|
|
|
|
use Joomla\CMS\Session\Session;
|
|
|
|
|
2021-03-05 03:08:47 +00:00
|
|
|
/**
|
|
|
|
* ###Component### Ajax Controller
|
|
|
|
*/
|
|
|
|
class ###Component###ControllerAjax extends JControllerLegacy
|
|
|
|
{
|
|
|
|
public function __construct($config)
|
|
|
|
{
|
|
|
|
parent::__construct($config);
|
|
|
|
// make sure all json stuff are set
|
2024-03-02 20:10:30 +00:00
|
|
|
Factory::getDocument()->setMimeEncoding( 'application/json' );
|
|
|
|
Factory::getApplication()->setHeader('Content-Disposition','attachment;filename="getajax.json"');
|
|
|
|
Factory::getApplication()->setHeader("Access-Control-Allow-Origin", "*");
|
2021-03-05 03:08:47 +00:00
|
|
|
// load the tasks
|
|
|
|
$this->registerTask('fieldRequired', 'ajax');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function ajax()
|
|
|
|
{
|
2024-03-02 20:10:30 +00:00
|
|
|
$user = Factory::getUser();
|
|
|
|
$jinput = Factory::getApplication()->input;
|
2021-03-05 03:08:47 +00:00
|
|
|
// Check Token!
|
2024-03-02 20:10:30 +00:00
|
|
|
$token = Session::getFormToken();
|
2021-03-05 03:08:47 +00:00
|
|
|
$call_token = $jinput->get('token', 0, 'ALNUM');
|
|
|
|
if($user->id != 0 && $token == $call_token)
|
|
|
|
{
|
|
|
|
$task = $this->getTask();
|
|
|
|
switch($task){
|
|
|
|
case 'fieldRequired':
|
|
|
|
try
|
|
|
|
{
|
|
|
|
$name = $jinput->get('name', NULL, 'WORD');
|
|
|
|
$form = $jinput->get('form', NULL, 'WORD');
|
|
|
|
$status = $jinput->get('status', NULL, 'INT');
|
2024-03-02 20:10:30 +00:00
|
|
|
|
|
|
|
if (Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($name) && Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($form))
|
2021-03-05 03:08:47 +00:00
|
|
|
{
|
|
|
|
$result = $this->getModel('ajax')->setFieldRequired($name,$form,$status);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$result = false;
|
|
|
|
}
|
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
|
|
|
{
|
|
|
|
echo $callback . "(".json_encode($result).");";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($result).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception $e)
|
|
|
|
{
|
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
|
|
|
{
|
|
|
|
echo $callback."(".json_encode($e).");";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode($e).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if($callback = $jinput->get('callback', null, 'CMD'))
|
|
|
|
{
|
|
|
|
echo $callback."(".json_encode(false).");";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "(".json_encode(false).");";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|