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.
 
 
 
 
 
 

105 lines
2.6 KiB

  1. <?php
  2. function crepair_post(&$a) {
  3. if(! local_user())
  4. return;
  5. $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
  6. if($cid) {
  7. $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
  8. intval($cid),
  9. intval(local_user())
  10. );
  11. }
  12. if(! count($r))
  13. return;
  14. $contact = $r[0];
  15. $nick = ((x($_POST,'nick')) ? $_POST['nick'] : null);
  16. $url = ((x($_POST,'url')) ? $_POST['url'] : null);
  17. $request = ((x($_POST,'request')) ? $_POST['request'] : null);
  18. $confirm = ((x($_POST,'confirm')) ? $_POST['confirm'] : null);
  19. $notify = ((x($_POST,'notify')) ? $_POST['notify'] : null);
  20. $poll = ((x($_POST,'poll')) ? $_POST['poll'] : null);
  21. $r = q("UPDATE `contact` SET `nick` = '%s', `url` = '%s', `request` = '%s', `confirm` = '%s', `notify` = '%s', `poll` = '%s'
  22. WHERE `id` = %d AND `uid` = %d LIMIT 1",
  23. dbesc($nick),
  24. dbesc($url),
  25. dbesc($request),
  26. dbesc($confirm),
  27. dbesc($notify),
  28. dbesc($poll),
  29. intval($contact['id']),
  30. local_user()
  31. );
  32. if($r)
  33. notice( t('Contact settings applied.') . EOL);
  34. else
  35. notice( t('Contact update failed.') . EOL);
  36. return;
  37. }
  38. function crepair_content(&$a) {
  39. if(! local_user()) {
  40. notice( t('Permission denied.') . EOL);
  41. return;
  42. }
  43. $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0);
  44. if($cid) {
  45. $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
  46. intval($cid),
  47. intval(local_user())
  48. );
  49. }
  50. if(! count($r)) {
  51. notice( t('Contact not found.') . EOL);
  52. return;
  53. }
  54. $contact = $r[0];
  55. $msg1 = t('Repair Contact Settings');
  56. $msg2 = t('<strong>WARNING: This is highly advanced</strong> and if you enter incorrect information your communications with this contact will stop working.');
  57. $msg3 = t('Please use your browser \'Back\' button <strong>now</strong> if you are uncertain what to do on this page.');
  58. $o .= '<h2>' . $msg1 . '</h2>';
  59. $o .= '<div class="error-message">' . $msg2 . EOL . EOL. $msg3 . '</div>';
  60. $tpl = load_view_file('view/crepair.tpl');
  61. $o .= replace_macros($tpl, array(
  62. '$label_name' => t('Name'),
  63. '$label_nick' => t('Account Nickname'),
  64. '$label_url' => t('Account URL'),
  65. '$label_request' => t('Friend Request URL'),
  66. '$label_confirm' => t('Friend Confirm URL'),
  67. '$label_notify' => t('Notification Endpoint URL'),
  68. '$label_poll' => t('Poll/Feed URL'),
  69. '$contact_name' => $contact['name'],
  70. '$contact_nick' => $contact['nick'],
  71. '$contact_id' => $contact['id'],
  72. '$contact_url' => $contact['url'],
  73. '$request' => $contact['request'],
  74. '$confirm' => $contact['confirm'],
  75. '$notify' => $contact['notify'],
  76. '$poll' => $contact['poll'],
  77. '$lbl_submit' => t('Submit')
  78. ));
  79. return $o;
  80. }