Changeset 2863 for trunk/bp-activity.php
- Timestamp:
- 03/22/2010 11:34:23 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity.php
r2842 r2863 1 1 <?php 2 3 define ( 'BP_ACTIVITY_DB_VERSION', '2100' );4 5 /* Define the slug for the component */6 if ( !defined( 'BP_ACTIVITY_SLUG' ) )7 define ( 'BP_ACTIVITY_SLUG', 'activity' );8 9 2 require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-classes.php' ); 10 3 require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-templatetags.php' ); 11 4 require ( BP_PLUGIN_DIR . '/bp-activity/bp-activity-filters.php' ); 12 5 13 function bp_activity_install() {14 global $wpdb, $bp;15 16 if ( !empty($wpdb->charset) )17 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";18 19 /* Rename the old user activity cached table if needed. */20 if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$wpdb->base_prefix}bp_activity_user_activity_cached%'" ) )21 $wpdb->query( "RENAME TABLE {$wpdb->base_prefix}bp_activity_user_activity_cached TO {$bp->activity->table_name}" );22 23 /* Rename fields from pre BP 1.2 */24 if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$bp->activity->table_name}%'" ) ) {25 if ( $wpdb->get_var( "SHOW COLUMNS FROM {$bp->activity->table_name} LIKE 'component_action'" ) )26 $wpdb->query( "ALTER TABLE {$bp->activity->table_name} CHANGE component_action type varchar(75) NOT NULL" );27 28 if ( $wpdb->get_var( "SHOW COLUMNS FROM {$bp->activity->table_name} LIKE 'component_name'" ) )29 $wpdb->query( "ALTER TABLE {$bp->activity->table_name} CHANGE component_name component varchar(75) NOT NULL" );30 }31 32 /**33 * Build the tables34 */35 $sql[] = "CREATE TABLE {$bp->activity->table_name} (36 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,37 user_id bigint(20) NOT NULL,38 component varchar(75) NOT NULL,39 type varchar(75) NOT NULL,40 action text NOT NULL,41 content longtext NOT NULL,42 primary_link varchar(150) NOT NULL,43 item_id varchar(75) NOT NULL,44 secondary_item_id varchar(75) DEFAULT NULL,45 date_recorded datetime NOT NULL,46 hide_sitewide bool DEFAULT 0,47 mptt_left int(11) NOT NULL DEFAULT 0,48 mptt_right int(11) NOT NULL DEFAULT 0,49 KEY date_recorded (date_recorded),50 KEY user_id (user_id),51 KEY item_id (item_id),52 KEY secondary_item_id (secondary_item_id),53 KEY component (component),54 KEY type (type),55 KEY mptt_left (mptt_left),56 KEY mptt_right (mptt_right),57 KEY hide_sitewide (hide_sitewide)58 ) {$charset_collate};";59 60 $sql[] = "CREATE TABLE {$bp->activity->table_name_meta} (61 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,62 activity_id bigint(20) NOT NULL,63 meta_key varchar(255) DEFAULT NULL,64 meta_value longtext DEFAULT NULL,65 KEY activity_id (activity_id),66 KEY meta_key (meta_key)67 ) {$charset_collate};";68 69 require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );70 dbDelta($sql);71 72 update_site_option( 'bp-activity-db-version', BP_ACTIVITY_DB_VERSION );73 }74 75 6 function bp_activity_setup_globals() { 76 7 global $bp, $wpdb, $current_blog; 77 8 78 /* Internal identifier */ 9 if ( !defined( 'BP_ACTIVITY_SLUG' ) ) 10 define ( 'BP_ACTIVITY_SLUG', $bp->pages->activity->slug ); 11 12 /* For internal identification */ 79 13 $bp->activity->id = 'activity'; 14 $bp->activity->name = $bp->pages->activity->name; 15 $bp->activity->slug = BP_ACTIVITY_SLUG; 80 16 81 17 $bp->activity->table_name = $wpdb->base_prefix . 'bp_activity'; 82 18 $bp->activity->table_name_meta = $wpdb->base_prefix . 'bp_activity_meta'; 83 $bp->activity->slug = BP_ACTIVITY_SLUG;84 19 $bp->activity->format_notification_function = 'bp_activity_format_notifications'; 85 20 … … 91 26 add_action( 'bp_setup_globals', 'bp_activity_setup_globals' ); 92 27 93 function bp_activity_check_installed() {94 global $wpdb, $bp;95 96 if ( get_site_option( 'bp-activity-db-version' ) < BP_ACTIVITY_DB_VERSION )97 bp_activity_install();98 }99 add_action( 'admin_menu', 'bp_activity_check_installed' );100 101 function bp_activity_setup_root_component() {102 /* Register 'activity' as a root component (for RSS feed use) */103 bp_core_add_root_component( BP_ACTIVITY_SLUG );104 }105 add_action( 'bp_setup_root_components', 'bp_activity_setup_root_component' );106 107 28 function bp_activity_setup_nav() { 108 29 global $bp; 109 30 110 31 /* Add 'Activity' to the main navigation */ 111 bp_core_new_nav_item( array( 'name' => __( 'Activity', 'buddypress' ), 'slug' => $bp->activity-> slug, 'position' => 10, 'screen_function' => 'bp_activity_screen_my_activity', 'default_subnav_slug' => 'just-me', 'item_css_id' => $bp->activity->id ) );32 bp_core_new_nav_item( array( 'name' => __( 'Activity', 'buddypress' ), 'slug' => $bp->activity->name, 'position' => 10, 'screen_function' => 'bp_activity_screen_my_activity', 'default_subnav_slug' => 'just-me', 'item_css_id' => $bp->activity->id ) ); 112 33 113 34 $user_domain = ( !empty( $bp->displayed_user->domain ) ) ? $bp->displayed_user->domain : $bp->loggedin_user->domain; 114 35 $user_login = ( !empty( $bp->displayed_user->userdata->user_login ) ) ? $bp->displayed_user->userdata->user_login : $bp->loggedin_user->userdata->user_login; 115 $activity_link = $user_domain . $bp->activity-> slug. '/';36 $activity_link = $user_domain . $bp->activity->name . '/'; 116 37 117 38 /* Add the subnav items to the activity nav item if we are using a theme that supports this */ 118 bp_core_new_subnav_item( array( 'name' => __( 'Personal', 'buddypress' ), 'slug' => 'just-me', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity-> slug, 'screen_function' => 'bp_activity_screen_my_activity', 'position' => 10 ) );39 bp_core_new_subnav_item( array( 'name' => __( 'Personal', 'buddypress' ), 'slug' => 'just-me', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_my_activity', 'position' => 10 ) ); 119 40 120 41 if ( bp_is_active( 'friends' ) ) 121 bp_core_new_subnav_item( array( 'name' => __( 'Friends', 'buddypress' ), 'slug' => BP_FRIENDS_SLUG, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity-> slug, 'screen_function' => 'bp_activity_screen_friends', 'position' => 20, 'item_css_id' => 'activity-friends' ) );42 bp_core_new_subnav_item( array( 'name' => __( 'Friends', 'buddypress' ), 'slug' => BP_FRIENDS_SLUG, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_friends', 'position' => 20, 'item_css_id' => 'activity-friends' ) ); 122 43 123 44 if ( bp_is_active( 'groups' ) ) 124 bp_core_new_subnav_item( array( 'name' => __( 'Groups', 'buddypress' ), 'slug' => BP_GROUPS_SLUG, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_groups', 'position' => 30, 'item_css_id' => 'activity-groups' ) );125 126 bp_core_new_subnav_item( array( 'name' => __( 'Favorites', 'buddypress' ), 'slug' => 'favorites', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity-> slug, 'screen_function' => 'bp_activity_screen_favorites', 'position' => 40, 'item_css_id' => 'activity-favs' ) );127 bp_core_new_subnav_item( array( 'name' => sprintf( __( '@%s Mentions', 'buddypress' ), $user_login ), 'slug' => 'mentions', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity-> slug, 'screen_function' => 'bp_activity_screen_mentions', 'position' => 50, 'item_css_id' => 'activity-mentions' ) );45 bp_core_new_subnav_item( array( 'name' => __( 'Groups', 'buddypress' ), 'slug' => $bp->groups->name, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_groups', 'position' => 30, 'item_css_id' => 'activity-groups' ) ); 46 47 bp_core_new_subnav_item( array( 'name' => __( 'Favorites', 'buddypress' ), 'slug' => 'favorites', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_favorites', 'position' => 40, 'item_css_id' => 'activity-favs' ) ); 48 bp_core_new_subnav_item( array( 'name' => sprintf( __( '@%s Mentions', 'buddypress' ), $user_login ), 'slug' => 'mentions', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_mentions', 'position' => 50, 'item_css_id' => 'activity-mentions' ) ); 128 49 129 50 if ( $bp->current_component == $bp->activity->slug ) { … … 215 136 global $bp; 216 137 217 if ( !$bp->displayed_user->id || $bp->current_component != $bp->activity-> slug)138 if ( !$bp->displayed_user->id || $bp->current_component != $bp->activity->name ) 218 139 return false; 219 140
Note: See TracChangeset
for help on using the changeset viewer.