Skip to content

Commit

Permalink
Merge branch '4.0-dev' into 4.0_ListField
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonge committed Apr 11, 2019
2 parents 192a118 + 7fe9ce4 commit 1573b6a
Show file tree
Hide file tree
Showing 37 changed files with 398 additions and 556 deletions.
@@ -0,0 +1,98 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_actionlogs
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;

use \Joomla\CMS\MVC\Model\BaseModel;

BaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_actionlogs/models', 'ActionlogsModel');

/**
* Abstract Action Log Plugin
*
* @since 3.9.0
*/
abstract class ActionLogPlugin extends JPlugin
{
/**
* Application object.
*
* @var JApplicationCms
* @since 3.9.0
*/
protected $app;

/**
* Database object.
*
* @var JDatabaseDriver
* @since 3.9.0
*/
protected $db;

/**
* Load plugin language file automatically so that it can be used inside component
*
* @var boolean
* @since 3.9.0
*/
protected $autoloadLanguage = true;

/**
* Proxy for ActionlogsModelUserlog addLog method
*
* This method adds a record to #__action_logs contains (message_language_key, message, date, context, user)
*
* @param array $messages The contents of the messages to be logged
* @param string $messageLanguageKey The language key of the message
* @param string $context The context of the content passed to the plugin
* @param int $userId ID of user perform the action, usually ID of current logged in user
*
* @return void
*
* @since 3.9.0
*/
protected function addLog($messages, $messageLanguageKey, $context, $userId = null)
{
$user = JFactory::getUser();

foreach ($messages as $index => $message)
{
if (!array_key_exists('userid', $message))
{
$message['userid'] = $user->id;
}

if (!array_key_exists('username', $message))
{
$message['username'] = $user->username;
}

if (!array_key_exists('accountlink', $message))
{
$message['accountlink'] = 'index.php?option=com_users&task=user.edit&id=' . $user->id;
}

if (array_key_exists('type', $message))
{
$message['type'] = strtoupper($message['type']);
}

if (array_key_exists('app', $message))
{
$message['app'] = strtoupper($message['app']);
}

$messages[$index] = $message;
}

/** @var ActionlogsModelActionlog $model **/
$model = BaseModel::getInstance('Actionlog', 'ActionlogsModel');
$model->addLog($messages, strtoupper($messageLanguageKey), $context, $userId);
}
}
30 changes: 13 additions & 17 deletions administrator/components/com_actionlogs/models/fields/logtype.php
Expand Up @@ -9,6 +9,8 @@

defined('_JEXEC') or die;

use Joomla\CMS\Application\ApplicationHelper;

JFormHelper::loadFieldClass('checkboxes');
JLoader::register('ActionlogsHelper', JPATH_ADMINISTRATOR . '/components/com_actionlogs/helpers/actionlogs.php');

Expand Down Expand Up @@ -38,29 +40,23 @@ public function getOptions()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('a.extension')
->from($db->quoteName('#__action_logs_extensions', 'a'));

$db->setQuery($query);
->select($db->quoteName('extension'))
->from($db->quoteName('#__action_logs_extensions'));

$extensions = $db->loadObjectList();
$extensions = $db->setQuery($query)->loadColumn();

$options = array();
$defaults = array();
$options = array();
$tmp = array('checked' => true);

foreach ($extensions as $extension)
{
$tmp = array(
'checked' => true,
);

$defaults[] = $extension;

ActionlogsHelper::loadTranslationFiles($extension->extension);
$option = JHtml::_('select.option', $extension->extension, JText::_($extension->extension));
$options[] = (object) array_merge($tmp, (array) $option);
ActionlogsHelper::loadTranslationFiles($extension);
$option = JHtml::_('select.option', $extension, JText::_($extension));
$options[ApplicationHelper::stringURLSafe(JText::_($extension)) . '_' . $extension] = (object) array_merge($tmp, (array) $option);
}

return array_merge(parent::getOptions(), $options);
ksort($options);

return array_merge(parent::getOptions(), array_values($options));
}
}
Expand Up @@ -94,29 +94,31 @@
</td>
<?php endif; ?>
<th scope="row" class="has-context">
<?php if (isset($item->level)) : ?>
<?php echo LayoutHelper::render('joomla.html.treeprefix', array('level' => $item->level)); ?>
<?php endif; ?>
<?php if ($canCheckin && $isCheckout) : ?>
<?php echo HTMLHelper::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, 'associations.', $canCheckin); ?>
<?php endif; ?>
<?php if ($canEdit) : ?>
<?php $editIcon = $isCheckout ? '' : '<span class="fa fa-pencil-square mr-2" aria-hidden="true"></span>'; ?>
<a class="hasTooltip" href="<?php echo Route::_($this->editUri . '&id=' . (int) $item->id); ?>" title="<?php echo Text::_('JACTION_EDIT'); ?> <?php echo $this->escape(addslashes($item->title)); ?>">
<?php echo $editIcon; ?><?php echo $this->escape($item->title); ?></a>
<?php else : ?>
<span title="<?php echo Text::sprintf('JFIELD_ALIAS_LABEL', $this->escape($item->alias)); ?>"><?php echo $this->escape($item->title); ?></span>
<?php endif; ?>
<?php if (!empty($this->typeFields['alias'])) : ?>
<span class="small">
<?php echo Text::sprintf('JGLOBAL_LIST_ALIAS', $this->escape($item->alias)); ?>
</span>
<?php endif; ?>
<?php if (!empty($this->typeFields['catid'])) : ?>
<div class="small">
<?php echo Text::_('JCATEGORY') . ": " . $this->escape($item->category_title); ?>
</div>
<?php endif; ?>
<div class="float-left break-word">
<?php if (isset($item->level)) : ?>
<?php echo LayoutHelper::render('joomla.html.treeprefix', array('level' => $item->level)); ?>
<?php endif; ?>
<?php if ($canCheckin && $isCheckout) : ?>
<?php echo HTMLHelper::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, 'associations.', $canCheckin); ?>
<?php endif; ?>
<?php if ($canEdit) : ?>
<?php $editIcon = $isCheckout ? '' : '<span class="fa fa-pencil-square mr-2" aria-hidden="true"></span>'; ?>
<a class="hasTooltip" href="<?php echo Route::_($this->editUri . '&id=' . (int) $item->id); ?>" title="<?php echo Text::_('JACTION_EDIT'); ?> <?php echo $this->escape(addslashes($item->title)); ?>">
<?php echo $editIcon; ?><?php echo $this->escape($item->title); ?></a>
<?php else : ?>
<span title="<?php echo Text::sprintf('JFIELD_ALIAS_LABEL', $this->escape($item->alias)); ?>"><?php echo $this->escape($item->title); ?></span>
<?php endif; ?>
<?php if (!empty($this->typeFields['alias'])) : ?>
<span class="small">
<?php echo Text::sprintf('JGLOBAL_LIST_ALIAS', $this->escape($item->alias)); ?>
</span>
<?php endif; ?>
<?php if (!empty($this->typeFields['catid'])) : ?>
<div class="small">
<?php echo Text::_('JCATEGORY') . ": " . $this->escape($item->category_title); ?>
</div>
<?php endif; ?>
</div>
</th>
<td class="small">
<?php echo LayoutHelper::render('joomla.content.language', $item); ?>
Expand Down
Expand Up @@ -12,9 +12,9 @@
use Joomla\CMS\Language\Text;

?>
<a class="btn btn-secondary" type="button" onclick="document.getElementById('batch-category-id').value='';document.getElementById('batch-client-id').value='';document.getElementById('batch-language-id').value=''" data-dismiss="modal">
<button type="button" class="btn btn-secondary" onclick="document.getElementById('batch-category-id').value='';document.getElementById('batch-client-id').value='';document.getElementById('batch-language-id').value=''" data-dismiss="modal">
<?php echo Text::_('JCANCEL'); ?>
</a>
<button class="btn btn-success" type="submit" onclick="Joomla.submitbutton('banner.batch');">
</button>
<button type="submit" class="btn btn-success" onclick="Joomla.submitbutton('banner.batch');">
<?php echo Text::_('JGLOBAL_BATCH_PROCESS'); ?>
</button>
Expand Up @@ -11,9 +11,9 @@
use Joomla\CMS\Language\Text;

?>
<a class="btn btn-secondary" type="button" onclick="document.getElementById('batch-category-id').value='';document.getElementById('batch-access').value='';document.getElementById('batch-language-id').value=''" data-dismiss="modal">
<button type="button" class="btn btn-secondary" onclick="document.getElementById('batch-category-id').value='';document.getElementById('batch-access').value='';document.getElementById('batch-language-id').value=''" data-dismiss="modal">
<?php echo Text::_('JCANCEL'); ?>
</a>
<button class="btn btn-success" type="submit" onclick="Joomla.submitbutton('category.batch');">
</button>
<button type="submit" class="btn btn-success" onclick="Joomla.submitbutton('category.batch');">
<?php echo Text::_('JGLOBAL_BATCH_PROCESS'); ?>
</button>
</button>
Expand Up @@ -11,9 +11,9 @@
use Joomla\CMS\Language\Text;

?>
<a class="btn btn-secondary" type="button" onclick="document.getElementById('batch-category-id').value='';document.getElementById('batch-access').value='';document.getElementById('batch-language-id').value='';document.getElementById('batch-user-id').value='';document.getElementById('batch-tag-id').value=''" data-dismiss="modal">
<button type="button" class="btn btn-secondary" onclick="document.getElementById('batch-category-id').value='';document.getElementById('batch-access').value='';document.getElementById('batch-language-id').value='';document.getElementById('batch-user-id').value='';document.getElementById('batch-tag-id').value=''" data-dismiss="modal">
<?php echo Text::_('JCANCEL'); ?>
</a>
<button class="btn btn-success" type="submit" onclick="Joomla.submitbutton('contact.batch');">
</button>
<button type="submit" class="btn btn-success" onclick="Joomla.submitbutton('contact.batch');">
<?php echo Text::_('JGLOBAL_BATCH_PROCESS'); ?>
</button>
</button>
Expand Up @@ -13,9 +13,9 @@

HTMLHelper::_('script', 'com_content/admin-articles-default-batch-footer.js', ['version' => 'auto', 'relative' => true]);
?>
<button class="btn btn-secondary" type="button" data-dismiss="modal">
<button type="button" class="btn btn-secondary" data-dismiss="modal">
<?php echo Text::_('JCANCEL'); ?>
</button>
<button id='batch-submit-button-id' class="btn btn-success" type="submit" data-submit-task='article.batch'>
<button type="submit" id='batch-submit-button-id' class="btn btn-success" data-submit-task='article.batch'>
<?php echo Text::_('JGLOBAL_BATCH_PROCESS'); ?>
</button>
Expand Up @@ -11,9 +11,9 @@
use Joomla\CMS\Language\Text;

?>
<button class="btn btn-secondary" type="button" onclick="document.getElementById('batch-field-id').value='';document.getElementById('batch-access').value='';document.getElementById('batch-language-id').value=''" data-dismiss="modal">
<button type="button" class="btn btn-secondary" onclick="document.getElementById('batch-field-id').value='';document.getElementById('batch-access').value='';document.getElementById('batch-language-id').value=''" data-dismiss="modal">
<?php echo Text::_('JCANCEL'); ?>
</button>
<button class="btn btn-success" type="submit" onclick="Joomla.submitbutton('field.batch');">
<button type="submit" class="btn btn-success" onclick="Joomla.submitbutton('field.batch');">
<?php echo Text::_('JGLOBAL_BATCH_PROCESS'); ?>
</button>
</button>
Expand Up @@ -11,9 +11,9 @@
use Joomla\CMS\Language\Text;

?>
<button class="btn btn-secondary" type="button" onclick="document.getElementById('batch-field-id').value='';document.getElementById('batch-access').value='';document.getElementById('batch-language-id').value=''" data-dismiss="modal">
<button type="button" class="btn btn-secondary" onclick="document.getElementById('batch-field-id').value='';document.getElementById('batch-access').value='';document.getElementById('batch-language-id').value=''" data-dismiss="modal">
<?php echo Text::_('JCANCEL'); ?>
</button>
<button class="btn btn-success" type="submit" onclick="Joomla.submitbutton('group.batch');">
<button type="submit" class="btn btn-success" onclick="Joomla.submitbutton('group.batch');">
<?php echo Text::_('JGLOBAL_BATCH_PROCESS'); ?>
</button>
</button>
Expand Up @@ -15,11 +15,11 @@
$clientId = $this->state->get('filter.client_id');
$menuType = Factory::getApplication()->getUserState('com_menus.items.menutype');
?>
<a class="btn btn-secondary" type="button" onclick="document.getElementById('batch-menu-id').value='';document.getElementById('batch-access').value='';document.getElementById('batch-language-id').value=''" data-dismiss="modal">
<button type="button" class="btn btn-secondary" onclick="document.getElementById('batch-menu-id').value='';document.getElementById('batch-access').value='';document.getElementById('batch-language-id').value=''" data-dismiss="modal">
<?php echo Text::_('JCANCEL'); ?>
</a>
</button>
<?php if ((strlen($menuType) && $menuType != '*' && $clientId == 0) || ($published > 0 && $clientId == 1)): ?>
<button class="btn btn-success" type="submit" onclick="Joomla.submitbutton('item.batch');">
<button type="submit" class="btn btn-success" onclick="Joomla.submitbutton('item.batch');">
<?php echo Text::_('JGLOBAL_BATCH_PROCESS'); ?>
</button>
<?php endif; ?>
Expand Up @@ -11,9 +11,9 @@
use Joomla\CMS\Language\Text;

?>
<a class="btn btn-secondary" type="button" onclick="document.getElementById('batch-position-id').value='';document.getElementById('batch-access').value='';document.getElementById('batch-language-id').value=''" data-dismiss="modal">
<button type="button" class="btn btn-secondary" onclick="document.getElementById('batch-position-id').value='';document.getElementById('batch-access').value='';document.getElementById('batch-language-id').value=''" data-dismiss="modal">
<?php echo Text::_('JCANCEL'); ?>
</a>
<button class="btn btn-success" type="submit" onclick="Joomla.submitbutton('module.batch');">
</button>
<button type="submit" class="btn btn-success" onclick="Joomla.submitbutton('module.batch');">
<?php echo Text::_('JGLOBAL_BATCH_PROCESS'); ?>
</button>
</button>
Expand Up @@ -12,9 +12,9 @@
use Joomla\CMS\Language\Text;

?>
<a class="btn btn-secondary" type="button" onclick="document.getElementById('batch-category-id').value='';document.getElementById('batch-access').value='';document.getElementById('batch-language-id').value='';document.getElementById('batch-tag-id').value=''" data-dismiss="modal">
<button type="button" class="btn btn-secondary" onclick="document.getElementById('batch-category-id').value='';document.getElementById('batch-access').value='';document.getElementById('batch-language-id').value='';document.getElementById('batch-tag-id').value=''" data-dismiss="modal">
<?php echo Text::_('JCANCEL'); ?>
</a>
<button class="btn btn-success" type="submit" onclick="Joomla.submitbutton('newsfeed.batch');">
</button>
<button type="submit" class="btn btn-success" onclick="Joomla.submitbutton('newsfeed.batch');">
<?php echo Text::_('JGLOBAL_BATCH_PROCESS'); ?>
</button>
</button>

0 comments on commit 1573b6a

Please sign in to comment.