[ 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_scheduler 6 * 7 * @copyright (C) 2021 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\Scheduler\Administrator\Controller; 12 13 use Joomla\CMS\Language\Text; 14 use Joomla\CMS\MVC\Controller\BaseController; 15 use Joomla\CMS\Router\Route; 16 17 // phpcs:disable PSR1.Files.SideEffects 18 \defined('_JEXEC') or die; 19 // phpcs:enable PSR1.Files.SideEffects 20 21 /** 22 * Default controller for com_scheduler. 23 * 24 * @since 4.1.0 25 */ 26 class DisplayController extends BaseController 27 { 28 /** 29 * @var string 30 * @since 4.1.0 31 */ 32 protected $default_view = 'tasks'; 33 34 /** 35 * @param boolean $cachable If true, the view output will be cached 36 * @param array $urlparams An array of safe url parameters and their variable types, for valid values see 37 * {@link InputFilter::clean()}. 38 * 39 * @return BaseController|boolean Returns either a BaseController object to support chaining, or false on failure 40 * 41 * @since 4.1.0 42 * @throws \Exception 43 */ 44 public function display($cachable = false, $urlparams = array()) 45 { 46 $layout = $this->input->get('layout', 'default'); 47 48 // Check for edit form. 49 if ($layout === 'edit') { 50 if (!$this->validateEntry()) { 51 $tasksViewUrl = Route::_('index.php?option=com_scheduler&view=tasks', false); 52 $this->setRedirect($tasksViewUrl); 53 54 return false; 55 } 56 } 57 58 // Let the parent method take over 59 return parent::display($cachable, $urlparams); 60 } 61 62 /** 63 * Validates entry to the view 64 * 65 * @param string $layout The layout to validate entry for (defaults to 'edit') 66 * 67 * @return boolean True is entry is valid 68 * 69 * @since 4.1.0 70 */ 71 private function validateEntry(string $layout = 'edit'): bool 72 { 73 $context = 'com_scheduler'; 74 $id = $this->input->getInt('id'); 75 $isValid = true; 76 77 switch ($layout) { 78 case 'edit': 79 // True if controller was called and verified permissions 80 $inEditList = $this->checkEditId("$context.edit.task", $id); 81 $isNew = ($id == 0); 82 83 // For new item, entry is invalid if task type was not selected through SelectView 84 if ($isNew && !$this->app->getUserState("$context.add.task.task_type")) { 85 $this->setMessage((Text::_('COM_SCHEDULER_ERROR_FORBIDDEN_JUMP_TO_ADD_VIEW')), 'error'); 86 $isValid = false; 87 } elseif (!$inEditList) { 88 // For existing item, entry is invalid if TaskController has not granted access 89 if (!\count($this->app->getMessageQueue())) { 90 $this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 'error'); 91 } 92 93 $isValid = false; 94 } 95 break; 96 default: 97 break; 98 } 99 100 return $isValid; 101 } 102 }
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 |