[ 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\AdminController; 15 use Joomla\CMS\MVC\Model\BaseDatabaseModel; 16 use Joomla\CMS\Router\Route; 17 use Joomla\Component\Scheduler\Administrator\Model\TaskModel; 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 * MVC Controller for TasksView. 26 * 27 * @since 4.1.0 28 */ 29 class TasksController extends AdminController 30 { 31 /** 32 * Proxy for the parent method. 33 * 34 * @param string $name The name of the model. 35 * @param string $prefix The prefix for the PHP class name. 36 * @param array $config Array of configuration parameters. 37 * 38 * @return BaseDatabaseModel 39 * 40 * @since 4.1.0 41 */ 42 public function getModel($name = 'Task', $prefix = 'Administrator', $config = ['ignore_request' => true]): BaseDatabaseModel 43 { 44 return parent::getModel($name, $prefix, $config); 45 } 46 47 /** 48 * Unlock a locked task, i.e., a task that is presumably still running but might have crashed and got stuck in the 49 * "locked" state. 50 * 51 * @return void 52 * 53 * @since 4.1.0 54 */ 55 public function unlock(): void 56 { 57 // Check for request forgeries 58 $this->checkToken(); 59 60 /** @var integer[] $cid Items to publish (from request parameters). */ 61 $cid = (array) $this->input->get('cid', [], 'int'); 62 63 // Remove zero values resulting from input filter 64 $cid = array_filter($cid); 65 66 if (empty($cid)) { 67 $this->app->getLogger() 68 ->warning(Text::_($this->text_prefix . '_NO_ITEM_SELECTED'), array('category' => 'jerror')); 69 } else { 70 /** @var TaskModel $model */ 71 $model = $this->getModel(); 72 73 // Make sure the item IDs are integers 74 $cid = ArrayHelper::toInteger($cid); 75 76 // Unlock the items. 77 try { 78 $model->unlock($cid); 79 $errors = $model->getErrors(); 80 $noticeText = null; 81 82 if ($errors) { 83 $this->app->enqueueMessage(Text::plural($this->text_prefix . '_N_ITEMS_FAILED_UNLOCKING', \count($cid)), 'error'); 84 } else { 85 $noticeText = $this->text_prefix . '_N_ITEMS_UNLOCKED'; 86 } 87 88 if (\count($cid)) { 89 $this->setMessage(Text::plural($noticeText, \count($cid))); 90 } 91 } catch (\Exception $e) { 92 $this->setMessage($e->getMessage(), 'error'); 93 } 94 } 95 96 $this->setRedirect( 97 Route::_( 98 'index.php?option=' . $this->option . '&view=' . $this->view_list 99 . $this->getRedirectToListAppend(), 100 false 101 ) 102 ); 103 } 104 }
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 |