/[drupal]/contributions/modules/password_reset/password_reset.install
ViewVC logotype

Contents of /contributions/modules/password_reset/password_reset.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Tue Oct 23 19:57:57 2007 UTC (2 years, 1 month ago) by karthik
Branch: MAIN
CVS Tags: DRUPAL-5--1-1-BETA, DRUPAL-6--1-0, HEAD
Branch point for: DRUPAL-5, DRUPAL-6--1
File MIME type: text/x-php
Initial commit: The password_reset module allows for passwords to be reset without involving
e-mail addresses through the use of security questions. This module would
typically be used on sites that do not require users to enter their e-mail
addresses - something that is possible only with a core hack, albeit a minor
one.
1 <?php
2 // $Id$
3
4 /**
5 * Implementation of hook_install().
6 */
7 function password_reset_install() {
8 switch ($GLOBALS['db_type']) {
9 case 'mysql':
10 case 'mysqli':
11 db_query("CREATE TABLE {password_reset} (
12 qid int UNSIGNED NOT NULL auto_increment,
13 question varchar(255) NOT NULL default '',
14 PRIMARY KEY (qid)
15 ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
16 db_query("CREATE TABLE {password_reset_users} (
17 uid int UNSIGNED NOT NULL default 0,
18 qid int UNSIGNED NOT NULL default 0,
19 answer varchar(255) NOT NULL default '',
20 PRIMARY KEY (uid),
21 KEY qid (qid)
22 ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
23 break;
24 case 'pgsql':
25 // pgSQL is not really supported as there are a couple of REPLACE queries
26 // in the module.
27 db_query("CREATE TABLE {password_reset} (
28 qid serial CHECK (qid >= 0),
29 question varchar(255) NOT NULL default '',
30 PRIMARY KEY (qid)
31 )");
32 db_query("CREATE TABLE {password_reset_users} (
33 uid int UNSIGNED NOT NULL default 0,
34 qid int UNSIGNED NOT NULL default 0,
35 answer varchar(255) NOT NULL default '',
36 PRIMARY KEY (uid)
37 )");
38 db_query("CREATE INDEX {password_reset_users}_qid_idx ON {password_reset_users} (qid)");
39 break;
40 }
41
42 // Insert demo question.
43 db_query("INSERT INTO {password_reset} (question) VALUES ('What is your library card number?')");
44
45 $salt = 'ertertertdsfg';
46 // Initialise existing accounts with generated answers.
47 db_query("INSERT INTO {password_reset_users} (uid, qid, answer) SELECT u.uid, 1, MD5(u.pass + '". $salt ."') FROM {users} u WHERE u.uid > 0");
48
49 drupal_set_message(t('password_reset module: Installation script complete.'));
50 }
51
52 /**
53 * Implementation of hook_uninstall().
54 */
55 function password_reset_uninstall() {
56 db_query('DROP TABLE {password_reset}');
57 db_query('DROP TABLE {password_reset_users}');
58 drupal_set_message(t('password_reset module: Uninstallation script complete.'));
59 }

  ViewVC Help
Powered by ViewVC 1.1.2