diff --git a/bin/dbsv-update.php b/bin/dbsv-update.php index 4ee5ee95b..b2c30f273 100644 --- a/bin/dbsv-update.php +++ b/bin/dbsv-update.php @@ -878,6 +878,12 @@ function dbv_154() // add pictures order option ADD UNIQUE INDEX `object_type` (`object_type`,`object_id`,`seq`)"); } + function dbv_155() + { + if (!sql_field_exists('cache_report_reasons', 'order')) + sql("ALTER TABLE `cache_report_reasons` ADD COLUMN `order` tinyint(2) unsigned NOT NULL"); + } + // When adding new mutations, take care that they behave well if run multiple // times. This improves robustness of database versioning. // diff --git a/htdocs/doc/sql/static-data/data.sql b/htdocs/doc/sql/static-data/data.sql index 0a3e555f2..6e49c9e93 100644 --- a/htdocs/doc/sql/static-data/data.sql +++ b/htdocs/doc/sql/static-data/data.sql @@ -152,10 +152,11 @@ INSERT INTO `cache_logtype` (`cache_type_id`, `log_type_id`) VALUES ('10', '3'); -- Table cache_report_reasons SET NAMES 'utf8'; TRUNCATE TABLE `cache_report_reasons`; -INSERT INTO `cache_report_reasons` (`id`, `name`, `trans_id`) VALUES ('1', 'Cache on private property', '776'); -INSERT INTO `cache_report_reasons` (`id`, `name`, `trans_id`) VALUES ('2', 'Copyright violation', '777'); -INSERT INTO `cache_report_reasons` (`id`, `name`, `trans_id`) VALUES ('3', 'Cache is gone', '778'); -INSERT INTO `cache_report_reasons` (`id`, `name`, `trans_id`) VALUES ('4', 'Other reason', '779'); +INSERT INTO `cache_report_reasons` (`id`, `name`, `trans_id`, `order`) VALUES ('1', 'Cache on private property', '776', 2); +INSERT INTO `cache_report_reasons` (`id`, `name`, `trans_id`, `order`) VALUES ('2', 'Copyright violation', '777', 3); +INSERT INTO `cache_report_reasons` (`id`, `name`, `trans_id`, `order`) VALUES ('3', 'Cache is gone', '778', 1); +INSERT INTO `cache_report_reasons` (`id`, `name`, `trans_id`, `order`) VALUES ('4', 'Other reason', '779', 5); +INSERT INTO `cache_report_reasons` (`id`, `name`, `trans_id`, `order`) VALUES ('5', 'Description is unusable', '2609', 4); -- Table cache_report_status SET NAMES 'utf8'; @@ -2866,6 +2867,7 @@ INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2605', 'If you INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2606', 'Picture', '2015-06-17 10:09:14'); INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2607', 'Title:', '2015-06-17 10:09:14'); INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2608', 'move up', '2015-06-17 10:09:14'); +INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2609', 'Description is unusable', '2015-06-17 10:09:14'); -- Table sys_trans_ref SET NAMES 'utf8'; @@ -7461,6 +7463,7 @@ INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUE INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2606', 'DE', 'Bild', '2015-06-17 10:09:14'); INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2607', 'DE', 'Titel:', '2015-06-17 10:09:14'); INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2608', 'DE', 'nach oben', '2015-06-17 10:09:14'); +INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2609', 'DE', 'Beschreibung ist unbrauchbar', '2015-06-17 10:09:14'); INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('1', 'EN', 'Reorder IDs', '2010-09-02 00:15:30'); INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2', 'EN', 'The database could not be reconnected.', '2010-08-28 11:48:07'); INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('3', 'EN', 'Testing – please do not login', '2010-08-28 11:48:07'); diff --git a/htdocs/doc/sql/tables/cache_report_reasons.sql b/htdocs/doc/sql/tables/cache_report_reasons.sql index b1b17059e..41ef6196d 100644 --- a/htdocs/doc/sql/tables/cache_report_reasons.sql +++ b/htdocs/doc/sql/tables/cache_report_reasons.sql @@ -4,6 +4,7 @@ CREATE TABLE `cache_report_reasons` ( `id` tinyint(3) unsigned NOT NULL auto_increment, `name` varchar(80) NOT NULL, `trans_id` int(10) unsigned NOT NULL, + `order` tinyint(2) unsigned NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='static content' ; diff --git a/htdocs/reportcache.php b/htdocs/reportcache.php index 6a4f6d7fe..1161044da 100644 --- a/htdocs/reportcache.php +++ b/htdocs/reportcache.php @@ -46,12 +46,12 @@ { if ($cache->report($login->userid, $reportreason, $reportnote)) { - $reasontext = sql_value("SELECT IFNULL(`tt`.`text`, `crr`.`name`) - FROM `cache_report_reasons` AS `crr` - INNER JOIN `sys_trans_text` AS `tt` ON `tt`.`trans_id`=`crr`.`trans_id` - WHERE `crr`.`id` =&1 - AND `tt`.`lang`='&2'", - 'unknown', $reportreason, $opt['template']['locale']); + $reasontext = sql_value(" + SELECT IFNULL(`tt`.`text`, `crr`.`name`) + FROM `cache_report_reasons` AS `crr` + INNER JOIN `sys_trans_text` AS `tt` ON `tt`.`trans_id`=`crr`.`trans_id` + WHERE `crr`.`id` =&1 AND `tt`.`lang`='&2'", + 'unknown', $reportreason, $opt['template']['locale']); $tpl->assign('reasontext', $reasontext); $tpl->assign('success', true); @@ -63,11 +63,13 @@ } } - $rs = sql("SELECT `cache_report_reasons`.`id`, IFNULL(`sys_trans_text`.`text`, `cache_report_reasons`.`name`) AS `name` - FROM `cache_report_reasons` - LEFT JOIN `sys_trans` ON `cache_report_reasons`.`trans_id`=`sys_trans`.`id` AND `cache_report_reasons`.`name`=`sys_trans`.`text` - LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1'", - $opt['template']['locale']); + $rs = sql(" + SELECT `cache_report_reasons`.`id`, IFNULL(`sys_trans_text`.`text`, `cache_report_reasons`.`name`) AS `name` + FROM `cache_report_reasons` + LEFT JOIN `sys_trans` ON `cache_report_reasons`.`trans_id`=`sys_trans`.`id` AND `cache_report_reasons`.`name`=`sys_trans`.`text` + LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1' + ORDER BY `order`", + $opt['template']['locale']); $tpl->assign_rs('reasons', $rs); sql_free_result($rs);