Issue 3873
[friendica-addons.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
10 use Friendica\Core\Config;
11
12 function webrtc_install() {
13         register_hook('app_menu', 'addon/webrtc/webrtc.php', 'webrtc_app_menu');
14 }
15
16 function webrtc_uninstall() {
17         unregister_hook('app_menu', 'addon/webrtc/webrtc.php', 'webrtc_app_menu');
18
19 }
20
21 function webrtc_app_menu($a,&$b) {
22         $b['app_menu'][] = '<div class="app-title"><a href="webrtc">' . t('WebRTC Videochat') . '</a></div>';
23 }
24
25 function webrtc_plugin_admin (&$a, &$o) {
26         $t = get_markup_template( "admin.tpl", "addon/webrtc/" );
27         $o = replace_macros( $t, array(
28             '$submit' => t('Save Settings'),
29             '$webrtcurl' => array('webrtcurl', t('WebRTC Base URL'), Config::get('webrtc','webrtcurl' ), t('Page your users will create a WebRTC chat room on. For example you could use https://live.mayfirst.org .')),
30         ));
31 }
32 function webrtc_plugin_admin_post (&$a) {
33         $url = ((x($_POST, 'webrtcurl')) ? notags(trim($_POST['webrtcurl'])) : '');
34             Config::set('webrtc', 'webrtcurl', $url);
35             info( t('Settings updated.'). EOL);
36 }
37
38 function webrtc_module() {
39         return;
40 }
41
42 function webrtc_content(&$a) {
43         $o = '';
44
45         /* landingpage to create chatrooms */
46         $webrtcurl = Config::get('webrtc','webrtcurl');
47
48         /* embedd the landing page in an iframe */
49         $o .= '<h2>'.t('Video Chat').'</h2>';
50         $o .= '<p>'.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>';
51         if ($webrtcurl == '') {
52             $o .= '<p>'.t('Please contact your friendica admin and send a reminder to configure the WebRTC addon.').'</p>';
53         } else {
54             $o .= '<iframe src="'.$webrtcurl.'" width="600px" height="600px"></iframe>';
55         }
56
57
58         return $o;
59 }
60 ?>