]> git.mxchange.org Git - friendica.git/blob - include/contact_selectors.php
Merge remote-tracking branch 'upstream/develop' into develop
[friendica.git] / include / contact_selectors.php
1 <?php
2
3 use Friendica\Database\DBM;
4 use Friendica\Protocol\Diaspora;
5
6 function contact_profile_assign($current,$foreign_net) {
7
8         $o = '';
9
10         $disabled = (($foreign_net) ? ' disabled="true" ' : '');
11
12         $o .= "<select id=\"contact-profile-selector\" class=\"form-control\" $disabled name=\"profile-assign\" >\r\n";
13
14         $r = q("SELECT `id`, `profile-name`, `is-default` FROM `profile` WHERE `uid` = %d",
15                         intval($_SESSION['uid']));
16
17         if (DBM::is_result($r)) {
18                 foreach ($r as $rr) {
19                         $selected = (($rr['id'] == $current || ($current == 0 && $rr['is-default'] == 1)) ? " selected=\"selected\" " : "");
20                         $o .= "<option value=\"{$rr['id']}\" $selected >{$rr['profile-name']}</option>\r\n";
21                 }
22         }
23         $o .= "</select>\r\n";
24         return $o;
25 }
26
27
28 function contact_reputation($current) {
29
30         $o = '';
31         $o .= "<select id=\"contact-reputation-selector\" name=\"reputation\" />\r\n";
32
33         $rep = array(
34                 0 => t('Unknown | Not categorised'),
35                 1 => t('Block immediately'),
36                 2 => t('Shady, spammer, self-marketer'),
37                 3 => t('Known to me, but no opinion'),
38                 4 => t('OK, probably harmless'),
39                 5 => t('Reputable, has my trust')
40         );
41
42         foreach ($rep as $k => $v) {
43                 $selected = (($k == $current) ? " selected=\"selected\" " : "");
44                 $o .= "<option value=\"$k\" $selected >$v</option>\r\n";
45         }
46         $o .= "</select>\r\n";
47         return $o;
48 }
49
50
51 function contact_poll_interval($current, $disabled = false) {
52
53         $dis = (($disabled) ? ' disabled="disabled" ' : '');
54         $o = '';
55         $o .= "<select id=\"contact-poll-interval\" name=\"poll\" $dis />" . "\r\n";
56
57         $rep = array(
58                 0 => t('Frequently'),
59                 1 => t('Hourly'),
60                 2 => t('Twice daily'),
61                 3 => t('Daily'),
62                 4 => t('Weekly'),
63                 5 => t('Monthly')
64         );
65
66         foreach ($rep as $k => $v) {
67                 $selected = (($k == $current) ? " selected=\"selected\" " : "");
68                 $o .= "<option value=\"$k\" $selected >$v</option>\r\n";
69         }
70         $o .= "</select>\r\n";
71         return $o;
72 }
73
74
75 function network_to_name($s, $profile = "") {
76
77         $nets = array(
78                 NETWORK_DFRN     => t('Friendica'),
79                 NETWORK_OSTATUS  => t('OStatus'),
80                 NETWORK_FEED     => t('RSS/Atom'),
81                 NETWORK_MAIL     => t('Email'),
82                 NETWORK_DIASPORA => t('Diaspora'),
83                 NETWORK_FACEBOOK => t('Facebook'),
84                 NETWORK_ZOT      => t('Zot!'),
85                 NETWORK_LINKEDIN => t('LinkedIn'),
86                 NETWORK_XMPP     => t('XMPP/IM'),
87                 NETWORK_MYSPACE  => t('MySpace'),
88                 NETWORK_GPLUS    => t('Google+'),
89                 NETWORK_PUMPIO   => t('pump.io'),
90                 NETWORK_TWITTER  => t('Twitter'),
91                 NETWORK_DIASPORA2 => t('Diaspora Connector'),
92                 NETWORK_STATUSNET => t('GNU Social Connector'),
93                 NETWORK_PNUT      => t('pnut'),
94                 NETWORK_APPNET => t('App.net')
95         );
96
97         call_hooks('network_to_name', $nets);
98
99         $search  = array_keys($nets);
100         $replace = array_values($nets);
101
102         $networkname = str_replace($search, $replace, $s);
103
104         if ((in_array($s, array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) && ($profile != "")) {
105                 $r = dba::fetch_first("SELECT `gserver`.`platform` FROM `gcontact`
106                                 INNER JOIN `gserver` ON `gserver`.`nurl` = `gcontact`.`server_url`
107                                 WHERE `gcontact`.`nurl` = ? AND `platform` != ''", normalise_link($profile));
108
109                 if (DBM::is_result($r)) {
110                         $networkname = $r['platform'];
111                 }
112         }
113
114         return $networkname;
115 }