Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

Commit

Permalink
Merge pull request #131 from Millon15/issue-129
Browse files Browse the repository at this point in the history
Issue #129 fix
  • Loading branch information
Millon15 authored Apr 24, 2019
2 parents 7291520 + 91e34eb commit 4133338
Show file tree
Hide file tree
Showing 30 changed files with 101 additions and 450 deletions.
11 changes: 6 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ YII_DEBUG=true
YII_ENV=dev
YII_ENV_DEV=false

VD_KEY=
VD_KEY= #yii's csrf validation token

# Oauth2 42
42_API_CI= #client id
Expand All @@ -12,14 +12,15 @@ VD_KEY=

# Mysql config
# Local database
DB_HOST=mysql
DB_PORT=3306
DB_HOST=mysql # your mysql server's IP
DB_NAME=yii2
DB_USERNAME=yii2
DB_PASSWORD=yii2
# UNIX_SOCKET=/var/run/mysqld/mysqld.sock

#YII_ENV_TEST=1
YII_ENV_DEV=true
# Ports binding
WEB_PORT=8888
DB_PORT=3306
PHPMA_PORT=8080

GITHUB_API_TOKEN=
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@ composer.phar

# phpunit itself is not needed
phpunit.phar

# local phpunit config
/phpunit.xml

/.vagrant
.env

# yii2 dirs
/web/assets
assets
Expand All @@ -48,3 +46,7 @@ tests/_support/_generated

# to include
!assets/AppAsset.php

# files to exclude
.env
index.php
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Cheatera Change Log

------------------------
- Issue #129 BUG: #66 fix
- Issue #66 FEATURE: Добавить обновление данных о пользователе в БД при логине
- Issue #102 FEATURE: Добавить камеры с marvin.unit.ua
- Issue #64 FEATURE: Добавить просмотры групп по проектам
Expand Down
81 changes: 0 additions & 81 deletions Vagrantfile

This file was deleted.

6 changes: 3 additions & 3 deletions config/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

return [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=' . env('DB_HOST', 'mysql') . ';dbname=' . env('DB_NAME', 'yii2'),
'username' => env('DB_USERNAME', 'yii2'),
'password' => env('DB_PASSWORD', 'yii2'),
'dsn' => 'mysql:host=' . getenv('DB_HOST', 'mysql') . ';port=' . getenv('DB_PORT', '3306') .';dbname=' . getenv('DB_NAME', 'yii2') . ';',
'username' => getenv('DB_USERNAME', 'yii2'),
'password' => getenv('DB_PASSWORD', 'yii2'),
'charset' => 'utf8',
// Schema cache options (for production environment)
//'enableSchemaCache' => true,
Expand Down
13 changes: 6 additions & 7 deletions config/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
'@bower' => '@vendor/bower-asset',
'@npm' => '@vendor/npm-asset',
],
'modules' => [
'modules' => [
'languages' => [
'class' => 'klisl\languages\Module',
//Языки используемые в приложении
//Языки используемые в приложении
'languages' => [
'Русский' => 'ru',
'Українська' => 'uk',
Expand All @@ -28,8 +28,7 @@
],
'components' => [
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => env('VD_KEY', ''),
'cookieValidationKey' => getenv('VD_KEY'),
'enableCookieValidation' => true,
'enableCsrfValidation' => true,
'baseUrl' => '', //убрать frontend/web
Expand Down Expand Up @@ -77,8 +76,8 @@
'clients' => [
'auth42' => [
'class' => 'app\helpers\Auth42',
'clientId' => env('42_API_CI', ''),
'clientSecret' => env('42_API_CS', ''),
'clientId' => getenv('42_API_CI'),
'clientSecret' => getenv('42_API_CS'),
],
],
],
Expand All @@ -105,8 +104,8 @@
'students' => 'show/students',
'pools' => 'show/pools',
'calculator' => 'calculator/index',
'change-theme' => 'site/change-theme',
'calculator/form-submission' => 'calculator/form-submission',
'change-theme' => 'site/change-theme',
'corrections' => 'corrections/index',
'friends' => 'friend/index',
'friends/create/<id:[\w\-]+>/<course:\w+>' => 'friend/create',
Expand Down
4 changes: 2 additions & 2 deletions controllers/CalculatorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CalculatorController extends CommonController
*
* @return String which sends to the View
*/
public function actionIndex( $model = null )
public function actionIndex($model = null)
{
$title = Yii::t('app', 'Experience calculator');
$description = Yii::t('app', 'Want to know your level after project evaluation -- use our Experience calculator!');
Expand Down Expand Up @@ -46,7 +46,7 @@ public function actionIndex( $model = null )
* @param Object $model reference to Calculator's Model instance
* @param Array $post $post request array
*/
private function getMarkFromPost( &$model, $post )
private function getMarkFromPost(&$model, $post)
{
if ($model && $post
&& $model->load($post) && $model->validate() ) {
Expand Down
9 changes: 4 additions & 5 deletions controllers/ProjectsAllSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,14 @@ public function search($params)
'xlogin' => SORT_ASC,
]],
]);


$dataProvider->sort->attributes['location'] = [
'asc' => ['xlogins.location' => SORT_ASC],
'desc' => ['xlogins.location' => SORT_DESC],];

'desc' => ['xlogins.location' => SORT_DESC],
];
$dataProvider->sort->attributes['lastloc'] = [
'asc' => ['xlogins.lastloc' => SORT_ASC],
'desc' => ['xlogins.lastloc' => SORT_DESC],];
'desc' => ['xlogins.lastloc' => SORT_DESC],
];

$this->load($params);

Expand Down
20 changes: 10 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
version: '3'
version: '3.4'

services:
web:
build: ./
ports:
- '8888:80'
- '${WEB_PORT:-8888}:80'
expose:
- "80"
- "9000"
- '9000'
volumes:
- ./:/var/www/html/
links:
Expand All @@ -17,12 +17,12 @@ services:
container_name: 'yii2-mysql'
restart: 'always'
ports:
- "3306:3306"
- '${DB_PORT:-3306}:3306'
environment:
MYSQL_ROOT_PASSWORD: yii2
MYSQL_DATABASE: yii2
MYSQL_USER: yii2
MYSQL_PASSWORD: yii2
MYSQL_DATABASE: ${DB_NAME:-yii2}
MYSQL_USER: ${DB_USERNAME:-yii2}
MYSQL_PASSWORD: ${DB_PASSWORD:-yii2}
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-yii2}
volumes:
- ./config/:/docker-entrypoint-initdb.d/

Expand All @@ -35,6 +35,6 @@ services:
PMA_HOST: mysql
PMA_PORT: 3306
ports:
- '8080:80'
- '${PHPMA_PORT:-8080}:80'
volumes:
- /sessions
2 changes: 1 addition & 1 deletion helpers/Auth42.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function fetchMe($params)
->setHeaders($params);
$response = $this->sendRequest($request);

RememberUserInfo\RememberUserInfo::rememberAllToDB($response);
new RememberUserInfo\RememberUserInfo($response);

$profileLink = '/pools/';
if (isset($response['cursus_users'])) {
Expand Down
18 changes: 5 additions & 13 deletions helpers/RememberUserInfo/RememberAchievements.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ protected function init()
$this->responseSubset = $this->response['achievements'];
$this->model = 'app\models\Achievements';
$this->idcol = 'aid';

$this->ARcollection = $this->model::find()
->where(['xlogin' => $this->xlogin])
->all();
}

/**
* {@inheritdoc}
*/
protected function norminate()
protected function remember()
{
foreach ($this->responseSubset as &$achievement) {
$achievement['xlogin'] = $this->xlogin;
Expand All @@ -27,19 +31,7 @@ protected function norminate()
self::swapKeysInArr($achievement, [ 'id' => 'aid' ]);
$achievement['description'] = htmlentities($achievement['description']);
$achievement['visible'] = $achievement['visible'] ?? 'True';
}
}

/**
* {@inheritdoc}
*/
protected function remember()
{
$this->ARcollection = $this->model::find()
->where(['xlogin' => $this->xlogin])
->all();

foreach ($this->responseSubset as $achievement) {
self::saveChangesToDB($achievement);
}
}
Expand Down
18 changes: 5 additions & 13 deletions helpers/RememberUserInfo/RememberCurses.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ protected function init()
$this->responseSubset = $this->response['cursus_users'];
$this->model = 'app\models\Curses';
$this->idcol = 'cursus_users_id';

$this->ARcollection = $this->model::find()
->where([ 'xlogin' => $this->xlogin ])
->all();
}

/**
* {@inheritdoc}
*/
protected function norminate()
protected function remember()
{
foreach ($this->responseSubset as &$curs) {
unset($curs['user']);
Expand All @@ -32,19 +36,7 @@ protected function norminate()
$curs['xid'] = $this->xid;
self::setTrueFalse($curs['has_coalition']);
$curs['grade'] = $curs['grade'] ?? 'None';
}
}

/**
* {@inheritdoc}
*/
protected function remember()
{
$this->ARcollection = $this->model::find()
->where([ 'xlogin' => $this->xlogin ])
->all();

foreach ($this->responseSubset as $curs) {
$this->saveChangesToDB($curs);
}
}
Expand Down
Loading

0 comments on commit 4133338

Please sign in to comment.