]> git.mxchange.org Git - friendica-addons.git/blob - impressum/impressum.php
Friendika -> Friendika (impressum)
[friendica-addons.git] / impressum / impressum.php
1 <?php
2 /**
3  * Name: Impressum
4  * Description: Plugin to add contact information to the about page (/friendica)
5  * Version: 1.0
6  * Author: Tobias Diekershoff <https://diekershoff.homeunix.net/friendika/profile/tobias>
7  * License: 3-clause BSD license
8  */
9
10 function impressum_install() {
11     register_hook('about_hook', 'addon/impressum/impressum.php', 'impressum_show');
12     logger("installed impressum plugin");
13 }
14
15 function impressum_uninstall() {
16     unregister_hook('about_hook', 'addon/impressum/impressum.php', 'impressum_show');
17     logger("uninstalled impressum plugin");
18 }
19 function obfuscate_email ($s) {
20     $s = str_replace('@','(at)',$s);
21     $s = str_replace('.','(dot)',$s);
22     return $s;
23 }
24 function impressum_show($a,&$b) {
25     $b .= '<h3>'.t('Impressum').'</h3>';
26     $owner = get_config('impressum', 'owner');
27     $owner_profile = get_config('impressum','ownerprofile');
28     $postal = get_config('impressum', 'postal');
29     $notes = get_config('impressum', 'notes');
30     $email = obfuscate_email( get_config('impressum','email') );
31     if (strlen($owner)) {
32         if (strlen($owner_profile)) {
33             $tmp = '<a href="'.$owner_profile.'">'.$owner.'</a>';
34         } else {
35             $tmp = $owner;
36         }
37         if (strlen($email)) {
38             $b .= '<p><strong>'.t('Site Owner').'</strong>: '. $tmp .'<br /><strong>'.t('Email Address').'</strong>: '.$email.'</p>';
39         } else {
40             $b .= '<p><strong>'.t('Site Owner').'</strong>: '. $tmp .'</p>';
41         }
42         if (strlen($postal)) {
43             $b .= '<p><strong>'.t('Postal Address').'</strong><br />'. $postal .'</p>';
44         }
45         if (strlen($notes)) {
46             $b .= '<p>'.$notes.'</p>';
47         }
48     } else {
49         $b .= '<p>'.t('The impressum addon needs to be configured!<br />Please add at least the <tt>owner</tt> variable to your config file. For other variables please refer to the README file of the addon.').'</p>';
50     }
51 }
52
53 function impressum_plugin_admin_post (&$a) {
54     $owner = ((x($_POST, 'owner')) ? notags(trim($_POST['owner'])) : '');
55     $ownerprofile = ((x($_POST, 'ownerprofile')) ? notags(trim($_POST['ownerprofile'])) : '');
56     $postal = ((x($_POST, 'postal')) ? (trim($_POST['postal'])) : '');
57     $notes = ((x($_POST, 'notes')) ? (trim($_POST['notes'])) : '');
58     $email = ((x($_POST, 'email')) ? notags(trim($_POST['email'])) : '');
59     set_config('impressum','owner',$owner);
60     set_config('impressum','ownerprofile',$ownerprofile);
61     set_config('impressum','postal',$postal);
62     set_config('impressum','email',$email);
63     set_config('impressum','notes',$notes);
64     info( t('Settings updated.'). EOL );
65 }
66 function impressum_plugin_admin (&$a, &$o) {
67     $t = file_get_contents( dirname(__file__). "/admin.tpl" );
68     $o = replace_macros($t, array(
69         '$submit' => t('Submit'),
70         '$owner' => array('owner', t('Site Owner'), get_config('impressum','owner'), ''),
71         '$ownerprofile' => array('ownerprofile', t('Site Owners Profile'), get_config('impressum','ownerprofile'), ''),
72         '$postal' => array('postal', t('Postal Address'), get_config('impressum','postal'), ''),
73         '$notes' => array('notes', t('Notes'), get_config('impressum','notes'), ''),
74         '$email' => array('email', t('Email Address'), get_config('impressum','email'), ''),
75     ));
76 }