You are here

function privatemsg_block in Privatemsg 6.2

Same name and namespace in other branches
  1. 5.3 privatemsg.module \privatemsg_block()
  2. 5 privatemsg.module \privatemsg_block()
  3. 6 privatemsg.module \privatemsg_block()

File

./privatemsg.module, line 1438
Allows users to send private messages to other users.

Code

function privatemsg_block($op = 'list', $delta = 0, $edit = array()) {
  if ('list' == $op) {
    $blocks = array();
    $blocks['privatemsg-menu'] = array(
      'info' => t('Privatemsg links'),
      'cache' => BLOCK_NO_CACHE,
    );
    $blocks['privatemsg-new'] = array(
      'info' => t('New message indication'),
      'cache' => BLOCK_NO_CACHE,
    );
    return $blocks;
  }
  elseif ($op == 'configure' && $delta == 'privatemsg-new') {
    $form['notification'] = array(
      '#type' => 'checkbox',
      '#title' => t('Display block when there are no new messages'),
      '#default_value' => variable_get('privatemsg_no_messages_notification', 0),
      '#description' => t('Enable this to have this block always displayed, even if there are no new messages'),
    );
    return $form;
  }
  elseif ($op == 'save' && $delta == 'privatemsg-new') {
    variable_set('privatemsg_no_messages_notification', $edit['notification']);
  }
  elseif ('view' == $op) {
    $block = array();
    switch ($delta) {
      case 'privatemsg-menu':
        $block = _privatemsg_block_menu();
        break;
      case 'privatemsg-new':
        $block = _privatemsg_block_new();
        break;
    }
    return $block;
  }
}