Skip to content
This repository has been archived by the owner on May 9, 2023. It is now read-only.

Commit

Permalink
code cleanup, added settings item
Browse files Browse the repository at this point in the history
  • Loading branch information
pauloamgomes committed Jul 29, 2018
1 parent 51e540e commit 47a97ac
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 21 deletions.
3 changes: 3 additions & 0 deletions Controller/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace EmailOnSave\Controller;

/**
* Admin class.
*/
class Admin extends \Cockpit\AuthController {

public function index() {
Expand Down
4 changes: 2 additions & 2 deletions actions.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php


$app->on('collections.save.after', function($name, $data) use($app) {
$app->on('collections.save.after', function ($name, $data) use ($app) {

$settings = $app->storage->getKey('cockpit/options', 'emailonsave.settings', []);

Expand Down Expand Up @@ -45,4 +45,4 @@
);

}
});
});
27 changes: 13 additions & 14 deletions admin.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
<?php

// ACL
// ACL.
$this("acl")->addResource('EmailOnSave', ['manage.emailonsave']);

$app->on('admin.init', function() {
/*
* add menu entry if the user has access to group stuff
*/
$this->on('cockpit.view.settings.item', function () {
if ($this->module('cockpit')->hasaccess('EmailOnSave', 'manage.emailonsave')) {
$this->renderView("emailonsave:views/partials/settings.php");
}
});

// bind admin routes /emailonsave
$this->bindClass('EmailOnSave\\Controller\\Admin', 'emailonsave');

// add to modules menu
$this('admin')->addMenuItem('modules', [
'label' => 'Email On Save',
'icon' => 'assets:app/media/icons/email.svg',
'route' => '/emailonsave',
'active' => strpos($this['route'], '/emailonsave') === 0
]);

});
$app->on('admin.init', function () use ($app) {
// Bind admin routes /settings/email-on-save.
$this->bindClass('EmailOnSave\\Controller\\Admin', 'settings/email-on-save');
});
8 changes: 4 additions & 4 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

// ADMIN
// ADMIN.
if (COCKPIT_ADMIN && !COCKPIT_API_REQUEST) {
include_once(__DIR__ . '/admin.php');
include_once __DIR__ . '/admin.php';
}

// ACTIONS
include_once(__DIR__ . '/actions.php');
// ACTIONS.
include_once __DIR__ . '/actions.php';
19 changes: 19 additions & 0 deletions views/partials/settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

/**
* @file
* Logger settings entry view.
*/
?>

<div>
<div class="uk-panel uk-panel-space uk-panel-box uk-panel-card">

<img src="@url('assets:app/media/icons/email.svg')" width="50" height="50" alt="@lang('Email on Save')" />

<div class="uk-text-truncate uk-margin">
@lang('Email on Save')
</div>
<a class="uk-position-cover" href="@route('/settings/email-on-save')"></a>
</div>
</div>
2 changes: 1 addition & 1 deletion views/settings/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<div class="uk-width-medium-1-2">
<button class="uk-button uk-button-large uk-width-1-3 uk-button-primary uk-margin-right">@lang('Save')</button>
<a href="@route('/')">@lang('Cancel')</a>
<a href="@route('/settings')">@lang('Cancel')</a>
</div>
</form>
Expand Down

0 comments on commit 47a97ac

Please sign in to comment.