mirror of
https://github.com/Yetangitu/ampache
synced 2025-10-03 09:49:30 +02:00
Add new display_user_field plugin type ; Paypal and Flattr user donation plugin
This commit is contained in:
parent
ad64c4982b
commit
2837c44fe8
8 changed files with 255 additions and 8 deletions
|
@ -187,7 +187,7 @@ while(true)
|
||||||
$genre = $channel->get_genre();
|
$genre = $channel->get_genre();
|
||||||
// Send Shoutcast metadata on demand
|
// Send Shoutcast metadata on demand
|
||||||
if ($options['metadata']) {
|
if ($options['metadata']) {
|
||||||
fwrite($sock, "icy-notice1: " . AmpConfig::get('title') . "\r\n");
|
fwrite($sock, "icy-notice1: " . AmpConfig::get('site_title') . "\r\n");
|
||||||
fwrite($sock, "icy-name: " . $channel->name . "\r\n");
|
fwrite($sock, "icy-name: " . $channel->name . "\r\n");
|
||||||
if (!empty($genre)) {
|
if (!empty($genre)) {
|
||||||
fwrite($sock, "icy-genre: " . $genre . "\r\n");
|
fwrite($sock, "icy-genre: " . $genre . "\r\n");
|
||||||
|
|
|
@ -36,4 +36,5 @@ should be implemented as a public method:
|
||||||
get_song_preview(string $track_mbid, string $artist_name, string $title)
|
get_song_preview(string $track_mbid, string $artist_name, string $title)
|
||||||
stream_song_preview(string $file)
|
stream_song_preview(string $file)
|
||||||
display_home()
|
display_home()
|
||||||
external_share(string $url, string $text);
|
external_share(string $url, string $text)
|
||||||
|
display_user_field(User $user, library_item $libitem = null)
|
|
@ -86,9 +86,9 @@ $(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
$("body").delegate("form", "submit", function(e) {
|
$("body").delegate("form", "submit", function(e) {
|
||||||
// We do not support ajax post with files or login form
|
// We do not support ajax post with files or login form, neither specific target
|
||||||
var $file = $(this).find("input[type=file]");
|
var $file = $(this).find("input[type=file]");
|
||||||
if ($(this).attr('name') !== 'login' && (!$file || !$file.val() || $file.val() === "")) {
|
if ($(this).attr('name') !== 'login' && (!$file || !$file.val() || $file.val() === "") && ($(this).attr('target') === undefined || $(this).attr('target') === '')) {
|
||||||
var postData = $(this).serializeArray();
|
var postData = $(this).serializeArray();
|
||||||
var formURL = $(this).attr("action");
|
var formURL = $(this).attr("action");
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -2368,7 +2368,7 @@ msgstr "Se désabonner"
|
||||||
|
|
||||||
#: ../../lib/class/user.class.php:1488
|
#: ../../lib/class/user.class.php:1488
|
||||||
msgid "Follow"
|
msgid "Follow"
|
||||||
msgstr "suivre"
|
msgstr "S'abonner"
|
||||||
|
|
||||||
#: ../../lib/class/video.class.php:760
|
#: ../../lib/class/video.class.php:760
|
||||||
msgid "Afar"
|
msgid "Afar"
|
||||||
|
@ -5171,7 +5171,7 @@ msgstr "Éditer l'album"
|
||||||
#: ../../templates/show_song_row.inc.php:32
|
#: ../../templates/show_song_row.inc.php:32
|
||||||
#: ../../templates/show_video_row.inc.php:37
|
#: ../../templates/show_video_row.inc.php:37
|
||||||
msgid "Play next"
|
msgid "Play next"
|
||||||
msgstr "Lecture à la suite"
|
msgstr "Jouer à la suite"
|
||||||
|
|
||||||
#: ../../templates/show_album_row.inc.php:54
|
#: ../../templates/show_album_row.inc.php:54
|
||||||
#: ../../templates/show_artist_row.inc.php:54
|
#: ../../templates/show_artist_row.inc.php:54
|
||||||
|
@ -7675,7 +7675,7 @@ msgstr "Envoyer un message privé"
|
||||||
|
|
||||||
#: ../../templates/show_user.inc.php:54
|
#: ../../templates/show_user.inc.php:54
|
||||||
msgid "Member Since"
|
msgid "Member Since"
|
||||||
msgstr "Membre Depuis"
|
msgstr "Membre depuis"
|
||||||
|
|
||||||
#: ../../templates/show_user.inc.php:57 ../../templates/show_users.inc.php:44
|
#: ../../templates/show_user.inc.php:57 ../../templates/show_users.inc.php:44
|
||||||
#: ../../templates/show_users.inc.php:75
|
#: ../../templates/show_users.inc.php:75
|
||||||
|
|
105
modules/plugins/Flattr.plugin.php
Normal file
105
modules/plugins/Flattr.plugin.php
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
<?php
|
||||||
|
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* LICENSE: GNU General Public License, version 2 (GPLv2)
|
||||||
|
* Copyright 2001 - 2015 Ampache.org
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License v2
|
||||||
|
* as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class AmpacheFlattr {
|
||||||
|
public $name = 'Flattr';
|
||||||
|
public $categories = 'user';
|
||||||
|
public $description = 'Flattr donation button on user page';
|
||||||
|
public $url = '';
|
||||||
|
public $version = '000001';
|
||||||
|
public $min_ampache = '370034';
|
||||||
|
public $max_ampache = '999999';
|
||||||
|
|
||||||
|
// These are internal settings used by this class, run this->load to
|
||||||
|
// fill them out
|
||||||
|
private $user_id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* This function does nothing...
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* install
|
||||||
|
* This is a required plugin function. It inserts our preferences
|
||||||
|
* into Ampache
|
||||||
|
*/
|
||||||
|
public function install() {
|
||||||
|
// Check and see if it's already installed
|
||||||
|
if (Preference::exists('flattr_user_id')) { return false; }
|
||||||
|
|
||||||
|
Preference::insert('flattr_user_id','Flattr User ID','',25,'string','plugins');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* uninstall
|
||||||
|
* This is a required plugin function. It removes our preferences from
|
||||||
|
* the database returning it to its original form
|
||||||
|
*/
|
||||||
|
public function uninstall() {
|
||||||
|
Preference::delete('flattr_user_id');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* upgrade
|
||||||
|
* This is a recommended plugin function
|
||||||
|
*/
|
||||||
|
public function upgrade() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* display_user_field
|
||||||
|
* This display the module in user page
|
||||||
|
*/
|
||||||
|
public function display_user_field(User $user, library_item $libitem = null) {
|
||||||
|
$name = ($libitem != null) ? $libitem->get_fullname() : (T_('User') . " `" . $user->fullname . "` " . T_('on') . " " . AmpConfig::get('site_title'));
|
||||||
|
$link = ($libitem != null && $libitem->link) ? $libitem->link : $user->link;
|
||||||
|
|
||||||
|
echo "<a rel='nohtml' href='https://flattr.com/submit/auto?user_id=" . scrub_out($this->user_id) . "&url=" . rawurlencode($link) . "&category=audio&title=" . rawurlencode($name) . "' target='_blank'><img src='//button.flattr.com/flattr-badge-large.png' alt='Flattr this' title='Flattr this' border='0'></a>";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load
|
||||||
|
* This loads up the data we need into this object, this stuff comes
|
||||||
|
* from the preferences.
|
||||||
|
*/
|
||||||
|
public function load($user) {
|
||||||
|
$user->set_preferences();
|
||||||
|
$data = $user->prefs;
|
||||||
|
|
||||||
|
$this->user_id = trim($data['flattr_user_id']);
|
||||||
|
if (!strlen($this->user_id)) {
|
||||||
|
debug_event($this->name,'No Flattr User ID, user field plugin skipped','3');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
124
modules/plugins/Paypal.plugin.php
Normal file
124
modules/plugins/Paypal.plugin.php
Normal file
|
@ -0,0 +1,124 @@
|
||||||
|
<?php
|
||||||
|
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* LICENSE: GNU General Public License, version 2 (GPLv2)
|
||||||
|
* Copyright 2001 - 2015 Ampache.org
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License v2
|
||||||
|
* as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class AmpachePaypal {
|
||||||
|
public $name = 'Paypal';
|
||||||
|
public $categories = 'user';
|
||||||
|
public $description = 'Paypal donation button on user page';
|
||||||
|
public $url = '';
|
||||||
|
public $version = '000001';
|
||||||
|
public $min_ampache = '370034';
|
||||||
|
public $max_ampache = '999999';
|
||||||
|
|
||||||
|
// These are internal settings used by this class, run this->load to
|
||||||
|
// fill them out
|
||||||
|
private $business;
|
||||||
|
private $currency_code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* This function does nothing...
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* install
|
||||||
|
* This is a required plugin function. It inserts our preferences
|
||||||
|
* into Ampache
|
||||||
|
*/
|
||||||
|
public function install() {
|
||||||
|
// Check and see if it's already installed
|
||||||
|
if (Preference::exists('paypal_business')) { return false; }
|
||||||
|
|
||||||
|
Preference::insert('paypal_business','Paypal ID','',25,'string','plugins');
|
||||||
|
Preference::insert('paypal_currency_code','Paypal Currency Code','USD',25,'string','plugins');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* uninstall
|
||||||
|
* This is a required plugin function. It removes our preferences from
|
||||||
|
* the database returning it to its original form
|
||||||
|
*/
|
||||||
|
public function uninstall() {
|
||||||
|
Preference::delete('paypal_business');
|
||||||
|
Preference::delete('paypal_currency_code');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* upgrade
|
||||||
|
* This is a recommended plugin function
|
||||||
|
*/
|
||||||
|
public function upgrade() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* display_user_field
|
||||||
|
* This display the module in user page
|
||||||
|
*/
|
||||||
|
public function display_user_field(User $user, library_item $libitem = null) {
|
||||||
|
$name = ($libitem != null) ? $libitem->get_fullname() : (T_('User') . " `" . $user->fullname . "` " . T_('on') . " " . AmpConfig::get('site_title'));
|
||||||
|
$lang = substr(AmpConfig::get('lang'), 0, 2);
|
||||||
|
if (empty($lang)) $lang = 'US';
|
||||||
|
|
||||||
|
echo "<form action='https://www.paypal.com/cgi-bin/webscr' method='post' target='_top'>";
|
||||||
|
echo "<input type='hidden' name='cmd' value='_donations'>";
|
||||||
|
echo "<input type='hidden' name='business' value='" . scrub_out($this->business) . "'>";
|
||||||
|
echo "<input type='hidden' name='lc' value='" . $lang . "'>";
|
||||||
|
echo "<input type='hidden' name='item_name' value='" . $name . "'>";
|
||||||
|
echo "<input type='hidden' name='no_note' value='0'>";
|
||||||
|
echo "<input type='hidden' name='currency_code' value='" . scrub_out($this->currency_code) . "'>";
|
||||||
|
echo "<input type='hidden' name='bn' value='PP-DonationsBF:btn_donate_SM.gif:NonHostedGuest'>";
|
||||||
|
echo "<input type='image' src='https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif' border='0' name='submit' alt='PayPal - The safer, easier way to pay online!'>";
|
||||||
|
echo "<img alt='' border='0' src='https://www.paypalobjects.com/fr_XC/i/scr/pixel.gif' width='1' height='1'>";
|
||||||
|
echo "</form>";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load
|
||||||
|
* This loads up the data we need into this object, this stuff comes
|
||||||
|
* from the preferences.
|
||||||
|
*/
|
||||||
|
public function load($user) {
|
||||||
|
$user->set_preferences();
|
||||||
|
$data = $user->prefs;
|
||||||
|
|
||||||
|
$this->business = trim($data['paypal_business']);
|
||||||
|
if (!strlen($this->business)) {
|
||||||
|
debug_event($this->name,'No Paypal ID, user field plugin skipped','3');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->currency_code = trim($data['paypal_currency_code']);
|
||||||
|
if (!strlen($this->currency_code)) {
|
||||||
|
$this->currency_code = 'USD';
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,7 +31,24 @@ if ($client->f_avatar) {
|
||||||
echo $client->f_avatar . "<br /><br />";
|
echo $client->f_avatar . "<br /><br />";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<?php echo $client->get_display_follow(); ?>
|
<?php if (AmpConfig::get('sociable')) {
|
||||||
|
echo $client->get_display_follow();
|
||||||
|
|
||||||
|
$plugins = Plugin::get_plugins('display_user_field');
|
||||||
|
?>
|
||||||
|
<ul id="plugins_user_field">
|
||||||
|
<?php
|
||||||
|
foreach ($plugins as $plugin_name) {
|
||||||
|
$plugin = new Plugin($plugin_name);
|
||||||
|
if ($plugin->load($GLOBALS['user'])) {
|
||||||
|
?>
|
||||||
|
<li><?php $plugin->_plugin->display_user_field($client); ?> </li>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</ul>
|
||||||
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
<dl class="media_details">
|
<dl class="media_details">
|
||||||
<?php $rowparity = UI::flip_class(); ?>
|
<?php $rowparity = UI::flip_class(); ?>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue