-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRsg2DbSelections.php
More file actions
64 lines (55 loc) · 1.89 KB
/
Rsg2DbSelections.php
File metadata and controls
64 lines (55 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* Class Rsg2DbSelections
* Contains functions to select images, galleries from the RSGallery2 database
* Returns lists
* @copyright (C) 2015 RSGallery2 Team
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @version 4.0.1
*/
class Rsg2DbSelections
{
/**
* Get a list of all galleries (id/parent) ordered by parent/ordering
* @return array of id/parent associations
*/
public function ListOfAllGalleriesOrdered ()
{
$database = JFactory::getDBO();
$query = $database->getQuery(true);
$query->select('id, parent')
->from('#__rsgallery2_galleries')
->order('parent, ordering');
$database->setQuery( $query );
$allGalleries = $database->loadObjectList();
}
/**
* Get limited ($count) number of random images
* if $gallerySelection is set then only requested galleries will be returned
* @param int $count Restricts size of returned array
* @param string $gallerySelection defines gallery ids to use. Example "2,3"
* @return array of db image items
*/
public function RandomImagesLimited ($count=0, $gallerySelection=null)
{
$database = JFactory::getDBO();
$query = $database->getQuery(true);
$query->select('*')
->from('#__rsgallery2_files')
->where('published = 1');
/* NOTE TODO Access should be checked for galleries, not for images
// If user is not a Super Admin then use View Access Levels
if (!$superAdmin) { // No View Access check for Super Administrators
$query->where('access IN ('.$groupsIN.')'); //@todo use trash state: published=-2
}
*/
// Select only galleries from what user wants
if ($gallerySelection) {
$query->where('gallery_id IN ('.$gallerySelection.')');
}
$query->order('rand()');
$database->setQuery($query, 0, $count); //$count is the number of results to return
$randomImages = $database->loadAssocList();
return $randomImages;
}
}