Example #1
0
 /**
  * Ustawienie menu
  */
 private function initMenu()
 {
     $menu = Cache::read('menu-' . $this->userRole);
     if (!isset($menu) || $menu === false) {
         // Pobranie menu z configa
         Configure::load('Admin.app_menu', 'default');
         $menuConfig = Configure::read('menu');
         $that = $this;
         $generateMenu = function ($array) use($that, &$generateMenu) {
             $menu = array();
             foreach ($array as $key => $item) {
                 $link = $item['link'];
                 // czy ma dostep
                 if (!$link || $that->permission->check($link['controller'], $link['action'])) {
                     $childs = [];
                     if (isset($item['childs']) && !empty($item['childs'])) {
                         $childs = $generateMenu($item['childs']);
                         $item['childs'] = $childs;
                     }
                     // Nie dodaje pustych elementów do menu bez linku
                     if (count($childs) == 0 && !$link) {
                         continue;
                     }
                     $menu[$key] = $item;
                 }
             }
             return $menu;
         };
         $menu = $generateMenu($menuConfig);
         Cache::write('menu-' . $this->userRole, $menu);
     }
     $this->set('params', $this->request->params);
     $this->set('menu', $menu);
 }
 public function onControllerInit($event)
 {
     $controller = $event->subject();
     if (isset($controller->request->params['prefix'])) {
         $menuFile = $controller->request->params['prefix'] . '_menus';
         if ($theme = Configure::read('App.admin.theme')) {
             if ($theme != '' && $theme != 'RearEngine' && Plugin::loaded($theme)) {
                 $controller->viewBuilder()->theme($theme);
             }
         }
         foreach (Plugin::loaded() as $plugin) {
             try {
                 Configure::load($plugin . '.' . $menuFile, 'default', true);
             } catch (\Exception $e) {
                 if (Configure::read('debug')) {
                     Log::warning('Unable to load app ' . $plugin . '/Config/' . $menuFile . ' config file', ['scope' => 'RearEngine plugin']);
                 }
             }
         }
         try {
             Configure::load($menuFile, 'default', true);
         } catch (\Exception $e) {
             if (Configure::read('debug')) {
                 Log::warning('Unable to load App/Config/' . $menuFile . ' config file.', ['scope' => 'RearEngine plugin']);
             }
         }
     }
 }
 /**
  * Wrap Moxiemanager's api.php in a controller action.
  *
  * @return void
  */
 public function api()
 {
     try {
         $pluginPath = Plugin::path('CkTools');
         define('MOXMAN_CLASSES', $pluginPath . 'src/Lib/moxiemanager/classes');
         define('MOXMAN_PLUGINS', $pluginPath . 'src/Lib/moxiemanager/plugins');
         define('MOXMAN_ROOT', $pluginPath . 'src/Lib/moxiemanager');
         define('MOXMAN_API_FILE', __FILE__);
         $appConfig = Configure::read('CkTools.moxiemanager');
         Configure::load('CkTools.moxiemanager');
         $moxieManagerConfig = Configure::read('moxiemanager');
         if (is_array($appConfig)) {
             $moxieManagerConfig = Hash::merge($moxieManagerConfig, $appConfig);
         }
         $GLOBALS['moxieManagerConfig'] = $moxieManagerConfig;
         require_once MOXMAN_CLASSES . '/MOXMAN.php';
         $context = \MOXMAN_Http_Context::getCurrent();
         $pluginManager = \MOXMAN::getPluginManager();
         foreach ($pluginManager->getAll() as $plugin) {
             if ($plugin instanceof \MOXMAN_Http_IHandler) {
                 $plugin->processRequest($context);
             }
         }
     } catch (Exception $e) {
         \MOXMAN_Exception::printException($e);
     }
     return $this->render(false, false);
 }
 /**
  * Test StartupWithExistingConfigFile
  *
  * @return void
  */
 public function testStartupWithExistingConfigFile()
 {
     Configure::config('default', new PhpConfig(PATH_TO_CONFIG_FILES));
     Configure::load('recaptchaWithExistingKeys', 'default', false);
     // check that secret is well imported
     $this->assertEquals('goodsecret', Configure::read('Recaptcha.secret'));
 }
Example #5
0
 function __construct()
 {
     Configure::load('amazon', 'default');
     $this->awsAccessKey = Configure::read('AwsAccessKey');
     $this->awsSecretKey = Configure::read('AwsSecretKey');
     $this->associateTag = Configure::read('AssociateTag');
 }
Example #6
0
 /**
  *
  */
 public function linkedinget($resource, $token)
 {
     Configure::load('Linkedin.linkedin_credentials');
     $credentials = Configure::read('credentials');
     $linkedIn = new LinkedInLib($credentials['api_key'], $credentials['api_secret']);
     $result = $linkedIn->linkedinget($resource, $token);
     return $result;
 }
 /**
  * 初期化処理
  *
  * @access public
  */
 public function __construct()
 {
     // 「app.php」から画像アップロード先のパスを取得する
     Configure::config('default', new PhpConfig());
     Configure::load('app', 'default', false);
     $this->uploadFilePath = Configure::read('App.uploadFilePath');
     $this->uploadTempFilePath = Configure::read('App.uploadTempFilePath');
 }
Example #8
0
 /**
  * Make sure the CrudView config exists
  *
  * If it doesn't, load the defaults file
  *
  * @return array
  */
 public function ensureConfig()
 {
     $config = Configure::read('CrudView');
     if ($config !== null) {
         return $config;
     }
     return Configure::load('CrudView.defaults');
 }
Example #9
0
 /**
  * Returns the translated version of the given country
  *
  * @param string $country E.g. "de", "en"
  * @return string
  */
 public function country($country)
 {
     if (!Configure::read('countries')) {
         Configure::load('CkTools.countries');
     }
     $countries = Configure::read('countries');
     return isset($countries[$country]) ? $countries[$country] : $country;
 }
 public function initialize(array $config)
 {
     Configure::load('UploadManager.uploads', 'default');
     $this->maxFileSize = Configure::read('Uploads.maxFileSize');
     $this->maxFileSize *= 1048576;
     // Multiply by bytes per mb
     $this->storagePath = Configure::read('Uploads.storagePath');
     $this->storeOwner = Configure::read('Uploads.storeOwner');
 }
Example #11
0
 /**
  * Wrapper para Configure::load().
  * Faz uma verificação para ver se o plugin está instalado. (@see PluginStarter::install()).
  * 
  * @param string $pluginName O nome do plugin a ser carregado.
  * @return bool              O retorno do chamado Configure::load().
  */
 public function load($pluginName)
 {
     $settingsFile = $this->pluginInstallationFolder . $pluginName . DS . 'settings.php';
     if (!file_exists($settingsFile)) {
         $this->install($pluginName);
     }
     $configPath = Text::insert('Plugins/:plugin/settings', ['plugin' => $pluginName]);
     return Configure::load($configPath);
 }
Example #12
0
 public function __construct(ComponentRegistry $registry, array $config = [])
 {
     parent::__construct($registry, $config);
     if ($this->user('role')) {
         $this->role = $this->user('role');
     }
     if (!file_exists(CONFIG . "locker.php")) {
         throw new Exception(_('locker.php not found in config directory'));
     }
     //Load configuration directives for Locker
     $params = $this->request->params;
     Configure::load('locker');
     $this->roles = Configure::read('locker.roles');
     $this->controllers = Configure::read('locker.controllers');
     $path = "/{$params['controller']}/{$params['action']}";
     if (!empty($params['prefix'])) {
         $path = "/{$params['prefix']}" . $path;
     }
     if (!empty($params['plugin'])) {
         $path = "/{$params['plugin']}" . $path;
     }
     $base = strtolower($path);
     $exact = strtolower($path . '/' . implode('/', $params['pass']));
     $wildcard = strtolower($base . '/*');
     if ($this->role != 'public' && !in_array($this->role, $this->roles)) {
         throw new Exception(__('Your user role is not present in locker configuration'));
     }
     if (!empty($this->controllers[$exact])) {
         if ($this->check($exact)) {
             return $this->allow();
         }
         if ($this->user()) {
             throw new MethodNotAllowedException(sprintf(__("You do not have permission to access this area: %s"), $exact));
         }
         return;
     }
     if (!empty($this->controllers[$wildcard]) && !empty($params['pass'])) {
         if ($this->check($wildcard)) {
             return $this->allow();
         }
         if ($this->user()) {
             throw new MethodNotAllowedException(sprintf(__("You do not have permission to access this area: %s"), $wildcard));
         }
         return;
     }
     if (!empty($this->controllers[$base])) {
         if ($this->check($base)) {
             return $this->allow();
         }
         if ($this->user()) {
             throw new MethodNotAllowedException(sprintf(__("You do not have permission to access this area: %s"), $base));
         }
         return;
     }
     throw new Exception(__('Method is not present on locker.php configuration'));
 }
Example #13
0
 /**
  * @return void
  */
 public function initConfig()
 {
     // Local config without extra config file
     $conf = (array) Configure::read('Queue');
     // Fallback to Plugin config which can be overwritten via local app config.
     Configure::load('Queue.queue');
     $defaultConf = (array) Configure::read('Queue');
     $conf = array_merge($defaultConf, $conf);
     Configure::write('Queue', $conf);
 }
 /**
  * 初期化処理
  * beforeFilter()メソッドの前に呼び出される。
  *
  * @access public
  */
 public function initialize()
 {
     parent::initialize();
     // コンポーネント読み込み
     $this->loadComponent('Csrf');
     $this->loadComponent('Cookie');
     // 登録確認メールのURLを取得する
     Configure::config('default', new PhpConfig());
     Configure::load('app', 'default', false);
     $this->sendMailUrl = Configure::read('Email.default.addUserSendMailUrl');
 }
Example #15
0
 public function __construct()
 {
     if ($this->config === null) {
         $this->config = Configure::load('CakeD.config')['FTP'];
     }
     $this->instance = $this->getClient();
     if (!$this->dir_exists($this->config['directory']['root']) && $this->config['directory']['create']) {
         $this->mkdir($this->config['directory']['root']);
     }
     $this->cd($this->config['directory']['root']);
 }
Example #16
0
 /**
  * Loads the events config file for a plugin.
  *
  * @param $plugin
  * @return bool|mixed
  */
 public static function events($plugin)
 {
     $return = false;
     $config = static::$_plugins[$plugin];
     if ($config['events'] === true) {
         $return = static::_includeFile($config['configPath'] . Plugin::FILE_EVENTS, $config['ignoreMissing']);
         //  Load event configuration.
         Configure::load($plugin . '.' . Event::CONFIG_NAME);
     }
     return $return;
 }
 /**
  * Get all user's captcha configuration.
  *
  * @return array
  */
 public static function all()
 {
     // all default configs
     $configsWithoutCaptcha = Configure::read();
     // all default configs and captcha configs
     Configure::load('captcha');
     $configsWithCaptcha = Configure::read();
     // get only captcha configs
     $captchaConfigs = array_diff_key($configsWithCaptcha, $configsWithoutCaptcha);
     return $captchaConfigs;
 }
 /**
  * Initiaization
  *
  * @return void
  */
 public function initialize()
 {
     parent::initialize();
     $this->_pluginDocumentRoot = Plugin::path('AdaptiveImages') . 'webroot';
     //load config from ./config/ if exists
     if (file_exists(ROOT . DS . 'config' . DS . $this->_configFilename . '.php')) {
         Configure::load($this->_configFilename);
     } else {
         Configure::load('AdaptiveImages.' . $this->_configFilename);
     }
     $this->_configData = Configure::read('AdaptiveImagesPlugin');
     $this->Imagine = new Imagine();
 }
 /**
  * Instance getter for the UserRights instance
  *
  * @return UserRights
  */
 public function getUserRights()
 {
     if (!$this->_UserRights) {
         if (Configure::load('user_rights') === false) {
             trigger_error('UserRights: Could not load config/user_rights.php', E_USER_WARNING);
         }
         $rightsConfig = Configure::read('user_rights');
         if (!is_array($rightsConfig)) {
             $rightsConfig = [];
         }
         $this->_UserRights = new UserRights($rightsConfig);
     }
     return $this->_UserRights;
 }
Example #20
0
 /**
  *  Preliminary check for alternate/tmp file must be made 
  */
 public function __construct(array $properties, array $options)
 {
     parent::__construct($properties, $options);
     Configure::load('UploadManager.images', 'default');
     $this->tmpDirPath = Configure::read('Images.tmpStoragePath');
     $this->tmpDirFull = WWW_ROOT . $this->tmpDirPath;
     $tmpPath = $this->tmpDirPath . DS . $this->source() . '-' . $this->_properties['id'];
     $tmpPathFull = WWW_ROOT . $tmpPath;
     $tmp = new File($tmpPathFull);
     if ($tmp->exists()) {
         $this->tmpPath = $tmpPath;
         $this->tmpPathFull = $tmpPathFull;
     }
 }
 /**
  * Load config and retrieve permissions
  * If the configuration file does not exist, or the permissions key not present, return defaultPermissions
  * To be mocked
  *
  * @param string $key name of the configuration file to read permissions from
  * @return array permissions
  */
 protected function _loadPermissions($key)
 {
     try {
         Configure::load($key, 'default');
         $permissions = Configure::read('Users.SimpleRbac.permissions');
     } catch (Exception $ex) {
         $msg = __d('Users', 'Missing configuration file: "config/{0}.php". Using default permissions', $key);
         $this->log($msg, LogLevel::WARNING);
     }
     if (empty($permissions)) {
         return $this->_defaultPermissions;
     }
     return $permissions;
 }
Example #22
0
 public function __construct()
 {
     Configure::load('CakeD.config');
     $this->config = Configure::read('DROPBOX');
     if ($this->config['token'] === null) {
         throw new Exceptions\ConfigParamNotFound('Parameter token is null.');
     }
     if ($this->config['directory'] === null) {
         $this->config['directory'] = '';
     }
     if ($this->config['mode'] === null) {
         $this->config['mode'] = 'rw';
     }
     $this->instance = $this->getClient();
 }
Example #23
0
 /**
  * Checking the existence of a plugin and its connection.
  *
  * @param array $plugins
  */
 public static function load(array $plugins)
 {
     $paths = App::path('Plugin');
     foreach ($plugins as $plugin) {
         $isPlugin = false;
         if (CakePlugin::loaded($plugin)) {
             break;
         }
         foreach ($paths as $path) {
             $pluginPath = $path . $plugin . DS;
             if (is_dir($pluginPath)) {
                 $isPlugin = $pluginPath;
                 break;
             }
         }
         if ($pluginPath = $isPlugin) {
             $plgConfig = ['autoload' => true];
             //  Plugin config files.
             $plgBootstrap = $pluginPath . 'config' . DS . self::$_pluginsSrc['bootstrap'];
             $plgRoutes = $pluginPath . 'config' . DS . self::$_pluginsSrc['routes'];
             $plgEvents = $pluginPath . 'config' . DS . self::$_pluginsSrc['events'];
             if (file_exists($plgBootstrap)) {
                 $plgConfig['bootstrap'] = true;
             }
             if (file_exists($plgRoutes)) {
                 $plgConfig['routes'] = true;
             }
             CakePlugin::load($plugin, $plgConfig);
             if (CakePlugin::loaded($plugin)) {
                 Union::mergeConfig('App.paths.locales', [$pluginPath . 'src' . DS . 'Locale' . DS]);
                 if (file_exists($plgEvents)) {
                     Configure::load($plugin . '.events');
                 }
             }
         } else {
             throw new MissingPluginException(['plugin' => $plugin]);
         }
     }
 }
 /**
  * Checks for reCAPTCHA
  * @return bool
  * @see https://developers.google.com/recaptcha/docs/verify
  * @throws \Cake\Network\Exception\InternalErrorException
  */
 public function check()
 {
     //Loads the configuration file and gets the form keys
     Configure::load('recaptcha');
     $keys = Configure::read('Recaptcha.Form');
     //Checks for form keys
     if (empty($keys['public']) || empty($keys['private'])) {
         throw new InternalErrorException(__d('me_tools', 'Form keys are not configured'));
     }
     $controller = $this->_registry->getController();
     $response = $controller->request->data('g-recaptcha-response');
     if (empty($response)) {
         $this->error = __d('me_tools', 'You have not filled out the {0} control', 'reCAPTCHA');
         return false;
     }
     $results = (new Client())->post('https://www.google.com/recaptcha/api/siteverify', am(['remoteip' => $controller->request->clientIp(), 'secret' => $keys['private']], compact('response')));
     if (empty($results) || empty($results->json['success'])) {
         $this->error = __d('me_tools', 'It was not possible to verify the {0} control', 'reCAPTCHA');
         return false;
     }
     return true;
 }
 /**
  * Delete file on server represented by entity being deleted
  */
 public function beforeDelete(Event $event, Entity $entity, \ArrayObject $options)
 {
     Configure::load('UploadManager.uploads', 'default');
     $storagePath = Configure::read('Uploads.storagePath');
     $file = new File($entity->path);
     $folder = $file->Folder();
     // Check for empty directories on successful delete
     if ($file->delete()) {
         // Delete type folder if empty
         if (!$folder->find()) {
             $oldFolder = $folder;
             $folder->cd($folder->realpath($folder->pwd() . DS . '..'));
             $oldFolder->delete();
             // Check for other possible empty parent (owner storage)
             if ($folder->pwd() !== $storagePath) {
                 if (!$folder->find()) {
                     $folder->delete();
                 }
             }
         }
     } else {
         $event->stopPropagation();
     }
 }
Example #26
0
use Cake\Mailer\Email;
use Cake\Network\Request;
use Cake\Routing\DispatcherFactory;
use Cake\Utility\Inflector;
use Cake\Utility\Security;
/**
 * Read configuration file and inject configuration into various
 * CakePHP classes.
 *
 * By default there is only one configuration file. It is often a good
 * idea to create multiple configuration files, and separate the configuration
 * that changes from configuration that does not. This makes deployment simpler.
 */
try {
    Configure::config('default', new PhpConfig());
    Configure::load('app', 'default', false);
} catch (\Exception $e) {
    die($e->getMessage() . "\n");
}
// Load an environment local configuration file.
// You can use a file like app_local.php to provide local overrides to your
// shared configuration.
//Configure::load('app_local', 'default');
// When debug = false the metadata cache should last
// for a very very long time, as we don't want
// to refresh the cache while users are doing requests.
if (!Configure::read('debug')) {
    Configure::write('Cache._cake_model_.duration', '+1 years');
    Configure::write('Cache._cake_core_.duration', '+1 years');
}
/**
Example #27
0
 * Inflector::rules('uninflected', ['dontinflectme']);
 * Inflector::rules('transliteration', ['/å/' => 'aa']);
 */
/**
 * Plugins need to be loaded manually, you can either load them one by one or all of them in a single call
 * Uncomment one of the lines below, as you need. make sure you read the documentation on Plugin to use more
 * advanced ways of loading plugins
 *
 * Plugin::loadAll(); // Loads all plugins at once
 * Plugin::load('Migrations'); //Loads a single plugin named Migrations
 *
 */
Plugin::load('Migrations');
// Only try to load DebugKit in development mode
// Debug Kit should not be installed on a production system
if (Configure::read('debug')) {
    Plugin::load('DebugKit', ['bootstrap' => true]);
}
/**
 * Connect middleware/dispatcher filters.
 */
DispatcherFactory::add('Asset');
DispatcherFactory::add('Routing');
DispatcherFactory::add('ControllerFactory');
/**
 * Enable default locale format parsing.
 * This is needed for matching the auto-localized string output of Time() class when parsing dates.
 */
Type::build('datetime')->useLocaleParser();
Configure::load('raspicake');
Example #28
0
 * @copyright     Copyright (c) Frank Förster (http://frankfoerster.com)
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
use Cake\Cache\Cache;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Event\EventManager;
use Cake\Filesystem\Folder;
use Wasabi\Cms\Event\DispatcherListener;
use Wasabi\Cms\Event\MenuListener;
use Wasabi\Cms\Event\RouteListener;
use Wasabi\Cms\Event\ThemeListener;
use Wasabi\Cms\View\Module\ModuleManager;
try {
    // Load and apply the Wasabi Core cache config.
    Configure::load('Wasabi/Cms.cache', 'default');
    foreach (Configure::consume('Cache') as $key => $config) {
        new Folder($config['path'], true, 0775);
        Cache::config($key, $config);
    }
} catch (\Exception $e) {
    die($e->getMessage() . "\n");
}
// Configure plugin translation paths.
Configure::write('App.paths.locales', array_merge(Configure::read('App.paths.locales'), [Plugin::path('Wasabi/Cms') . 'src' . DS . 'Locale' . DS]));
// Register module path.
ModuleManager::registerModulePath(Plugin::path('Wasabi/Cms') . 'src' . DS . 'View' . DS . 'Module' . DS);
EventManager::instance()->on(new RouteListener());
EventManager::instance()->on(new ThemeListener());
EventManager::instance()->on(new DispatcherListener());
EventManager::instance()->on(new MenuListener());
Example #29
0
Plugin::load('Api', ['bootstrap' => true, 'routes' => true]);
Plugin::load('Monitor', ['bootstrap' => true, 'routes' => true]);
Configure::write('AssetCompress.rawMode', false);
if (ENVIRONMENT === Environments::DEVELOPMENT) {
    Configure::write('AssetCompress.rawMode', true);
}
// Only try to load DebugKit in development mode
// Debug Kit should not be installed on a production system
// if (Configure::read('debug')) {
//     Plugin::load('DebugKit', ['bootstrap' => true]);
//     Plugin::load('CakeBootstrap3');
// }
// Datasource Type Mappings
Type::map('json', 'CkTools\\Database\\Type\\JsonType');
// Load Additional Configs
Configure::load('CkTools.countries');
/**
 * Debug Logging Helper
 *
 * @return voidauth
 */
function dlog()
{
    $args = func_get_args();
    foreach ($args as $arg) {
        if (!is_string($arg)) {
            $arg = print_r($arg, true);
        }
        \Cake\Log\Log::write('debug', print_r($arg, true));
    }
}
Example #30
0
 /**
  * testLoad method
  *
  * @return void
  */
 public function testLoadPlugin()
 {
     Configure::config('test', new PhpConfig());
     Plugin::load('TestPlugin');
     $result = Configure::load('TestPlugin.load', 'test');
     $this->assertTrue($result);
     $expected = '/test_app/Plugin/TestPlugin/Config/load.php';
     $config = Configure::read('plugin_load');
     $this->assertEquals($expected, $config);
     $result = Configure::load('TestPlugin.more.load', 'test');
     $this->assertTrue($result);
     $expected = '/test_app/Plugin/TestPlugin/Config/more.load.php';
     $config = Configure::read('plugin_more_load');
     $this->assertEquals($expected, $config);
     Plugin::unload();
 }