/usr/share/horde/whups/lib/Block/Query.php is in php-horde-whups 3.0.9-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | <?php
/**
* Display the results of a saved Query in a block.
*/
class Whups_Block_Query extends Whups_Block_Tickets
{
/**
* Is this block enabled?
*
* @var boolean
*/
public $enabled = true;
/**
*/
public function __construct($app, $params = array())
{
parent::__construct($app, $params);
$this->_name = _("Query Results");
}
/**
*/
protected function _params()
{
$qManager = new Whups_Query_Manager();
$qDefault = null;
$qParams = $qManager->listQueries($GLOBALS['registry']->getAuth());
if (count($qParams)) {
$qType = 'enum';
} else {
$qDefault = _("You have no saved queries.");
$qType = 'error';
}
return array_merge(array(
'query' => array(
'type' => $qType,
'name' => _("Query to run"),
'default' => $qDefault,
'values' => $qParams
)),
parent::_params()
);
}
/**
*/
protected function _title()
{
if (($query = $this->_getQuery()) && $query->name) {
return Horde::link(Whups::urlFor('query', empty($query->slug) ? array('id' => $query->id) : array('slug' => $query->slug)))
. htmlspecialchars($query->name) . '</a>';
}
return $this->getName();
}
/**
*/
protected function _content()
{
if (!($query = $this->_getQuery())) {
return '<p class="horde-content"><em>' . _("No query to run") . '</em></p>';
}
$vars = Horde_Variables::getDefaultVariables();
$tickets = $GLOBALS['whups_driver']->executeQuery($query, $vars);
if (!$tickets) {
return '<p class="horde-content"><em>' . _("No tickets from query.") . '</em></p>';
}
return $this->_table($tickets, 'whups_block_query_' . $query->id);
}
/**
*/
private function _getQuery()
{
if (empty($this->_params['query'])) {
return false;
}
$qManager = new Whups_Query_Manager();
try {
$query = $qManager->getQuery($this->_params['query']);
} catch (Whups_Exception $e) {
return false;
}
if (!$query->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
return false;
}
return $query;
}
}
|