/**
  * index action
  *
  * Shows all settings with the specific prefix.
  *
  * @param string $key The prefix.
  * @return void|\Cake\Network\Respose
  * @throws NotFoundException
  */
 public function index($key = null)
 {
     if (!$key) {
         $key = 'App';
     }
     $this->Menu->active($this->prefixes[$key]);
     if (!$this->__prefixExists($key)) {
         throw new NotFoundException("The prefix-setting " . $key . " could not be found");
     }
     $prefix = Hash::get($this->prefixes, ucfirst($key));
     $settings = $this->Configurations->find('all')->where(['name LIKE' => $key . '%', 'editable' => 1])->order(['weight', 'id']);
     if ($this->request->is(['patch', 'post', 'put'])) {
         $settings = $this->Configurations->patchEntities($settings, $this->request->data);
         foreach ($settings as $setting) {
             $this->Flash->success('The settings has been saved.');
             if (!$this->Configurations->save($setting)) {
                 $this->Flash->error('The settings could not be saved. Please, try again.');
             }
         }
         Setting::clear(true);
         Setting::autoLoad();
         return $this->redirect([]);
     }
     $this->set(compact('prefix', 'settings'));
 }
 public function afterDispatch(Event $event)
 {
     $request = $event->data['request'];
     $response = $event->data['response'];
     if (!Configure::read('AB.Show')) {
         return;
     }
     if ($request->param('plugin') === 'DebugKit' || $request->is('requested')) {
         return;
     }
     if ($request->param('plugin') === 'AdminBar' || $request->is('requested')) {
         return;
     }
     if ($request->param('prefix') === 'admin') {
         if (!Setting::read('AB.Backend')) {
             return;
         }
     }
     if ($request->param('prefix') !== 'admin') {
         if (!Setting::read('AB.Frontend')) {
             return;
         }
     }
     $this->_injectScripts($request, $response);
 }
Пример #3
0
 /**
  * _getOptionsArray
  *
  * Getter for `options`. Array's are json-decoded.
  *
  * @return array
  */
 protected function _getOptions()
 {
     if (array_key_exists('name', $this->_properties)) {
         $options = Setting::options($this->_properties['name']);
         if (is_callable($options)) {
             return $options();
         }
         return $options;
     }
     return false;
 }
Пример #4
0
 /**
  * reset_password
  *
  * Sends mail if an user requested a new password.
  *
  * @param $user User entity.
  * @return void
  */
 public function reset_password($user)
 {
     $from = Configure::read('CA.email.from');
     $fullBaseUrl = Setting::read('App.BaseUrl');
     $this->domain($fullBaseUrl);
     $this->viewVars(['user' => $user, 'resetUrl' => $fullBaseUrl . '/admin/users/reset/' . $user['email'] . '/' . $user['request_key'], 'baseUrl' => $fullBaseUrl, 'loginUrl' => $fullBaseUrl . '/admin', 'from' => reset($from)]);
     $this->template('CakeAdmin.reset_password', 'CakeAdmin.default');
     $this->emailFormat('both');
     $this->from($from);
     $this->to($user['email']);
     $this->subject(__('Forgot Password'));
     $this->transport(Configure::read('CA.email.transport'));
 }
Пример #5
0
<?php

/**
 * CakeManager (http://cakemanager.org)
 * Copyright (c) http://cakemanager.org
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) http://cakemanager.org
 * @link          http://cakemanager.org CakeManager Project
 * @since         1.0
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Settings\Core\Setting;
Plugin::load('Bootstrap');
Configure::write('Settings.Prefixes.LS', 'LightStrap');
Configure::write('CA.viewClass', 'LightStrap.App');
Configure::write('CA.theme', 'LightStrap');
Setting::register('LS.subtheme', 'Cosmo', ['options' => [null => 'None', 'Cerulean' => 'Cerulean', 'Cosmo' => 'Cosmo', 'Cyborg' => 'Cyborg', 'Darkly' => 'Darkly', 'Flatly' => 'Flatly', 'Journal' => 'Journal', 'Lumen' => 'Lumen', 'Paper' => 'Paper', 'Readable' => 'Readable', 'Simplex' => 'Simplex', 'Slate' => 'Slate', 'Spacelab' => 'Spacelab', 'Superhero' => 'Superhero', 'United' => 'United', 'Yeti' => 'Yeti'], 'type' => 'select']);
Configure::write('CA.LightStrap.subtheme', Setting::read('LS.subtheme'));
Setting::register('LS.navbar', 'navbar-default', ['options' => ['navbar-default' => 'Default', 'navbar-inverse' => 'Inverse'], 'type' => 'select']);
Configure::write('CA.LightStrap.navbar', Setting::read('LS.navbar'));
Setting::register('LS.container', 'container', ['options' => ['container' => 'Fixed', 'container-fluid' => 'Fluid'], 'type' => 'select']);
Configure::write('CA.LightStrap.container', Setting::read('LS.container'));
Пример #6
0
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) http://cakemanager.org
 * @link          http://cakemanager.org CakeManager Project
 * @since         1.0
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Settings\Core\Setting;
# Plugins
Plugin::load('Utils', []);
Plugin::load('Settings', ['bootstrap' => true, 'routes' => true]);
Plugin::load('Notifier', ['bootstrap' => true, 'routes' => true]);
# Configurations
Configure::write('Session.timeout', 4320);
Configure::write('CA.theme', 'CakeAdmin');
Configure::write('CA.viewClass', null);
Configure::write('CA.layout.default', 'CakeAdmin.default');
Configure::write('CA.layout.login', 'CakeAdmin.login');
Configure::write('CA.fields', ['username' => 'email', 'password' => 'password']);
Configure::write('CA.Menu.main', []);
Configure::write('Settings.Prefixes.CA', 'CakeAdmin');
Configure::write('CA.PostTypes', []);
Configure::write('CA.Models.administrators', 'CakeAdmin.Administrators');
# Settings
Setting::register('App.Name', 'CakeAdmin Application');
# Theming
Plugin::load('LightStrap', ['bootstrap' => true, 'routes' => true]);
Пример #7
0
<?php

/**
 * CakeManager (http://cakemanager.org)
 * Copyright (c) http://cakemanager.org
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) http://cakemanager.org
 * @link          http://cakemanager.org CakeManager Project
 * @since         1.0
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
use Cake\Core\Configure;
use Cake\Routing\DispatcherFactory;
use Settings\Core\Setting;
# Configures
Configure::write('AB.Show', true);
Configure::write('Settings.Prefixes.AB', 'AdminBar');
# Settings
Setting::register('AB.Backend', true, ['type' => 'select', 'options' => [0 => 'Disabled', 1 => 'Enabled']]);
Setting::register('AB.Frontend', true, ['type' => 'select', 'options' => [0 => 'Disabled', 1 => 'Enabled']]);
# AdminBar
Configure::write('AdminBar.goto_backend', ['on' => ['prefix' => ['!admin', '*'], 'controller' => '*', 'action' => '*'], 'label' => 'CakeAdmin Panel', 'url' => '/admin']);
Configure::write('AdminBar.goto_website', ['on' => ['prefix' => 'admin', 'controller' => '*', 'action' => '*'], 'label' => 'Go To Website', 'url' => Configure::read('App.fullBaseUrl')]);
Configure::write('AdminBar.goto_settings', ['on' => ['prefix' => 'admin', 'controller' => '*', 'action' => '*'], 'label' => 'Settings', 'url' => ['prefix' => 'admin', 'plugin' => 'CakeAdmin', 'controller' => 'Settings', 'action' => 'index']]);
# Dispatcher Filter
DispatcherFactory::add('AdminBar.AdminBar');
Пример #8
0
 public function getRoutes()
 {
     $blogs = $this->find('all')->select(['id', 'slug'])->contain(['Categories' => function ($q) {
         return $q->select(['id', 'slug']);
     }])->toArray();
     $routes = [];
     foreach ($blogs as $blog) {
         $id = $blog->id;
         $replacements = ['category_slug' => $blog->category->slug, 'blog_slug' => $blog->slug];
         $slug = Text::insert(Setting::read('CMS.BlogsUrl'), $replacements);
         $routes[$id] = $slug;
     }
     return $routes;
 }
Пример #9
0
<?php

/**
 * CakeManager (http://cakemanager.org)
 * Copyright (c) http://cakemanager.org
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) http://cakemanager.org
 * @link          http://cakemanager.org CakeManager Project
 * @since         1.0
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
use Settings\Core\Setting;
use Cake\Core\Configure;
Configure::write('Settings.Prefixes.Api', 'API');
Setting::register('Api.JWT', 0, ['type' => 'select', 'options' => [1 => 'On', 0 => 'Off']]);
return ['Api.JWT' => Setting::read('Api.JWT')];
Пример #10
0
 * @link          http://cakemanager.org CakeManager Project
 * @since         1.0
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
use Cake\Core\Configure;
use Settings\Core\Setting;
use Cake\ORM\TableRegistry;
use Cake\Cache\Cache;
use Cms\Utility\PathManager;
Configure::write('Settings.Prefixes.CMS', 'Cake CMS');
Setting::register('CMS.Pages', true, ['type' => 'checkbox']);
Setting::register('CMS.Blogs', true, ['type' => 'checkbox']);
Setting::register('CMS.Index', false, ['type' => 'select', 'options' => function () {
    return [false => 'None'] + TableRegistry::get('Cms.Pages')->find('list')->toArray();
}]);
Setting::register('CMS.BlogsUrl', '/:category_slug/:blog_slug');
if (Setting::read('CMS.Pages')) {
    Configure::write('CA.Models.pages', 'Cms.Pages');
    PathManager::instance()->register('pages', 'Cms.Pages');
}
if (Setting::read('CMS.Blogs')) {
    Configure::write('CA.Models.categories', 'Cms.Categories');
    Configure::write('CA.Models.blogs', 'Cms.Blogs');
    PathManager::instance()->register('blogs', 'Cms.Blogs');
    PathManager::instance()->register('categories', 'Cms.Categories');
}
# Notification Templates
Configure::write('Notifier.templates.blog_post', ['title' => 'A new blog has been posted', 'body' => 'The blog :title has been posted by :creator']);
# AdminBar
Configure::write('AdminBar.edit_blog', ['on' => ['plugin' => 'Cms', 'controller' => 'Blogs', 'action' => 'view'], 'label' => 'Edit Blog', 'url' => ['prefix' => 'admin', 'plugin' => 'CakeAdmin', 'controller' => 'PostTypes', 'action' => 'edit', ':pass.0', 'type' => 'blogs']]);
Configure::write('AdminBar.read_blog', ['on' => ['prefix' => 'admin', 'plugin' => 'CakeAdmin', 'controller' => 'PostTypes', 'action' => ['edit', 'view'], 'type' => 'blogs'], 'label' => 'Read Blog', 'url' => ['prefix' => false, 'plugin' => 'Cms', 'controller' => 'Blogs', 'action' => 'view', ':pass.1']]);
 public function testIndexPostWithDefaultKey()
 {
     Setting::write('App.FirstKey', 'First Value');
     Setting::write('App.SecondKey', 'Second Value');
     Setting::write('CA.ThirthKey', 'Thirth Value');
     $this->session(['Auth' => ['CakeAdmin' => ['id' => 1, 'email' => '*****@*****.**', 'cakeadmin' => 1]]]);
     $settings = TableRegistry::get('Settings.Configurations');
     $this->assertEquals('First Value', $settings->findByName('App.FirstKey')->toArray()[0]['value']);
     $this->post('/admin/settings', [['id' => '1', 'value' => 'First Value Edited']]);
     $this->assertResponseSuccess();
     $this->assertEquals('First Value Edited', $settings->findByName('App.FirstKey')->toArray()[0]['value']);
 }
Пример #12
0
 /**
  * Test autoload-method
  *
  * @return void
  */
 public function testAutoload()
 {
     Setting::write('App.Test1', 'Test1');
     Setting::write('App.Test2', 'Test2');
     Setting::clear();
     $this->assertEmpty(Setting::read());
     Setting::clear(true);
     Setting::autoLoad();
     $_array = ['App.Test1' => 'Test1', 'App.Test2' => 'Test2'];
     $this->assertEquals($_array, Setting::read());
 }