From 974077c06c8464223e26479e07a8349b8e6c509d Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 13 Apr 2011 20:14:30 -0700 Subject: [PATCH] contact "repair/relocate URL" tool --- images/tools.png | Bin 0 -> 490 bytes mod/contacts.php | 2 + mod/crepair.php | 105 ++++++++++++++++++++++++++++++ view/contact_edit.tpl | 2 + view/crepair.tpl | 34 ++++++++++ view/theme/duepuntozero/style.css | 21 ++++++ 6 files changed, 164 insertions(+) create mode 100644 images/tools.png create mode 100644 mod/crepair.php create mode 100644 view/crepair.tpl diff --git a/images/tools.png b/images/tools.png new file mode 100644 index 0000000000000000000000000000000000000000..c17094a81bde4976d6e01a2848e657dd850bfab9 GIT binary patch literal 490 zcmVw*VKanmSfMN^i%FueLO%XS=hgG(aqBnl z_1-<_oqNw6j|p@b9od+J7u%S?y@?(f7)ClqV@zt$dhvu0G(sL$VFhot;4IAI3Z6ujfm5qy9m>?29a9l(g~E2o-FM!8<)BQqLQrgI7~7R%2ATJVf@Ov0yu z@ko}n;#kW*K?$a@>R}Trxmhyq;|pt;!XPfRdoD zHNoma7<;(WCFMC16(SLRwoUz&z-aIhHt;DeawN%@UB`|tEh>S1L^Mgzr4ni9mX*Zo z5?rV4+QpE|`v#2veB4oiJgC(jUc|gE$*1kJ55L;95~N`n?N~s!F2U%@vnP?#FLf!o z9{n>(pX>E7NuOU`O7B4@u62VmpF literal 0 HcmV?d00001 diff --git a/mod/contacts.php b/mod/contacts.php index 834b1c63de..ee7177d48e 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -272,6 +272,8 @@ function contacts_content(&$a) { '$visit' => t('Visit $name\'s profile'), '$blockunblock' => t('Block/Unblock contact'), '$ignorecont' => t('Ignore contact'), + '$altcrepair' => t('Repair contact URL settings'), + '$lblcrepair' => t("Repair contact URL settings \x28WARNING: Advanced\x29"), '$delete' => t('Delete contact'), '$poll_interval' => contact_poll_interval($r[0]['priority']), '$lastupdtext' => t('Last updated: '), diff --git a/mod/crepair.php b/mod/crepair.php new file mode 100644 index 0000000000..617c381f7d --- /dev/null +++ b/mod/crepair.php @@ -0,0 +1,105 @@ +argc > 1) ? intval($a->argv[1]) : 0); + + if($cid) { + $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($cid), + intval(local_user()) + ); + } + + if(! count($r)) + return; + + $contact = $r[0]; + + $nick = ((x($_POST,'nick')) ? $_POST['nick'] : null); + $url = ((x($_POST,'url')) ? $_POST['url'] : null); + $request = ((x($_POST,'request')) ? $_POST['request'] : null); + $confirm = ((x($_POST,'confirm')) ? $_POST['confirm'] : null); + $notify = ((x($_POST,'notify')) ? $_POST['notify'] : null); + $poll = ((x($_POST,'poll')) ? $_POST['poll'] : null); + + + $r = q("UPDATE `contact` SET `nick` = '%s', `url` = '%s', `request` = '%s', `confirm` = '%s', `notify` = '%s', `poll` = '%s' + WHERE `id` = %d AND `uid` = %d LIMIT 1", + dbesc($nick), + dbesc($url), + dbesc($request), + dbesc($confirm), + dbesc($notify), + dbesc($poll), + intval($contact['id']), + local_user() + ); + + if($r) + notice( t('Contact settings applied.') . EOL); + else + notice( t('Contact update failed.') . EOL); + + return; +} + + + +function crepair_content(&$a) { + + if(! local_user()) { + notice( t('Permission denied.') . EOL); + return; + } + + $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0); + + if($cid) { + $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($cid), + intval(local_user()) + ); + } + + if(! count($r)) { + notice( t('Contact not found.') . EOL); + return; + } + + $contact = $r[0]; + + $msg1 = t('Repair Contact Settings'); + + $msg2 = t('WARNING: This is highly advanced and if you enter incorrect information your communications with this contact will stop working.'); + $msg3 = t('Please use your browser \'Back\' button now if you are uncertain what to do on this page.'); + + $o .= '

' . $msg1 . '

'; + + $o .= '
' . $msg2 . EOL . EOL. $msg3 . '
'; + + $tpl = load_view_file('view/crepair.tpl'); + $o .= replace_macros($tpl, array( + '$label_name' => t('Name'), + '$label_nick' => t('Account Nickname'), + '$label_url' => t('Account URL'), + '$label_request' => t('Friend Request URL'), + '$label_confirm' => t('Friend Confirm URL'), + '$label_notify' => t('Notification Endpoint URL'), + '$label_poll' => t('Poll/Feed URL'), + '$contact_name' => $contact['name'], + '$contact_nick' => $contact['nick'], + '$contact_id' => $contact['id'], + '$contact_url' => $contact['url'], + '$request' => $contact['request'], + '$confirm' => $contact['confirm'], + '$notify' => $contact['notify'], + '$poll' => $contact['poll'], + '$lbl_submit' => t('Submit') + )); + + return $o; + +} \ No newline at end of file diff --git a/view/contact_edit.tpl b/view/contact_edit.tpl index 4c2c6c6f81..5e4f023350 100644 --- a/view/contact_edit.tpl +++ b/view/contact_edit.tpl @@ -20,6 +20,8 @@