options['group_type'])) { return og_user_check_roles($group['group_type'], $group['gid'], array_filter($this->options['og_role']), $account); } } function get_access_callback() { if ($group = og_context($this->options['group_type'])) { return array('og_user_check_roles', array($group['group_type'], $group['gid'], array_filter($this->options['og_role']))); } return TRUE; } function summary_title() { $count = count($this->options['og_role']); if ($count < 1) { return t('No role(s) selected'); } elseif ($count > 1) { return t('Multiple roles'); } else { $rids = og_get_all_roles(); $rid = reset($this->options['og_role']); return check_plain($rids[$rid]); } } function option_definition() { $options = parent::option_definition(); $options['og_role'] = array('default' => array()); $options['group_type'] = array('default' => 'node'); return $options; } function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['og_role'] = array( '#type' => 'checkboxes', '#title' => t('Role'), '#default_value' => $this->options['og_role'], '#options' => array_map('check_plain', og_get_all_roles()), '#description' => t('Only the checked roles will be able to access this display. Note that users with "access all views" can see any view, regardless of role.'), ); $form['group_type'] = array( '#type' => 'select', '#options' => og_get_all_group_entity(), '#title' => t('Group type'), '#default_value' => $this->options['group_type'], '#description' => t('Determine what entity type that group should be of.') ); } function options_validate(&$form, &$form_state) { if (!array_filter($form_state['values']['access_options']['og_role'])) { form_error($form['og_role'], t('You must select at least one role if type is "by role"')); } } function options_submit(&$form, &$form_state) { $form_state['values']['access_options']['og_role'] = array_filter($form_state['values']['access_options']['og_role']); } }