danielebarchiesi@0: subject = trim($comment->subject); danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * The comment is being inserted. danielebarchiesi@0: * danielebarchiesi@0: * @param $comment danielebarchiesi@0: * The comment object. danielebarchiesi@0: */ danielebarchiesi@0: function hook_comment_insert($comment) { danielebarchiesi@0: // Reindex the node when comments are added. danielebarchiesi@0: search_touch_node($comment->nid); danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * The comment is being updated. danielebarchiesi@0: * danielebarchiesi@0: * @param $comment danielebarchiesi@0: * The comment object. danielebarchiesi@0: */ danielebarchiesi@0: function hook_comment_update($comment) { danielebarchiesi@0: // Reindex the node when comments are updated. danielebarchiesi@0: search_touch_node($comment->nid); danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * Comments are being loaded from the database. danielebarchiesi@0: * danielebarchiesi@0: * @param $comments danielebarchiesi@0: * An array of comment objects indexed by cid. danielebarchiesi@0: */ danielebarchiesi@0: function hook_comment_load($comments) { danielebarchiesi@0: $result = db_query('SELECT cid, foo FROM {mytable} WHERE cid IN (:cids)', array(':cids' => array_keys($comments))); danielebarchiesi@0: foreach ($result as $record) { danielebarchiesi@0: $comments[$record->cid]->foo = $record->foo; danielebarchiesi@0: } danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * The comment is being viewed. This hook can be used to add additional data to the comment before theming. danielebarchiesi@0: * danielebarchiesi@0: * @param $comment danielebarchiesi@0: * Passes in the comment the action is being performed on. danielebarchiesi@0: * @param $view_mode danielebarchiesi@0: * View mode, e.g. 'full', 'teaser'... danielebarchiesi@0: * @param $langcode danielebarchiesi@0: * The language code used for rendering. danielebarchiesi@0: * danielebarchiesi@0: * @see hook_entity_view() danielebarchiesi@0: */ danielebarchiesi@0: function hook_comment_view($comment, $view_mode, $langcode) { danielebarchiesi@0: // how old is the comment danielebarchiesi@0: $comment->time_ago = time() - $comment->changed; danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * The comment was built; the module may modify the structured content. danielebarchiesi@0: * danielebarchiesi@0: * This hook is called after the content has been assembled in a structured array danielebarchiesi@0: * and may be used for doing processing which requires that the complete comment danielebarchiesi@0: * content structure has been built. danielebarchiesi@0: * danielebarchiesi@0: * If the module wishes to act on the rendered HTML of the comment rather than the danielebarchiesi@0: * structured content array, it may use this hook to add a #post_render callback. danielebarchiesi@0: * Alternatively, it could also implement hook_preprocess_comment(). See danielebarchiesi@0: * drupal_render() and theme() documentation respectively for details. danielebarchiesi@0: * danielebarchiesi@0: * @param $build danielebarchiesi@0: * A renderable array representing the comment. danielebarchiesi@0: * danielebarchiesi@0: * @see comment_view() danielebarchiesi@0: * @see hook_entity_view_alter() danielebarchiesi@0: */ danielebarchiesi@0: function hook_comment_view_alter(&$build) { danielebarchiesi@0: // Check for the existence of a field added by another module. danielebarchiesi@0: if ($build['#view_mode'] == 'full' && isset($build['an_additional_field'])) { danielebarchiesi@0: // Change its weight. danielebarchiesi@0: $build['an_additional_field']['#weight'] = -10; danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: // Add a #post_render callback to act on the rendered HTML of the comment. danielebarchiesi@0: $build['#post_render'][] = 'my_module_comment_post_render'; danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * The comment is being published by the moderator. danielebarchiesi@0: * danielebarchiesi@0: * @param $comment danielebarchiesi@0: * Passes in the comment the action is being performed on. danielebarchiesi@0: * @return danielebarchiesi@0: * Nothing. danielebarchiesi@0: */ danielebarchiesi@0: function hook_comment_publish($comment) { danielebarchiesi@0: drupal_set_message(t('Comment: @subject has been published', array('@subject' => $comment->subject))); danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * The comment is being unpublished by the moderator. danielebarchiesi@0: * danielebarchiesi@0: * @param $comment danielebarchiesi@0: * Passes in the comment the action is being performed on. danielebarchiesi@0: * @return danielebarchiesi@0: * Nothing. danielebarchiesi@0: */ danielebarchiesi@0: function hook_comment_unpublish($comment) { danielebarchiesi@0: drupal_set_message(t('Comment: @subject has been unpublished', array('@subject' => $comment->subject))); danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * The comment is being deleted by the moderator. danielebarchiesi@0: * danielebarchiesi@0: * @param $comment danielebarchiesi@0: * Passes in the comment the action is being performed on. danielebarchiesi@0: * @return danielebarchiesi@0: * Nothing. danielebarchiesi@0: */ danielebarchiesi@0: function hook_comment_delete($comment) { danielebarchiesi@0: drupal_set_message(t('Comment: @subject has been deleted', array('@subject' => $comment->subject))); danielebarchiesi@0: } danielebarchiesi@0: danielebarchiesi@0: /** danielebarchiesi@0: * @} End of "addtogroup hooks". danielebarchiesi@0: */