Skip to content

Instantly share code, notes, and snippets.

@eteubert
Created February 25, 2012 16:22
Show Gist options
  • Select an option

  • Save eteubert/1909337 to your computer and use it in GitHub Desktop.

Select an option

Save eteubert/1909337 to your computer and use it in GitHub Desktop.
dtpr: dtpr_get_user_capability_names
<?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