/** * Get fields array for config values. */ function _groupadmin_settings_fields($context = FALSE) { static $fields; if ($fields) { return $fields; } // Get possible access types. $roles = array_merge(array('nobody'), _groupadmin_user_has_role()); // Array of variables of name => array: description, [default value], [required/options], [menu_rebuild_needed]. // For fieldset: name => array: description, [collapsed], [collapsible]. $links = array('f_links' => array('What links should be shown where?', TRUE, TRUE), 'x_show_on_node_page' => array('Show GroupAdmin <em>Members</em> link on node page.', TRUE, FALSE, TRUE), 'x_show_on_members_page' => array('Show GroupAdmin <em>Members</em> link on standard <em>members</em> page.', TRUE, FALSE, TRUE), 'x_use_standard_path' => array('Expose GroupAdmin at /og/users/[gid]. You may also need to ' . l('disable og_members', 'admin/build/views/disable/og_members') . ' View.', FALSE, FALSE, TRUE), 'x_remove_standard_link' => array('Remove the standard <em>Add Members</em> link.', TRUE, FALSE, TRUE)); $options = array('f_options' => array('Options for appearance and behaviour.', TRUE, TRUE), 'n_help_node' => array('Node (nid) for help section. If not specified, help section will not be displayed.'), 'n_member_help_node' => array('Node (nid) for help for members. If not specified, main help node will be used.'), 'n_admin_help_node' => array('Node (nid) for help for admins. If not specified, member help node will be used.'), 'x_help_collapsed' => array('If set, help section initially appears collapsed.', TRUE), 'n_pagelen' => array('Page length for user list.', 10, TRUE), 'x_reset_on_add' => array('Clear the search criteria after adding a new member.', FALSE)); $access = array('f_access_control' => array('This section allows you to define access controls. ' . 'Note: <em>manager</em> and <em>admin</em> here refer to Group roles and ' . '<em>visitor</em> means anyone who has access to view the Group node.', TRUE, TRUE), 'l_basic_access' => array('Who is allowed basic access to <em>GroupAdmin</em>?', 4, $roles, TRUE), 'l_show_admins' => array('Who is allowed to view/search group administrators?', 4, $roles, TRUE), 'l_show_members' => array('Who is allowed to view/search group members?', 3, $roles, TRUE), 'l_show_non-members' => array('Who is allowed to view/search non-members?', 2, $roles), 'l_show_email' => array('Who is allowed to view/search email addresses?', 0, $roles), 'l_show_real_names' => array('Who is allowed to view/search real names?', 0, $roles), 'x_more_permissions' => array('Activate role-based permissions in conjunction with the above.', FALSE, FALSE, TRUE)); /* $advanced = array( // Advanced. 'f_advanced' => array('<strong>NOT YET FULLY FUNCTIONAL!</strong> This section allows you to define a more flexible configuration for GroupAdmin, depending on group-type and/or individual group.' . '<ul><li>Using configuration per group-type, the main configuration values will be used as defaults.</li>' . '<li>Using configuration per group, the group-type and then main configuration values will be used as defaults.</li></ul>', TRUE, TRUE), 'x_configuration_per_group_type' => array('Provide a separate configuration for each type of group, accessible via content-type edit pages. ' . 'Access requires <em>administer content types</em> permission.', FALSE, FALSE, TRUE), 'x_configuration_per_group' => array('Provide a separate configuration for each individual group.', FALSE, FALSE, TRUE), ); if ($context) { unset($access['l_basic_access']); unset($access['x_more_permissions']); $fields = array_merge($options, $access); } else { $fields = array_merge($links, $options, $access, $advanced); } */ $fields = array_merge($links, $options, $access); // Add configuration arrays from other modules. $fields = array_merge($fields, _groupadmin_get_modules('config_fields')); return $fields; }
/** * Check whether current user can perform tasks for given group. * We don't need to worry too much about performance here, as result * will normally be cached via _groupadmin_access() function. */ function _groupadmin_access_check($gid, $op) { // Initial checks: make sure $gid is a valid Group node. if (!_groupadmin_checkfunc('og_is_group_type')) { return FALSE; } if (!og_is_group_type(_groupadmin_get_group($gid, 'type'))) { return FALSE; } global $user; $node = _groupadmin_get_group($gid); switch ($op) { case 'administrate': $required = 'admins'; break; case 'show_all': $op = 'show_non-members'; // don't break // don't break default: $required = _groupadmin_settings('l_' . $op); } $access = _groupadmin_user_has_role($node, $user, $required); return $access; }