2
0
Эх сурвалжийг харах

! Move calendar export function from permissions based to settings

Signed-off-by: Spuds <spuds@simplemachines.org>
Spuds 13 жил өмнө
parent
commit
6f9a37051a

+ 3 - 2
Sources/Calendar.php

@@ -331,8 +331,9 @@ function iCalDownload()
 {
 	global $smcFunc, $sourcedir, $forum_version, $context, $modSettings, $webmaster_email, $mbname;
 
-	// This requires the export permission
-	isAllowedTo('calendar_export');
+	// You can't export if the calendar export feature is off.
+	if (empty($modSettings['cal_export']))
+		fatal_lang_error('calendar_export_off', false);
 	
 	// Goes without saying that this is required.
 	if (!isset($_REQUEST['eventid']))

+ 1 - 1
Sources/ManageCalendar.php

@@ -314,13 +314,13 @@ function ModifyCalendarSettings($return_config = false)
 			array('permissions', 'calendar_post'),
 			array('permissions', 'calendar_edit_own'),
 			array('permissions', 'calendar_edit_any'),
-			array('permissions', 'calendar_export'),
 		'',
 			// How many days to show on board index, and where to display events etc?
 			array('int', 'cal_days_for_index', 6, 'postinput' => $txt['days_word']),
 			array('select', 'cal_showholidays', array(0 => $txt['setting_cal_show_never'], 1 => $txt['setting_cal_show_cal'], 3 => $txt['setting_cal_show_index'], 2 => $txt['setting_cal_show_all'])),
 			array('select', 'cal_showbdays', array(0 => $txt['setting_cal_show_never'], 1 => $txt['setting_cal_show_cal'], 3 => $txt['setting_cal_show_index'], 2 => $txt['setting_cal_show_all'])),
 			array('select', 'cal_showevents', array(0 => $txt['setting_cal_show_never'], 1 => $txt['setting_cal_show_cal'], 3 => $txt['setting_cal_show_index'], 2 => $txt['setting_cal_show_all'])),
+			array('check', 'cal_export'),
 		'',
 			// Linking events etc...
 			array('select', 'cal_defaultboard', $boards),

+ 0 - 2
Sources/ManagePermissions.php

@@ -1463,7 +1463,6 @@ function loadAllPermissions($loadType = 'classic')
 			'pm_read' => array(false, 'pm', 'use_pm_system'),
 			'pm_send' => array(false, 'pm', 'use_pm_system'),
 			'calendar_view' => array(false, 'calendar', 'view_basic_info'),
-			'calendar_export' => array(false, 'calendar', 'view_basic_info'),
 			'calendar_post' => array(false, 'calendar', 'post_calendar'),
 			'calendar_edit' => array(true, 'calendar', 'post_calendar', 'moderate_general'),
 			'admin_forum' => array(false, 'maintenance', 'administrate'),
@@ -1544,7 +1543,6 @@ function loadAllPermissions($loadType = 'classic')
 		$hiddenPermissions[] = 'calendar_view';
 		$hiddenPermissions[] = 'calendar_post';
 		$hiddenPermissions[] = 'calendar_edit';
-		$hiddenPermissions[] = 'calendar_export';
 	}
 	if (!in_array('w', $context['admin_features']))
 		$hiddenPermissions[] = 'issue_warning';

+ 2 - 2
Sources/Subs-Calendar.php

@@ -177,7 +177,7 @@ function getEventRange($low_date, $high_date, $use_permissions = true)
 					'link' => $row['id_board'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>',
 					'can_edit' => allowedTo('calendar_edit_any') || ($row['id_member'] == $user_info['id'] && allowedTo('calendar_edit_own')),
 					'modify_href' => $scripturl . '?action=' . ($row['id_board'] == 0 ? 'calendar;sa=post;' : 'post;msg=' . $row['id_first_msg'] . ';topic=' . $row['id_topic'] . '.0;calendar;') . 'eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'],
-					'can_export' => allowedTo('calendar_export'),
+					'can_export' => !empty($modSettings['cal_export']) ? true : false,
 					'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'],
 				);
 			// Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info.
@@ -192,7 +192,7 @@ function getEventRange($low_date, $high_date, $use_permissions = true)
 					'href' => $row['id_topic'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0',
 					'link' => $row['id_topic'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>',
 					'can_edit' => false,
-					'can_export' => false,
+					'can_export' => !empty($modSettings['cal_export']) ? true : false,
 					'topic' => $row['id_topic'],
 					'msg' => $row['id_first_msg'],
 					'poster' => $row['id_member'],

+ 1 - 1
Themes/default/languages/Errors.english.php

@@ -64,7 +64,6 @@ $txt['cannot_post_unapproved_replies_own'] = 'You do not have permission to post
 $txt['cannot_post_unapproved_replies_any'] = 'You do not have permission to post unapproved replies to other users\' topics.';
 $txt['cannot_calendar_edit_any'] = 'You cannot edit calendar events.';
 $txt['cannot_calendar_edit_own'] = 'You don\'t have the privileges necessary to edit your own events.';
-$txt['cannot_calendar_export'] = 'Sorry, You cannot export calendar events.';
 $txt['cannot_calendar_post'] = 'Event posting isn\'t allowed - sorry.';
 $txt['cannot_calendar_view'] = 'Sorry, but you are not allowed to view the calendar.';
 $txt['cannot_remove_any'] = 'Sorry, but you don\'t have the privilege to remove just any topic.  Check to make sure this topic wasn\'t just moved to another board.';
@@ -149,6 +148,7 @@ $txt['parent_not_found'] = 'Board structure corrupt: unable to find parent board
 $txt['modify_post_time_passed'] = 'You may not modify this post as the time limit for edits has passed.';
 
 $txt['calendar_off'] = 'You cannot access the calendar right now because it is disabled.';
+$txt['calendar_export_off'] = 'You cannot export calendar events because that feature is currently disabled.';
 $txt['invalid_month'] = 'Invalid month value.';
 $txt['invalid_year'] = 'Invalid year value.';
 $txt['invalid_day'] = 'Invalid day value.';

+ 1 - 0
Themes/default/languages/Help.english.php

@@ -218,6 +218,7 @@ $helptxt['smileys'] = '<strong>Smiley Center</strong><br />
 	You are also able to edit message icons from here, if you have them enabled on the settings page.';
 $helptxt['calendar'] = '<strong>Manage Calendar</strong><br />
 	Here you can modify the current calendar settings as well as add and remove holidays that appear on the calendar.';
+$helptxt['cal_export'] = 'Exports a text file in the iCal format for importing in to other calendar applications';
 
 $helptxt['serversettings'] = '<strong>Server Settings</strong><br />
 	Here you can perform the core configuration for your forum. This section includes the database and url settings, as well as other

+ 1 - 1
Themes/default/languages/ManageCalendar.english.php

@@ -7,7 +7,6 @@ $txt['calendar_desc'] = 'From here you can modify all aspects of the calendar.';
 $txt['calendar_settings_desc'] = 'Here you can enable the calendar, and determine the settings that it should use.';
 $txt['save_settings'] = 'Save Settings';
 $txt['groups_calendar_view'] = 'Membergroups allowed to view the calendar';
-$txt['groups_calendar_export'] = 'Membergroups allowed to export calendar events';
 $txt['groups_calendar_post'] = 'Membergroups allowed to create events';
 $txt['groups_calendar_edit_own'] = 'Membergroups allowed to edit their own events';
 $txt['groups_calendar_edit_any'] = 'Membergroups allowed to edit any events';
@@ -17,6 +16,7 @@ $txt['setting_cal_days_for_index'] = 'Max days in advance on board index';
 $txt['setting_cal_showholidays'] = 'Show holidays';
 $txt['setting_cal_showbdays'] = 'Show birthdays';
 $txt['setting_cal_showevents'] = 'Show events';
+$txt['setting_cal_export'] = 'Allow events to be exported in Ical format';
 $txt['setting_cal_show_never'] = 'Never';
 $txt['setting_cal_show_cal'] = 'In calendar only';
 $txt['setting_cal_show_index'] = 'On board index only';

+ 0 - 2
Themes/default/languages/ManagePermissions.english.php

@@ -104,8 +104,6 @@ $txt['permissionname_calendar_edit'] = 'Edit events in the calendar';
 $txt['permissionhelp_calendar_edit'] = 'An Event is a topic linked to a certain date or date range. The event can be edited by clicking the red asterisk (*) next to the event in the calendar view. In order to be able to edit an event, a user must have sufficient permissions to edit the first message of the topic that is linked to the event.';
 $txt['permissionname_calendar_edit_own'] = 'Own events';
 $txt['permissionname_calendar_edit_any'] = 'Any events';
-$txt['permissionname_calendar_export'] = 'Export events from the calendar';
-$txt['permissionhelp_calendar_export'] = 'Exports a text file in the iCal format for importing in to other calendar applications';
 
 $txt['permissiongroup_maintenance'] = 'Forum administration';
 $txt['permissionname_admin_forum'] = 'Administrate forum and database';