]> git.mxchange.org Git - friendica.git/blob - mod/friendica.php
Merge pull request #1037 from Beanow/feature/expose-profile-data
[friendica.git] / mod / friendica.php
1 <?php
2
3 function friendica_init(&$a) {
4         if ($a->argv[1]=="json"){
5                 $register_policy = Array('REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN');
6
7                 $sql_extra = '';
8                 if(x($a->config,'admin_nickname')) {
9                         $sql_extra = sprintf(" AND nickname = '%s' ",dbesc($a->config['admin_nickname']));
10                 }
11                 if (isset($a->config['admin_email']) && $a->config['admin_email']!=''){
12                         $adminlist = explode(",", str_replace(" ", "", $a->config['admin_email']));
13
14                         //$r = q("SELECT username, nickname FROM user WHERE email='%s' $sql_extra", dbesc($a->config['admin_email']));
15                         $r = q("SELECT username, nickname FROM user WHERE email='%s' $sql_extra", dbesc($adminlist[0]));
16                         $admin = array(
17                                 'name' => $r[0]['username'],
18                                 'profile'=> $a->get_baseurl().'/profile/'.$r[0]['nickname'],
19                         );
20                 } else {
21                         $admin = false;
22                 }
23
24                 $visible_plugins = array();
25                 if(is_array($a->plugins) && count($a->plugins)) {
26                         $r = q("select * from addon where hidden = 0");
27                         if(count($r))
28                                 foreach($r as $rr)
29                                         $visible_plugins[] = $rr['name'];
30                 }
31
32                 $data = Array(
33                         'version' => FRIENDICA_VERSION,
34                         'url' => z_root(),
35                         'plugins' => $visible_plugins,
36                         'register_policy' =>  $register_policy[$a->config['register_policy']],
37                         'admin' => $admin,
38                         'site_name' => $a->config['sitename'],
39                         'platform' => FRIENDICA_PLATFORM,
40                         'info' => ((x($a->config,'info')) ? $a->config['info'] : '')
41                 );
42
43                 echo json_encode($data);
44                 killme();
45         }
46 }
47
48
49
50 function friendica_content(&$a) {
51
52         $o = '';
53         $o .= '<h3>Friendica</h3>';
54
55
56         $o .= '<p></p><p>';
57
58         $o .= t('This is Friendica, version') . ' ' . FRIENDICA_VERSION . ' ';
59         $o .= t('running at web location') . ' ' . z_root() . '</p><p>';
60
61         $o .= t('Please visit <a href="http://friendica.com">Friendica.com</a> to learn more about the Friendica project.') . '</p><p>';        
62
63         $o .= t('Bug reports and issues: please visit') . ' ' . '<a href="https://github.com/friendica/friendica/issues?state=open">the bucktracker at github</a></p><p>';
64         $o .= t('Suggestions, praise, donations, etc. - please email "Info" at Friendica - dot com') . '</p>';
65
66         $o .= '<p></p>';
67
68         $visible_plugins = array();
69         if(is_array($a->plugins) && count($a->plugins)) {
70                 $r = q("select * from addon where hidden = 0");
71                 if(count($r))
72                         foreach($r as $rr)
73                                 $visible_plugins[] = $rr['name'];
74         }
75
76
77         if(count($visible_plugins)) {
78                 $o .= '<p>' . t('Installed plugins/addons/apps:') . '</p>';
79                 $sorted = $visible_plugins;
80                 $s = '';
81                 sort($sorted);
82                 foreach($sorted as $p) {
83                         if(strlen($p)) {
84                                 if(strlen($s)) $s .= ', ';
85                                 $s .= $p;
86                         }
87                 }
88                 $o .= '<div style="margin-left: 25px; margin-right: 25px;">' . $s . '</div>';
89         }
90         else
91                 $o .= '<p>' . t('No installed plugins/addons/apps') . '</p>';
92
93         call_hooks('about_hook', $o);   
94
95         return $o;
96
97 }