/**
  * 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);
 }
コード例 #2
0
 /**
  * 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);
 }