From 2dbe596c8273af1c4d8cd3296f52720d82998bd0 Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Fri, 16 Dec 2011 09:37:58 +0100 Subject: [PATCH] unhosted remoteStorage URL in user XRD --- uhremotestorage.tgz | Bin 0 -> 1144 bytes uhremotestorage/settings.tpl | 6 +++ uhremotestorage/uhremotestorage.php | 61 ++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 uhremotestorage.tgz create mode 100644 uhremotestorage/settings.tpl create mode 100644 uhremotestorage/uhremotestorage.php diff --git a/uhremotestorage.tgz b/uhremotestorage.tgz new file mode 100644 index 0000000000000000000000000000000000000000..2654cd0317dc7bf6f9d9a36f3c72aff73e08767c GIT binary patch literal 1144 zcmV-;1c&<{iwFQ%^T1931MOFBZ`(Ey&R6SK+yrlu0!OkFzW}MMEoeGyz_1O?S`26d zL6&HnFii>+l{g6e-*=Q0&vBD@K$8r^_2@YNWUBqZG z(BIx@(5=S3e!u!QIOz3;{n2PJ><^C*y1kQ=UjG0FFX7BC%0eX);9#0esCZJ2$l^5| zdR>$|{O^qYe4c-`4NdT{=KCT3`^Tf<4*#R$!N~!1pCP`z_@DD1evb@W!Qr6=hwy8% zB&SgFxhNFLpsoaHNJ%HbM}#L6hU&NUe#G2XI(vRskIzaq7xEN-)TF>$u`D@-aIRE-8Uza}XHt~8pNeIW zOEIO41W2ExtJN~X?STarOiP|>KVhe$W6F_n##|3>t(GJ+icZORF2urha`Z!>&+$rT zP6wPM%LLy&6AzscExc>!o-*&vm&RB*qdYE%Qk2h%ueP^QwBJ^Y%&BKHSZhP8R*Q+* zj7ZmRl8h|xY_d^oZCTc%^dQq)1X-<;zbZ#xntMr>_E~#zp0wcAqbxm2(stV1cG7|G z+7l0tlhtZx$yF&CjA2GpoTq|M>CA0UJ~>qzxWq5boXgIxlTOE}cUF0!Q*awiT5U`3 zUoDw)iFykqV@YzBq{PLgmJi2Y12wxJj3Ct6hLUhNf!bWs*vPk>hFy5-F1#T}Vz_QN@S@;|QD&58r`KrxMKY z8m#1sTvD#4E-2SIV@zD@iw`4$8&OJ_N=kS}7YShA+;0m{ucG6er1<0B75T{B2ri=w z0^*v#WunYH$HPj}EO@meIzKJ+qYeV@mq15*wF%_>?Bhmjl~&YLXBa!i&(qrDMB-wB zsoR+B)C-$8fu`}AG6oZU)1z;pQc-ipLK^*ql^6yz3X(i8f;xE@O}E19I!}~tQd;uE z#k=>F*>Fb-797L=scH=J@5bS$?@O+ z|Bm}TeE$!IL-YQB6@(eRf|MmiF}ClxKbl}`Uf7Y<3g;(L-4??Df8s z;_E-frc79d@9Ml%x@@pNs5!K&*|Ba>uwJ92ZiOhkUZa+6qt&Ulqp;c!>Lw?fNzk2r zZ0FU5MHR8(Dq$tgwC@ChC=5_p)UxWY=?De}1_lNO1_lNO1_lNO1_lNO1_lNOh`#`5 K2XC+dC;$M|3@R4@ literal 0 HcmV?d00001 diff --git a/uhremotestorage/settings.tpl b/uhremotestorage/settings.tpl new file mode 100644 index 00000000..45036dd4 --- /dev/null +++ b/uhremotestorage/settings.tpl @@ -0,0 +1,6 @@ +
+

$title

+

$desc

+ {{ inc field_input.tpl with $field=$url }}{{ endinc }} +
+
diff --git a/uhremotestorage/uhremotestorage.php b/uhremotestorage/uhremotestorage.php new file mode 100644 index 00000000..5c182004 --- /dev/null +++ b/uhremotestorage/uhremotestorage.php @@ -0,0 +1,61 @@ + + */ + + function uhremotestorage_install() { + register_hook('personal_xrd', 'addon/uhremotestorage/uhremotestorage.php', 'uhremotestorage_personal_xrd'); + register_hook('plugin_settings', 'addon/uhremotestorage/uhremotestorage.php', 'uhremotestorage_settings'); + register_hook('plugin_settings_post', 'addon/uhremotestorage/uhremotestorage.php', 'uhremotestorage_settings_post'); + + logger("installed uhremotestorage"); +} + + +function uhremotestorage_uninstall() { + + unregister_hook('personal_xrd', 'addon/uhremotestorage/uhremotestorage.php', 'uhremotestorage_personal_xrd'); + unregister_hook('plugin_settings', 'addon/uhremotestorage/uhremotestorage.php', 'uhremotestorage_settings'); + unregister_hook('plugin_settings_post', 'addon/uhremotestorage/uhremotestorage.php', 'uhremotestorage_settings_post'); + + logger("removed uhremotestorage"); +} + +function uhremotestorage_personal_xrd($a, &$b){ + + $davurl = get_pconfig($b['user']['uid'],'uhremotestorage','davurl'); + if ($davurl){ + $b['xml'] = str_replace( + '', + "\t".''."\n", + $b['xml'] + ); + } +} + +function uhremotestorage_settings_post($a, $post){ + if(! local_user()) + return; + set_pconfig(local_user(),'uhremotestorage','davurl',$_POST['unhoestedurl']); +} + +function uhremotestorage_settings($a, &$s){ + if(! local_user()) + return; + + $uid = $a->user['nickname'] ."@". $a->get_hostname(); + + $davurl = get_pconfig(local_user(),'uhremotestorage','davurl'); + + $tpl = file_get_contents(dirname(__file__)."/settings.tpl"); + $s .= replace_macros($tpl, array( + '$title' => 'Unhosted remote storage', + '$desc' => sprintf( t('Allow to use your friendika id (%s) to connecto to external unhosted-enabled storage (like ownCloud)'), $uid ), + '$url' => array( 'unhoestedurl', t('Unhosted DAV storage url'), $davurl, 'If your are using ownCloud, your unhosted url will be like http://HOST/apps/remoteStorage/compat.php/USER/remoteStorage/'), + '$submit' => t('Submit'), + )); + +}