]> git.mxchange.org Git - friendica.git/blobdiff - include/contact_selectors.php
Merge pull request #2686 from rabuzarus/2107-contact_edit
[friendica.git] / include / contact_selectors.php
index 1303acf74a13a1788930997dd8953c61e8752a79..35c9d983d72797f49ac49f46da496d93d1bfed48 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-
+require_once('include/diaspora.php');
 
 function contact_profile_assign($current,$foreign_net) {
 
@@ -7,10 +7,10 @@ function contact_profile_assign($current,$foreign_net) {
 
        $disabled = (($foreign_net) ? ' disabled="true" ' : '');
 
-       $o .= "<select id=\"contact-profile-selector\" $disabled name=\"profile-assign\" />\r\n";
+       $o .= "<select id=\"contact-profile-selector\" class=\"form-control\" $disabled name=\"profile-assign\" />\r\n";
 
        $r = q("SELECT `id`, `profile-name` FROM `profile` WHERE `uid` = %d",
-                        intval($_SESSION['uid']));
+                       intval($_SESSION['uid']));
 
        if(count($r)) {
                foreach($r as $rr) {
@@ -70,11 +70,45 @@ function contact_poll_interval($current, $disabled = false) {
 }
 
 
-function network_to_name($s) {
+function network_to_name($s, $profile = "") {
+
+       $nets = array(
+               NETWORK_DFRN     => t('Friendica'),
+               NETWORK_OSTATUS  => t('OStatus'),
+               NETWORK_FEED     => t('RSS/Atom'),
+               NETWORK_MAIL     => t('Email'),
+               NETWORK_DIASPORA => t('Diaspora'),
+               NETWORK_FACEBOOK => t('Facebook'),
+               NETWORK_ZOT      => t('Zot!'),
+               NETWORK_LINKEDIN => t('LinkedIn'),
+               NETWORK_XMPP     => t('XMPP/IM'),
+               NETWORK_MYSPACE  => t('MySpace'),
+               NETWORK_MAIL2    => t('Email'),
+               NETWORK_GPLUS    => t('Google+'),
+               NETWORK_PUMPIO   => t('pump.io'),
+               NETWORK_TWITTER  => t('Twitter'),
+               NETWORK_DIASPORA2 => t('Diaspora Connector'),
+               NETWORK_STATUSNET => t('GNU Social'),
+               NETWORK_APPNET => t('App.net')
+       );
+
+       call_hooks('network_to_name', $nets);
+
+       $search  = array_keys($nets);
+       $replace = array_values($nets);
+
+       $networkname = str_replace($search,$replace,$s);
 
-       call_hooks('network_to_name', $s);
+       if (($s == NETWORK_DIASPORA) AND ($profile != "") AND diaspora::is_redmatrix($profile)) {
+               $networkname = t("Hubzilla/Redmatrix");
 
-       return str_replace(array(NETWORK_DFRN,NETWORK_OSTATUS,NETWORK_FEED,NETWORK_MAIL,NETWORK_DIASPORA,NETWORK_FACEBOOK,NETWORK_ZOT),
-               array(t('Friendika'),t('OStatus'),t('RSS/Atom'),t('Email'),t('Diaspora'),t('Facebook'),t('Zot!')),$s);
+               $r = q("SELECT `gserver`.`platform` FROM `gcontact`
+                               INNER JOIN `gserver` ON `gserver`.`nurl` = `gcontact`.`server_url`
+                               WHERE `gcontact`.`nurl` = '%s' AND `platform` != ''",
+                               dbesc(normalise_link($profile)));
+               if ($r)
+                       $networkname = $r[0]["platform"];
+       }
 
+       return $networkname;
 }