forked from GNUsocial/gnu-social
Make group search in Directory use PEAR::DB
No more direct SQL queries please.
This commit is contained in:
parent
66df043c19
commit
b039d960f5
@ -27,12 +27,7 @@
|
|||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET'))
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
{
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once INSTALLDIR . '/lib/publicgroupnav.php';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Group directory
|
* Group directory
|
||||||
@ -40,6 +35,7 @@ require_once INSTALLDIR . '/lib/publicgroupnav.php';
|
|||||||
* @category Directory
|
* @category Directory
|
||||||
* @package StatusNet
|
* @package StatusNet
|
||||||
* @author Zach Copley <zach@status.net>
|
* @author Zach Copley <zach@status.net>
|
||||||
|
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
@ -308,6 +304,14 @@ class GroupdirectoryAction extends Action
|
|||||||
|
|
||||||
if (isset($this->q)) {
|
if (isset($this->q)) {
|
||||||
|
|
||||||
|
// Disable this to get global group searches
|
||||||
|
$group->joinAdd(array('id', 'local_group:group_id'));
|
||||||
|
|
||||||
|
$wheres = array('nickname', 'fullname', 'homepage', 'description', 'location');
|
||||||
|
foreach ($wheres as $where) {
|
||||||
|
$group->whereAdd("LOWER({$group->__table}.{$where}) LIKE LOWER('%".$group->escape($this->q)."%')", 'OR');
|
||||||
|
}
|
||||||
|
|
||||||
$order = 'user_group.created ASC';
|
$order = 'user_group.created ASC';
|
||||||
|
|
||||||
if ($this->sort == 'nickname') {
|
if ($this->sort == 'nickname') {
|
||||||
@ -322,17 +326,8 @@ class GroupdirectoryAction extends Action
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = <<< GROUP_QUERY_END
|
$group->orderBy($order);
|
||||||
SELECT user_group.*
|
$group->limit($offset, $limit);
|
||||||
FROM user_group
|
|
||||||
JOIN local_group ON user_group.id = local_group.group_id
|
|
||||||
ORDER BY %s
|
|
||||||
LIMIT %d, %d
|
|
||||||
GROUP_QUERY_END;
|
|
||||||
|
|
||||||
$cnt = 0;
|
|
||||||
$group->query(sprintf($sql, $order, $limit, $offset));
|
|
||||||
$group->find();
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// User is browsing via AlphaNav
|
// User is browsing via AlphaNav
|
||||||
@ -371,6 +366,8 @@ GROUP_QUERY_END;
|
|||||||
$group->query($sql);
|
$group->query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$group->find();
|
||||||
|
|
||||||
return $group;
|
return $group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user