Permalink
Browse files

fix ACL, view problem Volumes

  • Loading branch information...
1 parent c979ec3 commit 2b5dff817b7ccad73a7d594d6de63c549c233ad5 @tim4dev committed Sep 1, 2011
@@ -1,8 +1,6 @@
<?php
/**
- * Copyright 2007, 2008, 2009 Yuri Timofeev tim4dev@gmail.com
- *
- * This file is part of Webacula.
+ * Copyright 2007, 2008, 2009, 2011 Yuri Timofeev tim4dev@gmail.com
*
* Webacula is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -80,15 +78,16 @@ function feedAction ()
}
// Get info Volumes with Status of media: Disabled, Error
$media = new Media();
- $ret = $media->GetProblemVolumes();
- $result = $ret->fetchAll();
- foreach ($result as $item) {
- $content = '<pre><b>' . $this->view->translate->_("Volume Name") . ' : </b>' . $item['volumename'] . '<br>' . '<b>' . $this->view->translate->_("Volume Status") . ' : </b>' . $item['volstatus'] . '<br>' . '</pre>';
- $afeed['entries'][] = array(
- 'title' => $this->view->translate->_("Volumes with errors") ,
- 'link' => $this->view->baseUrl . '/volume/problem/' , 'description' => $content ,
- 'lastUpdate' => time()
- );
+ $result = $media->getProblemVolumes();
+ if ($result) {
+ foreach ($result as $item) {
+ $content = '<pre><b>' . $this->view->translate->_("Volume Name") . ' : </b>' . $item['volumename'] . '<br>' . '<b>' . $this->view->translate->_("Volume Status") . ' : </b>' . $item['volstatus'] . '<br>' . '</pre>';
+ $afeed['entries'][] = array(
+ 'title' => $this->view->translate->_("Volumes with errors") ,
+ 'link' => $this->view->baseUrl . '/volume/problem/' , 'description' => $content ,
+ 'lastUpdate' => time()
+ );
+ }
}
// import array to feed
$feed = Zend_Feed::importArray($afeed, 'rss');
@@ -76,8 +76,7 @@ function problemAction ()
$order = addslashes(trim($this->_request->getParam('order', 'VolumeName')));
// get data from model
$media = new Media();
- $ret = $media->GetProblemVolumes();
- $this->view->resultProblemVolumes = $ret->fetchAll(null, $order);
+ $this->view->resultProblemVolumes = $media->getProblemVolumes($order);
// fix http://sourceforge.net/apps/trac/webacula/ticket/81
//$this->view->resultVolumesNeedReplacement = $media->getVolumesNeedReplacement();
$this->view->meta_refresh = 300; // meta http-equiv="refresh"
@@ -94,8 +93,7 @@ function problemDashboardAction ()
$order = addslashes(trim($this->_request->getParam('order', 'VolumeName')));
// get data from model
$media = new Media();
- $ret = $media->GetProblemVolumes();
- $this->view->resultProblemVolumes = $ret->fetchAll(null, $order);
+ $this->view->resultProblemVolumes = $media->getProblemVolumes($order);
if ( empty($this->view->resultProblemVolumes) ) {
$this->_helper->viewRenderer->setNoRender();
} else {
@@ -1,8 +1,6 @@
<?php
/**
- * Copyright 2007, 2008, 2009 Yuri Timofeev tim4dev@gmail.com
- *
- * This file is part of Webacula.
+ * Copyright 2007, 2008, 2009, 2011 Yuri Timofeev tim4dev@gmail.com
*
* Webacula is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -27,11 +25,13 @@ class Media extends Zend_Db_Table
{
public $db;
public $db_adapter;
+ protected $bacula_acl; // bacula acl
public function __construct($config = array())
{
$this->db = Zend_Registry::get('db_bacula');
$this->db_adapter = Zend_Registry::get('DB_ADAPTER');
+ $this->bacula_acl = new MyClass_BaculaAcl();
parent::__construct($config);
}
@@ -57,21 +57,23 @@ protected function _setupPrimaryKey()
* Get info Volumes with Status of media: Disabled, Error
*
*/
- function GetProblemVolumes()
+ function getProblemVolumes($order=null)
{
$db = Zend_Registry::get('db_bacula');
// make select from multiple tables
$select = new Zend_Db_Select($db);
$select->distinct();
- $select->from('Media',
+ $select->from(array('m' => 'Media'),
array("MediaId", 'PoolId', 'StorageId',
'VolumeName', 'VolStatus', 'VolBytes', 'MaxVolBytes', 'VolJobs', 'VolRetention', 'Recycle', 'Slot',
'InChanger', 'MediaType', 'FirstWritten', 'LastWritten'
));
+ $select->joinLeft(array('p' => 'Pool'), 'm.PoolId = p.PoolId', array('PoolName' => 'p.Name'));
$select->where("VolStatus IN ('Error', 'Disabled')");
//$sql = $select->__toString(); echo "<pre>$sql</pre>"; exit; // for !!!debug!!!
- $result = $select->query();
- return $result;
+ $result = $select->query()->fetchAll(null, $order);
+ // do Bacula ACLs
+ return $this->bacula_acl->doBaculaAcl($result, 'poolname', 'pool');
}

0 comments on commit 2b5dff8

Please sign in to comment.