本文整理汇总了PHP中OC\Share\Share::shareItem方法的典型用法代码示例。如果您正苦于以下问题:PHP Share::shareItem方法的具体用法?PHP Share::shareItem怎么用?PHP Share::shareItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC\Share\Share
的用法示例。
在下文中一共展示了Share::shareItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: shareItem
/**
* Share an item with a user, group, or via private link
* @param string $itemType
* @param string $itemSource
* @param int $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
* @param string $shareWith User or group the item is being shared with
* @param int $permissions CRUDS
* @param string $itemSourceName
* @param \DateTime $expirationDate
* @return bool|string Returns true on success or false on failure, Returns token on success for links
* @throws \Exception
*/
public static function shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions, $itemSourceName = null, \DateTime $expirationDate = null)
{
return \OC\Share\Share::shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions, $itemSourceName, $expirationDate);
}
示例2: shareFile
/**
* @param $fid
* @param $uid
* @param $wUid
* @return bool|string
* @throws \Exception
* @throws \OC\HintException
*/
public function shareFile($uid, $wUid, $fid, $permission = 1)
{
$isEnabled = \OCP\Share::isEnabled();
$isAllowed = \OCP\Share::isResharingAllowed();
$sharedWith = \OCP\Share::getUsersItemShared('file', $fid, $uid, false, true);
//$file = $this->connect->files()->getInfoById($fid);
if ($isEnabled && $isAllowed && !in_array($wUid, $sharedWith)) {
// \OCP\Constants::PERMISSION_READ
// \OCP\Constants::PERMISSION_ALL
// \OCP\Share::SHARE_TYPE_LINK
// \OCP\Share::SHARE_TYPE_USER,
$shareIsSuccess = \OC\Share\Share::shareItem('file', $fid, \OCP\Share::SHARE_TYPE_USER, $wUid, $permission);
if ($shareIsSuccess) {
$this->connect->update('*PREFIX*share', ['uid_initiator' => $uid], 'share_with = :share_with AND uid_owner = :uid_owner AND file_source = :file_source', [':share_with' => $wUid, ':uid_owner' => $uid, ':file_source' => $fid]);
$token = \OC\Share\Share::shareItem('file', $fid, \OCP\Share::SHARE_TYPE_LINK, $wUid, $permission);
$this->connect->update('*PREFIX*share', ['uid_initiator' => $uid, 'share_with' => null], 'uid_owner = :uid_owner AND file_source = :file_source AND token = :token', [':uid_owner' => $uid, ':file_source' => $fid, ':token' => $token]);
return $token;
}
}
}