At work I am using Drupal as a CMS for blogging, organising project related information etc. I feel it is more suited to a collaborative role than PyDS which is essentially a private tool for publishing to a community server. The community servers available do not appear to be strong CMS systems.
Drupal is very nicely written and even I, a PHP n00b, have managed to write a Drupal module that enables me to email a posting from the work server to my home PyDS installation where it can be posted to my personal/public blog. The email->PyDS gateway that I set up for photo blogging does the posting of the email to the blog.
Main stubling block encountered was when random pieces of the email message received were missing. This turned out to be because the message was stored in the database with \r line delimiters rather than \n. When the message was transmitted this looked to the email stuff like VERY long lines so it proceeded to screw up. I'm not sure where these came from, whether the web browser uses these in text fields or what. This script turns them to \n's which everybody loves (except dos/mac zealots).
Here is my Drupal 'sendhome.module' which does the posting.
1 <?php
2
3
4
5
6
7
8 function sendhome_help($section = 'admin/help#sendhome') {
9 $output = "";
10
11 switch ($section) {
12 case 'admin/modules#description':
13 $output = t("Send page home");
14 break;
15 }
16 return $output;
17 }
18
19 function sendhome_link($type, $node=0, $main) {
20 global $user;
21
22 $links = array();
23
24
25
26
27 if( $user->name == 'my drupal login name') {
28 $links[] = l(t("Send Page Home"), "sendhome/confirm/$node->nid", array("title" => t("Send Page Home."), "callback" => "sendhome_page"));
29 }
30 return $links;
31 }
32
33
34
35
36 function sendhome_menu($may_cache) {
37 global $user;
38 $items = array();
39
40
41
42
43
44 $items[] = array('path' => 'sendhome/confirm',
45 'callback' => 'sendhome_page',
46 'access' => user_access('access content'),
47 'type' => MENU_CALLBACK);
48
49
50 return $items;
51 }
52
53
54 function sendhome_page( $uid = 0) {
55
56
57
58 $op = $_POST["op"];
59 $edit = $_POST["edit"];
60
61 if( empty($op)) {
62
63
64
65 if( arg(1) == 'confirm') {
66 $nid = arg(2);
67 }
68 } else {
69
70
71
72 $nid = $edit["nid"];
73 }
74
75
76
77
78 $nodes = db_query("SELECT nid, title, teaser, created FROM {node} WHERE nid = %d", $nid);
79
80 drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('View'), "node/view/$nid")));
81
82 while ($node = db_fetch_object($nodes)) {
83
84
85
86 $item = node_load(array('nid' => $node->nid));
87
88
89
90
91 $output .= $item->title;
92 $output .= "\n";
93 $body = str_replace( '<!--break-->', '', $item->body);
94
95
96 $output .= $body;
97 }
98
99
100
101
102
103 $output = str_replace( "\r\n", "\n", $output);
104 $output = str_replace( "\r", "\n", $output);
105
106 if ($op != t("Send")) {
107
108
109
110 $output = "<div class=\"node\">$output</div>";
111 $output .= form( form_submit(t("Send")) . form_hidden("nid", $nid));
112 print theme( "page", $output, "Post Message Home?");
113 }
114 else {
115
116
117
118 $strTo = "censored@microsoft.com";
119 $strFrom = "me@here";
120 $strMagicSubjectLine = "hush, it's a secret";
121
122
123
124
125 mail( $strTo, $strMagicSubjectLine, $output, "From: $strFrom\r\n", "-f$strFrom");
126 print theme( "page", '', "Posted Message");
127 }
128 }
129
130 ?>