Commit 69d8d25c authored by Олег Гиммельшпах's avatar Олег Гиммельшпах

Merge branch 'master' of git.task-on.com:ktask/task-on.com

parents 9066a938 ac08a4b4
......@@ -168,6 +168,10 @@ JS;
$opt = $element['fileOptions'];
if(!empty($element['empty']))
$opt['value'] = $element['empty'];
if(!empty($element['inputOptions']))
$optEl['inputOptions'] = $element['inputOptions'];
if(!empty($element['inputOptions']))
$opt['inputOptions'] = $element['inputOptions'];
switch($element['type']) {
case 'checkbox':
$opt['data-render'] = 'switchery';
......@@ -191,12 +195,15 @@ JS;
case 'email':
$tmp = $this->field($this->model, $key, $optEl)->input($element['type'], $opt);
if(!empty($element['hint'])) $tmp = $tmp->hint($element['hint']);
if($element['options']['label'] === false) $tmp = $tmp->label(false);
$config['options'][] = $tmp;
break;
case 'password':
//$opt['value'] = '';
$optEl['template'] = '{label}{input}<div id="'.$element['pwd-id'].'" class="is0 m-t-5"></div>{error}';
$config['options'][] = $this->field($this->model, $key, $optEl)->input($element['type'], $opt);
$tmp = $this->field($this->model, $key, $optEl)->input($element['type'], $opt);
if($element['options']['label'] === false) $tmp = $tmp->label(false);
$config['options'][] = $tmp;
break;
case 'hidden':
$config['options'][] = $this->field($this->model, $key, $optEl)->hiddenInput($opt)->label(false);
......@@ -209,6 +216,7 @@ JS;
//$optEl['template'] = '{label}<div class="col-md-8">{input}</div>{error}{hint}';
$tmp = $this->field($this->model, $key, $optEl)->dropDownList($element['items'],$opt);
if(!empty($element['hint'])) $tmp = $tmp->hint($element['hint']);
if($element['options']['label'] === false) $tmp = $tmp->label(false);
$config['options'][] = $tmp;
break;
case 'listBox':
......@@ -272,7 +280,8 @@ JS;
if($button['type'] == 'htmlBlock')
$config['options'][] = $button['value'];
else if($button['type'] == 'submit')
$config['options'][] = \yii\helpers\Html::submitButton($button['value'], ['class'=> 'btn btn-success']);
$config['options'][] = (!empty($button['class'])) ? \yii\helpers\Html::submitButton($button['value'], ['class'=> $button['class']])
: \yii\helpers\Html::submitButton($button['value'], ['class'=> 'btn btn-success']);
else if($button['type'] == 'cancel')
$config['options'][] = \yii\helpers\Html::resetButton($button['value'], ['class'=> 'btn btn-default']);
else if($button['type'] == 'danger')
......
......@@ -186,6 +186,7 @@ JS;
$config['options'][] = '<div style="clear: both;"></div>';
/* **************** */
}
unset($config['elements']);
if($meta) {
//die(print_r($model->metaTag));
......
......@@ -79,7 +79,7 @@ class AuthItem extends \common\components\ActiveRecordModel
}
public function getAssignment() {
return $this->hasOne(AuthAssignment::className(), ['name' => 'item_name']);
return $this->hasMany(AuthAssignment::className(), ['item_name' => 'name']);
}
public function relations()
......@@ -97,7 +97,6 @@ class AuthItem extends \common\components\ActiveRecordModel
'auth_items_childs(parent, child)',
'condition' => 'type = "' . self::TYPE_TASK . '"'
),
'assignments' => array(self::HAS_MANY, 'AuthAssignment', 'itemname'),
'users' => array(self::HAS_MANY, 'User', 'userid', 'through' => 'assignments')
);
}
......@@ -188,7 +187,8 @@ class AuthItem extends \common\components\ActiveRecordModel
if(!$roles)
{
$roles = $this->findAllByAttributes(array(
'type' => self::TYPE_ROLE
//'type' => self::TYPE_ROLE
'rule_name' => 'group'
));
}
return $roles;
......
......@@ -6,6 +6,7 @@ use common\components\BaseController;
use common\modules\school\models\Courses;
use common\modules\school\models\SearchCourses;
use common\modules\school\models\SearchLessons;
use common\modules\users\models\User;
class CourseController extends BaseController
{
......@@ -23,7 +24,9 @@ class CourseController extends BaseController
$search = \Yii::$app->request->queryParams;
$dataProvider = $searchModel->search($search);
return $this->render('index', ['dataProvider' => $dataProvider]);
$modelUser = new User();
$form = new \common\components\BaseForm('/common/modules/users/forms/RegistrationUserForm', $modelUser);
return $this->render('index', ['dataProvider' => $dataProvider, 'form' => $form->out]);
}
public function actionView($id)
......
......@@ -26,7 +26,6 @@ class Courses extends \common\components\ActiveRecordModel
self::TYPE_DV => 'в разработке',
];
public static function tableName()
{
return 'courses';
......
......@@ -49,12 +49,9 @@
<div class="container">
<div class="row">
<div class="col-md-4 col-xs-6 col-sm-12">
<form class="sh_reg_form">
<input type="text" class="input_st field-input required alphanumeric" placeholder="Ваше имя*">
<input type="tel" class="input_st field-input required alphanumeric" placeholder="Телефон*">
<input type="email" class="input_st field-input required email" placeholder="E-mail*">
<button class="save-button sh_bt_send">Записаться</button>
</form>
<?php
echo $form;
?>
<div class="usl">Проходя регистрацию вы подтверждаете<br><a href="#">согласие на обработку персональных данных.</a></div>
</div>
<div class="col-md-8 col-xs-6 col-sm-12">
......
......@@ -46,7 +46,7 @@ class UserController extends \common\components\BaseController {
}
public function loadModel($id) {
public function loadModel($id, $scopes = array(), $attribute = NULL) {
$model = User::model()->findByPk((int)$id);
if ($model === null) {
$this->pageNotFound();
......@@ -104,14 +104,15 @@ class UserController extends \common\components\BaseController {
public function actionRegistration() {
$model = new User;
die('');
$model = new User();
$model->scenario = User::SCENARIO_REGISTRATION;
$form = new BaseForm('users.RegistrationForm', $model);
/* $form = new BaseForm('users.RegistrationForm', $model);
$this->performAjaxValidation($model);
unset($form->elements['captcha']);
$is_created = false;
$is_created = false;*/
if (isset($_POST['User'])) {
$model->attributes = $_POST['User'];
......
<?php
use yii\helpers\Url;
use common\modules\users\models\User;
$elements = [
'name' => ['type' => 'text', 'placeholder'=>"Ваше имя*", 'options'=>['label'=>false],
'inputOptions'=>['class'=>'input_st field-input required alphanumeric']],
'email' => ['type' => 'text', 'placeholder'=>"E-mail*", 'options'=>['label'=>false],
'inputOptions'=>['class'=>'input_st field-input required alphanumeric']],
'password' => ['type' => 'password', 'placeholder'=>"Придумайте пароль*", 'options'=>['label'=>false],
'inputOptions'=>['class'=>'input_st field-input required alphanumeric']],
'password_c' => ['type' => 'password', 'placeholder'=>"Повторите пароль*", 'options'=>['label'=>false],
'inputOptions'=>['class'=>'input_st field-input required alphanumeric']],
'phone' => ['type' => 'text', 'placeholder'=>"Телефон", 'options'=>['label'=>false],
'inputOptions'=>['class'=>'input_st field-input required alphanumeric']],
'teltext' => '<div class="teltext-block">Для участие в проводимых конкурсах укажите Ваш реальный номер телефона,
что бы мы смогли вас оповестить о результатах</div>',
'occupation' => [
'type' => 'dropdownlist',
'items' => User::$occupation_list,
'placeholder'=>"Род занятий",
'options'=>['label'=>false],
'empty'=>'Чем вы занимаетесь',
'inputOptions'=>['class'=>'input_st field-input required alphanumeric']
],
];
return [
'activeForm'=>[
'id' => 'sh_reg_form',
'options' => [
//'onsubmit'=>"ajaxSubmit(url: ".Url::toRoute(['/users/user/registration']).")";
'enctype' => 'multipart/form-data'
],
],
'elements' => $elements,
'buttons' => [
'submit' => ['type' => 'submit', 'value' => 'Записаться', 'class'=>"save-button sh_bt_send"]
]
];
......@@ -17,6 +17,11 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
{
const PAGE_SIZE = 10;
const OCCUPATION_CHIEF_IT = 1;
const OCCUPATION_MANAGER_IT = 2;
const OCCUPATION_CREATOR = 3;
const OCCUPATION_NOT_IT = 4;
const STATUS_ACTIVE = 'active';
const STATUS_NEW = 'new';
const STATUS_BLOCKED = 'blocked';
......@@ -63,6 +68,14 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
public $tmp; //for external using. no delete!
// public $post;
public static $occupation_list = [
self::OCCUPATION_CHIEF_IT => 'Руководитель в IT сфере',
self::OCCUPATION_MANAGER_IT => 'Менеджер в IT сфере',
self::OCCUPATION_CREATOR => 'Разработчик',
self::OCCUPATION_NOT_IT => 'Не работаю в IT',
];
public function behaviors()
{
return [
......@@ -91,7 +104,8 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
"send_email" => "Отправить уведомление на почту",
"generate_new" => "Сгенерировать пароль автоматически",
"post" => "Должность",
"status" => "Активен / заблокирован"
"status" => "Активен / заблокирован",
"occupation" => "Род занятий",
));
return $attrs;
......@@ -136,7 +150,7 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
self::SCENARIO_CHANGE_PASSWORD,
self::SCENARIO_CREATE,
], 'message' => 'Пожалуйста, укажите пароль'],
[['password'], 'string', 'min' => 4, 'on' => [
[['password'], 'string', 'min' => 7, 'on' => [
self::SCENARIO_REGISTRATION,
self::SCENARIO_CHANGE_PASSWORD,
self::SCENARIO_UPDATE,
......@@ -183,6 +197,7 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
self::SCENARIO_SEARCH,
self::SCENARIO_CREATE,
]],
[['occupation'], 'integer', 'max' => 11],
[['tmp','role','sort','fio','name', 'surname','email', 'mobile_phone'], 'safe'],
];
}
......@@ -355,7 +370,7 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
public function relations()
{
return array(
'assignment' => array(self::HAS_ONE, 'AuthAssignment', 'userid'),
'assignment' => array(self::HAS_ONE, 'AuthAssignment', 'user_id'),
'city' => array(self::BELONGS_TO, 'City', 'city_id')
);
}
......@@ -394,8 +409,13 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
public function getRole()
{
/*$assigment = AuthAssignment::find(['userid' => $this->id])->one();
$auth = AuthItem::find()->joinWith('assignment', true)
->andWhere(['rule_name' => 'group'])
->andWhere(['auth_assignment.user_id' => $this->id])
->one();
return $auth->name;
/*$assigment = AuthAssignment::find(['userid' => $this->id])->one();
if (!$assigment)
{
$assigment = new AuthAssignment();
......@@ -404,8 +424,8 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
$assigment->save(false);
}
return $assigment->role;*/
return 'admin';
return $assigment->role;
return 'admin';*/
}
public function getRoleName()
......
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160204_213447_add_field_to_users_table extends Migration
{
public function safeUp()
{
$this->addColumn('users', 'occupation', Schema::TYPE_INTEGER . '(11)');
}
public function safeDown()
{
$this->dropColumn('users', 'occupation');
}
}
......@@ -22,6 +22,7 @@ return [
'school' => ['class' => 'common\modules\school\Module',],
'bids' => ['class' => 'common\modules\bids\Module'],
'testings' => ['class' => 'common\modules\testings\Module',],
'users' => ['class' => 'common\modules\users\users',],
'sitemap' => [
'class' => 'himiklab\sitemap\Sitemap',
'models' => [
......@@ -81,7 +82,7 @@ return [
//'css_linebreak_pos' => false,
],
'user' => [
'identityClass' => 'common\modules\scoring\models\ScClient',
'identityClass' => 'common\modules\users\models\User',
'loginUrl' => ['/site/login'],
'enableAutoLogin' => true,
],
......@@ -165,6 +166,7 @@ return [
'school' => 'school/course/index',
'school/course/<id>' => 'school/course/view',
'school/lesson/<id>' => 'school/lesson/view',
'login' => 'site/login',
'<page:(/)>' => 'content/page/view',
'<_m>/<_c>/<_a>/<id:\d+>' => '<_m>/<_c>/<_a>',
......@@ -178,10 +180,10 @@ return [
],
'authManager' => [
'class' => 'yii\rbac\DbManager',
/*'connectionID' => 'db',
'connectionID' => 'db',
'itemTable' => 'auth_items',
'assignmentTable' => 'auth_assignments',
'itemChildTable' => 'auth_item_child',*/
'itemChildTable' => 'auth_item_child',
'defaultRoles' => [
'user',
'moderator',
......
......@@ -3,7 +3,7 @@ namespace frontend\controllers;
use common\modules\scoring\models\ScRequest;
use Yii;
use frontend\models\LoginForm;
//use frontend\models\LoginForm;
use frontend\models\PasswordResetRequestForm;
use frontend\models\ResetPasswordForm;
use frontend\models\SignupForm;
......@@ -22,6 +22,7 @@ use common\modules\request\models\ScZodiac;
use \yii\web\Response;
use \yii\widgets\ActiveForm;
use common\modules\scoring\models\ScClient;
use common\models\LoginForm;
/**
* Site controller
......@@ -115,6 +116,14 @@ class SiteController extends BaseController
}
public function actionLogin()
{
//Yii::$app->user->getIdentity()->getRole()
$model = new LoginForm();
$model->load(Yii::$app->request->post());
$model->login();
}
/*public function actionLogin()
{
$this->layout = '//main-short';
$model = new \frontend\models\LoginForm();
......@@ -178,7 +187,7 @@ class SiteController extends BaseController
'model' => $model,
]);
}
}
}*/
public function actionLogout()
{
......
......@@ -23,4 +23,5 @@
<?php $this->registerJsFile('/js/inputmask.phone.extensions.js', ['position' => yii\web\View::POS_END ]);?>
<?php $this->registerJsFile('/js/common.js', ['position' => yii\web\View::POS_END ]);?>
<?php $this->registerJsFile('/js/jquery.form.js', ['position' => yii\web\View::POS_END ]);?>
<?php $this->registerJsFile('/js/bids-form.js', ['position' => yii\web\View::POS_END ]);?>
\ No newline at end of file
......@@ -11459,3 +11459,9 @@ h6 {
.row li{
list-style: none;
}
.teltext-block{
margin-top: -40px;
margin-bottom: 15px;
color: #698387;
font-size: 14px;
}
\ No newline at end of file
......@@ -581,3 +581,66 @@ jQuery(document).ready(function(){
});
});
// prepare the form when the DOM is ready
$(document).ready(function() {
var options = {
//target: '#output2', // target element(s) to be updated with server response
beforeSubmit: showRequest, // pre-submit callback
success: showResponse, // post-submit callback
// other available options:
url: '/users/user/registration' // override for form's 'action' attribute
//type: type // 'get' or 'post', override for form's 'method' attribute
//dataType: null // 'xml', 'script', or 'json' (expected server response type)
//clearForm: true // clear all form fields after successful submit
//resetForm: true // reset the form after successful submit
// $.ajax options can be used here too, for example:
//timeout: 3000
};
// bind to the form's submit event
$('#sh_reg_form').submit(function() {
// inside event callbacks 'this' is the DOM element so we first
// wrap it in a jQuery object and then invoke ajaxSubmit
$(this).ajaxSubmit(options);
// !!! Important !!!
// always return false to prevent standard browser submit and page navigation
return false;
});
});
// pre-submit callback
function showRequest(formData, jqForm, options) {
// formData is an array; here we use $.param to convert it to a string to display it
// but the form plugin does this for you automatically when it submits the data
var queryString = $.param(formData);
// jqForm is a jQuery object encapsulating the form element. To access the
// DOM element for the form do this:
// var formElement = jqForm[0];
//alert('About to submit: \n\n' + queryString);
// here we could return false to prevent the form from being submitted;
// returning anything other than false will allow the form submit to continue
return true;
}
// post-submit callback
function showResponse(responseText, statusText, xhr, $form) {
// for normal html responses, the first argument to the success callback
// is the XMLHttpRequest object's responseText property
// if the ajaxSubmit method was passed an Options Object with the dataType
// property set to 'xml' then the first argument to the success callback
// is the XMLHttpRequest object's responseXML property
// if the ajaxSubmit method was passed an Options Object with the dataType
// property set to 'json' then the first argument to the success callback
// is the json data object returned by the server
//alert('status: ' + statusText + '\n\nresponseText: \n' + responseText +
// '\n\nThe output div should have already been updated with the responseText.');
}
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment