Skip to content
Permalink
Browse files

improved handling of log type changes; updates #336

  • Loading branch information...
following5 committed Mar 26, 2016
1 parent a22f680 commit 12c8a0ceff4691491a684b0542ed4dbc3d8482d7
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('1360', 'EN', 'This cache stores a GeoKrety', '2010-09-10 23:58:48');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('1361', 'EN', 'This cache has %1 recommandation(s)', '2010-09-10 23:58:36');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('1362', 'EN', 'Edit log entry for the cache <a href=\"viewcache.php?cacheid={cacheid}\">{cachename}</a>', '2010-09-10 23:58:12');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('1363', 'EN', 'Type of log-enrty', '2010-09-10 23:57:46');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('1363', 'EN', 'Type of log entry', '2010-09-10 23:57:46');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('1364', 'EN', 'JavaScript is disabled in your browser, you can enter text only. To use HTML, or the editor, please enable JavaScript.', '2010-09-10 23:57:54');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('1365', 'EN', 'New cache', '2010-09-10 23:57:04');
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('1366', 'EN', 'Owner:', '2010-09-10 23:56:45');
@@ -56,23 +56,29 @@
$useradmin = ($login->admin & ADMIN_USER) ? 1 : 0;
//does log with this logid exist?
$log_rs = sql("SELECT `cache_logs`.`cache_id` AS `cache_id`,
`cache_logs`.`node` AS `node`,
`cache_logs`.`text` AS `text`,
`cache_logs`.`date` AS `date`,
`cache_logs`.`user_id` AS `user_id`,
`cache_logs`.`type` AS `logtype`,
`cache_logs`.`oc_team_comment` AS `oc_team_comment`,
`cache_logs`.`text_html` AS `text_html`,
`cache_logs`.`text_htmledit` AS `text_htmledit`,
`caches`.`name` AS `cachename`,
`caches`.`type` AS `cachetype`,
`caches`.`user_id` AS `cache_user_id`,
`caches`.`logpw` as `logpw`,
`caches`.`status` as `status`
FROM `cache_logs`
INNER JOIN `caches` ON (`caches`.`cache_id`=`cache_logs`.`cache_id`) WHERE `id`='&1'",
$log_id);
$log_rs = sql("
SELECT
`cache_logs`.`id` AS `log_id`,
`cache_logs`.`cache_id` AS `cache_id`,
`cache_logs`.`node` AS `node`,
`cache_logs`.`text` AS `text`,
`cache_logs`.`date` AS `date`,
`cache_logs`.`user_id` AS `user_id`,
`cache_logs`.`type` AS `logtype`,
`cache_logs`.`oc_team_comment` AS `oc_team_comment`,
`cache_logs`.`text_html` AS `text_html`,
`cache_logs`.`text_htmledit` AS `text_htmledit`,
`caches`.`name` AS `cachename`,
`caches`.`type` AS `cachetype`,
`caches`.`user_id` AS `cache_user_id`,
`caches`.`logpw` as `logpw`,
`caches`.`status` as `status`,
`log_types`.`cache_status` > 0 AS `is_status_log`
FROM `cache_logs`
JOIN `log_types` ON `log_types`.`id`=`cache_logs`.`type`
INNER JOIN `caches` ON `caches`.`cache_id`=`cache_logs`.`cache_id`
WHERE `cache_logs`.`id`='&1'",
$log_id);
$log_record = sql_fetch_array($log_rs);
sql_free_result($log_rs);
@@ -264,6 +270,22 @@
(($descMode == 3) ? 1 : 0),
$log_id);
// update cache status if changed by logtype
if (is_latest_log($log_record['cache_id'], $log_record['log_id']))
{
$newstatus = sqlValue("
SELECT `cache_status` FROM `log_types`
WHERE `id`='" . sql_escape($log_type) . "'",
false);
if ($newstatus && $newstatus != $log_record['status']) {
sql("SET @STATUS_CHANGE_USER_ID='&1'", $login->userid);
sql("
UPDATE `caches` SET `status`='" . sql_escape($newstatus) . "'
WHERE `cache_id`='" . sql_escape($log_record['cache_id']) . "'
");
}
}
//update user-stat if type changed
if ($log_record['logtype'] != $log_type)
{
@@ -307,14 +329,27 @@
}
// build logtype options
$disable_statuschange = (
$log_record['cache_user_id'] == $login->userid
&& !is_latest_log($log_record['cache_id'], $log_record['log_id'])
);
$logtype_names = get_logtype_names();
$allowed_logtypes = get_cache_log_types($log_record['cache_id'], $log_record['logtype']);
$allowed_logtypes = get_cache_log_types($log_record['cache_id'], $log_record['logtype'], !$disable_statuschange);
$logtypeoptions = '';
foreach ($allowed_logtypes as $logtype)
{
$selected = ($log_record['logtype'] == $logtype ? ' selected="selected"' : '');
$logtypeoptions .= '<option value="' . $logtype . '"' . $selected . '>' . htmlspecialchars($logtype_names[$logtype], ENT_COMPAT, 'UTF-8') . '</option>' . "\n";
}
$disable_typechange = $disable_statuschange && $log_record['is_status_log'];
tpl_set_var('type_edit_disabled', $disable_typechange ? $type_edit_disabled : '');
// TODO: Enforce the 'diables' when processing the posted data.
// It's not that urgent, because nothing can be broken by changing
// past status log types (it was even allowed up to OC 3.0.17);
// just the log history may look weird.
if (teamcomment_allowed($log_record['cache_id'], 3, $log_record['oc_team_comment']))
tpl_set_var('teamcommentoption',
mb_ereg_replace('{chk_sel}', ($oc_team_comment ? 'checked' : ''), $teamcomment_field));
@@ -402,3 +437,16 @@
//make the template and send it out
tpl_BuildTemplate();
function is_latest_log($cache_id, $log_id)
{
$lastest_log_id = sqlValue("
SELECT `id` FROM `cache_logs`
WHERE `cache_id`='" . sql_escape($cache_id) . "'
ORDER BY `order_date` DESC, `date_created` DESC, `id` DESC
LIMIT 1",
0,
$cache_id);
return ($log_id == $lastest_log_id);
}
@@ -27,3 +27,5 @@
$log_pw_field_pw_not_ok = '<tr><td colspan="2">' . t('passwort to log:') . ' <input type="text" name="log_pw" maxlength="20" size="20" value=""/><span class="errormsg"> ' . t('Invalid password!') . '</span></td></tr><tr><td class="spacer" colspan="2"></td></tr>';
$teamcomment_field = '&nbsp; <input type="checkbox" name="teamcomment" value="1" class="checkbox" {chk_sel} id="teamcomment" /> <label for="teamcomment">' . t('OC team comment') . "</label>";
$type_edit_disabled = 'disabled class="disabled"';
@@ -91,7 +91,7 @@ function _chkFound () {
<tr>
<td width="180px">{t}Type of log-enrty{/t}</td>
<td align="left">
<select name="logtype" onChange="return _chkFound()">
<select name="logtype" onChange="return _chkFound()" {type_edit_disabled}>
{logtypeoptions}
</select>
{teamcommentoption}
@@ -58,7 +58,7 @@ function admin_has_open_report($cache_id)
// type_id => translated type name
// first entry is default for new logs
function get_cache_log_types($cache_id, $old_logtype)
function get_cache_log_types($cache_id, $old_logtype, $statuslogs=true)
{
global $login;
@@ -82,7 +82,7 @@ function get_cache_log_types($cache_id, $old_logtype)
{
$allowed_logtypes[] = 3; // note
}
if ($owner || $admin_report)
if (($owner && $statuslogs) || $admin_report)
{
if ($cache_status != 5 && (($cache_status != 4 && $cache_status != 7) || $admin_report))
{

0 comments on commit 12c8a0c

Please sign in to comment.
You can’t perform that action at this time.