tolong bantuannya ane mw buat user level access
saya buat sebuah file dengan nama “EWebUser.php” di /protected/components
<?php
class EWebUser extends CWebUser {
protected $_model;
protected function loadUser() {
if ($this->_model === null) {
$this->_model = User::model()->findByPk($this->id);
}
return $this->_model;
}
function getLevel() {
$user = $this->loadUser();
if ($user)
return $user->level_id;
return 100;
}
}
terus di /config/main.php sya tambahkan
‘components’ => array(
'user' => array(
// There you go, use our 'extended' version
'class' => 'application.components.EWebUser',
// enable cookie-based authentication
'allowAutoLogin' => true,
),
dan di user controller sya tulis sbb
public function accessRules() {
return array(
array('allow',
'actions' => array('create', 'captcha'),
'users' => array('*'),
),
array('allow',
'actions' => array('update', 'view'),
'users' => array('@'),
),
array('allow',
'actions' => array('admin', 'index', 'delete'),
'expression' => '$user->getLevel()<=1',
),
array('deny',
'users' => array('*'),
),
);
}
tapi muncul error seperti ini
Alias "application.components.EWebUser" is invalid. Make sure it points to an existing PHP file.
tolong bantuannya gan…