Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
3.1KB

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