/**
  * Implements EntityReferenceHandler::getReferencableEntities().
  */
 public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0)
 {
     $settings = $this->field['settings']['handler_settings'];
     $include_space = $settings['include_space'];
     $all_groups = oa_core_get_all_groups();
     $groups = array_map(create_function('$group', 'return $group->title;'), $all_groups);
     $group_options = array();
     $count = 0;
     foreach ($groups as $nid => $group_name) {
         $count++;
         if (!$match || stripos($group_name, $match) !== FALSE) {
             $group_options[$nid] = $group_name;
         }
         if ($limit && $count == $limit) {
             break;
         }
     }
     if ($space_id = oa_core_get_space_context()) {
         // Bring current group to front.
         if (!empty($group_options[$space_id])) {
             $group_options = array($space_id => t('!name (current)', array('!name' => $group_options[$space_id]))) + $group_options;
         } elseif ($include_space) {
             $group_options = array($space_id => t('- All space members -')) + $group_options;
         }
     }
     return array(OA_GROUP_TYPE => $group_options);
 }
 /**
  * Implements EntityReferenceHandler::getReferencableEntities().
  */
 public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0)
 {
     $settings = $this->field['settings']['handler_settings'];
     $include_space = $settings['include_space'];
     $all_groups = oa_core_get_all_groups($match, $match_operator, $limit);
     $groups = array_map(create_function('$group', 'return $group->title;'), $all_groups);
     $group_options = array();
     foreach ($groups as $nid => $group_name) {
         $group_options[$nid] = $group_name;
     }
     if ($space_id = oa_core_get_space_context()) {
         // Bring current group to front.
         if (!empty($group_options[$space_id])) {
             $group_options = array($space_id => t('!name (current)', array('!name' => $group_options[$space_id]))) + $group_options;
         } elseif ($include_space) {
             // NOTE: This title text is ignored and overwritten by select2widget
             // in select2widget_render_modes().  All that matters is the $space_id.
             // Current space should be cached.
             $space = node_load($space_id);
             if (empty($match) || stripos($space->title, $match) !== FALSE) {
                 $group_options = array($space_id => t('- All space members -')) + $group_options;
             }
         }
     }
     return array(OA_GROUP_TYPE => $group_options);
 }
 /**
  * Implements EntityReferenceHandler::getReferencableEntities().
  */
 public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0)
 {
     $gid = oa_core_get_space_context();
     $space = node_load($gid);
     $type = variable_get_value('oa_worktracker_assigned_to_users');
     if ($type === OA_WORKTRACKER_ASSIGN_TO_INHERITED_USERS && !module_exists('oa_subspaces')) {
         $type = OA_WORKTRACKER_ASSIGN_TO_ONLY_LOCAL_USERS;
     }
     $uids = array();
     switch ($type) {
         case OA_WORKTRACKER_ASSIGN_TO_INHERITED_USERS:
             $uids = og_subgroups_get_users_group('node', $space);
             $uids = $uids['user'];
             $inherited = _og_subgroups_get_inherited_users('node', $gid);
             foreach ($inherited as $inherited_uid => $data) {
                 $uids[] = $inherited_uid;
             }
             break;
         case OA_WORKTRACKER_ASSIGN_TO_ONLY_LOCAL_USERS:
             $query = new EntityFieldQuery();
             $query->entityCondition('entity_type', 'og_membership')->propertyCondition('group_type', 'node', '=')->propertyCondition('gid', $gid, '=')->propertyCondition('entity_type', 'user', '=')->propertyCondition('state', OG_STATE_ACTIVE, '=');
             $result = $query->execute();
             if (!empty($result['og_membership'])) {
                 $og_memberships = og_membership_load_multiple(array_keys($result['og_membership']));
                 foreach ($og_memberships as $og_membership) {
                     $uids[] = $og_membership->etid;
                 }
             }
             break;
         case OA_WORKTRACKER_ASSIGN_TO_ANY_USERS:
             $query = db_select('users', 'u')->fields('u', array('uid'))->condition('status', 1);
             $uids = $query->execute()->fetchCol();
             break;
     }
     $options = array('user' => array());
     if (!empty($uids)) {
         // Get the user label and make sure that the user can access the space.
         $users = user_load_multiple($uids);
         foreach ($users as $uid => $account) {
             if (node_access('view', $space, $account)) {
                 $options['user'][$uid] = check_plain($this->getLabel($account));
             }
         }
         asort($options['user']);
     }
     return $options;
 }
/**
 * Implements template_preprocess_page().
 */
function oa_radix_preprocess_page(&$vars)
{
    // Rework search_form to our liking.
    $vars['search_form'] = '';
    if (module_exists('search') && user_access('search content')) {
        $search_box_form = drupal_get_form('search_form');
        $search_box_form['basic']['keys']['#title'] = '';
        $search_box_form['basic']['keys']['#attributes'] = array('placeholder' => 'Search');
        $search_box_form['basic']['keys']['#attributes']['class'][] = 'search-query';
        $search_box_form['basic']['submit']['#value'] = t('Search');
        $search_box_form['#attributes']['class'][] = 'navbar-form';
        $search_box_form['#attributes']['class'][] = 'pull-right';
        $search_box = drupal_render($search_box_form);
        $vars['search_form'] = user_access('search content') ? $search_box : NULL;
    }
    // Add user_badge to header.
    $vars['user_badge'] = '';
    if (module_exists('oa_dashboard')) {
        $user_badge = module_invoke('oa_dashboard', 'block_view', 'oa_user_badge');
        $vars['user_badge'] = $user_badge['content'];
    }
    $toolbar = panels_mini_block_view('oa_toolbar_panel');
    $vars['oa_toolbar_panel'] = isset($toolbar) ? $toolbar['content'] : '';
    $footer = panels_mini_block_view('oa_footer_panel');
    $vars['oa_footer_panel'] = isset($footer) ? $footer['content'] : '';
    ctools_include('content');
    $banner = ctools_content_render('oa_space_banner', '', array('banner_position' => 2));
    if (!empty($banner->content)) {
        $vars['oa_banner'] = $banner->content;
    }
    $vars['oa_space_menu'] = '';
    $space_id = oa_core_get_space_context();
    if (variable_get('oa_space_menu_' . $space_id, TRUE)) {
        $space_menu = ctools_content_render('oa_space_menu', '', array(), array());
        if (!empty($space_menu->content)) {
            $vars['oa_space_menu'] = $space_menu->content;
        }
    }
}