You are here

function shoutbox_group_shoutbox in Shoutbox 7

Same name and namespace in other branches
  1. 6.2 shoutbox_group/shoutbox_group.module \shoutbox_group_shoutbox()
  2. 7.2 shoutbox_group/shoutbox_group.module \shoutbox_group_shoutbox()

Implementation of hook_shoutbox()

File

shoutbox_group/shoutbox_group.module, line 108

Code

function shoutbox_group_shoutbox($op, &$shout, &$a1 = NULL, $form_state = NULL) {
  global $group;
  switch ($op) {
    case 'insert':

      // Determine if the shout was added to a group
      if ($group_id = $form_state['values']['group_id']) {

        // Add the shout reference to the group
        $record = new stdClass();
        $record->shout_id = $shout->shout_id;
        $record->nid = $group_id;
        drupal_write_record('shoutbox_groups', $record);
      }
      break;
    case 'presave':

      // Determine if the shout was added to a group
      if ($group_id = $form_state['values']['group_id']) {

        // Tag this shout as belonging to this module
        $shout->module = 'shoutbox_group';
      }
      break;
    case 'delete':
      db_query("DELETE FROM {shoutbox_groups} WHERE shout_id = :id", array(
        ':id' => $shout->shout_id,
      ));
      break;
    case 'link':

      // If in group context, set the shoutbox page path
      if ($group = shoutbox_group_get_group()) {
        $a1 = "shoutbox/group/{$group['gid']}";
      }
      break;
    case 'form':
      _shoutbox_group_alter_form($a1);
      break;
    case 'context':
      if ($group = shoutbox_group_get_group()) {

        // A group is being viewed, display only group shouts

        //$etid=isset($group->etid) ? $group->etid : $group->gid;
        $a1['shoutbox_group'] = $group['gid'];
      }
      break;
    case 'js path':
      if ($group = shoutbox_group_get_group()) {

        //$etid=isset($group->etid) ? $group->etid : $group->gid;
        $etid = $group['gid'];
        $a1 = "shoutbox/group/{$etid}/js/view/";
      }
      break;
    case 'view':
      break;
  }
}