Skip to content

Commit 2f5bda6

Browse files
authored
Merge branch '4.0-dev' into 4.0_dashboardmenu
2 parents 684db0f + 921913f commit 2f5bda6

File tree

5 files changed

+40
-23
lines changed

5 files changed

+40
-23
lines changed

installation/sql/mysql/joomla.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`,
633633
(0, 'plg_quickicon_extensionupdate', 'plugin', 'extensionupdate', 'quickicon', 0, 1, 1, 1, '', '', 0, '0000-00-00 00:00:00', 0, 0),
634634
(0, 'plg_captcha_recaptcha', 'plugin', 'recaptcha', 'captcha', 0, 0, 1, 0, '', '{"public_key":"","private_key":"","theme":"clean"}', 0, '0000-00-00 00:00:00', 0, 0),
635635
(0, 'plg_system_highlight', 'plugin', 'highlight', 'system', 0, 1, 1, 0, '', '', 0, '0000-00-00 00:00:00', 7, 0),
636-
(0, 'plg_content_finder', 'plugin', 'finder', 'content', 0, 0, 1, 0, '', '', 0, '0000-00-00 00:00:00', 0, 0),
636+
(0, 'plg_content_finder', 'plugin', 'finder', 'content', 0, 1, 1, 0, '', '', 0, '0000-00-00 00:00:00', 0, 0),
637637
(0, 'plg_finder_categories', 'plugin', 'categories', 'finder', 0, 1, 1, 0, '', '', 0, '0000-00-00 00:00:00', 1, 0),
638638
(0, 'plg_finder_contacts', 'plugin', 'contacts', 'finder', 0, 1, 1, 0, '', '', 0, '0000-00-00 00:00:00', 2, 0),
639639
(0, 'plg_finder_content', 'plugin', 'content', 'finder', 0, 1, 1, 0, '', '', 0, '0000-00-00 00:00:00', 3, 0),

installation/sql/postgresql/joomla.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder",
644644
(0, 'plg_quickicon_extensionupdate', 'plugin', 'extensionupdate', 'quickicon', 0, 1, 1, 1, '', '', 0, '1970-01-01 00:00:00', 0, 0),
645645
(0, 'plg_captcha_recaptcha', 'plugin', 'recaptcha', 'captcha', 0, 0, 1, 0, '', '{"public_key":"","private_key":"","theme":"clean"}', 0, '1970-01-01 00:00:00', 0, 0),
646646
(0, 'plg_system_highlight', 'plugin', 'highlight', 'system', 0, 1, 1, 0, '', '', 0, '1970-01-01 00:00:00', 7, 0),
647-
(0, 'plg_content_finder', 'plugin', 'finder', 'content', 0, 0, 1, 0, '', '', 0, '1970-01-01 00:00:00', 0, 0),
647+
(0, 'plg_content_finder', 'plugin', 'finder', 'content', 0, 1, 1, 0, '', '', 0, '1970-01-01 00:00:00', 0, 0),
648648
(0, 'plg_finder_categories', 'plugin', 'categories', 'finder', 0, 1, 1, 0, '', '', 0, '1970-01-01 00:00:00', 1, 0),
649649
(0, 'plg_finder_contacts', 'plugin', 'contacts', 'finder', 0, 1, 1, 0, '', '', 0, '1970-01-01 00:00:00', 2, 0),
650650
(0, 'plg_finder_content', 'plugin', 'content', 'finder', 0, 1, 1, 0, '', '', 0, '1970-01-01 00:00:00', 3, 0),

libraries/src/User/User.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -401,22 +401,27 @@ public function getAuthorisedCategories($component, $action)
401401
$db = Factory::getDbo();
402402

403403
$subQuery = $db->getQuery(true)
404-
->select('id,asset_id')
405-
->from('#__categories')
406-
->where('extension = ' . $db->quote($component))
407-
->where('published = 1');
404+
->select($db->quoteName(['id', 'asset_id']))
405+
->from($db->quoteName('#__categories'))
406+
->where(
407+
[
408+
$db->quoteName('extension') . ' = :component',
409+
$db->quoteName('published') . ' = 1',
410+
]
411+
);
408412

409413
$query = $db->getQuery(true)
410-
->select('c.id AS id, a.name AS asset_name')
411-
->from('(' . (string) $subQuery . ') AS c')
412-
->join('INNER', '#__assets AS a ON c.asset_id = a.id');
414+
->select($db->quoteName(['c.id', 'a.name']))
415+
->from('(' . $subQuery . ') AS ' . $db->quoteName('c'))
416+
->join('INNER', $db->quoteName('#__assets', 'a'), $db->quoteName('c.asset_id') . ' = ' . $db->quoteName('a.id'))
417+
->bind(':component', $component);
413418
$db->setQuery($query);
414419
$allCategories = $db->loadObjectList('id');
415420
$allowedCategories = array();
416421

417422
foreach ($allCategories as $category)
418423
{
419-
if ($this->authorise($action, $category->asset_name))
424+
if ($this->authorise($action, $category->name))
420425
{
421426
$allowedCategories[] = (int) $category->id;
422427
}

libraries/src/User/UserFactory.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ public function loadUserByUsername(string $username): User
6565
$query = $this->db->getQuery(true)
6666
->select($this->db->quoteName('id'))
6767
->from($this->db->quoteName('#__users'))
68-
->where($this->db->quoteName('username') . ' = ' . $this->db->quote($username));
69-
$query->setLimit(1, 0);
68+
->where($this->db->quoteName('username') . ' = :username')
69+
->bind(':username', $username)
70+
->setLimit(1);
7071
$this->db->setQuery($query);
7172

7273
return $this->loadUserById((int) $this->db->loadResult());

libraries/src/User/UserHelper.php

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use Joomla\CMS\Object\CMSObject;
2727
use Joomla\CMS\Plugin\PluginHelper;
2828
use Joomla\CMS\Uri\Uri;
29+
use Joomla\Database\ParameterType;
2930
use Joomla\Utilities\ArrayHelper;
3031

3132
/**
@@ -108,8 +109,12 @@ abstract class UserHelper
108109
*/
109110
public static function addUserToGroup($userId, $groupId)
110111
{
112+
// Cast as integer until method is typehinted.
113+
$userId = (int) $userId;
114+
$groupId = (int) $groupId;
115+
111116
// Get the user object.
112-
$user = new User((int) $userId);
117+
$user = new User($userId);
113118

114119
// Add the user to the group if necessary.
115120
if (!in_array($groupId, $user->groups))
@@ -119,7 +124,8 @@ public static function addUserToGroup($userId, $groupId)
119124
$query = $db->getQuery(true)
120125
->select($db->quoteName('id'))
121126
->from($db->quoteName('#__usergroups'))
122-
->where($db->quoteName('id') . ' = ' . (int) $groupId);
127+
->where($db->quoteName('id') . ' = :groupId')
128+
->bind(':groupId', $groupId, ParameterType::INTEGER);
123129
$db->setQuery($query);
124130

125131
// If the group does not exist, return an exception.
@@ -136,7 +142,7 @@ public static function addUserToGroup($userId, $groupId)
136142
}
137143

138144
// Set the group data for any preloaded user objects.
139-
$temp = User::getInstance((int) $userId);
145+
$temp = User::getInstance($userId);
140146
$temp->groups = $user->groups;
141147

142148
if (Factory::getSession()->getId())
@@ -234,9 +240,9 @@ public static function setUserGroups($userId, $groups)
234240
// Get the titles for the user groups.
235241
$db = Factory::getDbo();
236242
$query = $db->getQuery(true)
237-
->select($db->quoteName('id') . ', ' . $db->quoteName('title'))
243+
->select($db->quoteName(['id', 'title']))
238244
->from($db->quoteName('#__usergroups'))
239-
->where($db->quoteName('id') . ' = ' . implode(' OR ' . $db->quoteName('id') . ' = ', $user->groups));
245+
->whereIn($db->quoteName('id'), $user->groups);
240246
$db->setQuery($query);
241247
$results = $db->loadObjectList();
242248

@@ -307,22 +313,25 @@ public static function getProfile($userId = 0)
307313
*/
308314
public static function activateUser($activation)
309315
{
310-
$db = Factory::getDbo();
316+
$db = Factory::getDbo();
317+
$nullDate = $db->getNullDate();
311318

312319
// Let's get the id of the user we want to activate
313320
$query = $db->getQuery(true)
314321
->select($db->quoteName('id'))
315322
->from($db->quoteName('#__users'))
316-
->where($db->quoteName('activation') . ' = ' . $db->quote($activation))
323+
->where($db->quoteName('activation') . ' = :activation')
317324
->where($db->quoteName('block') . ' = 1')
318-
->where($db->quoteName('lastvisitDate') . ' = ' . $db->quote($db->getNullDate()));
325+
->where($db->quoteName('lastvisitDate') . ' = :nullDate')
326+
->bind(':activation', $activation)
327+
->bind(':nullDate', $nullDate);
319328
$db->setQuery($query);
320329
$id = (int) $db->loadResult();
321330

322331
// Is it a valid user to activate?
323332
if ($id)
324333
{
325-
$user = User::getInstance((int) $id);
334+
$user = User::getInstance($id);
326335

327336
$user->set('block', '0');
328337
$user->set('activation', '');
@@ -361,8 +370,10 @@ public static function getUserId($username)
361370
$query = $db->getQuery(true)
362371
->select($db->quoteName('id'))
363372
->from($db->quoteName('#__users'))
364-
->where($db->quoteName('username') . ' = ' . $db->quote($username));
365-
$db->setQuery($query, 0, 1);
373+
->where($db->quoteName('username') . ' = :username')
374+
->bind(':username', $username)
375+
->setLimit(1);
376+
$db->setQuery($query);
366377

367378
return $db->loadResult();
368379
}

0 commit comments

Comments
 (0)