Added Library Info

This commit is contained in:
Deon George
2011-06-24 11:27:21 +10:00
parent 529d70d2bb
commit 279eacd4ab
17 changed files with 520 additions and 65 deletions

View File

@@ -0,0 +1,24 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Library
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_LIBRARY extends ORMTSM {
protected $_table_name = 'LIBRARIES';
protected $_primary_key = 'LIBRARY_NAME';
protected $_sorting = array(
'LIBRARY_NAME'=>'ASC',
);
protected $_has_one = array(
);
protected $_has_many = array(
);
}
?>

View File

@@ -0,0 +1,81 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Library Volumes
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_LIBVOLUME extends ORMTSM {
protected $_table_name = 'LIBVOLUMES';
protected $_primary_key = 'VOLUME_NAME';
protected $_sorting = array(
'VOLUME_NAME'=>'ASC',
);
protected $_has_one = array(
'VOLUME'=>array('foreign_key'=>'VOLUME_NAME','far_key'=>'VOLUME_NAME'),
);
protected $_has_many = array(
'VOLHISTORY'=>array('foreign_key'=>'VOLUME_NAME','far_key'=>'VOLUME_NAME'),
);
public function usage() {
switch (strtolower($this->STATUS)) {
case 'scratch': return strtolower($this->STATUS);
case 'private':
switch (strtolower($this->LAST_USE)) {
case 'dbbackup':
case 'data':
return strtolower($this->LAST_USE);
default: return 'unknown';
}
}
}
public function volusage() {
switch ($this->usage()) {
case 'scratch': return _('Scratch');
case 'dbbackup': return $this->VOLHISTORY->lastuse()->TYPE;
case 'data': return $this->VOLUME->STGPOOL_NAME;
default: return _('Unknown');
}
}
public function status() {
switch ($this->usage()) {
case 'data': return sprintf('%s/%s',$this->VOLUME->display('STATUS'),$this->VOLUME->display('ACCESS'));
case 'dbbackup': return $this->VOLHISTORY->lastuse()->backupid();
default: return '';
}
}
public function access() {
switch ($this->usage()) {
case 'data':
case 'dbbackup':
return sprintf('%s/%s',$this->display('STATUS'),$this->display('OWNER'));
default: return '';
}
}
public function lastwrite() {
switch ($this->usage()) {
case 'data':
return $this->VOLUME->display('LAST_WRITE_DATE');
case 'dbbackup':
return $this->VOLHISTORY->lastuse()->display('DATE_TIME');
default: return '';
}
}
}
?>

View File

@@ -0,0 +1,41 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package PTA
* @subpackage Volume History
* @category Models
* @author Deon George
* @copyright (c) 2010 phpTSMadmin Development Team
* @license http://phptsmadmin.sf.net/license.html
*/
class Model_VOLHISTORY extends ORMTSM {
protected $_table_name = 'VOLHISTORY';
protected $_primary_key = 'VOLUME_NAME';
protected $_sorting = array(
'DATE_TIME'=>'ASC',
);
protected $_has_one = array(
'VOLUME'=>array('foreign_key'=>'VOLUME_NAME','far_key'=>'VOLUME_NAME'),
);
protected $_has_many = array(
);
protected $_display_filters = array(
'DATE_TIME'=>array(
array('ORMTSM::date',array(':value','d-M-Y')),
),
);
public function lastuse() {
// We'll find the last record
foreach ($this->order_by('DATE_TIME DESC')->find_all() as $r)
return $r;
}
public function backupid() {
return sprintf('%s.%s.%s',$this->BACKUP_SERIES,$this->BACKUP_OPERATION,$this->VOLUME_SEQ);
}
}
?>