library/Director: fix PSR2 complaints

This commit is contained in:
Thomas Gelf 2016-02-26 11:58:37 +01:00
parent 586c043290
commit 4bc5afb2f8
39 changed files with 388 additions and 155 deletions

View File

@ -16,7 +16,8 @@ class ActivityLogTable extends QuickTable
'id' => 'l.id',
'change_time' => 'l.change_time',
'author' => 'l.author',
'action' => "CONCAT(l.action_name || ' ' || REPLACE(l.object_type, 'icinga_', '') || ' \"' || l.object_name || '\"')"
'action' => "CONCAT(l.action_name || ' ' || REPLACE(l.object_type, 'icinga_', '')"
. " || ' \"' || l.object_name || '\"')"
);
}
@ -24,8 +25,8 @@ class ActivityLogTable extends QuickTable
{
return $this->url(
'director/show/activitylog',
array_merge(array('id' => $row->id), $this->extraParams
));
array_merge(array('id' => $row->id), $this->extraParams)
);
}
public function getTitles()

View File

@ -16,7 +16,8 @@ class IcingaEndpointTable extends IcingaObjectTable
'id' => 'e.id',
'endpoint' => 'e.object_name',
'object_type' => 'e.object_type',
'host' => "(CASE WHEN e.host IS NULL THEN NULL ELSE CONCAT(e.host || ':' || COALESCE(e.port, 5665)) END)",
'host' => "(CASE WHEN e.host IS NULL THEN NULL ELSE"
. " CONCAT(e.host || ':' || COALESCE(e.port, 5665)) END)",
'zone' => 'z.object_name',
);
}

View File

@ -16,7 +16,6 @@ $this->provideRestriction(
$this->translate('Allow to use only these db resources (comma separated list)')
);
$this->provideConfigTab('config', array(
'title' => 'Configuration',
'url' => 'settings'
@ -43,4 +42,3 @@ $section->add($this->translate('Config'))
->setUrl('director/list/deploymentlog')
->setPriority(902)
->setRenderer('ConfigHealthItemRenderer');

View File

@ -159,6 +159,7 @@ class RestApiClient
}
curl_setopt_array($curl, $opts);
// TODO: request headers, validate status code
Benchmark::measure('Rest Api, sending ' . $url);
$res = curl_exec($curl);
@ -236,7 +237,7 @@ class RestApiClient
$str = substr($this->readBuffer, $offset, $pos);
$decoded = json_decode($str);
if ($decoded === false) {
throw new Exception('Got invalid JSON: ' . $str);
throw new Exception('Got invalid JSON: ' . $str);
}
// printf("Processing %s bytes\n", strlen($str));

View File

@ -14,5 +14,4 @@ abstract class Stream
{
$this->stream = $stream;
}
}

View File

@ -165,7 +165,7 @@ abstract class CustomVariable implements IcingaConfigRenderer
public static function fromDbRow($row)
{
switch($row->format) {
switch ($row->format) {
case 'string':
$var = new CustomVariableString($row->varname, $row->varvalue);
break;
@ -194,7 +194,10 @@ abstract class CustomVariable implements IcingaConfigRenderer
return $this->toConfigString();
} catch (Exception $e) {
trigger_error($e);
$previousHandler = set_exception_handler(function () {});
$previousHandler = set_exception_handler(
function () {
}
);
restore_error_handler();
call_user_func($previousHandler, $e);
die();

View File

@ -38,7 +38,7 @@ class CustomVariableBoolean extends CustomVariable
$this->value = $value;
return $this;
}
}
public function toConfigString()
{

View File

@ -37,7 +37,7 @@ class CustomVariableNull extends CustomVariable
}
return $this;
}
}
public function toConfigString()
{

View File

@ -51,7 +51,7 @@ class CustomVariableNumber extends CustomVariable
$this->value = $value;
return $this;
}
}
public function toConfigString()
{

View File

@ -32,7 +32,7 @@ class CustomVariableString extends CustomVariable
}
return $this;
}
}
public function toConfigString()
{

View File

@ -269,7 +269,10 @@ class CustomVariables implements Iterator, Countable, IcingaConfigRenderer
return $this->toConfigString();
} catch (Exception $e) {
trigger_error($e);
$previousHandler = set_exception_handler(function () {});
$previousHandler = set_exception_handler(
function () {
}
);
restore_error_handler();
call_user_func($previousHandler, $e);
die();

View File

@ -130,7 +130,9 @@ abstract class DbObject
*
* @return void
*/
protected function beforeInit() {}
protected function beforeInit()
{
}
/**
* Wird ausgeführt, nachdem mittels ::factory() ein neues Objekt erstellt
@ -138,7 +140,9 @@ abstract class DbObject
*
* @return void
*/
protected function onFactory() {}
protected function onFactory()
{
}
/**
* Wird ausgeführt, nachdem mittels ::factory() ein neues Objekt erstellt
@ -146,7 +150,9 @@ abstract class DbObject
*
* @return void
*/
protected function onLoadFromDb() {}
protected function onLoadFromDb()
{
}
/**
* Wird ausgeführt, bevor ein Objekt abgespeichert wird. Die Operation
@ -154,14 +160,18 @@ abstract class DbObject
*
* @return void
*/
protected function beforeStore() {}
protected function beforeStore()
{
}
/**
* Wird ausgeführt, nachdem ein Objekt erfolgreich gespeichert worden ist
*
* @return void
*/
protected function onStore() {}
protected function onStore()
{
}
/**
* Wird ausgeführt, nachdem ein Objekt erfolgreich der Datenbank hinzu-
@ -169,7 +179,9 @@ abstract class DbObject
*
* @return void
*/
protected function onInsert() {}
protected function onInsert()
{
}
/**
* Wird ausgeführt, nachdem bestehendes Objekt erfolgreich der Datenbank
@ -177,7 +189,9 @@ abstract class DbObject
*
* @return void
*/
protected function onUpdate() {}
protected function onUpdate()
{
}
/**
* Wird ausgeführt, bevor ein Objekt gelöscht wird. Die Operation wird
@ -185,7 +199,9 @@ abstract class DbObject
*
* @return void
*/
protected function beforeDelete() {}
protected function beforeDelete()
{
}
/**
* Wird ausgeführt, nachdem bestehendes Objekt erfolgreich aud der
@ -193,7 +209,9 @@ abstract class DbObject
*
* @return void
*/
protected function onDelete() {}
protected function onDelete()
{
}
/**
* Set database connection
@ -394,7 +412,10 @@ abstract class DbObject
{
$props = array();
foreach (array_keys($this->modifiedProperties) as $key) {
if ($key === $this->autoincKeyName) continue;
if ($key === $this->autoincKeyName) {
continue;
}
$props[$key] = $this->properties[$key];
}
return $props;
@ -475,9 +496,8 @@ abstract class DbObject
$id[$key] = $this->properties[$key];
}
return $id;
} else {
if (isset($this->properties[$this->keyName]))
{
} else {
if (isset($this->properties[$this->keyName])) {
return $this->properties[$this->keyName];
}
}
@ -491,8 +511,7 @@ abstract class DbObject
*/
public function getAutoincId()
{
if (isset($this->properties[$this->autoincKeyName]))
{
if (isset($this->properties[$this->autoincKeyName])) {
return $this->properties[$this->autoincKeyName];
}
return null;

View File

@ -162,7 +162,7 @@ class Db extends DbConnection
array(
'prev' => 'lt.id',
'next' => 'gt.id'
)
)
)->join(
array('lt' => $smaller),
null,
@ -227,9 +227,13 @@ class Db extends DbConnection
public function getLastActivityChecksum()
{
if ($this->getDbType() === 'pgsql') {
$select = "SELECT checksum FROM (SELECT * FROM (SELECT 1 AS pos, LOWER(ENCODE(checksum, 'hex')) AS checksum FROM director_activity_log ORDER BY change_time DESC LIMIT 1) a UNION SELECT 2 AS pos, '' AS checksum) u ORDER BY pos LIMIT 1";
$select = "SELECT checksum FROM (SELECT * FROM (SELECT 1 AS pos, LOWER(ENCODE(checksum, 'hex')) AS checksum"
. " FROM director_activity_log ORDER BY change_time DESC LIMIT 1) a"
. " UNION SELECT 2 AS pos, '' AS checksum) u ORDER BY pos LIMIT 1";
} else {
$select = "SELECT checksum FROM (SELECT * FROM (SELECT 1 AS pos, LOWER(HEX(checksum)) AS checksum FROM director_activity_log ORDER BY change_time DESC LIMIT 1) a UNION SELECT 2 AS pos, '' AS checksum) u ORDER BY pos LIMIT 1";
$select = "SELECT checksum FROM (SELECT * FROM (SELECT 1 AS pos, LOWER(HEX(checksum)) AS checksum"
. " FROM director_activity_log ORDER BY change_time DESC LIMIT 1) a"
. " UNION SELECT 2 AS pos, '' AS checksum) u ORDER BY pos LIMIT 1";
}
return $this->db()->fetchOne($select);

View File

@ -41,12 +41,12 @@ class Migrations
}
public function hasPendingMigrations()
{
{
return $this->countPendingMigrations() > 0;
}
public function countPendingMigrations()
{
{
return count($this->listPendingMigrations());
}
@ -92,7 +92,10 @@ class Migrations
$versions = array();
foreach (new DirectoryIterator($this->getMigrationsDir()) as $file) {
if($file->isDot()) continue;
if ($file->isDot()) {
continue;
}
$filename = $file->getFilename();
if (preg_match('/^upgrade_(\d+)\.sql$/', $filename, $match)) {
$versions[] = $match[1];

View File

@ -64,7 +64,8 @@ abstract class ImportSourceHook
return $this;
}
public function getSetting($name, $default = null) {
public function getSetting($name, $default = null)
{
if (array_key_exists($name, $this->settings)) {
return $this->settings[$name];
} else {

View File

@ -276,8 +276,7 @@ class IcingaConfig
$this->db->commit();
} catch (Exception $e) {
$this->db->rollBack();
throw $e;
var_dump($e->getMessage());
throw $e;
}
return $this;
@ -373,10 +372,18 @@ throw $e;
$zones = array();
$endpoints = array();
foreach (IcingaHost::prefetchAll($this->connection) as $host) {
if ($host->object_type !== 'object') continue;
if ($host->getResolvedProperty('has_agent') !== 'y') continue;
if ($host->object_type !== 'object') {
continue;
}
if ($host->getResolvedProperty('has_agent') !== 'y') {
continue;
}
$name = $host->object_name;
if (IcingaEndpoint::exists($name, $this->connection)) continue;
if (IcingaEndpoint::exists($name, $this->connection)) {
continue;
}
$props = array(
'object_name' => $name,
@ -411,18 +418,24 @@ throw $e;
protected function createFileForObjects($type, $objects)
{
Benchmark::measure(sprintf('Generating %d %s', count($objects), $type));
if (empty($objects)) return $this;
if (empty($objects)) {
return $this;
}
$masterZone = $this->connection->getMasterZoneName();
$globalZone = $this->connection->getDefaultGlobalZoneName();
$file = null;
foreach ($objects as $object) {
if ($object->disabled === 'y') continue;
if ($object->disabled === 'y') {
continue;
}
if ($object->isExternal()) {
if ($type === 'zone') {
$this->zoneMap[$object->id] = $object->object_name;
}
continue;
} elseif ($object->isTemplate()) {
$filename = strtolower($type) . '_templates';
@ -557,6 +570,7 @@ throw $e;
}
// TODO: wipe unused files
// DELETE f FROM director_generated_file f left join director_generated_config_file cf ON f.checksum = cf.file_checksum WHERE cf.file_checksum IS NULL;
// DELETE f FROM director_generated_file f
// LEFT JOIN director_generated_config_file cf ON f.checksum = cf.file_checksum
// WHERE cf.file_checksum IS NULL;
}

View File

@ -455,7 +455,9 @@ class Sync
) as $object) {
if ($object instanceof IcingaService) {
if (! $object->host_id) continue;
if (! $object->host_id) {
continue;
}
}
$key = $this->fillVariables(
@ -502,7 +504,9 @@ class Sync
$imports = array();
foreach ($this->syncProperties as $p) {
if ($p->source_id !== $sourceId) continue;
if ($p->source_id !== $sourceId) {
continue;
}
$prop = $p->destination_field;
$val = $this->fillVariables($p->source_expression, $row);

View File

@ -16,11 +16,11 @@ class KickstartHelper
protected $apiUser;
protected $config = array(
'endpoint' => null,
'host' => null,
'port' => null,
'username' => null,
'password' => null,
'endpoint' => null,
'host' => null,
'port' => null,
'username' => null,
'password' => null,
);
public function __construct(Db $db)

View File

@ -261,7 +261,10 @@ class IcingaArguments implements Iterator, Countable, IcingaConfigRenderer
return $this->toConfigString();
} catch (Exception $e) {
trigger_error($e);
$previousHandler = set_exception_handler(function () {});
$previousHandler = set_exception_handler(
function () {
}
);
restore_error_handler();
if ($previousHandler !== null) {
call_user_func($previousHandler, $e);

View File

@ -31,9 +31,19 @@ class IcingaCommand extends IcingaObject
protected static $pluginDir;
/**
* Render the 'medhods_execute' property as 'execute'
*
* Execute is a reserved word in SQL, column name was prefixed
*
* Avoid complaints for method names with underscore:
* @codingStandardsIgnoreStart
*
* @return string
*/
protected function renderMethods_execute()
{
// Execute is a reserved word in SQL, column name was prefixed
// @codingStandardsIgnoreEnd
return c::renderKeyValue('execute', $this->methods_execute);
}

View File

@ -58,13 +58,31 @@ class IcingaEndpoint extends IcingaObject
return new CoreApi($client);
}
/**
* Use duration time renderer helper
*
* Avoid complaints for method names with underscore:
* @codingStandardsIgnoreStart
*
* @return string
*/
protected function renderLog_duration()
{
// @codingStandardsIgnoreEnd
return $this->renderPropertyAsSeconds('log_duration');
}
/**
* Internal property, will not be rendered
*
* Avoid complaints for method names with underscore:
* @codingStandardsIgnoreStart
*
* @return string
*/
protected function renderApiuser_id()
{
// @codingStandardsIgnoreEnd
return '';
}
}

View File

@ -112,18 +112,37 @@ class IcingaHost extends IcingaObject
return $this->getResolvedProperty('check_command_id') !== null;
}
/**
* Internal property, will not be rendered
*
* Avoid complaints for method names with underscore:
* @codingStandardsIgnoreStart
*
* @return string
*/
protected function renderHas_Agent()
{
return '';
}
/**
* Internal property, will not be rendered
*
* @return string
*/
protected function renderMaster_should_connect()
{
return '';
}
/**
* Internal property, will not be rendered
*
* @return string
*/
protected function renderAccept_config()
{
// @codingStandardsIgnoreEnd
return '';
}
}

View File

@ -483,7 +483,9 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
$origins = $object->$getOrigins();
foreach ($object->$getInherited() as $key => $value) {
if (in_array($key, $blacklist)) continue;
if (in_array($key, $blacklist)) {
continue;
}
// $vals[$name]->$key = $value;
$vals['_MERGED_']->$key = $value;
$vals['_INHERITED_']->$key = $value;
@ -500,7 +502,9 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
}
foreach ($this->$get() as $key => $value) {
if ($value === null) continue;
if ($value === null) {
continue;
}
// $vals[$this->object_name]->$key = $value;
$vals['_MERGED_']->$key = $value;
@ -807,8 +811,12 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
foreach ($this->properties as $key => $value) {
if ($value === null) continue;
if (in_array($key, $blacklist)) continue;
if ($value === null) {
continue;
}
if (in_array($key, $blacklist)) {
continue;
}
$method = 'render' . ucfirst($key);
if (method_exists($this, $method)) {
@ -821,8 +829,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
c::renderBoolean($value)
);
}
} elseif (
substr($key, -3) === '_id'
} elseif (substr($key, -3) === '_id'
&& $this->hasRelation($relKey = substr($key, 0, -3))
) {
$out .= $this->renderRelationProperty($relKey, $value);
@ -949,9 +956,17 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
);
}
/**
* We do not render zone properties, objects are stored to zone dirs
*
* Avoid complaints for method names with underscore:
* @codingStandardsIgnoreStart
*
* @return string
*/
protected function renderZone_id()
{
// We do not render zone properties, objects are stored to zone dirs
// @codingStandardsIgnoreEnd
return '';
}
@ -1194,11 +1209,17 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
}
if ($skipDefaults) {
if (empty($props['imports'])) unset($props['imports']);
if (array_key_exists('vars', $props)) {
if (count((array) $props['vars']) === 0) unset($props['vars']);
if (empty($props['imports'])) {
unset($props['imports']);
}
if (array_key_exists('vars', $props)) {
if (count((array) $props['vars']) === 0) {
unset($props['vars']);
}
}
if (empty($props['groups'])) {
unset($props['groups']);
}
if (empty($props['groups'])) unset($props['groups']);
}
ksort($props);
@ -1278,7 +1299,10 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
return $this->toConfigString();
} catch (Exception $e) {
trigger_error($e);
$previousHandler = set_exception_handler(function () {});
$previousHandler = set_exception_handler(
function () {
}
);
restore_error_handler();
if ($previousHandler !== null) {
call_user_func($previousHandler, $e);

View File

@ -317,7 +317,10 @@ class IcingaObjectGroups implements Iterator, Countable, IcingaConfigRenderer
return $this->toConfigString();
} catch (Exception $e) {
trigger_error($e);
$previousHandler = set_exception_handler(function () {});
$previousHandler = set_exception_handler(
function () {
}
);
restore_error_handler();
if ($previousHandler !== null) {
call_user_func($previousHandler, $e);

View File

@ -300,7 +300,10 @@ class IcingaObjectImports implements Iterator, Countable, IcingaConfigRenderer
return $this->toConfigString();
} catch (Exception $e) {
trigger_error($e);
$previousHandler = set_exception_handler(function () {});
$previousHandler = set_exception_handler(
function () {
}
);
restore_error_handler();
if ($previousHandler !== null) {
call_user_func($previousHandler, $e);

View File

@ -78,32 +78,70 @@ class IcingaService extends IcingaObject
);
}
/**
* Render host_id as host_name
*
* Avoid complaints for method names with underscore:
* @codingStandardsIgnoreStart
*
* @return string
*/
public function renderHost_id()
{
// @codingStandardsIgnoreEnd
return $this->renderRelationProperty('host', $this->host_id, 'host_name');
}
protected function renderCustomExtensions()
{
if ($this->command_endpoint_id !== null) return '';
if ($this->object_type !== 'object') return '';
if ($this->getResolvedProperty('use_agent') !== 'y') return '';
if ($this->command_endpoint_id !== null
|| $this->object_type !== 'object'
|| $this->getResolvedProperty('use_agent') !== 'y') {
return '';
}
return $this->renderRelationProperty('host', $this->host_id, 'command_endpoint');
}
/**
* Do not render internal property
*
* Avoid complaints for method names with underscore:
* @codingStandardsIgnoreStart
*
* @return string
*/
public function renderUse_agent()
{
// @codingStandardsIgnoreEnd
return '';
}
/**
* Use duration time renderer helper
*
* Avoid complaints for method names with underscore:
* @codingStandardsIgnoreStart
*
* @return string
*/
protected function renderCheck_Interval()
{
// @codingStandardsIgnoreEnd
return $this->renderPropertyAsSeconds('check_interval');
}
/**
* Use duration time renderer helper
*
* Avoid complaints for method names with underscore:
* @codingStandardsIgnoreStart
*
* @return string
*/
protected function renderRetry_Interval()
{
// @codingStandardsIgnoreEnd
return $this->renderPropertyAsSeconds('retry_interval');
}

View File

@ -237,7 +237,10 @@ class IcingaTimePeriodRanges implements Iterator, Countable, IcingaConfigRendere
return $this->toConfigString();
} catch (Exception $e) {
trigger_error($e);
$previousHandler = set_exception_handler(function () {});
$previousHandler = set_exception_handler(
function () {
}
);
restore_error_handler();
if ($previousHandler !== null) {
call_user_func($previousHandler, $e);

View File

@ -25,8 +25,7 @@ class IcingaUser extends IcingaObject
protected $supportsImports = true;
protected function renderEnable_notifications()
{
return $this->renderBooleanProperty('enable_notifications');
}
protected $booleans = array(
'enable_notifications'x => 'enable_notifications'
);
}

View File

@ -34,5 +34,4 @@ class ImportSource extends DbObjectWithSettings
->order('priority DESC')
);
}
}

View File

@ -13,20 +13,31 @@ class SyncProperty extends DbObject
protected $autoincKeyName = 'id';
protected $defaultProperties = array(
'id' => null,
'rule_id' => null,
'source_id' => null,
'id' => null,
'rule_id' => null,
'source_id' => null,
'source_expression' => null,
'destination_field' => null,
'priority' => null,
'filter_expression' => null,
'merge_policy' => null
'destination_field' => null,
'priority' => null,
'filter_expression' => null,
'merge_policy' => null
);
/**
* Virtual property for source_column
*
* Internally we always use an expression. Form indirectly uses this
*
* Avoid complaints for method names with underscore:
* @codingStandardsIgnoreStart
*
* @return self
*/
public function setSource_column($value)
{
// @codingStandardsIgnoreEnd
$this->source_expression = '${' . $value . '}';
return $this;
return $this;
}
public function sourceIsSingleColumn()

View File

@ -14,12 +14,12 @@ class SyncRule extends DbObject
protected $autoincKeyName = 'id';
protected $defaultProperties = array(
'id' => null,
'rule_name' => null,
'object_type' => null,
'id' => null,
'rule_name' => null,
'object_type' => null,
'update_policy' => null,
'purge_existing' => null,
'filter_expression' => null,
'purge_existing' => null,
'filter_expression' => null,
);
private $filter;

View File

@ -44,7 +44,9 @@ class PlainObjectRenderer
protected static function renderArray($array, $prefix = '')
{
if (empty($array)) return '[]';
if (empty($array)) {
return '[]';
}
$vals = array();
@ -60,7 +62,10 @@ class PlainObjectRenderer
{
$vals = array();
$hash = (array) $hash;
if (empty($hash)) return '{}';
if (empty($hash)) {
return '{}';
}
ksort($hash);
foreach ($hash as $key => $val) {
$vals[] = $prefix

View File

@ -63,7 +63,7 @@ class Util
$out = '';
for($i = 1; $i <= $blocks; $i++) {
for ($i = 1; $i <= $blocks; $i++) {
// $i encoded as 4 bytes, big endian.
$last = $salt . pack('N', $i);
// first iteration

View File

@ -69,7 +69,7 @@ abstract class ActionController extends Controller
protected function sendJson($object)
{
$this->getResponse()->setHeader('Content-Type', 'application/json', true);
$this->_helper->layout()->disableLayout();
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
echo json_encode($object, JSON_PRETTY_PRINT) . "\n";
@ -89,36 +89,60 @@ abstract class ActionController extends Controller
protected function setConfigTabs()
{
$this->view->tabs = Widget::create('tabs')->add('deploymentlog', array(
'label' => $this->translate('Deployments'),
'url' => 'director/list/deploymentlog')
)->add('generatedconfig', array(
'label' => $this->translate('Configs'),
'url' => 'director/list/generatedconfig')
)->add('activitylog', array(
'label' => $this->translate('Activity Log'),
'url' => 'director/list/activitylog')
)->add('datalist', array(
'label' => $this->translate('Data lists'),
'url' => 'director/list/datalist')
)->add('datafield', array(
'label' => $this->translate('Data fields'),
'url' => 'director/list/datafield')
$this->view->tabs = Widget::create('tabs')->add(
'deploymentlog',
array(
'label' => $this->translate('Deployments'),
'url' => 'director/list/deploymentlog'
)
)->add(
'generatedconfig',
array(
'label' => $this->translate('Configs'),
'url' => 'director/list/generatedconfig'
)
)->add(
'activitylog',
array(
'label' => $this->translate('Activity Log'),
'url' => 'director/list/activitylog'
)
)->add(
'datalist',
array(
'label' => $this->translate('Data lists'),
'url' => 'director/list/datalist'
)
)->add(
'datafield',
array(
'label' => $this->translate('Data fields'),
'url' => 'director/list/datafield'
)
);
return $this->view->tabs;
}
protected function setImportTabs()
{
$this->view->tabs = Widget::create('tabs')->add('importsource', array(
'label' => $this->translate('Import source'),
'url' => 'director/list/importsource')
)->add('importrun', array(
'label' => $this->translate('Import history'),
'url' => 'director/list/importrun')
)->add('syncrule', array(
'label' => $this->translate('Sync rule'),
'url' => 'director/list/syncrule')
$this->view->tabs = Widget::create('tabs')->add(
'importsource',
array(
'label' => $this->translate('Import source'),
'url' => 'director/list/importsource'
)
)->add(
'importrun',
array(
'label' => $this->translate('Import history'),
'url' => 'director/list/importrun'
)
)->add(
'syncrule',
array(
'label' => $this->translate('Sync rule'),
'url' => 'director/list/syncrule'
)
);
return $this->view->tabs;
}

View File

@ -103,12 +103,13 @@ abstract class ObjectController extends ActionController
$this->view->title = sprintf($this->translate('Modify %s'), ucfirst($ltype));
$this->view->form->handleRequest();
$this->view->actionLinks = $this->view->icon('paste') . ' '
. $this->view->qlink(
sprintf($this->translate('Clone'), $this->translate(ucfirst($ltype))),
'director/' . $ltype .'/clone',
array('name' => $object->object_name)
);
$this->view->actionLinks = $this->view->icon('paste')
. ' '
. $this->view->qlink(
sprintf($this->translate('Clone'), $this->translate(ucfirst($ltype))),
'director/' . $ltype .'/clone',
array('name' => $object->object_name)
);
$this->render('object/form', null, true);
}
@ -149,12 +150,13 @@ abstract class ObjectController extends ActionController
);
$this->view->form->handleRequest();
$this->view->actionLinks = $this->view->icon('left-big') . ' '
$this->view->actionLinks = $this->view->icon('left-big')
. ' '
. $this->view->qlink(
sprintf($this->translate('back'), $this->translate(ucfirst($ltype))),
'director/' . $ltype,
array('name' => $this->object->object_name)
);
sprintf($this->translate('back'), $this->translate(ucfirst($ltype))),
'director/' . $ltype,
array('name' => $this->object->object_name)
);
$this->render('object/form', null, true);
}

View File

@ -94,12 +94,13 @@ abstract class ObjectsController extends ActionController
$addTitle = $this->translate('Add %s');
}
$this->view->addLink = $this->view->icon('plus') . ' '
. $this->view->qlink(
sprintf($addTitle, $this->translate(ucfirst($ltype))),
'director/' . $ltype .'/add',
$addParams
);
$this->view->addLink = $this->view->icon('plus')
. ' '
. $this->view->qlink(
sprintf($addTitle, $this->translate(ucfirst($ltype))),
'director/' . $ltype .'/add',
$addParams
);
$this->view->title = $this->translate('Icinga ' . ucfirst($ltype));
$table = $this->loadTable($table)->setConnection($this->db());
@ -151,7 +152,7 @@ abstract class ObjectsController extends ActionController
array('Group', 'Period', 'Argument', 'ApiUser'),
str_replace(
'template',
'',
'',
substr($this->getRequest()->getControllerName(), 0, -1)
)
);

View File

@ -347,13 +347,15 @@ abstract class DirectorObjectForm extends QuickForm
}
// TODO: handle structured vars
if (! is_string($value)) continue;
if (! is_string($value)) {
continue;
}
// Show inheritance information in case we inherited this var:
if (isset($inherited->$key)) {
$this->addCustomVar($key, $value, $inherited->$key, $origins->$key);
$this->addCustomVar($key, $value, $inherited->$key, $origins->$key);
} else {
$this->addCustomVar($key, $value);
$this->addCustomVar($key, $value);
}
}
@ -674,7 +676,10 @@ abstract class DirectorObjectForm extends QuickForm
$label = $this->translate('Delete');
}
$el = $this->createElement('submit', $label)->setLabel($label)->setDecorators(array('ViewHelper')); //->removeDecorator('Label');
$el = $this->createElement('submit', $label)
->setLabel($label)
->setDecorators(array('ViewHelper'));
//->removeDecorator('Label');
$this->deleteButtonName = $el->getName();
$this->addElement($el);
@ -689,7 +694,9 @@ abstract class DirectorObjectForm extends QuickForm
public function shouldBeDeleted()
{
if (! $this->hasDeleteButton()) return false;
if (! $this->hasDeleteButton()) {
return false;
}
$name = $this->deleteButtonName;
return $this->getSentValue($name) === $this->getElement($name)->getLabel();
@ -878,24 +885,34 @@ abstract class DirectorObjectForm extends QuickForm
protected function addCheckExecutionElements()
{
$this->addElement('text', 'check_interval', array(
'label' => $this->translate('Check interval'),
'description' => $this->translate('Your regular check interval')
));
$this->addElement(
'text',
'check_interval',
array(
'label' => $this->translate('Check interval'),
'description' => $this->translate('Your regular check interval')
)
);
$this->addElement('text', 'retry_interval', array(
'label' => $this->translate('Retry interval'),
'description' => $this->translate('Retry interval, will be applied after a state change unless the next hard state is reached')
));
$this->addElement(
'text',
'retry_interval',
array(
'label' => $this->translate('Retry interval'),
'description' => $this->translate(
'Retry interval, will be applied after a state change unless the next hard state is reached'
)
)
);
$this->optionalBoolean(
'enable_active_checks',
'enable_active_checks',
$this->translate('Execute active checks'),
$this->translate('Whether to actively check this object')
);
$this->optionalBoolean(
'enable_passive_checks',
'enable_passive_checks',
$this->translate('Accept passive checks'),
$this->translate('Whether to accept passive check results for this object')
);

View File

@ -98,7 +98,7 @@ abstract class QuickTable implements Paginatable
$value = '<pre>' . $this->view()->escape(print_r($val, 1)) . '</pre>';
} else {
$value = $this->view()->escape($val);
}
}
}
$htm .= ' <td>' . $value . "</td>\n";
@ -352,7 +352,11 @@ abstract class QuickTable implements Paginatable
}
}
} else {
$str .= $this->whereToSql($this->mapFilterColumn($filter->getColumn()), $filter->getSign(), $filter->getExpression());
$str .= $this->whereToSql(
$this->mapFilterColumn($filter->getColumn()),
$filter->getSign(),
$filter->getExpression()
);
}
return $str;

View File

@ -21,4 +21,3 @@ $this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\Pro
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierStripDomain');
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierSubstring');
$this->provideHook('director/PropertyModifier', $prefix . 'PropertyModifier\\PropertyModifierUppercase');