You are here

function _shoutbox_is_user_owned in Shoutbox 5

Same name and namespace in other branches
  1. 6.2 shoutbox.module \_shoutbox_is_user_owned()
  2. 6 shoutbox.module \_shoutbox_is_user_owned()
  3. 7.2 shoutbox.module \_shoutbox_is_user_owned()
  4. 7 shoutbox.module \_shoutbox_is_user_owned()

Determine if the current user owns the $shout.

Parameters

$shout: The shout object that we want to check.

Return value

True if the shout is owned by the current user

2 calls to _shoutbox_is_user_owned()
_shoutbox_display_posts in ./shoutbox.module
Output existing shoutbox posts as html. Used by shoutbox_block_view.
_shoutbox_user_access in ./shoutbox.module
This function is necessary because even if a user has permission (according to the user_access function), they still should not have some permissions, such as moderating their own posts, etc.

File

./shoutbox.module, line 1124
shoutbox module displays a block for users to create short messages for thw whole site. Uses AHAH to update the database and display content.

Code

function _shoutbox_is_user_owned($shout) {
  global $user;
  $user_owned = FALSE;
  if ($shout->uid > 0 && $shout->uid == $user->uid) {
    $user_owned = TRUE;
  }
  else {
    if ($shout->uid == 0 && $user->uid == 0) {
      if ($shout->sid == session_id()) {
        $user_owned = TRUE;
      }
      else {
        if (empty($shout->sid) && !empty($shout->hostname)) {
          $user_owned = $shout->hostname == _shoutbox_ip_address();
        }
      }
    }
  }
  return $user_owned;
}