2015-10-30 15:09:07 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @author Roeland Jago Douma <rullzer@owncloud.com>
|
|
|
|
*
|
|
|
|
* @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 OC\Share20;
|
|
|
|
|
|
|
|
use OCP\Files\Node;
|
|
|
|
use OCP\IUser;
|
|
|
|
use OCP\IGroup;
|
|
|
|
|
2015-10-30 15:10:08 +03:00
|
|
|
class Share implements IShare {
|
2015-10-30 15:09:07 +03:00
|
|
|
|
|
|
|
/** @var string */
|
2015-10-30 15:10:08 +03:00
|
|
|
private $id;
|
2015-10-30 15:09:07 +03:00
|
|
|
/** @var Node */
|
|
|
|
private $path;
|
|
|
|
/** @var int */
|
|
|
|
private $shareType;
|
|
|
|
/** @var IUser|IGroup|string */
|
2015-10-30 15:10:08 +03:00
|
|
|
private $sharedWith;
|
2015-10-30 15:09:07 +03:00
|
|
|
/** @var IUser|string */
|
|
|
|
private $sharedBy;
|
|
|
|
/** @var IUser|string */
|
|
|
|
private $shareOwner;
|
|
|
|
/** @var int */
|
|
|
|
private $permissions;
|
|
|
|
/** @var \DateTime */
|
|
|
|
private $expireDate;
|
|
|
|
/** @var string */
|
|
|
|
private $password;
|
2015-10-30 15:10:08 +03:00
|
|
|
/** @var string */
|
|
|
|
private $token;
|
|
|
|
/** @var int */
|
|
|
|
private $parent;
|
2015-11-02 23:06:55 +03:00
|
|
|
/** @var string */
|
|
|
|
private $target;
|
2015-11-06 14:05:19 +03:00
|
|
|
/** @var int */
|
|
|
|
private $shareTime;
|
|
|
|
/** @var bool */
|
|
|
|
private $mailSend;
|
2015-11-02 23:06:55 +03:00
|
|
|
|
2015-10-30 15:09:07 +03:00
|
|
|
/**
|
2015-10-30 15:10:08 +03:00
|
|
|
* Set the id of the share
|
2015-10-30 15:09:07 +03:00
|
|
|
*
|
2015-11-24 11:58:37 +03:00
|
|
|
* @param string $id
|
2015-10-30 15:09:07 +03:00
|
|
|
* @return Share The modified object
|
|
|
|
*/
|
2015-10-30 15:10:08 +03:00
|
|
|
public function setId($id) {
|
|
|
|
$this->id = $id;
|
2015-10-30 15:09:07 +03:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the id of the share
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getId() {
|
2015-10-30 15:10:08 +03:00
|
|
|
return $this->id;
|
2015-10-30 15:09:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the path of this share
|
|
|
|
*
|
|
|
|
* @param Node $path
|
|
|
|
* @return Share The modified object
|
|
|
|
*/
|
|
|
|
public function setPath(Node $path) {
|
|
|
|
$this->path = $path;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the path of this share for the current user
|
|
|
|
*
|
|
|
|
* @return Node
|
|
|
|
*/
|
|
|
|
public function getPath() {
|
|
|
|
return $this->path;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the shareType
|
|
|
|
*
|
|
|
|
* @param int $shareType
|
|
|
|
* @return Share The modified object
|
|
|
|
*/
|
|
|
|
public function setShareType($shareType) {
|
|
|
|
$this->shareType = $shareType;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the shareType
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getShareType() {
|
|
|
|
return $this->shareType;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-30 15:10:08 +03:00
|
|
|
* Set the receiver of this share
|
2015-10-30 15:09:07 +03:00
|
|
|
*
|
|
|
|
* @param IUser|IGroup|string
|
|
|
|
* @return Share The modified object
|
|
|
|
*/
|
2015-10-30 15:10:08 +03:00
|
|
|
public function setSharedWith($sharedWith) {
|
|
|
|
$this->sharedWith = $sharedWith;
|
2015-10-30 15:09:07 +03:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-30 15:10:08 +03:00
|
|
|
* Get the receiver of this share
|
2015-10-30 15:09:07 +03:00
|
|
|
*
|
|
|
|
* @return IUser|IGroup|string
|
|
|
|
*/
|
2015-10-30 15:10:08 +03:00
|
|
|
public function getSharedWith() {
|
|
|
|
return $this->sharedWith;
|
2015-10-30 15:09:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the permissions
|
|
|
|
*
|
|
|
|
* @param int $permissions
|
|
|
|
* @return Share The modified object
|
|
|
|
*/
|
|
|
|
public function setPermissions($permissions) {
|
|
|
|
//TODO checkes
|
|
|
|
|
|
|
|
$this->permissions = $permissions;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the share permissions
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getPermissions() {
|
|
|
|
return $this->permissions;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the expiration date
|
|
|
|
*
|
|
|
|
* @param \DateTime $expireDate
|
|
|
|
* @return Share The modified object
|
|
|
|
*/
|
2015-12-15 11:52:04 +03:00
|
|
|
public function setExpirationDate($expireDate) {
|
2015-10-30 15:09:07 +03:00
|
|
|
//TODO checks
|
|
|
|
|
|
|
|
$this->expireDate = $expireDate;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the share expiration date
|
|
|
|
*
|
|
|
|
* @return \DateTime
|
|
|
|
*/
|
|
|
|
public function getExpirationDate() {
|
|
|
|
return $this->expireDate;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the sharer of the path
|
|
|
|
*
|
|
|
|
* @param IUser|string $sharedBy
|
|
|
|
* @return Share The modified object
|
|
|
|
*/
|
|
|
|
public function setSharedBy($sharedBy) {
|
|
|
|
//TODO checks
|
|
|
|
$this->sharedBy = $sharedBy;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get share sharer
|
|
|
|
*
|
|
|
|
* @return IUser|string
|
|
|
|
*/
|
|
|
|
public function getSharedBy() {
|
|
|
|
//TODO check if set
|
|
|
|
return $this->sharedBy;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the original share owner (who owns the path)
|
|
|
|
*
|
|
|
|
* @param IUser|string
|
|
|
|
*
|
|
|
|
* @return Share The modified object
|
|
|
|
*/
|
|
|
|
public function setShareOwner($shareOwner) {
|
|
|
|
//TODO checks
|
|
|
|
|
|
|
|
$this->shareOwner = $shareOwner;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the original share owner (who owns the path)
|
|
|
|
*
|
|
|
|
* @return IUser|string
|
|
|
|
*/
|
|
|
|
public function getShareOwner() {
|
|
|
|
//TODO check if set
|
|
|
|
return $this->shareOwner;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the password
|
|
|
|
*
|
|
|
|
* @param string $password
|
|
|
|
*
|
|
|
|
* @return Share The modified object
|
|
|
|
*/
|
|
|
|
public function setPassword($password) {
|
|
|
|
//TODO verify
|
|
|
|
|
|
|
|
$this->password = $password;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the password
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2015-11-06 14:05:19 +03:00
|
|
|
public function getPassword() {
|
2015-10-30 15:09:07 +03:00
|
|
|
return $this->password;
|
|
|
|
}
|
2015-10-30 15:10:08 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the token
|
|
|
|
*
|
|
|
|
* @param string $token
|
|
|
|
* @return Share The modified object
|
|
|
|
*/
|
|
|
|
public function setToken($token) {
|
|
|
|
$this->token = $token;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the token
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getToken() {
|
|
|
|
return $this->token;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the parent id of this share
|
|
|
|
*
|
|
|
|
* @param int $parent
|
|
|
|
* @return Share The modified object
|
|
|
|
*/
|
|
|
|
public function setParent($parent) {
|
|
|
|
$this->parent = $parent;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the parent id of this share
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getParent() {
|
|
|
|
return $this->parent;
|
|
|
|
}
|
2015-11-02 23:06:55 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the target of this share
|
|
|
|
*
|
2015-11-24 11:58:37 +03:00
|
|
|
* @param string $target
|
2015-11-02 23:06:55 +03:00
|
|
|
* @return Share The modified object
|
|
|
|
*/
|
|
|
|
public function setTarget($target) {
|
|
|
|
$this->target = $target;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the target of this share
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getTarget() {
|
|
|
|
return $this->target;
|
|
|
|
}
|
2015-11-06 14:05:19 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the time this share was created
|
|
|
|
*
|
|
|
|
* @param int $shareTime
|
|
|
|
* @return Share The modified object
|
|
|
|
*/
|
|
|
|
public function setShareTime($shareTime) {
|
|
|
|
$this->shareTime = $shareTime;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the timestamp this share was created
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getSharetime() {
|
|
|
|
return $this->shareTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set mailSend
|
|
|
|
*
|
|
|
|
* @param bool $mailSend
|
|
|
|
* @return Share The modified object
|
|
|
|
*/
|
|
|
|
public function setMailSend($mailSend) {
|
|
|
|
$this->mailSend = $mailSend;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get mailSend
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function getMailSend() {
|
|
|
|
return $this->mailSend;
|
|
|
|
}
|
2015-10-30 15:09:07 +03:00
|
|
|
}
|