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.

160 lines
4.3 KiB

11 years ago
11 years ago
11 years ago
  1. <?php
  2. // Included here for completeness, but this is a very dangerous operation.
  3. // It is the caller's responsibility to confirm the requestor's intent and
  4. // authorisation to do this.
  5. function user_remove($uid) {
  6. if(! $uid)
  7. return;
  8. $a = get_app();
  9. logger('Removing user: ' . $uid);
  10. $r = q("select * from user where uid = %d limit 1", intval($uid));
  11. call_hooks('remove_user',$r[0]);
  12. // save username (actually the nickname as it is guaranteed
  13. // unique), so it cannot be re-registered in the future.
  14. q("insert into userd ( username ) values ( '%s' )",
  15. $r[0]['nickname']
  16. );
  17. q("DELETE FROM `contact` WHERE `uid` = %d", intval($uid));
  18. q("DELETE FROM `group` WHERE `uid` = %d", intval($uid));
  19. q("DELETE FROM `group_member` WHERE `uid` = %d", intval($uid));
  20. q("DELETE FROM `intro` WHERE `uid` = %d", intval($uid));
  21. q("DELETE FROM `event` WHERE `uid` = %d", intval($uid));
  22. q("DELETE FROM `item` WHERE `uid` = %d", intval($uid));
  23. q("DELETE FROM `mail` WHERE `uid` = %d", intval($uid));
  24. q("DELETE FROM `photo` WHERE `uid` = %d", intval($uid));
  25. q("DELETE FROM `profile` WHERE `uid` = %d", intval($uid));
  26. q("DELETE FROM `profile_check` WHERE `uid` = %d", intval($uid));
  27. q("DELETE FROM `pconfig` WHERE `uid` = %d", intval($uid));
  28. q("DELETE FROM `user` WHERE `uid` = %d", intval($uid));
  29. if($uid == local_user()) {
  30. unset($_SESSION['authenticated']);
  31. unset($_SESSION['uid']);
  32. goaway($a->get_baseurl());
  33. }
  34. }
  35. function contact_remove($id) {
  36. q("DELETE FROM `contact` WHERE `id` = %d LIMIT 1",
  37. intval($id)
  38. );
  39. q("DELETE FROM `item` WHERE `contact-id` = %d ",
  40. intval($id)
  41. );
  42. q("DELETE FROM `photo` WHERE `contact-id` = %d ",
  43. intval($id)
  44. );
  45. q("DELETE FROM `mail` WHERE `contact-id` = %d ",
  46. intval($id)
  47. );
  48. q("DELETE FROM `event` WHERE `cid` = %d ",
  49. intval($id)
  50. );
  51. q("DELETE FROM `queue` WHERE `cid` = %d ",
  52. intval($id)
  53. );
  54. }
  55. // Contact has refused to recognise us as a friend. We will start a countdown.
  56. // If they still don't recognise us in 32 days, the relationship is over,
  57. // and we won't waste any more time trying to communicate with them.
  58. // This provides for the possibility that their database is temporarily messed
  59. // up or some other transient event and that there's a possibility we could recover from it.
  60. if(! function_exists('mark_for_death')) {
  61. function mark_for_death($contact) {
  62. if($contact['term-date'] == '0000-00-00 00:00:00') {
  63. q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d LIMIT 1",
  64. dbesc(datetime_convert()),
  65. intval($contact['id'])
  66. );
  67. }
  68. else {
  69. $expiry = $contact['term-date'] . ' + 32 days ';
  70. if(datetime_convert() > datetime_convert('UTC','UTC',$expiry)) {
  71. // relationship is really truly dead.
  72. contact_remove($contact['id']);
  73. }
  74. }
  75. }}
  76. if(! function_exists('unmark_for_death')) {
  77. function unmark_for_death($contact) {
  78. // It's a miracle. Our dead contact has inexplicably come back to life.
  79. q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d LIMIT 1",
  80. dbesc('0000-00-00 00:00:00'),
  81. intval($contact['id'])
  82. );
  83. }}
  84. if(! function_exists('contact_photo_menu')){
  85. function contact_photo_menu($contact) {
  86. $a = get_app();
  87. $contact_url="";
  88. $pm_url="";
  89. $status_link="";
  90. $photos_link="";
  91. $posts_link="";
  92. $sparkle = false;
  93. if($contact['network'] === NETWORK_DFRN) {
  94. $sparkle = true;
  95. $profile_link = $a->get_baseurl() . '/redir/' . $contact['id'];
  96. }
  97. else
  98. $profile_link = $contact['url'];
  99. if($profile_link === 'mailbox')
  100. $profile_link = '';
  101. if($sparkle) {
  102. $status_link = $profile_link . "?url=status";
  103. $photos_link = $profile_link . "?url=photos";
  104. $profile_link = $profile_link . "?url=profile";
  105. $pm_url = $a->get_baseurl() . '/message/new/' . $contact['id'];
  106. }
  107. $contact_url = $a->get_baseurl() . '/contacts/' . $contact['id'];
  108. $posts_link = $a->get_baseurl() . '/network/?cid=' . $contact['id'];
  109. $menu = Array(
  110. t("View status") => $status_link,
  111. t("View profile") => $profile_link,
  112. t("View photos") => $photos_link,
  113. t("View recent") => $posts_link,
  114. t("Edit contact") => $contact_url,
  115. t("Send PM") => $pm_url,
  116. );
  117. $args = array('contact' => $contact, 'menu' => $menu);
  118. call_hooks('contact_photo_menu', $args);
  119. $o = "";
  120. foreach($menu as $k=>$v){
  121. if ($v!="") {
  122. if(($k !== t("View recent")) && ($k !== t("Send PM")))
  123. $o .= "<li><a target=\"redir\" href=\"$v\">$k</a></li>\n";
  124. else
  125. $o .= "<li><a href=\"$v\">$k</a></li>\n";
  126. }
  127. }
  128. return $o;
  129. }}