當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。