1
|
|
|
<?php
|
2
|
|
|
/**
|
3
|
|
|
* @author Nikita Melnikov <[email protected]>
|
4
|
|
|
* @link https://github.com/shogodev/argilla/
|
5
|
|
|
* @copyright Copyright © 2003-2014 Shogo
|
6
|
|
|
* @license http://argilla.ru/LICENSE
|
7
|
|
|
* @package frontend.commands
|
8
|
|
|
*/
|
9
|
|
|
|
10
|
|
|
Yii::import('backend.components.db.*');
|
11
|
|
|
Yii::import('backend.components.auth.*');
|
12
|
|
|
Yii::import('backend.modules.rbac.models.*');
|
13
|
|
|
|
14
|
|
|
class PasswordsCommand extends CConsoleCommand
|
15
|
|
|
{
|
16
|
|
|
/**
|
17
|
|
|
* @var string
|
18
|
|
|
*/
|
19
|
|
|
protected $username;
|
20
|
|
|
|
21
|
|
|
/**
|
22
|
|
|
* @var string
|
23
|
|
|
*/
|
24
|
|
|
protected $password;
|
25
|
|
|
|
26
|
|
|
/**
|
27
|
|
|
* @var BUser
|
28
|
|
|
*/
|
29
|
|
|
protected $user;
|
30
|
|
|
|
31
|
|
|
/**
|
32
|
|
|
* Обновление пароля у пользователя / Добавление нового пользователя
|
33
|
|
|
*
|
34
|
|
|
* @param string $user
|
35
|
|
|
* @param string $password
|
36
|
|
|
*
|
37
|
|
|
* @return int
|
38
|
|
|
*/
|
39
|
|
|
public function actionCreate($user, $password)
|
40
|
|
|
{
|
41
|
|
|
$this->username = $user;
|
42
|
|
|
$this->password = $password;
|
43
|
|
|
|
44
|
|
|
try
|
45
|
|
|
{
|
46
|
|
|
$criteria = new CDbCriteria();
|
47
|
|
|
$criteria->compare('username', $this->username);
|
48
|
|
|
|
49
|
|
|
$this->user = BUser::model()->find($criteria);
|
50
|
|
|
|
51
|
|
|
if( $this->user === null )
|
52
|
|
|
{
|
53
|
|
|
$this->user = new BUser();
|
54
|
|
|
$this->user->username = $this->username;
|
55
|
|
|
}
|
56
|
|
|
elseif( !$this->confirm('Пользователь уже существует, обновить его пароль?', false) )
|
57
|
|
|
return 1;
|
58
|
|
|
|
59
|
|
|
$this->user->setNewPassword($this->password);
|
60
|
|
|
$this->user->save();
|
61
|
|
|
|
62
|
|
|
echo "----------------------------------------------------".PHP_EOL;
|
63
|
|
|
echo "\tSuccess".PHP_EOL;
|
64
|
|
|
echo "----------------------------------------------------".PHP_EOL;
|
65
|
|
|
echo "\tUser: " . $this->user->username.PHP_EOL;
|
66
|
|
|
echo "\tPassword: ";
|
67
|
|
|
echo $this->password.PHP_EOL;
|
68
|
|
|
}
|
69
|
|
|
catch( CException $e )
|
|
|
|
|
70
|
|
|
{
|
71
|
|
|
echo "\tFailure".PHP_EOL;
|
72
|
|
|
echo "----------------------------------------------------".PHP_EOL;
|
73
|
|
|
echo "\t".$e->getMessage().PHP_EOL;
|
74
|
|
|
|
75
|
|
|
}
|
76
|
|
|
echo "----------------------------------------------------".PHP_EOL;
|
77
|
|
|
|
78
|
|
|
return 0;
|
79
|
|
|
}
|
80
|
|
|
} |
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.