Skip to content
Permalink
Browse files

Merge pull request #552 from following5/editlog

ported editlog to lib2 and added condition state editing
  • Loading branch information...
teiling88 committed Aug 31, 2017
2 parents ffce1e2 + 91638f4 commit 7751e9b1414ec5e6b88e57f05ecdb2fdd78a88fd

Large diffs are not rendered by default.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
@@ -37,3 +37,5 @@
define('ERROR_UPLOAD_ERR_TYPE', 1024);
define('ERROR_UPLOAD_UNKNOWN', 1025);
define('ERROR_UPLOAD_ERR_BAD_FORMAT', 1026);
define('ERROR_WRONG_NODE', 1027);
@@ -288,6 +288,38 @@ public function getListingOutdatedLogUrl()
return $url;
}
// test if af the time of insertion of an existing log the listing
// was outdated and there is no newer listing-[not]-outdated-log
public function getListingOutdatedRelativeToLog($logId)
{
$logDate = sql_value("SELECT `order_date` FROM `cache_logs` WHERE `id`='&1'", '', $logId);
return
sql_value( // Is there a newer log with LO flag?
"SELECT 1
FROM `cache_logs`
WHERE `cache_id`='&1'
AND `order_date`>'&2'
AND `listing_outdated`>0
LIMIT 1",
0,
$this->getCacheId(),
$logDate
) == 0 && sql_value( // Was the listing outdated before the log was posted?
"SELECT `listing_outdated`
FROM `cache_logs`
WHERE `cache_id`='&1'
AND `listing_outdated`>0
AND `id`!='&2'
ORDER BY `order_date` DESC, `date_created` DESC, `id` DESC
LIMIT 1",
0,
$this->getCacheId(),
$logId
) == 2;
}
public function setListingOutdated($value)
{
return $this->reCache->setValue('listing_outdated', $value);
@@ -963,14 +995,14 @@ public function updateCacheStatus($logType)
// $userLogType:
// Logtype selected by the user, or null if not applicable
public function getUserLogTypes($userLogType, $oldLogType = 0)
public function getUserLogTypes($userLogType, $oldLogType = 0, $statusLogs = true)
{
$logTypes = [];
$logtypeNames = get_logtype_names();
$allowedLogtypes = get_cache_log_types($this->getCacheId(), $oldLogType);
$allowedLogtypes = get_cache_log_types($this->getCacheId(), $oldLogType, $statusLogs);
$defaultLogType = $userLogType;
if (!logtype_ok($this->getCacheId(), $defaultLogType, $oldLogType)) {
if (!logtype_ok($this->getCacheId(), $defaultLogType, $oldLogType, $statusLogs)) {
$defaultLogType = $allowedLogtypes[0];
}
@@ -1004,4 +1036,22 @@ public function statusUserLogAllowed()
$this->getCacheId()
) == 1;
}
/**
* @param $logId
* @return bool
*/
public function isLatestLog($logId)
{
$latestLogId = sql_value(
"SELECT `id` FROM `cache_logs`
WHERE `cache_id`='&1'
ORDER BY `order_date` DESC, `date_created` DESC, `id` DESC
LIMIT 1",
0,
$this->nCacheId
);
return ($logId == $latestLogId);
}
}
@@ -426,4 +426,38 @@ public static function isMasslogging($userId)
return ($masslogs > $opt['logic']['masslog']['count']);
}
public static function validateDate($year, $month, $day, $hour, $minute, $submit)
{
$dateOk = false;
if (is_numeric($month)
&& is_numeric($day)
&& is_numeric($year)
&& ($hour . $minute == '' || is_numeric($hour))
&& ($minute == '' || is_numeric($minute))
) {
$dateOk = checkdate($month, $day, $year)
&& ($year >= 2000)
&& ($hour >= 0)
&& ($hour <= 23)
&& ($minute >= 0)
&& ($minute <= 59);
if ($dateOk && $submit) {
$dateOk = (
mktime(
$hour + 0,
$minute + 0,
0,
$month,
$day,
$year
)
< time()
);
}
}
return $dateOk;
}
}
@@ -79,10 +79,7 @@ function get_cache_log_types($cache_id, $old_logtype, $statuslogs = true)
$cache_status = $rCache['status'];
$owner = $login->userid == ($rCache['user_id']);
$admin_report = admin_has_open_report($cache_id);
$admin_locked = $login->hasAdminPriv(ADMIN_USER) && in_array($rCache['status'], array(
6,
7
));
$admin_locked = $login->hasAdminPriv(ADMIN_USER) && in_array($rCache['status'], [6, 7]);
// build result list
//
@@ -125,9 +122,9 @@ function get_cache_log_types($cache_id, $old_logtype, $statuslogs = true)
}
function logtype_ok($cache_id, $logtype_id, $old_logtype)
function logtype_ok($cache_id, $logtype_id, $old_logtype, $statusLogs = true)
{
return in_array($logtype_id, get_cache_log_types($cache_id, $old_logtype));
return in_array($logtype_id, get_cache_log_types($cache_id, $old_logtype, $statusLogs));
}
Oops, something went wrong.

0 comments on commit 7751e9b

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