2013-02-19 04:14:26 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2015-05-13 20:28:09 +00:00
|
|
|
* Name: Pledgie
|
2015-05-18 19:51:34 +00:00
|
|
|
* Description: Show link to a pledgie account for donating
|
2015-05-13 20:28:09 +00:00
|
|
|
* Version: 1.1
|
|
|
|
* Author: tony baldwin <tony@free-haven.org>
|
|
|
|
* Hauke Altmann <https://snarl.de/profile/tugelblend>
|
|
|
|
*
|
|
|
|
*/
|
2018-01-17 00:51:12 +00:00
|
|
|
use Friendica\Core\Addon;
|
2017-11-06 23:55:24 +00:00
|
|
|
use Friendica\Core\Config;
|
|
|
|
|
2015-05-13 20:28:09 +00:00
|
|
|
function pledgie_install() {
|
2018-01-17 00:51:12 +00:00
|
|
|
Addon::registerHook('page_end', 'addon/pledgie/pledgie.php', 'pledgie_active');
|
2018-01-20 13:57:41 +00:00
|
|
|
Addon::registerHook('addon_settings', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings');
|
|
|
|
Addon::registerHook('addon_settings_post', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings_post');
|
2015-05-13 20:28:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function pledgie_uninstall() {
|
2018-01-17 00:51:12 +00:00
|
|
|
Addon::unregisterHook('page_end', 'addon/pledgie/pledgie.php', 'pledgie_active');
|
2018-01-20 13:57:41 +00:00
|
|
|
Addon::unregisterHook('addon_settings', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings');
|
|
|
|
Addon::unregisterHook('addon_settings_post', 'addon/pledgie/pledgie.php', 'pledgie_addon_settings_post');
|
2015-05-13 20:28:09 +00:00
|
|
|
}
|
2013-02-19 04:14:26 +00:00
|
|
|
|
2015-05-13 20:28:09 +00:00
|
|
|
function pledgie_addon_settings(&$a,&$s) {
|
2013-02-19 04:14:26 +00:00
|
|
|
|
2015-05-13 20:28:09 +00:00
|
|
|
if(! is_site_admin())
|
|
|
|
return;
|
2013-02-19 04:14:26 +00:00
|
|
|
|
2015-05-13 20:28:09 +00:00
|
|
|
/* Add our stylesheet to the page so we can make our settings look nice */
|
|
|
|
|
|
|
|
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/pledgie/pledgie.css' . '" media="all" />' . "\r\n";
|
|
|
|
|
2017-11-06 23:55:24 +00:00
|
|
|
$campaign = Config::get('pledgie-campaign','text');
|
|
|
|
$describe = Config::get('pledgie-describe','text');
|
2015-05-13 20:28:09 +00:00
|
|
|
|
|
|
|
if(! $campaign)
|
|
|
|
$campaign = '';
|
|
|
|
|
|
|
|
if(! describe)
|
|
|
|
$describe = '';
|
|
|
|
|
|
|
|
$s .= '<div class="settings-block">';
|
|
|
|
$s .= '<h3>' . t('"pledgie" Settings') . '</h3>';
|
|
|
|
$s .= '<div id="pledgie-wrapper">';
|
|
|
|
$s .= '<label id="pledgie-label" for="pledgie-campaign">' . t('Pledgie campaign number to use for donations') . ' </label>';
|
|
|
|
$s .= '<input id="pledgie-campaign" type="text" name="pledgie-campaign" value="' . $campaign . '">';
|
|
|
|
$s .= '</div><div class="clear"></div>';
|
|
|
|
|
|
|
|
$s .= '<div id="pledgie-wrapper">';
|
|
|
|
$s .= '<label id="pledgie-label" for="pledgie-describe">' . t('Description of the Pledgie campaign') . ' </label>';
|
|
|
|
$s .= '<input id="pledgie-describe" type="text" name="pledgie-describe" value="' . $describe . '">';
|
|
|
|
$s .= '</div><div class="clear"></div>';
|
|
|
|
|
|
|
|
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="pledgie-submit" name="pledgie-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
|
|
|
|
|
|
|
|
return;
|
2015-02-12 16:29:43 +00:00
|
|
|
}
|
2015-05-13 20:28:09 +00:00
|
|
|
|
|
|
|
function pledgie_addon_settings_post(&$a,&$b) {
|
|
|
|
|
|
|
|
if(! is_site_admin())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if($_POST['pledgie-submit']) {
|
2017-11-06 23:55:24 +00:00
|
|
|
Config::set('pledgie-describe','text',trim(strip_tags($_POST['pledgie-describe'])));
|
|
|
|
Config::set('pledgie-campaign','text',trim(strip_tags($_POST['pledgie-campaign'])));
|
2015-05-13 20:28:09 +00:00
|
|
|
info( t('pledgie Settings saved.') . EOL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function pledgie_active(&$a,&$b) {
|
2017-11-06 23:55:24 +00:00
|
|
|
$campaign = Config::get('pledgie-campaign','text');
|
|
|
|
$describe = Config::get('pledgie-describe','text');
|
2015-05-18 20:21:38 +00:00
|
|
|
$b .= '<div style="position: fixed; padding:5px; border-style:dotted; border-width:1px; background-color: white; line-height: 1; bottom: 5px; left: 20px; z-index: 1000; width: 150px; font-size: 12px;">';
|
2017-03-20 07:38:50 +00:00
|
|
|
$b .= $describe . '<br/><a href="https://pledgie.com/campaigns/';
|
2015-05-13 20:28:09 +00:00
|
|
|
$b .= $campaign;
|
2017-03-20 07:38:50 +00:00
|
|
|
$b .= '"><img alt="Click here to lend your support to: ' . $describe . '!" src="https://pledgie.com/campaigns/';
|
2015-05-13 20:28:09 +00:00
|
|
|
$b .= $campaign;
|
2017-02-09 18:07:00 +00:00
|
|
|
$b .= '.png?skin_name=chrome" border="0" target="_blank" /></a></div>';
|
2017-02-09 14:52:50 +00:00
|
|
|
}
|