Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f8b4756
Joomla! 4.4.8 Rc 3
MacJoom Aug 26, 2024
b7903e5
Revert to dev
MacJoom Aug 26, 2024
f2b1145
Joomla! 4.4.8 Stable
MacJoom Aug 27, 2024
e491457
Revert to dev
MacJoom Aug 27, 2024
22cb27a
[5.2][Events] Use event classes for Authentication plugins (#43601)
Fedik Aug 29, 2024
4bdf8e7
[5.2][Events] Use event classes for Finder plugins (#43607)
Fedik Aug 29, 2024
5147b27
[5.2] Fixing FQSN in BaseModel (#43995)
Hackwar Aug 29, 2024
53a3390
[cypress] PostgreSQL Connection pool for System Tests (#43924)
muhme Aug 29, 2024
56a4640
[5.2][Events] Use event classes for Media-action plugins (#43608)
Fedik Aug 29, 2024
1fa2a60
4.4 to 5.2 upmerge 2024-08-29 (#43996)
Hackwar Aug 29, 2024
4d47d69
[5.2] Tinymce lang sort (#43910)
brianteeman Aug 29, 2024
8a780c3
[Guided Tours] Fix dropdown mouse accessibility on fancy selects (#43…
obuisard Aug 29, 2024
50726be
[5.2] Search for content checked out by an author (#43965)
brianteeman Aug 29, 2024
b19b923
[5.2] SEF: Add option to don't set Itemid to homepage by default (#42…
Hackwar Aug 29, 2024
1af3e65
Revert "4.4 to 5.2 upmerge 2024-08-29" (#43998)
Hackwar Aug 29, 2024
cf6b370
Merge branch 'refs/heads/4.4-dev' into 44-52-upmerge-20240829
Hackwar Aug 29, 2024
7e7dd1c
Merge pull request #43999 from Hackwar/44-52-upmerge-20240829
Hackwar Aug 29, 2024
8de07cc
Articles Module (#43738)
drmenzelit Aug 30, 2024
9275907
[5.2] [Guided tours] Auto start tours - full functionality (#43814)
obuisard Aug 30, 2024
a79cd92
[5.2] Composer dependency updates (#44004)
Hackwar Aug 31, 2024
76252d6
Merge remote-tracking branch 'upstream/5.2-dev' into 5.3/upmerge
HLeithner Sep 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion administrator/components/com_actionlogs/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
label="COM_ACTIONLOGS_LOG_EXTENSIONS_LABEL"
multiple="true"
layout="joomla.form.field.list-fancy-select"
default="com_banners,com_cache,com_categories,com_checkin,com_config,com_contact,com_content,com_fields,com_installer,com_media,com_menus,com_messages,com_modules,com_newsfeeds,com_plugins,com_redirect,com_scheduler,com_tags,com_templates,com_users"
default="com_banners,com_cache,com_categories,com_checkin,com_config,com_contact,com_content,com_fields,com_guidedtours,com_installer,com_media,com_menus,com_messages,com_modules,com_newsfeeds,com_plugins,com_redirect,com_scheduler,com_tags,com_templates,com_users"
/>
<field
name="loggable_api"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Add mod_articles module
INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `locked`, `manifest_cache`, `params`, `custom_data`) VALUES
(0, 'mod_articles', 'module', 'mod_articles', '', 0, 1, 0, 0, 1, '', '', '');
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
--
-- Add the Guided Tours selectable option to the User Action Logs
--
INSERT INTO `#__action_logs_extensions` (`extension`) VALUES ('com_guidedtours');

INSERT INTO `#__action_log_config` (`type_title`, `type_alias`, `id_holder`, `title_holder`, `table_name`, `text_prefix`) VALUES
('guidedtour', 'com_guidedtours.state', 'id', 'title', '#__guidedtours', 'PLG_ACTIONLOG_JOOMLA');
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Add mod_articles module
INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "locked", "manifest_cache", "params", "custom_data", "ordering", "state") VALUES
(0, 'mod_articles', 'module', 'mod_articles', '', 0, 1, 0, 0, 1, '', '', '', 0, 0);
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
--
-- Add the Guided Tours selectable option to the User Action Logs
--
INSERT INTO "#__action_logs_extensions" ("extension") VALUES ("com_guidedtours");

INSERT INTO "#__action_log_config" ("type_title", "type_alias", "id_holder", "title_holder", "table_name", "text_prefix") VALUES
('guidedtour', 'com_guidedtours.state', 'id', 'title', '#__guidedtours', 'PLG_ACTIONLOG_JOOMLA');
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,11 @@ protected function getListQuery()
$search = '%' . substr($search, 8) . '%';
$query->where('(' . $db->quoteName('a.introtext') . ' LIKE :search1 OR ' . $db->quoteName('a.fulltext') . ' LIKE :search2)')
->bind([':search1', ':search2'], $search);
} elseif (stripos($search, 'checkedout:') === 0) {
$search = '%' . substr($search, 11) . '%';
$query->where('(' . $db->quoteName('uc.name') . ' LIKE :search1 OR ' . $db->quoteName('uc.username') . ' LIKE :search2)'
. ' AND ' . $db->quoteName('a.checked_out') . ' IS NOT NULL')
->bind([':search1', ':search2'], $search);
} else {
$search = '%' . str_replace(' ', '%', trim($search)) . '%';
$query->where(
Expand Down
23 changes: 23 additions & 0 deletions administrator/components/com_guidedtours/config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<config>
<fieldset name="guidedtours_config" label="COM_GUIDEDTOURS">
<field
name="allowTourAutoStart"
type="radio"
label="COM_GUIDEDTOURS_CONFIG_USER_ALLOWTOURAUTOSTART_LABEL"
description="COM_GUIDEDTOURS_CONFIG_USER_ALLOWTOURAUTOSTART_DESCRIPTION"
layout="joomla.form.field.radio.switcher"
default="1"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>

<field
name="delayed_time"
type="text"
label="COM_GUIDEDTOURS_CONFIG_DELAYED_TIME_LABEL"
description="COM_GUIDEDTOURS_CONFIG_DELAYED_TIME_DESCRIPTION"
default="60"
size="small"
showon="allowTourAutoStart:1"
/>
</fieldset>
<fieldset
name="permissions"
label="JCONFIG_PERMISSIONS_LABEL"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?php

/**
* @package Joomla.Administrator
* @subpackage com_guidedtours
*
* @copyright (C) 2024 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\Component\Guidedtours\Administrator\Controller;

use Joomla\CMS\Event\AbstractEvent;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Response\JsonResponse;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
* The guided tours controller for ajax requests.
*
* @since __DEPLOY_VERSION__
*/
class AjaxController extends BaseController
{
/**
* Ajax call used when cancelling, skipping or completing a tour.
* It allows:
* - the trigering of before and after events the user state is recorded
* - the recording of the user behavior in the action logs
*/
public function fetchUserState()
{
$user = $this->app->getIdentity();

$tourId = $this->app->input->getInt('tid', 0);
$stepNumber = $this->app->input->getString('sid', '');
$context = $this->app->input->getString('context', '');

if ($user != null && $user->id > 0) {
$actionState = '';

switch ($context) {
case 'tour.complete':
$actionState = 'completed';
break;
case 'tour.cancel':
$actionState = 'delayed';
break;
case 'tour.skip':
$actionState = 'skipped';
break;
}

PluginHelper::importPlugin('guidedtours');

// event onBeforeTourSaveUserState before save user tour state
$beforeEvent = AbstractEvent::create(
'onBeforeTourSaveUserState',
[
'subject' => new \stdClass(),
'tourId' => $tourId,
'actionState' => $actionState,
'stepNumber' => $stepNumber,
]
);

$this->app->getDispatcher()->dispatch('onBeforeTourSaveUserState', $beforeEvent);

// Save the tour state only when the tour auto-starts.
$tourModel = $this->getModel('Tour', 'Administrator');
if ($tourModel->isAutostart($tourId)) {
$result = $tourModel->saveTourUserState($tourId, $actionState);
if ($result) {
$message = Text::sprintf('COM_GUIDEDTOURS_USERSTATE_STATESAVED', $user->id, $tourId);
} else {
$message = Text::sprintf('COM_GUIDEDTOURS_USERSTATE_STATENOTSAVED', $user->id, $tourId);
}
} else {
$result = false;
$message = Text::sprintf('COM_GUIDEDTOURS_USERSTATE_STATENOTSAVED', $user->id, $tourId);
}

// event onAfterTourSaveUserState after save user tour state (may override message)
$afterEvent = AbstractEvent::create(
'onAfterTourSaveUserState',
[
'subject' => new \stdClass(),
'tourId' => $tourId,
'actionState' => $actionState,
'stepNumber' => $stepNumber,
'result' => $result,
'message' => &$message,
]
);

$this->app->getDispatcher()->dispatch('onAfterTourSaveUserState', $afterEvent);

// Construct the response data
$data = [
'tourId' => $tourId,
'stepId' => $stepNumber,
'context' => $context,
'state' => $actionState,
];
echo new JsonResponse($data, $message);
$this->app->close();
} else {
// Construct the response data
$data = [
'success' => false,
'tourId' => $tourId,
];

$message = Text::_('COM_GUIDEDTOURS_USERSTATE_CONNECTEDONLY');
echo new JsonResponse($data, $message, true);
$this->app->close();
}
}
}
79 changes: 74 additions & 5 deletions administrator/components/com_guidedtours/src/Model/TourModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace Joomla\Component\Guidedtours\Administrator\Model;

use Joomla\CMS\Date\Date;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Log\Log;
Expand Down Expand Up @@ -530,20 +531,28 @@ public function setAutostart($id, $autostart)
/**
* Retrieve a tour's autostart value
*
* @param string $uid the uid of a tour
* @param string $pk the id or uid of a tour
*
* @return boolean
*
* @since 5.1.0
*/
public function isAutostart($uid)
public function isAutostart($pk): bool
{
$db = $this->getDatabase();

$query = $db->getQuery(true)
->select($db->quoteName('autostart'))
->from($db->quoteName('#__guidedtours'))
->where($db->quoteName('published') . ' = 1')
->where($db->quoteName('uid') . ' = :uid')
->bind(':uid', $uid, ParameterType::STRING);
->where($db->quoteName('published') . ' = 1');

if (\is_integer($pk)) {
$query->where($db->quoteName('id') . ' = :id')
->bind(':id', $pk, ParameterType::INTEGER);
} else {
$query->where($db->quoteName('uid') . ' = :uid')
->bind(':uid', $pk, ParameterType::STRING);
}

$db->setQuery($query);

Expand All @@ -558,4 +567,64 @@ public function isAutostart($uid)

return $result;
}

/**
* Save a tour state for a specific user.
*
* @param int $id The id of the tour
* @param string $state The label of the state to be saved (completed, delayed or skipped)
*
* @return boolean
*
* @since __DEPLOY_VERSION__
*/
public function saveTourUserState($id, $state = ''): bool
{
$user = $this->getCurrentUser();
$db = $this->getDatabase();

$profileKey = 'guidedtour.id.' . $id;

// Check if the profile key already exists.
$query = $db->getQuery(true)
->select($db->quoteName('profile_value'))
->from($db->quoteName('#__user_profiles'))
->where($db->quoteName('user_id') . ' = :user_id')
->where($db->quoteName('profile_key') . ' = :profileKey')
->bind(':user_id', $user->id, ParameterType::INTEGER)
->bind(':profileKey', $profileKey, ParameterType::STRING);

try {
$result = $db->setQuery($query)->loadResult();
} catch (\Exception $e) {
return false;
}

$tourState = [];

$tourState['state'] = $state;
if ($state === 'delayed') {
$tourState['time'] = Date::getInstance();
}

$profileObject = (object)[
'user_id' => $user->id,
'profile_key' => $profileKey,
'profile_value' => json_encode($tourState),
'ordering' => 0,
];

if (!\is_null($result)) {
$values = json_decode($result, true);

// The profile is updated only when delayed. 'Completed' and 'Skipped' are final
if (!empty($values) && $values['state'] === 'delayed') {
$db->updateObject('#__user_profiles', $profileObject, ['user_id', 'profile_key']);
}
} else {
$db->insertObject('#__user_profiles', $profileObject);
}

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace Joomla\Component\Media\Administrator\Plugin;

use Joomla\CMS\Event\Model\PrepareFormEvent;
use Joomla\CMS\Form\Form;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Plugin\CMSPlugin;
Expand All @@ -34,6 +35,35 @@ class MediaActionPlugin extends CMSPlugin
*/
protected $autoloadLanguage = true;

/**
* Returns an array of events this subscriber will listen to.
*
* @return array
*
* @since __DEPLOY_VERSION__
*/
public static function getSubscribedEvents(): array
{
return [
'onContentPrepareForm' => 'onContentPrepareFormListener',
];
}

/**
* The form event. Load additional parameters when available into the field form.
* Only when the type of the form is of interest.
*
* @param PrepareFormEvent $event Event instance.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function onContentPrepareFormListener(PrepareFormEvent $event): void
{
$this->onContentPrepareForm($event->getForm(), $event->getData());
}

/**
* The form event. Load additional parameters when available into the field form.
* Only when the type of the form is of interest.
Expand Down
12 changes: 12 additions & 0 deletions administrator/components/com_users/forms/user.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,18 @@
<option value="dark">COM_USERS_USER_COLORSCHEME_OPTION_DARK</option>
</field>

<field
name="allowTourAutoStart"
type="list"
label="COM_USERS_USER_ALLOWTOURAUTOSTART_LABEL"
default=""
validate="options"
>
<option value="">JOPTION_USE_DEFAULT</option>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>

<field
name="admin_language"
type="language"
Expand Down
2 changes: 1 addition & 1 deletion administrator/language/en-GB/com_content.ini
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ COM_CONTENT_FIELDSET_URLS_AND_IMAGES="Images and Links"
COM_CONTENT_FILTER_AUTHORS_BY_ME="Created by me"
COM_CONTENT_FILTER_FEATURED_NO="Unfeatured Articles"
COM_CONTENT_FILTER_FEATURED_YES="Featured Articles"
COM_CONTENT_FILTER_SEARCH_DESC="Search in title, alias and note. Prefix with ID: or AUTHOR: or CONTENT: to search for an article ID, article author or search in article content."
COM_CONTENT_FILTER_SEARCH_DESC="Search in title, alias and note. Prefix with ID: or AUTHOR: or CONTENT: to search for an article ID, article author or search in article content. Prefix with CHECKEDOUT: to search for content checked out by a specified user."
COM_CONTENT_FILTER_SEARCH_LABEL="Search Articles"
COM_CONTENT_FORM_TITLE_EDIT="Edit Article"
COM_CONTENT_FORM_TITLE_NEW="New Article"
Expand Down
7 changes: 7 additions & 0 deletions administrator/language/en-GB/com_guidedtours.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
COM_GUIDEDTOURS="Guided Tours"
COM_GUIDEDTOURS_AUTOSTART_DESC="Start the tour automatically when a user reaches the context in which the tour should be displayed."
COM_GUIDEDTOURS_AUTOSTART_LABEL="Auto Start"
COM_GUIDEDTOURS_CONFIG_DELAYED_TIME_DESCRIPTION="The amount of time (in minutes) a tour is delayed after being cancelled by the user and until it is shown again (only when a tour is set to start automatically).<br>For instance, enter 60 for 1 hour, 1440 for 24 hours, 10080 for 1 week."
COM_GUIDEDTOURS_CONFIG_DELAYED_TIME_LABEL="Auto Start Time Delay (in minutes)"
COM_GUIDEDTOURS_CONFIG_USER_ALLOWTOURAUTOSTART_DESCRIPTION="Turn on or off the auto starting functionality of tours."
COM_GUIDEDTOURS_CONFIG_USER_ALLOWTOURAUTOSTART_LABEL="Allow Auto Starting Tours"
COM_GUIDEDTOURS_CONFIGURATION="Guided Tours: Options"
COM_GUIDEDTOURS_DESCRIPTION="Description"
COM_GUIDEDTOURS_DESCRIPTION_TRANSLATION="Description (%s)"
Expand Down Expand Up @@ -90,4 +94,7 @@ COM_GUIDEDTOURS_TYPE_REDIRECT_URL_DESC="Enter the relative URL of the page you w
COM_GUIDEDTOURS_TYPE_REDIRECT_URL_LABEL="Relative URL"
COM_GUIDEDTOURS_URL_LABEL="Relative URL"
COM_GUIDEDTOURS_URL_DESC="Enter the relative URL of the page from where you want to Start the tour, e.g administrator/index.php?option=com_guidedtours&view=tours for the tours' list page."
COM_GUIDEDTOURS_USERSTATE_CONNECTEDONLY="Tour User state action is only for connected users."
COM_GUIDEDTOURS_USERSTATE_STATENOTSAVED="Tour User state not saved for user %1$s tour %2$s."
COM_GUIDEDTOURS_USERSTATE_STATESAVED="Tour User state saved for user %1$s tour %2$s."
COM_GUIDEDTOURS_XML_DESCRIPTION="Component for managing Guided Tours functionality."
Loading