]> source.dussan.org Git - nextcloud-server.git/commitdiff
Now added enabled element
authorRoeland Jago Douma <roeland@famdouma.nl>
Mon, 9 Feb 2015 13:26:49 +0000 (14:26 +0100)
committerRoeland Jago Douma <roeland@famdouma.nl>
Wed, 11 Mar 2015 14:02:55 +0000 (15:02 +0100)
This change allows for more generic parsing for the capabilities.

apps/files_sharing/lib/capabilities.php
apps/files_sharing/tests/capabilities.php

index 95ee810bc9f2898b7c95277cfce023256a327ada..21822b18503f970b2d8150c7252145a04932539c 100644 (file)
@@ -5,7 +5,7 @@
  * later.
  * See the COPYING-README file.
  */
+
 namespace OCA\Files_Sharing;
 
 use \OCP\IConfig;
@@ -43,14 +43,14 @@ class Capabilities {
        public function getCaps() {
                $res = array();
 
-               $public = false;
-               if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') {
-                       $public = array();
+               $public = array();
+               $public['enabled'] = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes';
+               if ($public['enabled']) {
                        $public['password_enforced'] = ($this->config->getAppValue('core', 'shareapi_enforce_links_password', 'yes') === 'yes');
 
-                       $public['expire_date'] = false;
-                       if ($this->config->getAppValue('core', 'shareapi_default_expire_date', 'yes') === 'yes') {
-                               $public['expire_date'] = array();
+                       $public['expire_date'] = array();
+                       $public['expire_date']['enabled'] = $this->config->getAppValue('core', 'shareapi_default_expire_date', 'yes') === 'yes';
+                       if ($public['expire_date']['enabled']) {
                                $public['expire_date']['days'] = $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7');
                                $public['expire_date']['enforce'] = $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'yes') === 'yes';
                        }
index 1b63030501b2ef39739bfaccc9eaeb688b6bfa0a..a9980c63fea8344f29d192c1e25c484babb8c1ca 100644 (file)
@@ -53,7 +53,8 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
                        array('core', 'shareapi_allow_links', 'yes', 'no'),
                );
                $result = $this->getResults($map);
-               $this->assertFalse($result['public']);
+               $this->assertInternalType('array', $result['public']);
+               $this->assertFalse($result['public']['enabled']);
        }
 
        /**
@@ -65,6 +66,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
                );
                $result = $this->getResults($map);
                $this->assertInternalType('array', $result['public']);
+               $this->assertTrue($result['public']['enabled']);
        }
 
        /**
@@ -103,7 +105,8 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
                );
                $result = $this->getResults($map);
                $this->assertArrayHasKey('expire_date', $result['public']);
-               $this->assertFalse($result['public']['expire_date']);
+               $this->assertInternalType('array', $result['public']['expire_date']);
+               $this->assertFalse($result['public']['expire_date']['enabled']);
        }
 
        /**
@@ -119,6 +122,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
                $result = $this->getResults($map);
                $this->assertArrayHasKey('expire_date', $result['public']);
                $this->assertInternalType('array', $result['public']['expire_date']);
+               $this->assertTrue($result['public']['expire_date']['enabled']);
                $this->assertArrayHasKey('days', $result['public']['expire_date']);
                $this->assertFalse($result['public']['expire_date']['enforce']);
        }