source: extensions/scheduler/include/admin_events.inc.php @ 19232

Last change on this file since 19232 was 19232, checked in by plg, 11 years ago

initial version of plugin Scheduler

File size: 1.6 KB
Line 
1<?php
2defined('SCHEDULER_PATH') or die('Hacking attempt!');
3
4/**
5 * add a tab on photo properties page
6 */
7function 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&amp;image_id='.$_GET['image_id'],
14      );
15  }
16 
17  return $sheets;
18}
19
20/**
21 * add a prefilter on photo edit page
22 */
23function 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
31function scheduler_photo_edit_replace_level()
32{
33  global $page, $template;
34
35  if ('photo' == $_GET['page'] and (!isset($_GET['tab']) or 'properties' == $_GET['tab']))
36  {
37    // is the current photo on schedule?
38    $query = '
39SELECT *
40  FROM '.SCHEDULER_TABLE.'
41  WHERE image_id = '.$_GET['image_id'].'
42;';
43    $scheduler = pwg_db_fetch_assoc(pwg_query($query));
44
45    if (!isset($scheduler['scheduled_for']))
46    {
47      return;
48    }
49   
50    if (isset($_POST['submit']))
51    {
52      // we have to change the level in the scheduler table
53      single_update(
54        SCHEDULER_TABLE,
55        array('level' => $_POST['level']),
56        array('image_id' => $_GET['image_id'])
57        );
58
59      $scheduler['level'] = $_POST['level'];
60
61      // then picture_modify.php will update IMAGES_TABLE to level 32 (=scheduled)
62      $_POST['level'] = 32;
63    }
64   
65    $template->set_prefilter('picture_modify', 'scheduler_picture_edit_prefilter');
66   
67    $template->assign('level_options_selected_scheduler', array($scheduler['level']));
68  }
69}
70?>
Note: See TracBrowser for help on using the repository browser.