فهرست منبع

! In some cases the 'post event' button was shown when you couldn't actually post an event (fixes #1182)

Signed-off-by: Michael Eshom <[email protected]>
Michael Eshom 10 سال پیش
والد
کامیت
4bb49bae54
2فایلهای تغییر یافته به همراه13 افزوده شده و 3 حذف شده
  1. 1 1
      Sources/Calendar.php
  2. 12 2
      Sources/Subs.php

+ 1 - 1
Sources/Calendar.php

@@ -126,7 +126,7 @@ function CalendarMain()
 		$context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions);
 
 	// Basic template stuff.
-	$context['can_post'] = allowedTo('calendar_post');
+	$context['can_post'] = $context['allow_calendar_event'];
 	$context['current_day'] = $curPage['day'];
 	$context['current_month'] = $curPage['month'];
 	$context['current_year'] = $curPage['year'];

+ 12 - 2
Sources/Subs.php

@@ -3702,6 +3702,16 @@ function setupMenuContext()
 
 	$cacheTime = $modSettings['lastActive'] * 60;
 
+	// Initial "can you post an event in the calendar" option
+	$context['allow_calendar_event'] = allowedTo('calendar_post');
+	
+	// If you don't allow events not linked to posts and you're not an admin, we have more work to do...
+	if (empty($modSettings['cal_allow_unlinked']) && !$user_info['is_admin'])
+	{
+		$boards_can_post = boardsAllowedTo('post_new');
+		$context['allow_calendar_event'] &= !empty($boards_can_post);
+	}
+
 	// There is some menu stuff we need to do if we're coming at this from a non-guest perspective.
 	if (!$context['user']['is_guest'])
 	{
@@ -3809,12 +3819,12 @@ function setupMenuContext()
 					'view' => array(
 						'title' => $txt['calendar_menu'],
 						'href' => $scripturl . '?action=calendar',
-						'show' => allowedTo('calendar_post'),
+						'show' => $context['allow_calendar_event'],
 					),
 					'post' => array(
 						'title' => $txt['calendar_post_event'],
 						'href' => $scripturl . '?action=calendar;sa=post',
-						'show' => allowedTo('calendar_post'),
+						'show' => $context['allow_calendar_event'],
 						'is_last' => true,
 					),
 				),