1 <?php # vim:ts=4:sw=4:et:
2 /* For licensing and copyright terms, see the file named LICENSE */
5 require_once 'MTrackWeb.php';
7 class MTrackWeb_Report extends MTrackWeb
9 var $template = 'report.html';
14 require_once 'MTrack/ACL.php';
15 MTrackACL::requireAllRights('Reports', 'read');
22 $this->edit = !empty($_REQUEST['edit']);
24 if ($this->edit && !$pi) {
25 MTrackACL::requireAllRights('Reports', 'create');
26 $rep = new MTrack_Report;
30 $rep = MTrack_Report::loadByID($pi);
31 MTrackACL::requireAllRights("report:" . $rep->rid, $this->edit ? 'modify' : 'read');
34 ///$rep = MTrack_Report::loadBySummary($pi);
35 ///MTrackACL::requireAllRights("report:" . $rep->rid, $edit ? 'modify' : 'read');
37 if (isset($_GET['format'])) {
38 // targeted report format; omit decoration <<< ??? tab delimited only at present?
40 unset($params['format']);
41 switch ($_GET['format']) {
43 header('Content-Type: text/plain');
46 echo $rep->renderReport($rep->query, $params, $_GET['format']);
50 $this->title = "Create Report";
52 $this->title = $this->edit ?
53 ('{' . $rep->rid . '} ' . $rep->summary . " (edit)") :
54 '{' . $rep->rid . '} ' . $rep->summary;
56 $this->canModify = MTrackACL::hasAllRights("report:" . $rep->rid, 'modify');
59 MTrack_Report::$link = $this->link;
67 MTrackACL::requireAllRights('Reports', 'create');
68 $rep = new MTrack_Report;
72 $rep = MTrack_Report::loadByID($pi);
73 MTrackACL::requireAllRights("report:" . $rep->rid, 'modify');
75 $rep->summary = $_POST['name'];
76 $rep->description = $_POST['description'];
77 $rep->query = $_POST['query'];
78 if (isset($_POST['cancel'])) {
79 header("Location: {$this->baseURL}/Reports");
82 // in theory... everything else is a 'save'...
84 $cs = MTrackChangeset::begin(
85 "report:" . $rep->summary, $_POST['comment']);
88 return $this->get($pi);
89 } catch (Exception $e) {
90 $this->message = $e->getMessage();
92 return $this->get($pi);