diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-01-04 16:10:48 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-01-04 16:10:48 +0000 |
commit | 6690a4ec4cf75b2f18cc53bf67f011c1ecc45e15 (patch) | |
tree | 5cac9cb74340d9d26922f3041cb06a9ec9c4e5cd /modules/comment/comment.api.php | |
parent | fbf4e0f1167cdc88b4f8244df63a917ce5167191 (diff) | |
download | brdo-6690a4ec4cf75b2f18cc53bf67f011c1ecc45e15.tar.gz brdo-6690a4ec4cf75b2f18cc53bf67f011c1ecc45e15.tar.bz2 |
- Patch #353480 by dereine, justinrandell: remove from hook_comment().
Diffstat (limited to 'modules/comment/comment.api.php')
-rw-r--r-- | modules/comment/comment.api.php | 106 |
1 files changed, 84 insertions, 22 deletions
diff --git a/modules/comment/comment.api.php b/modules/comment/comment.api.php index a486dd932..9b431e98d 100644 --- a/modules/comment/comment.api.php +++ b/modules/comment/comment.api.php @@ -12,37 +12,99 @@ */ /** - * Act on comments. + * The comment is being inserted. * - * This hook allows modules to extend the comments system. + * @param $form_values + * Passes in an array of form values submitted by the user. + * @return + * Nothing. + */ +function hook_comment_insert(&$form_values) { + $nid = $form_values['nid']; + + cache_clear_all_like(drupal_url(array('id' => $nid))); +} + +/** + * The user has just finished editing the comment and is trying to + * preview or submit it. This hook can be used to check or + * even modify the node. Errors should be set with form_set_error(). * - * @param $a1 - * Dependent on the action being performed. - * - For "validate","update","insert", passes in an array of form values submitted by the user. - * - For all other operations, passes in the comment the action is being performed on. - * @param $op - * What kind of action is being performed. Possible values: - * - "insert": The comment is being inserted. - * - "update": The comment is being updated. - * - "view": The comment is being viewed. This hook can be used to add additional data to the comment before theming. - * - "validate": The user has just finished editing the comment and is - * trying to preview or submit it. This hook can be used to check or - * even modify the node. Errors should be set with form_set_error(). - * - "publish": The comment is being published by the moderator. - * - "unpublish": The comment is being unpublished by the moderator. - * - "delete": The comment is being deleted by the moderator. + * @param $form_values + * Passes in an array of form values submitted by the user. * @return - * Dependent on the action being performed. - * - For all other operations, nothing. + * Nothing. */ -function hook_comment(&$a1, $op) { - if ($op == 'insert' || $op == 'update') { - $nid = $a1['nid']; +function hook_comment_validate(&$form_values) { + // if the subject is the same as the comment. + if ($form_values['subject'] == $form_values['comment']) { + form_set_error('comment', t('you should write more text than in the subject')); } +} + +/** + * The comment is being updated. + * + * @param $form_values + * Passes in an array of form values submitted by the user. + * @return + * Nothing. + */ +function hook_comment_update(&$form_values) { + $nid = $form_values['nid']; cache_clear_all_like(drupal_url(array('id' => $nid))); } /** + * The comment is being viewed. This hook can be used to add additional data to the comment before theming. + * + * @param $comment + * Passes in the comment the action is being performed on. + * @return + * Nothing. + */ +function hook_comment_view(&$comment) { + // how old is the comment + $comment->time_ago = time() - $comment->timestamp; +} + +/** + * The comment is being published by the moderator. + * + * @param $form_values + * Passes in an array of form values submitted by the user. + * @return + * Nothing. + */ +function hook_comment_publish($form_values) { + drupal_set_message(t('Comment: @subject has been published', array('@subject' => $form_values['subject']))); +} + +/** + * The comment is being unpublished by the moderator. + * + * @param $comment + * Passes in the comment the action is being performed on. + * @return + * Nothing. + */ +function hook_comment_unpublish(&$comment) { + drupal_set_message(t('Comment: @subject has been unpublished', array('@subject' => $comment->subject))); +} + +/** + * The comment is being deleted by the moderator. + * + * @param $comment + * Passes in the comment the action is being performed on. + * @return + * Nothing. + */ +function hook_comment_delete(&$comment) { + drupal_set_message(t('Comment: @subject has been deleted', array('@subject' => $comment->subject))); +} + +/** * @} End of "addtogroup hooks". */ |