franck@0: 'checkbox', franck@0: '#title' => t('Sort by number of group nodes'), franck@0: '#default_value' => faceted_search_variable_get($env_id, 'og_statistics_sort', FALSE), franck@0: '#description' => t('If only searching group content types enables sorting by the most recent node added to the group, rather than comment added to the group node itself.'), franck@0: '#weight' => -1, franck@0: ); franck@0: } franck@0: } franck@0: franck@0: /** franck@0: * Implementation of hook_faceted_search_query_alter(). franck@0: * franck@0: * This is quite late in the sequence, but were altering a facet franck@0: * (the content-type one) rather than making a new one we could hook franck@0: * in the sort(s) to. franck@0: * @todo I guess there is a much better way of doing this! Like franck@0: * maybe inheriting content-type facet and extending it and making it franck@0: * sort an option? franck@0: */ franck@0: function og_statistics_faceted_search_query_alter($search, &$query) { franck@0: if (faceted_search_variable_get($search->_env_id, 'og_statistics_sort', FALSE)) { // change for a variable franck@0: $query->tables['default']['c']['table'] = 'og_statistics'; franck@0: $query->fields['default']['score']['field'] = '%d * POW(2, (GREATEST(MAX(n.created), MAX(n.changed), MAX(c.last_node_timestamp)) - %d) * 6.43e-8)'; franck@0: } franck@0: } franck@0: