1 | <?php |
---|
2 | defined('SCHEDULER_PATH') or die('Hacking attempt!'); |
---|
3 | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Basic checks and infos | |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | |
---|
8 | check_status(ACCESS_ADMINISTRATOR); |
---|
9 | |
---|
10 | check_input_parameter('image_id', $_GET, false, PATTERN_ID); |
---|
11 | |
---|
12 | $admin_photo_base_url = get_root_url().'admin.php?page=photo-'.$_GET['image_id']; |
---|
13 | $self_url = SCHEDULER_ADMIN.'-photo&image_id='.$_GET['image_id']; |
---|
14 | |
---|
15 | /* Initialisation */ |
---|
16 | $query = ' |
---|
17 | SELECT * |
---|
18 | FROM '.IMAGES_TABLE.' |
---|
19 | WHERE id = '.$_GET['image_id'].' |
---|
20 | ;'; |
---|
21 | $picture = pwg_db_fetch_assoc(pwg_query($query)); |
---|
22 | |
---|
23 | $query = ' |
---|
24 | SELECT * |
---|
25 | FROM '.SCHEDULER_TABLE.' |
---|
26 | WHERE image_id = '.$picture['id'].' |
---|
27 | ;'; |
---|
28 | $scheduler = pwg_db_fetch_assoc(pwg_query($query)); |
---|
29 | |
---|
30 | if (isset($scheduler['scheduled_for'])) |
---|
31 | { |
---|
32 | $scheduler['scheduled_for'] = date('Y-m-d H:i', strtotime($scheduler['scheduled_for'])); |
---|
33 | } |
---|
34 | |
---|
35 | // +-----------------------------------------------------------------------+ |
---|
36 | // | Photo[Scheduler] tab | |
---|
37 | // +-----------------------------------------------------------------------+ |
---|
38 | |
---|
39 | include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); |
---|
40 | $tabsheet = new tabsheet(); |
---|
41 | $tabsheet->set_id('photo'); // <= don't forget tabsheet id |
---|
42 | $tabsheet->select('scheduler'); |
---|
43 | $tabsheet->assign(); |
---|
44 | |
---|
45 | // +-----------------------------------------------------------------------+ |
---|
46 | // | Process form | |
---|
47 | // +-----------------------------------------------------------------------+ |
---|
48 | |
---|
49 | if (isset($_POST['scheduled_for'])) |
---|
50 | { |
---|
51 | $scheduled_for = date('Y-m-d H:i', strtotime($_POST['scheduled_for'])); |
---|
52 | |
---|
53 | $level = $picture['level']; |
---|
54 | if (isset($scheduler['level'])) |
---|
55 | { |
---|
56 | $level = $scheduler['level']; |
---|
57 | } |
---|
58 | |
---|
59 | $query = ' |
---|
60 | DELETE |
---|
61 | FROM '.SCHEDULER_TABLE.' |
---|
62 | WHERE image_id = '.$picture['id'].' |
---|
63 | ;'; |
---|
64 | pwg_query($query); |
---|
65 | |
---|
66 | single_insert( |
---|
67 | SCHEDULER_TABLE, |
---|
68 | array( |
---|
69 | 'image_id' => $picture['id'], |
---|
70 | 'scheduled_for' => $scheduled_for, |
---|
71 | 'level' => $level |
---|
72 | ) |
---|
73 | ); |
---|
74 | |
---|
75 | single_update( |
---|
76 | IMAGES_TABLE, |
---|
77 | array('level' => 32), |
---|
78 | array('id' => $picture['id']) |
---|
79 | ); |
---|
80 | |
---|
81 | invalidate_user_cache(); |
---|
82 | |
---|
83 | $_SESSION['page_infos'] = array(l10n('Photo informations updated')); |
---|
84 | redirect($self_url); |
---|
85 | } |
---|
86 | |
---|
87 | // +-----------------------------------------------------------------------+ |
---|
88 | // | Display page | |
---|
89 | // +-----------------------------------------------------------------------+ |
---|
90 | |
---|
91 | /* Template */ |
---|
92 | $template->assign(array( |
---|
93 | 'F_ACTION' => $self_url, |
---|
94 | 'TITLE' => render_element_name($picture), |
---|
95 | 'TN_SRC' => DerivativeImage::thumb_url($picture), |
---|
96 | 'SCHEDULED_FOR' => @$scheduler['scheduled_for'], |
---|
97 | )); |
---|
98 | |
---|
99 | $template->set_filename('scheduler_content', realpath(SCHEDULER_PATH . 'admin/template/photo.tpl')); |
---|
100 | ?> |
---|