Application->getModule('configuration'); $appCfg = $cfg->getApplicationConfig(); if($cfg->isPostgreSQLType($appCfg['db']['type'])) { $orderPool = strtolower($orderPool); $orderVolume = strtolower($orderVolume); } $criteria->OrdersBy[$orderPool] = 'asc'; $criteria->OrdersBy[$orderVolume] = 'asc'; if(is_int($limit) && $limit > 0) { $criteria->Limit = $limit; } $volumes = VolumeRecord::finder()->findAll($criteria); if($withPools) { $this->setExtraVariables($volumes); } return $volumes; } public function getVolumesByPoolId($poolid) { return VolumeRecord::finder()->findBypoolid($poolid); } public function getVolumeByName($volumeName) { return VolumeRecord::finder()->findByvolumename($volumeName); } public function getVolumeById($volumeId) { return VolumeRecord::finder()->findBymediaid($volumeId); } public function setVolume($mediaid, $volumeOptions) { $volume = $this->getVolumeById($mediaid); if(property_exists($volumeOptions, 'volstatus')) { $volume->volstatus = $volumeOptions->volstatus; } if(property_exists($volumeOptions, 'poolid')) { $volume->poolid = $volumeOptions->poolid; } if(property_exists($volumeOptions, 'volretention')) { $volume->volretention = $volumeOptions->volretention; } if(property_exists($volumeOptions, 'voluseduration')) { $volume->voluseduration = $volumeOptions->voluseduration; } if(property_exists($volumeOptions, 'maxvoljobs')) { $volume->maxvoljobs = $volumeOptions->maxvoljobs; } if(property_exists($volumeOptions, 'maxvolfiles')) { $volume->maxvolfiles = $volumeOptions->maxvolfiles; } if(property_exists($volumeOptions, 'maxvolbytes')) { $volume->maxvolbytes = $volumeOptions->maxvolbytes; } if(property_exists($volumeOptions, 'slot')) { $volume->slot = $volumeOptions->slot; } if(property_exists($volumeOptions, 'recycle')) { $volume->recycle = $volumeOptions->recycle; } if(property_exists($volumeOptions, 'enabled')) { $volume->enabled = $volumeOptions->enabled; } if(property_exists($volumeOptions, 'inchanger')) { $volume->inchanger = $volumeOptions->inchanger; } return $volume->save(); } private function setExtraVariables(&$volumes) { $pools = $this->Application->getModule('pool')->getPools(false); foreach($volumes as $volume) { $volstatus = strtolower($volume->volstatus); $volume->whenexpire = ($volstatus == 'full' || $volstatus == 'used') ? date( 'Y-m-d H:i:s', (strtotime($volume->lastwritten) + $volume->volretention)) : 'no date'; foreach($pools as $pool) { if($volume->poolid == $pool->poolid) { $volume->pool = $pool; } } } } } ?>