versioning.php 2.26 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
/**
 *
 * @package    mahara
 * @subpackage core
 * @author     Catalyst IT Ltd
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
 *
 */

define('INTERNAL', 1);
define('MENUITEM', 'create/views');

define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'view');
17
define('SECTION_PAGE', 'versioning');
18
19
20
21
22
23
24
25
26
27
28

require(dirname(dirname(__FILE__)) . '/init.php');
require_once(get_config('libroot') . 'view.php');
define('TITLE', get_string('timeline', 'view'));

$offset = param_integer('offset', 0);

$view = param_integer('view');
if (!can_view_view($view)) {
    throw new AccessDeniedException(get_string('accessdenied', 'error'));
}
29

30
$fromdate = param_variable('fromdate', '-3 months');
31
$todate = param_variable('todate', 'tomorrow');
32

33
34
35
$viewobject = new View($view);
define('SUBSECTIONHEADING', $viewobject->display_title(true, false, false));

36
37
38
function timeline_submit(Pieform $form, $values) {
    redirect('/view/versioning.php?view='.$values['viewid'].'&fromdate='.$values['from'].'&todate='.$values['to']);
}
39

40
41
if ($fromdate || $todate ) {
    $versions = View::get_versions($view, $fromdate, $todate);
42
43
44
45
}
else {
    $versions = View::get_versions($view);
}
46
47
48
49
50
51

if ($versions->total == 0) {
    throw new AccessDeniedException(get_string('noversionsexist', 'view', $viewobject->get('title')));
}

$form = View::get_timeline_form($view, $fromdate, $todate);
52

53
54
55
56
57
58
59
60
61
$smarty = smarty(array('paginator', 'js/jquery/jquery-ui/js/jquery-ui.min.js', 'js/jTLine/js/jtline.js'), array(), array('view' => array(
        'versionnumber',
        'gotonextversion',
        'gotopreviousversion',
        'previousversion',
        'nextversion',
        'versionnumber',
    ),
  ), array('sidebars' => false));
62
$smarty->assign('versions', $versions->data);
63
$smarty->assign('timelineform', $form);
64
$smarty->assign('views', $versions->count);
65
66
67
$smarty->assign('fromdate', urlencode($fromdate));
$smarty->assign('todate', urlencode($todate));
$smarty->assign('viewurl', $viewobject->get_url());
68
$smarty->assign('view', $view);
69
$smarty->assign('viewtitle', hsc($viewobject->get('title')));
70
71
$smarty->assign('headingclass', 'page-header');
$smarty->display('view/versioning.tpl');