mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
N°6275-refactor time/date to ease AddLogEntry/AddLogEntryFromJSON testability in the future
This commit is contained in:
@@ -544,8 +544,11 @@ class ormCaseLog {
|
||||
*/
|
||||
public function AddLogEntry(string $sText, $sOnBehalfOf = '', $iOnBehalfOfId = null)
|
||||
{
|
||||
$sText = HTMLSanitizer::Sanitize($sText);
|
||||
//date/time ops moved here for test stability
|
||||
$iNow = time();
|
||||
$sDate = date(AttributeDateTime::GetInternalFormat());
|
||||
|
||||
$sText = HTMLSanitizer::Sanitize($sText);
|
||||
if ($sOnBehalfOf == '' && $iOnBehalfOfId === null) {
|
||||
$sOnBehalfOf = UserRights::GetUserFriendlyName();
|
||||
$iUserId = UserRights::GetUserId();
|
||||
@@ -584,7 +587,7 @@ class ormCaseLog {
|
||||
$this->m_aIndex[] = array(
|
||||
'user_name' => $sOnBehalfOf,
|
||||
'user_id' => $iUserId,
|
||||
'date' => time(),
|
||||
'date' => $iNow,
|
||||
'text_length' => $iTextlength,
|
||||
'separator_length' => $iSepLength,
|
||||
'format' => static::ENUM_FORMAT_HTML,
|
||||
@@ -595,6 +598,9 @@ class ormCaseLog {
|
||||
|
||||
public function AddLogEntryFromJSON($oJson, $bCheckUserId = true)
|
||||
{
|
||||
//date/time ops moved here for test stability
|
||||
$iNow = time();
|
||||
|
||||
if (isset($oJson->user_id))
|
||||
{
|
||||
if (!UserRights::IsAdministrator())
|
||||
@@ -633,7 +639,7 @@ class ormCaseLog {
|
||||
}
|
||||
else
|
||||
{
|
||||
$iDate = time();
|
||||
$iDate = $iNow;
|
||||
}
|
||||
if (isset($oJson->format))
|
||||
{
|
||||
@@ -660,7 +666,7 @@ class ormCaseLog {
|
||||
$this->m_aIndex[] = array(
|
||||
'user_name' => $sOnBehalfOf,
|
||||
'user_id' => $iUserId,
|
||||
'date' => $iDate,
|
||||
'date' => $iNow,
|
||||
'text_length' => $iTextlength,
|
||||
'separator_length' => $iSepLength,
|
||||
'format' => $sFormat,
|
||||
|
||||
Reference in New Issue
Block a user