CMS  Version 3.9
permissions_map.inc
Go to the documentation of this file.
1 <?php
2 Fakoli::using("developer_tools", "section");
3 Fakoli::usingFeature("grouped_data_view");
4 
5 $page_title = "Permission Map";
6 $menu_item = "Permission Map";
7 
8 $site_id = checkNumeric($_GET["site_id"]);
9 
10 $sites = query(Site, "ORDER BY site_name");
11 
12 
13 if (!$site_id) $site_id = $sites[0]->site_id;
14 
15 $tabs = new DataItemTabBar("tabs", $sites);
16 
17 $permissions = Query::create(Settings, "WHERE options='Permissions' ORDER BY component")->execute();
18 
19 $sectionContent = Query::create(SectionContent, "WHERE section_id IN (SELECT section_id FROM section WHERE site_id=:s) AND permissions IS NOT NULL AND permissions != ''")
20  ->bind(":s", $site_id)
21  ->execute();
22 
24 
25 foreach($sectionContent as $content)
26 {
27  $perms = explode(",", $content->permissions);
28  foreach($perms as $perm)
29  {
30  if (!array_key_exists($perm, $contentByPermission))
31  {
32  $contentByPermission[$perm] = array();
33  }
34 
35  $contentByPermission[$perm][] = $content;
36  }
37 }
38 
39 $groups = array();
40 foreach($permissions as $perm)
41 {
42  $groups[$perm->format("{component}:{name}")] = $perm->format("{annotation} <span style='font-weight:normal;font-size:75%'>{component}:{name}</span>");
43 }
44 
45 
46 $table = new GroupedDataListView($contentByPermission, "content_by_permission");
47 $table->column("Identifier", "<strong>{identifier}</strong>", true, "width: 20%")
48  ->column("Roles", "{role:/,/, /}", true, "width: 30%")
49  ->column("Permissions", "{permissions:/,/, /}", true, "width:30%")
50  ->column("Template", "{template}", true);
51 
52 foreach($groups as $key => $group)
53 {
54  $table->group($group, $key);
55 }
56 
57 $table->mode = "tree";
58 $table->groupAsWorksheets = false;
59 $table->filter = true;
60 $table->sortable = true;
61 $table->excelFile = codify($config['sitename']."_section_map").".xls";
62 
63 $script .= $table->writeScript();
64 
65 $tabs->writeHTML();
66 ?>
67 <div class='tab_border'>
68 <?
69 $table->drawView();
70 ?>
71 </div>
static usingFeature()
Uses the specified framework feature(s).
Definition: core.inc:388
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition: core.inc:116
The Settings class provides components with a common API for specifying application settings and conf...
Definition: settings.inc:49
Definition: site.inc:40
$group
Definition: group_form.inc:43
global $config
Definition: import.inc:4
foreach($sectionContent as $content) $groups
foreach($permissions as $perm) $table
$menu_item
$permissions
$site_id
$page_title
$contentByPermission
$sectionContent
if(array_key_exists("HTTP_IF_MODIFIED_SINCE", $_SERVER)) $content
Definition: styles.css.inc:24