Changeset 9293 for trunk/src/bp-groups/bp-groups-template.php
- Timestamp:
- 01/02/2015 04:32:04 AM (11 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-groups/bp-groups-template.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/bp-groups-template.php
r9291 r9293 1882 1882 1883 1883 /** 1884 * Can the logged-inuser send invitations in the specified group?1884 * Can a user send invitations in the specified group? 1885 1885 * 1886 1886 * @since BuddyPress (1.5.0) 1887 * 1888 * @param int $group_id Optional. The ID of the group whose status you want to 1889 * check. Default: the ID of the current group. 1890 * @return bool $can_send_invites 1891 */ 1892 function bp_groups_user_can_send_invites( $group_id = false ) { 1893 global $bp; 1894 1887 * @since BuddyPress (2.2.0) Added the $user_id parameter. 1888 * 1889 * @param int $group_id The group ID to check. 1890 * @param int $user_id The user ID to check. 1891 * @return bool 1892 */ 1893 function bp_groups_user_can_send_invites( $group_id = 0, $user_id = 0 ) { 1895 1894 $can_send_invites = false; 1896 1895 $invite_status = false; 1897 1896 1898 if ( is_user_logged_in() ) { 1899 if ( bp_current_user_can( 'bp_moderate' ) ) { 1900 // Super admins can always send invitations 1897 // If $user_id isn't specified, we check against the logged-in user. 1898 if ( ! $user_id ) { 1899 $user_id = bp_loggedin_user_id(); 1900 } 1901 1902 // If $group_id isn't specified, use existing one if available. 1903 if ( ! $group_id ) { 1904 $group_id = bp_get_current_group_id(); 1905 } 1906 1907 if ( $user_id ) { 1908 // Users with the 'bp_moderate' cap can always send invitations 1909 if ( user_can( $user_id, 'bp_moderate' ) ) { 1901 1910 $can_send_invites = true; 1902 1903 1911 } else { 1904 // If no $group_id is provided, default to the current group id1905 if ( !$group_id )1906 $group_id = isset( $bp->groups->current_group->id ) ? $bp->groups->current_group->id : 0;1907 1908 // If no group has been found, bail1909 if ( !$group_id )1910 return false;1911 1912 1912 $invite_status = bp_group_get_invite_status( $group_id ); 1913 if ( !$invite_status )1914 return false;1915 1913 1916 1914 switch ( $invite_status ) { 1917 1915 case 'admins' : 1918 if ( groups_is_user_admin( bp_loggedin_user_id(), $group_id ) )1916 if ( groups_is_user_admin( $user_id, $group_id ) ) { 1919 1917 $can_send_invites = true; 1918 } 1920 1919 break; 1921 1920 1922 1921 case 'mods' : 1923 if ( groups_is_user_mod( bp_loggedin_user_id(), $group_id ) || groups_is_user_admin( bp_loggedin_user_id(), $group_id ) )1922 if ( groups_is_user_mod( $user_id, $group_id ) || groups_is_user_admin( $user_id, $group_id ) ) { 1924 1923 $can_send_invites = true; 1924 } 1925 1925 break; 1926 1926 1927 1927 case 'members' : 1928 if ( groups_is_user_member( bp_loggedin_user_id(), $group_id ) )1928 if ( groups_is_user_member( $user_id, $group_id ) ) { 1929 1929 $can_send_invites = true; 1930 } 1930 1931 break; 1931 1932 } … … 1933 1934 } 1934 1935 1935 return apply_filters( 'bp_groups_user_can_send_invites', $can_send_invites, $group_id, $invite_status ); 1936 /** 1937 * Filters whether a user can send invites in a group. 1938 * 1939 * @since BuddyPress (1.5.0) 1940 * @since BuddyPress (2.2.0) Added the $user_id parameter. 1941 * 1942 * @param bool $can_send_invites Whether the user can send invites 1943 * @param int $group_id The group ID being checked 1944 * @param bool $invite_status The group's current invite status 1945 * @param int $user_id The user ID being checked 1946 */ 1947 return apply_filters( 'bp_groups_user_can_send_invites', $can_send_invites, $group_id, $invite_status, $user_id ); 1936 1948 } 1937 1949
Note: See TracChangeset
for help on using the changeset viewer.