uid) { $num_rows = db_result(db_query('SELECT count(*) from {lazyreg} where uid = %d', $user->uid)); if ($num_rows) { $block['content'] = t('You are using a temporary account. To keep this account, please go and edit ' . l(t('your account'), 'user/'.$user->uid.'/edit') . ' info.'); } } break; } return $block; } } /** * Implementation of hook_menu() * */ function lazyreg_menu() { $items = array(); $items['admin/settings/lazyreg'] = array( 'title' => 'Lazy Registration Settings', 'description' => 'Control details regarding lazy registration.', 'page callback' => 'drupal_get_form', 'access arguments' => array('administer lazy registration'), 'page arguments' => array('lazyreg_admin'), 'type' => MENU_NORMAL_ITEM, ); return $items; } function lazyreg_admin(&$form_state) { $form['lazyreg_enabled'] = array( '#type' => 'checkbox', '#title' => t('Enable lazy registration'), '#default_value' => variable_get('enabled', 0), '#description' => t("Select this if you'd like to use lazy registration. This will replace the 403 error handler with lazyreg's one."), ); $form['lazyreg_skipl'] = array( '#type' => 'checkbox', '#title' => t('Skip login screen'), '#default_value' => variable_get('lazyreg_skipl', 0), '#description' => t("This option makes Lazyreg create the temporary account automatically, instead of asking the user if he/she wants to login or to continue with a temporary account."), ); $form['lazyreg_askemail'] = array( '#type' => 'checkbox', '#title' => t('Ask for email at the beginning?'), '#default_value' => variable_get('lazyreg_askemail', 0), '#description' => t("To simplify account confirmation, the module can ask for the email adress before the automatic account creation. Also, an email will be sent there with the confirmation link, if that option is set."), ); $form['lazyreg_simple'] = array( '#type' => 'checkbox', '#title' => t('Simple confirmation'), '#default_value' => variable_get('lazyreg_simple', 1), '#description' => t("If simple confirmation is selected, the account will become a full one when a modification is made to it. Otherwise, an extra checkbox will appear on the edit account page."), ); $form['lazyreg_confirm'] = array( '#type' => 'checkbox', '#title' => t('Require email confirmation'), '#default_value' => variable_get('lazyreg_confirm', 1), '#description' => t("Require the user to enter a valid email address where a confirmation link will be sent to activate the account."), ); $form['lazyreg_purge'] = array( '#type' => 'textfield', '#title' => t('Purge accounts after how many days of inactivity?'), '#default_value' => variable_get('lazyreg_purge', 2), '#description' => t("Temporary accounts which have been inactive for this number of days will be deleted. Requires cron."), ); $roles = user_roles(1); $form['lazyreg_role'] = array( '#type' => 'select', '#title' => t('Temporary user role'), '#options' => array($roles), '#default_value' => variable_get('lazyreg_role', 2), '#description' => t('The temporary accounts created by the module will be assigned this role. Make sure the role has the "change own username" permission. Add new roles here.', array('%url' => url('admin/access/roles'))), ); $form['lazyreg_ptemplate'] = array( '#title' => t('Email template with password'), '#type' => t('textarea'), '#default_value' => variable_get('lazyreg_ptemplate', t("Hello %user, We created a temporary account for you at %site with the name %user and password %password. If you want to continue using it, please go to this link to activate it: %confirmation_link If you're not interested in using the account anymore, ignore this email. The account will be automatically deleted. Thank you, %site administrators")), '#description' => t('This template will be used when email confirmation is required and a password will be sent to the user. You can use the following variables which will be replaced: %user, %confirmation_link, %site, %password.'), ); $form['lazyreg_template'] = array( '#title' => t('Email template'), '#type' => t('textarea'), '#default_value' => variable_get('lazyreg_template', t("Hello %user, We created a temporary account for you at %site with the username %user. If you want to continue using it, please go to this link to activate it: %confirmation_link If you're not interested in using the account anymore, ignore this email. The account will be automatically deleted. Thank you, %site administrators")), '#description' => t('This template will be used when email confirmation is required and no password will be sent to the user. You can use the following variables which will be replaced: %user, %confirmation_link, %site.'), ); $form['submit']['lazyreg_admin_submit_handler'] = array('#type' => 'submit', '#value' => t('Submit')); return ($form); }