| @@ -9,45 +9,45 @@ discard block | ||
| 9 | 9 | * Implements hook_block() for Drupal 6 compatibility | 
| 10 | 10 | */ | 
| 11 | 11 |  function node_comment_block_block($op = 'list', $delta = 0, $edit = array()) { | 
| 12 | -  switch ($op) { | |
| 13 | - case 'view': | |
| 12 | +    switch ($op) { | |
| 13 | + case 'view': | |
| 14 | 14 | //$block = node_comment_block_block_view($delta); | 
| 15 | 15 | $block = array(); | 
| 16 | 16 |      if ($delta == 'node_comments') { | 
| 17 | -      if (arg(0) == 'node' && is_numeric($nid = arg(1)) && !arg(2)) { | |
| 17 | +        if (arg(0) == 'node' && is_numeric($nid = arg(1)) && !arg(2)) { | |
| 18 | 18 | $node = node_load($nid); | 
| 19 | 19 |          if ($node->comment !== 0) { | 
| 20 | - $block['subject'] = NULL; // This should be NULL otherwise there will be duplicate h2 elements. | |
| 21 | - $block['content'] = ''; | |
| 22 | -          if ($node->comment) { | |
| 20 | + $block['subject'] = NULL; // This should be NULL otherwise there will be duplicate h2 elements. | |
| 21 | + $block['content'] = ''; | |
| 22 | +            if ($node->comment) { | |
| 23 | 23 | $block['content'] .= comment_render($node); | 
| 24 | - } | |
| 24 | + } | |
| 25 | + } | |
| 25 | 26 | } | 
| 26 | - } | |
| 27 | 27 | } | 
| 28 | 28 | break; | 
| 29 | - case 'list': | |
| 29 | + case 'list': | |
| 30 | 30 | $blocks = node_comment_block_block_info(); | 
| 31 | 31 | return $blocks; | 
| 32 | 32 | break; | 
| 33 | - default: | |
| 33 | + default: | |
| 34 | 34 | } | 
| 35 | - return $block; | |
| 35 | + return $block; | |
| 36 | 36 | } | 
| 37 | 37 | |
| 38 | 38 | /** | 
| 39 | 39 | * Port Drupal 7 render() function to Drupal 6 | 
| 40 | 40 | */ | 
| 41 | 41 |  function render(&$element) { | 
| 42 | -  if (is_array($element)) { | |
| 42 | +    if (is_array($element)) { | |
| 43 | 43 | show($element); | 
| 44 | 44 | return drupal_render($element); | 
| 45 | - } | |
| 46 | -  else { | |
| 45 | + } | |
| 46 | +    else { | |
| 47 | 47 | // Safe-guard for inappropriate use of render() on flat variables: return | 
| 48 | 48 | // the variable as-is. | 
| 49 | 49 | return $element; | 
| 50 | - } | |
| 50 | + } | |
| 51 | 51 | } | 
| 52 | 52 | |
| 53 | 53 | |
| @@ -56,50 +56,50 @@ discard block | ||
| 56 | 56 | * Implements hook_block_info(). | 
| 57 | 57 | */ | 
| 58 | 58 |  function node_comment_block_block_info() { | 
| 59 | - $blocks['node_comments'] = array( | |
| 59 | + $blocks['node_comments'] = array( | |
| 60 | 60 |      'info' => t('Node comments'), | 
| 61 | - ); | |
| 61 | + ); | |
| 62 | 62 | |
| 63 | - return $blocks; | |
| 63 | + return $blocks; | |
| 64 | 64 | } | 
| 65 | 65 | |
| 66 | 66 | /** | 
| 67 | 67 | * Implements hook_block_view(). | 
| 68 | 68 | */ | 
| 69 | 69 |  function node_comment_block_block_view($delta = '') { | 
| 70 | - $block = array(); | |
| 70 | + $block = array(); | |
| 71 | 71 | |
| 72 | -  if ($delta == 'node_comments') { | |
| 72 | +    if ($delta == 'node_comments') { | |
| 73 | 73 |      if (arg(0) == 'node' && is_numeric($nid = arg(1)) && !arg(2)) { | 
| 74 | - $node = node_load($nid); | |
| 74 | + $node = node_load($nid); | |
| 75 | 75 | |
| 76 | -      if ($node->comment !== 0) { | |
| 76 | +        if ($node->comment !== 0) { | |
| 77 | 77 | $block['subject'] = NULL; // This should be NULL otherwise there will be duplicate h2 elements. | 
| 78 | 78 | $block['content'] = ''; | 
| 79 | 79 | |
| 80 | 80 | $node = node_view($node); | 
| 81 | 81 | |
| 82 | 82 |          if ($node['comments']) { | 
| 83 | - $block['content'] .= render($node['comments']); | |
| 83 | + $block['content'] .= render($node['comments']); | |
| 84 | + } | |
| 84 | 85 | } | 
| 85 | - } | |
| 86 | 86 | } | 
| 87 | - } | |
| 87 | + } | |
| 88 | 88 | |
| 89 | - return $block; | |
| 89 | + return $block; | |
| 90 | 90 | } | 
| 91 | 91 | |
| 92 | 92 | /** | 
| 93 | 93 | * Implements hook_preprocess_HOOK() for nodes. | 
| 94 | 94 | */ | 
| 95 | 95 |  function node_comment_block_preprocess_node(&$variables) { | 
| 96 | - $node = $variables['node']; | |
| 97 | - // Only hide standard comments for news content | |
| 98 | -  if ($variables['type'] == 'news') { | |
| 96 | + $node = $variables['node']; | |
| 97 | + // Only hide standard comments for news content | |
| 98 | +    if ($variables['type'] == 'news') { | |
| 99 | 99 | $variables['node']->comment = 0; | 
| 100 | - } | |
| 100 | + } | |
| 101 | 101 | |
| 102 | - /* Drupal 7... | |
| 102 | + /* Drupal 7... | |
| 103 | 103 |    if ($node->comment !== 0 && $variables['view_mode'] == 'full') { | 
| 104 | 104 |      if (isset($variables['content']['comments'])) { | 
| 105 | 105 | unset($variables['content']['comments']); | 
| @@ -113,10 +113,10 @@ discard block | ||
| 113 | 113 | * Implements hook_form_FORM_ID_alter() for block_admin_configure. | 
| 114 | 114 | */ | 
| 115 | 115 |  function node_comment_block_form_block_admin_configure_alter(&$form, &$form_state) { | 
| 116 | -  if (isset($form['delta'])) { | |
| 116 | +    if (isset($form['delta'])) { | |
| 117 | 117 |      if ($form['delta']['#value'] == 'node_comments') { | 
| 118 | - $form['settings']['title']['#disabled'] = TRUE; | |
| 119 | -      $form['settings']['title']['#description'] = t('The title for this block cannot be overridden.'); | |
| 118 | + $form['settings']['title']['#disabled'] = TRUE; | |
| 119 | +        $form['settings']['title']['#description'] = t('The title for this block cannot be overridden.'); | |
| 120 | + } | |
| 120 | 121 | } | 
| 121 | - } | |
| 122 | 122 | } | 
| @@ -280,12 +280,12 @@ discard block | ||
| 280 | 280 | } | 
| 281 | 281 | |
| 282 | 282 |    switch ($op) { | 
| 283 | - case 'delete': | |
| 284 | - // Only call delete function on certain node types | |
| 285 | -      if (in_array( $node->type, $node_types)) { | |
| 286 | - boinc_solr_comments_delete($node); | |
| 287 | - } | |
| 288 | - break; | |
| 283 | + case 'delete': | |
| 284 | + // Only call delete function on certain node types | |
| 285 | +    if (in_array( $node->type, $node_types)) { | |
| 286 | + boinc_solr_comments_delete($node); | |
| 287 | + } | |
| 288 | + break; | |
| 289 | 289 | } //switch | 
| 290 | 290 | } | 
| 291 | 291 | |
| @@ -335,13 +335,13 @@ discard block | ||
| 335 | 335 | */ | 
| 336 | 336 |  function boinc_solr_comments_comment(&$a1, $op) { | 
| 337 | 337 |    switch ($op) { | 
| 338 | - case 'view': | |
| 339 | - case 'update': | |
| 340 | - break; | |
| 341 | - case 'delete': | |
| 342 | - // $a1 should be a comment object | |
| 343 | - boinc_solr_comments_deletecomment($a1); | |
| 344 | - break; | |
| 338 | + case 'view': | |
| 339 | + case 'update': | |
| 340 | + break; | |
| 341 | + case 'delete': | |
| 342 | + // $a1 should be a comment object | |
| 343 | + boinc_solr_comments_deletecomment($a1); | |
| 344 | + break; | |
| 345 | 345 | }// switch | 
| 346 | 346 | } | 
| 347 | 347 | |
| @@ -14,19 +14,19 @@ discard block | ||
| 14 | 14 | * Implementation of hook_menu() | 
| 15 | 15 | */ | 
| 16 | 16 |  function boinc_solr_comments_menu() { | 
| 17 | - $items = array(); | |
| 18 | - $base_path = 'admin/settings/apachesolr/indexcomments'; | |
| 19 | - $items[$base_path] = array( | |
| 20 | - 'title' => 'Index Comments', | |
| 21 | - 'description' => 'Administer Indexing of Comments', | |
| 22 | - 'page callback' => 'drupal_get_form', | |
| 23 | -      'page arguments' => array('boinc_solr_comments_form'), | |
| 24 | -      'access arguments' => array('administer search'), | |
| 25 | - 'file' => 'boinc_solr_comments.admin.inc', | |
| 26 | - 'weight' => '10', | |
| 27 | - ); | |
| 28 | - | |
| 29 | - return $items; | |
| 17 | + $items = array(); | |
| 18 | + $base_path = 'admin/settings/apachesolr/indexcomments'; | |
| 19 | + $items[$base_path] = array( | |
| 20 | + 'title' => 'Index Comments', | |
| 21 | + 'description' => 'Administer Indexing of Comments', | |
| 22 | + 'page callback' => 'drupal_get_form', | |
| 23 | +        'page arguments' => array('boinc_solr_comments_form'), | |
| 24 | +        'access arguments' => array('administer search'), | |
| 25 | + 'file' => 'boinc_solr_comments.admin.inc', | |
| 26 | + 'weight' => '10', | |
| 27 | + ); | |
| 28 | + | |
| 29 | + return $items; | |
| 30 | 30 | } | 
| 31 | 31 | |
| 32 | 32 | |
| @@ -58,11 +58,11 @@ discard block | ||
| 58 | 58 | * Environment ID for apache solr. | 
| 59 | 59 | */ | 
| 60 | 60 |  function boinc_solr_comments_apachesolr_index_documents_alter(array &$documents, $entity, $entity_type, $env_id) { | 
| 61 | - $comdocs = array(); | |
| 61 | + $comdocs = array(); | |
| 62 | 62 | |
| 63 | - // Array of node types that will have comments indexed. | |
| 64 | -  $node_types = variable_get('boinc_solr_comments_nodetypes', ''); | |
| 65 | -  if (empty($node_types)) { | |
| 63 | + // Array of node types that will have comments indexed. | |
| 64 | +    $node_types = variable_get('boinc_solr_comments_nodetypes', ''); | |
| 65 | +    if (empty($node_types)) { | |
| 66 | 66 | // If the variable has not been set, then by default index | 
| 67 | 67 | // comments for all known node types. | 
| 68 | 68 | $node_types = array( | 
| @@ -72,28 +72,28 @@ discard block | ||
| 72 | 72 | 'story' => 'story', | 
| 73 | 73 | 'team_forum' => 'team_forum', | 
| 74 | 74 | ); | 
| 75 | - } | |
| 75 | + } | |
| 76 | 76 | |
| 77 | - // Loop over all documents and alter: | |
| 78 | -  foreach ($documents as $document) { | |
| 77 | + // Loop over all documents and alter: | |
| 78 | +    foreach ($documents as $document) { | |
| 79 | 79 | //dd($document, "index documents alter - document"); | 
| 80 | 80 | |
| 81 | 81 | $to_process = ( array_key_exists($document->bundle, $node_types) AND $node_types[$document->bundle] ); | 
| 82 | 82 |      if ( $document->entity_type=='node' AND $to_process) { | 
| 83 | 83 | |
| 84 | - // Remove ts_comments if present. | |
| 85 | -      if (isset($document->ts_comments)) { | |
| 84 | + // Remove ts_comments if present. | |
| 85 | +        if (isset($document->ts_comments)) { | |
| 86 | 86 | unset($document->ts_comments); | 
| 87 | - } | |
| 88 | - // Node information. | |
| 89 | - $nid = $document->entity_id; | |
| 90 | - $node = node_load($nid); | |
| 87 | + } | |
| 88 | + // Node information. | |
| 89 | + $nid = $document->entity_id; | |
| 90 | + $node = node_load($nid); | |
| 91 | 91 | |
| 92 | - // Query database for comments of node. Only return comments | |
| 93 | - // with status 0 (0 is published for comments). | |
| 94 | -      $sql = 'SELECT cid from {comments} WHERE nid = %d AND status = 0 ORDER by timestamp DESC'; | |
| 95 | - $resource = db_query($sql, $nid); | |
| 96 | -      while ($row = db_fetch_array($resource)) { | |
| 92 | + // Query database for comments of node. Only return comments | |
| 93 | + // with status 0 (0 is published for comments). | |
| 94 | +        $sql = 'SELECT cid from {comments} WHERE nid = %d AND status = 0 ORDER by timestamp DESC'; | |
| 95 | + $resource = db_query($sql, $nid); | |
| 96 | +        while ($row = db_fetch_array($resource)) { | |
| 97 | 97 | // Load the comment from cid. | 
| 98 | 98 | $comment = _comment_load($row['cid']); | 
| 99 | 99 | |
| @@ -116,10 +116,10 @@ discard block | ||
| 116 | 116 | // Comment object has no language | 
| 117 | 117 | $comment_document->ss_language = 'und'; | 
| 118 | 118 |          if (function_exists('drupal_get_path_alias')) { | 
| 119 | - $output = drupal_get_path_alias($comment_document->path, NULL); | |
| 120 | -          if ($output && $output != $document->path) { | |
| 119 | + $output = drupal_get_path_alias($comment_document->path, NULL); | |
| 120 | +            if ($output && $output != $document->path) { | |
| 121 | 121 | $comment_document->path_alias = $output; | 
| 122 | - } | |
| 122 | + } | |
| 123 | 123 | } | 
| 124 | 124 | |
| 125 | 125 | // Code derived from apachesolr_index_node_solr_document | 
| @@ -129,13 +129,13 @@ discard block | ||
| 129 | 129 | |
| 130 | 130 | // Author information | 
| 131 | 131 |          if ($comment->uid == 0 || strlen($comment->name) == 0) { | 
| 132 | - // @see user_validate_name(). !'0' === TRUE. | |
| 133 | - $comment_document->ss_name = '0'; | |
| 132 | + // @see user_validate_name(). !'0' === TRUE. | |
| 133 | + $comment_document->ss_name = '0'; | |
| 134 | 134 | } | 
| 135 | 135 |          else { | 
| 136 | - $comment_document->ss_name = $comment->name; | |
| 137 | - // We want the name to be searchable for keywords. | |
| 138 | - $comment_document->tos_name = $comment->name; | |
| 136 | + $comment_document->ss_name = $comment->name; | |
| 137 | + // We want the name to be searchable for keywords. | |
| 138 | + $comment_document->tos_name = $comment->name; | |
| 139 | 139 | } | 
| 140 | 140 | |
| 141 | 141 | // Index formatted username so it can be searched and sorted | 
| @@ -157,59 +157,59 @@ discard block | ||
| 157 | 157 | // Unset the following fields (if set) that don't make sense | 
| 158 | 158 | // for a comment. | 
| 159 | 159 |          if (isset($comment_document->bs_sticky)) { | 
| 160 | - unset($comment_document->bs_sticky); | |
| 160 | + unset($comment_document->bs_sticky); | |
| 161 | 161 | } | 
| 162 | 162 |          if (isset($comment_document->bs_promote)) { | 
| 163 | - unset($comment_document->bs_promote); | |
| 163 | + unset($comment_document->bs_promote); | |
| 164 | 164 | } | 
| 165 | 165 |          if (isset($comment_document->is_tnid)) { | 
| 166 | - unset($comment_document->is_tnid); | |
| 166 | + unset($comment_document->is_tnid); | |
| 167 | 167 | } | 
| 168 | 168 |          if (isset($comment_document->bs_translate)) { | 
| 169 | - unset($comment_document->bs_translate); | |
| 169 | + unset($comment_document->bs_translate); | |
| 170 | 170 | } | 
| 171 | 171 |          if (isset($comment_document->ts_last_comment_timestamp)) { | 
| 172 | - unset($comment_document->ts_last_comment_timestamp); | |
| 172 | + unset($comment_document->ts_last_comment_timestamp); | |
| 173 | 173 | } | 
| 174 | 174 |          if (isset($comment_document->ds_last_comment_or_change)) { | 
| 175 | - unset($comment_document->ds_last_comment_or_change); | |
| 175 | + unset($comment_document->ds_last_comment_or_change); | |
| 176 | 176 | } | 
| 177 | 177 |          if (isset($comment_document->is_comment_count)) { | 
| 178 | - unset($comment_document->is_comment_count); | |
| 178 | + unset($comment_document->is_comment_count); | |
| 179 | 179 | } | 
| 180 | 180 | |
| 181 | 181 | // Loop over fields in document and copy relevant values into | 
| 182 | 182 | // comment_document. | 
| 183 | 183 |          foreach ($document as $fieldName => $fieldValue) { | 
| 184 | 184 | |
| 185 | - // Copy over fields [im_taxonomy_vid_1], [tid], [im_vid_1], | |
| 186 | - // [im_vid_Forums], [tm_vid_1_names] | |
| 187 | -          if ( ( preg_match('/tid/', $fieldName) OR preg_match('/vid/', $fieldName) ) AND is_array($fieldValue) ) { | |
| 185 | + // Copy over fields [im_taxonomy_vid_1], [tid], [im_vid_1], | |
| 186 | + // [im_vid_Forums], [tm_vid_1_names] | |
| 187 | +            if ( ( preg_match('/tid/', $fieldName) OR preg_match('/vid/', $fieldName) ) AND is_array($fieldValue) ) { | |
| 188 | 188 |              foreach ($fieldValue as $subkey => $subvalue) { | 
| 189 | - $comment_document->addField($fieldName, $subvalue); | |
| 189 | + $comment_document->addField($fieldName, $subvalue); | |
| 190 | 190 | } | 
| 191 | - }// if preg_match | |
| 191 | + }// if preg_match | |
| 192 | 192 | |
| 193 | - // Set the access keys so this module will work with | |
| 194 | - // apachesolr_access. | |
| 195 | -          if (module_exists('apachesolr_access')) { | |
| 193 | + // Set the access keys so this module will work with | |
| 194 | + // apachesolr_access. | |
| 195 | +            if (module_exists('apachesolr_access')) { | |
| 196 | 196 |              if (preg_match('/^access/', $fieldName) AND is_array($fieldValue)) { | 
| 197 | -              foreach ($fieldValue as $subkey => $subvalue) { | |
| 197 | +                foreach ($fieldValue as $subkey => $subvalue) { | |
| 198 | 198 | $comment_document->addField($fieldName, $subvalue); | 
| 199 | - } | |
| 199 | + } | |
| 200 | 200 | }// if preg_match | 
| 201 | - }// if module_exist | |
| 201 | + }// if module_exist | |
| 202 | 202 | |
| 203 | 203 | }// foreach document | 
| 204 | 204 | |
| 205 | 205 | $comdocs[] = $comment_document; | 
| 206 | - }// while | |
| 206 | + }// while | |
| 207 | 207 | }// if entity_type=node | 
| 208 | - }// documents | |
| 208 | + }// documents | |
| 209 | 209 | |
| 210 | - // Merge the comment documents with the input documents array. These | |
| 211 | - // documents will now be added to the Solr search index. | |
| 212 | - $documents = array_merge($documents, $comdocs); | |
| 210 | + // Merge the comment documents with the input documents array. These | |
| 211 | + // documents will now be added to the Solr search index. | |
| 212 | + $documents = array_merge($documents, $comdocs); | |
| 213 | 213 | } | 
| 214 | 214 | |
| 215 | 215 | /** | 
| @@ -225,19 +225,19 @@ discard block | ||
| 225 | 225 | * The Solr query used for the search. | 
| 226 | 226 | */ | 
| 227 | 227 |  function boinc_solr_comments_apachesolr_process_results(&$results, DrupalSolrQueryInterface $query) { | 
| 228 | - //dpm($query->getSolrParams(), "process_results query getSolrParams"); | |
| 229 | -  foreach($results as $id => $result) { | |
| 228 | + //dpm($query->getSolrParams(), "process_results query getSolrParams"); | |
| 229 | +    foreach($results as $id => $result) { | |
| 230 | 230 |      if ($result['entity_type']=='comment') { | 
| 231 | 231 | $results[$id]['type'] = 'Comment'; | 
| 232 | 232 | $results[$id]['date'] = $result['fields']['changed']; | 
| 233 | 233 |          if (isset($result['fields']['is_uid'])) { | 
| 234 | - $uid = $result['fields']['is_uid']; | |
| 235 | - $results[$id]['uid'] = $uid; | |
| 236 | -          $results[$id]['user'] = theme('username', user_load($uid)); | |
| 234 | + $uid = $result['fields']['is_uid']; | |
| 235 | + $results[$id]['uid'] = $uid; | |
| 236 | +            $results[$id]['user'] = theme('username', user_load($uid)); | |
| 237 | 237 | } | 
| 238 | 238 | } //if result entity_type == comment | 
| 239 | - }// foreach $result | |
| 240 | - //dpm($results, "process_results array_results"); | |
| 239 | + }// foreach $result | |
| 240 | + //dpm($results, "process_results array_results"); | |
| 241 | 241 | } | 
| 242 | 242 | |
| 243 | 243 | /** | 
| @@ -251,8 +251,8 @@ discard block | ||
| 251 | 251 | * The Solr query used for the search. | 
| 252 | 252 | */ | 
| 253 | 253 |  function boinc_solr_comments_apachesolr_query_alter($query) { | 
| 254 | - // Add custom field to query results | |
| 255 | -  $query->addParam('fl','tos_content_extra'); | |
| 254 | + // Add custom field to query results | |
| 255 | +    $query->addParam('fl','tos_content_extra'); | |
| 256 | 256 | } | 
| 257 | 257 | |
| 258 | 258 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * | 
| @@ -265,9 +265,9 @@ discard block | ||
| 265 | 265 | * | 
| 266 | 266 | */ | 
| 267 | 267 |  function boinc_solr_comments_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { | 
| 268 | - // Array of node types that will have comments indexed. | |
| 269 | -  $node_types = variable_get('boinc_solr_comments_nodetypes', ''); | |
| 270 | -  if (empty($node_types)) { | |
| 268 | + // Array of node types that will have comments indexed. | |
| 269 | +    $node_types = variable_get('boinc_solr_comments_nodetypes', ''); | |
| 270 | +    if (empty($node_types)) { | |
| 271 | 271 | // If the variable has not been set, then by default index | 
| 272 | 272 | // comments for all known node types. | 
| 273 | 273 | $node_types = array( | 
| @@ -277,16 +277,16 @@ discard block | ||
| 277 | 277 | 'story' => 'story', | 
| 278 | 278 | 'team_forum' => 'team_forum', | 
| 279 | 279 | ); | 
| 280 | - } | |
| 280 | + } | |
| 281 | 281 | |
| 282 | -  switch ($op) { | |
| 282 | +    switch ($op) { | |
| 283 | 283 | case 'delete': | 
| 284 | 284 | // Only call delete function on certain node types | 
| 285 | 285 |        if (in_array( $node->type, $node_types)) { | 
| 286 | 286 | boinc_solr_comments_delete($node); | 
| 287 | - } | |
| 288 | - break; | |
| 289 | - } //switch | |
| 287 | + } | |
| 288 | + break; | |
| 289 | + } //switch | |
| 290 | 290 | } | 
| 291 | 291 | |
| 292 | 292 | |
| @@ -303,30 +303,30 @@ discard block | ||
| 303 | 303 | * Returns TRUE if the comment was deleted, otherwise return FALSE. | 
| 304 | 304 | */ | 
| 305 | 305 |  function boinc_solr_comments_delete($node) { | 
| 306 | - // Load the Solr environment. | |
| 307 | - $env_id = apachesolr_default_environment(); | |
| 308 | - // Check to see if Solr is read-only. | |
| 309 | -  if (apachesolr_environment_variable_get($env_id, 'apachesolr_read_only', APACHESOLR_READ_WRITE) == APACHESOLR_READ_ONLY) { | |
| 306 | + // Load the Solr environment. | |
| 307 | + $env_id = apachesolr_default_environment(); | |
| 308 | + // Check to see if Solr is read-only. | |
| 309 | +    if (apachesolr_environment_variable_get($env_id, 'apachesolr_read_only', APACHESOLR_READ_WRITE) == APACHESOLR_READ_ONLY) { | |
| 310 | 310 | return FALSE; | 
| 311 | - } | |
| 311 | + } | |
| 312 | 312 | |
| 313 | - // Code derived from apachesolr_index_delete_entity_from_index | |
| 314 | -  try { | |
| 313 | + // Code derived from apachesolr_index_delete_entity_from_index | |
| 314 | +    try { | |
| 315 | 315 | $solr = apachesolr_get_solr($env_id); | 
| 316 | 316 | // Custom query to find all comments with parent nid of the node bing deleted. | 
| 317 | 317 | $query = "entity_type:comment AND tos_content_extra:" . $node->nid; | 
| 318 | 318 | $solr->deleteByQuery($query); | 
| 319 | 319 | // Log the query used for deletion. | 
| 320 | 320 |      watchdog('Apache Solr', 'Deleted documents from index with query @query', array('@query' => $query), WATCHDOG_INFO); | 
| 321 | - } | |
| 322 | -  catch (Exception $e) { | |
| 323 | -      watchdog('Apache Solr', nl2br(check_plain($e->getMessage())), NULL, WATCHDOG_ERROR); | |
| 324 | - return FALSE; | |
| 325 | - }// try | |
| 326 | - | |
| 327 | - // all deletions sucessful | |
| 328 | - apachesolr_set_last_index_updated($env_id, APACHESOLR_REQUEST_TIME); | |
| 329 | - return TRUE; | |
| 321 | + } | |
| 322 | +    catch (Exception $e) { | |
| 323 | +        watchdog('Apache Solr', nl2br(check_plain($e->getMessage())), NULL, WATCHDOG_ERROR); | |
| 324 | + return FALSE; | |
| 325 | + }// try | |
| 326 | + | |
| 327 | + // all deletions sucessful | |
| 328 | + apachesolr_set_last_index_updated($env_id, APACHESOLR_REQUEST_TIME); | |
| 329 | + return TRUE; | |
| 330 | 330 | } | 
| 331 | 331 | |
| 332 | 332 | /** | 
| @@ -334,15 +334,15 @@ discard block | ||
| 334 | 334 | * | 
| 335 | 335 | */ | 
| 336 | 336 |  function boinc_solr_comments_comment(&$a1, $op) { | 
| 337 | -  switch ($op) { | |
| 337 | +    switch ($op) { | |
| 338 | 338 | case 'view': | 
| 339 | 339 | case 'update': | 
| 340 | 340 | break; | 
| 341 | 341 | case 'delete': | 
| 342 | 342 | // $a1 should be a comment object | 
| 343 | 343 | boinc_solr_comments_deletecomment($a1); | 
| 344 | - break; | |
| 345 | - }// switch | |
| 344 | + break; | |
| 345 | + }// switch | |
| 346 | 346 | } | 
| 347 | 347 | |
| 348 | 348 | /** | 
| @@ -358,16 +358,16 @@ discard block | ||
| 358 | 358 | * Returns TRUE if the comment was deleted, otherwise return FALSE. | 
| 359 | 359 | */ | 
| 360 | 360 |  function boinc_solr_comments_deletecomment($comment) { | 
| 361 | - // Load the Solr environment. | |
| 362 | - $env_id = apachesolr_default_environment(); | |
| 363 | - // Check to see if Solr is read-only. | |
| 364 | -  if (apachesolr_environment_variable_get($env_id, 'apachesolr_read_only', APACHESOLR_READ_WRITE) == APACHESOLR_READ_ONLY) { | |
| 361 | + // Load the Solr environment. | |
| 362 | + $env_id = apachesolr_default_environment(); | |
| 363 | + // Check to see if Solr is read-only. | |
| 364 | +    if (apachesolr_environment_variable_get($env_id, 'apachesolr_read_only', APACHESOLR_READ_WRITE) == APACHESOLR_READ_ONLY) { | |
| 365 | 365 | return FALSE; | 
| 366 | - } | |
| 367 | - //dd($comment->cid, "delete - nid begin"); | |
| 366 | + } | |
| 367 | + //dd($comment->cid, "delete - nid begin"); | |
| 368 | 368 | |
| 369 | - // Code derived from apachesolr_index_delete_entity_from_index. | |
| 370 | -  try { | |
| 369 | + // Code derived from apachesolr_index_delete_entity_from_index. | |
| 370 | +    try { | |
| 371 | 371 | $solr = apachesolr_get_solr($env_id); | 
| 372 | 372 | $entity_id = $comment->cid; | 
| 373 | 373 | $entity_type = 'comment'; | 
| @@ -377,14 +377,14 @@ discard block | ||
| 377 | 377 | // Log the query used for deletion. | 
| 378 | 378 |      watchdog('Apache Solr', 'Deleted documents from index with query @query', array('@query' => $query), WATCHDOG_INFO); | 
| 379 | 379 | } | 
| 380 | -  catch (Exception $e) { | |
| 380 | +    catch (Exception $e) { | |
| 381 | 381 |      watchdog('Apache Solr', nl2br(check_plain($e->getMessage())), NULL, WATCHDOG_ERROR); | 
| 382 | 382 | return FALSE; | 
| 383 | - }// try | |
| 383 | + }// try | |
| 384 | 384 | |
| 385 | - // deletion sucessful | |
| 386 | - apachesolr_set_last_index_updated($env_id, APACHESOLR_REQUEST_TIME); | |
| 387 | - return TRUE; | |
| 385 | + // deletion sucessful | |
| 386 | + apachesolr_set_last_index_updated($env_id, APACHESOLR_REQUEST_TIME); | |
| 387 | + return TRUE; | |
| 388 | 388 | } | 
| 389 | 389 | |
| 390 | 390 | |
| @@ -399,7 +399,7 @@ discard block | ||
| 399 | 399 | */ | 
| 400 | 400 | |
| 401 | 401 |  function boinc_solr_comments_enable() { | 
| 402 | -  drupal_set_message( bts('Warning: Your content <a href="@url">must be re-indexed</a> before Apache Solr will search comments.', array('@url' => url('admin/settings/apachesolr/index')), NULL, 'boinc:admin-solr-index-comments-message'), 'warning'); | |
| 402 | +    drupal_set_message( bts('Warning: Your content <a href="@url">must be re-indexed</a> before Apache Solr will search comments.', array('@url' => url('admin/settings/apachesolr/index')), NULL, 'boinc:admin-solr-index-comments-message'), 'warning'); | |
| 403 | 403 | } | 
| 404 | 404 | |
| 405 | 405 | /** | 
| @@ -410,12 +410,12 @@ discard block | ||
| 410 | 410 | * The comment to be published (unhidden). | 
| 411 | 411 | */ | 
| 412 | 412 |  function boinc_solr_comments_publish($comment) { | 
| 413 | -  if ( ($comment->cid) AND ($comment->nid) ) { | |
| 413 | +    if ( ($comment->cid) AND ($comment->nid) ) { | |
| 414 | 414 | $node = node_load($comment->nid); | 
| 415 | 415 | // Tell Solr that the node has been updated, so the comment can be | 
| 416 | 416 | // indexed. | 
| 417 | 417 | apachesolr_entity_update($node, 'node'); | 
| 418 | - } | |
| 418 | + } | |
| 419 | 419 | } | 
| 420 | 420 | |
| 421 | 421 | /** | 
| @@ -426,9 +426,9 @@ discard block | ||
| 426 | 426 | * The comment to be unpublished (hidden). | 
| 427 | 427 | */ | 
| 428 | 428 |  function boinc_solr_comments_unpublish($comment) { | 
| 429 | -  if ( ($comment->cid) ) { | |
| 429 | +    if ( ($comment->cid) ) { | |
| 430 | 430 | // Call the deletecomment function for hook comment. | 
| 431 | 431 | boinc_solr_comments_deletecomment($comment); | 
| 432 | - } | |
| 432 | + } | |
| 433 | 433 | } | 
| 434 | 434 | |
| @@ -19,10 +19,10 @@ | ||
| 19 | 19 |    foreach (content_types() as $key => $info) { | 
| 20 | 20 | // Exclude node types profile, team, and panel | 
| 21 | 21 |      switch ($key) { | 
| 22 | - case 'profile': | |
| 23 | - case 'team': | |
| 24 | - case 'panel': | |
| 25 | - continue 2; | |
| 22 | + case 'profile': | |
| 23 | + case 'team': | |
| 24 | + case 'panel': | |
| 25 | + continue 2; | |
| 26 | 26 | }// switch key | 
| 27 | 27 | $options[$key] = $info['name']; | 
| 28 | 28 | } | 
| @@ -7,48 +7,48 @@ | ||
| 7 | 7 | */ | 
| 8 | 8 | |
| 9 | 9 |  function boinc_solr_comments_form(&$form_state) { | 
| 10 | - $form = array(); | |
| 10 | + $form = array(); | |
| 11 | 11 | |
| 12 | - $form['config'] = array( | |
| 12 | + $form['config'] = array( | |
| 13 | 13 | '#type' => 'fieldset', | 
| 14 | 14 |      '#title' => t('Configuration'), | 
| 15 | 15 | '#collapsible' => TRUE, | 
| 16 | - ); | |
| 16 | + ); | |
| 17 | 17 | |
| 18 | - $options = array(); | |
| 19 | -  foreach (content_types() as $key => $info) { | |
| 18 | + $options = array(); | |
| 19 | +    foreach (content_types() as $key => $info) { | |
| 20 | 20 | // Exclude node types profile, team, and panel | 
| 21 | 21 |      switch ($key) { | 
| 22 | - case 'profile': | |
| 22 | + case 'profile': | |
| 23 | 23 | case 'team': | 
| 24 | 24 | case 'panel': | 
| 25 | 25 | continue 2; | 
| 26 | 26 | }// switch key | 
| 27 | 27 | $options[$key] = $info['name']; | 
| 28 | - } | |
| 29 | - asort($options); | |
| 28 | + } | |
| 29 | + asort($options); | |
| 30 | 30 | |
| 31 | - // Form defaults | |
| 32 | - $default = array( | |
| 31 | + // Form defaults | |
| 32 | + $default = array( | |
| 33 | 33 |      'boinc_solr_comments_nodetypes' => variable_get('boinc_solr_comments_nodetypes', ''), | 
| 34 | - ); | |
| 35 | -  if (empty($default['boinc_solr_comments_nodetypes'])) { | |
| 34 | + ); | |
| 35 | +    if (empty($default['boinc_solr_comments_nodetypes'])) { | |
| 36 | 36 |      $default['boinc_solr_comments_nodetypes'] = array('forum','team_forum','news','page','story'); | 
| 37 | - } | |
| 37 | + } | |
| 38 | 38 | |
| 39 | - // Define the form | |
| 40 | - $form['config']['nodes'] = array( | |
| 39 | + // Define the form | |
| 40 | + $form['config']['nodes'] = array( | |
| 41 | 41 | '#type' => 'markup', | 
| 42 | 42 |      '#value' => bts('Select the content types where the comments are indexed by Apace Solr. Your content must be re-indexed after changing this configuration.', array(), NULL, 'boinc:admin-solr-search-comments-option'), | 
| 43 | - ); | |
| 43 | + ); | |
| 44 | 44 | |
| 45 | - $form['config']['boinc_solr_comments_nodetypes'] = array( | |
| 45 | + $form['config']['boinc_solr_comments_nodetypes'] = array( | |
| 46 | 46 | '#type' => 'checkboxes', | 
| 47 | 47 | '#title' => 'node', | 
| 48 | 48 | '#options' => $options, | 
| 49 | 49 | '#default_value' => $default['boinc_solr_comments_nodetypes'], | 
| 50 | - ); | |
| 50 | + ); | |
| 51 | 51 | |
| 52 | - return system_settings_form($form); | |
| 52 | + return system_settings_form($form); | |
| 53 | 53 | } | 
| 54 | 54 | |
| @@ -7,15 +7,15 @@ | ||
| 7 | 7 | */ | 
| 8 | 8 | |
| 9 | 9 |  class views_handler_argument_boincteam_id extends views_handler_argument_numeric { | 
| 10 | -  function construct() { | |
| 10 | +    function construct() { | |
| 11 | 11 | parent::construct(); | 
| 12 | - } | |
| 12 | + } | |
| 13 | 13 | |
| 14 | -  function set_argument($arg) { | |
| 14 | +    function set_argument($arg) { | |
| 15 | 15 | // When setting the ID argument, convert to BOINC ID | 
| 16 | 16 | $id = is_numeric($arg) ? $arg : 0; | 
| 17 | 17 |      $boinc_id = db_result(db_query("SELECT team_id FROM {boincteam} WHERE nid = %d", $id)); | 
| 18 | 18 | $this->argument = $boinc_id; | 
| 19 | 19 | return $this->validate_arg($boinc_id); | 
| 20 | - } | |
| 20 | + } | |
| 21 | 21 | } | 
| @@ -13,80 +13,80 @@ | ||
| 13 | 13 | */ | 
| 14 | 14 |  function boincteam_forum_views_data() { | 
| 15 | 15 | |
| 16 | - // ----------------------------------------------------------------------------------------------- | |
| 17 | - // Definition for team table | |
| 18 | - // ----------------------------------------------------------------------------------------------- | |
| 16 | + // ----------------------------------------------------------------------------------------------- | |
| 17 | + // Definition for team table | |
| 18 | + // ----------------------------------------------------------------------------------------------- | |
| 19 | 19 | |
| 20 | -  $data['boincteam_forum_node']['table']['group'] = t('BOINC'); | |
| 20 | +    $data['boincteam_forum_node']['table']['group'] = t('BOINC'); | |
| 21 | 21 | |
| 22 | - $data['boincteam_forum_node']['table']['base'] = array( | |
| 23 | - 'field' => 'nid', | |
| 24 | -      'title' => t('BOINC team forum topic'), | |
| 25 | -      'help' => t('Forum topics for a team'), | |
| 26 | - ); | |
| 22 | + $data['boincteam_forum_node']['table']['base'] = array( | |
| 23 | + 'field' => 'nid', | |
| 24 | +        'title' => t('BOINC team forum topic'), | |
| 25 | +        'help' => t('Forum topics for a team'), | |
| 26 | + ); | |
| 27 | 27 | |
| 28 | - // Describe each of the individual fields in this table to Views. For | |
| 29 | - // each field, you may define what field, sort, argument, and/or filter | |
| 30 | - // handlers it supports. This will determine where in the Views interface you | |
| 31 | - // may use the field. | |
| 28 | + // Describe each of the individual fields in this table to Views. For | |
| 29 | + // each field, you may define what field, sort, argument, and/or filter | |
| 30 | + // handlers it supports. This will determine where in the Views interface you | |
| 31 | + // may use the field. | |
| 32 | 32 | |
| 33 | - // Primary keys allowed as arguments | |
| 33 | + // Primary keys allowed as arguments | |
| 34 | 34 | |
| 35 | - $data['boincteam_forum_node']['tfid'] = array( | |
| 35 | + $data['boincteam_forum_node']['tfid'] = array( | |
| 36 | 36 |      'title' => t('Team forum ID'), | 
| 37 | 37 |      'help' => t('The ID of the team forum containing this topic.'), | 
| 38 | 38 | 'field' => array( | 
| 39 | - 'handler' => 'views_handler_field_numeric', | |
| 40 | - 'click sortable' => TRUE | |
| 39 | + 'handler' => 'views_handler_field_numeric', | |
| 40 | + 'click sortable' => TRUE | |
| 41 | 41 | ), | 
| 42 | 42 | 'argument' => array( | 
| 43 | - 'handler' => 'views_handler_argument_numeric', | |
| 44 | - 'name field' => 'title', // the field to display in the summary. | |
| 45 | - 'numeric' => TRUE, | |
| 46 | - 'validate type' => 'id' | |
| 43 | + 'handler' => 'views_handler_argument_numeric', | |
| 44 | + 'name field' => 'title', // the field to display in the summary. | |
| 45 | + 'numeric' => TRUE, | |
| 46 | + 'validate type' => 'id' | |
| 47 | 47 | ), | 
| 48 | 48 | 'relationship' => array( | 
| 49 | - 'base' => 'boincteam_forum', | |
| 50 | - 'field' => 'tfid', | |
| 51 | - 'handler' => 'views_handler_relationship', | |
| 52 | -      'label' => t('Team Forum') | |
| 49 | + 'base' => 'boincteam_forum', | |
| 50 | + 'field' => 'tfid', | |
| 51 | + 'handler' => 'views_handler_relationship', | |
| 52 | +        'label' => t('Team Forum') | |
| 53 | 53 | ), | 
| 54 | 54 | 'filter' => array( | 
| 55 | - 'handler' => 'views_handler_filter_numeric' | |
| 55 | + 'handler' => 'views_handler_filter_numeric' | |
| 56 | 56 | ), | 
| 57 | 57 | 'sort' => array( | 
| 58 | - 'handler' => 'views_handler_sort_numeric' | |
| 58 | + 'handler' => 'views_handler_sort_numeric' | |
| 59 | 59 | ) | 
| 60 | - ); | |
| 60 | + ); | |
| 61 | 61 | |
| 62 | - // Foreign key fields | |
| 62 | + // Foreign key fields | |
| 63 | 63 | |
| 64 | - $data['boincteam_forum_node']['nid'] = array( | |
| 64 | + $data['boincteam_forum_node']['nid'] = array( | |
| 65 | 65 |      'title' => t('Team forum node'), | 
| 66 | 66 |      'help' => t('The node containing the content of this team forum topic.'), | 
| 67 | 67 |      // This is a foreign key to the {node} table. When the view is configured | 
| 68 | 68 | // with this relationship, all the fields for the related user node will be | 
| 69 | 69 | // available. | 
| 70 | 70 | 'relationship' => array( | 
| 71 | - 'base' => 'node', | |
| 72 | - 'field' => 'nid', | |
| 73 | - 'handler' => 'views_handler_relationship', | |
| 74 | -      'label' => t('Team Forum Topic Node') | |
| 71 | + 'base' => 'node', | |
| 72 | + 'field' => 'nid', | |
| 73 | + 'handler' => 'views_handler_relationship', | |
| 74 | +        'label' => t('Team Forum Topic Node') | |
| 75 | 75 | ), | 
| 76 | 76 | 'field' => array( | 
| 77 | - 'handler' => 'views_handler_field_numeric', | |
| 78 | - 'click sortable' => TRUE | |
| 77 | + 'handler' => 'views_handler_field_numeric', | |
| 78 | + 'click sortable' => TRUE | |
| 79 | 79 | ), | 
| 80 | 80 | 'filter' => array( | 
| 81 | - 'handler' => 'views_handler_filter_numeric' | |
| 81 | + 'handler' => 'views_handler_filter_numeric' | |
| 82 | 82 | ), | 
| 83 | 83 | 'sort' => array( | 
| 84 | - 'handler' => 'views_handler_sort_numeric' | |
| 84 | + 'handler' => 'views_handler_sort_numeric' | |
| 85 | 85 | ) | 
| 86 | - ); | |
| 86 | + ); | |
| 87 | 87 | |
| 88 | - // Descriptions of general fields (alphabetized) | |
| 89 | - // ... | |
| 88 | + // Descriptions of general fields (alphabetized) | |
| 89 | + // ... | |
| 90 | 90 | |
| 91 | - return $data; | |
| 91 | + return $data; | |
| 92 | 92 | } | 
| @@ -7,15 +7,15 @@ | ||
| 7 | 7 | */ | 
| 8 | 8 | |
| 9 | 9 |  class views_handler_argument_boincuser_id extends views_handler_argument_numeric { | 
| 10 | -  function construct() { | |
| 10 | +    function construct() { | |
| 11 | 11 | parent::construct(); | 
| 12 | - } | |
| 12 | + } | |
| 13 | 13 | |
| 14 | -  function set_argument($arg) { | |
| 14 | +    function set_argument($arg) { | |
| 15 | 15 | // When setting the ID argument, convert to BOINC ID | 
| 16 | 16 | $id = is_numeric($arg) ? $arg : 0; | 
| 17 | 17 |      $boinc_id = db_result(db_query("SELECT boinc_id FROM {boincuser} WHERE uid = %d", $id)); | 
| 18 | 18 | $this->argument = $boinc_id; | 
| 19 | 19 | return $this->validate_arg($boinc_id); | 
| 20 | - } | |
| 20 | + } | |
| 21 | 21 | } | 
| @@ -6,15 +6,15 @@ | ||
| 6 | 6 | */ | 
| 7 | 7 | |
| 8 | 8 |  class views_handler_field_boincwork_host_app_et_avg extends views_handler_field { | 
| 9 | -  function construct() { | |
| 9 | +    function construct() { | |
| 10 | 10 | parent::construct(); | 
| 11 | - } | |
| 11 | + } | |
| 12 | 12 | |
| 13 | -  function render($values) { | |
| 13 | +    function render($values) { | |
| 14 | 14 | $gflops = 0; | 
| 15 | 15 |      if ($values->host_app_version_et_avg) { | 
| 16 | - $gflops = 1e-9 / $values->host_app_version_et_avg; | |
| 16 | + $gflops = 1e-9 / $values->host_app_version_et_avg; | |
| 17 | 17 | } | 
| 18 | 18 | return round($gflops, 2) . ' GFLOPS'; | 
| 19 | - } | |
| 19 | + } | |
| 20 | 20 | } | 
| @@ -6,12 +6,12 @@ | ||
| 6 | 6 | */ | 
| 7 | 7 | |
| 8 | 8 |  class views_handler_field_boincwork_host_app_turnaround_avg extends views_handler_field { | 
| 9 | -  function construct() { | |
| 9 | +    function construct() { | |
| 10 | 10 | parent::construct(); | 
| 11 | - } | |
| 11 | + } | |
| 12 | 12 | |
| 13 | -  function render($values) { | |
| 13 | +    function render($values) { | |
| 14 | 14 | $time_in_days = $values->host_app_version_turnaround_avg / (24*60*60); | 
| 15 | 15 |      return round($time_in_days, 2) . ' ' . t('days'); | 
| 16 | - } | |
| 16 | + } | |
| 17 | 17 | } | 
| @@ -6,11 +6,11 @@ | ||
| 6 | 6 | */ | 
| 7 | 7 | |
| 8 | 8 |  class views_handler_field_boincwork_app_version_number extends views_handler_field { | 
| 9 | -  function construct() { | |
| 9 | +    function construct() { | |
| 10 | 10 | parent::construct(); | 
| 11 | - } | |
| 11 | + } | |
| 12 | 12 | |
| 13 | -  function render($values) { | |
| 13 | +    function render($values) { | |
| 14 | 14 |      return sprintf("%01.2f", $values->app_version_host_app_version_version_num / 100); | 
| 15 | - } | |
| 15 | + } | |
| 16 | 16 | } |