Jump to content


Photo

Upcoming birthday hook when no visible calendars


If a user does not have permission to view any calendars the upcoming birthday hook throws the following error;

Warning: Invalid argument supplied for foreach() in /admin/applications_addon/ips/calendar/sources/hooks.php on line 151

   foreach( $calendars as $calendar )
   {
    /* We need to grab first calendar that allows birthdays */
    if( !$calendar['cal_bday_limit'] )
    {
	 continue;
    }
    $data   = array(
		  'id' => $calendar['cal_id'],
		  'title' => $calendar['cal_title_seo'],
		  'year' => $year,
		  'month' => $month,
		  'day' => $day,
		  );
    break;
   }

should be;

   if ( is_array($calendars) AND count( $calendars ) )
   {
    foreach( $calendars as $calendar )
    {
	 /* We need to grab first calendar that allows birthdays */
	 if( !$calendar['cal_bday_limit'] )
	 {
	  continue;
	 }
	 $data   = array(
		   'id' => $calendar['cal_id'],
		   'title' => $calendar['cal_title_seo'],
		   'year' => $year,
		   'month' => $month,
		   'day' => $day,
		   );
	 break;
    }
   }

Status: Duplicate
Version: 3.3.0
Fixed In:


1 Comments

:)