Skip to content

Commit

Permalink
allow consensual restoration of cache listings of enabled users;
Browse files Browse the repository at this point in the history
updates #1093
  • Loading branch information
following5 authored and teiling88 committed Aug 26, 2017
1 parent 7990b38 commit ba7e660
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 36 deletions.
13 changes: 8 additions & 5 deletions htdocs/restorecaches.php
Expand Up @@ -255,14 +255,13 @@

$tpl->assign('step', 5);
$tpl->assign('username', $_REQUEST['username']);
$tpl->assign(
'disabled',
$disabled =
sql_value(
"SELECT NOT `is_active_flag` FROM `user` WHERE `username`='&1'",
0,
$_REQUEST['username']
)
);
);
$tpl->assign('disabled', $disabled);

$simulate = isset($_REQUEST['simulate']) && $_REQUEST['simulate'];
$tpl->assign('simulate', $simulate);
Expand All @@ -275,7 +274,11 @@
}
}

if ($restore_date == '') {
$allowance = isset($_REQUEST['allowance']) && $_REQUEST['allowance'];
if (!$disabled && !$simulate && !$allowance) {
$tpl->assign('error', 'noallowance');
$tpl->display();
} elseif ($restore_date == '') {
$tpl->assign('error', 'nodate');
$tpl->display();
} elseif (count($restore_options) == 0) {
Expand Down
65 changes: 34 additions & 31 deletions htdocs/templates2/ocstyle/restorecaches.tpl
Expand Up @@ -36,7 +36,7 @@
<h2>{t 1=$username}Restore cache listings of %1{/t}</h2>

{if !$disabled && $step<5}
<p class="redtext">{t 1=$username}User '%1' is not disabled. You can view recorded changes, but not revert them.{/t}</p>
<p class="redtext">{t 1=$username}User '%1' is not disabled. To reset one or more caches to a previous version, you need the user's permission.{/t}</p>
{/if}

{if $error != "" && ($error != "notsure" || !$simulate)}
Expand All @@ -52,9 +52,11 @@
{t}You must choose the listing elements to be restored.{/t} {t}Use your browser's 'back' button to try again.{/t}
{elseif $error == "notsure"}
{t}You did not say that you are sure.{/t} {t}Use your browser's 'back' button to try again.{/t}
{elseif $error == "noallowance"}
{t}You did not confirm that the user has allowed to restore his caches.{/t}
{/if}
</p>
{if $error!="notsure" && $error!="nodate" && $error!="nochecks"}
{if $error != "notsure" && $error != "nodate" && $error != "nochecks" && $error != "noallowance"}
<br />
<form method="post" action="restorecaches.php">
<input type="hidden" name="finduser" value="1" />
Expand All @@ -65,9 +67,7 @@

{* step 3: select caches *}
{elseif $step == 3}
{if $disabled}
<p>{t}Please select the listings to restore{/t}:</p>
{/if}
<p>{t}Please select the listings to restore{/t}:</p>
<br />
<form method="post" action="restorecaches.php">
<input type="hidden" name="caches" value="1" />
Expand Down Expand Up @@ -117,10 +117,18 @@
<input type="hidden" name="username" value="{$username}" />
<input type="hidden" name="cacheids" value="{$cachelist}" />
<input type="hidden" name="doit" value="1" />
{if $today}
{if $today && !$rootadmin}
<p class="redtext">{t}The user changed one or more of these caches today, therefore you cannot revert changes. This can be done not before tomorrow.{/t}</p>
{/if}
{if ($disabled && !$today) || $rootadmin}
{if !$today || $rootadmin}
{if !$disabled}
<div style="margin:2em; padding:1em; border:1px dashed black;">
<table><tr><td class="default">
<input type="checkbox" name="allowance" id="allowance" value="1" />
&nbsp;{t}The user has allowed to reset the selected caches to a previous version.{/t}
</td></tr></table>
</div>
{/if}
<p>{t}Please select the date from which on all changes are to be reverted.<br />The listing will be reset to the contents it had on that day at 00:00:00.{/t}</p>
{/if}
<br />
Expand All @@ -134,7 +142,7 @@

{foreach from=$dates key=date item=caches}
<tr>
<td>{if ($disabled && !$today) || $rootadmin}<input type="radio" name="dateselect" value="{$date}" />{/if}</td>
<td>{if !$today || $rootadmin}<input type="radio" name="dateselect" value="{$date}" />{/if}</td>
<td>{$date|date_format:$opt.format.date}</td>
</tr>
{foreach from=$caches key=wp item=text}
Expand All @@ -155,29 +163,24 @@
{if $today && $rootadmin}
<p class="redtext">{t}Warning: If you revert any owner-made listing changes of <em>today</em>, your revert will be final. It cannot be corrected / undone afterwards. Only reverts of coords &amp; country, logs and pictures will be logged in this case, so all other changes will not be comprehensible. Therefore <span style="text-decoration:underline">it is strongly recommended to revert vandalism not before the next day!</span>{/t}</p>
{/if}
{if $disabled || $rootadmin}
<p>{t}Restore{/t} ...</p>
<p>
<input type="checkbox" name="restore_coords" value="1" /> {t}coordinates and country{/t}&nbsp;&nbsp;
<input type="checkbox" name="restore_settings" value="1" /> {t}name, settings, attributes and hide-date{/t} &nbsp;&nbsp;
<input type="checkbox" name="restore_waypoints" value="1" /> {t}GC/NC waypoints{/t} <br />
<input type="checkbox" name="restore_desc" value="1" /> {t}description(s) incl. pictures{/t} &nbsp;&nbsp;
<input type="checkbox" name="restore_logs" value="1" /> {t}logs incl. pictures{/t} &nbsp;&nbsp;
<a href="javascript:checkall('checked')">{t}_all{/t}</a> &nbsp; <a href="javascript:checkall('')">{t}nothing{/t}</a>
</p>
<p>
<em>{t}Excluded from restore: cache status, OConly attribute, additional waypoints, log password, preview picture status{/t}</em>
</p>
<p>
<input type="checkbox" name="sure" value="1" /> {t}Sure?{/t} &nbsp;&nbsp;
<input type="checkbox" name="simulate" value="1" /> {t}simulate{/t}
</p>
<br />
<p><input type="submit" class="formbutton" name="revert" value="{t}Revert Vandalism{/t}" style="width:200px" onclick="submitbutton('revert')" /></p>
{if !$disabled && $rootadmin}
<p>{t}You are root admin and can override the warnings. Take care!{/t}</p>
{/if}
{/if}
<p>{t}Restore{/t} ...</p>
<p>
<input type="checkbox" name="restore_coords" value="1" /> {t}coordinates and country{/t}&nbsp;&nbsp;
<input type="checkbox" name="restore_settings" value="1" /> {t}name, settings, attributes and hide-date{/t} &nbsp;&nbsp;
<input type="checkbox" name="restore_waypoints" value="1" /> {t}GC/NC waypoints{/t} <br />
<input type="checkbox" name="restore_desc" value="1" /> {t}description(s) incl. pictures{/t} &nbsp;&nbsp;
<input type="checkbox" name="restore_logs" value="1" /> {t}logs incl. pictures{/t} &nbsp;&nbsp;
<a href="javascript:checkall('checked')">{t}_all{/t}</a> &nbsp; <a href="javascript:checkall('')">{t}nothing{/t}</a>
</p>
<p>
<em>{t}Excluded from restore: cache status, OConly attribute, additional waypoints, log password, preview picture status{/t}</em>
</p>
<p>
<input type="checkbox" name="sure" value="1" /> {t}Sure?{/t} &nbsp;&nbsp;
<input type="checkbox" name="simulate" value="1" /> {t}simulate{/t}
</p>
<br />
<p><input type="submit" class="formbutton" name="revert" value="{t}Revert Vandalism{/t}" style="width:200px" onclick="submitbutton('revert')" /></p>
</form>

{* step 4: listings are restored - show result *}
Expand Down
3 changes: 3 additions & 0 deletions sql/static-data/sys_trans.sql
Expand Up @@ -1937,6 +1937,9 @@ INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2637', 'This Ge
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2638', 'Please verify that the geocache description is complete and all properties and attributes are set properly, according to the <a %1>instructions</a>. Then click <strong><a href=\"editcache.php?cacheid=%2&publish=now#others\">here</a></strong> and \"Save\" to publish your geocache.', '2017-08-20 19:30:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2640', 'Do you really want to delete the picture \\\'{title}\\\'?', '2017-08-22 18:45:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2641', 'There is already a report in progress for this cache, see below.', '2017-08-23 13:20:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2644', 'User \'%1\' is not disabled. To reset one or more caches to a previous version, you need the user\'s permission.', '2017-08-23 13:20:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2645', 'You did not confirm that the user has allowed to restore his caches.', '2017-08-23 13:20:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2646', 'The user has allowed to reset the selected caches to a previous version.', '2017-08-23 13:20:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2647', 'Admin info:', '2017-08-23 13:20:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2648', 'There already are %1 pending reports for this geocache.', '2017-08-23 13:20:00');
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2649', 'There already is a pending report for this geocache.', '2017-08-23 13:20:00');
Expand Down
3 changes: 3 additions & 0 deletions sql/static-data/sys_trans_text_de.sql
Expand Up @@ -1935,6 +1935,9 @@ INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUE
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2638', 'DE', 'Prüfe bitte, ob die Cachebeschreibung vollständig ist und alle Cacheigenschaften und -attribute gemäß <a %1>Anleitung</a> eingetragen sind. Dann klicke <strong><a href=\"editcache.php?cacheid=%2&publish=now#others\">hier</a></strong> auf &bdquo;Speichern&ldquo;, um deinen Cache zu veröffentlichen.', '2017-08-20 19:30:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2640', 'DE', 'Möchtest du das Bild &bdquo;{title}&ldquo; wirklich löschen?', '2017-08-22 18:45:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2641', 'DE', 'Für diesen Cache ist bereits eine Meldung in Arbeit, siehe unten.', '2017-08-23 13:20:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2644', 'DE', 'Der Benutzer \'%1\' ist nicht deaktiviert. Du darfst seine Caches nur zurücksetzen, wenn er sein Einverständnis dazu gegeben hat.', '2017-08-23 13:20:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2645', 'DE', 'Du hast nicht bestätigt, dass der Benutzer mit dem Zurücksetzen der Caches einverstanden ist.', '2017-08-23 13:20:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2646', 'DE', 'Der Benutzer ist damit einverstanden, dass die ausgewählten Cachen zurückgesetzt werden.', '2017-08-23 13:20:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2647', 'DE', 'Admin-Hinweis:', '2017-05-14 21:00:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2648', 'DE', 'Für diesen Cache liegen bereits %1 Meldungen vor.', '2017-05-14 21:00:00');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2649', 'DE', 'Für diesen Cache liegt bereits eine Meldung vor.', '2017-05-14 21:00:00');
Expand Down

0 comments on commit ba7e660

Please sign in to comment.