Version 4.1.2

This commit is contained in:
Neo committed 2025-12-19 05:32:19 -08:00
1 parent 3ba79295ee
commit 28bd025b35
1131 files changed
+63658 -20579

No files matched your search

+52
View File
@@ -41,4 +41,56 @@ class _Application extends \IPS\Application
{
return 'comment';
}
/**
* Is chat online? Returns error message if not
*
* @return string|TRUE
*/
public function offlineMessage()
{
if( \IPS\Settings::i()->ipschat_online )
{
$times = explode( ',', \IPS\Settings::i()->ipschat_online );
if( count( $times ) AND $times[0] )
{
/* Do we need to adjust the time zone? */
if( isset( $times[2] ) AND $times[2] != \IPS\Member::loggedIn()->timezone )
{
$start = new \IPS\DateTime( '2015-01-01 ' . $times[0], new \DateTimeZone( $times[2] ) );
$start->setTimezone( new \DateTimeZone( \IPS\Member::loggedIn()->timezone ) );
$times[0] = $start->format( 'H:i' );
$end = new \IPS\DateTime( '2015-01-01 ' . $times[1], new \DateTimeZone( $times[2] ) );
$end->setTimezone( new \DateTimeZone( \IPS\Member::loggedIn()->timezone ) );
$times[1] = $end->format( 'H:i' );
}
$currentTime = new \IPS\DateTime( NULL, new \DateTimeZone( ( isset( $times[2] ) ) ? $times[2] : \IPS\Member::loggedIn()->timezone ) );
$currentTime->setTimezone( new \DateTimeZone( \IPS\Member::loggedIn()->timezone ) );
$currentTime = $currentTime->format( 'H:i' );
/* Convert times to floats, as that is simple to compare */
$start = str_replace( ':', '.', $times[0] );
$end = str_replace( ':', '.', $times[1] );
$currentTime = str_replace( ':', '.', $currentTime );
if( $end > $start )
{
if( !( $currentTime >= $start ) OR !( $currentTime < $end ) )
{
return \IPS\Member::loggedIn()->language()->addToStack( 'chat_currently_offline', FALSE, array( 'sprintf' => $start ) );
}
}
else
{
if( !( $currentTime >= $start ) AND $currentTime >= $end )
{
return \IPS\Member::loggedIn()->language()->addToStack( 'chat_currently_offline', FALSE, array( 'sprintf' => $start ) );
}
}
}
}
}
}