Commit 1e8c022f authored by Daniele's avatar Daniele
Browse files

Asterized

parent c9370443
The Yii framework is free software. It is released under the terms of
the following BSD License.
Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyleft
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyleft
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of Yii Software LLC nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYLEFT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYLEFT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
# AMOS Basic Template
`by EliteDivision`
AMOS Basic Template
===============================
This is a skeleton based on [Yii 2 Template](http://www.yiiframework.com/)
The template includes three tiers: front end, back end, and console, each of which is a separate Yii application.
The template is designed to work in a team development environment. It supports deploying the application in different environments.
`by arter`
## Platform requirements
### Hardware
#### Minimum
- STORAGE 200 GB.
- RAM 8GB
- CPU 4 Core
#### Recommended
- STORAGE 500 GB.
- RAM 16GB
- CPU 8 Core
This is a skeleton based on [Yii 2 Template](http://www.yiiframework.com/)
### Software
- Debian >= 8, CentOS >= 7
- Apache >= 2.4.29
- Php 7.0.X
- MariaDB 10.2.X / MySQL 5.7.X
- [Composer Dependency Manager](https://www.yiiframework.com/doc/guide/2.0/en/start-installation#installing-composer)
The template includes three tiers: front end, back end, and console, each of which
is a separate Yii application.
#### Required Apache/Lighttpd extensions
access_compat, alias, auth, autoindex, deflate, dir, env, filter, mime, mpm_prefork, negotiation, php7.0, reqtimeout, rewrite, setenvif, status
The template is designed to work in a team development environment. It supports
deploying the application in different environments.
#### Required PHP extensions
apc, bcmath, ctype, curl, dom, exif, fileinfo, ftp, gd, gettext, iconv, imagick, intl, json, mbstring, mcrypt, mysqli, opcache, pdo, pdo_mysql, posix, soap, ssl, xml, xsl, zip
Documentation is at [docs/guide/README.md](docs/guide/README.md).
#### Required MySQL Options
In file `my.ini` in Windows or `my.cnf` in Linux, from the clause **sql-mode** *remove* options `STRICT_TRANS_TABLES`and `ONLY_FULL_GROUP_BY`
to set it as follows
```
[mysql]
sql_mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
```
DIRECTORY STRUCTURE
-------------------
## DIRECTORY STRUCTURE
```
common
config/ contains shared configurations
......@@ -74,84 +49,3 @@ environments/ contains environment-based overrides
tests contains various tests for the advanced application
codeception/ contains tests developed with Codeception PHP Testing Framework
```
## Platform configuration/initialization
Please select the environment you want to configure the platform with, follows the default
- Development
- Production
Nowadays main differences between default environments are:
|Feature | Developments | Production |
|-|-|-|
| [Gii](https://www.yiiframework.com/doc/guide/2.0/en/start-gii) | Enabled | Not Enabled |
| [Debug](https://www.yiiframework.com/extension/yiisoft/yii2-debug/doc/guide/2.0/en/installation) | Enabled | Not Enabled |
| [Cache](https://www.yiiframework.com/doc/guide/2.0/en/caching-data) | [Dummycache](https://www.yiiframework.com/doc/api/2.0/yii-caching-dummycache) | [File cache](https://www.yiiframework.com/doc/api/2.0/yii-caching-filecache)|
| [Mailer](https://www.yiiframework.com/doc/guide/2.0/en/tutorial-mailing) | [Mail to file](https://www.yiiframework.com/doc/api/2.0/yii-mail-basemailer#$useFileTransport-detail) | Send mail |
Default environments can be copied or modified as needed.
Each new environment needs an entry into file "*environments/index.php*" to allow the init system to use it, and should be as follows
```
'ENVIRONMENT_NAME_HERE' => [
'path' => 'ENVIRONMENT_DIRECTORY_HERE',
'setWritable' => [
'backend/runtime',
'backend/web/assets',
'common/uploads',
'common/uploads/store',
'common/uploads/temp',
'frontend/runtime',
'frontend/web/assets',
],
'setExecutable' => [
'yii',
'tests/codeception/bin/yii',
],
'setCookieValidationKey' => [
'backend/config/main-local.php',
'frontend/config/main-local.php',
],
],
```
Please substitute the placeholders `ENVIRONMENT_NAME_HERE`, `ENVIRONMENT_DIRECTORY_HERE` with proper strings.
### Database
Before to install the platform, please create the database that will be layed at the base of it, e.g.
```
# mysql -u DB_USERNAME_HERE -pDB_PASSWORD_HERE -e "CREATE DATABASE
\`DB_NAME_HERE\` COLLATE 'utf8_general_ci';"
```
Then configure the [database connection](https://www.yiiframework.com/doc/guide/2.0/en/start-databases) into file "*environments/ENVIRONMENT_DIRECTORY_HERE/common/config/main-local.php*" as follows
```
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=DB_NAME_HERE',
'username' => 'DB_USERNAME_HERE',
'password' => 'DB_PASSWORD_HERE',
'charset' => 'utf8',
],
]
```
Obviuosly into the file path put the directory where your selected environments is (prod, test, dev, demo, new1, etc.)
and substitute the placeholders `DB_NAME_HERE`, `DB_USERNAME_HERE`, `DB_PASSWORD_HERE` with proper strings.
### Environment initialization
Once the environment to be used is properly configured, run the following command to apply configurations to platform
```
# php init
```
### Packages depandency management
Run the following command to download all the required packages
```
# composer update
```
### Database migration
Run the following command to create tables and views into database, and fill it up with basic data
```
# php yii migrate
```
### Start up account
After installation, the only accout available into the platform is an administrative account having
`username`: demo
`password`: Demo123!
Please change it after first login.
File mode changed from 100755 to 100644
<?php
/**
* Copyright 2020 Art-ER S. Cons. P.A.
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
*
* @package Open20Package
* @category CategoryName
*/
/**
*/
namespace backend\actions;
class ErrorAction extends \yii\web\ErrorAction
{
const ASSISTENZA_MODULE = 0;
const ASSISTENZA_PLATFORM_URL = 1;
const ASSISTENZA_PLATFORM_MAIL = 2;
public $errors_managed = ['404', '403', '500'];
public $mailAddress;
function run()
{
$exception = \Yii::$app->errorHandler->exception;
if (in_array($exception->statusCode, $this->errors_managed)) {
return $this->controller->render("error$exception->statusCode", ['exception' => $exception],['assistance' => $this->assistanceType()],['mailAddress' => $this->mailAddress]);
} else {
return $this->controller->render('error', ['exception' => $exception],['assistance' => $this->assistanceType()],['mailAddress' => $this->mailAddress]);
}
}
function assistanceType()
{
//Pickup assistance params
$assistance = isset(\Yii::$app->params['assistance']) ? \Yii::$app->params['assistance'] : [];
//Check if is in email mode
$isMail = ((isset($assistance['type']) && $assistance['type'] == 'email') || (!isset($assistance['type']) && isset(\Yii::$app->params['email-assistenza']))) ? true : false;
$this->mailAddress = isset($assistance['email']) ? $assistance['email'] : (isset(\Yii::$app->params['email-assistenza']) ? \Yii::$app->params['email-assistenza'] : '');
if (isset(\Yii::$app->params['assistance-url'])) {
return (self::ASSISTENZA_MODULE);
} elseif (isset(\Yii::$app->modules['assistance-request'])) {
return (self::ASSISTENZA_PLATFORM_URL);
}
if ((isset($assistance['enabled']) && $assistance['enabled']) || (!isset($assistance['enabled']) && isset(\Yii::$app->params['email-assistenza']))) {
return (self::ASSISTENZA_PLATFORM_MAIL);
}
return '';
}
}
\ No newline at end of file
<?php
/**
* Copyright 2020 Art-ER S. Cons. P.A.
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package backend\assets
* @package arter\amos\basic\template
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace backend\assets;
......@@ -44,4 +41,4 @@ class AppAsset extends AssetBundle
}
parent::init();
}
}
}
\ No newline at end of file
<?php
/**
* Copyright 2020 Art-ER S. Cons. P.A.
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package backend\bootstrap
* @package arter\amos\basic\template
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace backend\bootstrap;
......
namespace: backend\tests
actor: Tester
paths:
tests: tests
log: tests/_output
data: tests/_data
helpers: tests/_support
settings:
bootstrap: _bootstrap.php
colors: true
memory_limit: 1024M
modules:
config:
Yii2:
configFile: 'config/test-local.php'
<?php
/**
* Copyright 2020 Art-ER S. Cons. P.A.
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package backend\components
* @package arter\amos\basic\template
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace backend\components;
......@@ -45,4 +42,4 @@ class LanguageSelector implements BootstrapInterface
$app->language = $preferredLanguage;
}
}
}
\ No newline at end of file
File mode changed from 100755 to 100644
<?php
/**
* Copyright 2020 Art-ER S. Cons. P.A.
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package backend\config
* @package arter\amos\basic\template
* @category CategoryName
* @author Elite Division S.r.l.
*/
$bootstrap = [];
......@@ -28,6 +25,5 @@ $bootstrap[] = 'workflow';
$bootstrap[] = 'notify';
$bootstrap[] = 'comments';
$bootstrap[] = 'layout';
$bootstrap[] = 'socialauth';
return $bootstrap;
<?php
/**
* Copyright 2020 Art-ER S. Cons. P.A.
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package backend\config
* @package arter\amos\basic\template
* @category CategoryName
* @author Elite Division S.r.l.
*/
return [
......
......@@ -4,18 +4,15 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package backend\config
* @package arter\amos\basic\template
* @category CategoryName
* @author Elite Division S.r.l.
*/
return [
'errorHandler' => [
'errorAction' => 'site/error',
],
'errorAction' => 'error/error',
// 'errorAction' => 'layout/error/error', questa versione richiede layout: test/1.4.0
],
'eventSequence' => [
'class' => '\raoul2000\workflow\events\BasicEventSequence',
],
......
<?php
/**
* Copyright 2020 Art-ER S. Cons. P.A.
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package backend\config
* @package arter\amos\basic\template
* @category CategoryName
* @author Elite Division S.r.l.
*/
$common = require(__DIR__ . '/../../common/config/main.php');
......@@ -62,6 +59,9 @@ if (isset($modules['tag'])) {
if (isset($modules['documenti'])) {
$modules['tag']['modelsEnabled'][] = 'arter\amos\documenti\models\Documenti';
}
if (isset($modules['events'])) {
$modules['tag']['modelsEnabled'][] = 'arter\amos\events\models\Event';
}
if (isset($modules['news'])) {
$modules['tag']['modelsEnabled'][] = 'arter\amos\news\models\News';
}
......@@ -85,7 +85,6 @@ return [
'defaultRoute' => '/admin/security/login',
'homeUrl' => '/dashboard',
'id' => 'app-backend',
'name' => 'Amos Basic Template',
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
'bootstrap' => $bootstrap,
'components' => $components,
......
<?php
/**
* Copyright 2020 Art-ER S. Cons. P.A.
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package backend\config
* @package arter\amos\basic\template
* @category CategoryName
* @author Elite Division S.r.l.
*/
$modules = [
......@@ -49,9 +46,12 @@ $modules = [
'upload' => [
'class' => 'arter\amos\upload\AmosUpload',
],
'utility' => [
'class' => 'arter\amos\utility\Module'
],
'workflow' => [
'class' => 'arter\amos\workflow\AmosWorkflow',
],
];
return $modules;
return $modules;
\ No newline at end of file
<?php
/**
* Copyright 2020 Art-ER S. Cons. P.A.
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package backend\config
* @package arter\amos\basic\template
* @category CategoryName
* @author Elite Division S.r.l.
*/
use kartik\datecontrol\Module;
return [
'audit' => [
// 'class' => 'bedezign\yii2\audit\Audit',
'class' => 'arter\amos\audit\Audit',
'db' => 'db',
'accessRoles' => ['ADMIN'],
'batchSave' => false,
'ignoreActions' => [
'debug/*',
'ajax/*',
......@@ -29,6 +28,7 @@ return [
'site/inserisci-dati-autenticazione',
'site/insert-auth-data',
],
'skipActions' => ['GET'],
//This avoid all post data in audit
/*'panels' => [
'audit/request' => [
......
<?php
/**
* Copyright 2020 Art-ER S. Cons. P.A.
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package backend\config
* @package arter\amos\basic\template
* @category CategoryName
* @author Elite Division S.r.l.
*/
return [
......
<?php
/**
* Copyright 2020 Art-ER S. Cons. P.A.
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package backend\config
* @package Open20Package
* @category CategoryName
* @author Elite Division S.r.l.
*/
return [
'id' => 'app-backend-tests',
'components' => [
......
<?php
/**
* Copyright 2020 Art-ER S. Cons. P.A.
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package backend\config
* @package arter\amos\basic\template
* @category CategoryName
* @author Elite Division S.r.l.
*/
/**
......@@ -32,4 +29,4 @@ return array(
'/messages',
'/web/js',
),
);
);
\ No newline at end of file
<?php
/**
* Copyright 2020 Art-ER S. Cons. P.A.
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
*
* @package Open20Package
* @category CategoryName
*/
/**
*/
namespace backend\controllers;
use common\models\FirstAccessForm;
use common\models\ForgotPasswordForm;
use common\models\LoginForm;
use common\models\User;
use arter\amos\admin\models\UserProfile;
use Yii;
use yii\base\Model;
use yii\db\ActiveRecord;
use yii\filters\AccessControl;
use yii\filters\VerbFilter;
use \yii\helpers\Url;
use yii\web\Controller;
use yii\web\Cookie;
class ErrorController extends Controller
{
public function behaviors() {
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => [
'error',
'error404',
'error403',
'error500',
],
'allow' => true,
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
//'logout' => ['post'],
],
],
];
}
public function actions() {
$this->layout = '@vendor/arter/amos-layout/src/views/layouts/main';
return [
'error' => [
'class' => 'backend\actions\ErrorAction',
],
];
}
}
\ No newline at end of file