Unneeded "info" messages removed
[friendica-addons.git/.git] / webrtc / webrtc.php
1 <?php
2 /*
3  * Name: WebRTC Application
4  * Description: add a webrtc instance for video/audio
5  * Version: 1.0
6  * Author: Stephen Mahood <https://friends.mayfirst.org/profile/marxistvegan>
7  * Author: Tobias Diekershoff <https://f.diekershoff.de/profile/tobias>
8  */
9 use Friendica\Core\Hook;
10 use Friendica\Core\Renderer;
11 use Friendica\DI;
12 use Friendica\Util\Strings;
13
14 function webrtc_install() {
15         Hook::register('app_menu', 'addon/webrtc/webrtc.php', 'webrtc_app_menu');
16 }
17
18 function webrtc_uninstall() {
19         Hook::unregister('app_menu', 'addon/webrtc/webrtc.php', 'webrtc_app_menu');
20
21 }
22
23 function webrtc_app_menu($a,&$b) {
24         $b['app_menu'][] = '<div class="app-title"><a href="webrtc">' . DI::l10n()->t('WebRTC Videochat') . '</a></div>';
25 }
26
27 function webrtc_addon_admin (&$a, &$o) {
28         $t = Renderer::getMarkupTemplate( "admin.tpl", "addon/webrtc/" );
29         $o = Renderer::replaceMacros( $t, [
30             '$submit' => DI::l10n()->t('Save Settings'),
31             '$webrtcurl' => ['webrtcurl', DI::l10n()->t('WebRTC Base URL'), DI::config()->get('webrtc','webrtcurl' ), DI::l10n()->t('Page your users will create a WebRTC chat room on. For example you could use https://live.mayfirst.org .')],
32         ]);
33 }
34 function webrtc_addon_admin_post (&$a) {
35         $url = (!empty($_POST['webrtcurl']) ? Strings::escapeTags(trim($_POST['webrtcurl'])) : '');
36             DI::config()->set('webrtc', 'webrtcurl', $url);
37 }
38
39 function webrtc_module() {
40         return;
41 }
42
43 function webrtc_content(&$a) {
44         $o = '';
45
46         /* landingpage to create chatrooms */
47         $webrtcurl = DI::config()->get('webrtc','webrtcurl');
48
49         /* embedd the landing page in an iframe */
50         $o .= '<h2>'.DI::l10n()->t('Video Chat').'</h2>';
51         $o .= '<p>'.DI::l10n()->t('WebRTC is a video and audio conferencing tool that works with Firefox (version 21 and above) and Chrome/Chromium (version 25 and above). Just create a new chat room and send the link to someone you want to chat with.').'</p>';
52         if ($webrtcurl == '') {
53             $o .= '<p>'.DI::l10n()->t('Please contact your friendica admin and send a reminder to configure the WebRTC addon.').'</p>';
54         } else {
55             $o .= '<iframe src="'.$webrtcurl.'" width="600px" height="600px"></iframe>';
56         }
57
58
59         return $o;
60 }
61 ?>