Thread: Calendar Enhancements - BBR - vB Event Forums
View Single Post
  #318  
Old 01-18-2011, 03:53 AM
utahraves's Avatar
utahraves utahraves is offline
 
Join Date: May 2007
Location: Utah
Posts: 169
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by smnet View Post
Just a small improvement for everybody....

This change will ensure all occurrences of the word 'thread' on the page are changed to 'event'... eg, 'print thread' becomes 'print event'. (NOTE: This does not take translations into account)

It also fixes a display error where the event details come before the action / admin / inline mod bar (it should come after, not before).

Open the plugin called "Display Event Details on Thread Page - BBR" (showthread complete hook)... replace all with this:-
Code:
// we need to initialise this variable here, otherwise on non Event Threads, the var will show as text
$lv_vb_eventforums_eventdetails = "";

// is this a VB event forum?
$lv_vb_eventforums_eventForum = false;
$lv_vb_eventforums_map = preg_split('/[\n:]/', trim($vbulletin->options['lv_vb_eventforums_map']));
for($lv_vb_eventforums_i = 0; $lv_vb_eventforums_i<count($lv_vb_eventforums_map); $lv_vb_eventforums_i+=2)
{
    if(intval($lv_vb_eventforums_map[$lv_vb_eventforums_i+1]) == $foruminfo['forumid'])
    {
        $lv_vb_eventforums_eventForum = true;
        break;
    }
}

$lv_vb_eventforums_eventid = $threadinfo['lv_vb_eventforums_eventid'];

if($lv_vb_eventforums_eventForum && ($lv_vb_eventforums_eventid > 0) && (!empty($lv_vb_eventforums_eventid)))
{
  require_once(DIR . '/includes/functions_calendar.php');
  require_once(DIR . '/includes/functions_misc.php');
  require_once(DIR . '/includes/functions_newpost.php');
  require_once(DIR . '/includes/functions.php');
  require_once(DIR . '/includes/functions_user.php');
  
  require_once(DIR . '/includes/class_bbcode.php');
  $bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list(), true);
  
  // get the event
  $lv_vb_eventforums_event = $vbulletin->db->query_read("
            SELECT *, IF(dateline_to = 0, 1, 0) AS singleday
            FROM " . TABLE_PREFIX . "event
            WHERE eventid = " . intval($lv_vb_eventforums_eventid) . "
        ");
  $lv_vb_eventforums_event = $vbulletin->db->fetch_array($lv_vb_eventforums_event);
  
  $eventinfo = $lv_vb_eventforums_event;
  
  ### Added by Farcaster #############################################################################
  
  $offset = $eventinfo['dst'] ? $vbulletin->userinfo['timezoneoffset'] : $vbulletin->userinfo['tzoffset'];
  $eventinfo['dateline_from_user'] = $eventinfo['dateline_from'] + $offset * 3600;
  $eventinfo['dateline_to_user'] = $eventinfo['dateline_to'] + $offset * 3600;
        
  ####################################################################################################
  
  // get the user info
  $lv_vb_eventforums_user = $vbulletin->db->query_read("
            SELECT *
            FROM " . TABLE_PREFIX . "user
            WHERE userid = " . intval($eventinfo['userid']) . "
        ");
  $lv_vb_eventforums_user = $vbulletin->db->fetch_array($lv_vb_eventforums_user);
  
  // get the calendar info
  $lv_vb_eventforums_calendar = $vbulletin->db->query_read("
            SELECT *
            FROM " . TABLE_PREFIX . "calendar
            WHERE calendarid = " . intval($eventinfo['calendarid']) . "
        ");
  $lv_vb_eventforums_calendar = $vbulletin->db->fetch_array($lv_vb_eventforums_calendar);
  
  $calendarinfo = $lv_vb_eventforums_calendar;
  $calendarinfo['title'] = '<a href="calendar.php?c=' . $eventinfo['calendarid'] . '">' . $calendarinfo['title'] . '</a>';
          
  // work out offsets etc
  $offset = $lv_vb_eventforums_event['utc'] ? $vbulletin->userinfo['timezoneoffset'] : ($vbulletin->userinfo['timezoneoffset'] ? $vbulletin->userinfo['tzoffset'] : $vbulletin->userinfo['timezoneoffset']);
  $from = $eventinfo['dateline_from'] + $offset * 3600;
  $to = $eventinfo['dateline_to'] + $offset * 3600; 
  
  if($lv_vb_eventforums_event['dateline_to'] == 0)
  {
    $from = $lv_vb_eventforums_event['dateline_from'];
  }
  
  $date1 = trim(vbdate($vbulletin->options['dateformat'],  $from, false, true, false, true));
  $date2 = trim(vbdate($vbulletin->options['dateformat'],  $to, false, true, false, true));
  $time1 = trim(vbdate($vbulletin->options['timeformat'],  $from, false, true, false, true));
  $time2 = trim(vbdate($vbulletin->options['timeformat'],  $to, false, true, false, true));
  
  // phrases
  require_once(DIR . '/includes/functions_databuild.php'); // added by Farcaster
  fetch_phrase_group("calendar"); // added by Farcaster
  
  $vbphrase['date_x_to_y'] = fetch_phrase("date_x_to_y", 'calendar');
  $vbphrase['time_x_to_y'] = fetch_phrase("time_x_to_y", 'calendar');
  $vbphrase['delete_reminder_for_this_event'] = fetch_phrase("delete_reminder_for_this_event", 'calendar');
  $vbphrase['request_reminder_for_this_event'] = fetch_phrase("request_reminder_for_this_event", 'calendar');
  $vbphrase['event_options'] = fetch_phrase("event_options", 'calendar');
  $vbphrase['edit_event'] = fetch_phrase("edit_event", 'calendar');
  $vbphrase['delete_event'] = fetch_phrase("delete_event", 'calendar');
  $vbphrase['move_event'] = fetch_phrase("move_event", 'calendar');
  $vbphrase['event_uses_dst'] = fetch_phrase("event_uses_dst", 'calendar');
  $vbphrase['event_posted_for_timezone_x'] = fetch_phrase("event_posted_for_timezone_x", 'calendar');
  $vbphrase['lv_vb_eventforums_phrase_noReplies'] = fetch_phrase("lv_vb_eventforums_phrase_noReplies", 'calendar');
  
  // Initialise all the variables we need to set for the template
  $show['canmoveevent'] = false;
  $show['caneditevent'] = false;
  $show['candeleteevent'] = false;
  
  $show['postedby'] = true;
  $show['subscribed'] = false;
  $show['subscribelink'] = true;
  $show['recuroption'] = false;
  $show['adjustedday'] = false;
  $show['holiday'] = false;
  
  $show['singleday'] = false;
  $show['daterange'] = false;
  
  $show['customfields'] = false;
  $show['customoption'] = false;
  
  $show['eventoptions'] = false;
  
  // can the user move or delete this event?
  $show['canmoveevent'] = can_moderate_calendar($calendarinfo['calendarid'], 'canmoveevents');
  $show['candeleteevent'] = can_moderate_calendar($calendarinfo['calendarid'], 'candeleteevents');
  $show['caneditevent'] = can_moderate_calendar($calendarinfo['calendarid'], 'caneditevents');
  
  if(isset($lv_vb_eventforums_permissions))
  {
    // check each usergroup
    foreach($lv_vb_eventforums_permissions as $key => $value)
    {
      // can this user edit the event?
      if(!$show['caneditevent'])
      {
        if($eventinfo['userid'] == $vbulletin->userinfo['userid'])
        {
          if(($value & $vbulletin->bf_ugp_calendarpermissions['caneditevent']))
          {
            $show['caneditevent'] = true;
          }
        }
      }
    }
  }
  
  // show the options box?
  if(($show['candeleteevent'] OR $show['canmoveevent'] OR $show['caneditevent']) AND !$show['holiday'])
  {
    $show['eventoptions'] = true;
  }

  fetch_musername($eventinfo);

  // construct the user info for the event poster
  $eventinfo['username'] = $lv_vb_eventforums_user['username'];

  // user title
  $eventinfo['usertitle'] = $lv_vb_eventforums_user['usertitle'];
  if($usertitle != '')
  {
    $eventinfo['usertitle'] .= '<div class="smallfont" style="margin-bottom:3px;">' . $usertitle . '</div>';
  }
 
  //we already have the avatar info, no need to refetch.
  fetch_avatar_from_userinfo($eventinfo);

  // prepare the member action drop-down menu
  $memberaction_dropdown = construct_memberaction_dropdown($eventinfo);
        
  //$avatar = fetch_avatar_url($eventinfo['userid']);
  //$eventinfo['avatarurl'] = $avatar[0];

      
  // does the current user have a reminder for this event?
  if($lv_vb_eventforums_eventReminderRows != 0)
  {
    $show['subscribed'] = true;
  }
  
  if($eventinfo['dateline_to'] == 0)
  {
    $show['singleday'] = true;
  }
  
  if(strcmp($date1, $date2) != 0)
  {
    $show['daterange'] = true;
  }
  
  if(!$show['daterange'] || $show['singleday'])
  {
    $eventdate = $date1;
  }

  $eventinfo['event'] = $bbcode_parser->parse($eventinfo['event'], $foruminfo['forumid'], true); 

if ($vbulletin->options['bbr_image_active']) {
$eventid = $eventinfo['eventid'];

$eventinfo['event'] = preg_replace('/<img src="([^"]*)" border="0" alt="" \/>/', '<a href="\\1" rel="' . $vbulletin->options['bbr_image_type'] . '[' . $eventid . ']"><img src="\\1" style="max-width: ' . $vbulletin->options['bbr_image_width'] . 'px; max-height: ' . $vbulletin->options['bbr_image_height'] . 'px; cursor: pointer;" border="0" alt="" /></a>', $eventinfo['event']);
}

$templater = vB_Template::create('spacer_open');
$spacertable1 = $templater->render();

$templater = vB_Template::create('spacer_close');
$spacertable2 = $templater->render();

($hook = vBulletinHook::fetch_hook('calendar_getday_event')) ? eval($hook) : false; // Added by Farcaster

$templater = vB_Template::create('calendar_showeventsbit');
       $templater->register('calendarinfo', $calendarinfo);
       $templater->register('customfields', $customfields);
       $templater->register('date1', $date1);
       $templater->register('date2', $date2);
       $templater->register('eventdate', $eventdate);
       $templater->register('eventinfo', $eventinfo);
       $templater->register('gobutton', $gobutton);
       $templater->register('memberaction_dropdown', $memberaction_dropdown);
       $templater->register('recurcriteria', $recurcriteria);
       $templater->register('spacer_close', $spacer_close);
       $templater->register('spacer_open', $spacer_open);
       $templater->register('time1', $time1);
       $templater->register('time2', $time2);
$lv_vb_eventforums_eventblock = $templater->render();  


  if($vbulletin->options['lv_vb_eventforums_varForEventDetails'])
  {
    $lv_vb_eventforums_eventdetails = $lv_vb_eventforums_eventblock;
  }
  else
  {
      $postbits = $lv_vb_eventforums_eventblock . $postbits;
  }
  
  // if thread is only showing first post, and is an event thread
  if($totalposts == 1) // only first post
  {
        $templater = vB_Template::create('lv_vb_eventforums_noPostSpacer');
        $noposts = $templater->render();  
        $postbits = $postbits . $noposts;
  } // is first post

$vbphrase = str_replace('Thread', 'Event', $vbphrase);
$vbphrase = str_replace('thread', 'event', $vbphrase);
}
Enjoy!
love this, thank you!
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01271 seconds
  • Memory Usage 1,824KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete