--- /dev/null
+begin;
+alter table wrreport add delete_date timestamp with time zone;
+alter table wrreport add delete_person_name varchar(30);
+alter table wrreport add delete_person_ip inet;
+alter table wrreport add delete_person_userid integer;
+alter table wrreport add delete_person_username varchar(30);
+alter table wrreport add delete_reason_public text;
+alter table wrreport add delete_invisible boolean;
+commit;
+
+++ /dev/null
-begin;
-alter table wrreport add delete_date timestamp with time zone;
-alter table wrreport add delete_person_name varchar(30);
-alter table wrreport add delete_person_ip inet;
-alter table wrreport add delete_person_userid integer;
-alter table wrreport add delete_person_username varchar(30);
-alter table wrreport add delete_reason_public text;
-alter table wrreport add delete_invisible boolean;
-commit;
-
/// $order = 'date_report desc, date_entry desc';
function wrReportGetReports($conditions, $order) {
$dbr = wfGetDB(DB_SLAVE);
- $res = $dbr->select('wrreport', wrReportGetColumnNames(), $conditions, $fname = 'Database::select', $options = array('ORDER BY' => 'date_report desc, date_entry desc'));
+ $columns = wrReportGetColumnNames();
+ global $wgDBtype;
+ if ($wgDBtype == "mysql") // "condition" is a reserved word in mysql
+ for ($i = 0; $i != count($columns); ++$i) $columns[$i] = sprintf('`%s`', $columns[$i]);
+ $res = $dbr->select('wrreport', $columns, $conditions, $fname = 'Database::select', $options = array('ORDER BY' => 'date_report desc, date_entry desc'));
$result = array();
while ($row = $dbr->fetchRow($res)) $result[] = $row;
$dbr->freeResult($res);
/// If no condition is present, array(NULL, NULL) is returned
function wrReportConditionRender($page_title) {
$dbr = wfGetDB(DB_SLAVE);
- $res = $dbr->select('wrreport', array('max(wrreport.id) as max'), array('page_title' => $page_title, 'condition is not null', 'date_invalid > now()'));
+ $cond = 'condition';
+ global $wgDBtype;
+ if ($wgDBtype == "mysql") $cond = "`$cond`"; // "condition" is a reserved word in mysql
+ $res = $dbr->select('wrreport', array('max(wrreport.id) as max'), array('page_title' => $page_title, "$cond is not null", 'date_invalid > now()'));
// select condition, date_report from wrreport where id = (select max(wrreport.id) as max from wrreport where page_title='Birgitzer Alm (vom Adelshof)' and date_invalid > now() and condition is not null);
if ($res->numRows() <= 0) {
$dbr->freeResult($res);
}
$row = $dbr->fetchObject($res);
$dbr->freeResult($res);
- $res = $dbr->select('wrreport', array('condition', 'date_report'), array('id' => $row->max));
+ $res = $dbr->select('wrreport', array($cond, 'date_report'), array('id' => $row->max));
if ($res->numRows() <= 0) {
$dbr->freeResult($res);
return array(NULL, NULL);
// Chech whether identical reports are present
if (!$errorMsg) {
$dbr = wfGetDB(DB_SLAVE);
- $sqlConditions = array('page_id' => $page_id, 'date_report' => $date_report, 'condition' => $condition, 'description' => $description, 'author_name' => $author_name);
+ $cond = 'condition';
+ global $wgDBtype;
+ if ($wgDBtype == "mysql") $cond = "`$cond`"; // "condition" is a reserved word in mysql
+ $sqlConditions = array('page_id' => $page_id, 'date_report' => $date_report, $cond => $condition, 'description' => $description, 'author_name' => $author_name);
$res = $dbr->select('wrreport', 'id', $sqlConditions);
if ($res->numRows() == 1) $errorMsg = utf8_encode('Der Rodelbahnbericht wurde bereits früher gespeichert.');
$dbr->freeResult($res);
'page_id' => $page_id,
'page_title' => $page_title,
'date_report' => $date_report,
- // 'date_entry' => '', // use database default
- // 'date_invalid' => '', // use database default
- 'condition' => $condition,
+ 'date_entry' => date('c'),
+ 'date_invalid' => date('c', strtotime('+9 days')),
+ $cond => $condition,
'description' => $description,
'author_name' => $author_name,
'author_ip' => $_SERVER['REMOTE_ADDR'],
--- /dev/null
+--- MySql
+--- SQL command to create the wrreport table, that is necessary to use the wrreport extension.
+CREATE TABLE wrreport (
+ id integer auto_increment primary key,
+ page_id integer, -- mediawiki page id the report is intended for
+ page_title varchar(255), -- mediawiki page title the report is intended for
+ date_report date, -- date, the report is intended for
+ date_entry datetime, -- date where report was created
+ date_invalid datetime, -- date were report becomes invalid
+ `condition` integer, -- condition from 1 (very good) to 5 (sledding not possible). NULL allowed.
+ description text, -- report description (wikitext)
+ author_name varchar(30), -- name of the person who created the report
+ author_ip varchar(15), -- IP address of the person who created the report
+ author_userid integer, -- mediawiki user id of the person who created the report
+ author_username varchar(30), -- mediawiki user name of the person who created the report
+ delete_date datetime, -- the report is considered deleted if this date is set
+ delete_person_name varchar(30), -- name of the person who deleted the report
+ delete_person_ip varchar(15), -- IP address of the person who deleted the report
+ delete_person_userid integer, -- mediawiki user id of the person who deleted the report
+ delete_person_username varchar(30), -- mediawiki user name of the person who deleted the report
+ delete_reason_public text, -- reason for the deletion (wikitext)
+ delete_invisible boolean, -- do not mention that someone deleted this recored
+ CONSTRAINT CHECK (`condition` >= 1 AND `condition` <= 5)
+);
+
--- /dev/null
+--- Postgresql
+--- SQL command to create the wrreport table, that is necessary to use the wrreport extension.
+CREATE TABLE wrreport (
+ id serial primary key,
+ page_id integer, -- mediawiki page id the report is intended for
+ page_title varchar(255), -- mediawiki page title the report is intended for
+ date_report date, -- date, the report is intended for
+ date_entry timestamp with time zone DEFAULT now(), -- date where report was created
+ date_invalid timestamp with time zone DEFAULT (now() + '9 days'::interval), -- date were report becomes invalid
+ condition integer, -- condition from 1 (very good) to 5 (sledding not possible). NULL allowed.
+ description text, -- report description (wikitext)
+ author_name varchar(30), -- name of the person who created the report
+ author_ip inet, -- IP address of the person who created the report
+ author_userid integer, -- mediawiki user id of the person who created the report
+ author_username varchar(30), -- mediawiki user name of the person who created the report
+ delete_date timestamp with time zone, -- the report is considered deleted if this date is set
+ delete_person_name varchar(30), -- name of the person who deleted the report
+ delete_person_ip inet, -- IP address of the person who deleted the report
+ delete_person_userid integer, -- mediawiki user id of the person who deleted the report
+ delete_person_username varchar(30), -- mediawiki user name of the person who deleted the report
+ delete_reason_public text, -- reason for the deletion (wikitext)
+ delete_invisible boolean, -- do not mention that someone deleted this recored
+ CONSTRAINT condition_check CHECK (condition >= 1 AND condition <= 5)
+);
+
+++ /dev/null
---- SQL command to create the wrreport table, that is necessary to use the wrreport extension.
-CREATE TABLE wrreport (
- id serial primary key,
- page_id integer, -- mediawiki page id the report is intended for
- page_title varchar(255), -- mediawiki page title the report is intended for
- date_report date, -- date, the report is intended for
- date_entry timestamp with time zone DEFAULT now(), -- date where report was created
- date_invalid timestamp with time zone DEFAULT (now() + '9 days'::interval), -- date were report becomes invalid
- condition integer, -- condition from 1 (very good) to 5 (sledding not possible). NULL allowed.
- description text, -- report description (wikitext)
- author_name varchar(30), -- name of the person who created the report
- author_ip inet, -- IP address of the person who created the report
- author_userid integer, -- mediawiki user id of the person who created the report
- author_username varchar(30), -- mediawiki user name of the person who created the report
- delete_date timestamp with time zone, -- the report is considered deleted if this date is set
- delete_person_name varchar(30), -- name of the person who deleted the report
- delete_person_ip inet, -- IP address of the person who deleted the report
- delete_person_userid integer, -- mediawiki user id of the person who deleted the report
- delete_person_username varchar(30), -- mediawiki user name of the person who deleted the report
- delete_reason_public text, -- reason for the deletion (wikitext)
- delete_invisible boolean, -- do not mention that someone deleted this recored
- CONSTRAINT condition_check CHECK (condition >= 1 AND condition <= 5)
-);
-