function tac_lite_user in Taxonomy Access Control Lite 6
Same name and namespace in other branches
- 5 tac_lite.module \tac_lite_user()
Implementation of hook_user().
File
- ./
tac_lite.module, line 282 - Control access to site content based on taxonomy, roles and users.
Code
function tac_lite_user($op, $edit, $account, $category = NULL) {
if (!user_access('administer tac_lite')) {
// Only for tac_lite administrators.
return;
}
switch ($op) {
case 'categories':
return array(
array(
'name' => 'tac_lite',
'title' => t('Access by taxonomy'),
'weight' => 5,
'access callback' => 'user_access',
'access arguments' => array(
'administer users',
),
),
);
break;
case 'form':
$vocabularies = taxonomy_get_vocabularies();
if ($category == 'tac_lite') {
$vids = variable_get('tac_lite_categories', NULL);
if (count($vids)) {
for ($i = 1; $i <= variable_get('tac_lite_schemes', 1); $i++) {
$config = _tac_lite_config($i);
$terms = isset($account->{$config}['realm']) ? $account->{$config}['realm'] : array();
if ($config['name']) {
$perms = $config['perms'];
if ($config['term_visibility']) {
$perms[] = t('term visibility');
}
$form['tac_lite'][$config['realm']] = array(
'#type' => 'fieldset',
'#title' => $config['name'],
'#description' => t('This scheme controls %perms.', array(
'%perms' => implode(' and ', $perms),
)),
'#tree' => TRUE,
);
foreach ($vids as $vid) {
$v = $vocabularies[$vid];
$form['tac_lite'][$config['realm']][$vid] = _taxonomy_term_select(check_plain($v->name), NULL, isset($terms[$vid]) ? $terms[$vid] : NULL, $vid, '', TRUE, '<' . t('none') . '>');
$form['tac_lite'][$config['realm']][$vid]['#description'] = t('Grant permission to this user by selecting terms. Note that permissions are in addition to those granted based on user roles.');
}
}
}
$form['tac_lite'][0] = array(
'#type' => 'markup',
'#value' => '<p>' . t('You may grant this user access based on the schemes and terms below. These permissions are in addition to <a href="!url">role based grants on scheme settings pages</a>.', array(
'!url' => url('admin/user/access/tac_lite/scheme_1'),
)) . "</p>\n",
'#weight' => -1,
);
return $form;
}
}
break;
}
}