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