Thread: Social Group and Album Enhancements - Social Group Calendars
View Single Post
  #2  
Old 01-28-2009, 09:13 AM
Farcaster Farcaster is offline
 
Join Date: Dec 2005
Posts: 386
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Unfortunately, vBulletin lacks some hooks in key places for events, such as hooks to the event SQL statements. This means that there are a number of file edits needed for this modification. Sorry for that, but I hope it will be worth it! Enjoy!

Step One – Backup Your Database and vBulletin Files!
This really needs to be said, especially since this version is in BETA. Loss of data/time/business is not the responsibility of the developer. Use at your own risk.

Step Two – Import the Product File
In the Admin CP, import rah_socialgroup_calendars_1_0_0.xml.

Step Three – Edit vBulletin File: includes/functions_calendar.php
Note: If you do not want to have Social Group Events show up in the upcoming events section on your forum homepage, then you only need do steps 1 through 7 in this section.

1. Find the first instance of (in function cache_events, near the beginning of the file):

PHP Code:
    $events $vbulletin->db->query_read_slave("
        SELECT event.*, 
2. Above that add:

PHP Code:
// Social Group Calendar **************************************************
 
    // Exempt administrators and other designated groups.
    
$exemptgroups explode(',',str_replace(' ','',$vbulletin->options['rah_socialcal_admins'])); 
 
    if (
is_member_of($vbulletin->userinfo,$exemptgroups)) {
        
$exemptsql " OR 1=1 ";
    }    
    if (
$vbulletin->userinfo['userid']) {
        
$eventjoin "     LEFT JOIN ".TABLE_PREFIX."socialgroupmember sgm ON sgm.userid = 0".$vbulletin->userinfo['userid']." AND sgm.groupid = event.socialgroupcalendar 
                        LEFT JOIN (SELECT groupid, name FROM "
.TABLE_PREFIX."socialgroup) sg ON sg.groupid = event.socialgroupcalendar";
        
$eventwhere " AND (event.socialgroupcalendar = 0 OR sgm.groupid IS NOT NULL $exemptsql) ";
        
$eventselect " sg.name as socialgroupname, ";
    }
 
    
// Social Group Calendar END *********************************************** 
3. Scroll back down and after the comma in “SELECT event.*,” add:

PHP Code:
$eventselect 
4. Scroll down about five lines to find:
PHP Code:
        LEFT JOIN " . TABLE_PREFIX . "user AS user ON (user.userid event.userid
5. Below that add:
PHP Code:
$eventjoin 
6. Scroll down about four lines to find:
PHP Code:
            visible 
7. Below that add:
PHP Code:
$eventwhere 
8. Find the following (in function build_events, near the end of the file):

PHP Code:
    $events $vbulletin->db->query_read_slave("
        SELECT eventid, userid, event.title, recurring, recuroption, dateline_from, dateline_to, event.calendarid, IF (dateline_to = 0, 1, 0) AS singleday, customfields,
            dateline_from AS dateline_from_user, dateline_to AS dateline_to_user, utc, dst 
9. Above that add:
PHP Code:
    // Social Group Calendar **************************************************
    
$eventjoin "     LEFT JOIN (SELECT groupid, name FROM ".TABLE_PREFIX."socialgroup) sg ON sg.groupid = event.socialgroupcalendar ";
    
$eventselect ", event.socialgroupcalendar, sg.name as socialgroupname ";
    
// Social Group Calendar END *********************************************** 
10. After “dateline_to AS dateline_to_user, utc, dst”, add:
PHP Code:
$eventselect 
11. Scroll down about two lines and find:
PHP Code:
        INNER JOIN " . TABLE_PREFIX . "calendar AS calendar USING (calendarid
12. Below that add:
PHP Code:
$eventjoin 
Step Four – Edit vBulletin File: index.php
Note: If you do not want to have Social Group Events show up in the upcoming events section on your forum homepage, you can skip this section entirely. Keep in mind though that if you do have your calendar options set to show events from the calendar that social group events will be posted to, the list will not be filtered and everyone will see them.

1. Find the following:
PHP Code:
// ### TODAY'S EVENTS #################################################
if ($vbulletin->options['showevents'])

2. Below that add:
PHP Code:
// Social Group Calendar **************************************************
// Get Social Group Memberships    
$usersocialgroups = array();    
if (
$vbulletin->userinfo['userid']) {
 
    
$getsocialgroups $vbulletin->db->query_read_slave("
    SELECT groupid 
    FROM "
.TABLE_PREFIX."socialgroupmember sgm 
    WHERE sgm.userid = "
.intval($vbulletin->userinfo['userid']));
 
    while (
$group $vbulletin->db->fetch_array($getsocialgroups)) {
        
$usersocialgroups[]=$group['groupid'];
 
    }        
}
 
// Exempt administrators and other designated groups.
$exemptgroups explode(',',str_replace(' ','',$vbulletin->options['rah_socialcal_admins']));     
 
if (
is_member_of($vbulletin->userinfo,$exemptgroups)) {
    
$exempt true;
}
// Social Group Calendar END *********************************************** 
3. Find the following:
PHP Code:
        {
            
$sub $eventinfo['dateline_from_user'] - (86400 * (intval($eventinfo['dateline_from_user'] / 86400)));
        } 
4. Below that add:
PHP Code:
        // Social Group Calendar **********************************************
        
$filterevent false;
        if (
$eventinfo['socialgroupcalendar'] AND !in_array($eventinfo['socialgroupcalendar'],$usersocialgroups)) {
            
// This is a social group event, and this is not a member.  Suppress the event
            
$filterevent true;
        }
 
        
// Add exception for admins and other designated groups.
        
if ($exempt) {
            
$filterevent false;
        }
 
        
// Add social group name to event title.
        
if ($eventinfo['socialgroupcalendar']) {
            
$eventstore[$eventinfo[eventid]]['title'] = "<font style=\"font-weight:bold\">[$eventinfo[socialgroupname]]</font> $eventinfo[title]";
        }        
        
// Social Group Calendar END ******************************************* 
5. Immediately below the code you just entered, find:
PHP Code:
        if ($vbulletin->userinfo['calendarpermissions']["$eventinfo[calendarid]"] & $vbulletin->bf_ugp_calendarpermissions['canviewcalendar'] OR ($eventinfo['holidayid'] AND $vbulletin->options['showholidays']))
        { 
6. Replace with:
PHP Code:
        // Edited from original for Social Group Calendar
        
if (!$filterevent AND $vbulletin->userinfo['calendarpermissions']["$eventinfo[calendarid]"] & $vbulletin->bf_ugp_calendarpermissions['canviewcalendar'] OR ($eventinfo['holidayid'] AND $vbulletin->options['showholidays']))
        { 
Step Five – Upload Files
Upload the modified files to the appropriate directory in your forum.

Step Six – Edit Template: socialgroups_form
1. Find the following:
HTML Code:
<legend>$vbphrase[group_options]</legend>
<div class="smallfont">
2. Below that add:
HTML Code:
<div>
    <label for="member_entered_events"><input type="checkbox" name="member_entered_events" id="member_entered_events" value="1" $checked[member_entered_events]/> $vbphrase[member_entered_events]</label>
</div>
Step Seven – Edit Template: socialgroups_group
Note: If you’re trying to install this on version 3.7.x, the section you put the variable in will be different. Try putting it above <!--pictures--> for instance, and then adjust to be located where you want.

1. Find the following:
HTML Code:
    </div><br />
</if>
 
 
<!-- Discussions -->
2. Above that add:
HTML Code:
$socialgroups_events
Step Eight – Configuration
In the Admin CP, go into vBulletin Options -> Social Group Calendar. Set the options as desired. The product will not start working until a calendar ID is entered in this section. Make sure to configure the calendar selected to allow members to post events.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05362 seconds
  • Memory Usage 1,875KB
  • 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
  • (4)bbcode_html
  • (18)bbcode_php
  • (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