soter
(Varza1999)
December 4, 2011, 7:30am
1
Hello!
Any ideas on how to approach this workflow on yii?
Auth no1: (autologin)
Auth no2:
Any ideas please? I’m moving in circle on this…
kind regards,
soter
perochak
(Amjad Mughal)
December 4, 2011, 8:13am
2
you can do this using access control and define its rules in your controllers.
public function accessRules()
{
return array(
array('allow', // allow all users to perform 'index' and 'view' actions
'actions'=>array('index','read'),
'users'=>array('*'),
),
array('allow', // allow authenticated user to perform 'create' and 'update' actions
'actions'=>array('create','update','add','admin','delete'),
'users'=>Yii::app()->getModule('user')->getAdmins(),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
jacmoe
(Jacob Moen)
December 4, 2011, 8:59am
3
[color="#006400 "]/* moved to general Yii 1.1 discussion */[/color]
soter
(Varza1999)
December 4, 2011, 9:50am
4
Than you for your answer
now let’s expand a little:
Auth no1: (autologin)
Auth no2:
What do you say?
gusnips
(Gustavo)
December 4, 2011, 10:10am
5
I would create a widget to create this menu
//view code
if(!Yii::app()->user->isGuest){
$this->widget('UserMenu');
}
//UserMenu widget
Yii::import('zii.widgets.CPortlet');
class UserMenu extends CPortlet{
public $title='User menu';
function renderContent(){
$models=UserLink::model()->activeUser()->findAll();
$links=array();
foreach($models as $model){
$links[]=array('label'=>$model->label,'url'=>$model->url)
}
$this->widget('zii.widgets.CMenu',array(
'items'=>$links
));
}
}
//UserLink model
class UserLink extends CActiveRecord{
//...
function scopes(){
return array(
'activeUser'=>array(
'condition'=>'user_id=:userID',
'params'=>array('userID'=>Yii::app()->user->id),
)
);
}
}
That would do it
Also, an access rule could be something like this
array('allow',
'actions'=>array('index','read'),
'expression'=>'isset($_SERVER["LOGON_USER"])',
),
soter
(Varza1999)
December 4, 2011, 10:59am
6
I would create a widget to create this menu
//view code
if(!Yii::app()->user->isGuest){
$this->widget('UserMenu');
}
//UserMenu widget
Yii::import('zii.widgets.CPortlet');
class UserMenu extends CPortlet{
public $title='User menu';
function renderContent(){
$models=UserLink::model()->activeUser()->findAll();
$links=array();
foreach($models as $model){
$links[]=array('label'=>$model->label,'url'=>$model->url)
}
$this->widget('zii.widgets.CMenu',array(
'items'=>$links
));
}
}
//UserLink model
class UserLink extends CActiveRecord{
//...
function scopes(){
return array(
'activeUser'=>array(
'condition'=>'user_id=:userID',
'params'=>array('userID'=>Yii::app()->user->id),
)
);
}
}
That would do it
Also, an access rule could be something like this
array('allow',
'actions'=>array('index','read'),
'expression'=>'isset($_SERVER["LOGON_USER"])',
),
wow, almost enlightened than you very much!