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

Last change on this file since 23317 was 23317, checked in by mistic100, 11 years ago

missing translations

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