Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taskonsite-архив-перенесен
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitry Korolev
taskonsite-архив-перенесен
Commits
07162482
Commit
07162482
authored
May 06, 2016
by
Олег Гиммельшпах
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge cms
parent
46f09d59
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
83 additions
and
74 deletions
+83
-74
common/mail/sendNewPassword-html.php
common/mail/sendNewPassword-html.php
+10
-0
common/mail/sendNewPassword-text.php
common/mail/sendNewPassword-text.php
+9
-0
common/modules/rbac/controllers/RoleAdminController.php
common/modules/rbac/controllers/RoleAdminController.php
+9
-5
common/modules/rbac/views/role-admin/manage.php
common/modules/rbac/views/role-admin/manage.php
+1
-1
common/modules/users/controllers/UserAdminController.php
common/modules/users/controllers/UserAdminController.php
+14
-62
common/modules/users/migrations/m160506_145707_fix_user.php
common/modules/users/migrations/m160506_145707_fix_user.php
+18
-0
common/modules/users/models/User.php
common/modules/users/models/User.php
+22
-6
No files found.
common/mail/sendNewPassword-html.php
0 → 100644
View file @
07162482
<?php
/* @var $this yii\web\View */
/* @var $user common\models\User */
?>
<div
class=
"password-reset"
>
<p>
Логин:
<?=
$user
->
email
;
?>
</p>
<p>
Пароль:
<?=
$user
->
password
;
?>
</p>
</div>
common/mail/sendNewPassword-text.php
0 → 100644
View file @
07162482
<?php
/* @var $this yii\web\View */
/* @var $user common\models\User */
?>
Логин:
<?=
$user
->
email
;
?>
Пароль:
<?=
$user
->
password
;
?>
common/modules/rbac/controllers/RoleAdminController.php
View file @
07162482
...
@@ -149,7 +149,7 @@ class RoleAdminController extends \common\components\AdminController
...
@@ -149,7 +149,7 @@ class RoleAdminController extends \common\components\AdminController
$modules
=
[];
$modules
=
[];
$columns
=
[
$columns
=
[
[
[
'label'
=>
'Ф
ИО
'
,
'label'
=>
'Ф
амилия, Имя
'
,
'attribute'
=>
'fullName'
,
'attribute'
=>
'fullName'
,
'format'
=>
'raw'
,
'format'
=>
'raw'
,
'value'
=>
function
(
$model
)
{
'value'
=>
function
(
$model
)
{
...
@@ -157,15 +157,19 @@ class RoleAdminController extends \common\components\AdminController
...
@@ -157,15 +157,19 @@ class RoleAdminController extends \common\components\AdminController
}
}
],
],
[
[
'label'
=>
'Дата добавления пользователя'
,
'label'
=>
'Дата добавления <br> пользователя'
,
'encodeLabel'
=>
false
,
'attribute'
=>
'date_create'
,
'attribute'
=>
'date_create'
,
'value'
=>
function
(
$model
)
{
return
(
$model
->
date_create
?
date
(
'd.m.Y H:i'
,
strtotime
(
$model
->
date_create
))
:
'Нет данных'
);
}
],
],
[
[
'label'
=>
'Последний вход в систему'
,
'label'
=>
'Последний вход <br> в систему'
,
'encodeLabel'
=>
false
,
'attribute'
=>
'last_logon'
,
'attribute'
=>
'last_logon'
,
'filter'
=>
false
,
'value'
=>
function
(
$model
)
{
'value'
=>
function
(
$model
)
{
return
(
$model
->
last_logon
?
date
(
'd.m.Y H:i'
,
$model
->
last_logon
)
:
null
);
return
(
$model
->
last_logon
?
date
(
'd.m.Y H:i'
,
$model
->
last_logon
)
:
'Нет данных'
);
}
}
]
]
];
];
...
...
common/modules/rbac/views/role-admin/manage.php
View file @
07162482
...
@@ -29,7 +29,7 @@ $not_system_role = '!in_array($data->name, AuthItem::$system_roles)';
...
@@ -29,7 +29,7 @@ $not_system_role = '!in_array($data->name, AuthItem::$system_roles)';
echo
AdminGrid
::
widget
([
echo
AdminGrid
::
widget
([
'id'
=>
'access-grid-roles'
,
'id'
=>
'access-grid-roles'
,
'dataProvider'
=>
$dataProvider
,
'dataProvider'
=>
$dataProvider
,
'f
ilterModel'
=>
$searchModel
,
'f
ormatDateValues'
=>
false
,
'rowOptions'
=>
function
(
$model
,
$index
,
$widget
,
$grid
){
'rowOptions'
=>
function
(
$model
,
$index
,
$widget
,
$grid
){
if
(
$model
->
status
==
'blocked'
)
if
(
$model
->
status
==
'blocked'
)
//return ['style'=>'background-color:#575d63 !important;'];
//return ['style'=>'background-color:#575d63 !important;'];
...
...
common/modules/users/controllers/UserAdminController.php
View file @
07162482
...
@@ -69,7 +69,8 @@ class UserAdminController extends \common\components\AdminController
...
@@ -69,7 +69,8 @@ class UserAdminController extends \common\components\AdminController
];
];
}
}
public
function
actionBlock
(
$id
)
{
public
function
actionBlock
(
$id
)
{
$model
=
User
::
find
()
->
where
([
'id'
=>
$id
])
->
one
();
$model
=
User
::
find
()
->
where
([
'id'
=>
$id
])
->
one
();
if
(
empty
(
$model
))
$error
;
if
(
empty
(
$model
))
$error
;
...
@@ -78,59 +79,9 @@ class UserAdminController extends \common\components\AdminController
...
@@ -78,59 +79,9 @@ class UserAdminController extends \common\components\AdminController
$this
->
redirect
([
'/rbac/role-admin/manage'
]);
$this
->
redirect
([
'/rbac/role-admin/manage'
]);
}
}
public
function
actionSendNewPassword
(
$id
)
{
$model
=
$this
->
loadModel
(
$id
);
$model
->
scenario
=
User
::
SCENARIO_SEND_NEW_PASSWORD
;
$form
=
new
BaseForm
(
'users.SendNewPasswordForm'
,
$model
);
//$this->performAjaxValidation($model);
/*
print_r($form);
die();
*/
if
(
isset
(
$_POST
[
'User'
]))
{
if
(
isset
(
$_POST
[
'User'
][
'password'
])
&&
isset
(
$_POST
[
'User'
][
'password_c'
]))
{
$model
->
password
=
$_POST
[
'User'
][
'password'
];
$model
->
password_c
=
$_POST
[
'User'
][
'password_c'
];
}
else
{
$model
->
password
=
123
;
$model
->
password_c
=
123
;
}
if
(
$model
->
validate
())
{
if
(
$_POST
[
'User'
][
'generate_new'
]
==
1
)
{
$password
=
PasswordGenerator
::
generate
(
7
);
}
else
{
$password
=
$_POST
[
'User'
][
'password'
];
}
$model
->
password
=
md5
(
$password
);
$model
->
password_c
=
md5
(
$password
);
if
(
$model
->
save
())
{
Yii
::
app
()
->
user
->
setFlash
(
'flash'
,
'Пароль для пользователя <b>'
.
$model
->
name
.
'</b> был изменён.'
);
$email
=
Yii
::
app
()
->
email
;
$email
->
to
=
$user
;
$email
->
from
=
Setting
::
getValue
(
'support_email'
);
$email
->
subject
=
'Hello'
;
$email
->
message
=
Yii
::
app
()
->
controller
->
renderInternal
(
Yii
::
getPathOfAlias
(
'application.views.yii-mail.pass'
)
.
'.php'
,
array
(
'password'
=>
$password
),
true
);
$email
->
send
();
$this
->
redirect
(
'/users/userAdmin/manage'
);
}
}
}
$this
->
render
(
'sendNewPassword'
,
array
(
'form'
=>
$form
));
}
public
function
actionManage
(
$is_deleted
=
0
)
public
function
actionManage
(
$is_deleted
=
0
)
{
{
$model
=
new
\common\modules\users\models\User
;
//$is_deleted = $this->getRequest()->getQueryParam('is_deleted') ? $this->getRequest()->getQueryParam('is_deleted') : 0;
$model
=
new
\common\modules\users\models\User
(
/*User::SCENARIO_SEARCH*/
);
$model
->
scenario
=
User
::
SCENARIO_SEARCH
;
$model
->
scenario
=
User
::
SCENARIO_SEARCH
;
$model
->
is_deleted
=
$is_deleted
;
$model
->
is_deleted
=
$is_deleted
;
...
@@ -147,7 +98,6 @@ class UserAdminController extends \common\components\AdminController
...
@@ -147,7 +98,6 @@ class UserAdminController extends \common\components\AdminController
));
));
}
}
public
function
actionView
(
$id
)
public
function
actionView
(
$id
)
{
{
$this
->
render
(
'view'
,
array
(
$this
->
render
(
'view'
,
array
(
...
@@ -175,11 +125,6 @@ class UserAdminController extends \common\components\AdminController
...
@@ -175,11 +125,6 @@ class UserAdminController extends \common\components\AdminController
$model
->
scenario
=
User
::
SCENARIO_CREATE
;
$model
->
scenario
=
User
::
SCENARIO_CREATE
;
$model
->
status
=
"active"
;
$model
->
status
=
"active"
;
if
(
!
isset
(
$_POST
[
'User'
]))
{
$model
->
send_email
=
true
;
}
\Yii
::
$app
->
controller
->
page_title
=
'Добавить пользователя'
;
\Yii
::
$app
->
controller
->
page_title
=
'Добавить пользователя'
;
\Yii
::
$app
->
controller
->
tabs
=
array
(
\Yii
::
$app
->
controller
->
tabs
=
array
(
...
@@ -196,18 +141,20 @@ class UserAdminController extends \common\components\AdminController
...
@@ -196,18 +141,20 @@ class UserAdminController extends \common\components\AdminController
if
(
$model
->
validate
())
if
(
$model
->
validate
())
{
{
$
password
=
$model
->
password
;
$
model
->
sendPassword
()
;
$model
->
password
=
\Yii
::
$app
->
security
->
generatePasswordHash
(
$model
->
password
);
$model
->
password
=
\Yii
::
$app
->
security
->
generatePasswordHash
(
$model
->
password
);
$model
->
activate_code
=
\Yii
::
$app
->
security
->
generatePasswordHash
(
$model
->
password
.
'xdf5sf'
);
$model
->
activate_code
=
\Yii
::
$app
->
security
->
generatePasswordHash
(
$model
->
password
.
'xdf5sf'
);
$model
->
save
(
false
);
$model
->
save
(
false
);
return
$this
->
redirect
(
array
(
return
$this
->
redirect
(
array
(
'/rbac/role-admin/manage'
,
'/rbac/role-admin/manage'
,
));
));
}
}
}
}
$form
=
new
\common\components\BaseForm
(
'/common/modules/users/forms/UserForm'
,
$model
);
$form
=
new
\common\components\BaseForm
(
'/common/modules/users/forms/UserForm'
,
$model
);
return
$this
->
render
(
'create'
,
[
return
$this
->
render
(
'create'
,
[
...
@@ -236,6 +183,11 @@ class UserAdminController extends \common\components\AdminController
...
@@ -236,6 +183,11 @@ class UserAdminController extends \common\components\AdminController
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
()))
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
()))
{
{
if
(
$model
->
send_email
)
{
$model
->
sendPassword
();
}
if
(
$model
->
password
)
if
(
$model
->
password
)
{
{
$model
->
password
=
$model
->
password_c
=
\Yii
::
$app
->
security
->
generatePasswordHash
(
$model
->
password
);
$model
->
password
=
$model
->
password_c
=
\Yii
::
$app
->
security
->
generatePasswordHash
(
$model
->
password
);
...
...
common/modules/users/migrations/m160506_145707_fix_user.php
0 → 100644
View file @
07162482
<?php
use
yii\db\Migration
;
class
m160506_145707_fix_user
extends
Migration
{
public
function
up
()
{
$this
->
alterColumn
(
'users'
,
'phone'
,
$this
->
string
(
20
));
$this
->
alterColumn
(
'users'
,
'mobile_phone'
,
$this
->
string
(
20
));
}
public
function
down
()
{
$this
->
alterColumn
(
'users'
,
'phone'
,
$this
->
string
(
14
));
$this
->
alterColumn
(
'users'
,
'mobile_phone'
,
$this
->
string
(
14
));
}
}
common/modules/users/models/User.php
View file @
07162482
...
@@ -25,6 +25,7 @@ use yii\data\ActiveDataProvider;
...
@@ -25,6 +25,7 @@ use yii\data\ActiveDataProvider;
use
himiklab\sortablegrid\SortableGridBehavior
;
use
himiklab\sortablegrid\SortableGridBehavior
;
use
\common\components\validators\RuEmailValidator
;
use
\common\components\validators\RuEmailValidator
;
use
\common\modules\messageTemplate\components\Templates
;
use
\common\modules\messageTemplate\components\Templates
;
use
common\models\Settings
;
use
\common\modules\rbac\models\AuthItem
;
use
\common\modules\rbac\models\AuthItem
;
use
\common\modules\rbac\models\AuthAssignment
;
use
\common\modules\rbac\models\AuthAssignment
;
...
@@ -198,7 +199,6 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
...
@@ -198,7 +199,6 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
self
::
SCENARIO_UPDATE
,
self
::
SCENARIO_UPDATE
,
self
::
SCENARIO_CREATE
,
self
::
SCENARIO_CREATE
,
]],
]],
//array('password', 'unsafe', 'on' => array(
[[
'password'
],
'safe'
,
'on'
=>
[
[[
'password'
],
'safe'
,
'on'
=>
[
self
::
SCENARIO_UPDATE
,
self
::
SCENARIO_UPDATE
,
]],
]],
...
@@ -215,12 +215,10 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
...
@@ -215,12 +215,10 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
self
::
SCENARIO_SEND_NEW_PASSWORD
,
self
::
SCENARIO_SEND_NEW_PASSWORD
,
],
'message'
=>
'Пароли должны совпадать и состоять из букв латинского алфавита или цифр.'
],
],
'message'
=>
'Пароли должны совпадать и состоять из букв латинского алфавита или цифр.'
],
[[
'password'
],
'safe'
,
'on'
=>
self
::
SCENARIO_CSV_IMPORT
],
[[
'password'
],
'safe'
,
'on'
=>
self
::
SCENARIO_CSV_IMPORT
],
//array('phone, mobile_phone, phone_ext, fax', 'PhoneValidator'),
[
'is_deleted, date_delete'
,
'safe'
,
'on'
=>
[
[
'is_deleted, date_delete'
,
'safe'
,
'on'
=>
[
self
::
SCENARIO_DELETE
,
self
::
SCENARIO_DELETE
,
]],
]],
[[
'is_deleted'
],
'integer'
,
'integerOnly'
=>
true
],
[[
'is_deleted'
],
'integer'
,
'integerOnly'
=>
true
],
//array('phone', 'integer'),
[[
'fio'
],
'string'
,
'min'
=>
2
],
[[
'fio'
],
'string'
,
'min'
=>
2
],
[[
'email'
],
'string'
,
'max'
=>
200
],
[[
'email'
],
'string'
,
'max'
=>
200
],
[[
'source'
],
'string'
,
'max'
=>
50
],
[[
'source'
],
'string'
,
'max'
=>
50
],
...
@@ -230,7 +228,6 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
...
@@ -230,7 +228,6 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
[[
'csv_file'
],
'file'
,
'mimeTypes'
=>
'csv'
,
'on'
=>
[
[[
'csv_file'
],
'file'
,
'mimeTypes'
=>
'csv'
,
'on'
=>
[
self
::
SCENARIO_CSV_IMPORT
,
self
::
SCENARIO_CSV_IMPORT
,
]],
]],
// [['fio', 'phone',' mobile_phone'], 'filter', 'filter' => 'strip_tags'],
[[
'id'
,
'email'
,
'status'
,
'date_create'
,
'fio'
],
'safe'
,
'on'
=>
[
[[
'id'
,
'email'
,
'status'
,
'date_create'
,
'fio'
],
'safe'
,
'on'
=>
[
self
::
SCENARIO_SEARCH
,
self
::
SCENARIO_SEARCH
,
self
::
SCENARIO_CREATE
,
self
::
SCENARIO_CREATE
,
...
@@ -268,7 +265,7 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
...
@@ -268,7 +265,7 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
*/
*/
public
static
function
findIdentity
(
$id
)
public
static
function
findIdentity
(
$id
)
{
{
return
static
::
findOne
([
'id'
=>
$id
/*, 'status' => self::STATUS_ACTIVE*/
]);
return
static
::
findOne
([
'id'
=>
$id
,
'status'
=>
self
::
STATUS_ACTIVE
]);
}
}
/**
/**
...
@@ -287,7 +284,7 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
...
@@ -287,7 +284,7 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
*/
*/
public
static
function
findByUsername
(
$username
)
public
static
function
findByUsername
(
$username
)
{
{
return
static
::
findOne
([
'email'
=>
$username
/*, 'status' => self::STATUS_ACTIVE*/
]);
return
static
::
findOne
([
'email'
=>
$username
,
'status'
=>
self
::
STATUS_ACTIVE
]);
}
}
/**
/**
...
@@ -433,6 +430,16 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
...
@@ -433,6 +430,16 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
return
$score
;
return
$score
;
}
}
public
function
beforeValidate
()
{
if
(
$this
->
status
==
0
)
{
$this
->
status
=
static
::
STATUS_BLOCKED
;
}
return
parent
::
beforeValidate
();
}
public
function
getFullName
()
public
function
getFullName
()
{
{
return
$this
->
name
.
' '
.
$this
->
surname
;
return
$this
->
name
.
' '
.
$this
->
surname
;
...
@@ -443,6 +450,15 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
...
@@ -443,6 +450,15 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
$this
->
fullName
=
$value
;
$this
->
fullName
=
$value
;
}
}
public
function
sendPassword
()
{
return
Yii
::
$app
->
mailer
->
compose
([
'html'
=>
'sendNewPaaword-html'
,
'text'
=>
'sendNewPaaword-text'
],
[
'user'
=>
$this
])
->
setFrom
(
Settings
::
getValue
(
'content-support-email'
))
->
setTo
(
$this
->
email
)
->
setSubject
(
'Данные для входа'
)
->
send
();
}
public
function
getCustomName
(
$user
=
null
)
public
function
getCustomName
(
$user
=
null
)
{
{
if
(
!
$user
)
if
(
!
$user
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment