[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Administrator 5 * @subpackage com_contact 6 * 7 * @copyright (C) 2009 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\Contact\Administrator\Controller; 12 13 use Joomla\CMS\Application\CMSApplication; 14 use Joomla\CMS\Language\Text; 15 use Joomla\CMS\MVC\Controller\AdminController; 16 use Joomla\CMS\MVC\Factory\MVCFactoryInterface; 17 use Joomla\Input\Input; 18 use Joomla\Utilities\ArrayHelper; 19 20 // phpcs:disable PSR1.Files.SideEffects 21 \defined('_JEXEC') or die; 22 // phpcs:enable PSR1.Files.SideEffects 23 24 /** 25 * Contacts list controller class. 26 * 27 * @since 1.6 28 */ 29 class ContactsController extends AdminController 30 { 31 /** 32 * Constructor. 33 * 34 * @param array $config An optional associative array of configuration settings. 35 * Recognized key values include 'name', 'default_task', 'model_path', and 36 * 'view_path' (this list is not meant to be comprehensive). 37 * @param MVCFactoryInterface $factory The factory. 38 * @param CMSApplication $app The Application for the dispatcher 39 * @param Input $input Input 40 * 41 * @since 3.0 42 */ 43 public function __construct($config = array(), MVCFactoryInterface $factory = null, $app = null, $input = null) 44 { 45 parent::__construct($config, $factory, $app, $input); 46 47 $this->registerTask('unfeatured', 'featured'); 48 } 49 50 /** 51 * Method to toggle the featured setting of a list of contacts. 52 * 53 * @return void 54 * 55 * @since 1.6 56 */ 57 public function featured() 58 { 59 // Check for request forgeries 60 $this->checkToken(); 61 62 $ids = (array) $this->input->get('cid', array(), 'int'); 63 $values = array('featured' => 1, 'unfeatured' => 0); 64 $task = $this->getTask(); 65 $value = ArrayHelper::getValue($values, $task, 0, 'int'); 66 67 // Get the model. 68 /** @var \Joomla\Component\Contact\Administrator\Model\ContactModel $model */ 69 $model = $this->getModel(); 70 71 // Access checks. 72 foreach ($ids as $i => $id) { 73 // Remove zero value resulting from input filter 74 if ($id === 0) { 75 unset($ids[$i]); 76 77 continue; 78 } 79 80 $item = $model->getItem($id); 81 82 if (!$this->app->getIdentity()->authorise('core.edit.state', 'com_contact.category.' . (int) $item->catid)) { 83 // Prune items that you can't change. 84 unset($ids[$i]); 85 $this->app->enqueueMessage(Text::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), 'notice'); 86 } 87 } 88 89 if (empty($ids)) { 90 $message = null; 91 92 $this->app->enqueueMessage(Text::_('COM_CONTACT_NO_ITEM_SELECTED'), 'warning'); 93 } else { 94 // Publish the items. 95 if (!$model->featured($ids, $value)) { 96 $this->app->enqueueMessage($model->getError(), 'warning'); 97 } 98 99 if ($value == 1) { 100 $message = Text::plural('COM_CONTACT_N_ITEMS_FEATURED', count($ids)); 101 } else { 102 $message = Text::plural('COM_CONTACT_N_ITEMS_UNFEATURED', count($ids)); 103 } 104 } 105 106 $this->setRedirect('index.php?option=com_contact&view=contacts', $message); 107 } 108 109 /** 110 * Proxy for getModel. 111 * 112 * @param string $name The name of the model. 113 * @param string $prefix The prefix for the PHP class name. 114 * @param array $config Array of configuration parameters. 115 * 116 * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel 117 * 118 * @since 1.6 119 */ 120 public function getModel($name = 'Contact', $prefix = 'Administrator', $config = array('ignore_request' => true)) 121 { 122 return parent::getModel($name, $prefix, $config); 123 } 124 }
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 |