• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP OCP\Share类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中OCP\Share的典型用法代码示例。如果您正苦于以下问题:PHP Share类的具体用法?PHP Share怎么用?PHP Share使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Share类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: moveShareToShare

 /**
  * Fix for https://github.com/owncloud/core/issues/20769
  *
  * The owner is allowed to move their files (if they are shared) into a receiving folder
  * In this case we need to update the parent of the moved share. Since they are
  * effectively handing over ownership of the file the rest of the code needs to know
  * they need to build up the reshare tree.
  *
  * @param string $path
  */
 private static function moveShareToShare($path)
 {
     $userFolder = \OC::$server->getUserFolder();
     // If the user folder can't be constructed (e.g. link share) just return.
     if ($userFolder === null) {
         return;
     }
     $src = $userFolder->get($path);
     $type = $src instanceof \OCP\Files\File ? 'file' : 'folder';
     $shares = \OCP\Share::getItemShared($type, $src->getId());
     // If the path we move is not a share we don't care
     if (empty($shares)) {
         return;
     }
     // Check if the destination is inside a share
     $mountManager = \OC::$server->getMountManager();
     $dstMount = $mountManager->find($src->getPath());
     if (!$dstMount instanceof \OCA\Files_Sharing\SharedMount) {
         return;
     }
     $parenShare = $dstMount->getShare();
     foreach ($shares as $share) {
         $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();
         $qb->update('share')->set('parent', $qb->createNamedParameter($parenShare['id']))->where($qb->expr()->eq('id', $qb->createNamedParameter($share['id'])))->execute();
     }
 }
开发者ID:farukuzun,项目名称:core-1,代码行数:36,代码来源:updater.php


示例2: getGroups

	/**
	 * @NoAdminRequired
	 */
	public function getGroups() {
		$tags = $this->tags->getTags();

		foreach ($tags as &$tag) {
			try {
				$ids = $this->tags->getIdsForTag($tag['id']);
				$tag['contacts'] = $ids;
				$tag['displayname'] = $this->displayName($tag);
			} catch(\Exception $e) {
				\OCP\Util::writeLog('contacts', __METHOD__ . ', ' . $e->getMessage(), \OCP\Util::ERROR);
			}
		}

		$favorites = $this->tags->getFavorites();

		$shares = \OCP\Share::getItemsSharedWith('addressbook', \OCA\Contacts\Share\Addressbook::FORMAT_ADDRESSBOOKS);
		$addressbookShare = new \OCA\Contacts\Share\Addressbook();
		foreach ($shares as $key => $share) {
			$children = $addressbookShare->getChildren($share['id']); // FIXME: This should be cheaper!
			$shares[$key]['length'] = count($children);
		}

		$groups = array(
			'categories' => $tags,
			'favorites' => $favorites,
			'shared' => $shares,
			'lastgroup' => \OCP\Config::getUserValue(\OCP\User::getUser(), 'contacts', 'lastgroup', 'all'),
			'sortorder' => \OCP\Config::getUserValue(\OCP\User::getUser(), 'contacts', 'groupsort', ''),
			);

		return new JSONResponse($groups);
	}
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:35,代码来源:groupcontroller.php


示例3: getACL

 /**
  * Returns a list of ACE's for this node.
  *
  * Each ACE has the following properties:
  *   * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
  *     currently the only supported privileges
  *   * 'principal', a url to the principal who owns the node
  *   * 'protected' (optional), indicating that this ACE is not allowed to
  *      be updated.
  *
  * @return array
  */
 public function getACL()
 {
     $readprincipal = $this->getOwner();
     $writeprincipal = $this->getOwner();
     $createprincipal = $this->getOwner();
     $deleteprincipal = $this->getOwner();
     $uid = AddrBook::extractUserID($this->getOwner());
     //\OCP\Config::setUserValue($uid, 'contactsplus', 'syncaddrbook', $this->addressBookInfo['uri']);
     $readWriteACL = array(array('privilege' => '{DAV:}read', 'principal' => 'principals/' . \OCP\User::getUser(), 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => 'principals/' . \OCP\User::getUser(), 'protected' => true));
     if ($uid !== \OCP\USER::getUser()) {
         $sharedAddressbook = \OCP\Share::getItemSharedWithBySource(ContactsApp::SHAREADDRESSBOOK, ContactsApp::SHAREADDRESSBOOKPREFIX . $this->addressBookInfo['id']);
         if ($sharedAddressbook) {
             if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_CREATE && $sharedAddressbook['permissions'] & \OCP\PERMISSION_UPDATE && $sharedAddressbook['permissions'] & \OCP\PERMISSION_DELETE) {
                 return $readWriteACL;
             }
             if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_CREATE) {
                 $createprincipal = 'principals/' . \OCP\USER::getUser();
             }
             if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_READ) {
                 $readprincipal = 'principals/' . \OCP\USER::getUser();
             }
             if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_UPDATE) {
                 $writeprincipal = 'principals/' . \OCP\USER::getUser();
             }
             if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_DELETE) {
                 $deleteprincipal = 'principals/' . \OCP\USER::getUser();
             }
         }
     } else {
         return parent::getACL();
     }
     return array(array('privilege' => '{DAV:}read', 'principal' => $readprincipal, 'protected' => true), array('privilege' => '{DAV:}write-content', 'principal' => $writeprincipal, 'protected' => true), array('privilege' => '{DAV:}bind', 'principal' => $createprincipal, 'protected' => true), array('privilege' => '{DAV:}unbind', 'principal' => $deleteprincipal, 'protected' => true));
 }
开发者ID:sahne123,项目名称:contactsplus,代码行数:45,代码来源:addressbook.php


示例4: getCalendarsForUser

 /**
  * Returns a list of calendars for a principal.
  *
  * Every project is an array with the following keys:
  *  * id, a unique id that will be used by other functions to modify the
  *	calendar. This can be the same as the uri or a database key.
  *  * uri, which the basename of the uri with which the calendar is
  *	accessed.
  *  * principalUri. The owner of the calendar. Almost always the same as
  *	principalUri passed to this method.
  *
  * Furthermore it can contain webdav properties in clark notation. A very
  * common one is '{DAV:}displayname'.
  *
  * @param string $principalUri
  * @return array
  */
 public function getCalendarsForUser($principalUri)
 {
     $raw = \OC_Calendar_Calendar::allCalendarsWherePrincipalURIIs($principalUri);
     $calendars = array();
     foreach ($raw as $row) {
         $components = explode(',', $row['components']);
         $sharedCalendar = \OCP\Share::getItemSharedWithBySource('calendar', $row['id']);
         if ($row['userid'] !== User::getUser() && empty($sharedCalendar)) {
             continue;
         }
         if ($row['userid'] != User::getUser()) {
             $row['uri'] = $row['uri'] . '_shared_by_' . $row['userid'];
         }
         $calendar = array('id' => $row['id'], 'uri' => $row['uri'], 'principaluri' => 'principals/' . \OCP\User::getUser(), '{' . \Sabre\CalDAV\Plugin::NS_CALENDARSERVER . '}getctag' => $row['ctag'] ? $row['ctag'] : '0', '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new \Sabre\CalDAV\Property\SupportedCalendarComponentSet($components));
         foreach ($this->propertyMap as $xmlName => $dbName) {
             $calendar[$xmlName] = isset($row[$dbName]) ? $row[$dbName] : '';
         }
         $calendars[] = $calendar;
     }
     if (\OCP\App::isEnabled('contacts')) {
         $ctag = 0;
         $app = new \OCA\Contacts\App();
         $addressBooks = $app->getAddressBooksForUser();
         foreach ($addressBooks as $addressBook) {
             $tmp = $addressBook->lastModified();
             if (!is_null($tmp)) {
                 $ctag = max($ctag, $tmp);
             }
         }
         $ctag++;
         $calendars[] = array('id' => 'contact_birthdays', 'uri' => 'contact_birthdays', '{DAV:}displayname' => (string) \OC_Calendar_App::$l10n->t('Contact birthdays'), 'principaluri' => 'principals/' . \OCP\User::getUser(), '{' . \Sabre\CalDAV\Plugin::NS_CALENDARSERVER . '}getctag' => $ctag, '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new \Sabre\CalDAV\Property\SupportedCalendarComponentSet(array('VEVENT')), '{http://apple.com/ns/ical/}calendar-color' => '#CCCCCC');
     }
     return $calendars;
 }
开发者ID:BacLuc,项目名称:newGryfiPage,代码行数:51,代码来源:backend.php


示例5: unShare

 /**
  * @param $fileId the fileId of the file
  * @param $shareWIth the ownCloud user to share the file with
  */
 private function unShare($fileId, $shareWIth)
 {
     try {
         \OCP\Share::unshare('file', $fileId, \OCP\Share::SHARE_TYPE_USER, $shareWIth);
     } catch (\Exception $e) {
     }
 }
开发者ID:arun-TK,项目名称:chat,代码行数:11,代码来源:removefile.php


示例6: getAccessList

 /**
  * get list of users with access to the file
  *
  * @param string $path to the file
  * @return array
  */
 public function getAccessList($path)
 {
     // Make sure that a share key is generated for the owner too
     list($owner, $ownerPath) = $this->util->getUidAndFilename($path);
     // always add owner to the list of users with access to the file
     $userIds = array($owner);
     if (!$this->util->isFile($ownerPath)) {
         return array('users' => $userIds, 'public' => false);
     }
     $ownerPath = substr($ownerPath, strlen('/files'));
     $ownerPath = $this->util->stripPartialFileExtension($ownerPath);
     // Find out who, if anyone, is sharing the file
     $result = \OCP\Share::getUsersSharingFile($ownerPath, $owner);
     $userIds = \array_merge($userIds, $result['users']);
     $public = $result['public'] || $result['remote'];
     // check if it is a group mount
     if (\OCP\App::isEnabled("files_external")) {
         $mounts = \OC_Mount_Config::getSystemMountPoints();
         foreach ($mounts as $mount) {
             if ($mount['mountpoint'] == substr($ownerPath, 1, strlen($mount['mountpoint']))) {
                 $mountedFor = $this->util->getUserWithAccessToMountPoint($mount['applicable']['users'], $mount['applicable']['groups']);
                 $userIds = array_merge($userIds, $mountedFor);
             }
         }
     }
     // Remove duplicate UIDs
     $uniqueUserIds = array_unique($userIds);
     return array('users' => $uniqueUserIds, 'public' => $public);
 }
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:35,代码来源:file.php


示例7: testGetParents

 function testGetParents()
 {
     $fileinfo1 = $this->view->getFileInfo($this->folder);
     $fileinfo2 = $this->view->getFileInfo($this->folder . $this->subfolder . $this->subsubfolder);
     $fileinfo3 = $this->view->getFileInfo($this->folder . $this->subfolder . $this->subsubfolder . $this->filename);
     $this->assertTrue(\OCP\Share::shareItem('folder', $fileinfo1['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31));
     $this->assertTrue(\OCP\Share::shareItem('folder', $fileinfo2['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER3, 31));
     $backend = new \OC_Share_Backend_Folder();
     $result = $backend->getParents($fileinfo3['fileid']);
     $this->assertSame(2, count($result));
     $count1 = 0;
     $count2 = 0;
     foreach ($result as $r) {
         if ($r['path'] === 'files' . $this->folder) {
             $this->assertSame(ltrim($this->folder, '/'), $r['collection']['path']);
             $count1++;
         } elseif ($r['path'] === 'files' . $this->folder . $this->subfolder . $this->subsubfolder) {
             $this->assertSame(ltrim($this->subsubfolder, '/'), $r['collection']['path']);
             $count2++;
         } else {
             $this->assertTrue(false, 'unexpected result');
         }
     }
     $this->assertSame(1, $count1);
     $this->assertSame(1, $count2);
     $result1 = $backend->getParents($fileinfo3['fileid'], self::TEST_FILES_SHARING_API_USER3);
     $this->assertSame(1, count($result1));
     $elemet = reset($result1);
     $this->assertSame('files' . $this->folder . $this->subfolder . $this->subsubfolder, $elemet['path']);
     $this->assertSame(ltrim($this->subsubfolder, '/'), $elemet['collection']['path']);
 }
开发者ID:Romua1d,项目名称:core,代码行数:31,代码来源:backend.php


示例8: generateTarget

 public function generateTarget($itemSource, $shareWith, $exclude = null)
 {
     // Always make target be test.txt to cause conflicts
     if (substr($itemSource, 0, strlen('test')) !== 'test') {
         $target = "test.txt";
     } else {
         $target = $itemSource;
     }
     $shares = \OCP\Share::getItemsSharedWithUser('test', $shareWith);
     $knownTargets = array();
     foreach ($shares as $share) {
         $knownTargets[] = $share['item_target'];
     }
     if (in_array($target, $knownTargets)) {
         $pos = strrpos($target, '.');
         $name = substr($target, 0, $pos);
         $ext = substr($target, $pos);
         $append = '';
         $i = 1;
         while (in_array($name . $append . $ext, $knownTargets)) {
             $append = $i;
             $i++;
         }
         $target = $name . $append . $ext;
     }
     return $target;
 }
开发者ID:Romua1d,项目名称:core,代码行数:27,代码来源:backend.php


示例9: __construct

 public function __construct()
 {
     $timeNow = time();
     //test
     $checkOffset = new \DateTime(date('d.m.Y', $timeNow), new \DateTimeZone(self::$tz));
     $calcSumWin = $checkOffset->getOffset();
     $this->nowTime = strtotime(date('d.m.Y H:i', $timeNow)) + $calcSumWin;
     if (\OC::$server->getSession()->get('public_link_token')) {
         $linkItem = \OCP\Share::getShareByToken(\OC::$server->getSession()->get('public_link_token', false));
         if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
             if ($linkItem['item_type'] === App::SHARECALENDAR) {
                 $sPrefix = App::SHARECALENDARPREFIX;
             }
             if ($linkItem['item_type'] === App::SHAREEVENT) {
                 $sPrefix = App::SHAREEVENTPREFIX;
             }
             if ($linkItem['item_type'] === App::SHARETODO) {
                 $sPrefix = App::SHARETODOPREFIX;
             }
             $itemSource = App::validateItemSource($linkItem['item_source'], $sPrefix);
             $rootLinkItem = Calendar::find($itemSource);
             $this->aCalendars[] = $rootLinkItem;
         }
     } else {
         if (\OCP\User::isLoggedIn()) {
             $this->aCalendars = Calendar::allCalendars(\OCP\User::getUser());
             $this->checkAlarm();
         }
     }
 }
开发者ID:Rotzbua,项目名称:calendarplus,代码行数:30,代码来源:alarm.php


示例10: getACL

 /**
  * Returns a list of ACE's for this node.
  *
  * Each ACE has the following properties:
  *   * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
  *     currently the only supported privileges
  *   * 'principal', a url to the principal who owns the node
  *   * 'protected' (optional), indicating that this ACE is not allowed to
  *      be updated.
  *
  * @return array
  */
 public function getACL()
 {
     $readprincipal = $this->getOwner();
     $writeprincipal = $this->getOwner();
     $createprincipal = $this->getOwner();
     $deleteprincipal = $this->getOwner();
     $uid = $this->carddavBackend->userIDByPrincipal($this->getOwner());
     $readWriteACL = array(array('privilege' => '{DAV:}read', 'principal' => 'principals/' . \OCP\User::getUser(), 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => 'principals/' . \OCP\User::getUser(), 'protected' => true));
     if ($uid !== \OCP\User::getUser()) {
         list($backendName, $id) = explode('::', $this->addressBookInfo['id']);
         $sharedAddressbook = \OCP\Share::getItemSharedWithBySource('addressbook', $id);
         if ($sharedAddressbook) {
             if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_CREATE && $sharedAddressbook['permissions'] & \OCP\PERMISSION_UPDATE && $sharedAddressbook['permissions'] & \OCP\PERMISSION_DELETE) {
                 return $readWriteACL;
             }
             if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_CREATE) {
                 $createprincipal = 'principals/' . \OCP\User::getUser();
             }
             if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_READ) {
                 $readprincipal = 'principals/' . \OCP\User::getUser();
             }
             if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_UPDATE) {
                 $writeprincipal = 'principals/' . \OCP\User::getUser();
             }
             if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_DELETE) {
                 $deleteprincipal = 'principals/' . \OCP\User::getUser();
             }
         }
     } else {
         return parent::getACL();
     }
     return array(array('privilege' => '{DAV:}read', 'principal' => $readprincipal, 'protected' => true), array('privilege' => '{DAV:}write-content', 'principal' => $writeprincipal, 'protected' => true), array('privilege' => '{DAV:}bind', 'principal' => $createprincipal, 'protected' => true), array('privilege' => '{DAV:}unbind', 'principal' => $deleteprincipal, 'protected' => true));
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:45,代码来源:addressbook.php


示例11: exportEvents

 /**
  *@PublicPage
  * @NoCSRFRequired
  * 
  */
 public function exportEvents()
 {
     $token = $this->params('t');
     $calid = null;
     $eventid = null;
     if (isset($token)) {
         $linkItem = \OCP\Share::getShareByToken($token, false);
         if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
             $rootLinkItem = \OCP\Share::resolveReShare($linkItem);
             if (isset($rootLinkItem['uid_owner'])) {
                 \OCP\JSON::checkUserExists($rootLinkItem['uid_owner']);
                 if ($linkItem['item_type'] === CalendarApp::SHARECALENDAR) {
                     $sPrefix = CalendarApp::SHARECALENDARPREFIX;
                 }
                 if ($linkItem['item_type'] === CalendarApp::SHAREEVENT) {
                     $sPrefix = CalendarApp::SHAREEVENTPREFIX;
                 }
                 if ($linkItem['item_type'] === CalendarApp::SHARETODO) {
                     $sPrefix = CalendarApp::SHARETODOPREFIX;
                 }
                 $itemSource = CalendarApp::validateItemSource($linkItem['item_source'], $sPrefix);
                 if ($linkItem['item_type'] === CalendarApp::SHARECALENDAR) {
                     $calid = $itemSource;
                 }
                 if ($linkItem['item_type'] === CalendarApp::SHAREEVENT || $linkItem['item_type'] === CalendarApp::SHARETODO) {
                     $eventid = $itemSource;
                 }
             }
         }
     } else {
         if (\OCP\User::isLoggedIn()) {
             $calid = $this->params('calid');
             $eventid = $this->params('eventid');
         }
     }
     if (!is_null($calid)) {
         $calendar = CalendarApp::getCalendar($calid, true);
         if (!$calendar) {
             $params = ['status' => 'error'];
             $response = new JSONResponse($params);
             return $response;
         }
         $name = str_replace(' ', '_', $calendar['displayname']) . '.ics';
         $calendarEvents = Export::export($calid, Export::CALENDAR);
         $response = new DataDownloadResponse($calendarEvents, $name, 'text/calendar');
         return $response;
     }
     if (!is_null($eventid)) {
         $data = CalendarApp::getEventObject($eventid, false);
         if (!$data) {
             $params = ['status' => 'error'];
             $response = new JSONResponse($params);
             return $response;
         }
         $name = str_replace(' ', '_', $data['summary']) . '.ics';
         $singleEvent = Export::export($eventid, Export::EVENT);
         $response = new DataDownloadResponse($singleEvent, $name, 'text/calendar');
         return $response;
     }
 }
开发者ID:Bullnados,项目名称:calendarplus,代码行数:65,代码来源:exportcontroller.php


示例12: validateUserPass

 /**
  * Validates a username and password
  *
  * This method should return true or false depending on if login
  * succeeded.
  *
  * @param string $username
  * @param string $password
  *
  * @return bool
  */
 protected function validateUserPass($username, $password)
 {
     $linkItem = \OCP\Share::getShareByToken($username, false);
     \OC_User::setIncognitoMode(true);
     $this->share = $linkItem;
     if (!$linkItem) {
         return false;
     }
     // check if the share is password protected
     if (isset($linkItem['share_with'])) {
         if ($linkItem['share_type'] == \OCP\Share::SHARE_TYPE_LINK) {
             // Check Password
             $forcePortable = CRYPT_BLOWFISH != 1;
             $hasher = new \PasswordHash(8, $forcePortable);
             if (!$hasher->CheckPassword($password . $this->config->getSystemValue('passwordsalt', ''), $linkItem['share_with'])) {
                 return false;
             } else {
                 return true;
             }
         } else {
             return false;
         }
     } else {
         return true;
     }
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:37,代码来源:publicauth.php


示例13: testSizePropagationWhenRecipientChangesFile

 public function testSizePropagationWhenRecipientChangesFile()
 {
     $this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
     $recipientView = new View('/' . self::TEST_FILES_SHARING_API_USER1 . '/files');
     $this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $ownerView = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
     $ownerView->mkdir('/sharedfolder/subfolder');
     $ownerView->file_put_contents('/sharedfolder/subfolder/foo.txt', 'bar');
     $sharedFolderInfo = $ownerView->getFileInfo('/sharedfolder', false);
     $this->assertInstanceOf('\\OC\\Files\\FileInfo', $sharedFolderInfo);
     \OCP\Share::shareItem('folder', $sharedFolderInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER1, 31);
     $ownerRootInfo = $ownerView->getFileInfo('', false);
     $this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
     $this->assertTrue($recipientView->file_exists('/sharedfolder/subfolder/foo.txt'));
     $recipientRootInfo = $recipientView->getFileInfo('', false);
     // when file changed as recipient
     $recipientView->file_put_contents('/sharedfolder/subfolder/foo.txt', 'foobar');
     // size of recipient's root stays the same
     $newRecipientRootInfo = $recipientView->getFileInfo('', false);
     $this->assertEquals($recipientRootInfo->getSize(), $newRecipientRootInfo->getSize());
     // size of owner's root increases
     $this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $newOwnerRootInfo = $ownerView->getFileInfo('', false);
     $this->assertEquals($ownerRootInfo->getSize() + 3, $newOwnerRootInfo->getSize());
 }
开发者ID:evanjt,项目名称:core,代码行数:25,代码来源:sizepropagation.php


示例14: getACL

 /**
  * Returns a list of ACE's for this node.
  *
  * Each ACE has the following properties:
  *   * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
  *     currently the only supported privileges
  *   * 'principal', a url to the principal who owns the node
  *   * 'protected' (optional), indicating that this ACE is not allowed to
  *      be updated.
  *
  * @return array
  */
 public function getACL()
 {
     $readprincipal = $this->getOwner();
     $writeprincipal = $this->getOwner();
     $uid = CalendarCalendar::extractUserID($this->getOwner());
     $calendar = CalendarApp::getCalendar($this->calendarInfo['id'], false, false);
     if ($uid === \OCP\USER::getUser() && (bool) $calendar['issubscribe'] === true) {
         $readprincipal = 'principals/' . \OCP\USER::getUser();
         $writeprincipal = '';
     }
     if ($uid !== \OCP\USER::getUser()) {
         $sharedCalendar = \OCP\Share::getItemSharedWithBySource(CalendarApp::SHARECALENDAR, CalendarApp::SHARECALENDARPREFIX . $this->calendarInfo['id']);
         if ($sharedCalendar && $sharedCalendar['permissions'] & \OCP\PERMISSION_READ) {
             $readprincipal = 'principals/' . \OCP\USER::getUser();
             $writeprincipal = '';
         }
         if ($sharedCalendar && $sharedCalendar['permissions'] & \OCP\PERMISSION_UPDATE) {
             $readprincipal = 'principals/' . \OCP\USER::getUser();
             $writeprincipal = 'principals/' . \OCP\USER::getUser();
         }
     }
     $acl = array(array('privilege' => '{DAV:}read', 'principal' => $readprincipal, 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal, 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-read', 'protected' => true), array('privilege' => '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}read-free-busy', 'principal' => '{DAV:}authenticated', 'protected' => true));
     if (empty($this->calendarInfo['{http://sabredav.org/ns}read-only'])) {
         $acl[] = ['privilege' => '{DAV:}write', 'principal' => $writeprincipal, 'protected' => true];
         $acl[] = ['privilege' => '{DAV:}write', 'principal' => $writeprincipal . '/calendar-proxy-write', 'protected' => true];
     }
     return $acl;
 }
开发者ID:Bullnados,项目名称:calendarplus,代码行数:40,代码来源:calendar.php


示例15: getAddressBook

 /**
  * Returns a specific address book.
  *
  * @param string $addressbookid
  * @param mixed $id Contact ID
  * @return mixed
  */
 public function getAddressBook($addressbookid, array $options = array())
 {
     $addressBook = \OCP\Share::getItemSharedWithBySource('addressbook', $addressbookid, Contacts\Share\Addressbook::FORMAT_ADDRESSBOOKS);
     // Not sure if I'm doing it wrongly, or if its supposed to return
     // the info in an array?
     $addressBook = isset($addressBook['permissions']) ? $addressBook : $addressBook[0];
     $addressBook['backend'] = $this->name;
     return $addressBook;
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:16,代码来源:shared.php


示例16: tearDown

 function tearDown()
 {
     $this->sharedCache->clear();
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     $fileinfo = $this->view->getFileInfo('container/shareddir');
     \OCP\Share::unshare('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
     $this->view->deleteAll('container');
     $this->ownerCache->clear();
     parent::tearDown();
 }
开发者ID:Romua1d,项目名称:core,代码行数:10,代码来源:watcher.php


示例17: getMountsForUser

 /**
  * Get all mountpoints applicable for the user and check for shares where we need to update the etags
  *
  * @param \OCP\IUser $user
  * @param \OCP\Files\Storage\IStorageFactory $storageFactory
  * @return \OCP\Files\Mount\IMountPoint[]
  */
 public function getMountsForUser(IUser $user, IStorageFactory $storageFactory)
 {
     $shares = \OCP\Share::getItemsSharedWithUser('file', $user->getUID());
     $shares = array_filter($shares, function ($share) {
         return $share['permissions'] > 0;
     });
     $shares = array_map(function ($share) use($user, $storageFactory) {
         return new SharedMount('\\OC\\Files\\Storage\\Shared', '/' . $user->getUID() . '/' . $share['file_target'], array('share' => $share, 'user' => $user->getUID()), $storageFactory);
     }, $shares);
     // array_filter removes the null values from the array
     return array_filter($shares);
 }
开发者ID:evanjt,项目名称:core,代码行数:19,代码来源:mountprovider.php


示例18: addressBookDeletion

 /**
  * Delete any registred address books (Future)
  */
 public static function addressBookDeletion($parameters)
 {
     // Clean up sharing
     \OCP\Share::unshareAll('addressbook', $parameters['addressbookid']);
     if (count($parameters['contactids'])) {
         // Remove contacts from groups
         $tagMgr = \OC::$server->getTagManager()->load('contact');
         $tagMgr->purgeObjects($parameters['contactids']);
         // Purge property indexes
         Utils\Properties::purgeIndexes($parameters['contactids']);
     }
 }
开发者ID:untitaker,项目名称:contacts,代码行数:15,代码来源:hooks.php


示例19: sendInternalShareMail

 /**
  * inform users if a file was shared with them
  *
  * @param array $recipientList list of recipients
  * @param string $itemSource shared item source
  * @param string $itemType shared item type
  * @return array list of user to whom the mail send operation failed
  */
 public function sendInternalShareMail($recipientList, $itemSource, $itemType)
 {
     $noMail = [];
     foreach ($recipientList as $recipient) {
         $recipientDisplayName = \OCP\User::getDisplayName($recipient);
         $to = $this->config->getUserValue($recipient, 'settings', 'email', '');
         if ($to === '') {
             $noMail[] = $recipientDisplayName;
             continue;
         }
         $items = \OCP\Share::getItemSharedWithUser($itemType, $itemSource, $recipient);
         $filename = trim($items[0]['file_target'], '/');
         $subject = (string) $this->l->t('%s shared »%s« with you', array($this->senderDisplayName, $filename));
         $expiration = null;
         if (isset($items[0]['expiration'])) {
             try {
                 $date = new DateTime($items[0]['expiration']);
                 $expiration = $date->getTimestamp();
             } catch (\Exception $e) {
                 $this->logger->error("Couldn't read date: " . $e->getMessage(), ['app' => 'sharing']);
             }
         }
         // Link to folder, or root folder if a file
         if ($itemType === 'folder') {
             $args = array('dir' => $filename);
         } else {
             if (strpos($filename, '/')) {
                 $args = array('dir' => '/' . dirname($filename), 'scrollto' => basename($filename));
             } else {
                 $args = array('dir' => '/', 'scrollto' => $filename);
             }
         }
         $link = \OCP\Util::linkToAbsolute('files', 'index.php', $args);
         list($htmlBody, $textBody) = $this->createMailBody($filename, $link, $expiration);
         // send it out now
         try {
             $message = $this->mailer->createMessage();
             $message->setSubject($subject);
             $message->setTo([$to => $recipientDisplayName]);
             $message->setHtmlBody($htmlBody);
             $message->setPlainBody($textBody);
             $message->setFrom([\OCP\Util::getDefaultEmailAddress('sharing-noreply') => (string) $this->l->t('%s via %s', [$this->senderDisplayName, $this->defaults->getName()])]);
             if (!is_null($this->replyTo)) {
                 $message->setReplyTo([$this->replyTo]);
             }
             $this->mailer->send($message);
         } catch (\Exception $e) {
             $this->logger->error("Can't send mail to inform the user about an internal share: " . $e->getMessage(), ['app' => 'sharing']);
             $noMail[] = $recipientDisplayName;
         }
     }
     return $noMail;
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:61,代码来源:mailnotifications.php


示例20: setUp

 protected function setUp()
 {
     parent::setUp();
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     \OCP\Share::registerBackend('test', 'Test_Share_Backend');
     $config = $this->getMockBuilder('\\OCP\\IConfig')->disableOriginalConstructor()->getMock();
     $certificateManager = $this->getMock('\\OCP\\ICertificateManager');
     $httpHelperMock = $this->getMockBuilder('\\OC\\HTTPHelper')->setConstructorArgs(array($config, $certificateManager))->getMock();
     $httpHelperMock->expects($this->any())->method('post')->with($this->anything())->will($this->returnValue(true));
     $this->registerHttpHelper($httpHelperMock);
     $this->s2s = new \OCA\Files_Sharing\API\Server2Server();
 }
开发者ID:riso,项目名称:owncloud-core,代码行数:12,代码来源:server2server.php



注:本文中的OCP\Share类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP OCP\USER类代码示例发布时间:2022-05-23
下一篇:
PHP OCP\JSON类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap