Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Erik Minekus
committed
Nov 17, 2013
1 parent
e61a81a
commit bcdf0c5
Showing
35 changed files
with
209 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
class UserIdBehavior extends CActiveRecordBehavior | ||
{ | ||
public $attributes = null; | ||
|
||
|
||
public function beforeSave($event) | ||
{ | ||
if(!$this->owner->isNewRecord) | ||
return; | ||
|
||
if(Yii::app() instanceof CConsoleApplication || Yii::app()->user->isGuest) | ||
return; | ||
|
||
$id = Yii::app()->user->id; | ||
|
||
foreach((array)$this->attributes as $attribute) | ||
{ | ||
$this->owner->{$attribute} = $id; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
class UserIpBehavior extends CActiveRecordBehavior | ||
{ | ||
public $attributes = null; | ||
|
||
|
||
public function beforeSave($event) | ||
{ | ||
if(!$this->owner->isNewRecord) | ||
return; | ||
|
||
$ip = Yii::app() instanceof CConsoleApplication | ||
? '127.0.0.1' | ||
: Yii::app()->request->userHostAddress; | ||
|
||
foreach((array)$this->attributes as $attribute) | ||
{ | ||
$this->owner->{$attribute} = $ip; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.