| 1 |
<?php |
<?php |
| 2 |
// $Id: posterous.module,v 1.2 2008/07/15 03:05:25 sethfreach Exp $ |
// $Id: posterous.module,v 1.3 2008/07/19 14:31:54 sethfreach Exp $ |
| 3 |
|
|
| 4 |
define("POSTEROUS_TO_EMAIL", "post@posterous.com"); |
define("POSTEROUS_TO_EMAIL", "post@posterous.com"); |
| 5 |
|
|
| 6 |
/** |
/** |
| 7 |
* Implementation of hook_perm() |
* Implementation of hook_perm() |
| 8 |
*/ |
*/ |
| 9 |
function posterous_perm() { |
function posterous_perm() { |
| 10 |
return array( |
return array( |
| 11 |
'configure posterous', |
'configure posterous', |
| 15 |
|
|
| 16 |
/** |
/** |
| 17 |
* Implementation of hook_menu() |
* Implementation of hook_menu() |
| 18 |
*/ |
*/ |
| 19 |
function posterous_menu($may_cache) { |
function posterous_menu($may_cache) { |
| 20 |
$items = array(); |
$items = array(); |
| 21 |
if ($may_cache) { |
if ($may_cache) { |
| 28 |
'access' => user_access('configure posterous'), |
'access' => user_access('configure posterous'), |
| 29 |
); |
); |
| 30 |
} |
} |
| 31 |
|
|
| 32 |
return $items; |
return $items; |
| 33 |
} |
} |
| 34 |
|
|
| 43 |
$form['array_filter'] = array( |
$form['array_filter'] = array( |
| 44 |
'#type' => 'hidden', |
'#type' => 'hidden', |
| 45 |
); |
); |
| 46 |
|
|
| 47 |
return system_settings_form($form); |
return system_settings_form($form); |
| 48 |
} |
} |
| 49 |
|
|
| 60 |
'#options' => array( 'post_to_posterous' => t('Send to Posterous also?') ), |
'#options' => array( 'post_to_posterous' => t('Send to Posterous also?') ), |
| 61 |
'#weight' => 5, |
'#weight' => 5, |
| 62 |
); |
); |
| 63 |
} |
} |
| 64 |
} |
} |
| 65 |
} |
} |
| 66 |
|
|
| 67 |
function posterous_nodeapi(&$node, $op, $a3, $a4) { |
function posterous_nodeapi(&$node, $op, $a3, $a4) { |
| 68 |
switch ($op) { |
switch ($op) { |
|
case 'insert': |
|
| 69 |
case 'update': |
case 'update': |
| 70 |
|
// for now, just disallow edits to be posted to Posterous. TODO: add admin setting to toggle this. |
| 71 |
|
drupal_set_message("Only new content will be posted to Posterous. Edits to Drupal content will not edit existing Posterous posts; it would create dupliates.", "error"); |
| 72 |
|
break; |
| 73 |
|
case 'insert': |
| 74 |
if ($node->posterous['post_to_posterous'] == 'post_to_posterous') { |
if ($node->posterous['post_to_posterous'] == 'post_to_posterous') { |
| 75 |
global $user; |
global $user; |
| 76 |
$mailkey = 'posterous_email'; |
$mailkey = 'posterous_email'; |