1<?php 2/** 3 * @package Joomla.Administrator 4 * @subpackage com_privacy 5 * 6 * @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved. 7 * @license GNU General Public License version 2 or later; see LICENSE.txt 8 */ 9 10defined('_JEXEC') or die; 11 12/** 13 * Consents management controller class. 14 * 15 * @since 3.9.0 16 */ 17class PrivacyControllerConsents extends JControllerForm 18{ 19 /** 20 * Method to invalidate specific consents. 21 * 22 * @return boolean 23 * 24 * @since 3.9.0 25 */ 26 public function invalidate($key = null, $urlVar = null) 27 { 28 // Check for request forgeries 29 JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); 30 31 $ids = $this->input->get('cid', array(), 'array'); 32 33 if (empty($ids)) 34 { 35 $this->setError(JText::_('JERROR_NO_ITEMS_SELECTED')); 36 } 37 else 38 { 39 // Get the model. 40 /** @var PrivacyModelConsents $model */ 41 $model = $this->getModel(); 42 43 // Publish the items. 44 if (!$model->invalidate($ids)) 45 { 46 $this->setError($model->getError()); 47 } 48 49 $message = JText::plural('COM_PRIVACY_N_CONSENTS_INVALIDATED', count($ids)); 50 } 51 52 $this->setRedirect(JRoute::_('index.php?option=com_privacy&view=consents', false), $message); 53 } 54 55 /** 56 * Method to invalidate all consents of a specific subject. 57 * 58 * @return boolean 59 * 60 * @since 3.9.0 61 */ 62 public function invalidateAll() 63 { 64 // Check for request forgeries 65 JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); 66 67 $filters = $this->input->get('filter', array(), 'array'); 68 69 if (isset($filters['subject']) && $filters['subject'] != '') 70 { 71 $subject = $filters['subject']; 72 } 73 else 74 { 75 $this->setError(JText::_('JERROR_NO_ITEMS_SELECTED')); 76 } 77 78 // Get the model. 79 /** @var PrivacyModelConsents $model */ 80 $model = $this->getModel(); 81 82 // Publish the items. 83 if (!$model->invalidateAll($subject)) 84 { 85 $this->setError($model->getError()); 86 } 87 88 $message = JText::_('COM_PRIVACY_CONSENTS_INVALIDATED_ALL'); 89 90 $this->setRedirect(JRoute::_('index.php?option=com_privacy&view=consents', false), $message); 91 } 92} 93