From c93094697e29635718856213e7dc43b096587e57 Mon Sep 17 00:00:00 2001 From: Derek Gifford Date: Mon, 8 May 2017 19:29:27 -0400 Subject: [PATCH 1/2] Add enableGravatar option to module --- Module.php | 3 +++ views/settings/profile.php | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Module.php b/Module.php index d325ee8ce..c16bf52b4 100644 --- a/Module.php +++ b/Module.php @@ -57,6 +57,9 @@ class Module extends BaseModule /** @var bool Enable the 'impersonate as another user' function */ public $enableImpersonateUser = true; + /** @var bool Enable gravatar profile avatars */ + public $enableGravatar = true; + /** @var int Email changing strategy. */ public $emailChangeStrategy = self::STRATEGY_DEFAULT; diff --git a/views/settings/profile.php b/views/settings/profile.php index 07c625ccb..48d510274 100644 --- a/views/settings/profile.php +++ b/views/settings/profile.php @@ -66,9 +66,9 @@ ) ); ?> - context->module->enableGravatar)? $form ->field($model, 'gravatar_email') - ->hint(Html::a(Yii::t('user', 'Change your avatar at Gravatar.com'), 'http://gravatar.com')) ?> + ->hint(Html::a(Yii::t('user', 'Change your avatar at Gravatar.com'), 'http://gravatar.com')) : null ?> field($model, 'bio')->textarea() ?> From c7f0e03e9987745876224d2d18c1f6f066425899 Mon Sep 17 00:00:00 2001 From: Derek Gifford Date: Mon, 8 May 2017 19:37:06 -0400 Subject: [PATCH 2/2] Widgetized the registration form. --- views/registration/register.php | 43 ++------------- widgets/Register.php | 93 +++++++++++++++++++++++++++++++++ widgets/views/register.php | 62 ++++++++++++++++++++++ 3 files changed, 160 insertions(+), 38 deletions(-) create mode 100644 widgets/Register.php create mode 100644 widgets/views/register.php diff --git a/views/registration/register.php b/views/registration/register.php index 97e7b494c..0e2a26bfb 100644 --- a/views/registration/register.php +++ b/views/registration/register.php @@ -1,5 +1,4 @@ title = Yii::t('user', 'Sign up'); $this->params['breadcrumbs'][] = $this->title; -?> -
-
-
-
-

title) ?>

-
-
- 'registration-form', - 'enableAjaxValidation' => true, - 'enableClientValidation' => false, - ]); ?> - - field($model, 'email') ?> - - field($model, 'username') ?> - - enableGeneratingPassword == false): ?> - field($model, 'password')->passwordInput() ?> - - - 'btn btn-success btn-block']) ?> - - -
-
-

- -

-
-
+echo Register::widget([ + 'model' => $model, + 'title' => $this->title, + 'enableGeneratingPassword' => $module->enableGeneratingPassword]); \ No newline at end of file diff --git a/widgets/Register.php b/widgets/Register.php new file mode 100644 index 000000000..7f5cd29d2 --- /dev/null +++ b/widgets/Register.php @@ -0,0 +1,93 @@ + + * + * For the full copyright and license information, please view the LICENSE.md + * file that was distributed with this source code. + */ + +namespace dektrium\user\widgets; + +use dektrium\user\models\RegistrationForm; +use yii\base\Widget; + +/** + * Login for widget. + * + * @author Dmitry Erofeev + */ +class Register extends Widget +{ + + /** + * @var \dektrium\user\models\RegistrationForm + */ + public $model; + + /** + * @var string + */ + public $id = 'registration-form'; + + /** + * @var string + */ + public $title = ""; + + /** + * @var bool + */ + public $validate = true; + + /** + * @var bool + */ + public $enableGeneratingPassword = null; + + /** + * @var bool + */ + public $displayLoginLink = true; + + /** + * @var bool + */ + public $panel = true; + + /** + * @var string + */ + public $panelType = 'default'; + + public function init() + { + parent::init(); + + if (!$this->model) { + $this->model = \Yii::createObject(RegistrationForm::className()); + } + if ($this->enableGeneratingPassword === null) { + $this->enableGeneratingPassword = Yii::$app->getModule('user')->enableGeneratingPassword; + } + } + + /** + * @inheritdoc + */ + public function run() + { + return $this->render('register', [ + 'model' => $this->model, + 'id' => $this->id, + 'title' => $this->title, + 'validate' => $this->validate, + 'enableGeneratingPassword' => $this->enableGeneratingPassword, + 'displayLoginLink' => $this->displayLoginLink, + 'panel' => $this->panel, + 'panelType' => $this->panelType, + ]); + } +} diff --git a/widgets/views/register.php b/widgets/views/register.php new file mode 100644 index 000000000..6192f6063 --- /dev/null +++ b/widgets/views/register.php @@ -0,0 +1,62 @@ + + * + * For the full copyright and license information, please view the LICENSE.md + * file that was distributed with this source code. + */ + +use yii\helpers\Html; +use yii\helpers\Url; +use yii\widgets\ActiveForm; + +/** + * @var yii\web\View $this + * @var dektrium\user\models\User $model + * @var dektrium\user\Module $module + */ + +?> +
+
+ +
+
+

+
+
+ +

+ + $id, + 'action' => Url::to(['/user/register']), + 'enableAjaxValidation' => true, + 'enableClientValidation' => false, + ]); ?> + + field($model, 'email') ?> + + field($model, 'username') ?> + + + field($model, 'password')->passwordInput() ?> + + + 'btn btn-success btn-block']) ?> + + + +
+
+ + +

+ +

+ +
+
\ No newline at end of file