Website is working!
This commit is contained in:
1 parent
c978ba8e19
commit
2ed0710575
24 files changed
+644
-119
No files matched your search
@@ -6,6 +6,7 @@ class AddPostForm extends CFormModel
|
||||
public $title;
|
||||
public $text;
|
||||
public $image;
|
||||
public $date;
|
||||
|
||||
|
||||
/**
|
||||
@@ -16,10 +17,20 @@ class AddPostForm extends CFormModel
|
||||
public function rules()
|
||||
{
|
||||
return array(
|
||||
array('title, text, image', 'required'),
|
||||
array('image', 'file', 'types'=>'jpg, gif, png'),
|
||||
array('title, text, image', 'required', 'message'=>'{attribute} ' . Yii::t('app', 'Field should not be blank')),
|
||||
array('title', 'length', 'max'=>45, 'tooLong'=>'{attribute} ' . Yii::t('app', 'Line is too long')),
|
||||
array('image', 'file', 'types'=>'jpg, gif, png', 'maxSize'=>8388608, 'message'=>'{attribute} ' . Yii::t('app', 'Image must be jpg, gif or png, and its size should not exceed 8 megabytes')),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function attributeLabels(){
|
||||
return array(
|
||||
'title' => Yii::t('app', 'Title:'),
|
||||
'text' => Yii::t('app', 'Text:'),
|
||||
'image' => Yii::t('app', 'Image:'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -22,7 +22,9 @@ class LoginForm extends CFormModel
|
||||
{
|
||||
return array(
|
||||
// username and password are required
|
||||
array('username, password', 'required'),
|
||||
array('username, password', 'required', 'message'=>'{attribute} ' . Yii::t('app', 'Field should not be blank')),
|
||||
array('username, password', 'length', 'max'=>45, 'tooLong'=>'{attribute} ' . Yii::t('app', 'Line is too long')),
|
||||
|
||||
// rememberMe needs to be a boolean
|
||||
array('rememberMe', 'boolean'),
|
||||
// password needs to be authenticated
|
||||
@@ -30,15 +32,7 @@ class LoginForm extends CFormModel
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares attribute labels.
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return array(
|
||||
'rememberMe'=>'Remember me next time',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Authenticates the password.
|
||||
@@ -50,7 +44,7 @@ class LoginForm extends CFormModel
|
||||
{
|
||||
$this->_identity=new UserIdentity($this->username,$this->password);
|
||||
if(!$this->_identity->authenticate())
|
||||
$this->addError('password','Incorrect username or password.');
|
||||
$this->addError('password', Yii::t('app', 'Login or password is incorrect'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,4 +68,12 @@ class LoginForm extends CFormModel
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
function attributeLabels(){
|
||||
return array(
|
||||
'username' => Yii::t('app', 'Username:'),
|
||||
'password' => Yii::t('app', 'Password:'),
|
||||
'rememberMe' => Yii::t('app', 'Remember me'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* LoginForm class.
|
||||
* LoginForm is the data structure for keeping
|
||||
* user login form data. It is used by the 'login' action of 'SiteController'.
|
||||
*/
|
||||
class RegisterForm extends CFormModel
|
||||
{
|
||||
public $username;
|
||||
public $password;
|
||||
public $email;
|
||||
|
||||
/**
|
||||
* Declares the validation rules.
|
||||
* The rules state that username and password are required,
|
||||
* and password needs to be authenticated.
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return array(
|
||||
array('username, password, email', 'required'),
|
||||
array('email', 'email'),
|
||||
array('username', 'unique'),
|
||||
);
|
||||
}
|
||||
|
||||
public function unique($attribute,$params)
|
||||
{
|
||||
|
||||
if(!$this->hasErrors())
|
||||
{
|
||||
$count = user::model()->count('username=:username', array('username'=>$this->username));
|
||||
if ($count != 0)
|
||||
$this->addError('username','Username already exists');
|
||||
|
||||
$count = user::model()->count('email=:email', array('email'=>$this->email));
|
||||
if ($count != 0)
|
||||
$this->addError('email','Email already exists');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
class User extends CActiveRecord
|
||||
{
|
||||
|
||||
public $verifyCode;
|
||||
|
||||
public static function model($className=__CLASS__)
|
||||
{
|
||||
return parent::model($className);
|
||||
@@ -15,9 +18,32 @@ class User extends CActiveRecord
|
||||
public function rules()
|
||||
{
|
||||
return array(
|
||||
array('username, password, email', 'required'),
|
||||
array('email', 'email'),
|
||||
array('username, password, email', 'required', 'message'=>'{attribute} ' . Yii::t('app', 'Field should not be blank')),
|
||||
array('username, password, email', 'length', 'max'=>45, 'tooLong'=>'{attribute} ' . Yii::t('app', 'Line is too long')),
|
||||
array('email', 'email', 'message'=>Yii::t('app', 'Email address is not correct')),
|
||||
array('username, email', 'unique'),
|
||||
array('verifyCode', 'captcha', 'allowEmpty'=>false, 'message'=>Yii::t('app', 'Confirmation code is not correct')),
|
||||
);
|
||||
}
|
||||
|
||||
public function unique($attribute,$params)
|
||||
{
|
||||
|
||||
if(!$this->hasErrors())
|
||||
{
|
||||
$count = user::model()->count($attribute . '=:attribute', array('attribute'=>$this->attributes[$attribute]));
|
||||
if ($count != 0)
|
||||
$this->addError($attribute, Yii::t('app', 'User {attribute} is already registered in system'), array('{attribute}' => $this->attributes[$attribute]));
|
||||
}
|
||||
}
|
||||
|
||||
function attributeLabels(){
|
||||
return array(
|
||||
'username' => Yii::t('app', 'Username:'),
|
||||
'password' => Yii::t('app', 'Password:'),
|
||||
'email' => Yii::t('app', 'Email:'),
|
||||
'verifyCode' => Yii::t('app', 'Confirmation code:'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user