Index: contrib/apachesolr_og/apachesolr_og.install =================================================================== RCS file: contrib/apachesolr_og/apachesolr_og.install diff -N contrib/apachesolr_og/apachesolr_og.install --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ contrib/apachesolr_og/apachesolr_og.install 29 Apr 2009 08:55:43 -0000 @@ -0,0 +1,33 @@ + TRUE, 'query' => 'Called function apachesolr_clear_last_index(). All content will be re-indexed'); + $facet_missing = variable_get('apachesolr_facet_missing', array()); + $facet_missing['apachesolr_og'][_apachesolr_og_gid_key()] = 1; + variable_set('apachesolr_facet_missing', $facet_missing); + return $ret; +} + Index: contrib/apachesolr_og/apachesolr_og.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/contrib/apachesolr_og/apachesolr_og.module,v retrieving revision 1.1.2.1 diff -u -p -r1.1.2.1 apachesolr_og.module --- contrib/apachesolr_og/apachesolr_og.module 25 Mar 2009 01:56:01 -0000 1.1.2.1 +++ contrib/apachesolr_og/apachesolr_og.module 29 Apr 2009 08:55:43 -0000 @@ -7,17 +7,52 @@ */ /** + * Implementation of hook_perm(). + */ +function apachesolr_og_perm() { + return array('administer apachesolr og'); +} + +/** + * Implementation of hook_menu(). + */ +function apachesolr_og_menu() { + return array( + 'admin/settings/apachesolr/og' => array( + 'title' => 'Organic Group', + 'description' => 'Configure Apachesolr OG.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('apachesolr_og_admin'), + 'access arguments' => array('administer apachesolr og'), + ), + ); +} + +function apachesolr_og_admin() { + $form = array(); + $form['apachesolr_og_groupnode'] = array( + '#type' => 'checkbox', + '#title' => t('Group nodes indexed'), + '#description' => t('Index group nodes as belonging to their own group'), + '#default_value' => variable_get('apachesolr_og_groupnode', 0), + ); + return system_settings_form($form); +} + +/** * Implementation of hook_apachesolr_update_index(). */ function apachesolr_og_apachesolr_update_index(&$document, $node) { - + // Index group posts if (!empty($node->og_groups)) { foreach ($node->og_groups as $gid) { $document->setMultiValue(_apachesolr_og_gid_key(), $gid); } - } - else { - $document->setMultiValue(_apachesolr_og_gid_key(), 0); + } elseif (!empty(variable_get('apachesolr_og_groupnode', 0))) { + // Index group nodes + if (!empty($node->og_description)) { + $document->setMultiValue(_apachesolr_og_gid_key(), $node->nid); + } } } @@ -25,6 +60,8 @@ function apachesolr_og_apachesolr_update * Implementation of hook_apachesolr_modify_query(). */ function apachesolr_og_apachesolr_modify_query(&$query, &$params, $caller) { + // Fetch the group ID in results - however, this is currently not used. + // May be useful for custom theming. if ($caller == 'apachesolr_search') { $params['fl'] .= ',' . _apachesolr_og_gid_key(); } @@ -98,7 +135,9 @@ function apachesolr_og_block($op = 'list // Add the blocks $blocks = array(); foreach ($enabled_facets as $delta => $facet_field) { - $blocks[$delta] = $facets[$delta] + array('cache' => BLOCK_CACHE_PER_PAGE,); + if (isset($facets[$delta])) { + $blocks[$delta] = $facets[$delta] + array('cache' => BLOCK_CACHE_PER_PAGE,); + } } return $blocks; @@ -129,13 +168,13 @@ function apachesolr_og_block($op = 'list /** * Callback function for the 'Filter by group' facet block. */ -function apachesolr_og_group_name($facet) { - if ($facet == 0) { - return t('No group'); +function apachesolr_og_group_name($facet, &$options) { + if (!is_numeric($facet)) { + $options['html'] = TRUE; + return theme('placeholder', t('No group')); } - $sql = 'SELECT title FROM {node} WHERE nid = %d'; - return db_result(db_query($sql, $facet)); + return db_result(db_query("SELECT title FROM {node} WHERE nid = %d", $facet)); } /** @@ -154,6 +193,10 @@ function apachesolr_og_theme() { * Theme the breadcrumb. */ function theme_apachesolr_breadcrumb_im_og_gid($group_id) { - return apachesolr_og_group_name($group_id); + if (!is_numeric($group_id)) { + return t('No group'); + } + + return db_result(db_query("SELECT title FROM {node} WHERE nid = %d", $group_id)); }