source: extensions/BatchDownloader/admin/sets.php @ 16609

Last change on this file since 16609 was 16598, checked in by mistic100, 12 years ago

-fix template override with UserCollection
-localization

File size: 3.7 KB
Line 
1<?php
2if (!defined('BATCH_DOWNLOAD_PATH')) die('Hacking attempt!');
3
4// actions
5if (isset($_GET['delete']))
6{
7  $BatchDownloader = new BatchDownloader($_GET['delete']);
8  $BatchDownloader->deleteLastArchive();
9  $BatchDownloader->clearImages();
10  pwg_query('DELETE FROM '.BATCH_DOWNLOAD_TSETS.' WHERE id = '.$_GET['delete'].';');
11}
12if (isset($_GET['cancel']))
13{
14  $BatchDownloader = new BatchDownloader($_GET['cancel']); 
15  $BatchDownloader->updateParam('total_size', $BatchDownloader->getEstimatedTotalSize());
16  $BatchDownloader->updateParam('status', 'done');
17  $BatchDownloader->deleteLastArchive();
18  $BatchDownloader->clearImages();
19}
20
21
22// filter
23$where_clauses = array('1=1');
24$order_by = 'date_creation DESC, status DESC';
25
26if (isset($_POST['filter']))
27{
28  if (!empty($_POST['username']))
29  {
30    array_push($where_clauses, 'username LIKE "%'.$_POST['username'].'%"');
31  }
32 
33  if ($_POST['type'] != -1)
34  {
35    array_push($where_clauses, 'type = "'.$_POST['type'].'"');
36  }
37 
38  if ($_POST['status'] != -1)
39  {
40    array_push($where_clauses, 'status = "'.$_POST['status'].'"');
41  }
42 
43  $order_by = $_POST['order_by'].' '.$_POST['direction'];
44}
45
46
47// get sets
48$query = '
49SELECT
50    s.id,
51    u.'.$conf['user_fields']['username'].' AS username
52  FROM '.BATCH_DOWNLOAD_TSETS.' AS s
53    INNER JOIN '.USERS_TABLE.' AS u
54    ON s.user_id = u.'.$conf['user_fields']['id'].'
55  WHERE
56    '.implode("\n    AND ", $where_clauses).'
57  ORDER BY '.$order_by.'
58;';
59$sets = simple_hash_from_query($query, 'id', 'username');
60
61foreach ($sets as $set_id => $username)
62{
63  $set = new BatchDownloader($set_id);
64  $template->append('sets', array_merge(
65    $set->getSetInfo(),
66    array(
67      'USERNAME' => $username,
68      'STATUS' => $set->getParam('status'),
69      'LAST_ZIP' => $set->getParam('last_zip'),
70      'U_DELETE' => BATCH_DOWNLOAD_ADMIN . '-sets&amp;delete='.$set->getParam('set_id'),
71      'U_CANCEL' => BATCH_DOWNLOAD_ADMIN . '-sets&amp;cancel='.$set->getParam('set_id'),
72    )
73    ));
74}
75
76
77// filter options
78$page['status_items'] = array(
79  -1 => '------------',
80  'new' => l10n('new'),
81  'download' => l10n('download'),
82  'done' => l10n('done'),
83  );
84
85$page['type_items'] = array(
86  -1 => '------------',
87  'calendar' => l10n('Calendar'),
88  'category' => l10n('Album'),
89  'flat' => l10n('Whole gallery'),
90  'tags' => l10n('Tags'),
91  'search' => l10n('Search'),
92  'favorites' => l10n('Favorites'),
93  'most_visited' => l10n('Most visited'),
94  'best_rated' => l10n('Best rated'),
95  'list' => l10n('Random'),
96  'recent_pics' => l10n('Recent photos'),
97  'collection' => l10n('User collection'),
98  );
99
100$page['order_by_items'] = array(
101  'date_creation' => l10n('Creation date'),
102  'total_size' => l10n('Total size'),
103  'nb_images' => l10n('Nb images'),
104  'nb_archives' => l10n('Nb archives'),
105  );
106
107$page['direction_items'] = array(
108  'DESC' => l10n('descending'),
109  'ASC' => l10n('ascending'),
110  );
111
112$template->assign('status_options', $page['status_items']);
113$template->assign('status_selected',
114    isset($_POST['status']) ? $_POST['status'] : '');
115
116$template->assign('type_options', $page['type_items']);
117$template->assign('type_selected',
118    isset($_POST['type']) ? $_POST['type'] : '');
119
120$template->assign('order_options', $page['order_by_items']);
121$template->assign('order_selected',
122    isset($_POST['order_by']) ? $_POST['order_by'] : '');
123
124$template->assign('direction_options', $page['direction_items']);
125$template->assign('direction_selected',
126    isset($_POST['direction']) ? $_POST['direction'] : '');
127
128
129$template->assign(array(
130  'F_USERNAME' => @htmlentities($_POST['username'], ENT_COMPAT, 'UTF-8'),
131  'F_FILTER_ACTION' => BATCH_DOWNLOAD_ADMIN . '-sets',
132  ));
133
134
135$template->set_filename('batch_download', dirname(__FILE__) . '/template/sets.tpl');
136
137?>
Note: See TracBrowser for help on using the repository browser.