本文整理汇总了PHP中PermissionsManager::scanForPermission方法的典型用法代码示例。如果您正苦于以下问题:PHP PermissionsManager::scanForPermission方法的具体用法?PHP PermissionsManager::scanForPermission怎么用?PHP PermissionsManager::scanForPermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PermissionsManager
的用法示例。
在下文中一共展示了PermissionsManager::scanForPermission方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: page_permissions
public function page_permissions()
{
if (isset($_POST['save-permissions'])) {
PermissionObject::removeAllPermissions();
if (isset($_POST['permission'])) {
foreach ($_POST['permission'] as $perm => $groups) {
foreach ($groups as $grp => $d) {
PermissionObject::addPermission($grp, $perm);
}
}
}
Notification::statusNotify(t("configuration enregistrée"), Notification::STATUS_SUCCESS);
}
$defined_permissions = PermissionObject::loadAllPermissions();
$df = array();
foreach ($defined_permissions as $p) {
if (!isset($df[$p->pid])) {
$df[$p->pid] = array();
}
$df[$p->pid][$p->gid] = 1;
}
$p = new PermissionsManager();
$permissions = $p->scanForPermission();
$groups = GroupObject::loadAll();
$table = array();
$hcol = array("");
$hrow = array();
foreach ($permissions as $u => $t) {
$hrow[] = $t;
$row = array();
foreach ($groups as $gd => $g) {
if ($u == 0) {
$hcol[] = $g->label;
}
$pm = new PermissionObject();
$pm->loadByName($t);
$tlabel = "permission[" . $g->gid . "][" . $pm->pid . "]";
if (isset($df[$pm->pid][$g->gid])) {
$row[] = "<input type='checkbox' name='{$tlabel}' id='{$tlabel}' checked='checked'/>";
} else {
$row[] = "<input type='checkbox' name='{$tlabel}' id='{$tlabel}' />";
}
}
$table[] = $row;
}
$theme = new Theme();
$theme->set_title(t("Permissions déclarées"));
$table = Themed::tabling($table, $hcol, $hrow);
$theme->add_to_body("<form method='POST' action=''>{$table} <input type='submit' name='save-permissions' value='" . t("Enregistrer") . "'/></form>");
$theme->process_theme(Theme::STRUCT_ADMIN);
}