Changeset 4083 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-rosetta-roles/inc/class-plugin.php
- Timestamp:
- 09/16/2016 08:56:17 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-rosetta-roles/inc/class-plugin.php
r3954 r4083 29 29 */ 30 30 const GENERAL_TRANSLATION_EDITOR_ROLE = 'general_translation_editor'; 31 32 /** 33 * Role of a locale manager. 34 */ 35 const LOCALE_MANAGER_ROLE = 'locale_manager'; 31 36 32 37 /** … … 102 107 103 108 // Simple check to see if they're an approver or not. 104 if ( ! $this->is_approver_for_locale( $args['user_id'], $locale_slug ) ) { 105 return false; 109 $role = $this->is_approver_for_locale( $args['user_id'], $locale_slug ); 110 if ( ! $role ) { 111 return false; 112 } 113 114 // Locale managers are allowed to approve all projects. 115 if ( self::LOCALE_MANAGER_ROLE === $role ) { 116 return true; 106 117 } 107 118 … … 170 181 * @param int $user_id User ID. 171 182 * @param string $locale_slug The Locale for which we are checking. 172 * @return bool True, if user is an approver, false if not.183 * @return false|string Role, if user is an approver, false if not. 173 184 */ 174 185 public function is_approver_for_locale( $user_id, $locale_slug ) { … … 202 213 203 214 $capabilities = $user->{$cap_key}; 204 $is_approver = ! empty( $capabilities[ self::TRANSLATION_EDITOR_ROLE ] ) || ! empty( $capabilities[ self::GENERAL_TRANSLATION_EDITOR_ROLE ] ); 205 $cache[ $user_id ][ $locale_slug ] = $is_approver; 206 207 return $is_approver; 215 216 if ( ! empty( $capabilities[ self::LOCALE_MANAGER_ROLE ] ) ) { 217 $cache[ $user_id ][ $locale_slug ] = self::LOCALE_MANAGER_ROLE; 218 return self::LOCALE_MANAGER_ROLE; 219 } elseif ( ! empty( $capabilities[ self::GENERAL_TRANSLATION_EDITOR_ROLE ] ) ) { 220 $cache[ $user_id ][ $locale_slug ] = self::GENERAL_TRANSLATION_EDITOR_ROLE; 221 return self::GENERAL_TRANSLATION_EDITOR_ROLE; 222 } elseif ( ! empty( $capabilities[ self::TRANSLATION_EDITOR_ROLE ] ) ) { 223 $cache[ $user_id ][ $locale_slug ] = self::TRANSLATION_EDITOR_ROLE; 224 return self::TRANSLATION_EDITOR_ROLE; 225 } else { 226 $cache[ $user_id ][ $locale_slug ] = false; 227 return false; 228 } 208 229 } 209 230
Note: See TracChangeset
for help on using the changeset viewer.