1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* This file takes care of creating/deleting pm_email_notify table used
|
6
|
* for storing user notification preferences
|
7
|
*/
|
8
|
|
9
|
function pm_email_notify_schema() {
|
10
|
$schema = array();
|
11
|
|
12
|
$schema['pm_email_notify'] = array(
|
13
|
'description' => '{pm_email_notify} holds private message email notification settings for each user ',
|
14
|
'fields' => array(
|
15
|
'user_id' => array(
|
16
|
'description' => 'ID of the user',
|
17
|
'type' => 'int',
|
18
|
'not null' => TRUE,
|
19
|
'unsigned' => TRUE,
|
20
|
),
|
21
|
'email_notify_is_enabled' => array(
|
22
|
'description' => 'Email Notification Status (Enabled=1, Disabled=0)',
|
23
|
'type' => 'int',
|
24
|
'not null' => TRUE,
|
25
|
'unsigned' => TRUE,
|
26
|
),
|
27
|
),
|
28
|
'unique keys' => array(
|
29
|
'user_id' => array('user_id')
|
30
|
),
|
31
|
);
|
32
|
|
33
|
return $schema;
|
34
|
}
|
35
|
|
36
|
/**
|
37
|
* Implements hook_uninstall().
|
38
|
*/
|
39
|
function pm_email_notify_uninstall() {
|
40
|
variable_del('pm_email_notify_body');
|
41
|
variable_del('pm_email_notify_default');
|
42
|
variable_del('pm_email_notify_subject');
|
43
|
variable_del('pm_email_notify_from');
|
44
|
}
|
45
|
|
46
|
/**
|
47
|
* Replace old placeholders with new tokens.
|
48
|
*/
|
49
|
function pm_email_notify_update_7000() {
|
50
|
$replacements = array(
|
51
|
'!author' => '[privatemsg_message:author]',
|
52
|
'!username' => '[privatemsg_message:recipient]',
|
53
|
'!author_uid' => '[privatemsg_message:author:uid]',
|
54
|
'!pm_subject' => '[privatemsg_message:subject]',
|
55
|
'!pm_body' => '[privatemsg_message:body]',
|
56
|
'!thread' => '[privatemsg_message:thread_id]',
|
57
|
'!site' => '[site:name]',
|
58
|
'!login-url' => '[site:login-url]',
|
59
|
'!uri' => ' [site:url]',
|
60
|
'!uri_brief' => '[site:url-brief]',
|
61
|
'!message' => '[privatemsg_message:url]',
|
62
|
'!settings' => '[privatemsg_message:recipient:edit-url]',
|
63
|
);
|
64
|
// Only update if there was actually something saved.
|
65
|
if ($subject = variable_get('pm_email_notify_subject', FALSE)) {
|
66
|
variable_set('pm_email_notify_subject', str_replace(array_keys($replacements), array_values($replacements), $subject));
|
67
|
}
|
68
|
if ($body = variable_get('pm_email_notify_body', FALSE)) {
|
69
|
variable_set('pm_email_notify_body', str_replace(array_keys($replacements), array_values($replacements), $body));
|
70
|
}
|
71
|
}
|
72
|
|