diff options
Diffstat (limited to 'application/controllers')
-rw-r--r-- | application/controllers/BasketController.php | 125 | ||||
-rw-r--r-- | application/controllers/ConfigController.php | 49 | ||||
-rw-r--r-- | application/controllers/DataController.php | 4 | ||||
-rw-r--r-- | application/controllers/HostController.php | 129 | ||||
-rw-r--r-- | application/controllers/ImportsourceController.php | 4 | ||||
-rw-r--r-- | application/controllers/ImportsourcesController.php | 2 | ||||
-rw-r--r-- | application/controllers/JobsController.php | 2 | ||||
-rw-r--r-- | application/controllers/SchemaController.php | 2 | ||||
-rw-r--r-- | application/controllers/SelfServiceController.php | 6 | ||||
-rw-r--r-- | application/controllers/ServiceController.php | 20 | ||||
-rw-r--r-- | application/controllers/SyncruleController.php | 25 | ||||
-rw-r--r-- | application/controllers/SyncrulesController.php | 2 |
12 files changed, 196 insertions, 174 deletions
diff --git a/application/controllers/BasketController.php b/application/controllers/BasketController.php index 8733d16..8d4db03 100644 --- a/application/controllers/BasketController.php +++ b/application/controllers/BasketController.php @@ -9,13 +9,10 @@ use gipfl\IcingaWeb2\Link; use gipfl\Web\Table\NameValueTable; use gipfl\Web\Widget\Hint; use Icinga\Date\DateFormatter; -use Icinga\Module\Director\Core\Json; -use Icinga\Module\Director\Data\Exporter; use Icinga\Module\Director\Db; use Icinga\Module\Director\DirectorObject\Automation\Basket; +use Icinga\Module\Director\DirectorObject\Automation\BasketDiff; use Icinga\Module\Director\DirectorObject\Automation\BasketSnapshot; -use Icinga\Module\Director\DirectorObject\Automation\BasketSnapshotFieldResolver; -use Icinga\Module\Director\DirectorObject\Automation\CompareBasketObject; use Icinga\Module\Director\Forms\AddToBasketForm; use Icinga\Module\Director\Forms\BasketCreateSnapshotForm; use Icinga\Module\Director\Forms\BasketForm; @@ -24,6 +21,7 @@ use Icinga\Module\Director\Forms\RestoreBasketForm; use Icinga\Module\Director\Web\Controller\ActionController; use ipl\Html\Html; use Icinga\Module\Director\Web\Table\BasketSnapshotTable; +use Ramsey\Uuid\Uuid; class BasketController extends ActionController { @@ -127,6 +125,26 @@ class BasketController extends ActionController $this->content()->add($form); } + public function uploadSnapshotAction() + { + $basket = Basket::load($this->params->get('name'), $this->db()); + $this->actions()->add( + Link::create( + $this->translate('back'), + 'director/basket/snapshots', + ['name' => $basket->get('basket_name')], + ['class' => 'icon-left-big'] + ) + ); + $this->basketTabs()->activate('snapshots'); + $this->addTitle($this->translate('Upload a Configuration Basket Snapshot')); + $form = (new BasketUploadForm()) + ->setObject($basket) + ->setDb($this->db()) + ->handleRequest(); + $this->content()->add($form); + } + /** * @throws \Icinga\Exception\NotFoundError */ @@ -147,6 +165,12 @@ class BasketController extends ActionController $basket->get('basket_name') )); $this->basketTabs()->activate('snapshots'); + $this->actions()->add(Link::create( + $this->translate('Upload'), + 'director/basket/upload-snapshot', + ['name' => $basket->get('basket_name')], + ['class' => 'icon-upload'] + )); } if ($basket !== null) { $this->content()->add( @@ -245,12 +269,9 @@ class BasketController extends ActionController $connection = $this->db(); } - $json = $snapshot->getJsonDump(); $this->addSingleTab($this->translate('Snapshot')); - $all = Json::decode($json); - $exporter = new Exporter($this->db()); - $fieldResolver = new BasketSnapshotFieldResolver($all, $connection); - foreach ($all as $type => $objects) { + $diff = new BasketDiff($snapshot, $connection); + foreach ($diff->getBasketObjects() as $type => $objects) { if ($type === 'Datafield') { // TODO: we should now be able to show all fields and link // to a "diff" for the ones that should be created @@ -274,39 +295,33 @@ class BasketController extends ActionController $linkParams['target_db'] = $targetDbName; } try { - $current = BasketSnapshot::instanceByIdentifier($type, $key, $connection); - if ($current === null) { - $table->addNameValueRow( - $key, - Link::create( - Html::tag('strong', ['style' => 'color: green'], $this->translate('new')), + if ($uuid = $object->uuid ?? null) { + $uuid = Uuid::fromString($uuid); + } + if ($diff->hasCurrentInstance($type, $key, $uuid)) { + if ($diff->hasChangedFor($type, $key, $uuid)) { + $link = Link::create( + $this->translate('modified'), 'director/basket/snapshotobject', - $linkParams - ) + $linkParams, + ['class' => 'basket-modified'] + ); + } else { + $link = Html::tag( + 'span', + ['class' => 'basket-unchanged'], + $this->translate('unchanged') + ); + } + } else { + $link = Link::create( + $this->translate('new'), + 'director/basket/snapshotobject', + $linkParams, + ['class' => 'basket-new'] ); - continue; - } - $currentExport = $exporter->export($current); - $fieldResolver->tweakTargetIds($currentExport); - - // Ignore originalId - if (isset($currentExport->originalId)) { - unset($currentExport->originalId); - } - if (isset($object->originalId)) { - unset($object->originalId); } - $hasChanged = ! CompareBasketObject::equals($currentExport, $object); - $table->addNameValueRow( - $key, - $hasChanged - ? Link::create( - Html::tag('strong', ['style' => 'color: orange'], $this->translate('modified')), - 'director/basket/snapshotobject', - $linkParams - ) - : Html::tag('span', ['style' => 'color: green'], $this->translate('unchanged')) - ); + $table->addNameValueRow($key, $link); } catch (Exception $e) { $table->addNameValueRow( $key, @@ -322,7 +337,6 @@ class BasketController extends ActionController $this->content()->add(Html::tag('h2', $type)); $this->content()->add($table); } - $this->content()->add(Html::tag('div', ['style' => 'height: 5em'])); } /** @@ -368,39 +382,28 @@ class BasketController extends ActionController ) */ ]); - $exporter = new Exporter($this->db()); - $json = $snapshot->getJsonDump(); + $this->addSingleTab($this->translate('Snapshot')); - $objects = Json::decode($json); $targetDbName = $this->params->get('target_db'); if ($targetDbName === null) { $connection = $this->db(); } else { $connection = Db::fromResourceName($targetDbName); } - $fieldResolver = new BasketSnapshotFieldResolver($objects, $connection); - $objectFromBasket = $objects->$type->$key; - unset($objectFromBasket->originalId); - CompareBasketObject::normalize($objectFromBasket); - $objectFromBasket = Json::encode($objectFromBasket, JSON_PRETTY_PRINT); - $current = BasketSnapshot::instanceByIdentifier($type, $key, $connection); - if ($current === null) { - $current = ''; - } else { - $exported = $exporter->export($current); - $fieldResolver->tweakTargetIds($exported); - unset($exported->originalId); - CompareBasketObject::normalize($exported); - $current = Json::encode($exported, JSON_PRETTY_PRINT); + $diff = new BasketDiff($snapshot, $connection); + $object = $diff->getBasketObject($type, $key); + if ($uuid = $object->uuid ?? null) { + $uuid = Uuid::fromString($uuid); } - - if ($current === $objectFromBasket) { + $basketJson = $diff->getBasketString($type, $key); + $currentJson = $diff->getCurrentString($type, $key, $uuid); + if ($currentJson === $basketJson) { $this->content()->add([ Hint::ok('Basket equals current object'), - Html::tag('pre', $current) + Html::tag('pre', $currentJson) ]); } else { - $this->content()->add(new InlineDiff(new PhpDiff($current, $objectFromBasket))); + $this->content()->add(new InlineDiff(new PhpDiff($currentJson, $basketJson))); } } diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index 3f8a105..8a5e702 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -8,6 +8,7 @@ use gipfl\Web\Widget\Hint; use Icinga\Data\Filter\Filter; use Icinga\Exception\IcingaException; use Icinga\Exception\NotFoundError; +use Icinga\Module\Director\Auth\Permission; use Icinga\Module\Director\Db\Branch\Branch; use Icinga\Module\Director\Deployment\DeploymentStatus; use Icinga\Module\Director\Forms\DeployConfigForm; @@ -186,7 +187,7 @@ class ConfigController extends ActionController ['class' => 'icon-user', 'data-base-target' => '_self'] )); } - if ($this->hasPermission('director/deploy') && ! $this->getBranch()->isBranch()) { + if ($this->hasPermission(Permission::DEPLOY) && ! $this->getBranch()->isBranch()) { if ($this->db()->hasDeploymentEndpoint()) { $this->actions()->add(DeployConfigForm::load() ->setDb($this->db()) @@ -369,31 +370,33 @@ class ConfigController extends ActionController $configs = $db->enumDeployedConfigs(); foreach (array($leftSum, $rightSum) as $sum) { - if (! array_key_exists($sum, $configs)) { + if ($sum && ! array_key_exists($sum, $configs)) { $configs[$sum] = substr($sum, 0, 7); } } $baseUrl = $this->url()->without(['left', 'right']); - $this->content()->add(Html::tag('form', ['action' => (string) $baseUrl, 'method' => 'GET'], [ - new HtmlString($this->view->formSelect( - 'left', - $leftSum, - ['class' => 'autosubmit', 'style' => 'width: 37%'], - [null => $this->translate('- please choose -')] + $configs - )), - Link::create( - Icon::create('flapping'), - $baseUrl, - ['left' => $rightSum, 'right' => $leftSum] - ), - new HtmlString($this->view->formSelect( - 'right', - $rightSum, - ['class' => 'autosubmit', 'style' => 'width: 37%'], - [null => $this->translate('- please choose -')] + $configs - )), - ])); + $this->content()->add( + Html::tag('form', ['action' => (string) $baseUrl, 'method' => 'GET', 'class' => 'director-form'], [ + new HtmlString($this->view->formSelect( + 'left', + $leftSum, + ['class' => ['autosubmit', 'config-diff']], + [null => $this->translate('- please choose -')] + $configs + )), + Link::create( + Icon::create('flapping'), + $baseUrl, + ['left' => $rightSum, 'right' => $leftSum] + ), + new HtmlString($this->view->formSelect( + 'right', + $rightSum, + ['class' => ['autosubmit', 'config-diff']], + [null => $this->translate('- please choose -')] + $configs + )), + ]) + ); if ($rightSum === null || $leftSum === null || ! strlen($rightSum) || ! strlen($leftSum)) { return; @@ -500,7 +503,7 @@ class ConfigController extends ActionController { $tabs = $this->tabs(); - if ($this->hasPermission('director/deploy') + if ($this->hasPermission(Permission::DEPLOY) && $deploymentId = $this->params->get('deployment_id') ) { $tabs->add('deployment', [ @@ -510,7 +513,7 @@ class ConfigController extends ActionController ]); } - if ($this->hasPermission('director/showconfig')) { + if ($this->hasPermission(Permission::SHOW_CONFIG)) { $tabs->add('config', [ 'label' => $this->translate('Config'), 'url' => 'director/config/files', diff --git a/application/controllers/DataController.php b/application/controllers/DataController.php index ae4bbcf..7480db2 100644 --- a/application/controllers/DataController.php +++ b/application/controllers/DataController.php @@ -216,7 +216,7 @@ class DataController extends ActionController $subTitle = $this->translate('Add a new instance'); } - $this->content()->add(Html::tag('h2', ['style' => 'margin-top: 2em'], $subTitle)); + $this->content()->add(Html::tag('h2', ['class' => 'dictionary-header'], $subTitle)); $form->handleRequest($this->getRequest()); $this->content()->add($form); if ($form->succeeded()) { @@ -326,7 +326,7 @@ class DataController extends ActionController Table::row([ $this->translate('Key / Instance'), $this->translate('Properties') - ], ['style' => 'text-align: left'], 'th') + ], ['class' => 'text-align-left'], 'th') ); foreach ($currentValue as $key => $item) { $table->add(Table::row([ diff --git a/application/controllers/HostController.php b/application/controllers/HostController.php index e107d22..33b5ba5 100644 --- a/application/controllers/HostController.php +++ b/application/controllers/HostController.php @@ -3,7 +3,9 @@ namespace Icinga\Module\Director\Controllers; use gipfl\Web\Widget\Hint; -use Icinga\Module\Director\Monitoring; +use Icinga\Module\Director\Auth\Permission; +use Icinga\Module\Director\Integration\Icingadb\IcingadbBackend; +use Icinga\Module\Director\Integration\MonitoringModule\Monitoring; use Icinga\Module\Director\Web\Table\ObjectsTableService; use ipl\Html\Html; use gipfl\IcingaWeb2\Link; @@ -31,28 +33,24 @@ class HostController extends ObjectController { protected function checkDirectorPermissions() { - if ($this->isServiceAction() && (new Monitoring())->authCanEditService( - $this->Auth(), - $this->getParam('name'), - $this->getParam('service') - )) { + $host = $this->getHostObject(); + $auth = $this->Auth(); + $backend = $this->backend(); + if ($this->isServiceAction() + && $backend->canModifyService($host->getObjectName(), $this->getParam('service')) + ) { return; } - - if ($this->isServicesReadOnlyAction()) { - $this->assertPermission('director/monitoring/services-ro'); + if ($this->isServicesReadOnlyAction() && $auth->hasPermission($this->getServicesReadOnlyPermission())) { return; } - - if ($this->hasPermission('director/hosts')) { // faster + if ($auth->hasPermission(Permission::HOSTS)) { // faster return; } - - if ($this->canModifyHostViaMonitoringPermissions($this->getParam('name'))) { + if ($backend->canModifyHost($host->getObjectName())) { return; } - - $this->assertPermission('director/hosts'); // complain about default hosts permission + $this->assertPermission(Permission::HOSTS); // complain about default hosts permission } protected function isServicesReadOnlyAction() @@ -76,16 +74,6 @@ class HostController extends ObjectController ]); } - protected function canModifyHostViaMonitoringPermissions($hostname) - { - if ($this->hasPermission('director/monitoring/hosts')) { - $monitoring = new Monitoring(); - return $monitoring->authCanEditHost($this->Auth(), $hostname); - } - - return false; - } - /** * @return HostgroupRestriction */ @@ -150,11 +138,35 @@ class HostController extends ObjectController public function findserviceAction() { + $auth = $this->Auth(); $host = $this->getHostObject(); - $this->redirectNow( - (new ServiceFinder($host, $this->getAuth())) - ->getRedirectionUrl($this->params->get('service')) - ); + $hostName = $host->getObjectName(); + $serviceName = $this->params->get('service'); + $info = ServiceFinder::find($host, $serviceName); + $backend = $this->backend(); + + if ($info && $auth->hasPermission(Permission::HOSTS)) { + $redirectUrl = $info->getUrl(); + } elseif ($info + && (($backend instanceof Monitoring && $auth->hasPermission(Permission::MONITORING_HOSTS)) + || ($backend instanceof IcingadbBackend && $auth->hasPermission(Permission::ICINGADB_HOSTS)) + ) + && $backend->canModifyService($hostName, $serviceName) + ) { + $redirectUrl = $info->getUrl(); + } elseif ($auth->hasPermission($this->getServicesReadOnlyPermission())) { + $redirectUrl = Url::fromPath('director/host/servicesro', [ + 'name' => $hostName, + 'service' => $serviceName + ]); + } else { + $redirectUrl = Url::fromPath('director/host/invalidservice', [ + 'name' => $hostName, + 'service' => $serviceName, + ]); + } + + $this->redirectNow($redirectUrl); } /** @@ -207,8 +219,7 @@ class HostController extends ObjectController $branch = $this->getBranch(); $hostHasBeenCreatedInBranch = $branch->isBranch() && $host->get('id'); $content = $this->content(); - $table = (new ObjectsTableService($this->db())) - ->setAuth($this->Auth()) + $table = (new ObjectsTableService($this->db(), $this->Auth())) ->setHost($host) ->setBranch($branch) ->setTitle($this->translate('Individual Service objects')) @@ -222,8 +233,7 @@ class HostController extends ObjectController $parents = IcingaTemplateRepository::instanceByObject($this->object) ->getTemplatesFor($this->object, true); foreach ($parents as $parent) { - $table = (new ObjectsTableService($this->db())) - ->setAuth($this->Auth()) + $table = (new ObjectsTableService($this->db(), $this->Auth())) ->setBranch($branch) ->setHost($parent) ->setInheritedBy($host) @@ -279,7 +289,7 @@ class HostController extends ObjectController */ public function servicesroAction() { - $this->assertPermission('director/monitoring/services-ro'); + $this->assertPermission($this->getServicesReadOnlyPermission()); $host = $this->getHostObject(); $service = $this->params->getRequired('service'); $db = $this->db(); @@ -289,8 +299,7 @@ class HostController extends ObjectController $this->addTitle($this->translate('Services on %s'), $host->getObjectName()); $content = $this->content(); - $table = (new ObjectsTableService($db)) - ->setAuth($this->Auth()) + $table = (new ObjectsTableService($db, $this->Auth())) ->setHost($host) ->setBranch($branch) ->setReadonly() @@ -305,7 +314,7 @@ class HostController extends ObjectController $parents = IcingaTemplateRepository::instanceByObject($this->object) ->getTemplatesFor($this->object, true); foreach ($parents as $parent) { - $table = (new ObjectsTableService($db)) + $table = (new ObjectsTableService($db, $this->Auth())) ->setReadonly() ->setBranch($branch) ->setHost($parent) @@ -387,6 +396,7 @@ class HostController extends ObjectController ->setHost($host) ->setBranch($this->getBranch()) ->setAffectedHost($affectedHost) + ->removeQueryLimit() ->setTitle($title); if ($roService) { $table->setReadonly()->highlightService($roService); @@ -582,20 +592,19 @@ class HostController extends ObjectController { $host = $this->object; try { - $mon = $this->monitoring(); - if ($host->isObject() - && $mon->isAvailable() - && $mon->hasHost($host->getObjectName()) + $backend = $this->backend(); + if ($host instanceof IcingaHost + && $host->isObject() + && $backend->hasHost($host->getObjectName()) ) { - $this->actions()->add(Link::create( - $this->translate('Show'), - 'monitoring/host/show', - ['host' => $host->getObjectName()], - [ - 'class' => 'icon-globe critical', - 'data-base-target' => '_next' - ] - )); + $this->actions()->add( + Link::create( + $this->translate('Show'), + $backend->getHostUrl($host->getObjectName()), + null, + ['class' => 'icon-globe critical', 'data-base-target' => '_next'] + ) + ); // Intentionally placed here, show it only for deployed Hosts $this->addOptionalInspectLink(); @@ -607,7 +616,7 @@ class HostController extends ObjectController protected function addOptionalInspectLink() { - if (! $this->hasPermission('director/inspect')) { + if (! $this->hasPermission(Permission::INSPECT)) { return; } @@ -627,11 +636,25 @@ class HostController extends ObjectController } /** - * @return IcingaHost + * @return ?IcingaHost */ protected function getHostObject() { - assert($this->object instanceof IcingaHost); + if ($this->object !== null) { + assert($this->object instanceof IcingaHost); + } return $this->object; } + + /** + * Get readOnly permission of the service for the current backend + * + * @return string permission + */ + protected function getServicesReadOnlyPermission(): string + { + return $this->backend() instanceof IcingadbBackend + ? Permission::ICINGADB_SERVICES_RO + : Permission::MONITORING_SERVICES_RO; + } } diff --git a/application/controllers/ImportsourceController.php b/application/controllers/ImportsourceController.php index cbddb9e..f417bf7 100644 --- a/application/controllers/ImportsourceController.php +++ b/application/controllers/ImportsourceController.php @@ -180,9 +180,7 @@ class ImportsourceController extends ActionController 'target' => '_blank', 'class' => 'icon-download', ] - ))->add(Link::create('[..]', '#', null, [ - 'onclick' => 'javascript:$("table.raw-data-table").toggleClass("collapsed");' - ])); + )); try { (new ImportsourceHookTable())->setImportSource($source)->renderTo($this); } catch (Exception $e) { diff --git a/application/controllers/ImportsourcesController.php b/application/controllers/ImportsourcesController.php index 4287292..f0021c5 100644 --- a/application/controllers/ImportsourcesController.php +++ b/application/controllers/ImportsourcesController.php @@ -30,7 +30,7 @@ class ImportsourcesController extends ActionController } $this->addTitle($this->translate('Import source')) - ->setAutoRefreshInterval(10) + ->setAutorefreshInterval(10) ->addAddLink( $this->translate('Add a new Import Source'), 'director/importsource/add' diff --git a/application/controllers/JobsController.php b/application/controllers/JobsController.php index 11e86ed..04c6d34 100644 --- a/application/controllers/JobsController.php +++ b/application/controllers/JobsController.php @@ -11,7 +11,7 @@ class JobsController extends ActionController public function indexAction() { $this->addTitle($this->translate('Jobs')) - ->setAutoRefreshInterval(10) + ->setAutorefreshInterval(10) ->addAddLink($this->translate('Add a new Job'), 'director/job/add') ->tabs(new ImportTabs())->activate('jobs'); diff --git a/application/controllers/SchemaController.php b/application/controllers/SchemaController.php index b0ca24e..961b7b1 100644 --- a/application/controllers/SchemaController.php +++ b/application/controllers/SchemaController.php @@ -62,7 +62,7 @@ class SchemaController extends ActionController return file_get_contents( sprintf( '%s/schema/%s.sql', - $this->Module()->getBasedir(), + $this->Module()->getBaseDir(), $type ) ); diff --git a/application/controllers/SelfServiceController.php b/application/controllers/SelfServiceController.php index 0b3b642..c3c9bb5 100644 --- a/application/controllers/SelfServiceController.php +++ b/application/controllers/SelfServiceController.php @@ -194,7 +194,7 @@ class SelfServiceController extends ActionController } else { throw new ProgrammingError( 'Expected boolean value, got %s', - var_export($value, 1) + var_export($value, true) ); } } @@ -275,7 +275,7 @@ class SelfServiceController extends ActionController // PluginsUrl => framework_plugins_url ]; $username = $settings->get('self-service/icinga_service_user'); - if ($username !== null && strlen($username) > 0) { + if ($username) { $params['icinga_service_user'] = $username; } @@ -404,7 +404,7 @@ class SelfServiceController extends ActionController { foreach ($keys as $key) { $value = $settings->get("self-service/$key"); - if (strlen($value)) { + if ($value) { $params[$key] = $value; } } diff --git a/application/controllers/ServiceController.php b/application/controllers/ServiceController.php index 3cd54d6..b62f317 100644 --- a/application/controllers/ServiceController.php +++ b/application/controllers/ServiceController.php @@ -4,11 +4,10 @@ namespace Icinga\Module\Director\Controllers; use Exception; use Icinga\Exception\NotFoundError; -use Icinga\Module\Director\Data\Db\DbObjectStore; +use Icinga\Module\Director\Auth\Permission; use Icinga\Module\Director\Data\Db\DbObjectTypeRegistry; use Icinga\Module\Director\Db\Branch\UuidLookup; use Icinga\Module\Director\Forms\IcingaServiceForm; -use Icinga\Module\Director\Monitoring; use Icinga\Module\Director\Objects\IcingaObject; use Icinga\Module\Director\Web\Controller\ObjectController; use Icinga\Module\Director\Objects\IcingaService; @@ -30,13 +29,14 @@ class ServiceController extends ObjectController protected function checkDirectorPermissions() { - if ($this->hasPermission('director/monitoring/services')) { - $monitoring = new Monitoring(); - if ($monitoring->authCanEditService($this->Auth(), $this->getParam('host'), $this->getParam('name'))) { - return; - } + if ($this->host + && $this->object + && $this->backend()->canModifyService($this->host->getObjectName(), $this->object->getObjectName()) + ) { + return; } - $this->assertPermission('director/hosts'); + + $this->assertPermission(Permission::HOSTS); } public function init() @@ -62,7 +62,7 @@ class ServiceController extends ObjectController protected function getOptionalRelatedObjectFromParams($type, $parameter) { - if ($id = $this->params->get("${parameter}_id")) { + if ($id = $this->params->get("{$parameter}_id")) { $key = (int) $id; } else { $key = $this->params->get($parameter); @@ -80,7 +80,7 @@ class ServiceController extends ObjectController { $key = $object->getUnresolvedRelated($relation); if ($key === null) { - if ($key = $object->get("${relation}_id")) { + if ($key = $object->get("{$relation}_id")) { $key = (int) $key; } else { $key = $object->get($relation); diff --git a/application/controllers/SyncruleController.php b/application/controllers/SyncruleController.php index 928cf2c..e575ad8 100644 --- a/application/controllers/SyncruleController.php +++ b/application/controllers/SyncruleController.php @@ -48,7 +48,7 @@ class SyncruleController extends ActionController */ public function indexAction() { - $this->setAutoRefreshInterval(10); + $this->setAutorefreshInterval(10); $rule = $this->requireSyncRule(); $this->tabs(new SyncRuleTabs($rule))->activate('show'); $ruleName = $rule->get('rule_name'); @@ -94,7 +94,7 @@ class SyncruleController extends ActionController break; case 'in-sync': $c->add(Html::tag('p', null, sprintf( - $this->translate('This Sync Rule was last found to by in Sync at %s.'), + $this->translate('This Sync Rule was last found to be in Sync at %s.'), $rule->get('last_attempt') ))); /* @@ -380,10 +380,7 @@ class SyncruleController extends ActionController protected function firstNames($objects, $max = 50) { $names = []; - $list = new UnorderedList(); - $list->addAttributes([ - 'style' => 'list-style-type: none; marign: 0; padding: 0', - ]); + $list = new UnorderedList([], ['class' => 'unordred-list']); $total = count($objects); $i = 0; PrefetchCache::forget(); @@ -464,7 +461,7 @@ class SyncruleController extends ActionController { $list = new UnorderedList(); foreach ($properties as $property => $cnt) { - $list->addItem("${cnt}x $property"); + $list->addItem("{$cnt}x $property"); } return $list; @@ -517,7 +514,6 @@ class SyncruleController extends ActionController if ($this->showNotInBranch($this->translate('Modifying Sync Rules'))) { return; } - } else { $this->addTitle($this->translate('Add sync rule')); $this->tabs(new SyncRuleTabs())->activate('add'); @@ -609,12 +605,11 @@ class SyncruleController extends ActionController $form = SyncPropertyForm::load()->setDb($db); $this->tabs(new SyncRuleTabs($rule))->activate('property'); $this->actions()->add(new Link( - $this->translate('back'), - 'director/syncrule/property', - ['rule_id' => $ruleId], - ['class' => 'icon-left-big'] - )); - + $this->translate('back'), + 'director/syncrule/property', + ['rule_id' => $ruleId], + ['class' => 'icon-left-big'] + )); if ($id = $this->params->get('id')) { $form->loadObject((int) $id); $this->addTitle( @@ -647,7 +642,7 @@ class SyncruleController extends ActionController */ public function historyAction() { - $this->setAutoRefreshInterval(30); + $this->setAutorefreshInterval(30); $rule = $this->requireSyncRule(); $this->tabs(new SyncRuleTabs($rule))->activate('history'); $this->addTitle($this->translate('Sync history') . ': ' . $rule->get('rule_name')); diff --git a/application/controllers/SyncrulesController.php b/application/controllers/SyncrulesController.php index 1829ebe..1c84ecf 100644 --- a/application/controllers/SyncrulesController.php +++ b/application/controllers/SyncrulesController.php @@ -23,7 +23,7 @@ class SyncrulesController extends ActionController } $this->addTitle($this->translate('Sync rule')) - ->setAutoRefreshInterval(10) + ->setAutorefreshInterval(10) ->addAddLink( $this->translate('Add a new Sync Rule'), 'director/syncrule/add' |