You are here

function shoutbox_tags_shoutbox in Shoutbox 7.2

Same name and namespace in other branches
  1. 6.2 shoutbox_tags/shoutbox_tags.module \shoutbox_tags_shoutbox()
  2. 7 shoutbox_tags/shoutbox_tags.module \shoutbox_tags_shoutbox()

Implements hook_shoutbox().

File

shoutbox_tags/shoutbox_tags.module, line 22

Code

function shoutbox_tags_shoutbox($op, &$shout, &$a1 = NULL, $form_state = NULL) {
  switch ($op) {
    case 'insert':

      // Extract the tags
      if ($tags = shoutbox_tags_extract($shout)) {

        // Save the tags
        shoutbox_tags_save($shout, $tags);
      }
      break;
    case 'edit':

      // Delete any tags from the shout
      shoutbox_tags_shoutbox('delete', $shout);

      // Redetect any tags from the shout
      shoutbox_tags_shoutbox('insert', $shout);
      break;
    case 'delete':

      // Remove any tag references to this shout
      db_delete('shoutbox_tags')
        ->condition('shout_id', $shout->shout_id)
        ->execute();
      break;
    case 'view':

      // Replace tags with links
      shoutbox_tags_to_links($shout);
      break;
    case 'context':

      // If we're viewing a tag, only returned shouts that have the tag
      if ($tag = shoutbox_tags_is_page()) {
        $a1['shoutbox_tags'] = $tag;
      }
      break;
    case 'js path':

      // Alter the js update path so only shouts with the given
      // tag are shown
      if ($tag = shoutbox_tags_is_page()) {
        $a1 = "shoutbox/tag/{$tag}/js/view/";
      }
      break;
    case 'form':

      // Remove the shout form if we're viewing a tag
      if (shoutbox_tags_is_page()) {
        $a1 = array();
      }
      break;
  }
}