This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
phptsmadmin/application/classes/Model/LIBVOLUME.php

92 lines
2.3 KiB
PHP
Raw Normal View History

2011-06-24 01:27:21 +00:00
<?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 ORM_TSM {
2011-06-24 01:27:21 +00:00
protected $_table_name = 'LIBVOLUMES';
2011-06-26 12:20:12 +00:00
protected $_primary_key = 'HOME_ELEMENT';
2011-06-24 01:27:21 +00:00
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)) {
2012-11-29 22:58:15 +00:00
case NULL: return 'empty';
2011-06-24 01:27:21 +00:00
case 'scratch': return strtolower($this->STATUS);
2012-11-29 22:58:15 +00:00
2011-06-24 01:27:21 +00:00
case 'private':
2011-06-27 05:11:32 +00:00
if ($this->VOLUME->STATUS == 'EMPTY')
return 'empty';
2011-06-24 01:27:21 +00:00
switch (strtolower($this->LAST_USE)) {
case 'dbbackup':
case 'data':
return strtolower($this->LAST_USE);
2011-06-27 05:11:32 +00:00
default: return 'unkown';
2011-06-24 01:27:21 +00:00
}
2011-06-27 05:11:32 +00:00
2011-06-26 12:20:12 +00:00
default: return 'notcheckedin';
2011-06-24 01:27:21 +00:00
}
}
public function volusage() {
switch ($this->usage()) {
2011-06-26 12:20:12 +00:00
case 'data':
case 'empty': return $this->VOLUME->STGPOOL_NAME;
2011-06-24 01:27:21 +00:00
case 'dbbackup': return $this->VOLHISTORY->lastuse()->TYPE;
2011-06-26 12:20:12 +00:00
case 'notcheckedin': return _('Not Checked In');
case 'scratch': return _('Scratch');
2011-06-24 01:27:21 +00:00
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() {
2011-06-26 12:20:12 +00:00
if ($this->usage() == 'scratch')
return '';
elseif ($this->STATUS)
return sprintf('%s/%s',$this->display('STATUS'),$this->display('OWNER'));
else
return '';
2011-06-24 01:27:21 +00:00
}
public function lastwrite() {
switch ($this->usage()) {
case 'data':
2011-06-26 12:20:12 +00:00
case 'empty': return $this->VOLUME->display('LAST_WRITE_DATE');
case 'dbbackup': return $this->VOLHISTORY->lastuse()->display('DATE_TIME');
2011-06-24 01:27:21 +00:00
default: return '';
}
}
2011-06-27 04:37:11 +00:00
public function removable() {
2011-06-27 05:11:32 +00:00
return ($this->usage() == 'dbbackup' OR (! in_array($this->usage(),array('empty','scratch')) AND $this->VOLUME->STGPOOL->POOLTYPE != 'PRIMARY')) ? TRUE : FALSE;
2011-06-27 04:37:11 +00:00
}
2011-06-24 01:27:21 +00:00
}
?>