Skip to content

Commit

Permalink
use the administrator default language for Mail template
Browse files Browse the repository at this point in the history
  • Loading branch information
carlitorweb committed May 5, 2024
1 parent f316e46 commit b13a47a
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions administrator/components/com_users/src/Model/UserModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Joomla\CMS\Form\Form;
use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Mail\MailTemplate;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Plugin\PluginHelper;
Expand Down Expand Up @@ -303,9 +304,9 @@ public function save($data)
*/
public function delete(&$pks)
{
$user = $this->getCurrentUser();
$table = $this->getTable();
$pks = (array) $pks;
$user = $this->getCurrentUser();
$table = $this->getTable();
$pks = (array) $pks;

// Check if I am a Super Admin
$iAmSuperAdmin = $user->authorise('core.admin');
Expand Down Expand Up @@ -370,8 +371,8 @@ public function delete(&$pks)
*/
public function block(&$pks, $value = 1)
{
$app = Factory::getApplication();
$user = $this->getCurrentUser();
$app = Factory::getApplication();
$user = $this->getCurrentUser();

// Check if I am a Super Admin
$iAmSuperAdmin = $user->authorise('core.admin');
Expand Down Expand Up @@ -474,15 +475,15 @@ public function block(&$pks, $value = 1)
*/
public function activate(&$pks)
{
$app = Factory::getApplication();
$user = $app->getIdentity();
$app = Factory::getApplication();
$user = $app->getIdentity();

// Check if I am a super admin
$iAmSuperAdmin = $user->authorise('core.admin');
$iAmSuperAdmin = $user->authorise('core.admin');

// Load user table
$table = $this->getTable();
$pks = (array) $pks;
$table = $this->getTable();
$pks = (array) $pks;

// Compile the user activated notification mail default values.
$mailData = [];
Expand All @@ -491,14 +492,14 @@ public function activate(&$pks)
$mailData['mailfrom'] = $app->get('mailfrom');
$mailData['sitename'] = $app->get('sitename');

// Load com_users site language strings, the mail template use it
$app->getLanguage()->load('com_users', JPATH_SITE);

$sendMailTo = function ($userData) use ($app, $mailData) {
$mailData['name'] = $userData['name'];
$mailData['username'] = $userData['username'];

$mailer = new \Joomla\CMS\Mail\MailTemplate('com_users.registration.user.admin_activated', $app->getLanguage()->getTag());
// Use the default language
$langTag = ComponentHelper::getParams('com_languages')->get('administrator', 'en-GB');

$mailer = new MailTemplate('com_users.registration.user.admin_activated', $langTag);
$mailer->addTemplateData($mailData);
$mailer->addRecipient($userData['email']);

Expand Down Expand Up @@ -536,7 +537,7 @@ public function activate(&$pks)
$allow = $user->authorise('core.edit.state', 'com_users');

// Don't allow non-super-admin to edit the active status of a super admin
$allow = (!$iAmSuperAdmin && Access::check($pk, 'core.admin')) ? false : $allow;
$allow = (!$iAmSuperAdmin && Access::check($pk, 'core.admin')) ? false : $allow;

// Ignore activated accounts but check if we can still
// resend the notification email
Expand Down Expand Up @@ -668,7 +669,7 @@ public function batch($commands, $pks, $contexts)
*/
public function batchReset($userIds, $action)
{
$userIds = ArrayHelper::toInteger($userIds);
$userIds = ArrayHelper::toInteger($userIds);

// Check if I am a Super Admin
$iAmSuperAdmin = $this->getCurrentUser()->authorise('core.admin');
Expand Down Expand Up @@ -697,11 +698,11 @@ public function batchReset($userIds, $action)
}

// Get the DB object
$db = $this->getDatabase();
$db = $this->getDatabase();

$userIds = ArrayHelper::toInteger($userIds);

$query = $db->getQuery(true);
$query = $db->getQuery(true);

// Update the reset flag
$query->update($db->quoteName('#__users'))
Expand Down Expand Up @@ -735,7 +736,7 @@ public function batchReset($userIds, $action)
*/
public function batchUser($groupId, $userIds, $action)
{
$userIds = ArrayHelper::toInteger($userIds);
$userIds = ArrayHelper::toInteger($userIds);

// Check if I am a Super Admin
$iAmSuperAdmin = $this->getCurrentUser()->authorise('core.admin');
Expand Down Expand Up @@ -923,8 +924,8 @@ public function getAssignedGroups($userId = null)
$userId = (!empty($userId)) ? $userId : (int) $this->getState('user.id');

if (empty($userId)) {
$result = [];
$form = $this->getForm();
$result = [];
$form = $this->getForm();

if ($form) {
$groupsIDs = $form->getValue('groups');
Expand Down

0 comments on commit b13a47a

Please sign in to comment.