function i18n_access_load_permissions in Translation Access 6
Same name and namespace in other branches
- 7 i18n_access.module \i18n_access_load_permissions()
Load the language permissions for a given user
6 calls to i18n_access_load_permissions()
- i18nAccessTestCase::setLanguagePermissions in ./
i18n_access.test - Sets the language permission for the specified user. Must be logged in as an 'administer users' privileged user before calling this.
- i18nAccessTestCase::testAdminUser in ./
i18n_access.test - Test admin user. User with 'administer nodes' permission should be able to create and edit nodes regardless of the language
- i18nAccessTestCase::testTranslatorUser in ./
i18n_access.test - Test translator user. User with 'create story content' and 'edit own story content' permissions should be able to create and edit story nodes only in the languages that they have permissions for.
- i18n_access_form_alter in ./
i18n_access.module - Implementation of hook_form_alter().
- i18n_access_user in ./
i18n_access.module - Implementation of hook_user().
File
- ./
i18n_access.module, line 46 - file_description
Code
function i18n_access_load_permissions($account = NULL) {
static $perms = array();
// use the global user id if none is passed
if (!isset($account)) {
$account = $GLOBALS['user'];
}
if (!isset($perms[$account->uid])) {
$perm_string = db_result(db_query('SELECT perm FROM {i18n_access} WHERE uid = %d', $account->uid));
if ($perm_string) {
$perms[$account->uid] = drupal_map_assoc(explode(', ', $perm_string));
}
else {
$perms[$account->uid] = array();
}
}
// adding the default languages if permission has been granted
if (user_access('access selected languages', $account)) {
$perms[$account->uid] = array_merge($perms[$account->uid], drupal_map_assoc(variable_get('i18n_access_languages', array())));
}
return $perms[$account->uid];
}