admins can log locked caches

This commit is contained in:
following
2013-04-13 00:38:32 +02:00
parent 343d2e364a
commit 036e6fa0c5
7 changed files with 34 additions and 13 deletions

View File

@ -49,6 +49,8 @@
}
else
{
$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`,
@ -69,8 +71,8 @@
$log_record = sql_fetch_array($log_rs);
sql_free_result($log_rs);
if ($log_record !== false &&
($log_record['status'] != 6 || ($log_record['cache_user_id'] == $login->userid && $log_record['user_id'] == $login->userid)) &&
$log_record['status'] != 7)
(($log_record['status'] != 6 || ($log_record['cache_user_id'] == $login->userid && $log_record['user_id'] == $login->userid)) &&
$log_record['status'] != 7) || $useradmin)
{
require($stylepath . '/editlog.inc.php');
require($stylepath.'/rating.inc.php');

View File

@ -57,11 +57,21 @@
require($stylepath . '/log_cache.inc.php');
require($stylepath.'/rating.inc.php');
$useradmin = ($login->admin & ADMIN_USER) ? 1 : 0;
$cachename = '';
if ($cache_id != 0)
{
//get cachename
$rs = sql("SELECT `caches`.`name`, `caches`.`user_id`, `caches`.`logpw`, `caches`.`wp_gc`, `caches`.`wp_nc`, `caches`.`type`, `caches`.`status` FROM `caches` INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` WHERE (`cache_status`.`allow_user_log`=1 OR `caches`.`user_id`='&1') AND `caches`.`cache_id`='&2'", $usr['userid'], $cache_id);
$rs = sql("SELECT `caches`.`name`, `caches`.`user_id`, `caches`.`logpw`,
`caches`.`wp_gc`, `caches`.`wp_nc`, `caches`.`type`,
`caches`.`status`,
`cache_status`.`allow_user_log`=1 OR `caches`.`user_id`='&1' AS `log_allowed`
FROM `caches`
INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id`
WHERE (`cache_status`.`allow_user_log`=1 OR `caches`.`user_id`='&1' OR '&3')
AND `caches`.`cache_id`='&2'",
$usr['userid'], $cache_id, $useradmin);
if (mysql_num_rows($rs) == 0)
{
@ -70,9 +80,10 @@
else
{
$record = sql_fetch_array($rs);
$adminlog = !($record['log_allowed']) && $useradmin;
// only the owner is allowed to make logs to not published caches
if ($record['user_id'] == $usr['userid'] || $record['status'] != 5)
// only the owner and admins are allowed to make logs to not published caches
if ($record['user_id'] == $usr['userid'] || $record['status'] != 5 || $useradmin)
{
$cachename = $record['name'];
$cache_user_id = $record['user_id'];
@ -95,7 +106,7 @@
{
$all_ok = false;
$log_text = isset($_POST['logtext']) ? ($_POST['logtext']) : '';
$log_type = isset($_POST['logtype']) ? ($_POST['logtype']+0) : 1;
$log_type = isset($_POST['logtype']) ? ($_POST['logtype']+0) : null;
$log_date_day = isset($_POST['logday']) ? trim($_POST['logday']) : date('d');
$log_date_month = isset($_POST['logmonth']) ? trim($_POST['logmonth']) : date('m');
$log_date_year = isset($_POST['logyear']) ? trim($_POST['logyear']) : date('Y');
@ -272,11 +283,13 @@
LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='" . sql_escape($locale) . "'
WHERE `caches`.`cache_id`='" . ($cache_id+0) . "'
ORDER BY `log_types`.`id` " . $logtypeorder);
$log_type = ($record['user_id'] == $usr['userid'] ? 3 : 1);
while ($rLogTypes = sql_fetch_assoc($rsLogTypes))
{
$sSelected = ($rLogTypes['id'] == $log_type) ? ' selected="selected"' : '';
$logtypeoptions .= '<option value="' . $rLogTypes['id'] . '"' . $sSelected . '>' . htmlspecialchars($rLogTypes['name'], ENT_COMPAT, 'UTF-8') . '</option>' . "\n";
}
if (!$adminlog || $rLogTypes['id'] == 3)
{
$sSelected = ($rLogTypes['id'] == $log_type) ? ' selected="selected"' : '';
$logtypeoptions .= '<option value="' . $rLogTypes['id'] . '"' . $sSelected . '>' . htmlspecialchars($rLogTypes['name'], ENT_COMPAT, 'UTF-8') . '</option>' . "\n";
}
sql_free_result($rsLogTypes);
//set tpl vars

View File

@ -204,6 +204,9 @@ div#bg2 {display: none;}
/*.nav4 {overflow: hidden; clear: both; margin: 0px; padding: 0px; color: rgb(75,75,75); font-size: 1.0em;margin: 0;}
*/
/*.nav4 ul {width: 160px; margin: 0px 0px 0px 0px; padding: 0px; border-bottom: solid 1px rgb(216,206,159); background-color: rgb(219,230,241);}*/
.nav4 li.hilite a { background-color:#ffb9b5 !important; }
.nav4 li {float: left; list-style: none; margin: 0px; padding: 0px;padding-bottom: 5px;}
.nav4 li.title {display: none; margin: 0px 0px 0px 0px; padding: 3px 5px 2px 5px; background-color: rgb(156,186,214); color: rgb(255,255,255); text-transform: uppercase; font-weight: bold; font-size: 120%;}
.nav4 li.group a {background-color: rgb(219,230,241);display: block; min-height: 1.7em; height: auto !important; height: 1.7em; line-height: 1.7em; margin: 0px; margin-right: 3px; padding: 0px 7px 0px 20px; border-top: solid 1px rgb(200,200,200); border-left: solid 7px rgb(219,230,241); color: rgb(75,75,75); font-weight: bold; font-size: 120%;}

View File

@ -34,7 +34,7 @@
{* Ocprop: /\?logid=([0-9a-f\-]+)" *}
{if $cache.userid==$login.userid || $logItem.userid==$login.userid}
<p class="editlog"><img src="images/trans.gif" border="0" width="16" height="16" alt="" title="" />
{if $logItem.userid==$login.userid && ($cache.userid==$login.userid || $cache.status!=6)}
{if $logItem.userid==$login.userid && ($cache.userid==$login.userid || $cache.status!=6 || $cache.adminlog)}
<a href="editlog.php?logid={$logItem.id|urlencode}"><img src="resource2/{$opt.template.style}/images/action/16x16-properties.png" border="0" align="middle" border="0" width="16" height="16" alt="" /></a>
[<a href="editlog.php?logid={$logItem.id|urlencode}">{t}Edit{/t}</a>]
{/if}

View File

@ -80,8 +80,8 @@
<ul id="cachemenu">
<li class="title" >Cache Menu</li>
{if $login.userid!=0}
{if $cache.log_allowed}
<li class="group"><a style="background-image: url(resource2/{$opt.template.style}/images/viewcache/new-entry-18.png);background-repeat:no-repeat;" href="log.php?cacheid={$cache.cacheid|urlencode}">{t}Log this cache{/t}</a></li>
{if $cache.log_allowed || $cache.adminlog}
<li class="group {if $cache.adminlog}hilite{/if}"><a style="background-image: url(resource2/{$opt.template.style}/images/viewcache/new-entry-18.png);background-repeat:no-repeat;" href="log.php?cacheid={$cache.cacheid|urlencode}">{t}Log this cache{/t}</a></li>
{/if}
{if $watched==1}

View File

@ -155,6 +155,8 @@ function getChildWaypoints($cacheid)
$tpl->error(ERROR_CACHE_NOT_PUBLISHED);
}
$rCache['adminlog'] = !$rCache['log_allowed'] && ($login->admin & ADMIN_USER);
$rCache['desclanguages'] = explode(',', $rCache['desclanguages']);
$rCache['sizeName'] = labels::getLabelValue('cache_size', $rCache['size']);

View File

@ -64,6 +64,7 @@
else
$tpl->error(ERROR_CACHE_NOT_EXISTS);
$rCache['adminlog'] = ($login->admin & ADMIN_USER);
$tpl->assign('cache', $rCache);
$tpl->assign('logs', cache::getLogsArray($cache_id, $start, $count));