View Single Post
  #172  
Old 05-05-2006, 05:54 AM
TomasDR TomasDR is offline
 
Join Date: Feb 2006
Posts: 121
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok here goes. This is what I did, it works for me in 3.5.4

I had to disable the Plugin: (hence the broken part)
"redirect links to individual events to their threads instead"
Hook Location : calendar_getday_start
Installed by: vB Event Forums

I decided to disable the Plugin: (and make a new one)
"Display Event Details on Thread Page"
Hook Location : showthread_complete
Installed by: vB Event Forums

I made a new Plugin:
"Event Attendance - Forum Combined"
Hook Location : showthread_complete
I tied it to vB Event Forums for the Product, not sure if that really does anything.

In the code I combined these 2 plugins.
"Display Event Details on Thread Page" (Hook Location : showthread_complete - vB Event Forums)
"Event Attendance - show/enroll" (Hook Location : calendar_getday_event - Event Attendance) (note: I had to leave this Plugin active!)

The Code: show/enroll remarked in caps and bolded
Code:
// we need to initialise this variable here, otherwise on non Event Threads, the var will show as text
$lv_vb_eventforums_eventdetails = "";
//ATTENDANCE VARIABLES FROM SHOW/ENROLL start
$time_until_event=$eventinfo['dateline_from']-(TIMENOW+$vbulletion->userinfo['timezoneoffset']*3600); 
//Check time till event 
if ($vbulletin->userinfo['dstonoff']) 
{ 
    $time_until_event=$time_until_event-3600; 
} 
//echo $time_until_event."   "; 
$show['enroll']=(($time_until_event>0) || ($vbulletin->options['lateenroll'])) ? true : false; 
//ATTENDANCE VARIABLES FROM SHOW/ENROLL end

// 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 *
            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;
  
  // reset the thread title, so the page title is correct.
  // we need todo this, otherwise all the html we added will show up in the browser title bar
  $threadinfo['title'] = $eventinfo['title'];
  
  // 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>';
  
  // query the event reminder table
  $lv_vb_eventforums_eventReminder = $vbulletin->db->query_read("
            SELECT subscribeeventid
            FROM " . TABLE_PREFIX . "subscribeevent
            WHERE eventid = " . intval($lv_vb_eventforums_eventid) . " AND userid = " . intval($vbulletin->userinfo['userid']) . "
        ");
  $lv_vb_eventforums_eventReminderRows = $vbulletin->db->num_rows($lv_vb_eventforums_eventReminder);
  
  // parse membergroupids and make sql code to insert into where clause
  if(trim($vbulletin->userinfo['membergroupids']) != '')
  {
    $membergroupids = preg_split('/[,]/', trim($vbulletin->userinfo['membergroupids']));
  }
  
  // get permissions
  $lv_vb_eventforums_permissions = array();
  
  $membergroupsql = '';
  if(isset($membergroupids) && (count($membergroupids) > 0))
  {
    foreach($membergroupids as $key => $value)
    {
   if($value != '')
   {
     $membergroupsql .= ' OR usergroupid = ' . $value;
   }
    }
  }
  
  // get permissions for the user's usergroups
  $lv_vb_eventforums_permissionsQuery = $vbulletin->db->query_read("
   SELECT usergroupid, calendarpermissions 
   FROM " . TABLE_PREFIX . "usergroup
   WHERE usergroupid = " . intval($vbulletin->userinfo['usergroupid']) . "
   " . $membergroupsql . "
  ");
  
  //$lv_vb_eventforums_usergroupPermissionsQuery = mysql_fetch_array($lv_vb_eventforums_usergroupPermissionsQuery, MYSQL_ASSOC); 
  
  while($row = $vbulletin->db->fetch_array($lv_vb_eventforums_permissionsQuery, MYSQL_ASSOC))
  {
    $lv_vb_eventforums_permissions[$row['usergroupid']] = $row['calendarpermissions'];
  }
  
  // format the sql for the next query
  if(count($membergroupids) > 0)
  {
    $membergroupsql = ' AND (usergroupid = ' . $vbulletin->userinfo['usergroupid'] . $membergroupsql . ')';
  }
  
  // get any permissions overwritten in the AdminCP for the calendar
  $lv_vb_eventforums_permissionsQuery = $vbulletin->db->query_read("
   SELECT usergroupid, calendarpermissions
   FROM " . TABLE_PREFIX . "calendarpermission
   WHERE calendarid = " . intval($eventinfo['calendarid']) . "
   " . $membergroupsql . "
  ");
  
  while($row = $vbulletin->db->fetch_array($lv_vb_eventforums_permissionsQuery, MYSQL_ASSOC))
  {
    $lv_vb_eventforums_permissions[$row['usergroupid']] = $row['calendarpermissions'];
  }
  
  // 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
  $vbphrase['date_x_to_y'] = fetch_phrase("date_x_to_y", 5);
  $vbphrase['time_x_to_y'] = fetch_phrase("time_x_to_y", 5);
  $vbphrase['delete_reminder_for_this_event'] = fetch_phrase("delete_reminder_for_this_event", 5);
  $vbphrase['request_reminder_for_this_event'] = fetch_phrase("request_reminder_for_this_event", 5);
  $vbphrase['event_options'] = fetch_phrase("event_options", 5);
  $vbphrase['edit_event'] = fetch_phrase("edit_event", 5);
  $vbphrase['delete_event'] = fetch_phrase("delete_event", 5);
  $vbphrase['move_event'] = fetch_phrase("move_event", 5);
  $vbphrase['lv_vb_eventforums_phrase_noReplies'] = fetch_phrase("lv_vb_eventforums_phrase_noReplies", 5);
  
  // 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;
          }
        }
      }
 }
 //-- for some reason the vb guys decided that user deleting their own posts
 //-- can only do it from the edit menu. its a bug i think.
    // can this user delete the event?
    /*if(!$show['candeleteevent'])
    {
      if($eventinfo['userid'] == $vbulletin->userinfo['userid'])
      {
        if(($value & $vbulletin->bf_ugp_calendarpermissions['candeleteevent']))
        {
       $show['candeleteevent'] = true;
        }
      }
    }*/
  }
  
//ATTENDANCE CODE FROM SHOW/ENROLL start 
//Enroll/Cancel 
if ($_REQUEST['ea'] == "attend" || $_REQUEST['ea'] == "unattend" AND ($time_until_event>0 OR $vbulletin->options['lateenroll']) ) 
        { 
            if (!$eventinfo['roll']) 
                { 
                    $roll = array(); 
                } 
                else 
                { 
                    $roll = @unserialize($eventinfo['roll']); 
                } 
        if ($_REQUEST['ea'] == "attend") 
            { 
            if ($vbulletin->userinfo[userid]) 
            { 
                $roll[$vbulletin->userinfo['userid']] = $vbulletin->userinfo['username'];         
            } 
            else 
            { 
            print_no_permission(); 
            } 
            } 
            else 
            { 
            if ($vbulletin->userinfo[userid]) 
            { 
                unset($roll[$vbulletin->userinfo['userid']]);         
            } 
            else 
            { 
            print_no_permission(); 
            } 
            } 
     
            $eventinfo['roll'] = serialize($roll); 
        $db->query_write("UPDATE ".TABLE_PREFIX."event SET roll='".addslashes($eventinfo['roll'])."' WHERE eventid='".$eventinfo['eventid']."'"); 
        $_REQUEST['do'] = "getinfo"; 
} 
//show enrolled people 
        $rollcount=0; 
                if ($eventinfo['useroll']) 
                { 
                    // Roll for this event 
            unset($rollbits); 
                    $show['userattending'] = false; 
                    if (($roll = @unserialize($eventinfo['roll'])) && is_array($roll)) 
                    { 
                if ($vbulletin->options['roll_sort']) 
                { 
                    uasort($roll, "strnatcasecmp"); 
                } 
                            if (array_key_exists($vbulletin->userinfo['userid'], $roll)) 
                            { 
                    $show['userattending']=true; 
                            } 
                     
                    while ($rollusername = current($roll)) 
                { 
                $rolluserid = key($roll); 
                eval('$rollbits .= "' . fetch_template('calendar_rollbit') . '";'); 
                $rollcount++; 
                next($roll); 
                } 
                    } 
                        else 
                        { 
                            $eventinfo['roll'] = ""; 
                        } 
                         
                        eval ('$eventinfo[roll] = "' . fetch_template('calendar_roll') . '";'); 
            $eventinfo['event'].=$eventinfo['roll']; 
                    // End Roll 
                } 
                else 
                { 
                    $eventinfo['roll'] = ""; 
                } 
//ATTENDANCE CODE FROM SHOW/ENROLL end
 
  
  // show the options box?
  if(($show['candeleteevent'] OR $show['canmoveevent'] OR $show['caneditevent']) AND !$show['holiday'])
  {
    $show['eventoptions'] = true;
  }
  
  // construct the user info for the event poster
  $eventinfo['musername'] = $lv_vb_eventforums_user['username'] . '</a>';
  
  // user title
  $usertitle = $lv_vb_eventforums_user['usertitle'];
  if($usertitle != '')
  {
    $eventinfo['musername'] .= '<div class="smallfont" style="margin-bottom:3px;">' . $usertitle . '</div>';
  }
  
  // user avatar
  //$avatarurl = fetch_avatar_url($lv_vb_eventforums_user['userid']);
  //if($avatarurl[0] != '')
  //{
  //  $eventinfo['musername'] .= '<div class="smallfont" style="margin-bottom:3px;">&nbsp;<br><a href="member.php?u=' . $lv_vb_eventforums_user['userid'] . '"><img title="" src="' . $avatarurl[0] .'" alt="" border="0"></a></div>';
  //}
  
  $eventinfo['musername'] .= '<a>'; // this is required to validate the tag we skipped
   
  // 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;
  }
  
  // get the title of the custom fields
  $lv_vb_eventforums_calendarFields = $vbulletin->db->query_read("
            SELECT *
            FROM " . TABLE_PREFIX . "calendarcustomfield
            WHERE calendarid = " . intval($lv_vb_eventforums_event['calendarid']) . "
   ORDER BY calendarcustomfieldid 
        ");
   
  // Custom Fields
  $lv_vb_eventforums_customfieldvals = unserialize($lv_vb_eventforums_event['customfields']);
  $lv_vb_eventforums_customfieldarray = array();
  
  if($lv_vb_eventforums_calendarFields)
  {
    while($row = $vbulletin->db->fetch_array($lv_vb_eventforums_calendarFields, MYSQL_ASSOC))
    {
   $lv_vb_eventforums_customfieldarray[$row['title']] = $lv_vb_eventforums_customfieldvals[$row['calendarcustomfieldid']];
    }
  }
  
  // custom fields
  if(count($lv_vb_eventforums_customfieldarray) > 0)
  {
    $show['customfields'] = true;
 $show['customoption'] = true;
 
    $lv_vb_eventforums_customfields = '';
    foreach($lv_vb_eventforums_customfieldarray as $key => $value) 
    {
   $value = trim($value);
   if(!empty($value))
   {
     $customtitle = $key;
     $customoption = convert_url_to_bbcode(unhtmlspecialchars($value));
     $customoption = $bbcode_parser->parse($customoption, 0, true);
     eval('$lv_vb_eventforums_customfields .= "' . fetch_template('calendar_showeventsbit_customfield') . '";');
   }
    }
 
 $customfields = $lv_vb_eventforums_customfields;
  }
  
  //$eventinfo['event'] = /*convert_url_to_bbcode(*/unhtmlspecialchars($eventinfo['event'])/*)*/;
  $eventinfo['event'] = $bbcode_parser->parse($eventinfo['event'], $foruminfo['forumid'], true); 
  
  eval('$spacertable1 = "' . fetch_template('spacer_close') . '";');
  eval('$spacertable2 = "' . fetch_template('spacer_open') . '";');
  //eval('$spacertable1 = "' . fetch_template('spacer_open') . '";');
  //eval('$spacertable2 = "' . fetch_template('spacer_close') . '";');
  //eval('$lv_vb_eventforums_eventblock = $spacertable1;');
  eval('$lv_vb_eventforums_eventblock = "' . fetch_template('calendar_showeventsbit') . '";');
  //eval('$lv_vb_eventforums_eventblock .= $spacertable2;');
  
  if($vbulletin->options['lv_vb_eventforums_varForEventDetails'])
  {
    $lv_vb_eventforums_eventdetails = $lv_vb_eventforums_eventblock;
  }
  else
  {
    $navbar .= $spacertable1 . $lv_vb_eventforums_eventblock . $spacertable2;
    //eval('$navbar =  . $navbar . $lv_vb_eventforums_eventblock;');
  }  
   
  // if thread is only showing first post, and is an event thread
  // discount the options and make sure quick reply is available without forcing an initial
  // click on a post.
  // This is because there is no quick reply button on the event, and the first post is hidden
  if($totalposts == 1) // only first post
  {
 require_once(DIR . '/includes/functions_editor.php');
    $istyles_js = construct_editor_styles_js();
    $qrpostid = $threadinfo['firstpostid'];
    $show['qr_require_click'] = 0;
 
 unset($messagearea);
 $editorid = construct_edit_toolbar('', 0, $foruminfo['forumid'], ($foruminfo['allowsmilies'] ? 1 : 0), 1, false, 'qr');
 $messagearea = "
  <script type=\"text/javascript\">
  <!--
   var threaded_mode = $threadedmode;
   var require_click = " . '0' . ";
   var is_last_page = " . '0' . ";
   var ajax_last_post = " . intval($effective_lastpost) . ";
  // -->
  </script>
  $messagearea
 ";
 // this isn't a great way todo this, but the lack of hooks makes this the only way I can see
 // its a bodge, but it works for now...
 $messagearea = preg_replace('/disabled="disabled"/', '', $messagearea);
 $messagearea = preg_replace('/' . fetch_phrase("click_quick_reply_icon", 41) . '/', '', $messagearea);
 
 //$noposts = '<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="0" border="0" width="100%" align="center">';
 //$noposts .= '<tbody><tr>';
 //$noposts .= '<td class="alt1">There are no replies to show</td>';
    //$noposts .= '</tr></tbody>';
 //$noposts .= '</table>';
 //$noposts .= '<br/>';
 eval('$noposts = "' . fetch_template('lv_vb_eventforums_noPostSpacer') . '";');
 //eval('$postbits = $noposts . $postbits . ;');
 $postbits = $noposts . $postbits;
  } // is first post
}
The only other issues I found was a slight display issue with a couple extra lines thrown in with the showthread view & my username is not color coded. Again minor issues imho. (see attachments, accurately named)
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01306 seconds
  • Memory Usage 1,873KB
  • 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)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