[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Site 5 * @subpackage com_privacy 6 * 7 * @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 namespace Joomla\Component\Privacy\Site\Controller; 12 13 use Joomla\CMS\Language\Text; 14 use Joomla\CMS\MVC\Controller\BaseController; 15 use Joomla\CMS\Router\Route; 16 use Joomla\CMS\Uri\Uri; 17 use Joomla\Component\Privacy\Site\Model\ConfirmModel; 18 use Joomla\Component\Privacy\Site\Model\RequestModel; 19 20 // phpcs:disable PSR1.Files.SideEffects 21 \defined('_JEXEC') or die; 22 // phpcs:enable PSR1.Files.SideEffects 23 24 /** 25 * Request action controller class. 26 * 27 * @since 3.9.0 28 */ 29 class RequestController extends BaseController 30 { 31 /** 32 * Method to confirm the information request. 33 * 34 * @return boolean 35 * 36 * @since 3.9.0 37 */ 38 public function confirm() 39 { 40 // Check the request token. 41 $this->checkToken('post'); 42 43 /** @var ConfirmModel $model */ 44 $model = $this->getModel('Confirm', 'Site'); 45 $data = $this->input->post->get('jform', [], 'array'); 46 47 $return = $model->confirmRequest($data); 48 49 // Check for a hard error. 50 if ($return instanceof \Exception) { 51 // Get the error message to display. 52 if ($this->app->get('error_reporting')) { 53 $message = $return->getMessage(); 54 } else { 55 $message = Text::_('COM_PRIVACY_ERROR_CONFIRMING_REQUEST'); 56 } 57 58 // Go back to the confirm form. 59 $this->setRedirect(Route::_('index.php?option=com_privacy&view=confirm', false), $message, 'error'); 60 61 return false; 62 } elseif ($return === false) { 63 // Confirm failed. 64 // Go back to the confirm form. 65 $message = Text::sprintf('COM_PRIVACY_ERROR_CONFIRMING_REQUEST_FAILED', $model->getError()); 66 $this->setRedirect(Route::_('index.php?option=com_privacy&view=confirm', false), $message, 'notice'); 67 68 return false; 69 } else { 70 // Confirm succeeded. 71 $this->setRedirect(Route::_(Uri::root()), Text::_('COM_PRIVACY_CONFIRM_REQUEST_SUCCEEDED'), 'info'); 72 73 return true; 74 } 75 } 76 77 /** 78 * Method to submit an information request. 79 * 80 * @return boolean 81 * 82 * @since 3.9.0 83 */ 84 public function submit() 85 { 86 // Check the request token. 87 $this->checkToken('post'); 88 89 /** @var RequestModel $model */ 90 $model = $this->getModel('Request', 'Site'); 91 $data = $this->input->post->get('jform', [], 'array'); 92 93 $return = $model->createRequest($data); 94 95 // Check for a hard error. 96 if ($return instanceof \Exception) { 97 // Get the error message to display. 98 if ($this->app->get('error_reporting')) { 99 $message = $return->getMessage(); 100 } else { 101 $message = Text::_('COM_PRIVACY_ERROR_CREATING_REQUEST'); 102 } 103 104 // Go back to the confirm form. 105 $this->setRedirect(Route::_('index.php?option=com_privacy&view=request', false), $message, 'error'); 106 107 return false; 108 } elseif ($return === false) { 109 // Confirm failed. 110 // Go back to the confirm form. 111 $message = Text::sprintf('COM_PRIVACY_ERROR_CREATING_REQUEST_FAILED', $model->getError()); 112 $this->setRedirect(Route::_('index.php?option=com_privacy&view=request', false), $message, 'notice'); 113 114 return false; 115 } else { 116 // Confirm succeeded. 117 $this->setRedirect(Route::_(Uri::root()), Text::_('COM_PRIVACY_CREATE_REQUEST_SUCCEEDED'), 'info'); 118 119 return true; 120 } 121 } 122 123 /** 124 * Method to extend the privacy consent. 125 * 126 * @return boolean 127 * 128 * @since 3.9.0 129 */ 130 public function remind() 131 { 132 // Check the request token. 133 $this->checkToken('post'); 134 135 /** @var ConfirmModel $model */ 136 $model = $this->getModel('Remind', 'Site'); 137 $data = $this->input->post->get('jform', [], 'array'); 138 139 $return = $model->remindRequest($data); 140 141 // Check for a hard error. 142 if ($return instanceof \Exception) { 143 // Get the error message to display. 144 if ($this->app->get('error_reporting')) { 145 $message = $return->getMessage(); 146 } else { 147 $message = Text::_('COM_PRIVACY_ERROR_REMIND_REQUEST'); 148 } 149 150 // Go back to the confirm form. 151 $this->setRedirect(Route::_('index.php?option=com_privacy&view=remind', false), $message, 'error'); 152 153 return false; 154 } elseif ($return === false) { 155 // Confirm failed. 156 // Go back to the confirm form. 157 $message = Text::sprintf('COM_PRIVACY_ERROR_CONFIRMING_REMIND_FAILED', $model->getError()); 158 $this->setRedirect(Route::_('index.php?option=com_privacy&view=remind', false), $message, 'notice'); 159 160 return false; 161 } else { 162 // Confirm succeeded. 163 $this->setRedirect(Route::_(Uri::root()), Text::_('COM_PRIVACY_CONFIRM_REMIND_SUCCEEDED'), 'info'); 164 165 return true; 166 } 167 } 168 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |