OSDN Git Service

ACLを独自チェックに変更
authorCake <cake_67@users.sourceforge.jp>
Tue, 13 Jul 2010 07:44:04 +0000 (16:44 +0900)
committerCake <cake_67@users.sourceforge.jp>
Tue, 13 Jul 2010 07:44:04 +0000 (16:44 +0900)
20 files changed:
app/config/core.php
app/config/sql/install/create_table.sql
app/config/sql/install/insert_data.sql
app/controllers/app_controller.php
app/controllers/character_pictures_controller.php
app/controllers/character_profile_archives_controller.php
app/controllers/character_sheets_controller.php
app/controllers/characters_controller.php
app/controllers/characters_has_profiles_controller.php
app/controllers/components/auth_plus.php
app/controllers/profile_selects_controller.php
app/controllers/profile_table_statics_controller.php
app/controllers/profile_tables_controller.php
app/controllers/profiles_controller.php
app/controllers/regist_mails_controller.php
app/controllers/site_configs_controller.php
app/controllers/systems_controller.php
app/controllers/users_controller.php
app/models/group.php
app/models/user.php

index 94e5e89..395670f 100644 (file)
  * The classname and database used in CakePHP's
  * access control lists.
  */
-       Configure::write('Acl.classname', 'DbAcl');
-       Configure::write('Acl.database', 'default');
+       //Configure::write('Acl.classname', 'DbAcl');
+       //Configure::write('Acl.database', 'default');
 /**
  * If you are on PHP 5.3 uncomment this line and correct your server timezone
  * to fix the date & time related errors.
index 1b4584f..bde63fe 100644 (file)
@@ -18,10 +18,6 @@ DROP TABLE IF EXISTS `systems`;
 
 DROP TABLE IF EXISTS `attachments`;
 
-DROP TABLE IF EXISTS `aros_acos`;
-DROP TABLE IF EXISTS `acos`;
-DROP TABLE IF EXISTS `aros`;
-
 DROP TABLE IF EXISTS `regist_mails`;
 DROP TABLE IF EXISTS `users`;
 DROP TABLE IF EXISTS `groups`;
@@ -88,43 +84,6 @@ CREATE TABLE `regist_mails` (
     FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
-CREATE TABLE `aros` (
-  `id` int(10) unsigned NOT NULL auto_increment,
-  `parent_id` int(10) default NULL,
-  `model` varchar(255) default '',
-  `foreign_key` int(10) unsigned default NULL,
-  `alias` varchar(255) default '',
-  `lft` int(10) default NULL,
-  `rght` int(10) default NULL,
-  PRIMARY KEY  (`id`),
-  KEY `model_foreign_key` (`model`,`foreign_key`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-CREATE TABLE `acos` (
-  `id` int(10) unsigned NOT NULL auto_increment,
-  `parent_id` int(10) default NULL,
-  `model` varchar(255) default '',
-  `foreign_key` int(10) unsigned default NULL,
-  `alias` varchar(255) default '',
-  `lft` int(10) default NULL,
-  `rght` int(10) default NULL,
-  PRIMARY KEY  (`id`),
-  KEY `alias` (`alias`),
-  KEY `lft_rght` (`lft`,`rght`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
-CREATE TABLE `aros_acos` (
-  `id` int(10) unsigned NOT NULL auto_increment,
-  `aro_id` int(10) unsigned NOT NULL,
-  `aco_id` int(10) unsigned NOT NULL,
-  `_create` char(2) NOT NULL default '0',
-  `_read` char(2) NOT NULL default '0',
-  `_update` char(2) NOT NULL default '0',
-  `_delete` char(2) NOT NULL default '0',
-  PRIMARY KEY  (`id`),
-  KEY `aro_aco` (`aro_id`,`aco_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
 CREATE TABLE `attachments` (
   `id` int(10) unsigned NOT NULL auto_increment,
   `user_id` INTEGER UNSIGNED NOT NULL,
index c5d1c93..016e2df 100644 (file)
@@ -11,84 +11,3 @@ INSERT INTO `groups` VALUES
 (6,'deleted',0);
 /*!40000 ALTER TABLE `groups` ENABLE KEYS */;
 UNLOCK TABLES;
-
-LOCK TABLES `aros` WRITE;
-/*!40000 ALTER TABLE `aros` DISABLE KEYS */;
-INSERT INTO `aros` VALUES 
-(1,NULL,'Group',1,'Group::1',1,2),
-(2,NULL,'Group',2,'Group::2',3,4),
-(3,NULL,'Group',3,'Group::3',5,6),
-(4,NULL,'Group',4,'Group::4',7,8),
-(5,NULL,'Group',5,'Group::5',9,10),
-(6,NULL,'Group',6,'Group::6',11,12);
-/*!40000 ALTER TABLE `aros` ENABLE KEYS */;
-UNLOCK TABLES;
-
-LOCK TABLES `acos` WRITE;
-/*!40000 ALTER TABLE `acos` DISABLE KEYS */;
-INSERT INTO `acos` VALUES 
-(NULL,NULL,'',NULL,'controllers',1,30),
-(NULL,1,'',NULL,'Users',2,3),
-(NULL,1,'',NULL,'Groups',4,5),
-(NULL,NULL,'',NULL,'prefix',31,38),
-(NULL,4,'',NULL,'admin',32,33),
-(NULL,4,'',NULL,'pc',34,35),
-(NULL,4,'',NULL,'m',36,37),
-(NULL,1,'',NULL,'Systems',6,7),
-(NULL,1,'',NULL,'Characters',8,9),
-(NULL,1,'',NULL,'Profiles',10,11),
-(NULL,1,'',NULL,'ProfileSelects',12,13),
-(NULL,1,'',NULL,'ProfileTables',14,15),
-(NULL,1,'',NULL,'SiteConfigs',16,17),
-(NULL,1,'',NULL,'CharacterPictures',18,19),
-(NULL,1,'',NULL,'ProfileTableStatics',20,21),
-(NULL,1,'',NULL,'CharacterSheets',22,23),
-(NULL,1,'',NULL,'CharacterProfileArchives',24,25),
-(NULL,1,'',NULL,'CharactersHasProfiles',26,27),
-(NULL,1,'',NULL,'RegistMails',28,29);
-/*!40000 ALTER TABLE `acos` ENABLE KEYS */;
-UNLOCK TABLES;
-
-LOCK TABLES `aros_acos` WRITE;
-/*!40000 ALTER TABLE `aros_acos` DISABLE KEYS */;
-INSERT INTO `aros_acos` VALUES 
-(NULL,1,1,'1','1','1','1'),
-(NULL,2,1,'1','1','1','1'),
-(NULL,3,1,'-1','-1','-1','-1'),
-(NULL,4,1,'-1','-1','-1','-1'),
-(NULL,5,1,'-1','-1','-1','-1'),
-(NULL,6,1,'-1','-1','-1','-1'),
-(NULL,3,2,'1','1','1','1'),
-(NULL,4,2,'1','1','1','1'),
-(NULL,5,2,'-1','-1','1','-1'),
-(NULL,2,3,'-1','-1','-1','-1'),
-(NULL,1,4,'1','1','1','1'),
-(NULL,2,4,'1','1','1','1'),
-(NULL,3,4,'1','1','1','1'),
-(NULL,4,4,'1','1','1','1'),
-(NULL,5,4,'1','1','1','1'),
-(NULL,3,5,'-1','1','-1','1'),
-(NULL,4,5,'-1','-1','-1','-1'),
-(NULL,5,5,'-1','-1','-1','-1'),
-(NULL,3,8,'-1','1','-1','-1'),
-(NULL,4,8,'-1','1','-1','-1'),
-(NULL,3,9,'1','1','1','1'),
-(NULL,4,9,'1','1','1','1'),
-(NULL,3,10,'-1','1','-1','-1'),
-(NULL,4,10,'-1','1','-1','-1'),
-(NULL,3,11,'-1','1','-1','-1'),
-(NULL,4,11,'-1','1','-1','-1'),
-(NULL,3,12,'-1','1','-1','-1'),
-(NULL,4,12,'-1','1','-1','-1'),
-(NULL,3,13,'1','1','1','1'),
-(NULL,4,13,'1','1','1','1'),
-(NULL,3,13,'1','1','1','1'),
-(NULL,4,13,'1','1','1','1'),
-(NULL,3,14,'1','1','1','1'),
-(NULL,4,14,'1','1','1','1'),
-(NULL,3,17,'1','1','1','1'),
-(NULL,4,17,'1','1','1','1'),
-(NULL,3,18,'1','1','1','1'),
-(NULL,4,18,'1','1','1','1');
-/*!40000 ALTER TABLE `aros_acos` ENABLE KEYS */;
-UNLOCK TABLES;
index ecb98a8..e0d2c39 100644 (file)
@@ -29,7 +29,6 @@ class AppController extends Controller
 
        var $components = array(
                'AuthPlus',
-               'Acl',
                'Cakeplus.HtmlEscape',
                'Token',
                'Crypt',
@@ -84,10 +83,6 @@ class AppController extends Controller
                ),
        );
 
-       /* ACL */
-       // 追加アクション用 crudMap
-       var $actionMapPlus = array();
-
        // POSTのTokenチェックをしないアクション
        var $disableTokenActions = array();
 
@@ -125,9 +120,10 @@ class AppController extends Controller
                $this->set('site_configs', $this->site_configs);
 
                if ($this->AuthPlus) {
-                       // ACL関連
-                       $this->AuthPlus->actionPath = 'controllers/';
-                       $this->AuthPlus->authorize = 'crud';
+//                     // ACL関連
+//                     $this->AuthPlus->actionPath = 'controllers/';
+//                     $this->AuthPlus->authorize = 'crud';
+                       $this->AuthPlus->authorize = 'orig';
                        // 認証済みユーザ情報のセット
                        $this->user_id = $this->AuthPlus->user('id');
                        $user = $this->getUser($this->user_id);
index 9925016..ef6cfd8 100644 (file)
@@ -7,11 +7,6 @@ class CharacterPicturesController extends AppController {
                'Select',
        );
 
-       /* ACL */
-       // 追加アクション用 crudMap
-       var $actionMapPlus = array(
-       );
-
        var $disableTokenActions = array();
 
        var $post_data = array();
index 2683a85..1d5bc6c 100644 (file)
@@ -8,12 +8,6 @@ class CharacterProfileArchivesController extends AppController {
                'Select',
        );
 
-       /* ACL */
-       // 追加アクション用 crudMap
-       var $actionMapPlus = array(
-               'multi_edit' => 'update',
-       );
-
        var $disableTokenActions = array();
 
        var $paginate = array(
index c9b418b..61514c5 100644 (file)
@@ -23,11 +23,6 @@ class CharacterSheetsController extends AppController {
                ),
        );
 
-       /* ACL */
-       // 追加アクション用 crudMap
-       var $actionMapPlus = array(
-       );
-
        var $disableTokenActions = array();
 
 
index 8617532..b34fdb6 100644 (file)
@@ -12,14 +12,6 @@ class CharactersController extends AppController {
        var $view = 'View';
        var $theme = null;
 
-       /* ACL */
-       // 追加アクション用 crudMap
-       var $actionMapPlus = array(
-               'add_milti_profiles' => 'update',
-               'change_system' => 'update',
-               'set_status' => 'update',
-       );
-
        var $disableTokenActions = array();
        var $post_data = array();
 
index ee01332..aa5eca4 100644 (file)
@@ -5,11 +5,6 @@ class CharactersHasProfilesController extends AppController {
        var $helpers = array(
        );
 
-       /* ACL */
-       // 追加アクション用 crudMap
-       var $actionMapPlus = array(
-       );
-
        var $disableTokenActions = array();
 
 
index 31e2ca2..eeb4591 100644 (file)
@@ -20,18 +20,6 @@ class AuthPlusComponent extends AuthComponent {
 
        function initialize(&$controller)
        {
-               // ACL: controllerごとのactionMap設定マージ
-               $this->actionMap = array_merge($this->actionMap, $controller->actionMapPlus);
-               $admin = Configure::read('Routing.admin');
-               if (!empty($admin)) {
-                       foreach ($controller->actionMapPlus as $k => $v) {
-                               $this->actionMap = array_merge(
-                                       $this->actionMap, 
-                                       array($admin . '_'. $k => $v)
-                               );
-                       }
-               }
-
                parent::initialize($controller);
 
                // ログイン後リダイレクト設定
@@ -57,18 +45,35 @@ class AuthPlusComponent extends AuthComponent {
        }
 
        function isAuthorized($type = null, $object = null, $user = null) {
-               $valid = parent::isAuthorized($type, $object, $user);
 
-               // view prefixごとのチェック
-               if ($valid) {
-                       if (isset($this->params['prefix']) 
-                               && $this->params['prefix'] == Configure::read('Routing.admin')) {
-                               $valid = $this->Acl->check(
-                                       $this->user(),
-                                       'admin',
-                                       $this->actionMap[$this->params['action']]
-                               );
+               if ($type == 'orig') {
+                       $user = $this->user();
+
+                       // 未ログイン
+                       if (empty($user)) {
+                               $valid = false;
+                       // 管理者
+                       } elseif (in_array($this->user('group_id'), array(
+                               Configure::read('Group.admin'), 
+                               Configure::read('Group.subadmin'), 
+                               Configure::read('Group.watcher'))
+                       )) {
+                               $valid = true;
+                       // 一般ユーザ
+                       } elseif ($this->user('group_id') == Configure::read('Group.member')) {
+                               if (isset($this->params['prefix']) 
+                                       && $this->params['prefix'] == Configure::read('Routing.admin')) {
+                                       $valid = false;
+                               } else {
+                                       $valid = true;
+
+                               }
+                       } else {
+                               $valid = false;
                        }
+               
+               } else {
+                       $valid = parent::isAuthorized($type, $object, $user);
                }
 
                return $valid;
index 9d191e4..449fa2f 100644 (file)
@@ -6,13 +6,6 @@ class ProfileSelectsController extends AppController {
                'Profiledisp',
        );
 
-       /* ACL */
-       // 追加アクション用 crudMap
-       var $actionMapPlus = array(
-               'listview' => 'read',
-               'edit_all' => 'update',
-       );
-
        // POSTのTokenチェックをしないアクション
        var $disableTokenActions = array();
 
@@ -166,15 +159,15 @@ class ProfileSelectsController extends AppController {
 
                if ($this->check_profile_type($profile)) {
 
-               foreach ($profile['ProfileSelect'] as $k => $v) {
+                       foreach ($profile['ProfileSelect'] as $k => $v) {
 
-                       if (isset($v['sort_order'])  && !empty($v['sort_order'])) {
-                               $sort_order[$k] = $v['sort_order'];
-                       } else {
-                               $sort_order[$k] = 0;
+                               if (isset($v['sort_order'])  && !empty($v['sort_order'])) {
+                                       $sort_order[$k] = $v['sort_order'];
+                               } else {
+                                       $sort_order[$k] = 0;
+                               }
                        }
-               }
-               $profile['ProfileSelect'] = $this->sort4sort_order($profile['ProfileSelect'], $sort_order);
+                       $profile['ProfileSelect'] = $this->sort4sort_order($profile['ProfileSelect'], $sort_order);
 
                        return $profile;
                }
index f13fde9..40ed96c 100644 (file)
@@ -6,11 +6,6 @@ class ProfileTableStaticsController extends AppController {
                'Profiledisp',
        );
 
-       /* ACL */
-       // 追加アクション用 crudMap
-       var $actionMapPlus = array(
-       );
-
        // POSTのTokenチェックをしないアクション
        var $disableTokenActions = array();
 
index ccdef51..d3ec786 100644 (file)
@@ -6,13 +6,6 @@ class ProfileTablesController extends AppController {
                'Profiledisp',
        );
 
-       /* ACL */
-       // 追加アクション用 crudMap
-       var $actionMapPlus = array(
-               'listview' => 'read',
-               'edit_all' => 'update',
-       );
-
        // POSTのTokenチェックをしないアクション
        var $disableTokenActions = array();
 
index c27f892..ea7afa2 100644 (file)
@@ -7,14 +7,6 @@ class ProfilesController extends AppController {
                'Profiledisp',
        );
 
-       /* ACL */
-       // 追加アクション用 crudMap
-       var $actionMapPlus = array(
-               'admin_export_profiles' => 'read',
-               'admin_import_profiles' => 'read',
-               'edit_all' => 'update',
-       );
-
        var $disableTokenActions = array(
        );
 
index 3f6af25..eb9f1d9 100644 (file)
@@ -8,12 +8,6 @@ class RegistMailsController extends AppController {
                'Crypt',
        );
 
-       /* ACL */
-       // 追加アクション用 crudMap
-       var $actionMapPlus = array(
-               'regist' => 'update',
-       );
-
        var $disableTokenActions = array();
 
        // listView用のpagenate設定
index bd9ea5e..078b096 100644 (file)
@@ -5,12 +5,6 @@ class SiteConfigsController extends AppController {
        var $helpers = array(
        );
 
-       /* ACL */
-       // 追加アクション用 crudMap
-       var $actionMapPlus = array(
-               'edit_customcss' => 'update',
-       );
-
        var $disableTokenActions = array(
        );
 
index cc4b300..1e2da01 100644 (file)
@@ -29,11 +29,6 @@ class SystemsController extends AppController {
                ),
        );
 
-       /* ACL */
-       // 追加アクション用 crudMap
-       var $actionMapPlus = array(
-       );
-
        var $disableTokenActions = array(
        );
 
index b52e552..2f0bedd 100644 (file)
@@ -12,15 +12,6 @@ class UsersController extends ModuleController {
                'Mail',
        );
 
-       /* ACL */
-       // 追加アクション用 crudMap
-       var $actionMapPlus = array(
-               'listview' => 'read',
-               'change_password' => 'update',
-               'edit_image' => 'update',
-               'edit_mail' => 'update',
-       );
-
        var $disableTokenActions = array('add','mobile_add');
 
        // listView用のpagenate設定
index fc6d8fd..03c16fe 100644 (file)
@@ -3,41 +3,8 @@ class Group extends AppModel {
 
        var $name = 'Group';
        var $actsAs = array(
-               'Acl' => 'requester', // ARO自動登録用
        );
 
        var $is_active = array(1, 2, 3, 4);
-
-       function parentNode() {
-               if (!$this->id) {
-                       return null;
-               }
-               $data = $this->read();
-               if (!$data['Group']['parent_id']){
-                       return null;
-               } else {
-                       return array('model' => 'Group', 'foreign_key' => $data['Group']['parent_id']);
-               }
-       }
-
-       // 更新時に親IDを変更する
-       function save($data = null, $validate = true, $fieldList = array())
-       {
-               if (parent::save($data, $validate, $fieldList)) {
-                       $conditions = array(
-                               'model' => $this->name,
-                               'foreign_key' => $this->id,
-                       );
-
-                       App::import('Component', 'Acl');
-                       $Aro = new Aro;
-                       $Aro->id = $Aro->field('id', $conditions);
-                       $Aro->saveField('parent_id', $data['Group']['parent_id']);
-                       $Aro->saveField('alias', $this->name . '::' . $this->id);
-                       return true;
-               }
-               return false;
-       }
-
 }
 ?>
index e23b829..6326730 100644 (file)
@@ -7,7 +7,6 @@ class User extends AppModel {
                'Cakeplus.ValidationErrorI18n',
                'Cakeplus.AddValidationRule',
                'SanitizePlus',
-               'Acl' => 'requester', // ARO自動登録用
                'Containable',
        );
 
@@ -163,44 +162,4 @@ class User extends AppModel {
 
                return parent::betweenWrapper($check[0], $idLength['min'], $idLength['max']);
        }
-
-       // ACL
-       function parentNode()
-       {
-               if (!$this->id && empty($this->data)) {
-                       return null;
-               }
-               $data = $this->data;
-               if (empty($this->data)) {
-                       $data = $this->read();
-               } elseif (!isset($data['User']['group_id']) || !$data['User']['group_id']) {
-                       $data['User']['group_id'] = $this->read('group_id');
-               }
-               if (!$data['User']['group_id']) {
-                       return null;
-               } else {
-                       return array('model' => 'Group', 'foreign_key' => $data['User']['group_id']);
-               }
-       }
-       // 更新時に親IDを変更する
-       function save($data = null, $validate = true, $fieldList = array())
-       {
-               if (parent::save($data, $validate, $fieldList)) {
-                       $conditions = array(
-                               'model' => $this->name,
-                               'foreign_key' => $this->id,
-                       );
-
-                       App::import('Component', 'Acl');
-                       $Aro = new Aro;
-                       $Aro->id = $Aro->field('id', $conditions);
-                       if (isset($data['User']['group_id']) && $data['User']['group_id']) {
-                               $Aro->saveField('parent_id', $data['User']['group_id']);
-                       }
-                       $Aro->saveField('alias', $this->name . '::' . $this->id);
-                       return true;
-               }
-               return false;
-       }
-
 }