Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
63272f41
Commit
63272f41
authored
Feb 15, 2014
by
Johnny Theill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update doc-blocks and small fixes according to coding standards
parent
ca122418
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
65 additions
and
28 deletions
+65
-28
SiteController.php
apps/advanced/backend/controllers/SiteController.php
+2
-1
LoginForm.php
apps/advanced/common/models/LoginForm.php
+2
-1
User.php
apps/advanced/common/models/User.php
+13
-6
SiteController.php
apps/advanced/frontend/controllers/SiteController.php
+3
-2
ContactForm.php
apps/advanced/frontend/models/ContactForm.php
+5
-3
PasswordResetRequestForm.php
apps/advanced/frontend/models/PasswordResetRequestForm.php
+4
-4
ResetPasswordForm.php
apps/advanced/frontend/models/ResetPasswordForm.php
+5
-5
SignupForm.php
apps/advanced/frontend/models/SignupForm.php
+4
-4
SiteController.php
apps/basic/controllers/SiteController.php
+3
-2
User.php
apps/basic/models/User.php
+24
-0
No files found.
apps/advanced/backend/controllers/SiteController.php
View file @
63272f41
...
@@ -72,4 +72,4 @@ class SiteController extends Controller
...
@@ -72,4 +72,4 @@ class SiteController extends Controller
Yii
::
$app
->
user
->
logout
();
Yii
::
$app
->
user
->
logout
();
return
$this
->
goHome
();
return
$this
->
goHome
();
}
}
}
}
\ No newline at end of file
apps/advanced/common/models/LoginForm.php
View file @
63272f41
...
@@ -67,4 +67,4 @@ class LoginForm extends Model
...
@@ -67,4 +67,4 @@ class LoginForm extends Model
}
}
return
$this
->
_user
;
return
$this
->
_user
;
}
}
}
}
\ No newline at end of file
apps/advanced/common/models/User.php
View file @
63272f41
...
@@ -27,6 +27,12 @@ class User extends ActiveRecord implements IdentityInterface
...
@@ -27,6 +27,12 @@ class User extends ActiveRecord implements IdentityInterface
const
ROLE_USER
=
10
;
const
ROLE_USER
=
10
;
/**
* Creates a new user
*
* @param $attributes
* @return static|null
*/
public
static
function
create
(
$attributes
)
public
static
function
create
(
$attributes
)
{
{
/** @var User $user */
/** @var User $user */
...
@@ -69,18 +75,18 @@ class User extends ActiveRecord implements IdentityInterface
...
@@ -69,18 +75,18 @@ class User extends ActiveRecord implements IdentityInterface
* Finds user by username
* Finds user by username
*
*
* @param string $username
* @param string $username
* @return s
elf
* @return s
tatic|null
*/
*/
public
static
function
findByUsername
(
$username
)
public
static
function
findByUsername
(
$username
)
{
{
return
static
::
find
([
'username'
=>
$username
,
'status'
=>
s
tatic
::
STATUS_ACTIVE
]);
return
static
::
find
([
'username'
=>
$username
,
'status'
=>
s
elf
::
STATUS_ACTIVE
]);
}
}
/**
/**
* Finds user by password reset token
* Finds user by password reset token
*
*
* @param string $token password reset token
* @param string $token password reset token
* @return s
elf
* @return s
tatic|null
*/
*/
public
static
function
findByPasswordResetToken
(
$token
)
public
static
function
findByPasswordResetToken
(
$token
)
{
{
...
@@ -92,9 +98,9 @@ class User extends ActiveRecord implements IdentityInterface
...
@@ -92,9 +98,9 @@ class User extends ActiveRecord implements IdentityInterface
return
null
;
return
null
;
}
}
return
User
::
find
([
return
static
::
find
([
'password_reset_token'
=>
$token
,
'password_reset_token'
=>
$token
,
'status'
=>
User
::
STATUS_ACTIVE
,
'status'
=>
self
::
STATUS_ACTIVE
,
]);
]);
}
}
...
@@ -189,4 +195,4 @@ class User extends ActiveRecord implements IdentityInterface
...
@@ -189,4 +195,4 @@ class User extends ActiveRecord implements IdentityInterface
[
'email'
,
'unique'
],
[
'email'
,
'unique'
],
];
];
}
}
}
}
\ No newline at end of file
apps/advanced/frontend/controllers/SiteController.php
View file @
63272f41
...
@@ -86,7 +86,7 @@ class SiteController extends Controller
...
@@ -86,7 +86,7 @@ class SiteController extends Controller
public
function
actionContact
()
public
function
actionContact
()
{
{
$model
=
new
ContactForm
;
$model
=
new
ContactForm
()
;
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
())
&&
$model
->
contact
(
Yii
::
$app
->
params
[
'adminEmail'
]))
{
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
())
&&
$model
->
contact
(
Yii
::
$app
->
params
[
'adminEmail'
]))
{
Yii
::
$app
->
session
->
setFlash
(
'success'
,
'Thank you for contacting us. We will respond to you as soon as possible.'
);
Yii
::
$app
->
session
->
setFlash
(
'success'
,
'Thank you for contacting us. We will respond to you as soon as possible.'
);
return
$this
->
refresh
();
return
$this
->
refresh
();
...
@@ -153,4 +153,4 @@ class SiteController extends Controller
...
@@ -153,4 +153,4 @@ class SiteController extends Controller
'model'
=>
$model
,
'model'
=>
$model
,
]);
]);
}
}
}
}
\ No newline at end of file
apps/advanced/frontend/models/ContactForm.php
View file @
63272f41
...
@@ -17,7 +17,7 @@ class ContactForm extends Model
...
@@ -17,7 +17,7 @@ class ContactForm extends Model
public
$verifyCode
;
public
$verifyCode
;
/**
/**
* @
return array the validation rules.
* @
inheritdoc
*/
*/
public
function
rules
()
public
function
rules
()
{
{
...
@@ -32,7 +32,7 @@ class ContactForm extends Model
...
@@ -32,7 +32,7 @@ class ContactForm extends Model
}
}
/**
/**
* @
return array customized attribute labels
* @
inheritdoc
*/
*/
public
function
attributeLabels
()
public
function
attributeLabels
()
{
{
...
@@ -43,6 +43,7 @@ class ContactForm extends Model
...
@@ -43,6 +43,7 @@ class ContactForm extends Model
/**
/**
* Sends an email to the specified email address using the information collected by this model.
* Sends an email to the specified email address using the information collected by this model.
*
* @param string $email the target email address
* @param string $email the target email address
* @return boolean whether the model passes validation
* @return boolean whether the model passes validation
*/
*/
...
@@ -60,4 +61,4 @@ class ContactForm extends Model
...
@@ -60,4 +61,4 @@ class ContactForm extends Model
return
false
;
return
false
;
}
}
}
}
}
}
\ No newline at end of file
apps/advanced/frontend/models/PasswordResetRequestForm.php
View file @
63272f41
...
@@ -25,8 +25,9 @@ class PasswordResetRequestForm extends Model
...
@@ -25,8 +25,9 @@ class PasswordResetRequestForm extends Model
}
}
/**
/**
* Sends an email with a link, for resetting the password.
*
*
* @return boolean
sends an email
* @return boolean
whether the email was send
*/
*/
public
function
sendEmail
()
public
function
sendEmail
()
{
{
...
@@ -51,5 +52,4 @@ class PasswordResetRequestForm extends Model
...
@@ -51,5 +52,4 @@ class PasswordResetRequestForm extends Model
return
false
;
return
false
;
}
}
}
}
\ No newline at end of file
\ No newline at end of file
apps/advanced/frontend/models/ResetPasswordForm.php
View file @
63272f41
...
@@ -19,7 +19,7 @@ class ResetPasswordForm extends Model
...
@@ -19,7 +19,7 @@ class ResetPasswordForm extends Model
private
$_user
;
private
$_user
;
/**
/**
* Creates a form model given a token
* Creates a form model given a token
.
*
*
* @param string $token
* @param string $token
* @param array $config name-value pairs that will be used to initialize the object properties
* @param array $config name-value pairs that will be used to initialize the object properties
...
@@ -38,7 +38,7 @@ class ResetPasswordForm extends Model
...
@@ -38,7 +38,7 @@ class ResetPasswordForm extends Model
}
}
/**
/**
* @
return array the validation rules.
* @
inheritdoc
*/
*/
public
function
rules
()
public
function
rules
()
{
{
...
@@ -50,6 +50,7 @@ class ResetPasswordForm extends Model
...
@@ -50,6 +50,7 @@ class ResetPasswordForm extends Model
/**
/**
* Resets password.
* Resets password.
*
* @return boolean if password was reset.
* @return boolean if password was reset.
*/
*/
public
function
resetPassword
()
public
function
resetPassword
()
...
@@ -59,5 +60,4 @@ class ResetPasswordForm extends Model
...
@@ -59,5 +60,4 @@ class ResetPasswordForm extends Model
$user
->
removePasswordResetToken
();
$user
->
removePasswordResetToken
();
return
$user
->
save
();
return
$user
->
save
();
}
}
}
}
\ No newline at end of file
\ No newline at end of file
apps/advanced/frontend/models/SignupForm.php
View file @
63272f41
...
@@ -36,7 +36,8 @@ class SignupForm extends Model
...
@@ -36,7 +36,8 @@ class SignupForm extends Model
/**
/**
* Signs user up.
* Signs user up.
* @return User saved model
*
* @return User|null the saved model or null if saving fails
*/
*/
public
function
signup
()
public
function
signup
()
{
{
...
@@ -45,5 +46,4 @@ class SignupForm extends Model
...
@@ -45,5 +46,4 @@ class SignupForm extends Model
}
}
return
null
;
return
null
;
}
}
}
}
\ No newline at end of file
\ No newline at end of file
apps/basic/controllers/SiteController.php
View file @
63272f41
...
@@ -76,7 +76,7 @@ class SiteController extends Controller
...
@@ -76,7 +76,7 @@ class SiteController extends Controller
public
function
actionContact
()
public
function
actionContact
()
{
{
$model
=
new
ContactForm
;
$model
=
new
ContactForm
()
;
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
())
&&
$model
->
contact
(
Yii
::
$app
->
params
[
'adminEmail'
]))
{
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
())
&&
$model
->
contact
(
Yii
::
$app
->
params
[
'adminEmail'
]))
{
Yii
::
$app
->
session
->
setFlash
(
'contactFormSubmitted'
);
Yii
::
$app
->
session
->
setFlash
(
'contactFormSubmitted'
);
return
$this
->
refresh
();
return
$this
->
refresh
();
...
@@ -91,4 +91,4 @@ class SiteController extends Controller
...
@@ -91,4 +91,4 @@ class SiteController extends Controller
{
{
return
$this
->
render
(
'about'
);
return
$this
->
render
(
'about'
);
}
}
}
}
\ No newline at end of file
apps/basic/models/User.php
View file @
63272f41
...
@@ -24,11 +24,20 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface
...
@@ -24,11 +24,20 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface
],
],
];
];
/**
* @inheritdoc
*/
public
static
function
findIdentity
(
$id
)
public
static
function
findIdentity
(
$id
)
{
{
return
isset
(
self
::
$users
[
$id
])
?
new
static
(
self
::
$users
[
$id
])
:
null
;
return
isset
(
self
::
$users
[
$id
])
?
new
static
(
self
::
$users
[
$id
])
:
null
;
}
}
/**
* Finds user by username
*
* @param string $username
* @return static|null
*/
public
static
function
findByUsername
(
$username
)
public
static
function
findByUsername
(
$username
)
{
{
foreach
(
self
::
$users
as
$user
)
{
foreach
(
self
::
$users
as
$user
)
{
...
@@ -39,21 +48,36 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface
...
@@ -39,21 +48,36 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface
return
null
;
return
null
;
}
}
/**
* @inheritdoc
*/
public
function
getId
()
public
function
getId
()
{
{
return
$this
->
id
;
return
$this
->
id
;
}
}
/**
* @inheritdoc
*/
public
function
getAuthKey
()
public
function
getAuthKey
()
{
{
return
$this
->
authKey
;
return
$this
->
authKey
;
}
}
/**
* @inheritdoc
*/
public
function
validateAuthKey
(
$authKey
)
public
function
validateAuthKey
(
$authKey
)
{
{
return
$this
->
authKey
===
$authKey
;
return
$this
->
authKey
===
$authKey
;
}
}
/**
* Validates password
*
* @param string $password password to validate
* @return bool if password provided is valid for current user
*/
public
function
validatePassword
(
$password
)
public
function
validatePassword
(
$password
)
{
{
return
$this
->
password
===
$password
;
return
$this
->
password
===
$password
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment