Revision: 2016
http://mrbs.svn.sourceforge.net/mrbs/?rev=2016&view=rev
Author: cimorrison
Date: 2011-09-27 10:56:19 +0000 (Tue, 27 Sep 2011)
Log Message:
-----------
Merged in latest changes from the trunk
Modified Paths:
--------------
mrbs/branches/datatables/web/Themes/default/header.inc
mrbs/branches/datatables/web/functions.inc
mrbs/branches/datatables/web/grab_globals.inc.php
mrbs/branches/datatables/web/language.inc
mrbs/branches/datatables/web/report.php
mrbs/branches/datatables/web/session_cookie.inc
mrbs/branches/datatables/web/session_http.inc
mrbs/branches/datatables/web/session_php.inc
mrbs/branches/datatables/web/session_remote_user.inc
mrbs/branches/datatables/web/systemdefaults.inc.php
Added Paths:
-----------
mrbs/branches/datatables/help_report.html
Property Changed:
----------------
mrbs/branches/datatables/
mrbs/branches/datatables/web/upgrade/5/pgsql.sql
Property changes on: mrbs/branches/datatables
___________________________________________________________________
Modified: svn:mergeinfo
- /mrbs/branches/custom_entry_fields:1374-1396
/mrbs/branches/datepicker:1409-1416
/mrbs/branches/disabled_rooms:1601-1634
/mrbs/branches/from_to_bookings:1491-1587
/mrbs/branches/ics_attachments:1652-1741
/mrbs/branches/improve_css_2008_06:804-872
/mrbs/branches/only_unicode:1747-1749
/mrbs/branches/provisional_bookings:1242-1280
/mrbs/branches/provisional_bookings_new_style:1407-1570
/mrbs/trunk:1863-2013
+ /mrbs/branches/custom_entry_fields:1374-1396
/mrbs/branches/datepicker:1409-1416
/mrbs/branches/disabled_rooms:1601-1634
/mrbs/branches/from_to_bookings:1491-1587
/mrbs/branches/ics_attachments:1652-1741
/mrbs/branches/improve_css_2008_06:804-872
/mrbs/branches/only_unicode:1747-1749
/mrbs/branches/provisional_bookings:1242-1280
/mrbs/branches/provisional_bookings_new_style:1407-1570
/mrbs/trunk:1863-2015
Copied: mrbs/branches/datatables/help_report.html (from rev 2015,
mrbs/trunk/help_report.html)
===================================================================
--- mrbs/branches/datatables/help_report.html (rev 0)
+++ mrbs/branches/datatables/help_report.html 2011-09-27 10:56:19 UTC (rev
2016)
@@ -0,0 +1,292 @@
+<!DOCTYPE html>
+
+<!-- $Id$ -->
+
+<html>
+
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>Help - report.php</title>
+<style type="text/css">
+body {
+ font-size: small;
+ font-family: Arial, Verdana, sans-serif;
+}
+h1 {
+ font-size: medium;
+ margin-top: 2em;
+}
+body > table > tbody > tr:last-child > td {
+ padding-bottom: 1em;
+}
+td {
+ padding: 0 1em 0 0;
+ vertical-align: top;
+}
+table table {
+ margin-left: 2em;
+}
+</style>
+</head>
+
+<body>
+<h1>NAME</h1>
+<p>
+report.php - produce MRBS reports
+</p>
+<h1>SYNOPSIS</h1>
+<p>
+<code>report.php [args]</code>
+</p>
+<p>
+where args is a space separated list of arguments of the form
<code>param1=value1&param2=value2</code>. Spaces
+in the value string and ampersands can normally be escaped with the backslash
character ('\'), depending
+on the shell. Array parameters can be sent by using the '[]' notation, eg
<code>param1[]=valueA&param1[]=valueB</code>.
+Array parameters must all appear in the same argument.
+</p>
+<h1>DESCRIPTION</h1>
+<p>
+ This page describes how to use MRBS reporting from the command line (CLI).
Report.php can
+ either be called directly or as a cron job. The script report.php should
be called
+ as a parameter to the PHP interpreter. The output of report.php is sent to
STDOUT.
+</p>
+<p>
+ The language and locale used for the reports is specified by the config
variable
+ $cli_language. The script can only be run from the command line if the MRBS
config
+ variable $allow_cli is set to TRUE.
+</p>
+<h1>OPTIONS</h1>
+<table>
+<tbody>
+<tr>
+ <td><code>summarize</code></td>
+ <td>
+ The type of report to produce. Permitted values are:
+ <table>
+ <tr><td><code>5</code></td><td>HTML report</td></tr>
+ <tr><td><code>6</code></td><td>HTML summary</td></tr>
+ <tr><td><code>7</code></td><td>HTML report and summary</td></tr>
+ <tr><td><code>9</code></td><td>CSV report<em> (default)</em></td></tr>
+ <tr><td><code>10</code></td><td>CSV summary</td></tr>
+ <tr><td><code>17</code></td><td>iCalendar (.ics file) report - excluding
periods</td></tr>
+ </table>
+ </td>
+</tr>
+</tbody>
+<tbody>
+<tr>
+ <td>
+ <code>day</code>
+ </td>
+ <td>
+ The day (1..31) to use as the base date for the reporting
+ period. If any of day, week and month are not specified
+ then today's date will be used as the base date.
+ </td>
+</tr>
+<tr>
+ <td>
+ <code>month</code>
+ </td>
+ <td>
+ The month (1..12) to use as the base date for the reporting
+ period. If any of day, week and month are not specified
+ then today's date will be used as the base date.
+ </td>
+</tr>
+<tr>
+ <td>
+ <code>year</code>
+ </td>
+ <td>
+ The year (4 digits) to use as the base date for the reporting
+ period. If any of day, week and month are not specified
+ then today's date will be used as the base date.
+ </td>
+</tr>
+</tbody>
+<tbody>
+<tr>
+ <td><code>from_day</code></td>
+ <td>
+ The start day (1..31) of the reporting period. If from_day,
+ from_month and from_year are not specified then the base date will
+ be used.
+ </td>
+</tr>
+<tr>
+ <td><code>from_month</code></td>
+ <td>
+ The start month (1..12) of the reporting period. If from_day,
+ from_month and from_year are not specified then the base date will
+ be used.
+ </td>
+</tr>
+<tr>
+ <td><code>from_year</code></td>
+ <td>
+ The start year (4 digits) of the reporting period. If from_day,
+ from_month and from_year are not specified then the base date will
+ be used.
+ </td>
+</tr>
+<tr>
+ <td><code>to_day</code></td>
+ <td>
+ The end day (1..31) of the reporting period. If to_day,
+ to_month and to_year are not specified then the base date +
+ $default_report_days (specified in systemdefaults.inc.php and
+ optionally over-ridden in config.in.php) will be used. Note that
+ the reporting period ends at 0000 on the to_day, so if for example
+ you want a report for all bookings in 2011 the to_date should be
+ 1 Jan 2012.
+ </td>
+</tr>
+<tr>
+ <td><code>to_month</code></td>
+ <td>
+ The end month (1..12) of the reporting period. If to_day,
+ to_month and to_year are not specified then the base date +
+ $default_report_days (specified in systemdefaults.inc.php and
+ optionally over-ridden in config.in.php) will be used.
+ </td>
+</tr>
+<tr>
+ <td><code>to_year</code></td>
+ <td>
+ The end year (4 digits) of the reporting period. If to_day,
+ to_month and to_year are not specified then the base date +
+ $default_report_days (specified in systemdefaults.inc.php and
+ optionally over-ridden in config.in.php) will be used.
+ </td>
+</tr>
+</tbody>
+<tbody>
+<tr>
+ <td><code>creatormatch</code></td>
+ <td>
+ Limit the report to entries where the creator's user name contains the
string.
+ </td>
+</tr>
+<tr>
+ <td><code>areamatch</code></td>
+ <td>
+ Limit the report to entries where the area name contains the string.
+ </td>
+</tr>
+<tr>
+ <td><code>roommatch</code></td>
+ <td>
+ Limit the report to entries where the room name contains the string.
+ </td>
+</tr>
+<tr>
+ <td><code>namematch</code></td>
+ <td>
+ Limit the report to entries where the entry name contains the string.
+ </td>
+</tr>
+<tr>
+ <td><code>descrmatch</code></td>
+ <td>
+ Limit the report to entries where the description contains the string.
+ </td>
+</tr>
+<tr>
+ <td><code>typematch[]</code></td>
+ <td>
+ Limit the report to entries of types X,Y,Z (eg
typematch[]=X&typematch[]=Y&typematch[]=Z). Default: all types.
+ </td>
+</tr>
+</tbody>
+<tbody>
+<tr>
+ <td><code>sortby</code></td>
+ <td>
+ Permitted values are:
+ <table>
+ <tr><td><code>r</code></td><td><em>(default)</em> sort by room
name</td></tr>
+ <tr><td><code>s</code></td><td>sort by start time</td></tr>
+ </table>
+ </td>
+</tr>
+<tr>
+ <td><code>display</code></td>
+ <td>
+ Permitted values are:
+ <table>
+ <tr><td><code>d</code></td><td><em>(default)</em> show start time and
duration</td></tr>
+ <tr><td><code>e</code></td><td>show start time and end time</td></tr>
+ </table>
+ </td>
+</tr>
+<tr>
+ <td><code>sumby</code></td>
+ <td>
+ The field to use for the first column of the summary table.
+ Permitted values are:
+ <table>
+ <tr><td><code>d</code></td><td><em>(default)</em> brief
description</td></tr>
+ <tr><td><code>c</code></td><td>creator's user name</td></tr>
+ <tr><td><code>t</code></td><td>type</td></tr>
+ </table>
+ </td>
+</tr>
+</tbody>
+<tbody>
+<tr>
+ <td><code>phase</code></td>
+ <td>
+ The phase of report production. Phase 1 is the gathering of user input
from
+ the web page form; Phase 2 is the production of the report or summary.
When running
+ from the command line it is not necessary to set this option as it is
automatically
+ set to 2 by MRBS. However when running report.php from the web browser or
by using wget,
+ setting phase=2 will force report.php to go straight to the production of
a report.
+ </td>
+</tr>
+</tbody>
+<tbody>
+<tr>
+ <td>custom</td>
+ <td>
+ Custom fields can be searched for using the same syntax as above.
+ </td>
+</tr>
+</tbody>
+</table>
+<h1>RETURN VALUES</h1>
+<p>
+Returns 0 on success.
+</p>
+<h1>EXAMPLES</h1>
+<p>
+ To produce a summary in CSV format of all bookings for 2011, arranged by the
creator's
+ name, and send the summary to the file summary.csv:
+</p>
+<p>
+<code>
+ /usr/local/bin/php /home/mrbs/report.php summarize=10
from_day=1&from_month=1&from_year=2011
to_day=1&to_month=1&to_year=2012 sumby=c > summary.csv
+</code>
+</p>
+<p>
+ The CLI output can be simulated in a browser by putting the parameters in a
query string. But note
+ that the parameter <code>phase=2</code> must be added to tell MRBS that it
is on the second
+ phase of report production (the first phase is gathering the user input from
the form; if report.php
+ is called from the command line the phase is automatically set to 2). For
example,
+ to simulate the CLI command above enter into the browser:
+</p>
+<p>
+<code>
+
report.php?phase=2&summarize=10&from_day=1&from_month=1&from_year=2011&to_day=1&to_month=1&to_year=2012&sumby=c
+</code>
+</p>
+<p>
+ When using wget, don't forget to escape ampersands with a backslash. For
example:
+</p>
+<p>
+<code>
+ wget -O myreport.csv
http://localhost/mrbs/report.php?phase=2\&summarize=10\&sumby=c
+</code>
+</p>
+</body>
+</html>
Modified: mrbs/branches/datatables/web/Themes/default/header.inc
===================================================================
--- mrbs/branches/datatables/web/Themes/default/header.inc 2011-09-27
09:42:47 UTC (rev 2015)
+++ mrbs/branches/datatables/web/Themes/default/header.inc 2011-09-27
10:56:19 UTC (rev 2016)
@@ -242,7 +242,7 @@
// Merge the specific options with the default options. We do a
deep
// merge.
?>
- var mergedOptions = $.extend(true, {}, defaultOptions,
specificOptions);
+ var mergedOptions = $.extend(true, {}, defaultOptions,
specificOptions);
var oTable = $(id).dataTable(mergedOptions);
<?php // Need to redraw the datatable when the browser window is
resized ?>
$(window).bind('resize', function () {
@@ -1467,7 +1467,7 @@
// performance for large tables
if (function_exists('json_encode'))
{
- $ajax_url = "http://" . $HTTP_HOST . $PHP_SELF . "?" . $QUERY_STRING .
"&ajax=1";
+ $ajax_url = "http://" . $HTTP_HOST . $PHP_SELF . "?" . $QUERY_STRING .
"&ajax=1&phase=2";
?>
tableOptions.sAjaxSource = "<?php echo $ajax_url ?>";
<?php
@@ -1615,7 +1615,7 @@
// and stop those first two columns being reordered
?>
tableOptions.oColReorder = {iFixedColumns: 2};
-
+
var reportTable = makeDataTable('#report_table', tableOptions);
<?php
Modified: mrbs/branches/datatables/web/functions.inc
===================================================================
--- mrbs/branches/datatables/web/functions.inc 2011-09-27 09:42:47 UTC (rev
2015)
+++ mrbs/branches/datatables/web/functions.inc 2011-09-27 10:56:19 UTC (rev
2016)
@@ -1892,4 +1892,42 @@
{
return (is_array($arr) && count(array_filter(array_keys($arr),'is_string'))
== count($arr));
}
+
+
+// Checks whether we are running as a CLI module
+//
+// Based on code from mniewerth at ultimediaos dot com at
+// http://php.net/manual/features.commandline.php
+function is_cgi()
+{
+ return (substr(PHP_SAPI, 0, 3) == 'cgi');
+}
+
+
+// Checks whether we are running from the CLI
+//
+// Based on code from mniewerth at ultimediaos dot com at
+// http://php.net/manual/features.commandline.php
+function is_cli()
+{
+ global $allow_cli;
+
+ if (!$allow_cli)
+ {
+ return FALSE;
+
+ }
+ if (defined('STDIN'))
+ {
+ return TRUE;
+ }
+ elseif (is_cgi() && getenv('TERM'))
+ {
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
?>
Modified: mrbs/branches/datatables/web/grab_globals.inc.php
===================================================================
--- mrbs/branches/datatables/web/grab_globals.inc.php 2011-09-27 09:42:47 UTC
(rev 2015)
+++ mrbs/branches/datatables/web/grab_globals.inc.php 2011-09-27 10:56:19 UTC
(rev 2016)
@@ -21,25 +21,42 @@
// $Id$
-//
+// Gets a form variable. Takes an optional third parameter which
+// is the default value if nothing is found from the form.
function get_form_var($variable, $type = 'string')
{
// We use some functions from here
require_once "functions.inc";
-
- if ($type == 'array')
+
+ global $cli_params, $allow_cli;
+
+ // Set the default value, and make sure it's the right type
+ if (func_num_args() > 2)
{
- $value = array();
+ $value = func_get_arg(2);
+ $value = ($type == 'array') ? (array)$value : $value;
}
else
{
- $value = NULL;
+ $value = ($type == 'array') ? array() : NULL;
}
-
- if (!empty($_POST) && isset($_POST[$variable]))
+
+ // Get the command line arguments if any (and we're allowed to)
+ if ($allow_cli && (!empty($cli_params) && isset($cli_params[$variable])))
{
if ($type == 'array')
{
+ $value = (array)$cli_params[$variable];
+ }
+ else
+ {
+ $value = $cli_params[$variable];
+ }
+ }
+ else if (!empty($_POST) && isset($_POST[$variable]))
+ {
+ if ($type == 'array')
+ {
$value = (array)$_POST[$variable];
}
else
@@ -192,4 +209,16 @@
$HTTP_HOST = $HTTP_SERVER_VARS['HTTP_HOST'];
}
+// If we're operating from the command line then build
+// an associative array of the command line parameters
+// (assumes they're in the form 'parameter=value')
+if (!empty($argc))
+{
+ $cli_params = array();
+ for ($i=1; $i<$argc; $i++)
+ {
+ parse_str($argv[$i], $param);
+ $cli_params = array_merge($cli_params, $param);
+ }
+}
?>
Modified: mrbs/branches/datatables/web/language.inc
===================================================================
--- mrbs/branches/datatables/web/language.inc 2011-09-27 09:42:47 UTC (rev
2015)
+++ mrbs/branches/datatables/web/language.inc 2011-09-27 10:56:19 UTC (rev
2016)
@@ -2,6 +2,8 @@
// $Id$
+require_once "functions.inc";
+
// A map is needed to convert from the HTTP language specifier to a
// locale specifier for Windows
//
@@ -368,10 +370,16 @@
// We attempt to make up a sensible locale from the HTTP_ACCEPT_LANGUAGE
// environment variable.
+$cli_mode = is_cli();
-// First we enumerate the user's language preferences...
-if (isset($HTTP_ACCEPT_LANGUAGE)) // Attempt to use $HTTP_ACCEPT_LANGUAGE only
when defined.
+// If we're running from the CLI, use the config setting
+if ($cli_mode && !empty($cli_language))
{
+ $langs[$cli_language] = 1.0;
+}
+// Otherwise we enumerate the user's language preferences...
+elseif (isset($HTTP_ACCEPT_LANGUAGE)) // Attempt to use $HTTP_ACCEPT_LANGUAGE
only when defined.
+{
$lang_specifiers = explode(',',$HTTP_ACCEPT_LANGUAGE);
foreach ($lang_specifiers as $specifier)
{
@@ -394,7 +402,7 @@
// The following attempts to import a language based on what the client
// is using.
-if (!$disable_automatic_language_changing)
+if (!$disable_automatic_language_changing || $cli_mode)
{
$doneit = 0;
@@ -411,7 +419,12 @@
{
$locale = $lang;
}
-
+ // When in CLI mode, we need to add the full path name as
+ // file_exists() ignores the include path
+ if ($cli_mode)
+ {
+ $lang_file = dirname($PHP_SELF) . "/" . $lang_file;
+ }
if (file_exists($lang_file))
{
include $lang_file;
@@ -429,7 +442,12 @@
foreach ($langs as $lang => $qual)
{
$lang_file = "lang." . strtolower(substr($lang,0,2));
-
+ // When in CLI mode, we need to add the full path name as
+ // file_exists() ignores the include path
+ if ($cli_mode)
+ {
+ $lang_file = dirname($PHP_SELF) . "/" . $lang_file;
+ }
if (file_exists($lang_file))
{
include $lang_file;
Modified: mrbs/branches/datatables/web/report.php
===================================================================
--- mrbs/branches/datatables/web/report.php 2011-09-27 09:42:47 UTC (rev
2015)
+++ mrbs/branches/datatables/web/report.php 2011-09-27 10:56:19 UTC (rev
2016)
@@ -705,36 +705,62 @@
}
+// Work out whether we are running from the command line
+$cli_mode = is_cli();
+
+if ($cli_mode)
+{
+ // Need to set include path if we're running in CLI mode
+ // (because otherwise PHP looks in the current directory rather
+ // than the directory from which the script was called)
+ ini_set("include_path", dirname($PHP_SELF));
+}
+
+$to_date = getdate(mktime(0, 0, 0, $month, $day + $default_report_days,
$year));
+
// Get non-standard form variables
-$From_day = get_form_var('From_day', 'int');
-$From_month = get_form_var('From_month', 'int');
-$From_year = get_form_var('From_year', 'int');
-$To_day = get_form_var('To_day', 'int');
-$To_month = get_form_var('To_month', 'int');
-$To_year = get_form_var('To_year', 'int');
+$from_day = get_form_var('from_day', 'int', $day);
+$from_month = get_form_var('from_month', 'int', $month);
+$from_year = get_form_var('from_year', 'int', $year);
+$to_day = get_form_var('to_day', 'int', $to_date['mday']);
+$to_month = get_form_var('to_month', 'int', $to_date['mon']);
+$to_year = get_form_var('to_year', 'int', $to_date['year']);
$creatormatch = get_form_var('creatormatch', 'string');
$areamatch = get_form_var('areamatch', 'string');
$roommatch = get_form_var('roommatch', 'string');
$namematch = get_form_var('namematch', 'string');
$descrmatch = get_form_var('descrmatch', 'string');
-$summarize = get_form_var('summarize', 'int');
+$summarize = get_form_var('summarize', 'int', (($cli_mode) ? REPORT +
OUTPUT_CSV : REPORT + OUTPUT_HTML));
$typematch = get_form_var('typematch', 'array');
-$sortby = get_form_var('sortby', 'string');
-$sumby = get_form_var('sumby', 'string');
-$match_approved = get_form_var('match_approved', 'string');
-$match_confirmed = get_form_var('match_confirmed', 'string');
-$match_private = get_form_var('match_private', 'string');
-$phase = get_form_var('phase', 'int');
+$sortby = get_form_var('sortby', 'string', 'r'); // $sortby: r=room, s=start
date/time.
+$sumby = get_form_var('sumby', 'string', 'd'); // $sumby: d=by brief
description, c=by creator, t=by type.
+$match_approved = get_form_var('match_approved', 'int', APPROVED_BOTH);
+$match_confirmed = get_form_var('match_confirmed', 'int', CONFIRMED_BOTH);
+$match_private = get_form_var('match_private', 'int', PRIVATE_BOTH);
+$phase = get_form_var('phase', 'int', 1);
$ajax = get_form_var('ajax', 'int'); // Set if this is an Ajax request
$datatable = get_form_var('datatable', 'int'); // Will only be set if we're
using DataTables
// Check the user is authorised for this page
-checkAuthorised();
+if ($cli_mode)
+{
+ $is_admin = TRUE;
+}
+else
+{
+ checkAuthorised();
+ // Also need to know whether they have admin rights
+ $user = getUserName();
+ $user_level = authGetUserLevel($user);
+ $is_admin = ($user_level >= 2);
+}
-// Also need to know whether they have admin rights
-$user = getUserName();
-$user_level = authGetUserLevel($user);
-$is_admin = ($user_level >= 2);
+// If we're running in CLI mode we're passing the parameters in from the
command line
+// not the form and we want to go straight to Phase 2 (producing the report)
+if ($cli_mode)
+{
+ $phase = 2;
+}
// Set up for Ajax. We need to know whether we're capable of dealing with
Ajax
// requests, which will only be if (a) the browser is using DataTables and (b)
@@ -746,28 +772,11 @@
$json_data['aaData'] = array();
}
-// Set some defaults
-if (!isset($phase))
-{
- // The default is that we're at Phase 1
- $phase = 1;
-}
-if (!isset($match_approved))
-{
- $match_approved = APPROVED_BOTH;
-}
-if (!isset($match_confirmed))
-{
- $match_confirmed = CONFIRMED_BOTH;
-}
-if (!isset($match_private))
-{
- $match_private = PRIVATE_BOTH;
-}
-if (empty($summarize))
-{
- $summarize = REPORT + OUTPUT_HTML;
-}
+$private_somewhere = some_area('private_enabled') ||
some_area('private_mandatory');
+$approval_somewhere = some_area('approval_enabled');
+$confirmation_somewhere = some_area('confirmation_enabled');
+$times_somewhere = (sql_query1("SELECT COUNT(*) FROM $tbl_area WHERE
enable_periods=0") > 0);
+$periods_somewhere = (sql_query1("SELECT COUNT(*) FROM $tbl_area WHERE
enable_periods!=0") > 0);
$output_as_csv = $summarize & OUTPUT_CSV;
$output_as_ical = $summarize & OUTPUT_ICAL;
@@ -804,11 +813,11 @@
}
// PHASE 2: SQL QUERY. We do the SQL query now to see if there's anything
there
-if (isset($areamatch))
+if ($phase == 2)
{
// Start and end times are also used to clip the times for summary info.
- $report_start = mktime(0, 0, 0, $From_month+0, $From_day+0, $From_year+0);
- $report_end = mktime(0, 0, 0, $To_month+0, $To_day+1, $To_year+0);
+ $report_start = mktime(0, 0, 0, $from_month+0, $from_day+0, $from_year+0);
+ $report_end = mktime(0, 0, 0, $to_month+0, $to_day+1, $to_year+0);
// Construct the SQL query
$sql = "SELECT E.*, "
@@ -1021,7 +1030,7 @@
{
// don't do anything if this is an Ajax request: we only want the data
}
-elseif ($output_as_html || empty($nmatch))
+elseif ($output_as_html || (empty($nmatch) && !$cli_mode))
{
print_header($day, $month, $year, $area, isset($room) ? $room : "");
}
@@ -1039,61 +1048,8 @@
}
-if (isset($areamatch))
-{
- // Resubmit - reapply parameters as defaults.
- // Make sure these are not escape-quoted:
-
- // Make default values when the form is reused.
- $areamatch_default = htmlspecialchars($areamatch);
- $roommatch_default = htmlspecialchars($roommatch);
- (isset($typematch)) ? $typematch_default = $typematch :
- $typematch_default = "";
- $namematch_default = htmlspecialchars($namematch);
- $descrmatch_default = htmlspecialchars($descrmatch);
- $creatormatch_default = htmlspecialchars($creatormatch);
-}
-else
-{
- // New report - use defaults.
- $areamatch_default = "";
- $roommatch_default = "";
- $typematch_default = array();
- $namematch_default = "";
- $descrmatch_default = "";
- $creatormatch_default = "";
- $From_day = $day;
- $From_month = $month;
- $From_year = $year;
- $To_time = mktime(0, 0, 0, $month, $day + $default_report_days, $year);
- $To_day = date("d", $To_time);
- $To_month = date("m", $To_time);
- $To_year = date("Y", $To_time);
- $match_private = PRIVATE_BOTH;
- $match_approved = APPROVED_BOTH;
- $match_confirmed = CONFIRMED_BOTH;
-}
-
-// $sumby: d=by brief description, c=by creator, t=by type.
-if (empty($sumby))
-{
- $sumby = "d";
-}
-// $sortby: r=room, s=start date/time.
-if (empty($sortby))
-{
- $sortby = "r";
-}
-
-$private_somewhere = some_area('private_enabled') ||
some_area('private_mandatory');
-$approval_somewhere = some_area('approval_enabled');
-$confirmation_somewhere = some_area('confirmation_enabled');
-$times_somewhere = (sql_query1("SELECT COUNT(*) FROM $tbl_area WHERE
enable_periods=0") > 0);
-$periods_somewhere = (sql_query1("SELECT COUNT(*) FROM $tbl_area WHERE
enable_periods!=0") > 0);
-
-
// Upper part: The form.
-if (($output_as_html || empty($nmatch)) && !$ajax) // We don't want the form
if this is an Ajax request
+if (!$ajax && ($output_as_html || (empty($nmatch) && !$cli_mode)))
{
?>
<div class="screenonly">
@@ -1107,27 +1063,27 @@
<div id="div_report_start">
<?php
- echo "<label for=\"From_datepicker\">" . get_vocab("report_start") .
":</label>\n";
- genDateSelector("From_", $From_day, $From_month, $From_year);
+ echo "<label for=\"from_datepicker\">" . get_vocab("report_start") .
":</label>\n";
+ genDateSelector("from_", $from_day, $from_month, $from_year);
?>
</div>
<div id="div_report_end">
<?php
- echo "<label for=\"To_datepicker\">" . get_vocab("report_end") .
":</label>\n";
- genDateSelector("To_", $To_day, $To_month, $To_year);
+ echo "<label for=\"to_datepicker\">" . get_vocab("report_end") .
":</label>\n";
+ genDateSelector("to_", $to_day, $to_month, $to_year);
?>
</div>
<div id="div_areamatch">
<label for="areamatch"><?php echo get_vocab("match_area");?>:</label>
- <input type="text" id="areamatch" name="areamatch" value="<?php echo
$areamatch_default; ?>">
+ <input type="text" id="areamatch" name="areamatch" value="<?php echo
htmlspecialchars($areamatch); ?>">
</div>
<div id="div_roommatch">
<label for="roommatch"><?php echo get_vocab("match_room");?>:</label>
- <input type="text" id="roommatch" name="roommatch" value="<?php echo
$roommatch_default; ?>">
+ <input type="text" id="roommatch" name="roommatch" value="<?php echo
htmlspecialchars($roommatch); ?>">
</div>
<div id="div_typematch">
@@ -1139,7 +1095,7 @@
if (!empty($val) )
{
echo " <option value=\"$key\"" .
- (is_array($typematch_default) && in_array ( $key,
$typematch_default ) ? " selected" : "") .
+ (is_array($typematch) && in_array ($key, $typematch) ? "
selected" : "") .
">$val</option>\n";
}
}
@@ -1150,17 +1106,17 @@
<div id="div_namematch">
<label for="namematch"><?php echo
get_vocab("match_entry");?>:</label>
- <input type="text" id="namematch" name="namematch" value="<?php echo
$namematch_default; ?>">
+ <input type="text" id="namematch" name="namematch" value="<?php echo
htmlspecialchars($namematch); ?>">
</div>
<div id="div_descrmatch">
<label for="descrmatch"><?php echo
get_vocab("match_descr");?>:</label>
- <input type="text" id="descrmatch" name="descrmatch" value="<?php
echo $descrmatch_default; ?>">
+ <input type="text" id="descrmatch" name="descrmatch" value="<?php
echo htmlspecialchars($descrmatch); ?>">
</div>
<div id="div_creatormatch">
<label for="creatormatch"><?php echo
get_vocab("createdby");?>:</label>
- <input type="text" id="creatormatch" name="creatormatch"
value="<?php echo $creatormatch_default; ?>">
+ <input type="text" id="creatormatch" name="creatormatch"
value="<?php echo htmlspecialchars($creatormatch); ?>">
</div>
<?php
@@ -1367,7 +1323,7 @@
// PHASE 2: Output the results, if called with parameters:
if ($phase == 2)
{
- if ($nmatch == 0)
+ if (($nmatch == 0) && !$cli_mode)
{
if ($ajax)
{
@@ -1431,6 +1387,11 @@
}
}
+if ($cli_mode)
+{
+ exit(0);
+}
+
if (($output_as_html || empty($nmatch)) & !$ajax)
{
require_once "trailer.inc";
Modified: mrbs/branches/datatables/web/session_cookie.inc
===================================================================
--- mrbs/branches/datatables/web/session_cookie.inc 2011-09-27 09:42:47 UTC
(rev 2015)
+++ mrbs/branches/datatables/web/session_cookie.inc 2011-09-27 10:56:19 UTC
(rev 2016)
@@ -276,8 +276,8 @@
// words 'you are xxxx' becomes a link to the
// report page with only entries created by xxx. Past entries are not
// displayed but this can be changed
- $search_string = "report.php?From_day=$day&From_month=$month&".
- "From_year=$year&To_day=1&To_month=12&To_year=2030&".
+ $search_string = "report.php?from_day=$day&from_month=$month&".
+ "from_year=$year&to_day=1&to_month=12&to_year=2030&".
"areamatch=&roommatch=&namematch=&descrmatch=&summarize=1&".
"sortby=r&display=d&sumby=d&creatormatch=$user";
?>
Modified: mrbs/branches/datatables/web/session_http.inc
===================================================================
--- mrbs/branches/datatables/web/session_http.inc 2011-09-27 09:42:47 UTC
(rev 2015)
+++ mrbs/branches/datatables/web/session_http.inc 2011-09-27 10:56:19 UTC
(rev 2016)
@@ -86,8 +86,8 @@
// words 'you are xxxx' becomes a link to the
// report page with only entries created by xxx. Past entries are not
// displayed but this can be changed
- $search_string = "report.php?From_day=$day&From_month=$month&".
-
"From_year=$year&To_day=1&To_month=12&To_year=2030&areamatch=&".
+ $search_string = "report.php?from_day=$day&from_month=$month&".
+
"from_year=$year&to_day=1&to_month=12&to_year=2030&areamatch=&".
"roommatch=&namematch=&descrmatch=&summarize=1&sortby=r&display=d&".
"sumby=d&creatormatch=$user";
?>
Modified: mrbs/branches/datatables/web/session_php.inc
===================================================================
--- mrbs/branches/datatables/web/session_php.inc 2011-09-27 09:42:47 UTC
(rev 2015)
+++ mrbs/branches/datatables/web/session_php.inc 2011-09-27 10:56:19 UTC
(rev 2016)
@@ -231,8 +231,8 @@
// words 'you are xxxx' becomes a link to the
// report page with only entries created by xxx. Past entries are not
// displayed but this can be changed
- $search_string = "report.php?From_day=$day&From_month=$month&".
-
"From_year=$year&To_day=1&To_month=12&To_year=2030&areamatch=&".
+ $search_string = "report.php?from_day=$day&from_month=$month&".
+
"from_year=$year&to_day=1&to_month=12&to_year=2030&areamatch=&".
"roommatch=&namematch=&descrmatch=&summarize=1&sortby=r&display=d&".
"sumby=d&creatormatch=".urlencode($user); ?>
Modified: mrbs/branches/datatables/web/session_remote_user.inc
===================================================================
--- mrbs/branches/datatables/web/session_remote_user.inc 2011-09-27
09:42:47 UTC (rev 2015)
+++ mrbs/branches/datatables/web/session_remote_user.inc 2011-09-27
10:56:19 UTC (rev 2016)
@@ -63,8 +63,8 @@
// words 'you are xxxx' becomes a link to the
// report page with only entries created by xxx. Past entries are not
// displayed but this can be changed
- $search_string = "report.php?From_day=$day&From_month=$month&".
-
"From_year=$year&To_day=1&To_month=12&To_year=2030&areamatch=&".
+ $search_string = "report.php?from_day=$day&from_month=$month&".
+
"from_year=$year&to_day=1&to_month=12&to_year=2030&areamatch=&".
"roommatch=&namematch=&descrmatch=&summarize=1&sortby=r&display=d&".
"sumby=d&creatormatch=$user"; ?>
Modified: mrbs/branches/datatables/web/systemdefaults.inc.php
===================================================================
--- mrbs/branches/datatables/web/systemdefaults.inc.php 2011-09-27 09:42:47 UTC
(rev 2015)
+++ mrbs/branches/datatables/web/systemdefaults.inc.php 2011-09-27 10:56:19 UTC
(rev 2016)
@@ -736,7 +736,13 @@
// on the Report page. (It also only shows up if JavaScript is enabled)
$auth['show_bulk_delete'] = FALSE;
+// Set to TRUE if you want to allow MRBS to be run from the command line, for
example
+// if you want to produce reports from a cron job. (It is set to FALSE by
default
+// as a security measure, because when running from the CLI you are assumed to
have
+// full admin access).
+$allow_cli = FALSE;
+
/**********************************************
* Email settings
**********************************************/
@@ -908,7 +914,10 @@
// use "_fr"
$faqfilelang = "";
+// Language selection when run from the command line
+$cli_language = "en";
+
/*************
* Reports
*************/
Property changes on: mrbs/branches/datatables/web/upgrade/5/pgsql.sql
___________________________________________________________________
Modified: svn:mergeinfo
- /mrbs/branches/custom_entry_fields/web/upgrade/5/pgsql.sql:1374-1396
/mrbs/branches/datepicker/web/upgrade/5/pgsql.sql:1409-1416
/mrbs/branches/disabled_rooms/web/upgrade/5/pgsql.sql:1601-1634
/mrbs/branches/from_to_bookings/web/upgrade/5/pgsql.sql:1491-1587
/mrbs/branches/ics_attachments/web/upgrade/5/pgsql.sql:1652-1741
/mrbs/branches/only_unicode/web/upgrade/5/pgsql.sql:1747-1749
/mrbs/branches/provisional_bookings/web/upgrade/5/pgsql.sql:1242-1280
/mrbs/branches/provisional_bookings_new_style/web/upgrade/5/pgsql.sql:1407-1570
/mrbs/trunk/web/upgrade/5/pgsql.sql:1863-2013
+ /mrbs/branches/custom_entry_fields/web/upgrade/5/pgsql.sql:1374-1396
/mrbs/branches/datepicker/web/upgrade/5/pgsql.sql:1409-1416
/mrbs/branches/disabled_rooms/web/upgrade/5/pgsql.sql:1601-1634
/mrbs/branches/from_to_bookings/web/upgrade/5/pgsql.sql:1491-1587
/mrbs/branches/ics_attachments/web/upgrade/5/pgsql.sql:1652-1741
/mrbs/branches/only_unicode/web/upgrade/5/pgsql.sql:1747-1749
/mrbs/branches/provisional_bookings/web/upgrade/5/pgsql.sql:1242-1280
/mrbs/branches/provisional_bookings_new_style/web/upgrade/5/pgsql.sql:1407-1570
/mrbs/trunk/web/upgrade/5/pgsql.sql:1863-2015
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits