Fix Event->Storage()
This commit is contained in:
parent
279e437545
commit
bef7098cb4
|
@ -15,12 +15,12 @@ class Event {
|
|||
public function __construct( $IdOrRow = null ) {
|
||||
$row = NULL;
|
||||
if ( $IdOrRow ) {
|
||||
if ( is_integer( $IdOrRow ) or is_numeric( $IdOrRow ) ) {
|
||||
$row = dbFetchOne( 'SELECT *,unix_timestamp(StartTime) as Time FROM Events WHERE Id=?', NULL, array( $IdOrRow ) );
|
||||
if ( is_integer($IdOrRow) or is_numeric($IdOrRow) ) {
|
||||
$row = dbFetchOne('SELECT *,unix_timestamp(StartTime) as Time FROM Events WHERE Id=?', NULL, array($IdOrRow));
|
||||
if ( ! $row ) {
|
||||
Error('Unable to load Event record for Id=' . $IdOrRow );
|
||||
}
|
||||
} elseif ( is_array( $IdOrRow ) ) {
|
||||
} elseif ( is_array($IdOrRow) ) {
|
||||
$row = $IdOrRow;
|
||||
} else {
|
||||
$backTrace = debug_backtrace();
|
||||
|
@ -31,16 +31,16 @@ class Event {
|
|||
return;
|
||||
}
|
||||
|
||||
if ( $row ) {
|
||||
foreach ($row as $k => $v) {
|
||||
$this->{$k} = $v;
|
||||
}
|
||||
} else {
|
||||
if ( $row ) {
|
||||
foreach ($row as $k => $v) {
|
||||
$this->{$k} = $v;
|
||||
}
|
||||
} else {
|
||||
$backTrace = debug_backtrace();
|
||||
$file = $backTrace[1]['file'];
|
||||
$line = $backTrace[1]['line'];
|
||||
Error('No row for Event ' . $IdOrRow . " from $file:$line");
|
||||
}
|
||||
Error('No row for Event ' . $IdOrRow . " from $file:$line");
|
||||
}
|
||||
} # end if isset($IdOrRow)
|
||||
} // end function __construct
|
||||
|
||||
|
@ -51,10 +51,8 @@ class Event {
|
|||
if ( ! ( array_key_exists('Storage', $this) and $this->{'Storage'} ) ) {
|
||||
if ( isset($this->{'StorageId'}) and $this->{'StorageId'} )
|
||||
$this->{'Storage'} = Storage::find_one(array('Id'=>$this->{'StorageId'}));
|
||||
if ( ! $this->{'Storage'} )
|
||||
if ( ! ( array_key_exists('Storage', $this) and $this->{'Storage'} ) )
|
||||
$this->{'Storage'} = new Storage(NULL);
|
||||
} else {
|
||||
$this->{'Storage'} = new Storage(NULL);
|
||||
}
|
||||
return $this->{'Storage'};
|
||||
}
|
||||
|
@ -73,12 +71,12 @@ class Event {
|
|||
$backTrace = debug_backtrace();
|
||||
$file = $backTrace[1]['file'];
|
||||
$line = $backTrace[1]['line'];
|
||||
Warning( "Unknown function call Event->$fn from $file:$line" );
|
||||
Warning("Unknown function call Event->$fn from $file:$line");
|
||||
}
|
||||
}
|
||||
|
||||
public function Time() {
|
||||
if ( ! isset( $this->{'Time'} ) ) {
|
||||
if ( ! isset($this->{'Time'}) ) {
|
||||
$this->{'Time'} = strtotime($this->{'StartTime'});
|
||||
}
|
||||
return $this->{'Time'};
|
||||
|
@ -100,7 +98,7 @@ class Event {
|
|||
$event_path = $this->{'MonitorId'} .'/'.$this->{'Id'};
|
||||
}
|
||||
|
||||
return( $event_path );
|
||||
return $event_path;
|
||||
} // end function Relative_Path()
|
||||
|
||||
public function Link_Path() {
|
||||
|
@ -210,8 +208,8 @@ class Event {
|
|||
$this->{'DiskSpace'} = $new;
|
||||
}
|
||||
if ( null === $this->{'DiskSpace'} ) {
|
||||
$this->{'DiskSpace'} = folder_size( $this->Path() );
|
||||
dbQuery( 'UPDATE Events SET DiskSpace=? WHERE Id=?', array( $this->{'DiskSpace'}, $this->{'Id'} ) );
|
||||
$this->{'DiskSpace'} = folder_size($this->Path());
|
||||
dbQuery('UPDATE Events SET DiskSpace=? WHERE Id=?', array($this->{'DiskSpace'}, $this->{'Id'}));
|
||||
}
|
||||
return $this->{'DiskSpace'};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue