Index: lazyreg.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/lazyreg/lazyreg.module,v retrieving revision 1.1 diff -u -r1.1 lazyreg.module --- lazyreg.module 5 Mar 2007 12:49:53 -0000 1.1 +++ lazyreg.module 7 Jun 2008 01:34:11 -0000 @@ -33,7 +33,7 @@ if ($user->uid) { $res = db_query('SELECT * from {lazyreg} where uid = %d', $user->uid); if (db_num_rows($res) > 0) { - $block['content'] = t('You are using a temporary account. To keep this account, please go to your account and edit your info.', array('%url' => url('user/'.$user->uid))); + $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; @@ -79,14 +79,18 @@ ); $items[] = array( 'path' => 'admin/settings/lazyreg', + 'type' => MENU_NORMAL_ITEM, 'title' => t('lazy registration'), - 'access' => node_access('administer lazy registration'), - 'callback' => 'lazyreg_admin'); + 'access' => user_access('administer site configuration'), + 'callback' => 'drupal_get_form', + 'description' => t('Control details regarding lazy registration.'), + 'callback arguments' => array('lazyreg_admin_settings') + ); } return $items; } -function lazyreg_admin() { +function lazyreg_admin_settings() { $adhandler = variable_get('site_403', ''); if ($adhandler == 'lazyreg') { $lren = 1; @@ -134,7 +138,7 @@ $roles = user_roles(1); $form['lazyreg_role'] = array('#type' => 'select', '#title' => t('Temporary user role'), - '#options' => $roles, + '#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'))), ); @@ -166,12 +170,11 @@ %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'] = array('#type' => 'submit', '#value' => t('Save options')); - return drupal_get_form('lazyreg_form_options', $form); + return system_settings_form($form); } -function lazyreg_form_options_submit($form_id, $form_values) { +function lazyreg_admin_settings_submit($form_id, $form_values) { if ($form_values['lazyreg_enabled']) { variable_set('site_403', 'lazyreg'); } @@ -186,7 +189,7 @@ variable_set('lazyreg_purge', $form_values['lazyreg_purge']); variable_set('lazyreg_template', $form_values['lazyreg_template']); variable_set('lazyreg_ptemplate', $form_values['lazyreg_ptemplate']); - drupal_set_message(t('The options have been saved.')); + drupal_set_message(t('The lazyreg options have been saved.')); return 'admin/settings/lazyreg'; } @@ -492,6 +495,7 @@ $now = time(); $delay = $purge_delay * 24 * 60 * 60; + set_time_limit(0); // sometimes this can take a while removing users $uids = array(); $res = db_query('select u.uid from {users} u, {lazyreg} r where %d - access > %d and u.uid = r.uid', $now, $delay); while ($o = db_fetch_object($res)) { @@ -499,6 +503,8 @@ } foreach ($uids as $uid) { + db_query("UPDATE {node} SET uid=0 WHERE uid=%d", $uid); // change owners on deleted users' nodes TODO: make optional + db_query("UPDATE {comments} SET uid=0 WHERE uid=%d", $uid); // change owners on deleted users' comments TODO: make optional db_query('DELETE FROM {users} WHERE uid = %d', $uid); db_query('DELETE FROM {sessions} WHERE uid = %d', $uid); db_query('DELETE FROM {users_roles} WHERE uid = %d', $uid);