Commit 5b3c777f authored by Marcello Pivanti's avatar Marcello Pivanti
Browse files

Open20 version

parents
require 'yaml'
require 'fileutils'
required_plugins = %w( vagrant-hostmanager vagrant-vbguest )
required_plugins.each do |plugin|
exec "vagrant plugin install #{plugin}" unless Vagrant.has_plugin? plugin
end
domains = {
frontend: 'y2aa-frontend.dev',
backend: 'y2aa-backend.dev'
}
config = {
local: './vagrant/config/vagrant-local.yml',
example: './vagrant/config/vagrant-local.example.yml'
}
# copy config from example if local config not exists
FileUtils.cp config[:example], config[:local] unless File.exist?(config[:local])
# read config
options = YAML.load_file config[:local]
# check github token
if options['github_token'].nil? || options['github_token'].to_s.length != 40
puts "You must place REAL GitHub token into configuration:\n/yii2-app-advanced/vagrant/config/vagrant-local.yml"
exit
end
# vagrant configurate
Vagrant.configure(2) do |config|
# select the box
config.vm.box = 'bento/ubuntu-16.04'
# should we ask about box updates?
config.vm.box_check_update = options['box_check_update']
config.vm.provider 'virtualbox' do |vb|
# machine cpus count
vb.cpus = options['cpus']
# machine memory size
vb.memory = options['memory']
# machine name (for VirtualBox UI)
vb.name = options['machine_name']
end
# machine name (for vagrant console)
config.vm.define options['machine_name']
# machine name (for guest machine console)
config.vm.hostname = options['machine_name']
# network settings
config.vm.network 'private_network', ip: options['ip']
# sync: folder 'yii2-app-advanced' (host machine) -> folder '/app' (guest machine)
config.vm.synced_folder './', '/app', owner: 'vagrant', group: 'vagrant'
# disable folder '/vagrant' (guest machine)
config.vm.synced_folder '.', '/vagrant', disabled: true
# hosts settings (host machine)
config.vm.provision :hostmanager
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.ignore_private_ip = false
config.hostmanager.include_offline = true
config.hostmanager.aliases = domains.values
# provisioners
config.vm.provision 'shell', path: './vagrant/provision/once-as-root.sh', args: [options['timezone']]
config.vm.provision 'shell', path: './vagrant/provision/once-as-vagrant.sh', args: [options['github_token']], privileged: false
config.vm.provision 'shell', path: './vagrant/provision/always-as-root.sh', run: 'always'
# post-install message (vagrant console)
config.vm.post_up_message = "Frontend URL: http://#{domains[:frontend]}\nBackend URL: http://#{domains[:backend]}"
end
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
* @package arter\amos\basic\template
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace backend\assets;
use yii\web\AssetBundle;
/**
* Class AppAsset
* Main backend application asset bundle.
* @package backend\assets
*/
class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
];
public $js = [
];
public $depends = [
'yii\web\YiiAsset',
];
public function init()
{
$moduleL = \Yii::$app->getModule('layout');
if (!empty($moduleL)) {
$this->depends [] = 'arter\amos\layout\assets\BaseAsset';
} else {
$this->depends [] = 'arter\amos\core\views\assets\AmosCoreAsset';
}
parent::init();
}
}
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
* @package arter\amos\basic\template
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace backend\bootstrap;
/*
* To change this proscription header, choose Proscription Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
use Yii;
use yii\base\Application;
/**
* Class AssignRolesAdmin: <br />
* Assign administration roles to user ADMIN <br />
* ELIGIBLE FOR DEPRECATION (DEPRECATED)
* @package backend\bootstrap
*/
class AssignRolesAdmin extends \yii\base\Component {
private $_startTime;
/**
* Application-specific roles initialization
* @uses onApplicationAction
*/
public function init() {
parent::init();
\Yii::$app->on(Application::EVENT_BEFORE_ACTION, [$this, 'onApplicationAction']);
}
/**
* Application-specific roles initialization
*/
public function onApplicationAction($event) {
$actionId = $event->action->uniqueId;
$authManager = Yii::$app->authManager;
$roles = $authManager->getRoles();
$children = $authManager->getChildren('ADMIN');
$adminRole = $authManager->getRole('ADMIN');
foreach ($roles as $key => $value) {
if ($key != 'ADMIN' && !isset($children[$key]) && !in_array($key, ['AMMINISTRATORE_CWH'])) { // TODO translate
$ruolo = $authManager->getRole($key);
$authManager->addChild($adminRole, $value);
}
}
}
}
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
* @package arter\amos\basic\template
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace backend\components;
use yii\base\BootstrapInterface;
/**
* Multi-language support
* @package backend\components
*/
class LanguageSelector implements BootstrapInterface
{
/**
* Supported-languages array
* @var array
*/
public $supportedLanguages = [];
/**
* Bootstrap for multi-language support
* @param \yii\base\Application $app
*/
public function bootstrap($app)
{
$preferredLanguage = isset($app->request->cookies['language']) ? (string)$app->request->cookies['language'] : null;
// or in case of database:
// $preferredLanguage = $app->user->language;
if (empty($preferredLanguage)) {
$preferredLanguage = $app->request->getPreferredLanguage($this->supportedLanguages);
}
$app->language = $preferredLanguage;
}
}
main-local.php
params-local.php
test-local.php
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
* @package arter\amos\basic\template
* @category CategoryName
* @author Elite Division S.r.l.
*/
$bootstrap = [];
$bootstrap[] = 'translatemanager';
$bootstrap[] = [
'class' => 'arter\amos\core\components\LanguageSelector',
'supportedLanguages' => ['en-GB', 'it-IT'],
'allowedIPs' => ['*']
];
$bootstrap[] = 'arter\amos\core\bootstrap\Breadcrumb';
$bootstrap[] = 'workflow';
$bootstrap[] = 'notify';
$bootstrap[] = 'comments';
$bootstrap[] = 'layout';
$bootstrap[] = 'socialauth';
return $bootstrap;
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
* @package arter\amos\basic\template
* @category CategoryName
* @author Elite Division S.r.l.
*/
return [
'view' => [
'class' => 'arter\amos\core\components\AmosView',
],
];
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
* @package arter\amos\basic\template
* @category CategoryName
* @author Elite Division S.r.l.
*/
return [
'errorHandler' => [
'errorAction' => 'site/error',
],
'eventSequence' => [
'class' => '\raoul2000\workflow\events\BasicEventSequence',
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
'logVars' => ['_SERVER'],
],
],
],
'request' => [
'csrfParam' => '_csrf-backend',
'enableCookieValidation' => false,
],
'session' => [
// this is the name of the session cookie used for login on the backend
'name' => 'advanced-backend',
],
'user' => [
'class' => 'arter\amos\core\user\AmosUser',
'identityClass' => 'arter\amos\core\user\User',
'loginUrl' => '/admin/security/login',
'enableAutoLogin' => true,
'identityCookie' => [
'name' => '_identity-backend',
'httpOnly' => true,
'secure' => true
],
],
'socialShare' => [
'class' => \arter\amos\core\components\ConfiguratorSocialShare::class,
],
];
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
* @package arter\amos\basic\template
* @category CategoryName
* @author Elite Division S.r.l.
*/
$common = require(__DIR__ . '/../../common/config/main.php');
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$modules = array_merge(
$common['modules'],
require(__DIR__ . '/modules-others.php'),
require(__DIR__ . '/modules-amos.php')
);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// TODO verificare che non ci siano index che non caricano bootstrap, in caso non ce ne siano, questa va eliminata
$bootstrap = array_merge(
$common['bootstrap'],
require(__DIR__ . '/bootstrap.php')
);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$components = array_merge(
$common['components'],
require(__DIR__ . '/components-others.php'),
require(__DIR__ . '/components-amos.php')
);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$params = array_merge(
$common['params'],
require(__DIR__ . '/params.php'),
require(__DIR__ . '/params-local.php')
);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (isset($modules['chat'])) {
$bootstrap[] = 'chat';
}
if ($params['template-amos'] === true) {
$bootstrap[] = 'backend\bootstrap\AssignRolesAdmin';
}
if (isset($modules['tag'])) {
if (isset($modules['community'])) {
$modules['tag']['modelsEnabled'][] = 'arter\amos\community\models\Community';
}
if (isset($modules['discussioni'])) {
$modules['tag']['modelsEnabled'][] = 'arter\amos\discussioni\models\DiscussioniTopic';
}
if (isset($modules['documenti'])) {
$modules['tag']['modelsEnabled'][] = 'arter\amos\documenti\models\Documenti';
}
if (isset($modules['news'])) {
$modules['tag']['modelsEnabled'][] = 'arter\amos\news\models\News';
}
if (isset($modules['organizzazioni'])) {
$modules['tag']['modelsEnabled'][] = 'arter\amos\organizzazioni\models\Profilo';
$modules['tag']['modelsEnabled'][] = 'arter\amos\organizzazioni\models\ProfiloSedi';
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
return [
'as access' => [
'class' => 'mdm\admin\components\AccessControl',
'allowActions' => [
'*',
'/build/'
],
],
'basePath' => dirname(__DIR__),
'controllerNamespace' => 'backend\controllers',
'defaultRoute' => '/admin/security/login',
'homeUrl' => '/dashboard',
'id' => 'app-backend',
'name' => 'Amos Basic Template',
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
'bootstrap' => $bootstrap,
'components' => $components,
'modules' => $modules,
'params' => $params,
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
];
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
* @package arter\amos\basic\template
* @category CategoryName
* @author Elite Division S.r.l.
*/
$modules = [
'amministra-utenti' => [
'class' => 'arter\amos\admin\RoleManager',
'layout' => "@vendor/arter/amos-core/views/layouts/admin",
//'left-menu', // it can be '@path/to/your/layout'.
'controllerMap' => [
'assignment' => [
'class' => 'mdm\admin\controllers\AssignmentController',
'userClassName' => 'common\models\User',
'idField' => 'id'
],
],
'menus' => [
'assignment' => [
'label' => 'Gestisci Assegnazioni' // TODO translate
],
]
],
'comuni' => [
'class' => 'arter\amos\comuni\AmosComuni',
],
'dashboard' => [
'class' => 'arter\amos\dashboard\AmosDashboard',
],
'layout' => [
'class' => 'arter\amos\layout\Module',
],
'myactivities' => [
'class' => 'arter\amos\myactivities\AmosMyActivities',
],
'privileges' => [
'class' => 'arter\amos\privileges\AmosPrivileges',
],
'upload' => [
'class' => 'arter\amos\upload\AmosUpload',
],
'workflow' => [
'class' => 'arter\amos\workflow\AmosWorkflow',
],
];
return $modules;
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
* @package arter\amos\basic\template
* @category CategoryName
* @author Elite Division S.r.l.
*/
use kartik\datecontrol\Module;
return [
'audit' => [
'class' => 'arter\amos\audit\Audit',
'db' => 'db',
'accessRoles' => ['ADMIN'],
'ignoreActions' => [
'debug/*',
'ajax/*',
'audit/*',
'site/login',
'admin/user-profile/cambia-password',
'site/inserisci-dati-autenticazione',
'site/insert-auth-data',
],
//This avoid all post data in audit
/*'panels' => [
'audit/request' => [
'ignoreKeys' => ['POST', 'requestBody'],
],
],*/
],
'datecontrol' => [
'class' => 'kartik\datecontrol\Module',
'displaySettings' => [
Module::FORMAT_DATE => 'dd-MM-yyyy',
Module::FORMAT_TIME => 'HH:mm',
Module::FORMAT_DATETIME => 'php:d-m-Y H:i',
],
// format settings for saving each date attribute (PHP format example)
'saveSettings' => [
Module::FORMAT_DATE => 'php:Y-m-d', // saves as unix timestamp
Module::FORMAT_TIME => 'php:H:i:s',
Module::FORMAT_DATETIME => 'php:Y-m-d H:i:s',
],
// set your display timezone
'displayTimezone' => 'Europe/Rome',
// set your timezone for date saved to db
'saveTimezone' => 'Europe/Rome',
'autoWidgetSettings' => [
Module::FORMAT_DATE => ['type' => 2, 'pluginOptions' => ['autoclose' => true]], // example
//Module::FORMAT_TIME => 'php:H:i:s',
//Module::FORMAT_DATETIME => 'php:Y-m-d H:i:s',
],
'widgetSettings' => [
Module::FORMAT_DATE => [
'class' => 'yii\widgets\MaskedInput', // example
'options' => [
'mask' => '99/99/9999',
'options' => ['class' => 'form-control'],
]
]
]
],
'gridview' => [
'class' => '\kartik\grid\Module'
],
'social' => [
// the module class
'class' => 'kartik\social\Module',
// the global settings for the google analytic plugin widget
'googleAnalytics' => [
'id' => 'UA-88133453-2',
'domain' => 'appdemoweb.org',
],
],
/****************DO NOT REMOVE****************/
];
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
* @package arter\amos\basic\template
* @category CategoryName
* @author Elite Division S.r.l.
*/
return [
'email-assistenza' => 'help@example.com',
'icon-framework' => 'am',
'googleMapsLibraries'=> null,
'googleMapsLanguage' =>'en',
// Enable Amos Exclusive features
'template-amos' => FALSE,
// Enable template slideshow
'slideshow' => TRUE,
'slideshow-label' => 'Mostra introduzione', // TODO translate and amos-XXX::[t()|tHtml()] ?
// Enable Localization menu
'languageSelector' => TRUE,
'allLanguages' => ['Italiano' => 'it-IT', 'English' => 'en-GB'],
//enable btn dashboard to frontend
'toFrontendLink' => false,
//diable wizard in create content models (News, Documents, Discussions)
'noWizardNewLayout' => true,
];
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
* @package arter
* @category CategoryName
* @author Elite Division S.r.l.
*/
return [
'id' => 'app-backend-tests',
'components' => [
'assetManager' => [
'basePath' => __DIR__ . '/../web/assets',
],
'urlManager' => [
'showScriptName' => true,
],
],
];
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
* @package arter\amos\basic\template
* @category CategoryName
* @author Elite Division S.r.l.
*/