Skip to content

Commit 64c6a3a

Browse files
added admin controller
1 parent 2870bba commit 64c6a3a

3 files changed

Lines changed: 189 additions & 0 deletions

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
/**
3+
* @author Semenov Alexander <[email protected]>
4+
* @link http://skeeks.com/
5+
* @copyright 2010 SkeekS (СкикС)
6+
* @date 31.05.2015
7+
*/
8+
namespace skeeks\cms\authclient\controllers;
9+
10+
use skeeks\cms\authclient\models\UserAuthClient;
11+
use skeeks\cms\models\user\UserEmail;
12+
use skeeks\cms\modules\admin\controllers\AdminModelEditorController;
13+
use yii\helpers\ArrayHelper;
14+
15+
/**
16+
* Class AdminUserAuthClientController
17+
* @package skeeks\cms\controllers
18+
*/
19+
class AdminUserAuthClientController extends AdminModelEditorController
20+
{
21+
public function init()
22+
{
23+
$this->name = "Управление социальными профилями";
24+
$this->modelShowAttribute = "displayName";
25+
$this->modelClassName = UserAuthClient::className();
26+
27+
parent::init();
28+
29+
}
30+
31+
public function actions()
32+
{
33+
return ArrayHelper::merge(parent::actions(), [
34+
35+
'index' =>
36+
[
37+
"columns" => [
38+
'displayName',
39+
40+
[
41+
'class' => \skeeks\cms\grid\UserColumnData::className(),
42+
'attribute' => "user_id"
43+
],
44+
45+
[
46+
'class' => \skeeks\cms\grid\DateTimeColumnData::className(),
47+
'attribute' => "created_at"
48+
],
49+
50+
51+
],
52+
],
53+
54+
'create' =>
55+
[
56+
'visible' => false
57+
]
58+
]);
59+
}
60+
61+
}

models/UserAuthClient.php

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
/**
3+
* @author Semenov Alexander <[email protected]>
4+
* @link http://skeeks.com/
5+
* @copyright 2010 SkeekS (СкикС)
6+
* @date 16.04.2016
7+
*/
8+
namespace skeeks\cms\authclient\models;
9+
10+
use skeeks\cms\models\behaviors\HasJsonFieldsBehavior;
11+
use Yii;
12+
use \yii\db\ActiveRecord;
13+
14+
/**
15+
* Class UserAuthClient
16+
* @package skeeks\module\cms\user\model
17+
*/
18+
class UserAuthClient extends ActiveRecord
19+
{
20+
/**
21+
* @inheritdoc
22+
*/
23+
public static function tableName()
24+
{
25+
return '{{%cms_user_authclient}}';
26+
}
27+
28+
/**
29+
* @return array
30+
*/
31+
public function behaviors()
32+
{
33+
return array_merge(parent::behaviors(), [
34+
HasJsonFieldsBehavior::className() =>
35+
[
36+
'class' => HasJsonFieldsBehavior::className(),
37+
'fields' => ['provider_data']
38+
]
39+
]);
40+
}
41+
42+
/**
43+
* @inheritdoc
44+
*/
45+
public function rules()
46+
{
47+
return [
48+
[['user_id'], 'required'],
49+
[['user_id', 'created_at', 'updated_at'], 'integer'],
50+
[['provider_data'], 'safe'],
51+
[['provider'], 'string', 'max' => 50],
52+
[['provider_identifier'], 'string', 'max' => 100]
53+
];
54+
}
55+
56+
/**
57+
* @inheritdoc
58+
*/
59+
public function attributeLabels()
60+
{
61+
return [
62+
'id' => Yii::t('app', 'ID'),
63+
'user_id' => Yii::t('app', 'User'),
64+
'provider' => Yii::t('app', 'Provider'),
65+
'provider_identifier' => Yii::t('app', 'Provider Identifier'),
66+
'provider_data' => Yii::t('app', 'Provider Data'),
67+
'created_at' => Yii::t('app', 'Created At'),
68+
'updated_at' => Yii::t('app', 'Updated At'),
69+
];
70+
}
71+
72+
/**
73+
* @return \yii\db\ActiveQuery
74+
*/
75+
public function getUser()
76+
{
77+
return $this->hasOne(User::className(), ['id' => 'user_id']);
78+
}
79+
80+
/**
81+
* @return string
82+
*/
83+
public function getDisplayName()
84+
{
85+
return $this->provider . " [{$this->provider_identifier}]";
86+
}
87+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
use yii\helpers\Html;
3+
use skeeks\cms\modules\admin\widgets\form\ActiveFormUseTab as ActiveForm;
4+
5+
/* @var $this yii\web\View */
6+
/* @var $model \yii\db\ActiveRecord */
7+
?>
8+
<?php $form = ActiveForm::begin(); ?>
9+
10+
<?= $form->fieldSet(\Yii::t('app',"Main")); ?>
11+
<? if (\Yii::$app->request->get('user_id')) : ?>
12+
<?= $form->field($model, 'user_id')->hiddenInput(['value' => \Yii::$app->request->get('user_id')])->label(false) ?>
13+
<? else: ?>
14+
<?= $form->fieldSelect($model, 'user_id', \yii\helpers\ArrayHelper::map(
15+
\skeeks\cms\models\User::find()->active()->all(),
16+
'id',
17+
'displayName'
18+
), [
19+
'allowDeselect' => true
20+
]) ?>
21+
<? endif; ?>
22+
23+
<?= $form->fieldSetEnd(); ?>
24+
25+
<? if (!$model->isNewRecord) : ?>
26+
<?= $form->fieldSet(\Yii::t('app',"Data of provider")); ?>
27+
<?/*= \yii\widgets\DetailView::widget([
28+
'model' => $model->provider_data,
29+
'attributes' => array_keys((array) $model->provider_data),
30+
])*/?>
31+
<pre>
32+
<?
33+
print_r($model->provider_data);
34+
?>
35+
</pre>
36+
<?= $form->fieldSetEnd(); ?>
37+
<? endif; ?>
38+
39+
40+
<?= $form->buttonsCreateOrUpdate($model); ?>
41+
<?php ActiveForm::end(); ?>

0 commit comments

Comments
 (0)