/[drupal]/contributions/modules/subscriptions/subscriptions_mail.templates.inc
ViewVC logotype

Contents of /contributions/modules/subscriptions/subscriptions_mail.templates.inc

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


Revision 1.5 - (show annotations) (download) (as text)
Sat Aug 30 12:42:40 2008 UTC (14 months, 3 weeks ago) by salvis
Branch: MAIN
CVS Tags: DRUPAL-6--1-0-RC1, DRUPAL-6--1-0, DRUPAL-6--1-1, DRUPAL-6--1-0-BETA3, DRUPAL-6--1-0-BETA2, DRUPAL-6--1-0-BETA6, DRUPAL-6--1-0-BETA5, DRUPAL-6--1-0-BETA4, HEAD
Changes since 1.4: +47 -18 lines
File MIME type: text/x-php
Implement support for mail_edit 6.x-1.x.
1 <?php
2 // $Id: subscriptions_mail.templates.inc,v 1.4 2008/06/22 14:20:46 salvis Exp $
3
4 /**
5 * @file
6 * Subscriptions module mail templates constants.
7 */
8
9 define('SUBSCRIPTIONS_COMMENT_MAILKEY', 'subscriptions_content_node-nid+comment');
10 define('SUBSCRIPTIONS_DIGEST_MAILKEY', 'subscriptions_mail_digest');
11
12 function subscriptions_mail_template_raw($key, $langcode) {
13 switch ($key) {
14
15 case 'SEP': return // SUBSCRIPTIONS_DEFAULT_SEPARATOR
16 t('| --------------------------------------------------------------------
17 ', array(), $langcode);
18
19 case 'SUBJ': return // SUBSCRIPTIONS_DEFAULT_SUBJECT
20 t('[!site] !subs_type subscription for !name: !title', array(), $langcode);
21
22 case 'FOOT': return // SUBSCRIPTIONS_DEFAULT_FOOTER
23 t('| This is an automated message. Please do NOT reply to the sender address!
24 | To manage your subscriptions go to
25 | !manage_url
26 ', array(), $langcode);
27
28 case 'BODY': return // SUBSCRIPTIONS_DEFAULT_BODY
29 t('| Greetings, !name.
30 |
31 | Your subscription on !site
32 | notifies you of {{!is_new==0?:a new post:
33 }}{{!is_updated==0?:an updated post:
34 }}{{!is_old==0?:new comments:
35 }}|
36 {{!is_published==1?:| ***** This post is unpublished! *****
37 }}{{!term_name==!term_name?:| Category: !term_name
38 }}{{!sender_name==!sender_name?:| Author: !sender_name
39 }}{{!sender_has_contact_page==0?:| Contact: !sender_contact_page
40 }}| Title: !title
41 {{!is_old==1?:
42 !teaser
43
44 }}| Link: !url
45 | Direct unsubscribe link (!subs_type):
46 | !unsubscribe_url
47 {{!has_new_comments==1?!SEPARATOR!comments:}}!SEPARATOR!FOOTER', array('!SEPARATOR' => subscriptions_mail_template_raw('SEP', $langcode), '!FOOTER' => subscriptions_mail_template_raw('FOOT', $langcode)), $langcode);
48
49 case 'CITEM': return // SUBSCRIPTIONS_DEFAULT_COMMENT_ITEM
50 t('| {{!comment_is_new==1?New:Updated}} {{!comment_is_published==1?:UNPUBLISHED }}comment:
51 | Author: !comment_name
52 | Title: !comment_title
53
54 !comment_text
55
56 | Link: !comment_url
57 ', array(), $langcode);
58
59 case 'DSUBJ': return // SUBSCRIPTIONS_DEFAULT_DIGEST_SUBJECT
60 t('[!site] Subscription Digest for !name', array(), $langcode);
61
62 case 'DBODY': return // SUBSCRIPTIONS_DEFAULT_DIGEST_BODY
63 t('| Greetings, !name.
64 |
65 | Your subscriptions on !site
66 | notify you of the following changes since the previous digest:
67 |
68 !bodies!SEPARATOR!FOOTER', array('!SEPARATOR' => subscriptions_mail_template_raw('SEP', $langcode), '!FOOTER' => subscriptions_mail_template_raw('FOOT', $langcode)), $langcode);
69
70 case 'DITEM': return // SUBSCRIPTIONS_DEFAULT_DIGEST_ITEM_BODY
71 t('{{!sender_name==!sender_name?:| Author: !sender_name
72 }}| Title: !title
73 {{!is_new==0?:!teaser
74 }}| Link: !url
75 | Direct unsubscribe link (!subs_type):
76 | !unsubscribe_url
77 {{!has_new_comments!=1?:!comments}}', array(), $langcode);
78
79 case 'DITEMCMT': return // SUBSCRIPTIONS_DEFAULT_DIGEST_ITEM_BODY_COMMENT
80 t('| Comment: !comment_title
81 ', array(), $langcode);
82
83 }
84 }
85
86 function subscriptions_mail_template($key, $langcode) {
87 static $templates;
88 if (!isset($templates[$langcode][$key])) {
89 $templates[$langcode][$key] = subscriptions_mail_template_raw($key, $langcode);
90 }
91 return $templates[$langcode][$key];
92 }
93
94 /**
95 * Retrieve a mail template, either from the mail_edit table or take
96 * our default template in this file, passing it through t().
97 *
98 * @param string $mailkey
99 * the full mailkey, used as id in the mail_edit table
100 * @param string $langcode
101 * the language code, used as language in the mail_edit table or for
102 * translating out default template
103 * @param string $part
104 * either 'subject' or 'body', used to indicate the column to retrieve
105 * from the mail_edit table
106 * @param string $key
107 * the key for calling subscriptions_mail_template() to retrieve the
108 * default template, if there's no match in the mail_edit table
109 */
110 function subscriptions_mail_template_load($mailkey, $langcode, $part, $key)
111 {
112 if (module_exists('mail_edit')) {
113 static $cache = array();
114 if (!isset($cache[$langcode][$mailkey]))
115 {
116 $cache[$langcode][$mailkey] = db_fetch_object(db_query("SELECT * FROM {mail_edit} WHERE id = '%s' and language = '%s'", $mailkey, $langcode));
117 }
118 if (isset($cache[$langcode][$mailkey]->$part)) {
119 return $cache[$langcode][$mailkey]->$part;
120 }
121 }
122 return subscriptions_mail_template($key, $langcode);
123 }
124

  ViewVC Help
Powered by ViewVC 1.1.2