You are here

function shoutbox_user_shoutbox in Shoutbox 7.2

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

Implements hook_shoutbox().

File

shoutbox_user/shoutbox_user.module, line 56

Code

function shoutbox_user_shoutbox($op, &$shout, &$a1 = NULL, $form_state = NULL) {
  switch ($op) {
    case 'context':
      if ($uid = shoutbox_user_get_current_uid()) {
        $a1['shoutbox_user'] = $uid;
      }
      break;
    case 'insert':

      // Determine if the shout was added for a user
      if (array_key_exists('uid', $form_state['values']) && ($uid = $form_state['values']['uid'])) {
        shoutbox_user_save($shout, $uid);
      }
      break;
    case 'presave':

      // Determine if the shout was added for a user
      if (array_key_exists('uid', $form_state['values']) && ($uid = $form_state['values']['uid'])) {

        // Tag this shout as belonging to this module
        $shout->module = 'shoutbox_user';
      }
      break;
    case 'delete':
      db_delete('shoutbox_user')
        ->condition('shout_id', $shout->shout_id)
        ->execute();
      break;
    case 'js path':

      // Alter the js update path so only shouts with the given
      // tag are shown
      if ($uid = shoutbox_user_get_current_uid()) {
        $a1 = "shoutbox/user/{$uid}/js/view/";
      }
      break;
    case 'form':
      if ($uid = shoutbox_user_get_current_uid()) {
        $a1['wrapper']['uid'] = array(
          '#type' => 'value',
          '#value' => $uid,
        );
      }
      break;
    case 'link':
      if ($uid = shoutbox_user_get_current_uid()) {
        $a1 = "shoutbox/user/{$uid}";
      }
      break;
  }
}