Skip to content

Commit

Permalink
added report reason for unusable description
Browse files Browse the repository at this point in the history
  • Loading branch information
following5 committed Mar 22, 2016
1 parent 3352405 commit 39784f0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
6 changes: 6 additions & 0 deletions bin/dbsv-update.php
Expand Up @@ -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.
//
Expand Down
11 changes: 7 additions & 4 deletions htdocs/doc/sql/static-data/data.sql
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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');
Expand Down
1 change: 1 addition & 0 deletions htdocs/doc/sql/tables/cache_report_reasons.sql
Expand Up @@ -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' ;
24 changes: 13 additions & 11 deletions htdocs/reportcache.php
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 39784f0

Please sign in to comment.