array( 'arguments' => array(), ), 'modalframe_register_login_link' => array( 'arguments' => array('attributes' => array(), 'query' => NULL), ), 'modalframe_register_register_link' => array( 'arguments' => array('attributes' => array(), 'query' => NULL), ), 'modalframe_register_logout_link' => array( 'arguments' => array('attributes' => array()), ), 'modalframe_register_my_account_link' => array( 'arguments' => array('attributes' => array()), ), ); } /** * Implementation of hook_menu(). */ function modalframe_register_menu() { $items = array(); $items['modal/login'] = array( 'title' => 'Login', 'page callback' => 'modalframe_register_page_login_form', 'access callback' => 'user_is_anonymous', 'type' => MENU_CALLBACK, ); $items['modal/register'] = array( 'title' => 'Register', 'page callback' => 'modalframe_register_page_register_form', 'access callback' => 'user_register_access', 'type' => MENU_CALLBACK, ); $items['modal/register/welcome'] = array( 'title' => 'Registration details', 'page callback' => 'modalframe_register_page_welcome', 'access callback' => 'user_is_logged_in', 'type' => MENU_CALLBACK, ); return $items; } /** * Implementation of hook_init(). */ function modalframe_register_init() { if ($_GET['q'] == 'modal/register' || $_GET['q'] == 'modal/login' || $_GET['q'] == 'modal/register/welcome') { modalframe_child_js(); } } /** * Implementation of hook_block(). */ function modalframe_register_block($op = 'list', $delta = 0, $edit = array()) { global $user; if ($op == 'list') { $blocks[0] = array( 'info' => t('Modal Frame Login/Register'), ); return $blocks; } elseif ($op == 'view') { if ($delta == 0) { $block['subject'] = user_is_anonymous() ? t('Modal Frame Login/Register') : theme('username', $user); $block['content'] = theme('modalframe_register_login_block'); return $block; } } } /** * Implementation of hook_form_alter(). */ function modalframe_register_form_alter(&$form, $form_state, $form_id) { // Append our submit handler. This is required if we want a chance to // close the modal frame dialog. $form['#submit'][] = 'modalframe_register_form_submit'; if ($form_id == 'user_register') { $form['#redirect'] = 'modal/register/welcome'; } } /** * Submit handler for our node edit form example. */ function modalframe_register_form_submit($form, &$form_state) { if ($form_state['values']['op'] == t('Log in')) { modalframe_close_dialog(array( 'message' => t('Processing the form...'), )); } } /** * Menu callback; login form in child window. */ function modalframe_register_page_login_form() { // Send the Modal Frame javascript for child windows to the page. modalframe_child_js(); // Get the forms from the user module. module_load_include('inc', 'user', 'user.pages'); // Render the page contents. $output = drupal_get_form('user_login'); $output .= '

'. t('Forgot your password?') .'

'; $output .= drupal_get_form('user_pass'); return $output; } /** * Menu callback; registration form in child window. */ function modalframe_register_page_register_form() { // Send the Modal Frame javascript for child windows to the page. modalframe_child_js(); // Render the page contents. module_load_include('inc', 'user', 'user.pages'); return drupal_get_form('user_register'); } /** * Menu callback; registration Welcome Page child window. */ function modalframe_register_page_welcome() { // Send the Modal Frame javascript for child windows to the page. modalframe_child_js(); // Render the page contents. return t('Thank You! Your registration is accepted. Please check your email for further instructions to instantly activate your account.'); } /** * The guts of the block with the modal register and login links on parent page. */ function theme_modalframe_register_login_block() { global $user; if (user_is_anonymous()) { modalframe_parent_js(); drupal_add_js(drupal_get_path('module', 'modalframe_register') .'/modalframe_register.js'); $items = array( theme('modalframe_register_login_link'), ); if (user_register_access()) { $items[] = theme('modalframe_register_register_link'); } $output = '
'; $output .= theme('item_list', $items); $output .= '
'; } else { $items = array( theme('modalframe_register_my_account_link'), theme('modalframe_register_logout_link'), ); $output = '
'; $output .= theme('item_list', $items); $output .= '
'; } return $output; } /** * Theme the user login link. */ function theme_modalframe_register_login_link($attributes = array(), $query = NULL) { $attributes['class'] = (!empty($attributes['class']) ? $attributes['class'] .' modalframe-register' : 'modalframe-register'); return l(t('Login'), 'modal/login', array('attributes' => $attributes, 'query' => (!empty($query) ? $query : drupal_get_destination()))); } /** * Theme the registration link. */ function theme_modalframe_register_register_link($attributes = array(), $query = NULL) { $attributes['class'] = (!empty($attributes['class']) ? $attributes['class'] .' modalframe-register' : 'modalframe-register'); return l(t('Register'), 'modal/register', array('attributes' => $attributes, 'query' => (!empty($query) ? $query : drupal_get_destination()))); } /** * Theme the logout link. */ function theme_modalframe_register_logout_link($attributes = array()) { return l(t('Logout'), 'logout', array('attributes' => $attributes)); } /** * Theme the My Account link. */ function theme_modalframe_register_my_account_link($attributes = array()) { global $user; $path = 'user/'. $user->uid; if (module_exists('path')) { $path = drupal_get_path_alias($path); } return l(t('My account'), $path, array('attributes' => $attributes)); }