summaryrefslogtreecommitdiffstats
path: root/apps/federatedfilesharing
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2016-04-18 18:17:08 +0200
committerBjörn Schießle <schiessle@owncloud.com>2016-04-22 14:55:40 +0200
commite10105474fbef8940fdfa96d5e2bf2f09b1f0649 (patch)
tree1881e059a3408a2d4e8096e31719ba989f7dfab1 /apps/federatedfilesharing
parent606b756a94643eaae87e18b39f6c75e6d18fec7e (diff)
downloadnextcloud-server-e10105474fbef8940fdfa96d5e2bf2f09b1f0649.tar.gz
nextcloud-server-e10105474fbef8940fdfa96d5e2bf2f09b1f0649.zip
move federated sharing settings to the federatedfilesharing app
Diffstat (limited to 'apps/federatedfilesharing')
-rw-r--r--apps/federatedfilesharing/appinfo/app.php6
-rw-r--r--apps/federatedfilesharing/appinfo/application.php88
-rw-r--r--apps/federatedfilesharing/css/3rdparty/gs-share/style.css49
-rw-r--r--apps/federatedfilesharing/css/settings-personal.css33
-rw-r--r--apps/federatedfilesharing/img/social-diaspora.svg52
-rw-r--r--apps/federatedfilesharing/img/social-facebook.svg43
-rw-r--r--apps/federatedfilesharing/img/social-gnu.svg79
-rw-r--r--apps/federatedfilesharing/img/social-googleplus.svg45
-rw-r--r--apps/federatedfilesharing/img/social-twitter.svg53
-rw-r--r--apps/federatedfilesharing/js/3rdparty/gs-share/gs-share.js206
-rw-r--r--apps/federatedfilesharing/js/settings-admin.js12
-rw-r--r--apps/federatedfilesharing/js/settings-personal.js19
-rw-r--r--apps/federatedfilesharing/lib/federatedshareprovider.php30
-rw-r--r--apps/federatedfilesharing/settings-admin.php34
-rw-r--r--apps/federatedfilesharing/settings-personal.php52
-rw-r--r--apps/federatedfilesharing/templates/settings-admin.php28
-rw-r--r--apps/federatedfilesharing/templates/settings-personal.php78
-rw-r--r--apps/federatedfilesharing/tests/federatedshareprovidertest.php46
18 files changed, 947 insertions, 6 deletions
diff --git a/apps/federatedfilesharing/appinfo/app.php b/apps/federatedfilesharing/appinfo/app.php
index 804ab69759c..23af62037a3 100644
--- a/apps/federatedfilesharing/appinfo/app.php
+++ b/apps/federatedfilesharing/appinfo/app.php
@@ -21,7 +21,5 @@
namespace OCA\FederatedFileSharing\AppInfo;
-use OCP\AppFramework\App;
-
-new App('federatedfilesharing');
-
+$app = new Application('federatedfilesharing');
+$app->registerSettings();
diff --git a/apps/federatedfilesharing/appinfo/application.php b/apps/federatedfilesharing/appinfo/application.php
new file mode 100644
index 00000000000..5a213aec8e2
--- /dev/null
+++ b/apps/federatedfilesharing/appinfo/application.php
@@ -0,0 +1,88 @@
+<?php
+/**
+ * @author Björn Schießle <schiessle@owncloud.com>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+
+namespace OCA\FederatedFileSharing\AppInfo;
+
+
+use OCA\FederatedFileSharing\FederatedShareProvider;
+use OCP\AppFramework\App;
+
+class Application extends App {
+
+ /** @var FederatedShareProvider */
+ protected $federatedShareProvider;
+
+ /**
+ * register personal and admin settings page
+ */
+ public function registerSettings() {
+ \OCP\App::registerAdmin('federatedfilesharing', 'settings-admin');
+ \OCP\App::registerPersonal('federatedfilesharing', 'settings-personal');
+ }
+
+ /**
+ * get instance of federated share provider
+ *
+ * @return FederatedShareProvider
+ */
+ public function getFederatedShareProvider() {
+ if ($this->federatedShareProvider === null) {
+ $this->initFederatedShareProvider();
+ }
+ return $this->federatedShareProvider;
+ }
+
+ /**
+ * initialize federated share provider
+ */
+ protected function initFederatedShareProvider() {
+ $addressHandler = new \OCA\FederatedFileSharing\AddressHandler(
+ \OC::$server->getURLGenerator(),
+ \OC::$server->getL10N('federatedfilesharing')
+ );
+ $discoveryManager = new \OCA\FederatedFileSharing\DiscoveryManager(
+ \OC::$server->getMemCacheFactory(),
+ \OC::$server->getHTTPClientService()
+ );
+ $notifications = new \OCA\FederatedFileSharing\Notifications(
+ $addressHandler,
+ \OC::$server->getHTTPClientService(),
+ $discoveryManager,
+ \OC::$server->getJobList()
+ );
+ $tokenHandler = new \OCA\FederatedFileSharing\TokenHandler(
+ \OC::$server->getSecureRandom()
+ );
+
+ $this->federatedShareProvider = new \OCA\FederatedFileSharing\FederatedShareProvider(
+ \OC::$server->getDatabaseConnection(),
+ $addressHandler,
+ $notifications,
+ $tokenHandler,
+ \OC::$server->getL10N('federatedfilesharing'),
+ \OC::$server->getLogger(),
+ \OC::$server->getLazyRootFolder(),
+ \OC::$server->getConfig()
+ );
+ }
+
+}
diff --git a/apps/federatedfilesharing/css/3rdparty/gs-share/style.css b/apps/federatedfilesharing/css/3rdparty/gs-share/style.css
new file mode 100644
index 00000000000..c699ddb3db5
--- /dev/null
+++ b/apps/federatedfilesharing/css/3rdparty/gs-share/style.css
@@ -0,0 +1,49 @@
+.js-gs-share, .gs-share [aria-hidden="true"], .gs-share-form[aria-hidden="true"] {
+ display: none;
+}
+
+.js-gs-share-enabled .js-gs-share {
+ display: inline;
+ float: left;
+}
+
+.gs-share .js-gs-share[href] {
+ display: inline;
+}
+
+.gs-share [aria-hidden="false"], .gs-share-form[aria-hidden="false"] {
+ display: block;
+ margin-top: 40px;
+}
+
+.gs-share {
+ position: relative;
+}
+
+.gs-share-form {
+ background: #FFF;
+ border: 1px solid #000;
+ border-radius: 5px;
+ padding: 5px;
+ position: absolute;
+ z-index: 1;
+}
+
+.gs-share [for="gs-account"], .gs-share [type="text"] {
+ display: block;
+ margin-bottom: 8px;
+}
+
+.gs-share [type="submit"] {
+ display: block;
+ margin-top: 8px;
+}
+
+.gs-share--icon {
+ border: none;
+ cursor: pointer;
+ min-height: 32px;
+ padding: 0;
+ padding-left: 33px;
+ background: transparent url('../../../img/gs-share.png') no-repeat left center;
+}
diff --git a/apps/federatedfilesharing/css/settings-personal.css b/apps/federatedfilesharing/css/settings-personal.css
new file mode 100644
index 00000000000..f53365c9371
--- /dev/null
+++ b/apps/federatedfilesharing/css/settings-personal.css
@@ -0,0 +1,33 @@
+#fileSharingSettings img {
+ cursor: pointer;
+}
+
+#fileSharingSettings xmp {
+ margin-top: 0;
+ white-space: pre-wrap;
+}
+
+[class^="social-"], [class*=" social-"] {
+ background-repeat: no-repeat;
+ background-position: 2px;
+ min-width: 16px;
+ min-height: 16px;
+ padding-left: 29px;
+ background-size: 24px;
+}
+
+.social-gnu {
+ background-image: url('../img/social-gnu.svg');
+}
+.social-diaspora {
+ background-image: url('../img/social-diaspora.svg');
+}
+.social-twitter {
+ background-image: url('../img/social-twitter.svg');
+}
+.social-facebook {
+ background-image: url('../img/social-facebook.svg');
+}
+.social-googleplus {
+ background-image: url('../img/social-googleplus.svg');
+}
diff --git a/apps/federatedfilesharing/img/social-diaspora.svg b/apps/federatedfilesharing/img/social-diaspora.svg
new file mode 100644
index 00000000000..1d5131129a9
--- /dev/null
+++ b/apps/federatedfilesharing/img/social-diaspora.svg
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.1"
+ width="32"
+ height="32"
+ id="svg3937"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="social-diaspora.svg">
+ <metadata
+ id="metadata4166">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs4164" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="640"
+ inkscape:window-height="480"
+ id="namedview4162"
+ showgrid="false"
+ inkscape:zoom="13.549078"
+ inkscape:cx="-5.9149036"
+ inkscape:cy="9.8488708"
+ inkscape:current-layer="svg3937" />
+ <path
+ d="m 15.956724,31 c -0.896548,4.3e-5 -1.344812,-0.448233 -1.344812,-1.344828 L 14.715361,19 5.612032,24.689655 C 4.9223812,25.172463 4.336189,25.034532 3.8534355,24.275862 L 3.3362024,23.448276 C 2.8534488,22.758671 2.991377,22.172465 3.7499869,21.689655 L 13.163651,16 3.6465383,10.310345 C 2.9568974,9.8966152 2.8189693,9.3104089 3.2327538,8.551724 L 3.8534355,7.517241 C 4.1982609,6.965584 4.7499735,6.896618 5.5085834,7.310345 L 14.715361,13 14.611912,2.344828 c 0,-0.89648 0.448264,-1.344756 1.344812,-1.344828 l 0.827569,0 c 0.896538,7.2e-5 1.344812,0.448348 1.344812,1.344828 L 18.025656,13 27.128985,7.206897 c 0.620651,-0.344761 1.206854,-0.206831 1.758596,0.413793 l 0.517233,0.827586 c 0.344796,0.7586846 0.206898,1.344891 -0.413784,1.758621 L 19.473917,16 l 9.620561,5.793103 c 0.689611,0.413845 0.827549,0.965568 0.413785,1.655173 L 28.99103,24.37931 c -0.482784,0.75867 -1.103465,0.896601 -1.862045,0.413793 L 18.025656,19 18.129105,29.655172 c 0,0.896595 -0.448274,1.344871 -1.344812,1.344828 l -0.827569,0"
+ id="star"
+ style="opacity:0.5;fill:#000000;fill-opacity:1"
+ inkscape:connector-curvature="0" />
+</svg>
diff --git a/apps/federatedfilesharing/img/social-facebook.svg b/apps/federatedfilesharing/img/social-facebook.svg
new file mode 100644
index 00000000000..aad02bc3853
--- /dev/null
+++ b/apps/federatedfilesharing/img/social-facebook.svg
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ enable-background="new 0 0 56.693 56.693"
+ height="32"
+ id="Layer_1"
+ version="1.1"
+ viewBox="0 0 32 32"
+ width="32"
+ xml:space="preserve"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="social-facebook.svg"><metadata
+ id="metadata5818"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
+ id="defs5816" /><sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="640"
+ inkscape:window-height="480"
+ id="namedview5814"
+ showgrid="false"
+ inkscape:zoom="11.271233"
+ inkscape:cx="5.0995367"
+ inkscape:cy="28.322502"
+ inkscape:current-layer="Layer_1" /><path
+ d="m 22.396887,16.008872 -4.203409,0 0,14.991128 -6.230193,0 0,-14.991128 -2.963285,0 0,-5.292784 2.963285,0 0,-3.429613 C 11.963285,4.831822 13.128489,1 18.251639,1 l 4.613498,0.01774 0,5.140971 -3.349714,0 c -0.547114,0 -1.320959,0.273067 -1.320959,1.44026 l 0,3.118099 4.749536,0 z"
+ id="path5812"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccccccscccssccc"
+ style="fill:#000000;fill-opacity:1;opacity:0.5" /></svg> \ No newline at end of file
diff --git a/apps/federatedfilesharing/img/social-gnu.svg b/apps/federatedfilesharing/img/social-gnu.svg
new file mode 100644
index 00000000000..24556aaa024
--- /dev/null
+++ b/apps/federatedfilesharing/img/social-gnu.svg
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="32"
+ height="32"
+ id="svg2880"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="social-gnu.svg"
+ inkscape:export-filename="/home/robmyers/Desktop/social_logo_competition/gnu-social-logo.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs2882">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective2888" />
+ <inkscape:perspective
+ id="perspective2859"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="17.21204"
+ inkscape:cx="13.854211"
+ inkscape:cy="18.472465"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1022"
+ inkscape:window-height="730"
+ inkscape:window-x="0"
+ inkscape:window-y="49"
+ inkscape:window-maximized="0" />
+ <metadata
+ id="metadata2885">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-119.19595,-352.32438)">
+ <path
+ style="opacity:0.5;fill:#000000;fill-opacity:1;stroke:none"
+ d="m 125.14074,354.32438 c -2.18531,0 -3.94479,1.75948 -3.94479,3.94479 l 0,15.76964 c 0,2.18531 1.75948,3.94419 3.94479,3.94419 l 11.72461,0 c -0.0131,4.46851 -6.05322,6.34138 -6.05322,6.34138 0,0 10.21217,-0.0335 11.65719,-6.34138 l 2.12751,0 c 2.18532,0 3.94479,-1.75888 3.94479,-3.94419 l 0,-15.76964 c 0,-2.18531 -1.75947,-3.94479 -3.94479,-3.94479 l -19.45609,0 z m 5.66602,3.16145 c 0.042,-0.007 0.0803,-0.007 0.11455,0 0.0366,0.007 0.0681,0.022 0.0943,0.0454 0.41895,0.37367 -0.69461,0.73954 -0.60497,2.57737 0.0394,0.80713 -0.2017,1.43484 1.34476,1.43484 1.03195,0 0.60505,-0.91938 1.90498,-0.91938 0.77317,0 1.0581,0.49786 1.16578,0.90268 0.10769,-0.40482 0.39265,-0.90268 1.16577,-0.90268 1.29994,0 0.87304,0.91938 1.90498,0.91938 1.54648,0 1.3054,-0.62771 1.34477,-1.43484 0.0896,-1.83783 -1.02452,-2.2037 -0.60556,-2.57737 0.41895,-0.37366 2.21932,1.81578 2.26414,2.66745 0.0469,0.89057 0.0697,2.29462 -1.25467,3.02244 1.47777,1.45682 1.67588,3.38756 1.67588,3.38756 l -2.55469,-0.0447 c 0,0 -0.58278,-2.64503 -3.67572,-2.51054 -3.09293,0.13447 -3.49614,0.67255 -3.49614,3.94479 0,3.27223 1.43378,4.39676 3.63037,4.48234 3.45154,0.13448 3.13818,-1.79282 3.13818,-1.79282 l -1.61383,0.0895 -0.89671,-2.42045 5.51329,0 c 0,2.64468 -1.12011,6.76843 -6.36465,6.49949 -5.24455,-0.26896 -6.41052,-4.39271 -6.45534,-7.17187 -0.0246,-1.52551 0.22386,-3.24602 1.47363,-4.46265 -1.31045,-0.72721 -1.2678,-2.13094 -1.2678,-3.02303 0,-1.10312 1.42517,-2.61621 2.05473,-2.71279 z"
+ id="path4639"
+ inkscape:connector-curvature="0" />
+ </g>
+</svg>
diff --git a/apps/federatedfilesharing/img/social-googleplus.svg b/apps/federatedfilesharing/img/social-googleplus.svg
new file mode 100644
index 00000000000..123273f2d38
--- /dev/null
+++ b/apps/federatedfilesharing/img/social-googleplus.svg
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ height="32"
+ id="Layer_1"
+ version="1.1"
+ viewBox="0 0 32 32"
+ width="32"
+ xml:space="preserve"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="social-googleplus.svg"><metadata
+ id="metadata4721"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
+ id="defs4719" /><sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="640"
+ inkscape:window-height="480"
+ id="namedview4717"
+ showgrid="false"
+ inkscape:zoom="14.120039"
+ inkscape:cx="16.803685"
+ inkscape:cy="25.296916"
+ inkscape:current-layer="Layer_1" /><style
+ type="text/css"
+ id="style4709"><![CDATA[
+ .st0{fill-rule:evenodd;clip-rule:evenodd;}
+]]></style><path
+ d="m 12.260365,1.00001 c -1.044403,0 -2.164648,0.121381 -3.360551,0.364723 C 7.692812,1.648864 6.529074,2.249513 5.409199,3.171551 3.776833,4.74759 2.962354,6.502187 2.962354,8.437552 c 0,1.600734 0.575619,3.003332 1.728237,4.209224 1.099897,1.293294 2.698442,1.953874 4.796683,1.980234 0.39512,0 0.817861,-0.0267 1.265423,-0.0775 -0.07353,0.20755 -0.154327,0.43048 -0.240621,0.67688 -0.0985,0.23057 -0.147948,0.52213 -0.147948,0.8698 0,0.57798 0.128855,1.07502 0.388569,1.48762 0.221977,0.42453 0.475109,0.82365 0.759795,1.19768 -0.920096,0.0244 -2.074179,0.14101 -3.465144,0.34467 -1.405117,0.24362 -2.74619,0.73028 -4.021172,1.45781 C 2.888819,21.26184 2.103483,22.04929 1.67146,22.94303 1.222511,23.83815 1,24.65257 1,25.38066 1,26.87734 1.688069,28.1616 3.060444,29.23708 4.421998,30.38637 6.482307,30.97531 9.242318,31 c 3.296919,-0.0505 5.820381,-0.83703 7.567065,-2.36284 1.686196,-1.47532 2.530304,-3.16622 2.530304,-5.07578 -0.02608,-1.34436 -0.332749,-2.43326 -0.922377,-3.26734 -0.625976,-0.82049 -1.354352,-1.56623 -2.184547,-2.24687 l -1.336959,-1.0958 c -0.192565,-0.19229 -0.392744,-0.41698 -0.59613,-0.67308 -0.241401,-0.26887 -0.361472,-0.60732 -0.361472,-1.02047 0,-0.42231 0.118073,-0.79294 0.352259,-1.11314 0.199779,-0.30855 0.415557,-0.58393 0.651408,-0.827 0.410103,-0.35849 0.796786,-0.711889 1.160829,-1.056231 0.329081,-0.34684 0.640495,-0.724448 0.932673,-1.134274 0.599894,-0.846566 0.912101,-1.973756 0.934299,-3.383312 0,-0.768597 -0.08672,-1.441865 -0.259587,-2.018173 C 17.498927,5.148549 17.257171,4.650391 16.984971,4.226692 16.700007,3.779685 16.410431,3.400399 16.113536,3.09296 15.80471,2.79773 15.527026,2.574136 15.278412,2.420417 l 2.429503,0 L 20.140669,1 12.260365,1 Z m 12.417942,0.168542 0,4.135521 -4.133895,0 0,2.002999 4.133895,0 0,4.133894 2.00354,0 0,-4.133894 4.133895,0 0,-2.002999 -4.133895,0 0,-4.135521 -2.00354,0 z M 9.822733,2.304994 c 0.806887,0.02581 1.520753,0.264821 2.141734,0.712105 0.608218,0.474477 1.099244,1.092424 1.472443,1.849089 0.794402,1.577704 1.192261,3.145874 1.192261,4.698051 0,0.360713 -0.02983,0.802452 -0.08671,1.329371 -0.0949,0.526364 -0.308925,1.039903 -0.643279,1.540185 -0.690627,0.706445 -1.554617,1.080265 -2.592084,1.118555 -0.821594,0 -1.551253,-0.25054 -2.188883,-0.752206 C 8.478088,12.299585 7.957919,11.690036 7.553643,10.971107 6.719841,9.429474 6.303937,7.947693 6.303937,6.523431 6.277017,5.444621 6.562813,4.468801 7.159655,3.59643 7.86804,2.76124 8.754744,2.330799 9.822733,2.304994 Z m 1.66754,17.540326 c 0.08939,-4e-5 0.159034,0.003 0.209187,0.009 0.337683,0 0.633039,0.0118 0.884983,0.0385 1.468658,1.02609 2.547169,1.89084 3.238073,2.59534 0.650949,0.74279 0.977113,1.61238 0.977113,2.61322 0,1.23142 -0.476766,2.23692 -1.430714,3.01967 -0.977255,0.7944 -2.395196,1.20356 -4.252037,1.2302 C 9.046107,29.32465 7.415497,28.8642 6.222646,27.96768 4.968474,27.07062 4.343209,25.92939 4.343209,24.54481 c 0,-0.70422 0.142508,-1.30655 0.432465,-1.80628 0.249447,-0.47503 0.556709,-0.87233 0.920751,-1.19226 0.377084,-0.30688 0.746941,-0.54508 1.110429,-0.71156 0.364043,-0.15344 0.645616,-0.26945 0.846505,-0.34576 0.853226,-0.25666 1.68826,-0.44222 2.503749,-0.55765 0.620565,-0.0574 1.064984,-0.0861 1.333165,-0.0862 z"
+ id="path4713"
+ style="opacity:0.5;fill:#000000;fill-opacity:1"
+ inkscape:connector-curvature="0" /></svg> \ No newline at end of file
diff --git a/apps/federatedfilesharing/img/social-twitter.svg b/apps/federatedfilesharing/img/social-twitter.svg
new file mode 100644
index 00000000000..00ce390de6b
--- /dev/null
+++ b/apps/federatedfilesharing/img/social-twitter.svg
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ height="32"
+ id="svg2"
+ version="1.1"
+ width="32"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="social-twitter.svg">
+ <metadata
+ id="metadata5269">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="640"
+ inkscape:window-height="480"
+ id="namedview5267"
+ showgrid="false"
+ inkscape:zoom="10.224"
+ inkscape:cx="-7.2593811"
+ inkscape:cy="16.128046"
+ inkscape:current-layer="svg2" />
+ <defs
+ id="defs4" />
+ <path
+ sodipodi:nodetypes="sscccccsscsccscsccsccss"
+ inkscape:connector-curvature="0"
+ style="opacity:0.5;fill:#000000;fill-opacity:1;fill-rule:nonzero"
+ id="rect2995"
+ d="m 21.611501,4.61946 c 0.05279,-0.002 0.106021,0 0.159127,0 1.770342,0 3.36956,0.74756 4.491932,1.94362 C 27.665067,6.2866 28.983178,5.77311 30.172539,5.06729 29.712752,6.50573 28.736679,7.71137 27.465106,8.4726 28.710494,8.32462 29.897115,7.99445 31,7.50421 c -0.824575,1.23442 -1.869002,2.31882 -3.071153,3.18481 0.01156,0.26431 0.01819,0.53117 0.01819,0.79791 C 27.947037,19.62063 21.755733,29 10.433964,29 6.9584454,29 3.7246302,27.98066 1,26.23346 c 0.481711,0.0572 0.9721881,0.0864 1.4685161,0.0864 2.8841872,0 5.5361434,-0.98372 7.6426469,-2.63469 -2.6929626,-0.0493 -4.9652637,-1.83087 -5.7490348,-4.27598 0.375747,0.0725 0.7622921,0.11139 1.1593551,0.11139 0.561492,0 1.1043981,-0.0759 1.6208231,-0.21596 -2.8159792,-0.56635 -4.9374873,-3.05156 -4.9374873,-6.03318 0,-0.0262 -4.66e-4,-0.054 0,-0.0796 0.830058,0.46101 1.7807801,0.73835 2.7892712,0.77063 -1.6515871,-1.10349 -2.7392592,-2.98649 -2.7392592,-5.12162 0,-1.12907 0.304455,-2.18754 0.834281,-3.09616 3.0358242,3.72399 7.5714429,6.17402 12.6869759,6.43101 -0.105355,-0.45126 -0.159128,-0.92088 -0.159128,-1.4026 0,-3.34627 2.669159,-6.0694 5.994545,-6.15366 z" />
+</svg>
diff --git a/apps/federatedfilesharing/js/3rdparty/gs-share/gs-share.js b/apps/federatedfilesharing/js/3rdparty/gs-share/gs-share.js
new file mode 100644
index 00000000000..fd4442708a4
--- /dev/null
+++ b/apps/federatedfilesharing/js/3rdparty/gs-share/gs-share.js
@@ -0,0 +1,206 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// @license magnet:?xt=urn:btih:3877d6d54b3accd4bc32f8a48bf32ebc0901502a&dn=mpl-2.0.txt MPL 2.0
+document.addEventListener('DOMContentLoaded', function () {
+ 'use strict';
+ /**
+ * 'Share' widget for GNU social
+ * http://code.chromic.org/project/view/2/
+ *
+ * We make a few assumptions about the target instance:
+ * 1) The API root is in the default location
+ * 2) Fancy URLs are enabled
+ * 3) CORS is allowed
+ * 4) The Bookmark plugin is enabled
+ *
+ * If 1), 3) or 4) are wrong, we fall back to a regular
+ * notice (instead of a bookmark notice)
+ *
+ * If 2) is wrong the user will be directed to a 404 :(
+ */
+
+ // TODO: input sanitation [1], [2]
+ // TODO: server-side fallback if JS is disabled
+
+ var createForm,
+ bindClicks,
+ frm,
+ shareAsNotice,
+ shareAsBookmark,
+ extractURLParams,
+ shareURL,
+ shareTitle,
+ closest,
+ i18n = window.i18n;
+
+ /**
+ * Internationalization
+ */
+ if (i18n === undefined) {
+ i18n = {
+ invalidId: 'The account id provided is invalid',
+ yourAcctId: 'Your account ID:',
+ idPlaceholder: 'user@example.org',
+ shareAsBookmark: 'Share as a bookmark'
+ };
+ }
+
+ shareAsNotice = function (title, url, domain) {
+ window.open('http://' + domain + '/notice/new?status_textarea=' + title + ' ' + url); // [1]
+ };
+
+ shareAsBookmark = function (title, url, domain) {
+ window.open('http://' + domain + '/main/bookmark/new?url=' + url + '&title=' + title); // [2]
+ };
+
+ /**
+ * Extract parameters from query string
+ *
+ * ex:
+ * ?foo=bar&baz=test
+ * will return:
+ * {foo: 'bar', baz: 'test'}
+ */
+ extractURLParams = function (queryStr) {
+ var parts = queryStr.substr(1).split('&'),
+ i, len, keyVal, params = {};
+
+ for (i = 0, len = parts.length; i < len; i += 1) {
+ keyVal = parts[i].split('=');
+ params[keyVal[0]] = keyVal[1];
+ }
+
+ return params;
+ };
+
+ // Create the form that we'll re-use throughout the page
+ createForm = function () {
+ var err = document.createElement('div');
+ err.setAttribute('class', 'gs-share-err');
+ err.setAttribute('tabindex', '-1');
+ err.setAttribute('aria-hidden', 'true');
+ err.textContent = i18n.invalidId;
+
+ frm = document.createElement('form');
+
+ frm.setAttribute('class', 'gs-share-form');
+ frm.setAttribute('tabindex', '-1');
+ frm.setAttribute('aria-hidden', 'true');
+
+ frm.innerHTML = '<label for="gs-account">' + i18n.yourAcctId + '</label>' +
+ '<input type="text" id="gs-account" placeholder="' + i18n.idPlaceholder + '" />' +
+ '<input type="checkbox" id="gs-bookmark" /> <label for="gs-bookmark">' + i18n.shareAsBookmark + '</label>' +
+ '<input type="submit" value="Share"/>';
+ frm.insertBefore(err, frm.firstChild);
+
+ // Submit handler
+ frm.addEventListener('submit', function (e) {
+ e.preventDefault();
+
+ var accountParts = document.getElementById('gs-account').value.split('@'),
+ username, domain, xhr, bookmarkURL;
+
+ if (accountParts.length === 2) {
+ err.setAttribute('aria-hidden', 'true');
+
+ username = accountParts[0];
+ domain = accountParts[1];
+ bookmarkURL = 'http://' + domain + '/api/bookmarks/' + username + '.json';
+
+ // Try bookmark
+ if (document.getElementById('gs-bookmark').checked) {
+ xhr = new XMLHttpRequest();
+
+ xhr.onreadystatechange = function () {
+ if (xhr.readyState === 4) {
+ if (xhr.status === 200) { // Success
+ shareAsBookmark(shareTitle, shareURL, domain);
+ } else { // Failure, fallback to regular notice
+ shareAsNotice(shareTitle, shareURL, domain);
+ }
+ }
+ };
+
+ xhr.open('GET', bookmarkURL, true);
+ xhr.send();
+ } else { // Regular notice
+ shareAsNotice(shareTitle, shareURL, domain);
+ }
+ } else { // Invalid account id
+ err.setAttribute('aria-hidden', 'false');
+ err.focus();
+ }
+ });
+
+ // Keydown handler
+ frm.addEventListener('keydown', function (e) {
+ if (e.keyCode === 27) { // Escape key closes the dialog
+ frm.parentElement.getElementsByClassName('js-gs-share')[0].focus();
+ frm.setAttribute('aria-hidden', 'true');
+ }
+ });
+
+ document.body.appendChild(frm);
+ };
+
+ /**
+ * Something similar to jQuery.closest
+ *
+ * Given `elm`, return the closest parent with class `cls`
+ * or false if there is no matching ancestor.
+ */
+ closest = function (elm, cls) {
+ while (elm !== document) {
+ if (elm.classList.contains(cls)) {
+ return elm;
+ }
+
+ elm = elm.parentNode;
+ }
+
+ return false;
+ };
+
+ bindClicks = function () {
+ document.addEventListener('click', function (e) {
+ var target = e.target,
+ urlParams,
+ lnk = closest(target, 'js-gs-share');
+
+ // Don't do anything on right/middle click or if ctrl or shift was pressed while left-clicking
+ if (!e.button && !e.ctrlKey && !e.shiftKey && lnk) {
+ e.preventDefault();
+
+ // Check for submission information in href first
+ if (lnk.search !== undefined) {
+ urlParams = extractURLParams(lnk.search);
+ shareURL = urlParams.url;
+ shareTitle = urlParams.title;
+ } else { // If it's not there, try data-* attributes. If not, use current document url and title
+ shareURL = lnk.getAttribute('data-url') || window.location.href;
+ shareTitle = lnk.getAttribute('data-title') || document.title;
+ }
+
+ // Move form after the clicked link
+ lnk.parentNode.appendChild(frm);
+
+ // Show form
+ frm.setAttribute('aria-hidden', 'false');
+
+ // Focus on form
+ frm.focus();
+ } else if (!frm.contains(target)) {
+ frm.setAttribute('aria-hidden', 'true');
+ }
+ });
+ };
+
+ // Flag that js is enabled
+ document.body.classList.add('js-gs-share-enabled');
+
+ createForm();
+ bindClicks();
+});
+// @license-end
diff --git a/apps/federatedfilesharing/js/settings-admin.js b/apps/federatedfilesharing/js/settings-admin.js
new file mode 100644
index 00000000000..95578bff548
--- /dev/null
+++ b/apps/federatedfilesharing/js/settings-admin.js
@@ -0,0 +1,12 @@
+$(document).ready(function() {
+
+ $('#fileSharingSettings input').change(function() {
+ var value = 'no';
+ if (this.checked) {
+ value = 'yes';
+ }
+ OC.AppConfig.setValue('files_sharing', $(this).attr('name'), value);
+ });
+
+ $('.section .icon-info').tipsy({gravity: 'w'});
+});
diff --git a/apps/federatedfilesharing/js/settings-personal.js b/apps/federatedfilesharing/js/settings-personal.js
new file mode 100644
index 00000000000..14a9b7bbfa7
--- /dev/null
+++ b/apps/federatedfilesharing/js/settings-personal.js
@@ -0,0 +1,19 @@
+$(document).ready(function() {
+
+ $('#fileSharingSettings button.pop-up').click(function() {
+ var url = $(this).data('url');
+ if (url) {
+ var width = 600;
+ var height = 400;
+ var left = (screen.width/2)-(width/2);
+ var top = (screen.height/2)-(height/2);
+
+ window.open(url, 'name', 'width=' + width + ', height=' + height + ', top=' + top + ', left=' + left);
+ }
+ });
+
+ $('#oca-files-sharing-add-to-your-website').click(function() {
+ $('#oca-files-sharing-add-to-your-website-expanded').slideDown();
+ });
+
+});
diff --git a/apps/federatedfilesharing/lib/federatedshareprovider.php b/apps/federatedfilesharing/lib/federatedshareprovider.php
index 78b0b664204..d014a6219a3 100644
--- a/apps/federatedfilesharing/lib/federatedshareprovider.php
+++ b/apps/federatedfilesharing/lib/federatedshareprovider.php
@@ -25,6 +25,8 @@ namespace OCA\FederatedFileSharing;
use OC\Share20\Share;
use OCP\Files\IRootFolder;
+use OCP\IAppConfig;
+use OCP\IConfig;
use OCP\IL10N;
use OCP\ILogger;
use OCP\Share\IShare;
@@ -65,6 +67,9 @@ class FederatedShareProvider implements IShareProvider {
/** @var IRootFolder */
private $rootFolder;
+ /** @var IConfig */
+ private $config;
+
/**
* DefaultShareProvider constructor.
*
@@ -75,6 +80,7 @@ class FederatedShareProvider implements IShareProvider {
* @param IL10N $l10n
* @param ILogger $logger
* @param IRootFolder $rootFolder
+ * @param IConfig $config
*/
public function __construct(
IDBConnection $connection,
@@ -83,7 +89,8 @@ class FederatedShareProvider implements IShareProvider {
TokenHandler $tokenHandler,
IL10N $l10n,
ILogger $logger,
- IRootFolder $rootFolder
+ IRootFolder $rootFolder,
+ IConfig $config
) {
$this->dbConnection = $connection;
$this->addressHandler = $addressHandler;
@@ -92,6 +99,7 @@ class FederatedShareProvider implements IShareProvider {
$this->l = $l10n;
$this->logger = $logger;
$this->rootFolder = $rootFolder;
+ $this->config = $config;
}
/**
@@ -601,4 +609,24 @@ class FederatedShareProvider implements IShareProvider {
// We don't handle groups here
return;
}
+
+ /**
+ * check if users from other ownCloud instances are allowed to mount public links share by this instance
+ *
+ * @return bool
+ */
+ public function isOutgoingServer2serverShareEnabled() {
+ $result = $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes');
+ return ($result === 'yes') ? true : false;
+ }
+
+ /**
+ * check if users are allowed to mount public links from other ownClouds
+ *
+ * @return bool
+ */
+ public function isIncomingServer2serverShareEnabled() {
+ $result = $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes');
+ return ($result === 'yes') ? true : false;
+ }
}
diff --git a/apps/federatedfilesharing/settings-admin.php b/apps/federatedfilesharing/settings-admin.php
new file mode 100644
index 00000000000..9dd21281fda
--- /dev/null
+++ b/apps/federatedfilesharing/settings-admin.php
@@ -0,0 +1,34 @@
+<?php
+/**
+ * @author Björn Schießle <schiessle@owncloud.com>
+ * @author Morris Jobke <hey@morrisjobke.de>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+use OCA\FederatedFileSharing\AppInfo\Application;
+
+\OC_Util::checkAdminUser();
+
+$app = new Application('federatedfilesharing');
+$federatedShareProvider = $app->getFederatedShareProvider();
+
+$tmpl = new OCP\Template('federatedfilesharing', 'settings-admin');
+$tmpl->assign('outgoingServer2serverShareEnabled', $federatedShareProvider->isOutgoingServer2serverShareEnabled());
+$tmpl->assign('incomingServer2serverShareEnabled', $federatedShareProvider->isIncomingServer2serverShareEnabled());
+
+return $tmpl->fetchPage();
diff --git a/apps/federatedfilesharing/settings-personal.php b/apps/federatedfilesharing/settings-personal.php
new file mode 100644
index 00000000000..385d3971146
--- /dev/null
+++ b/apps/federatedfilesharing/settings-personal.php
@@ -0,0 +1,52 @@
+<?php
+/**
+ * @author Björn Schießle <schiessle@owncloud.com>
+ * @author Jan-Christoph Borchardt <hey@jancborchardt.net>
+ * @author Thomas Müller <thomas.mueller@tmit.eu>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+use OCA\FederatedFileSharing\AppInfo\Application;
+
+\OC_Util::checkLoggedIn();
+
+$l = \OC::$server->getL10N('federatedfilesharing');
+
+$app = new Application('federatedfilesharing');
+$federatedShareProvider = $app->getFederatedShareProvider();
+
+$isIE8 = false;
+preg_match('/MSIE (.*?);/', $_SERVER['HTTP_USER_AGENT'], $matches);
+if (count($matches) > 0 && $matches[1] <= 9) {
+ $isIE8 = true;
+}
+
+$cloudID = \OC::$server->getUserSession()->getUser()->getCloudId();
+$url = 'https://owncloud.org/federation#' . $cloudID;
+$ownCloudLogoPath = \OC::$server->getURLGenerator()->imagePath('core', 'logo-icon.svg');
+
+$tmpl = new OCP\Template('federatedfilesharing', 'settings-personal');
+$tmpl->assign('outgoingServer2serverShareEnabled', $federatedShareProvider->isOutgoingServer2serverShareEnabled());
+$tmpl->assign('message_with_URL', $l->t('Share with me through my #ownCloud Federated Cloud ID, see %s', [$url]));
+$tmpl->assign('message_without_URL', $l->t('Share with me through my #ownCloud Federated Cloud ID', [$cloudID]));
+$tmpl->assign('owncloud_logo_path', $ownCloudLogoPath);
+$tmpl->assign('reference', $url);
+$tmpl->assign('cloudId', $cloudID);
+$tmpl->assign('showShareIT', !$isIE8);
+
+return $tmpl->fetchPage();
diff --git a/apps/federatedfilesharing/templates/settings-admin.php b/apps/federatedfilesharing/templates/settings-admin.php
new file mode 100644
index 00000000000..5d2eb04c170
--- /dev/null
+++ b/apps/federatedfilesharing/templates/settings-admin.php
@@ -0,0 +1,28 @@
+<?php
+/** @var OC_L10N $l */
+/** @var array $_ */
+script('federatedfilesharing', 'settings-admin');
+?>
+
+<div id="fileSharingSettings">
+ <h3><?php p($l->t('Federated Cloud Sharing'));?></h3>
+ <a target="_blank" rel="noreferrer" class="icon-info svg"
+ title="<?php p($l->t('Open documentation'));?>"
+ href="<?php p(link_to_docs('admin-sharing-federated')); ?>"></a>
+
+ <p>
+ <input type="checkbox" name="outgoing_server2server_share_enabled" id="outgoingServer2serverShareEnabled" class="checkbox"
+ value="1" <?php if ($_['outgoingServer2serverShareEnabled']) print_unescaped('checked="checked"'); ?> />
+ <label for="outgoingServer2serverShareEnabled">
+ <?php p($l->t('Allow users on this server to send shares to other servers'));?>
+ </label>
+ </p>
+
+ <p>
+ <input type="checkbox" name="incoming_server2server_share_enabled" id="incomingServer2serverShareEnabled" class="checkbox"
+ value="1" <?php if ($_['incomingServer2serverShareEnabled']) print_unescaped('checked="checked"'); ?> />
+ <label for="incomingServer2serverShareEnabled">
+ <?php p($l->t('Allow users on this server to receive shares from other servers'));?>
+ </label><br/>
+ </p>
+</div>
diff --git a/apps/federatedfilesharing/templates/settings-personal.php b/apps/federatedfilesharing/templates/settings-personal.php
new file mode 100644
index 00000000000..87b524af3e8
--- /dev/null
+++ b/apps/federatedfilesharing/templates/settings-personal.php
@@ -0,0 +1,78 @@
+<?php
+/** @var OC_L10N $l */
+/** @var array $_ */
+script('federatedfilesharing', 'settings-personal');
+style('federatedfilesharing', 'settings-personal');
+if ($_['showShareIT']) {
+ script('federatedfilesharing', '3rdparty/gs-share/gs-share');
+ style('federatedfilesharing', '3rdparty/gs-share/style');
+}
+?>
+
+<?php if ($_['outgoingServer2serverShareEnabled']): ?>
+ <div id="fileSharingSettings" class="section">
+ <h2><?php p($l->t('Federated Cloud')); ?></h2>
+
+ <p>
+ <?php p($l->t('Your Federated Cloud ID:')); ?>
+ <strong><?php p($_['cloudId']); ?></strong>
+ </p>
+
+ <br>
+
+ <?php if ($_['showShareIT']) {?>
+ <p>
+ <?php p($l->t('Share it:')); ?>
+ <div class="gs-share">
+ <button data-url="<?php p(urlencode($_['reference'])); ?>"
+ data-title='<?php p(urlencode($_['message_without_URL'])); ?>'
+ class='js-gs-share social-gnu'>
+ GNU Social
+ </button>
+ </div>
+ <button class="social-diaspora pop-up"
+ data-url='https://sharetodiaspora.github.io/?title=<?php p($_['message_without_URL']); ?>&url=<?php p(urlencode($_['reference'])); ?>'>
+ Diaspora
+ </button>
+ <button class="social-twitter pop-up"
+ data-url='https://twitter.com/intent/tweet?text=<?php p(urlencode($_['message_with_URL'])); ?>'>
+ Twitter
+ </button>
+ <button class="social-facebook pop-up"
+ data-url='https://www.facebook.com/sharer/sharer.php?u=<?php p(urlencode($_['reference'])); ?>'>
+ Facebook
+ </button>
+ <button class="social-googleplus pop-up"
+ data-url='https://plus.google.com/share?url=<?php p(urlencode($_['reference'])); ?>'/>
+ Google+
+ </button>
+ <button id="oca-files-sharing-add-to-your-website">
+ <?php p($l->t('Add to your website')) ?>
+ </button>
+ </p>
+
+ <div class="hidden" id="oca-files-sharing-add-to-your-website-expanded">
+ <p style="margin: 10px 0">
+ <a target="_blank" rel="noreferrer" href="<?php p($_['reference']); ?>"
+ style="padding:10px;background-color:#1d2d44;color:#fff;border-radius:3px;padding-left:4px;">
+ <img src="<?php p($_['owncloud_logo_path']); ?>"
+ style="width:50px;position:relative;top:8px;">
+ <?php p($l->t('Share with me via ownCloud')); ?>
+ </a>
+ </p>
+
+ <p>
+ <?php p($l->t('HTML Code:')); ?>
+ <xmp><a target="_blank" rel="noreferrer" href="<?php p($_['reference']); ?>"
+ style="padding:10px;background-color:#1d2d44;color:#fff;border-radius:3px;padding-left:4px;">
+ <img src="<?php p(\OC::$server->getURLGenerator()->getAbsoluteURL($_['owncloud_logo_path'])); ?>"
+ style="width:50px;position:relative;top:8px;">
+ <?php p($l->t('Share with me via ownCloud')); ?>
+
+</a></xmp>
+ </p>
+ </div>
+ <?php } ?>
+
+ </div>
+<?php endif; ?>
diff --git a/apps/federatedfilesharing/tests/federatedshareprovidertest.php b/apps/federatedfilesharing/tests/federatedshareprovidertest.php
index 92e9f10c3cd..1fbae90a46f 100644
--- a/apps/federatedfilesharing/tests/federatedshareprovidertest.php
+++ b/apps/federatedfilesharing/tests/federatedshareprovidertest.php
@@ -26,6 +26,7 @@ use OCA\FederatedFileSharing\FederatedShareProvider;
use OCA\FederatedFileSharing\Notifications;
use OCA\FederatedFileSharing\TokenHandler;
use OCP\Files\IRootFolder;
+use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\ILogger;
@@ -54,6 +55,8 @@ class FederatedShareProviderTest extends TestCase {
protected $logger;
/** @var IRootFolder | \PHPUnit_Framework_MockObject_MockObject */
protected $rootFolder;
+ /** @var IConfig | \PHPUnit_Framework_MockObject_MockObject */
+ protected $config;
/** @var IManager */
protected $shareManager;
@@ -78,6 +81,7 @@ class FederatedShareProviderTest extends TestCase {
}));
$this->logger = $this->getMock('OCP\ILogger');
$this->rootFolder = $this->getMock('OCP\Files\IRootFolder');
+ $this->config = $this->getMock('OCP\IConfig');
$this->addressHandler = new AddressHandler(\OC::$server->getURLGenerator(), $this->l);
$this->provider = new FederatedShareProvider(
@@ -87,7 +91,8 @@ class FederatedShareProviderTest extends TestCase {
$this->tokenHandler,
$this->l,
$this->logger,
- $this->rootFolder
+ $this->rootFolder,
+ $this->config
);
$this->shareManager = \OC::$server->getShareManager();
@@ -510,4 +515,43 @@ class FederatedShareProviderTest extends TestCase {
$this->assertCount($rowDeleted ? 0 : 1, $data);
}
+
+ /**
+ * @dataProvider dataTestFederatedSharingSettings
+ *
+ * @param string $isEnabled
+ * @param bool $expected
+ */
+ public function testIsOutgoingServer2serverShareEnabled($isEnabled, $expected) {
+ $this->config->expects($this->once())->method('getAppValue')
+ ->with('files_sharing', 'outgoing_server2server_share_enabled', 'yes')
+ ->willReturn($isEnabled);
+
+ $this->assertSame($expected,
+ $this->provider->isOutgoingServer2serverShareEnabled()
+ );
+ }
+
+ /**
+ * @dataProvider dataTestFederatedSharingSettings
+ *
+ * @param string $isEnabled
+ * @param bool $expected
+ */
+ public function testIsIncomingServer2serverShareEnabled($isEnabled, $expected) {
+ $this->config->expects($this->once())->method('getAppValue')
+ ->with('files_sharing', 'incoming_server2server_share_enabled', 'yes')
+ ->willReturn($isEnabled);
+
+ $this->assertSame($expected,
+ $this->provider->isIncomingServer2serverShareEnabled()
+ );
+ }
+
+ public function dataTestFederatedSharingSettings() {
+ return [
+ ['yes', true],
+ ['no', false]
+ ];
+ }
}