Skip to content
This repository was archived by the owner on Oct 29, 2020. It is now read-only.

Commit cee06be

Browse files
committed
Merge pull request #6500 from DoSomething/organ-donation-module
Organ donation module
2 parents 50d277a + 75eef2c commit cee06be

File tree

5 files changed

+120
-0
lines changed

5 files changed

+120
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name = DoSomething Organ Donation
2+
description = Functionality for collecting organ donation registrations
3+
core = 7.x
4+
package = DoSomething
5+
version = 7.x-0.3
6+
dependencies[] = entity
7+
dependencies[] = dosomething_helpers
8+
dependencies[] = dosomething_signup
9+
dependencies[] = dosomething_campaign
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/**
3+
* @file
4+
* Installation and schema hooks for dosomething_organ_donation.module
5+
*/
6+
7+
/**
8+
* Implements hook_schema().
9+
*/
10+
function dosomething_organ_donation_schema() {
11+
$schema = array();
12+
$schema['dosomething_organ_donation'] = array(
13+
'description' => 'Table for tracking organ donation registrations',
14+
'fields' => array(
15+
'sid' => array(
16+
'description' => 'The signup id associated with this registration',
17+
'type' => 'int',
18+
'not null' => TRUE,
19+
),
20+
'uid' => array(
21+
'description' => 'The {users}.uid that registered.',
22+
'type' => 'int',
23+
'not null' => TRUE,
24+
'default' => 0,
25+
),
26+
'registration_form_timestamp' => array(
27+
'description' => 'The Unix timestamp when the valid registration went through.',
28+
'type' => 'int',
29+
'not null' => FALSE,
30+
),
31+
'drop_screen' => array(
32+
'description' => 'The screen the user was on when the registration modal closed',
33+
'type' => 'int',
34+
'not null' => FALSE,
35+
),
36+
),
37+
'primary key' => array('sid'),
38+
'indexes' => array(
39+
'uid' => array('uid'),
40+
),
41+
);
42+
43+
return $schema;
44+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
/**
3+
* @file
4+
* Code for the dosomething_organ_donation feature.
5+
*/
6+
7+
/*
8+
* Implements hook_menu()
9+
*
10+
*/
11+
function dosomething_organ_donation_menu() {
12+
$items = array();
13+
14+
$items['organ-donation/registration'] = array(
15+
'page callback' => 'dosomething_organ_donation_store_registration',
16+
'access callback' => 'user_is_logged_in',
17+
'type' => MENU_CALLBACK,
18+
);
19+
20+
// Return the $items array to register the path
21+
return $items;
22+
}
23+
24+
/*
25+
* Stores meta data about the organ registration in the dosomething_organ_donation table.
26+
*
27+
*/
28+
function dosomething_organ_donation_store_registration() {
29+
$params = drupal_get_query_parameters();
30+
31+
try {
32+
if ($params['sid'] && $params['uid']) {
33+
db_insert('dosomething_organ_donation')
34+
->fields([
35+
'sid' => $params['sid'],
36+
'uid' => $params['uid'],
37+
'registration_form_timestamp' => REQUEST_TIME,
38+
])->execute();
39+
40+
$response = [
41+
'status' => 'registration data stored',
42+
];
43+
} else {
44+
$response = [
45+
'status' => 'Required parameters not found.',
46+
];
47+
48+
watchdog('dosomething_organ_donation', $response, NULL, WATCHDOG_ERROR);
49+
}
50+
51+
drupal_json_output($response);
52+
}
53+
catch (Exception $e) {
54+
drupal_json_output($e);
55+
56+
watchdog('dosomething_organ_donation', $e, NULL, WATCHDOG_ERROR);
57+
}
58+
59+
return;
60+
}

lib/profiles/dosomething/dosomething.info

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ dependencies[] = dosomething_image
9393
dependencies[] = dosomething_kudos
9494
dependencies[] = dosomething_mbp
9595
dependencies[] = dosomething_northstar
96+
dependencies[] = dosomething_organ_donation
9697
dependencies[] = dosomething_helpers
9798
dependencies[] = dosomething_home
9899
dependencies[] = dosomething_reportback

lib/profiles/dosomething/dosomething.make

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ projects[dosomething_notfound][download][type] = local
109109
projects[dosomething_notfound][download][source] = './lib/modules/dosomething/dosomething_notfound'
110110
projects[dosomething_notfound][subdir] = "dosomething"
111111

112+
; Dosomething Organ Donation
113+
projects[dosomething_organ_donation][type] = "module"
114+
projects[dosomething_organ_donation][download][type] = local
115+
projects[dosomething_organ_donation][download][source] = './lib/modules/dosomething/dosomething_organ_donation'
116+
projects[dosomething_organ_donation][subdir] = "dosomething"
117+
112118
; Dosomething Payment
113119
projects[dosomething_payment][type] = "module"
114120
projects[dosomething_payment][download][type] = local

0 commit comments

Comments
 (0)