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