Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
knox committed Dec 8, 2015
2 parents 27f420e + 13993c4 commit 508c46a
Show file tree
Hide file tree
Showing 192 changed files with 3,400 additions and 459 deletions.
5 changes: 5 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
Header set X-Robots-Tag "none"
Header set X-Frame-Options "SAMEORIGIN"
SetEnv modHeadersAvailable true

# Add CSP header if not set, used for static resources
Header append Content-Security-Policy ""
Header edit Content-Security-Policy "^$" "default-src 'none'; style-src 'self' 'unsafe-inline'; script-src 'self'"
</IfModule>

# Add cache control for CSS and JS files
Expand Down Expand Up @@ -53,6 +57,7 @@
RewriteRule ^core/js/oc.js$ index.php/core/js/oc.js [PT,E=PATH_INFO:$1]
RewriteRule ^core/preview.png$ index.php/core/preview.png [PT,E=PATH_INFO:$1]
RewriteCond %{REQUEST_FILENAME} !\.(css|js|svg|gif|png|html|ttf|woff)$
RewriteCond %{REQUEST_FILENAME} !core/img/favicon.ico$
RewriteCond %{REQUEST_FILENAME} !/remote.php
RewriteCond %{REQUEST_FILENAME} !/public.php
RewriteCond %{REQUEST_FILENAME} !/cron.php
Expand Down
11 changes: 11 additions & 0 deletions .mention-bot
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"maxReviewers": 3,
"numFilesToCheck": 5,
"alwaysNotifyForPaths": [
{
"name": "DeepDiver1975",
"files": ["apps/dav/**"]
}
],
"userBlacklist": ["owncloud-bot"]
}
9 changes: 9 additions & 0 deletions apps/dav/lib/rootcollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ public function __construct() {
$caldavBackend = new CalDavBackend($db);
$calendarRoot = new CalendarRoot($principalBackend, $caldavBackend, 'principals/users');
$calendarRoot->disableListing = $disableListing;
$systemTagCollection = new SystemTag\SystemTagsByIdCollection(
\OC::$server->getSystemTagManager()
);
$systemTagRelationsCollection = new SystemTag\SystemTagsRelationsCollection(
\OC::$server->getSystemTagManager(),
\OC::$server->getSystemTagObjectMapper()
);

$usersCardDavBackend = new CardDavBackend($db, $principalBackend);
$usersAddressBookRoot = new AddressBookRoot($principalBackend, $usersCardDavBackend, 'principals/users');
Expand All @@ -51,6 +58,8 @@ public function __construct() {
new SimpleCollection('addressbooks', [
$usersAddressBookRoot,
$systemAddressBookRoot]),
$systemTagCollection,
$systemTagRelationsCollection,
];

parent::__construct('root', $children);
Expand Down
3 changes: 3 additions & 0 deletions apps/dav/lib/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public function __construct(IRequest $request, $baseUri) {
// addressbook plugins
$this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin());

// system tags plugins
$this->server->addPlugin(new \OCA\DAV\SystemTag\SystemTagPlugin(\OC::$server->getSystemTagManager()));

// Finder on OS X requires Class 2 WebDAV support (locking), since we do
// not provide locking we emulate it using a fake locking plugin.
if($request->isUserAgent(['/WebDAVFS/'])) {
Expand Down
102 changes: 102 additions & 0 deletions apps/dav/lib/systemtag/systemtagmappingnode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?php
/**
* @author Vincent Petry <[email protected]>
*
* @copyright Copyright (c) 2015, 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\DAV\SystemTag;

use Sabre\DAV\Exception\NotFound;

use OCP\SystemTag\ISystemTag;
use OCP\SystemTag\ISystemTagManager;
use OCP\SystemTag\ISystemTagObjectMapper;
use OCP\SystemTag\TagNotFoundException;

/**
* Mapping node for system tag to object id
*/
class SystemTagMappingNode extends SystemTagNode {

/**
* @var ISystemTagObjectMapper
*/
private $tagMapper;

/**
* @var string
*/
private $objectId;

/**
* @var string
*/
private $objectType;

/**
* Sets up the node, expects a full path name
*
* @param ISystemTag $tag system tag
* @param string $objectId
* @param string $objectType
* @param ISystemTagManager $tagManager
* @param ISystemTagObjectMapper $tagMapper
*/
public function __construct(
ISystemTag $tag,
$objectId,
$objectType,
ISystemTagManager $tagManager,
ISystemTagObjectMapper $tagMapper
) {
$this->objectId = $objectId;
$this->objectType = $objectType;
$this->tagMapper = $tagMapper;
parent::__construct($tag, $tagManager);
}

/**
* Returns the object id of the relationship
*
* @return string object id
*/
public function getObjectId() {
return $this->objectId;
}

/**
* Returns the object type of the relationship
*
* @return string object type
*/
public function getObjectType() {
return $this->objectType;
}

/**
* Delete tag to object association
*/
public function delete() {
try {
$this->tagMapper->unassignTags($this->objectId, $this->objectType, $this->tag->getId());
} catch (TagNotFoundException $e) {
// can happen if concurrent deletion occurred
throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found', 0, $e);
}
}
}
126 changes: 126 additions & 0 deletions apps/dav/lib/systemtag/systemtagnode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?php
/**
* @author Vincent Petry <[email protected]>
*
* @copyright Copyright (c) 2015, 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\DAV\SystemTag;

use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\Exception\MethodNotAllowed;
use Sabre\DAV\Exception\Conflict;

use OCP\SystemTag\ISystemTag;
use OCP\SystemTag\ISystemTagManager;
use OCP\SystemTag\TagNotFoundException;
use OCP\SystemTag\TagAlreadyExistsException;

/**
* DAV node representing a system tag, with the name being the tag id.
*/
class SystemTagNode implements \Sabre\DAV\INode {

/**
* @var ISystemTag
*/
protected $tag;

/**
* @var ISystemTagManager
*/
protected $tagManager;

/**
* Sets up the node, expects a full path name
*
* @param ISystemTag $tag system tag
* @param ISystemTagManager $tagManager
*/
public function __construct(ISystemTag $tag, ISystemTagManager $tagManager) {
$this->tag = $tag;
$this->tagManager = $tagManager;
}

/**
* Returns the id of the tag
*
* @return string
*/
public function getName() {
return $this->tag->getId();
}

/**
* Returns the system tag represented by this node
*
* @return ISystemTag system tag
*/
public function getSystemTag() {
return $this->tag;
}

/**
* Renames the node
*
* @param string $name The new name
*
* @throws MethodNotAllowed not allowed to rename node
*/
public function setName($name) {
throw new MethodNotAllowed();
}

/**
* Update tag
*
* @param string $name new tag name
* @param bool $userVisible user visible
* @param bool $userAssignable user assignable
* @throws NotFound whenever the given tag id does not exist
* @throws Conflict whenever a tag already exists with the given attributes
*/
public function update($name, $userVisible, $userAssignable) {
try {
$this->tagManager->updateTag($this->tag->getId(), $name, $userVisible, $userAssignable);
} catch (TagNotFoundException $e) {
throw new NotFound('Tag with id ' . $this->tag->getId() . ' does not exist');
} catch (TagAlreadyExistsException $e) {
throw new Conflict(
'Tag with the properties "' . $name . '", ' .
$userVisible . ', ' . $userAssignable . ' already exists'
);
}
}

/**
* Returns null, not supported
*
*/
public function getLastModified() {
return null;
}

public function delete() {
try {
$this->tagManager->deleteTags($this->tag->getId());
} catch (TagNotFoundException $e) {
// can happen if concurrent deletion occurred
throw new NotFound('Tag with id ' . $this->tag->getId() . ' not found', 0, $e);
}
}
}
Loading

0 comments on commit 508c46a

Please sign in to comment.