You are here

function formblock_block_view in Form Block 7

Implements hook_block_view().

File

./formblock.module, line 80

Code

function formblock_block_view($delta = '') {
  $block = array();
  $block['content']['#attached']['css'][] = drupal_get_path('module', 'formblock') . '/formblock.css';
  switch ($delta) {
    case 'user_register':
      global $user;

      // Don't display the form to logged in users or if registration is disabled
      if (!$user->uid && variable_get('user_register', 1)) {
        $block['content']['form'] = drupal_get_form('user_register_form');
        $block['subject'] = t('Create new account');
        return $block;
      }
      break;
    case 'user_password_request':
      module_load_include('inc', 'user', 'user.pages');
      $block['subject'] = t('Request new password');
      $block['content']['form'] = drupal_get_form('user_pass');
      return $block;
    case 'contact_site':
      if (user_access('access site-wide contact form') && module_exists('contact')) {
        if (!flood_is_allowed('contact', variable_get('contact_hourly_threshold', 3))) {
          $content = t("You cannot send more than %number messages per hour. Please try again later.", array(
            '%number' => variable_get('contact_hourly_threshold', 3),
          ));
        }
        else {
          module_load_include('inc', 'contact', 'contact.pages');
          $content = drupal_get_form('contact_site_form');
        }
        $block['subject'] = t('Contact');
        $block['content']['form'] = $content;
        return $block;
      }
      break;
    default:
      return formblock_get_block($delta);
  }
}