/**
  * Returns a list of groups that match a partial name. This returns an
  * array instead of an object since it is used by typeahead.
  *
  * @param Request $r
  */
 public static function apiList(Request $r)
 {
     self::authenticateRequest($r);
     if (is_null($r['query'])) {
         throw new InvalidParameterException('parameterEmpty', 'query');
     }
     if (strlen($r['query']) < 2) {
         throw new InvalidParameterException('parameterInvalid', 'query');
     }
     try {
         $groups = GroupsDAO::SearchByName($r['query']);
     } catch (Exception $ex) {
         throw new InvalidDatabaseOperationException($ex);
     }
     $response = array();
     foreach ($groups as $group) {
         array_push($response, array('label' => $group->name, 'value' => $group->alias));
     }
     return $response;
 }