本文整理匯總了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);
}