diff --git a/batch.php b/batch.php index 6096512f..7522dbd4 100644 --- a/batch.php +++ b/batch.php @@ -21,7 +21,16 @@ */ if (!defined('NO_SESSION')) { - require_once 'lib/init.php'; + if (isset($_REQUEST['ssid'])) { + define('NO_SESSION', 1); + require_once 'lib/init.php'; + if (!Session::exists('stream', $_REQUEST['ssid'])) { + UI::access_denied(); + exit; + } + } else { + require_once 'lib/init.php'; + } } ob_end_clean(); diff --git a/docs/PLUGINS b/docs/PLUGINS index fb3ec998..674defc5 100644 --- a/docs/PLUGINS +++ b/docs/PLUGINS @@ -36,3 +36,4 @@ should be implemented as a public method: get_song_preview(string $track_mbid, string $artist_name, string $title) stream_song_preview(string $file) display_home() + external_share(string $url, string $text); diff --git a/images/icon_share_facebook.png b/images/icon_share_facebook.png new file mode 100644 index 00000000..3053f26c Binary files /dev/null and b/images/icon_share_facebook.png differ diff --git a/images/icon_share_googleplus.png b/images/icon_share_googleplus.png new file mode 100644 index 00000000..be37ca85 Binary files /dev/null and b/images/icon_share_googleplus.png differ diff --git a/images/icon_share_twitter.png b/images/icon_share_twitter.png new file mode 100644 index 00000000..be32e128 Binary files /dev/null and b/images/icon_share_twitter.png differ diff --git a/lib/class/share.class.php b/lib/class/share.class.php index bf5040ac..15ae2272 100644 --- a/lib/class/share.class.php +++ b/lib/class/share.class.php @@ -36,6 +36,7 @@ class Share extends database_object public $secret; public $public_url; + public $f_name; public $f_object_link; public $f_user; public $f_allow_stream; @@ -199,6 +200,7 @@ class Share extends database_object if ($details) { $object = new $this->object_type($this->object_id); $object->format(); + $this->f_name = $object->get_fullname(); $this->f_object_link = $object->f_link; $user = new User($this->user); $this->f_user = $user->fullname; @@ -305,4 +307,43 @@ class Share extends database_object return $is_shared; } + public static function display_ui($object_type, $object_id, $show_text = true) + { + echo "" . UI::get_icon('share', T_('Share')); + if ($show_text) { + echo "  " . T_('Share'); + } + echo ""; + } + + public static function display_ui_links($object_type, $object_id) + { + echo ""; + } + } // end of recommendation class diff --git a/lib/javascript/dynamicpage.js b/lib/javascript/dynamicpage.js index 2ff7c412..c2012a87 100644 --- a/lib/javascript/dynamicpage.js +++ b/lib/javascript/dynamicpage.js @@ -39,7 +39,7 @@ $(function() { $("body").delegate("a", "click", function() { var link = $(this).attr("href"); - if (link != "" && link.indexOf("javascript:") != 0 && link != "#" && link != undefined && $(this).attr("onclick") == undefined && $(this).attr("rel") != "nohtml" && $(this).attr("target") != "_blank") { + if (link !== undefined && link != "" && link.indexOf("javascript:") != 0 && link != "#" && link != undefined && $(this).attr("onclick") == undefined && $(this).attr("rel") != "nohtml" && $(this).attr("target") != "_blank") { if ($(this).attr("rel") != "prettyPhoto") { // Ajax load Ampache pages only if (link.indexOf(jsWebPath) > -1) { diff --git a/lib/javascript/tools.js b/lib/javascript/tools.js index ebb25df7..fc07ca55 100644 --- a/lib/javascript/tools.js +++ b/lib/javascript/tools.js @@ -138,6 +138,61 @@ function handleBroadcastAction(url, id) { $("#broadcastsdialog").dialog("close"); } +/************************************************************/ +/* Dialog selection to start a broadcast */ +/************************************************************/ + +var closeshare; +function showShareDialog(e, object_type, object_id) { + $("#sharedialog").dialog("close"); + + var parent = this; + parent.contentUrl = jsAjaxServer + '/ajax.server.php?page=browse&action=get_share_links&object_type=' + object_type + '&object_id=' + object_id; + parent.editDialogId = '
'; + + $(parent.editDialogId).dialog({ + modal: true, + dialogClass: 'sharedialogstyle', + resizable: false, + draggable: false, + width: 200, + height: 90, + autoOpen: false, + open: function () { + closeshare = 1; + $(document).bind('dblclick', shoverlayclickclose); + $(this).load(parent.contentUrl, function() { + $('#sharedialog').focus(); + }); + }, + focus: function() { + closeshare = 0; + }, + close: function (e) { + $(document).unbind('click'); + $(this).empty(); + $(this).dialog("destroy"); + } + }); + + $("#sharedialog").dialog("option", "position", [e.clientX + 10, e.clientY]); + $("#sharedialog").dialog("open"); + closeshare = 0; +} + +function shoverlayclickclose(e) { + if (closeshare) { + $("#sharedialog").dialog("close"); + } + closeshare = 1; +} + +function handleShareAction(url, id) { + ajaxPut(url, id); + $("#sharedialog").dialog("close"); +} + + /***************************************************/ /* Edit modal dialog for artists, albums and songs */ /***************************************************/ diff --git a/modules/plugins/Facebook.plugin.php b/modules/plugins/Facebook.plugin.php new file mode 100644 index 00000000..0e532b8a --- /dev/null +++ b/modules/plugins/Facebook.plugin.php @@ -0,0 +1,88 @@ +set_preferences(); + $data = $user->prefs; + + return true; + } // load +} diff --git a/modules/plugins/GooglePlus.plugin.php b/modules/plugins/GooglePlus.plugin.php new file mode 100644 index 00000000..4b24f629 --- /dev/null +++ b/modules/plugins/GooglePlus.plugin.php @@ -0,0 +1,88 @@ +set_preferences(); + $data = $user->prefs; + + return true; + } // load +} diff --git a/modules/plugins/Twitter.plugin.php b/modules/plugins/Twitter.plugin.php new file mode 100644 index 00000000..95bd5203 --- /dev/null +++ b/modules/plugins/Twitter.plugin.php @@ -0,0 +1,91 @@ +set_preferences(); + $data = $user->prefs; + + return true; + } // load +} diff --git a/server/browse.ajax.php b/server/browse.ajax.php index 2af54da1..ea648b51 100644 --- a/server/browse.ajax.php +++ b/server/browse.ajax.php @@ -187,6 +187,15 @@ switch ($_REQUEST['action']) { $browse->show_objects(); $results[$browse->get_content_div()] = ob_get_clean(); break; + case 'get_share_links': + $object_type = $_REQUEST['object_type']; + $object_id = intval($_REQUEST['object_id']); + + if (Core::is_library_item($object_type) && $object_id > 0) { + Share::display_ui_links($object_type, $object_id); + exit; + } + break; default: $results['rfc3514'] = '0x1'; break; diff --git a/share.php b/share.php index de335c25..07129f76 100644 --- a/share.php +++ b/share.php @@ -108,6 +108,30 @@ switch ($action) { } UI::show_footer(); exit; + case 'external_share': + if (AmpConfig::get('demo_mode')) { + UI::access_denied(); + exit; + } + + $plugin = new Plugin($_GET['plugin']); + if (!$plugin) { + UI::access_denied('Access Denied - Unkown external share plugin.'); + exit; + } + $plugin->load($GLOBALS['user']); + + $type = $_REQUEST['type']; + $id = $_REQUEST['id']; + $allow_download = (($type == 'song' && Access::check_function('download')) || Access::check_function('batch_download')); + $secret = Share::generate_secret(); + + $share_id = Share::create_share($type, $id, true, $allow_download, AmpConfig::get('share_expire'), $secret, 0); + $share = new Share($share_id); + $share->format(true); + + header("Location: " . $plugin->_plugin->external_share($share->public_url, $share->f_name)); + exit; } /** diff --git a/templates/jquery-editdialog.css b/templates/jquery-editdialog.css index 7f8ea73e..860c285c 100644 --- a/templates/jquery-editdialog.css +++ b/templates/jquery-editdialog.css @@ -254,4 +254,65 @@ .broadcastsdialogstyle.ui-dialog .ui-dialog-buttonset button:focus:active { display: none; +} + +/*********************************************** + jQuery share dialog +***********************************************/ +.sharedialogstyle.ui-dialog { + background-color: #222; + font-size: 10px; + overflow-x: hidden; + overflow-y: auto; + padding: 0; + margin: 0; + width: 100%; + height: 100%; + border-radius: 2px; + border-color: #1d1d1d; + border: 2px solid rgba(0,0,0,0.15); + z-index: 9999; +} + +.sharedialogstyle.ui-widget-content a { + background-color: #222; + color: #eee; + text-decoration: none; + text-align: left; + padding: 0.4em; +} + +.sharedialogstyle.ui-widget-content a:hover { + color: #ff9d00; + cursor: pointer; +} + +.sharedialogstyle.ui-dialog .ui-dialog-titlebar { + display: none; +} + +.sharedialogstyle.ui-dialog .ui-dialog-title { + display: none; +} + +.sharedialogstyle.ui-dialog .ui-dialog-content { + background-color: #222; + color: #999; + border: 0; +} + +.sharedialogstyle.ui-dialog .ui-dialog-buttonpane { + display: none; +} + +.sharedialogstyle.ui-dialog .ui-dialog-buttonset button { + display: none; +} + +.sharedialogstyle.ui-dialog .ui-dialog-buttonset button:hover { + display: none; +} + +.sharedialogstyle.ui-dialog .ui-dialog-buttonset button:focus:active { + display: none; } \ No newline at end of file diff --git a/templates/show_album.inc.php b/templates/show_album.inc.php index 36d1c32e..a58a5529 100644 --- a/templates/show_album.inc.php +++ b/templates/show_album.inc.php @@ -105,8 +105,7 @@ if (AmpConfig::get('show_played_times')) {
  • - - + id); ?>
  • diff --git a/templates/show_album_group_disks.inc.php b/templates/show_album_group_disks.inc.php index 5608e708..cd302060 100644 --- a/templates/show_album_group_disks.inc.php +++ b/templates/show_album_group_disks.inc.php @@ -125,7 +125,7 @@ if ($directplay_limit > 0) { - + id, false); ?> diff --git a/templates/show_album_row.inc.php b/templates/show_album_row.inc.php index 72701724..02aae411 100644 --- a/templates/show_album_row.inc.php +++ b/templates/show_album_row.inc.php @@ -73,7 +73,7 @@ if (Art::is_enabled()) { allow_group_disks || ($libitem->allow_group_disks && !count($libitem->album_suite)))) { ?> - + id, false); ?> diff --git a/templates/show_playlist_row.inc.php b/templates/show_playlist_row.inc.php index f55f8842..be687408 100644 --- a/templates/show_playlist_row.inc.php +++ b/templates/show_playlist_row.inc.php @@ -62,7 +62,7 @@ - + id, false); ?> has_access()) { ?> diff --git a/templates/show_playlist_song_row.inc.php b/templates/show_playlist_song_row.inc.php index 8668c1b6..49b988af 100644 --- a/templates/show_playlist_song_row.inc.php +++ b/templates/show_playlist_song_row.inc.php @@ -62,7 +62,7 @@ - + id, false); ?> has_access()) { ?> diff --git a/templates/show_song.inc.php b/templates/show_song.inc.php index 4d08befd..6a6f4087 100644 --- a/templates/show_song.inc.php +++ b/templates/show_song.inc.php @@ -72,7 +72,7 @@ $button_flip_state_id = 'button_flip_state_' . $song->id; - + id, false); ?> diff --git a/templates/show_song_row.inc.php b/templates/show_song_row.inc.php index 7cfc4a7f..141ee8e9 100644 --- a/templates/show_song_row.inc.php +++ b/templates/show_song_row.inc.php @@ -65,7 +65,7 @@ - + id, false); ?> diff --git a/templates/show_video.inc.php b/templates/show_video.inc.php index c83e79ba..8f13904e 100644 --- a/templates/show_video.inc.php +++ b/templates/show_video.inc.php @@ -85,7 +85,7 @@ foreach ($subtitles as $subtitle) { - + id, false); ?> diff --git a/templates/show_video_row.inc.php b/templates/show_video_row.inc.php index 5b54ae16..42919e37 100644 --- a/templates/show_video_row.inc.php +++ b/templates/show_video_row.inc.php @@ -77,7 +77,7 @@ if ($video_type != 'video') { - + id, false); ?>