From f6e35ff3fefafe908e1675690340ab93265192a0 Mon Sep 17 00:00:00 2001 From: Pascal Corpet Date: Tue, 8 Jun 2010 22:59:42 +0200 Subject: [PATCH] Fixes accessing to groups having shortnames that look like ids. Closes #1084 --- classes/group.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/classes/group.php b/classes/group.php index f58ff6b..e3f3b62 100644 --- a/classes/group.php +++ b/classes/group.php @@ -93,15 +93,15 @@ class Group return null; } - static public function get($id) + static public function get($id, $can_be_shortname = true) { if (!$id) { return null; } - if (is_int($id) || ctype_digit($id)) { - $where = XDB::format('id = {?}', $id); + if (!$can_be_shortname) { + $where = XDB::format('a.id = {?}', $id); } else { - $where = XDB::format('diminutif = {?}', $id); + $where = XDB::format('a.diminutif = {?}', $id); } $res = XDB::query('SELECT a.*, d.nom AS domnom, FIND_IN_SET(\'wiki_desc\', a.flags) AS wiki_desc, @@ -110,6 +110,9 @@ class Group LEFT JOIN group_dom AS d ON d.id = a.dom WHERE ' . $where); if ($res->numRows() != 1) { + if ($can_be_shortname && (is_int($id) || ctype_digit($id))) { + return Group::get($id, false); + } return null; } return new Group($res->fetchOneAssoc()); -- 2.1.4