1 | <?php |
---|
2 | defined('SCHEDULER_PATH') or die('Hacking attempt!'); |
---|
3 | |
---|
4 | /** |
---|
5 | * add a tab on photo properties page |
---|
6 | */ |
---|
7 | function scheduler_tabsheet_before_select($sheets, $id) |
---|
8 | { |
---|
9 | if ($id == 'photo') |
---|
10 | { |
---|
11 | $sheets['scheduler'] = array( |
---|
12 | 'caption' => l10n('Scheduler'), |
---|
13 | 'url' => SCHEDULER_ADMIN.'-photo&image_id='.$_GET['image_id'], |
---|
14 | ); |
---|
15 | } |
---|
16 | |
---|
17 | return $sheets; |
---|
18 | } |
---|
19 | |
---|
20 | /** |
---|
21 | * add a prefilter on photo edit page |
---|
22 | */ |
---|
23 | function scheduler_picture_edit_prefilter($content) |
---|
24 | { |
---|
25 | $search = 'selected=$level_options_selected}'; |
---|
26 | $replace = 'selected=$level_options_selected_scheduler}'; |
---|
27 | |
---|
28 | return str_replace($search, $replace, $content); |
---|
29 | } |
---|
30 | |
---|
31 | function scheduler_photo_edit_replace_level() |
---|
32 | { |
---|
33 | global $page, $template; |
---|
34 | |
---|
35 | if (!isset($_GET['page'])) |
---|
36 | { |
---|
37 | return; |
---|
38 | } |
---|
39 | |
---|
40 | if ($_GET['page'] != 'photo') |
---|
41 | { |
---|
42 | return; |
---|
43 | } |
---|
44 | |
---|
45 | if (isset($_GET['tab']) and $_GET['tab'] != 'properties') |
---|
46 | { |
---|
47 | return; |
---|
48 | } |
---|
49 | |
---|
50 | // is the current photo on schedule? |
---|
51 | $query = ' |
---|
52 | SELECT * |
---|
53 | FROM '.SCHEDULER_TABLE.' |
---|
54 | WHERE image_id = '.$_GET['image_id'].' |
---|
55 | ;'; |
---|
56 | $scheduler = pwg_db_fetch_assoc(pwg_query($query)); |
---|
57 | |
---|
58 | if (!isset($scheduler['scheduled_for'])) |
---|
59 | { |
---|
60 | return; |
---|
61 | } |
---|
62 | |
---|
63 | if (isset($_POST['submit'])) |
---|
64 | { |
---|
65 | // we have to change the level in the scheduler table |
---|
66 | single_update( |
---|
67 | SCHEDULER_TABLE, |
---|
68 | array('level' => $_POST['level']), |
---|
69 | array('image_id' => $_GET['image_id']) |
---|
70 | ); |
---|
71 | |
---|
72 | $scheduler['level'] = $_POST['level']; |
---|
73 | |
---|
74 | // then picture_modify.php will update IMAGES_TABLE to level 32 (=scheduled) |
---|
75 | $_POST['level'] = 32; |
---|
76 | } |
---|
77 | |
---|
78 | $template->set_prefilter('picture_modify', 'scheduler_picture_edit_prefilter'); |
---|
79 | |
---|
80 | $template->assign('level_options_selected_scheduler', array($scheduler['level'])); |
---|
81 | } |
---|
82 | ?> |
---|