Created
February 25, 2012 16:22
-
-
Save eteubert/1909337 to your computer and use it in GitHub Desktop.
dtpr: dtpr_get_user_capability_names
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Get capability names array of user. | |
| * | |
| * Example output: | |
| * | |
| * Array | |
| * ( | |
| * [1] => Array | |
| * ( | |
| * [organization_name] => Orga Unit 1 | |
| * [level_name] => Big Boss | |
| * ) | |
| * [3] => Array | |
| * ( | |
| * [organization_name] => Orga Unit 2 | |
| * [level_name] => Middle Manager | |
| * ) | |
| * ) | |
| * | |
| * @param $user_id integer | |
| * @return array | |
| */ | |
| function dtpr_get_user_capability_names( $user_id ) { | |
| $capabilities = dtpr_get_user_capabilities( $user_id ); | |
| $capability_names = array(); | |
| foreach ( $capabilities[ 'capabilities' ] as $organization_unit_id => $level ) { | |
| $organization = Inpsyde_Organization_Unit::find_by_id( $organization_unit_id ); | |
| if ( $organization ) { | |
| $capability_names[ $organization_unit_id ] = array( | |
| 'organization_name' => $organization->name, | |
| 'level_name' => Inpsyde_User_Level::find_by_id( $level )->name | |
| ); | |
| } else { | |
| $capability_names[ $organization_unit_id ] = array(); | |
| } | |
| } | |
| return $capability_names; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment