167 lines
		
	
	
		
			6.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			167 lines
		
	
	
		
			6.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| <?php
 | ||
| 
 | ||
| $config = [
 | ||
|     'id' => 'skillparts',
 | ||
|     'basePath' => dirname(__DIR__),
 | ||
|     'bootstrap' => ['log'],
 | ||
|     'defaultRoute' => 'main',
 | ||
|     'aliases' => [
 | ||
|         '@vendor'       => dirname(__DIR__) . '/../../../vendor',
 | ||
|         '@bower'        => '@vendor/bower-asset',
 | ||
|         '@npm'          => '@vendor/npm-asset'
 | ||
|     ],
 | ||
|     'components' => [
 | ||
|         'request' => [
 | ||
|             // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
 | ||
|             'cookieValidationKey' => '',
 | ||
|             'baseUrl' => ''
 | ||
|         ],
 | ||
|         'cache' => [
 | ||
|             'class' => 'yii\caching\FileCache',
 | ||
|         ],
 | ||
|         'user' => [
 | ||
|             'identityClass'     => 'app\models\Account',
 | ||
|             'loginUrl'          => ['/authentication'],
 | ||
|             // 'enableAutoLogin'     => true,
 | ||
|             'enableSession'     => true
 | ||
|         ],
 | ||
|         // 'authManager' => [
 | ||
|         //     'class' => 'mirzaev\yii2\arangodb\rbac\DbManager',
 | ||
|         // ],
 | ||
|         'session' => [
 | ||
|             'class' => 'mirzaev\yii2\arangodb\sessions\ArangoDbSession',
 | ||
|             'document' => 'session',
 | ||
|             'cookieParams' => [
 | ||
|                 // 'lifetime' => 3600 * 24 * 30 * 12
 | ||
|                 'lifetime' => 3600 * 24 * 3
 | ||
|             ],
 | ||
|             'writeCallback' => function($session): array {
 | ||
|                 // Инициализация
 | ||
|                 $data = [];
 | ||
| 
 | ||
|                 yii::$app->request->userIP and $data['ip'] = yii::$app->request->userIP;
 | ||
|                 Yii::$app->user->id and $data['account'] = Yii::$app->user->id;
 | ||
| 
 | ||
|                 return $data ?? [];
 | ||
|             },
 | ||
|             'timeout' => 3600 * 24 * 3,
 | ||
|             'useStrictMode' => false,
 | ||
|             'useCookies' => true
 | ||
|         ],
 | ||
|         'errorHandler' => [
 | ||
|             'errorAction' => 'error',
 | ||
|         ],
 | ||
|         'mailer' => [
 | ||
|             'class' => 'yii\swiftmailer\Mailer',
 | ||
|             // send all mails to a file by default. You have to set
 | ||
|             // 'useFileTransport' to false and configure a transport
 | ||
|             // for the mailer to send real emails.
 | ||
|             'useFileTransport' => true,
 | ||
|         ],
 | ||
|         'log' => [
 | ||
|             'traceLevel' => YII_DEBUG ? 3 : 0,
 | ||
|             'targets' => [
 | ||
|                 [
 | ||
|                     'class' => 'yii\log\FileTarget',
 | ||
|                     'levels' => ['error', 'warning'],
 | ||
|                 ],
 | ||
|             ],
 | ||
|         ],
 | ||
|         'arangodb' => require __DIR__ . '/db.php',
 | ||
|         'urlManager' => [
 | ||
|             'enablePrettyUrl'   => true,
 | ||
|             'showScriptName'    => false,
 | ||
|             'rules' => [
 | ||
|                 [
 | ||
|                     'class' => 'yii\rest\UrlRule',
 | ||
|                     'controller' => 'main'
 | ||
|                 ],
 | ||
|                 'product/<catn:[^/]+>' => 'product/index',
 | ||
|                 '<section:(product|cart)>/<catn:[^/]+>/<action:(read|write|edit|delete)>/<target:(title|catn|dscr|dmns|wght|image|cover|comm)>' => '<section>/<action>-<target>',
 | ||
|                 'orders' => 'order/index',
 | ||
|                 'orders/<_key:[^/]+>/<action:(accept)>' => 'order/<action>',
 | ||
|                 'orders/supply/<_key:[^/]+>/<action:(read|write|edit|delete)>' => 'order/supply-<action>',
 | ||
|                 'orders/supply/<_key:[^/]+>/<action:(read|write|edit|delete)>/<target:(stts|cost|time|comm)>' => 'order/supply-<action>-<target>',
 | ||
|                 'invoices/<order:[^/]+>' => 'invoice/index',
 | ||
|                 'invoices/<order:[^/]+>/<action:(download)>' => 'invoice/<action>'
 | ||
|             ],
 | ||
|         ],
 | ||
| 
 | ||
|     ],
 | ||
|     'modules' => [
 | ||
|         'exchange' => [
 | ||
|             'class' => 'carono\exchange1c\ExchangeModule',
 | ||
|             'exchangeDocuments' => true,
 | ||
|             'validateModelOnSave' => true,
 | ||
|             'groupClass' => 'app\models\SupplyGroup',
 | ||
|             'productClass' => 'app\models\Supply',
 | ||
|             'offerClass' => 'app\models\SupplyEdgeProduct',
 | ||
|             'partnerClass' => 'app\models\Account',
 | ||
|             'documentClass' => 'app\models\Order',
 | ||
|             'auth' => function ($mail, $pswd) {
 | ||
|                 // Необходимо уничтожить AccountForm
 | ||
|                 // return (new \app\models\AccountForm())->authentication($mail, $pswd);
 | ||
| 
 | ||
|                 if ($user = \app\models\Account::findByMail($mail)) {
 | ||
|                     if ($user->validatePassword($pswd)) {
 | ||
|                         return $user;
 | ||
|                     }
 | ||
|                 }
 | ||
|                 return false;
 | ||
|             }
 | ||
|         ]
 | ||
|     ],
 | ||
|     'params' => require __DIR__ . '/params.php',
 | ||
|     'on beforeAction' => function ($event) {
 | ||
|         if (
 | ||
|             !yii::$app->user->isGuest
 | ||
|             && (yii::$app->request->getPathInfo() !== 'offer'
 | ||
|                 && yii::$app->request->getPathInfo() !== 'offer/suppliers'
 | ||
|                 && yii::$app->request->getPathInfo() !== 'offer/accept'
 | ||
|                 && yii::$app->request->getPathInfo() !== 'offer/accept-suppliers'
 | ||
|                 && yii::$app->request->getPathInfo() !== 'notification'
 | ||
|                 && yii::$app->request->getPathInfo() !== 'identification')
 | ||
|         ) {
 | ||
|             // Нет соглашения с офертой
 | ||
| 
 | ||
|             if (
 | ||
|                 !(isset(yii::$app->session['offer_buyer_accepted'])
 | ||
|                     && yii::$app->session['offer_buyer_accepted'] === true)
 | ||
|                 && (!isset(yii::$app->user->identity->acpt['buyer'])
 | ||
|                     || yii::$app->user->identity->acpt['buyer'] === false)
 | ||
|             ) {
 | ||
|                 // Нет подтверждения офферты пользователя
 | ||
| 
 | ||
|                 // Переадресация на оферту
 | ||
|                 yii::$app->response->redirect('/offer')->send();
 | ||
|             } else if (
 | ||
|                 (isset(yii::$app->user->identity->agnt)
 | ||
|                     && yii::$app->user->identity->agnt === true)
 | ||
|                 && !(isset(yii::$app->session['offer_supplier_accepted'])
 | ||
|                     && yii::$app->session['offer_supplier_accepted'] === true)
 | ||
|                 && (!isset(yii::$app->user->identity->acpt['supplier'])
 | ||
|                     || yii::$app->user->identity->acpt['supplier'] === false)
 | ||
|             ) {
 | ||
|                 // Нет подтверждения офферты поставщика
 | ||
| 
 | ||
|                 // Переадресация на оферту
 | ||
|                 yii::$app->response->redirect('/offer/suppliers')->send();
 | ||
|             }
 | ||
|         }
 | ||
|     }
 | ||
| ];
 | ||
| 
 | ||
| if (YII_ENV_DEV) {
 | ||
|     $config['bootstrap'][] = 'debug';
 | ||
|     $config['modules']['debug'] = [
 | ||
|         'class' => 'yii\debug\Module',
 | ||
|         'panels' => [
 | ||
|             'ArangoDB' => [
 | ||
|                 'class' => 'mirzaev\yii2\arangodb\panels\arangodb\ArangoDbPanel'
 | ||
|             ]
 | ||
|         ]
 | ||
|     ];
 | ||
| }
 | ||
| 
 | ||
| return $config;
 | 
