Created
May 19, 2012 07:18
-
-
Save mojaie/2729847 to your computer and use it in GitHub Desktop.
CakePHP:test002_1
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
<?php | |
class TestsController extends AppController { | |
public $layout = null; | |
public function beforeFilter(){ | |
//openaccessには誰でもアクセスできる | |
$this->Auth->allowedActions = array('openaccess'); | |
//親クラス(AppController)読み込み | |
parent::beforeFilter(); | |
} | |
public function isAuthorized() { | |
if ($this->Auth->user('group') == 'admin') { | |
//admin権限を持つユーザは全てのページにアクセスできる | |
return true; | |
} elseif ($this->Auth->user('group') == 'user') { | |
if ($this->action == 'useronly') { | |
//user権限を持つユーザはuseronlyにアクセスできる | |
return true; | |
} | |
} | |
return false; | |
} | |
//誰でもアクセスできるページ | |
public function openaccess() { | |
} | |
//会員だけアクセスできるページ | |
public function useronly() { | |
} | |
//管理者だけアクセスできるページ | |
public function adminonly() { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment