forked from friendica/friendica-addons
Use new templating style
Add two templates that I forgot to checkin last time Switch to utf8_bin collation Separate "Local" and "Upstream" links Translate "Submit" button Fix some debug statements
This commit is contained in:
parent
d32b43feb8
commit
fa35dfe69d
|
@ -1,3 +0,0 @@
|
||||||
{{ inc field_input.tpl with $field=$frommail }}{{ endinc }}
|
|
||||||
<div class="submit"><input type="submit" name="page_site" /></div>
|
|
||||||
|
|
|
@ -10,4 +10,4 @@ CREATE TABLE IF NOT EXISTS `mailstream_item` (
|
||||||
KEY `message-id` (`message-id`),
|
KEY `message-id` (`message-id`),
|
||||||
KEY `created` (`created`),
|
KEY `created` (`created`),
|
||||||
KEY `completed` (`completed`)
|
KEY `completed` (`completed`)
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATION=utf8_bin;
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
<div class="mailstream-item-body">$item.body</div>
|
|
||||||
{{ if $item.plink }}
|
|
||||||
<a class="mailstream-item-plink" href="$item.plink">$item.plink</a>
|
|
||||||
{{ endif }}
|
|
|
@ -31,7 +31,10 @@ function mailstream_install() {
|
||||||
q('ALTER TABLE `mailstream_item` CHANGE `created` `created` timestamp NOT NULL DEFAULT now()');
|
q('ALTER TABLE `mailstream_item` CHANGE `created` `created` timestamp NOT NULL DEFAULT now()');
|
||||||
q('ALTER TABLE `mailstream_item` CHANGE `completed` `completed` timestamp NULL DEFAULT NULL');
|
q('ALTER TABLE `mailstream_item` CHANGE `completed` `completed` timestamp NULL DEFAULT NULL');
|
||||||
}
|
}
|
||||||
set_config('mailstream', 'dbversion', '0.4');
|
if (get_config('mailstream', 'dbversion') == '0.4') {
|
||||||
|
q('ALTER TABLE `mailstream_item` CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin');
|
||||||
|
}
|
||||||
|
set_config('mailstream', 'dbversion', '0.5');
|
||||||
}
|
}
|
||||||
|
|
||||||
function mailstream_uninstall() {
|
function mailstream_uninstall() {
|
||||||
|
@ -47,12 +50,14 @@ function mailstream_module() {}
|
||||||
|
|
||||||
function mailstream_plugin_admin(&$a,&$o) {
|
function mailstream_plugin_admin(&$a,&$o) {
|
||||||
$frommail = get_config('mailstream', 'frommail');
|
$frommail = get_config('mailstream', 'frommail');
|
||||||
$template = file_get_contents(dirname(__file__).'/admin.tpl');
|
$template = get_markup_template('admin.tpl', 'addon/mailstream/');
|
||||||
$config = array('frommail',
|
$config = array('frommail',
|
||||||
t('From Address'),
|
t('From Address'),
|
||||||
$frommail,
|
$frommail,
|
||||||
t('Email address that stream items will appear to be from.'));
|
t('Email address that stream items will appear to be from.'));
|
||||||
$o .= replace_macros($template, array('$frommail' => $config));
|
$o .= replace_macros($template, array(
|
||||||
|
'$frommail' => $config,
|
||||||
|
'$submit' => t('Submit')));
|
||||||
}
|
}
|
||||||
|
|
||||||
function mailstream_plugin_admin_post ($a) {
|
function mailstream_plugin_admin_post ($a) {
|
||||||
|
@ -76,7 +81,7 @@ function mailstream_post_remote_hook(&$a, &$item) {
|
||||||
intval($item['contact-id']), dbesc($item['uri']), dbesc(mailstream_generate_id($a, $item['uri'])));
|
intval($item['contact-id']), dbesc($item['uri']), dbesc(mailstream_generate_id($a, $item['uri'])));
|
||||||
$r = q('SELECT * FROM `mailstream_item` WHERE `uid` = %d AND `contact-id` = %d AND `uri` = "%s"', intval($item['uid']), intval($item['contact-id']), dbesc($item['uri']));
|
$r = q('SELECT * FROM `mailstream_item` WHERE `uid` = %d AND `contact-id` = %d AND `uri` = "%s"', intval($item['uid']), intval($item['contact-id']), dbesc($item['uri']));
|
||||||
if (count($r) != 1) {
|
if (count($r) != 1) {
|
||||||
logger('mailstream_post_remote_hook: Unexpected number of items returned from mailstream_item', LOGGER_ERROR);
|
logger('mailstream_post_remote_hook: Unexpected number of items returned from mailstream_item', LOGGER_NORMAL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$ms_item = $r[0];
|
$ms_item = $r[0];
|
||||||
|
@ -85,7 +90,7 @@ function mailstream_post_remote_hook(&$a, &$item) {
|
||||||
. $item['uid'] . ' ' . $item['contact-id'], LOGGER_DATA);
|
. $item['uid'] . ' ' . $item['contact-id'], LOGGER_DATA);
|
||||||
$r = q('SELECT * FROM `user` WHERE `uid` = %d', intval($item['uid']));
|
$r = q('SELECT * FROM `user` WHERE `uid` = %d', intval($item['uid']));
|
||||||
if (count($r) != 1) {
|
if (count($r) != 1) {
|
||||||
logger('mailstream_post_remote_hook: Unexpected number of users returned', LOGGER_ERROR);
|
logger('mailstream_post_remote_hook: Unexpected number of users returned', LOGGER_NORMAL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$user = $r[0];
|
$user = $r[0];
|
||||||
|
@ -197,17 +202,21 @@ function mailstream_send($a, $ms_item, $item, $user) {
|
||||||
}
|
}
|
||||||
$mail->IsHTML(true);
|
$mail->IsHTML(true);
|
||||||
$mail->CharSet = 'utf-8';
|
$mail->CharSet = 'utf-8';
|
||||||
$template = file_get_contents(dirname(__file__).'/mail.tpl');
|
$template = get_markup_template('mail.tpl', 'addon/mailstream/');
|
||||||
$item['body'] = bbcode($item['body']);
|
$item['body'] = bbcode($item['body']);
|
||||||
$mail->Body = replace_macros($template, array('$item' => $item));
|
$item['url'] = $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $item['id'];
|
||||||
|
$mail->Body = replace_macros($template, array(
|
||||||
|
'$upstream' => t('Upstream'),
|
||||||
|
'$local' => t('Local'),
|
||||||
|
'$item' => $item));
|
||||||
if (!$mail->Send()) {
|
if (!$mail->Send()) {
|
||||||
throw new Exception($mail->ErrorInfo);
|
throw new Exception($mail->ErrorInfo);
|
||||||
}
|
}
|
||||||
logger('mailstream_send sent message ' . $mail->MessageID . ' ' . $mail->Subject, LOGGER_DEBUG);
|
logger('mailstream_send sent message ' . $mail->MessageID . ' ' . $mail->Subject, LOGGER_DEBUG);
|
||||||
} catch (phpmailerException $e) {
|
} catch (phpmailerException $e) {
|
||||||
logger('mailstream_send PHPMailer exception sending message ' . $ms_item['message-id'] . ': ' . $e->errorMessage(), LOGGER_ERROR);
|
logger('mailstream_send PHPMailer exception sending message ' . $ms_item['message-id'] . ': ' . $e->errorMessage(), LOGGER_NORMAL);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
logger('mailstream_send exception sending message ' . $ms_item['message-id'] . ': ' . $e->getMessage(), LOGGER_ERROR);
|
logger('mailstream_send exception sending message ' . $ms_item['message-id'] . ': ' . $e->getMessage(), LOGGER_NORMAL);
|
||||||
}
|
}
|
||||||
// In case of failure, still set the item to completed. Otherwise
|
// In case of failure, still set the item to completed. Otherwise
|
||||||
// we'll just try to send it over and over again and it'll fail
|
// we'll just try to send it over and over again and it'll fail
|
||||||
|
@ -228,7 +237,7 @@ function mailstream_cron($a, $b) {
|
||||||
mailstream_send($a, $ms_item, $item, $user);
|
mailstream_send($a, $ms_item, $item, $user);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger('mailstream_cron: Unable to find item ' . $ms_item['uri'], LOGGER_ERROR);
|
logger('mailstream_cron: Unable to find item ' . $ms_item['uri'], LOGGER_NORMAL);
|
||||||
q("UPDATE `mailstream_item` SET `completed` = now() WHERE `id` = %d", intval($ms_item['id']));
|
q("UPDATE `mailstream_item` SET `completed` = now() WHERE `id` = %d", intval($ms_item['id']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,11 +249,13 @@ function mailstream_plugin_settings(&$a,&$s) {
|
||||||
$enabled_mu = ($enabled === 'on') ? ' checked="true"' : '';
|
$enabled_mu = ($enabled === 'on') ? ' checked="true"' : '';
|
||||||
$address = get_pconfig(local_user(), 'mailstream', 'address');
|
$address = get_pconfig(local_user(), 'mailstream', 'address');
|
||||||
$address_mu = $address ? (' value="' . $address . '"') : '';
|
$address_mu = $address ? (' value="' . $address . '"') : '';
|
||||||
$template = file_get_contents(dirname(__file__).'/settings.tpl');
|
$template = get_markup_template('settings.tpl', 'addon/mailstream/');
|
||||||
$s .= replace_macros($template, array('$address' => $address_mu,
|
$s .= replace_macros($template, array(
|
||||||
'$address_caption' => t('Address:'),
|
'$submit' => t('Submit'),
|
||||||
'$enabled' => $enabled_mu,
|
'$address' => $address_mu,
|
||||||
'$enabled_caption' => t('Enabled:')));
|
'$address_caption' => t('Address:'),
|
||||||
|
'$enabled' => $enabled_mu,
|
||||||
|
'$enabled_caption' => t('Enabled:')));
|
||||||
}
|
}
|
||||||
|
|
||||||
function mailstream_plugin_settings_post($a,$post) {
|
function mailstream_plugin_settings_post($a,$post) {
|
||||||
|
|
3
mailstream/view/admin.tpl
Normal file
3
mailstream/view/admin.tpl
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{{ inc field_input.tpl with $field=$frommail }}{{ endinc }}
|
||||||
|
<div class="submit"><input type="submit" name="page_site" value="$submit"></div>
|
||||||
|
|
5
mailstream/view/mail.tpl
Normal file
5
mailstream/view/mail.tpl
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<div class="mailstream-item-body">$item.body</div>
|
||||||
|
{{ if $item.plink }}
|
||||||
|
<div>$upstream: <a class="mailstream-item-plink" href="$item.plink">$item.plink</a><div>
|
||||||
|
<div>$local: <a class="mailstream-item-url" href="$item.url">$item.url</a></div>
|
||||||
|
{{ endif }}
|
|
@ -7,10 +7,11 @@
|
||||||
<td><input class="checkbox" type="checkbox" name="enabled" $enabled></td>
|
<td><input class="checkbox" type="checkbox" name="enabled" $enabled></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>$address_caption</td><td><input class="input" size="70" name="address"$address></td>
|
<td>$address_caption</td>
|
||||||
|
<td><input class="input" size="70" name="address"$address></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2"><input type="submit"></td>
|
<td colspan="2"><input type="submit" value="$submit"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
8
mailstream/view/smarty3/admin.tpl
Normal file
8
mailstream/view/smarty3/admin.tpl
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{{*
|
||||||
|
* AUTOMATICALLY GENERATED TEMPLATE
|
||||||
|
* DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN
|
||||||
|
*
|
||||||
|
*}}
|
||||||
|
{{include file="field_input.tpl" field=$frommail}}
|
||||||
|
<div class="submit"><input type="submit" name="page_site" value="{{$submit}}"></div>
|
||||||
|
|
10
mailstream/view/smarty3/mail.tpl
Normal file
10
mailstream/view/smarty3/mail.tpl
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{{*
|
||||||
|
* AUTOMATICALLY GENERATED TEMPLATE
|
||||||
|
* DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN
|
||||||
|
*
|
||||||
|
*}}
|
||||||
|
<div class="mailstream-item-body">{{$item.body}}</div>
|
||||||
|
{{if $item.plink}}
|
||||||
|
<div>{{$upstream}}: <a class="mailstream-item-plink" href="{{$item.plink}}">{{$item.plink}}</a><div>
|
||||||
|
<div>{{$local}}: <a class="mailstream-item-url" href="{{$item.url}}">{{$item.url}}</a></div>
|
||||||
|
{{/if}}
|
23
mailstream/view/smarty3/settings.tpl
Normal file
23
mailstream/view/smarty3/settings.tpl
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{{*
|
||||||
|
* AUTOMATICALLY GENERATED TEMPLATE
|
||||||
|
* DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN
|
||||||
|
*
|
||||||
|
*}}
|
||||||
|
<div class="settings-block">
|
||||||
|
<h3>Mail Stream Settings</h3>
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>{{$enabled_caption}}</td>
|
||||||
|
<td><input class="checkbox" type="checkbox" name="enabled" {{$enabled}}></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{{$address_caption}}</td>
|
||||||
|
<td><input class="input" size="70" name="address"{{$address}}></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><input type="submit" value="{{$submit}}"></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
Loading…
Reference in a new issue