YII+Giix+YII-user+Srbac
- 詳細內容
- 分類: Php
- 發佈: 2014-09-03, 週三 11:01
- 作者 Super User
- 點擊數: 14752
yii-1.1.14.f0fee9.tar.gz
giix-1.9.2.zip
yii-user-0.3-61-gfc69518.zip
srbac_1.2_r228.zip
Installing YII
==============
tar -zxvf yii-1.1.14.f0fee9.tar.gz
mv yii-1.1.14.f0fee9 yii
mv yii WebRoot(<---Your WebRoot)
cd WebRoot/yii
framework/yiic webapp testdrive
chown -R www:www WebRoot/yii
Create testdrive Database:
#mysql
mysql>create database testdrive
mysql>exit
Import All of the YII-USER tables into testdrive Database:
#mysql testdrive < WebRoot/yii/testdrive/protected/modules/user/data/schema.mysql.sql
Installing giix
===============
1) Extract the directories "giix-core" and "giix-components" from the
downloaded archive into your application's protected/extensions directory.
tar -zxvf giix-1.9.2.zip
mv giix-core WebRoot/yii/testdrive/protected/extensions
mv giix-components WebRoot/yii/testdrive/protected/extensions
chown -R www:www WebRoot/yii
2) Configure the gii generator path in your application, like:
cd WebRoot/yii/testdrive
vi ./protected/config/main.php
'modules'=>array(
// uncomment the following to enable the Gii tool
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'Enter Your Password Here',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1','X.X.X.X'), //X.X.X.X <--- Your IP address
'generatorPaths' => array(
'ext.giix-core', // giix generators
),
),
3) Configure your application to automatically load the giix component classes
when needed, like:
cd WebRoot/yii/testdrive
vi ./protected/config/main.php
'import'=>array(
'ext.giix-components.*', // giix components
It is recommended to set at least the 'password' and 'ipFilters' properties
in gii for security.
For more information see the gii documentation at <http://www.yiiframework.com/doc/api/GiiModule>.
Additionaly, you may remove the entire 'giix-core' directory and generator
configuration (step 2 above) when releasing your Web application for improved
security.
Then point your browser to /path/to/application/index.php?r=gii
Installing YII-USER
===================
Extract the release file under protected/modules
tar -zxvf yii-user-0.3-61-gfc69518.zip
mkdir WebRoot/yii/testdrive/protected/modules
mv mishamx-yii-user-fc69518 WebRoot/yii/testdrive/protected/modules/user
chown -R www:www WebRoot/yii
Create testdrive Database:
mysql
create database testdrive;
exit
cd WebRoot/yii/testdrive
vi ./protected/config/main.php
'import'=>array(
'application.modules.user.models.*',
'application.modules.user.components.*',
'modules'=>array(
'user'=>array(
'hash' => 'md5',
'sendActivationMail' => true,
'loginNotActiv' => false,
'activeAfterRegister' => false,
'autoLogin' => true,
'registrationUrl' => array('/user/registration'),
'recoveryUrl' => array('/user/recovery'),
'loginUrl' => array('/user/login'),
'returnUrl' => array('/user/profile'),
'returnLogoutUrl' => array('/user/login'),
),
'components'=>array(
'user'=>array(
'class' => 'WebUser',
'loginUrl' => array('/user/login'),
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=testdrive',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'tablePrefix' => 'tbl_',
),
cd WebRoot/yii/testdrive
vi ./protected/config/console.php
'modules'=>array(
'user'=>array(
'hash' => 'md5',
'sendActivationMail' => true,
'loginNotActiv' => false,
'activeAfterRegister' => false,
'autoLogin' => true,
'registrationUrl' => array('/user/registration'),
'recoveryUrl' => array('/user/recovery'),
'loginUrl' => array('/user/login'),
'returnUrl' => array('/user/profile'),
'returnLogoutUrl' => array('/user/login'),
),
'components'=>array(
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=testdrive',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'tablePrefix' => 'tbl_',
),
cd WebRoot/yii/testdrive
./protected/yiic migrate --migrationPath=user.migrations
Input admin login, email and password
cd WebRoot/yii/testdrive
vi ./protected/views/layouts/main.php
<?php $this->widget('zii.widgets.CMenu',array(
'items'=>array(
array('url'=>Yii::app()->getModule('user')->loginUrl, 'label'=>Yii::app()->getModule('user')->t("Login"), 'visible'=>Yii::app
()->user->isGuest),
//array('url'=>Yii::app()->getModule('user')->registrationUrl, 'label'=>Yii::app()->getModule('user')->t("Register"),
'visible'
=>Yii::app()->user->isGuest),
//array('url'=>Yii::app()->getModule('user')->profileUrl, 'label'=>Yii::app()->getModule('user')->t("Profile"), 'visible'=>!
Yii
::app()->user->isGuest),
array('url'=>Yii::app()->getModule('user')->logoutUrl, 'label'=>Yii::app()->getModule('user')->t("Logout").' ('.Yii::app()->u
ser->name.')', 'visible'=>!Yii::app()->user->isGuest),
),
)); ?>
Installing Srbac
================
Extract the release file under protected/modules
tar -zxvf srbac_1.2_r228.zip
mv srbac WebRoot/yii/testdrive/protected/modules
chown -R www:www WebRoot/yii
cd WebRoot/yii/testdrive
vi ./protected/config/main.php
'import'=>array(
'application.modules.srbac.controllers.SBaseController',
'modules'=>array(
'srbac' => array(
'userclass'=>'User',
'userid'=>'id',
'username'=>'username',
'delimeter'=>'@',
'debug'=>true,
'pageSize'=>10,
'superUser' =>'Authority',
'css'=>'srbac.css',
'layout'=>'application.views.layouts.main',
'notAuthorizedView'=> 'srbac.views.authitem.unauthorized',
'alwaysAllowed'=>array('SiteLogin','SiteLogout','SiteIndex','SiteAdmin','SiteError', 'SiteContact'),
'userActions'=>array('Show','View','List'),
'listBoxNumberOfLines' => 15,
'imagesPath' => 'srbac.images',
'imagesPack'=>'noia',
'iconText'=>true,
'header'=>'srbac.views.authitem.header',
'footer'=>'srbac.views.authitem.footer',
'showHeader'=>true,
'showFooter'=>true,
'alwaysAllowedPath'=>'srbac.components',
),
'components'=>array(
'authManager'=>array(
'class'=>'srbac.components.SDbAuthManager',
'connectionID'=>'db',
'itemTable'=>'tbl_items',
'assignmentTable'=>'tbl_assignments',
'itemChildTable'=>'tbl_itemchildren',
),
Then point your browser to /path/to/application/index.php?r=srbac and you will be redirected to the installation page.
A check is performed and if everything is OK you can proceed to the instalation
cd WebRoot/yii/testdrive
vi ./protected/modules/srbac/controllers/SBaseController.php
class SBaseController extends CController {
change to
class SBaseController extends GxController {
vi ./protected/modules/user/controllers/ActivationController.php
class ActivationController extends Controller
change to
class ActivationController extends SBaseController
vi ./protected/modules/user/controllers/AdminController.php
class AdminController extends Controller
change to
class AdminController extends SBaseController
vi ./protected/modules/user/controllers/DefaultController.php
class DefaultController extends Controller
change to
class DefaultController extends SBaseController
vi ./protected/modules/user/controllers/LoginController.php
class LoginController extends Controller
change to
class LoginController extends SBaseController
vi ./protected/modules/user/controllers/LogoutController.php
class LogoutController extends Controller
change to
class LogoutController extends SBaseController
vi ./protected/modules/user/controllers/ProfileController.php
class ProfileController extends Controller
change to
class ProfileController extends SBaseController
vi ./protected/modules/user/controllers/ProfileFieldController.php
class ProfileFieldController extends Controller
change to
class ProfileFieldController extends SBaseController
vi ./protected/modules/user/controllers/RecoveryController.php
class RecoveryController extends Controller
change to
class RecoveryController extends SBaseController
vi ./protected/modules/user/controllers/RegistrationController.php
class RegistrationController extends Controller
change to
class RegistrationController extends SBaseController
vi ./protected/modules/user/controllers/UserController.php
class UserController extends Controller
change to
class UserController extends SBaseController
......