1<?php
2# MantisBT - A PHP based bugtracking system
3
4# MantisBT is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation, either version 2 of the License, or
7# (at your option) any later version.
8#
9# MantisBT is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with MantisBT.  If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * Permissions Report
19 * @package MantisBT
20 * @author Marcello Scata' <marcelloscata at users.sourceforge.net> ITALY
21 * @copyright Copyright 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
22 * @copyright Copyright 2002  MantisBT Team - mantisbt-dev@lists.sourceforge.net
23 * @link http://www.mantisbt.org
24 *
25 * @uses core.php
26 * @uses access_api.php
27 * @uses config_api.php
28 * @uses constant_inc.php
29 * @uses helper_api.php
30 * @uses html_api.php
31 * @uses lang_api.php
32 * @uses string_api.php
33 */
34
35require_once( 'core.php' );
36require_api( 'access_api.php' );
37require_api( 'config_api.php' );
38require_api( 'constant_inc.php' );
39require_api( 'helper_api.php' );
40require_api( 'html_api.php' );
41require_api( 'lang_api.php' );
42require_api( 'string_api.php' );
43
44access_ensure_project_level( config_get( 'manage_configuration_threshold' ) );
45
46layout_page_header( lang_get( 'permissions_summary_report' ) );
47
48layout_page_begin( 'manage_overview_page.php' );
49
50print_manage_menu( PAGE_CONFIG_DEFAULT );
51print_manage_config_menu( 'adm_permissions_report.php' );
52
53
54/**
55 * return html for start of administration report section
56 * @param string $p_section_name Section name.
57 * @return string
58 */
59function get_section_begin_apr( $p_section_name ) {
60	$t_access_levels = MantisEnum::getValues( config_get( 'access_levels_enum_string' ) );
61
62	$t_output = '<div class="col-md-12 col-xs-12">';
63	$t_output .= '<div class="space-10"></div>';
64
65	$t_output .= '<div class="widget-box widget-color-blue2">';
66	$t_output .= '   <div class="widget-header widget-header-small">';
67	$t_output .= '        <h4 class="widget-title lighter uppercase">';
68	$t_output .= '            ' . icon_get( 'fa-lock', 'ace-icon' );
69	$t_output .= $p_section_name;
70	$t_output .= '       </h4>';
71	$t_output .= '   </div>';
72	$t_output .= '   <div class="widget-body">';
73	$t_output .= '   <div class="widget-main no-padding">';
74
75	$t_output .= '       <div class="table-responsive">';
76	$t_output .= '           <table class="table table-striped table-hover table-bordered table-condensed">';
77
78	$t_output .= '<thead>';
79	$t_output .= '<tr>';
80	$t_output .= '<th class="bold">' . lang_get( 'perm_rpt_capability' ) . '</th>';
81
82	foreach( $t_access_levels as $t_access_level ) {
83		$t_output .= '<th class="bold" style="text-align:center">&#160;' . MantisEnum::getLabel( lang_get( 'access_levels_enum_string' ), $t_access_level ) . '&#160;</th>';
84	}
85
86	$t_output .= '</tr>' . "\n";
87	$t_output .= '</thead>';
88	$t_output .= '<tbody>';
89
90	return $t_output;
91}
92
93/**
94 * Return html for a row
95 * @param string  $p_caption      Caption.
96 * @param integer $p_access_level Access level.
97 * @return string
98 */
99function get_capability_row( $p_caption, $p_access_level ) {
100	$t_access_levels = MantisEnum::getValues( config_get( 'access_levels_enum_string' ) );
101
102	$t_output = '<tr><td>' . string_display_line( $p_caption ) . '</td>';
103	foreach( $t_access_levels as $t_access_level ) {
104		if( $t_access_level >= (int)$p_access_level ) {
105			$t_value = icon_get( 'fa-check', 'fa-lg blue' );
106		} else {
107			$t_value = '&#160;';
108		}
109
110		$t_output .= '<td class="center">' . $t_value . '</td>';
111	}
112
113	$t_output .= '</tr>' . "\n";
114
115	return $t_output;
116}
117
118/**
119 * return html for end of administration report section
120 * @return string
121 */
122function get_section_end() {
123	$t_output = '</tbody></table></div> ' . "\n";
124	$t_output .= '</div></div></div></div> ' . "\n";
125	$t_output .= '<div class="space-10"></div>';
126	return $t_output;
127}
128
129# News
130if( config_get( 'news_enabled' ) == ON ) {
131	echo get_section_begin_apr( lang_get( 'news' ) );
132	echo get_capability_row( lang_get( 'view_private_news' ), config_get( 'private_news_threshold' ) );
133	echo get_capability_row( lang_get( 'manage_news' ), config_get( 'manage_news_threshold' ) );
134	echo get_section_end();
135}
136
137# Attachments
138if( config_get( 'allow_file_upload' ) == ON ) {
139	echo get_section_begin_apr( lang_get( 'attachments' ) );
140	echo get_capability_row( lang_get( 'view_list_of_attachments' ), config_get( 'view_attachments_threshold' ) );
141	echo get_capability_row( lang_get( 'download_attachments' ), config_get( 'download_attachments_threshold' ) );
142	echo get_capability_row( lang_get( 'delete_attachments' ), config_get( 'delete_attachments_threshold' ) );
143	echo get_capability_row( lang_get( 'upload_issue_attachments' ), config_get( 'upload_bug_file_threshold' ) );
144	echo get_section_end();
145}
146
147# Filters
148echo get_section_begin_apr( lang_get( 'filters' ) );
149echo get_capability_row( lang_get( 'save_filters' ), config_get( 'stored_query_create_threshold' ) );
150echo get_capability_row( lang_get( 'save_filters_as_shared' ), config_get( 'stored_query_create_shared_threshold' ) );
151echo get_capability_row( lang_get( 'use_saved_filters' ), config_get( 'stored_query_use_threshold' ) );
152echo get_section_end();
153
154# Projects
155echo get_section_begin_apr( lang_get( 'projects_link' ) );
156echo get_capability_row( lang_get( 'create_project' ), config_get( 'create_project_threshold' ) );
157echo get_capability_row( lang_get( 'delete_project' ), config_get( 'delete_project_threshold' ) );
158echo get_capability_row( lang_get( 'manage_projects_link' ), config_get( 'manage_project_threshold' ) );
159echo get_capability_row( lang_get( 'manage_user_access_to_project' ), config_get( 'project_user_threshold' ) );
160echo get_capability_row( lang_get( 'automatically_included_in_private_projects' ), config_get( 'private_project_threshold' ) );
161echo get_section_end();
162
163# Project Documents
164if( config_get( 'enable_project_documentation' ) == ON ) {
165	echo get_section_begin_apr( lang_get( 'project_documents' ) );
166	echo get_capability_row( lang_get( 'view_project_documents' ), config_get( 'view_proj_doc_threshold' ) );
167	echo get_capability_row( lang_get( 'upload_project_documents' ), config_get( 'upload_project_file_threshold' ) );
168	echo get_section_end();
169}
170
171# Custom Fields
172echo get_section_begin_apr( lang_get( 'custom_fields_setup' ) );
173echo get_capability_row( lang_get( 'manage_custom_field_link' ), config_get( 'manage_custom_fields_threshold' ) );
174echo get_capability_row( lang_get( 'link_custom_fields_to_projects' ), config_get( 'custom_field_link_threshold' ) );
175echo get_section_end();
176
177# Sponsorships
178if( config_get( 'enable_sponsorship' ) == ON ) {
179	echo get_section_begin_apr( lang_get( 'sponsorships' ) );
180	echo get_capability_row( lang_get( 'view_sponsorship_details' ), config_get( 'view_sponsorship_details_threshold' ) );
181	echo get_capability_row( lang_get( 'view_sponsorship_total' ), config_get( 'view_sponsorship_total_threshold' ) );
182	echo get_capability_row( lang_get( 'sponsor_issue' ), config_get( 'sponsor_threshold' ) );
183	echo get_capability_row( lang_get( 'assign_sponsored_issue' ), config_get( 'assign_sponsored_bugs_threshold' ) );
184	echo get_capability_row( lang_get( 'handle_sponsored_issue' ), config_get( 'handle_sponsored_bugs_threshold' ) );
185	echo get_section_end();
186}
187
188# Others
189echo get_section_begin_apr( lang_get( 'others' ) );
190echo get_capability_row( lang_get( 'view' ) . ' ' . lang_get( 'summary_link' ), config_get( 'view_summary_threshold' ) );
191echo get_capability_row( lang_get( 'see_email_addresses_of_other_users' ), config_get( 'show_user_email_threshold' ) );
192echo get_capability_row( lang_get( 'send_reminders' ), config_get( 'bug_reminder_threshold' ) );
193echo get_capability_row( lang_get( 'add_profiles' ), config_get( 'add_profile_threshold' ) );
194echo get_capability_row( lang_get( 'manage_users_link' ), config_get( 'manage_user_threshold' ) );
195echo get_capability_row( lang_get( 'notify_of_new_user_created' ), config_get( 'notify_new_user_created_threshold_min' ) );
196echo get_section_end();
197
198layout_page_end();
199