first commit

This commit is contained in:
2025-06-17 11:53:18 +02:00
commit 9f0f7ba12b
8804 changed files with 1369176 additions and 0 deletions

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="component" method="upgrade">
<name>com_checkin</name>
<author>Joomla! Project</author>
<creationDate>2006-04</creationDate>
<copyright>(C) 2006 Open Source Matters, Inc.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>4.0.0</version>
<description>COM_CHECKIN_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Component\Checkin</namespace>
<administration>
<files folder="admin">
<filename>checkin.xml</filename>
<filename>config.xml</filename>
<folder>forms</folder>
<folder>services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages folder="admin">
<language tag="en-GB">language/en-GB/com_checkin.ini</language>
<language tag="en-GB">language/en-GB/com_checkin.sys.ini</language>
</languages>
</administration>
</extension>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<config>
<help key="Check-in:_Options"/>
<fieldset
name="permissions"
label="JCONFIG_PERMISSIONS_LABEL"
>
<field
name="rules"
type="rules"
label="JCONFIG_PERMISSIONS_LABEL"
filter="rules"
validate="rules"
component="com_checkin"
section="component">
<action
name="core.admin"
title="JACTION_ADMIN"
/>
<action
name="core.manage"
title="JACTION_MANAGE"
/>
</field>
</fieldset>
</config>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_CHECKIN_FILTER_SEARCH_LABEL"
description="COM_CHECKIN_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
noresults="COM_CHECKIN_NO_ITEMS"
/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="JGLOBAL_SORT_BY"
class="js-select-submit-on-change"
default="table ASC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="table ASC">COM_CHECKIN_DATABASE_TABLE_ASC</option>
<option value="table DESC">COM_CHECKIN_DATABASE_TABLE_DESC</option>
<option value="count ASC">COM_CHECKIN_ITEMS_TO_CHECK_IN_ASC</option>
<option value="count DESC">COM_CHECKIN_ITEMS_TO_CHECK_IN_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="JGLOBAL_LIST_LIMIT"
default="5"
class="js-select-submit-on-change"
/>
</fields>
</form>

View File

@ -0,0 +1,53 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_checkin
*
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
\defined('_JEXEC') or die;
use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
use Joomla\CMS\Extension\ComponentInterface;
use Joomla\CMS\Extension\MVCComponent;
use Joomla\CMS\Extension\Service\Provider\ComponentDispatcherFactory;
use Joomla\CMS\Extension\Service\Provider\MVCFactory;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
/**
* The checkin service provider.
*
* @since 4.0.0
*/
return new class () implements ServiceProviderInterface {
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*
* @since 4.0.0
*/
public function register(Container $container)
{
$container->registerServiceProvider(new MVCFactory('\\Joomla\\Component\\Checkin'));
$container->registerServiceProvider(new ComponentDispatcherFactory('\\Joomla\\Component\\Checkin'));
$container->set(
ComponentInterface::class,
function (Container $container) {
$component = new MVCComponent($container->get(ComponentDispatcherFactoryInterface::class));
$component->setMVCFactory($container->get(MVCFactoryInterface::class));
return $component;
}
);
}
};

View File

@ -0,0 +1,122 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_checkin
*
* @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Checkin\Administrator\Controller;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Response\JsonResponse;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Checkin Controller
*
* @since 1.6
*/
class DisplayController extends BaseController
{
/**
* The default view.
*
* @var string
* @since 1.6
*/
protected $default_view = 'checkin';
/**
* Method to display a view.
*
* @param boolean $cachable If true, the view output will be cached
* @param array $urlparams An array of safe URL parameters and their variable types.
* @see \Joomla\CMS\Filter\InputFilter::clean() for valid values.
*
* @return static A \JControllerLegacy object to support chaining.
*/
public function display($cachable = false, $urlparams = [])
{
return parent::display();
}
/**
* Check in a list of items.
*
* @return void
*/
public function checkin()
{
// Check for request forgeries
$this->checkToken();
$ids = (array) $this->input->get('cid', [], 'string');
if (empty($ids)) {
$this->app->enqueueMessage(Text::_('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST'), 'warning');
} else {
// Get the model.
/** @var \Joomla\Component\Checkin\Administrator\Model\CheckinModel $model */
$model = $this->getModel('Checkin');
// Checked in the items.
$this->setMessage(Text::plural('COM_CHECKIN_N_ITEMS_CHECKED_IN', $model->checkin($ids)));
}
$this->setRedirect('index.php?option=com_checkin');
}
/**
* Provide the data for a badge in a menu item via JSON
*
* @return void
*
* @since 4.0.0
* @throws \Exception
*/
public function getMenuBadgeData()
{
if (!$this->app->getIdentity()->authorise('core.manage', 'com_checkin')) {
throw new \Exception(Text::_('JGLOBAL_AUTH_ACCESS_DENIED'));
}
$model = $this->getModel('Checkin');
$amount = (int) \count($model->getItems());
echo new JsonResponse($amount);
}
/**
* Method to get the number of locked icons
*
* @return void
*
* @since 4.0.0
* @throws \Exception
*/
public function getQuickiconContent()
{
if (!$this->app->getIdentity()->authorise('core.manage', 'com_checkin')) {
throw new \Exception(Text::_('JGLOBAL_AUTH_ACCESS_DENIED'));
}
$model = $this->getModel('Checkin');
$amount = (int) \count($model->getItems());
$result = [];
$result['amount'] = $amount;
$result['sronly'] = Text::plural('COM_CHECKIN_N_QUICKICON_SRONLY', $amount);
echo new JsonResponse($result);
}
}

View File

@ -0,0 +1,238 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_checkin
*
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Checkin\Administrator\Model;
use Joomla\CMS\Event\Checkin\AfterCheckinEvent;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\MVC\Model\ListModel;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Checkin Model
*
* @since 1.6
*/
class CheckinModel extends ListModel
{
/**
* Count of the total items checked out
*
* @var integer
*/
protected $total;
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
* @param MVCFactoryInterface $factory The factory.
*
* @see \Joomla\CMS\MVC\Model\BaseDatabaseModel
* @since 3.2
*/
public function __construct($config = [], MVCFactoryInterface $factory = null)
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = [
'table',
'count',
];
}
parent::__construct($config, $factory);
}
/**
* Method to auto-populate the model state.
*
* Note: Calling getState in this method will result in recursion.
*
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
*
* @since 1.6
*/
protected function populateState($ordering = 'table', $direction = 'asc')
{
// List state information.
parent::populateState($ordering, $direction);
}
/**
* Checks in requested tables
*
* @param array $ids An array of table names. Optional.
*
* @return mixed The database results or 0
*
* @since 1.6
*/
public function checkin($ids = [])
{
$db = $this->getDatabase();
if (!\is_array($ids)) {
return 0;
}
// This int will hold the checked item count.
$results = 0;
$app = Factory::getApplication();
foreach ($ids as $tn) {
// Make sure we get the right tables based on prefix.
if (stripos($tn, $app->get('dbprefix')) !== 0) {
continue;
}
$fields = $db->getTableColumns($tn, false);
if (!(isset($fields['checked_out']) && isset($fields['checked_out_time']))) {
continue;
}
$query = $db->getQuery(true)
->update($db->quoteName($tn))
->set($db->quoteName('checked_out') . ' = DEFAULT');
if ($fields['checked_out_time']->Null === 'YES') {
$query->set($db->quoteName('checked_out_time') . ' = NULL');
} else {
$nullDate = $db->getNullDate();
$query->set($db->quoteName('checked_out_time') . ' = :checkouttime')
->bind(':checkouttime', $nullDate);
}
if ($fields['checked_out']->Null === 'YES') {
$query->where($db->quoteName('checked_out') . ' IS NOT NULL');
} else {
$query->where($db->quoteName('checked_out') . ' > 0');
}
$db->setQuery($query);
if ($db->execute()) {
$results += $db->getAffectedRows();
$this->getDispatcher()->dispatch('onAfterCheckin', new AfterCheckinEvent('onAfterCheckin', [
'subject' => $tn,
]));
}
}
return $results;
}
/**
* Get total of tables
*
* @return integer Total to check-in tables
*
* @since 1.6
*/
public function getTotal()
{
if (!isset($this->total)) {
$this->getItems();
}
return $this->total;
}
/**
* Get tables
*
* @return array Checked in table names as keys and checked in item count as values.
*
* @since 1.6
*/
public function getItems()
{
if (!isset($this->items)) {
$db = $this->getDatabase();
$tables = $db->getTableList();
$prefix = Factory::getApplication()->get('dbprefix');
// This array will hold table name as key and checked in item count as value.
$results = [];
foreach ($tables as $tn) {
// Make sure we get the right tables based on prefix.
if (stripos($tn, $prefix) !== 0) {
continue;
}
if ($this->getState('filter.search') && stripos($tn, $this->getState('filter.search')) === false) {
continue;
}
$fields = $db->getTableColumns($tn, false);
if (!(isset($fields['checked_out']) && isset($fields['checked_out_time']))) {
continue;
}
$query = $db->getQuery(true)
->select('COUNT(*)')
->from($db->quoteName($tn));
if ($fields['checked_out']->Null === 'YES') {
$query->where($db->quoteName('checked_out') . ' IS NOT NULL');
} else {
$query->where($db->quoteName('checked_out') . ' > 0');
}
$db->setQuery($query);
$count = $db->loadResult();
if ($count) {
$results[$tn] = $count;
}
}
$this->total = \count($results);
// Order items by table
if ($this->getState('list.ordering') == 'table') {
if (strtolower($this->getState('list.direction')) == 'asc') {
ksort($results);
} else {
krsort($results);
}
} else {
// Order items by number of items
if (strtolower($this->getState('list.direction')) == 'asc') {
asort($results);
} else {
arsort($results);
}
}
// Pagination
$limit = (int) $this->getState('list.limit');
if ($limit !== 0) {
$this->items = \array_slice($results, $this->getState('list.start'), $limit);
} else {
$this->items = $results;
}
}
return $this->items;
}
}

View File

@ -0,0 +1,133 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_checkin
*
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Checkin\Administrator\View\Checkin;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\GenericDataException;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* HTML View class for the Checkin component
*
* @since 1.0
*/
class HtmlView extends BaseHtmlView
{
/**
* An array of items
*
* @var array
*/
protected $items;
/**
* The pagination object
*
* @var \Joomla\CMS\Pagination\Pagination
*/
protected $pagination;
/**
* The model state
*
* @var \Joomla\Registry\Registry
*/
protected $state;
/**
* Form object for search filters
*
* @var \Joomla\CMS\Form\Form
*
* @since 4.0.0
*/
public $filterForm;
/**
* The active search filters
*
* @var array
*
* @since 4.0.0
*/
public $activeFilters;
/**
* Is this view an Empty State
*
* @var boolean
*
* @since 4.0.0
*/
private $isEmptyState = false;
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return void
*/
public function display($tpl = null)
{
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->total = $this->get('Total');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
if (!\count($this->items)) {
$this->isEmptyState = true;
$this->setLayout('emptystate');
}
// Check for errors.
if (\count($errors = $this->get('Errors'))) {
throw new GenericDataException(implode("\n", $errors), 500);
}
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
ToolbarHelper::title(Text::_('COM_CHECKIN_GLOBAL_CHECK_IN'), 'check-square');
$toolbar = Toolbar::getInstance();
if (!$this->isEmptyState) {
$toolbar->checkin('checkin');
}
if ($this->getCurrentUser()->authorise('core.admin', 'com_checkin')) {
$toolbar->divider();
$toolbar->preferences('com_checkin');
$toolbar->divider();
}
$toolbar->help('Maintenance:_Global_Check-in');
}
}

View File

@ -0,0 +1,79 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_checkin
*
* @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Router\Route;
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->document->getWebAssetManager();
$wa->useScript('multiselect');
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
?>
<form action="<?php echo Route::_('index.php?option=com_checkin'); ?>" method="post" name="adminForm" id="adminForm">
<div class="row">
<div class="col-md-12">
<div id="j-main-container" class="j-main-container">
<?php echo LayoutHelper::render('joomla.searchtools.default', ['view' => $this]); ?>
<?php if ($this->total > 0) : ?>
<table id="global-checkin" class="table">
<caption class="visually-hidden">
<?php echo Text::_('COM_CHECKIN_TABLE_CAPTION'); ?>,
<span id="orderedBy"><?php echo Text::_('JGLOBAL_SORTED_BY'); ?> </span>,
<span id="filteredBy"><?php echo Text::_('JGLOBAL_FILTERED_BY'); ?></span>
</caption>
<thead>
<tr>
<td class="w-1 text-center">
<?php echo HTMLHelper::_('grid.checkall'); ?>
</td>
<th scope="col">
<?php echo HTMLHelper::_('searchtools.sort', 'COM_CHECKIN_DATABASE_TABLE', 'table', $listDirn, $listOrder); ?>
</th>
<th scope="col">
<?php echo HTMLHelper::_('searchtools.sort', 'COM_CHECKIN_ITEMS_TO_CHECK_IN', 'count', $listDirn, $listOrder); ?>
</th>
</tr>
</thead>
<tbody>
<?php $i = 0; ?>
<?php foreach ($this->items as $table => $count) : ?>
<tr class="row<?php echo $i % 2; ?>">
<td class="text-center">
<?php echo HTMLHelper::_('grid.id', $i, $table, false, 'cid', 'cb', $table); ?>
</td>
<th scope="row">
<?php echo Text::sprintf('COM_CHECKIN_TABLE', $table); ?>
</th>
<td>
<span class="badge bg-secondary"><?php echo $count; ?></span>
</td>
</tr>
<?php $i++; ?>
<?php endforeach; ?>
</tbody>
</table>
<?php // load the pagination. ?>
<?php echo $this->pagination->getListFooter(); ?>
<?php endif; ?>
<input type="hidden" name="task" value="">
<input type="hidden" name="boxchecked" value="0">
<?php echo HTMLHelper::_('form.token'); ?>
</div>
</div>
</div>
</form>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<layout title="COM_CHECKIN_CHECKIN_VIEW_DEFAULT_TITLE">
<message>
<![CDATA[COM_CHECKIN_CHECKIN_VIEW_DEFAULT_DESC]]>
</message>
</layout>
<fields name="params">
<fieldset name="basic" label="JOPTIONS">
<field
name="ajax-badge"
type="radio"
label="COM_CHECKIN_CHECKIN_VIEW_DISPLAY_BADGE"
layout="joomla.form.field.radio.switcher"
default=""
>
<option value="">JHIDE</option>
<option value="index.php?option=com_checkin&amp;task=getMenuBadgeData&amp;format=json">JSHOW</option>
</field>
</fieldset>
</fields>
</metadata>

View File

@ -0,0 +1,23 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_checkin
*
* @copyright (C) 2021 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;
$displayData = [
'textPrefix' => 'COM_CHECKIN',
'helpURL' => 'https://docs.joomla.org/Special:MyLanguage/Help4.x:Maintenance:_Global_Check-in',
'icon' => 'icon-check-square',
'title' => Text::_('COM_CHECKIN_GLOBAL_CHECK_IN'),
];
echo LayoutHelper::render('joomla.content.emptystate', $displayData);