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

Last change on this file since 16400 was 16400, checked in by mistic100, 12 years ago
  • display creation date
  • improve set titles for Tags and Calendar
  • add Download history admin page

TODO : User Selection, localization, change archive name to more user-friendly one in the Force-Download

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