当前位置: 首页>>代码示例>>PHP>>正文


PHP Perms::getAll方法代码示例

本文整理汇总了PHP中Perms::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Perms::getAll方法的具体用法?PHP Perms::getAll怎么用?PHP Perms::getAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Perms的用法示例。


在下文中一共展示了Perms::getAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: perms

 public function perms()
 {
     if ($this->requiresPermission('manage roles', $this->name)) {
         Fabriq::title('Admin | Manage permissions');
         FabriqModules::add_css('roles', 'roles');
         $perms = new Perms();
         $perms->getAll();
         $modules = new Modules();
         $modules->getEnabled();
         $roles = FabriqModules::new_model('roles', 'Roles');
         $roles->getRoles();
         $modulePerms = FabriqModules::new_model('roles', 'ModulePerms');
         $modulePerms->getAll();
         $permissions = array();
         foreach ($perms as $perm) {
             $permissions[$perm->id] = array();
             foreach ($roles as $role) {
                 if (isset($modulePerms->perms[$perm->id][$role->id])) {
                     $permissions[$perm->id][$role->id] = 1;
                 } else {
                     $permissions[$perm->id][$role->id] = 0;
                 }
             }
         }
         if (isset($_POST['submit'])) {
             foreach ($perms as $perm) {
                 foreach ($roles as $role) {
                     if (isset($_POST['permission'][$perm->id][$role->id])) {
                         $permissions[$perm->id][$role->id] = 1;
                         // add to database if it's not already set
                         if (!isset($modulePerms->perms[$perm->id][$role->id])) {
                             $p = FabriqModules::new_model('roles', 'ModulePerms');
                             $p->permission = $perm->id;
                             $p->role = $role->id;
                             $p->id = $p->create();
                             $modulePerms->perms[$perm->id][$role->id] = $modulePerms->count();
                             $modulePerms->add($p);
                         }
                     } else {
                         $permissions[$perm->id][$role->id] = 0;
                         // remove from database if it is already set
                         if (isset($modulePerms->perms[$perm->id][$role->id])) {
                             $p = FabriqModules::new_model('roles', 'ModulePerms');
                             $p->find($modulePerms[$modulePerms->perms[$perm->id][$role->id]]->id);
                             $p->destroy();
                             $modulePerms->remove($modulePerms->perms[$perm->id][$role->id]);
                             $modulePerms->reindex();
                         }
                     }
                 }
             }
             Messaging::message('Permissions have been updated.', 'success');
         }
         FabriqModules::set_var($this->name, 'perms', $perms);
         FabriqModules::set_var($this->name, 'modules', $modules);
         FabriqModules::set_var($this->name, 'roles', $roles);
         FabriqModules::set_var($this->name, 'permissions', $permissions);
     }
 }
开发者ID:ralivue,项目名称:fabriqframework,代码行数:59,代码来源:roles.module.php

示例2: install_step3


//.........这里部分代码省略.........
                 mkdir('sites/' . FabriqStack::site() . "/app/views/homepage");
             }
             $actionFile = 'sites/' . FabriqStack::site() . "/app/views/homepage/index.view.php";
             if (!file_exists($actionFile)) {
                 $fh = fopen($actionFile, 'w');
                 fwrite($fh, "<h1>homepage#index</h1>\n");
                 fclose($fh);
             }
             // create the framework database tables
             global $db;
             $db_info = array('server' => trim($_POST['server']), 'user' => trim($_POST['user']), 'pwd' => trim($_POST['pwd']), 'db' => trim($_POST['db']));
             $db = new Database($db_info);
             // install config table
             $query = "CREATE TABLE IF NOT EXISTS  `fabriq_config` (\n\t\t\t\t\t\t`version` VARCHAR(10) NOT NULL,\n\t\t\t\t\t\t`installed` DATETIME NOT NULL,\n\t\t\t\t\t\tPRIMARY KEY (`version`)\n\t\t\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
             $db->query($query);
             $query = "INSERT INTO fabriq_config (version, installed) VALUES (?, ?)";
             $db->prepare_cud($query, array($this->installVersion, date('Y-m-d H:i:s')));
             // modules table
             $query = "CREATE TABLE IF NOT EXISTS `fabmods_modules` (\n\t\t\t\t\t\t`id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t`module` varchar(100) NOT NULL,\n\t\t\t\t\t\t`enabled` tinyint(4) NOT NULL,\n\t\t\t\t\t\t`hasconfigs` tinyint(1) NOT NULL,\n\t\t\t\t\t\t`installed` tinyint(1) NOT NULL,\n\t\t\t\t\t\t`versioninstalled` varchar(20) NOT NULL,\n\t\t\t\t\t\t`description` text NOT NULL,\n\t\t\t\t\t\t`dependson` text,\n\t\t\t\t\t\t`created` datetime NOT NULL,\n\t\t\t\t\t\t`updated` datetime NOT NULL,\n\t\t\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t\t\t) ENGINE=InnoDB  DEFAULT CHARSET=utf8;";
             $db->query($query);
             // module configs table
             $query = "CREATE TABLE IF NOT EXISTS `fabmods_module_configs` (\n\t\t\t\t\t\t`id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t`module` int(11) NOT NULL,\n\t\t\t\t\t\t`var` varchar(100) NOT NULL,\n\t\t\t\t\t\t`val` text NOT NULL,\n\t\t\t\t\t\t`created` datetime NOT NULL,\n\t\t\t\t\t\t`updated` datetime NOT NULL,\n\t\t\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t\t\t) ENGINE=InnoDB  DEFAULT CHARSET=utf8;";
             $db->query($query);
             // module perms table
             $query = "CREATE TABLE IF NOT EXISTS `fabmods_perms` (\n\t\t\t\t\t\t`id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t`permission` varchar(100) NOT NULL,\n\t\t\t\t\t\t`module` int(11) NOT NULL,\n\t\t\t\t\t\t`created` datetime NOT NULL,\n\t\t\t\t\t\t`updated` datetime NOT NULL,\n\t\t\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t\t\t) ENGINE=InnoDB  DEFAULT CHARSET=utf8;";
             $db->query($query);
             // install the module events table
             $query = "CREATE TABLE IF NOT EXISTS `fabmods_module_events` (\n\t\t\t\t\t`id` INT(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t`eventModule` VARCHAR(50) NOT NULL,\n\t\t\t\t\t`eventAction` VARCHAR(50) NOT NULL,\n\t\t\t\t\t`eventName` VARCHAR(100) NOT NULL,\n\t\t\t\t\t`handlerModule` VARCHAR(50) NOT NULL,\n\t\t\t\t\t`handlerAction` VARCHAR(50) NOT NULL,\n\t\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
             $db->query($query);
             if (!isset($_SESSION['FAB_INSTALL_mods_installed'])) {
                 Messaging::message('Configuration file has been written', 'success');
                 Messaging::message('Core database tables have been created', 'success');
                 FabriqModules::register_module('pathmap');
                 FabriqModules::register_module('roles');
                 FabriqModules::register_module('users');
                 FabriqModules::register_module('sitemenus');
                 FabriqModules::register_module('fabriqmodules');
                 FabriqModules::register_module('fabriqinstall');
                 FabriqModules::install('pathmap');
                 $module = new Modules();
                 $module->getModuleByName('pathmap');
                 $module->enabled = 1;
                 $module->update();
                 Messaging::message('Installed pathmap module', 'success');
                 FabriqModules::install('roles');
                 $module = new Modules();
                 $module->getModuleByName('roles');
                 $module->enabled = 1;
                 $module->update();
                 Messaging::message('Installed roles module', 'success');
                 FabriqModules::install('users');
                 $module = new Modules();
                 $module->getModuleByName('users');
                 $module->enabled = 1;
                 $module->update();
                 Messaging::message('Installed users module', 'success');
                 FabriqModules::register_module('sitemenus');
                 FabriqModules::install('sitemenus');
                 $module = new Modules();
                 $module->getModuleByName('sitemenus');
                 $module->enabled = 1;
                 $module->update();
                 Messaging::message('Installed sitemenus module', 'success');
                 FabriqModules::register_module('fabriqmodules');
                 FabriqModules::install('fabriqmodules');
                 $module = new Modules();
                 $module->getModuleByName('fabriqmodules');
                 $module->enabled = 1;
                 $module->update();
                 Messaging::message('Installed fabriqmodules module', 'success');
                 FabriqModules::register_module('fabriqinstall');
                 FabriqModules::install('fabriqinstall');
                 $module = new Modules();
                 $module->getModuleByName('fabriqinstall');
                 $module->enabled = 1;
                 $module->update();
                 Messaging::message('Installed fabriqinstall module', 'success');
                 // get admin role and give it all perms so that the admin can actually set
                 // things up
                 $role = FabriqModules::new_model('roles', 'Roles');
                 $role->getRole('administrator');
                 $perms = new Perms();
                 $perms->getAll();
                 foreach ($perms as $perm) {
                     $modPerm = FabriqModules::new_model('roles', 'ModulePerms');
                     $modPerm->permission = $perm->id;
                     $modPerm->role = $role->id;
                     $modPerm->create();
                 }
                 $_SESSION['FAB_INSTALL_mods_installed'] = true;
             }
             if ($continue) {
                 // go to next step
                 header("Location: " . PathMap::build_path('fabriqinstall', 'install', 4));
                 exit;
             }
         }
         FabriqModules::set_var('fabriqinstall', 'submitted', true);
     }
 }
开发者ID:ralivue,项目名称:fabriqframework,代码行数:101,代码来源:fabriqinstall.module.php


注:本文中的Perms::getAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。