当前位置: 首页>>代码示例>>PHP>>正文


PHP Share::resolveReShare方法代码示例

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


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

示例1: 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

示例2: getByShareToken

 public static function getByShareToken($token)
 {
     $linkItem = \OCP\Share::getShareByToken($token, false);
     if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
         // seems to be a valid share
         $rootLinkItem = \OCP\Share::resolveReShare($linkItem);
     } else {
         throw new \Exception('This file was probably unshared');
     }
     $file = new File($rootLinkItem['file_source'], $rootLinkItem, $token);
     if (isset($linkItem['share_with']) && !empty($linkItem['share_with'])) {
         $file->setPasswordProtected(true);
     }
     return $file;
 }
开发者ID:owncloud,项目名称:richdocuments,代码行数:15,代码来源:file.php

示例3: setupFromToken

 /**
  * Sets up the filesystem and user for public sharing
  * @param string $token string share token
  * @param string $relativePath optional path relative to the share
  * @param string $password optional password
  * @return array
  */
 public static function setupFromToken($token, $relativePath = null, $password = null)
 {
     \OC_User::setIncognitoMode(true);
     $linkItem = \OCP\Share::getShareByToken($token, !$password);
     if ($linkItem === false || $linkItem['item_type'] !== 'file' && $linkItem['item_type'] !== 'folder') {
         \OC_Response::setStatus(404);
         \OCP\Util::writeLog('core-preview', 'Passed token parameter is not valid', \OCP\Util::DEBUG);
         exit;
     }
     if (!isset($linkItem['uid_owner']) || !isset($linkItem['file_source'])) {
         \OC_Response::setStatus(500);
         \OCP\Util::writeLog('core-preview', 'Passed token seems to be valid, but it does not contain all necessary information . ("' . $token . '")', \OCP\Util::WARN);
         exit;
     }
     $rootLinkItem = \OCP\Share::resolveReShare($linkItem);
     $path = null;
     if (isset($rootLinkItem['uid_owner'])) {
         \OCP\JSON::checkUserExists($rootLinkItem['uid_owner']);
         \OC_Util::tearDownFS();
         \OC_Util::setupFS($rootLinkItem['uid_owner']);
     }
     try {
         $path = Filesystem::getPath($linkItem['file_source']);
     } catch (NotFoundException $e) {
         \OCP\Util::writeLog('share', 'could not resolve linkItem', \OCP\Util::DEBUG);
         \OC_Response::setStatus(404);
         \OCP\JSON::error(array('success' => false));
         exit;
     }
     if (!isset($linkItem['item_type'])) {
         \OCP\Util::writeLog('share', 'No item type set for share id: ' . $linkItem['id'], \OCP\Util::ERROR);
         \OC_Response::setStatus(404);
         \OCP\JSON::error(array('success' => false));
         exit;
     }
     if (isset($linkItem['share_with']) && (int) $linkItem['share_type'] === \OCP\Share::SHARE_TYPE_LINK) {
         if (!self::authenticate($linkItem, $password)) {
             \OC_Response::setStatus(403);
             \OCP\JSON::error(array('success' => false));
             exit;
         }
     }
     $basePath = $path;
     if ($relativePath !== null && Filesystem::isReadable($basePath . $relativePath)) {
         $path .= Filesystem::normalizePath($relativePath);
     }
     return array('linkItem' => $linkItem, 'basePath' => $basePath, 'realPath' => $path);
 }
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:55,代码来源:Helper.php

示例4: getPath

 /**
  * @param $token
  * @return null|string
  */
 private function getPath($token)
 {
     $linkItem = Share::getShareByToken($token, false);
     $path = null;
     if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
         // seems to be a valid share
         $rootLinkItem = Share::resolveReShare($linkItem);
         if (isset($rootLinkItem['uid_owner'])) {
             JSON::checkUserExists($rootLinkItem['uid_owner']);
             OC_Util::tearDownFS();
             OC_Util::setupFS($rootLinkItem['uid_owner']);
             $path = Filesystem::getPath($linkItem['file_source']);
         }
     }
     return $path;
 }
开发者ID:riso,项目名称:owncloud-core,代码行数:20,代码来源:sharecontroller.php

示例5: OC_Connector_Sabre_Server

$server = new OC_Connector_Sabre_Server($objectTree);
$server->httpRequest = $requestBackend;
$server->setBaseUri($baseuri);
// Load plugins
$defaults = new OC_Defaults();
$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, $defaults->getName()));
$server->addPlugin(new \Sabre\DAV\Locks\Plugin($lockBackend));
$server->addPlugin(new \Sabre\DAV\Browser\Plugin(false));
// Show something in the Browser, but no upload
$server->addPlugin(new OC_Connector_Sabre_FilesPlugin());
$server->addPlugin(new OC_Connector_Sabre_MaintenancePlugin());
$server->addPlugin(new OC_Connector_Sabre_ExceptionLoggerPlugin('webdav'));
// wait with registering these until auth is handled and the filesystem is setup
$server->subscribeEvent('beforeMethod', function () use($server, $objectTree, $authBackend) {
    $share = $authBackend->getShare();
    $rootShare = \OCP\Share::resolveReShare($share);
    $owner = $rootShare['uid_owner'];
    $isWritable = $share['permissions'] & (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_CREATE);
    $fileId = $share['file_source'];
    if (!$isWritable) {
        \OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, $storage) {
            return new \OCA\Files_Sharing\ReadOnlyWrapper(array('storage' => $storage));
        });
    }
    OC_Util::setupFS($owner);
    $ownerView = \OC\Files\Filesystem::getView();
    $path = $ownerView->getPath($fileId);
    $view = new \OC\Files\View($ownerView->getAbsolutePath($path));
    $rootInfo = $view->getFileInfo('');
    // Create ownCloud Dir
    if ($rootInfo->getType() === 'dir') {
开发者ID:kebenxiaoming,项目名称:owncloudRedis,代码行数:31,代码来源:publicwebdav.php

示例6: array

 * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::checkAppEnabled('gallery');
if (isset($_GET['token'])) {
    $token = $_GET['token'];
    $linkItem = \OCP\Share::getShareByToken($token);
    if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
        // seems to be a valid share
        $type = $linkItem['item_type'];
        $fileSource = $linkItem['file_source'];
        $shareOwner = $linkItem['uid_owner'];
        $path = null;
        $rootLinkItem = \OCP\Share::resolveReShare($linkItem);
        $fileOwner = $rootLinkItem['uid_owner'];
        // Setup FS with owner
        OCP\JSON::checkUserExists($fileOwner);
        OC_Util::tearDownFS();
        OC_Util::setupFS($fileOwner);
        // The token defines the target directory (security reasons)
        $path = \OC\Files\Filesystem::getPath($linkItem['file_source']);
        $view = new \OC\Files\View(\OC\Files\Filesystem::getView()->getAbsolutePath($path));
        $images = $view->searchByMime('image');
        $result = array();
        foreach ($images as $image) {
            $result[] = $token . $image['path'];
        }
        OCP\JSON::setContentTypeHeader();
        echo json_encode(array('images' => $result, 'users' => array(), 'displayNames' => array()));
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:31,代码来源:getimages.php

示例7: setTokenBasedEnv

 /**
  * Creates the environment based on the linkItem the token links to
  *
  * @param array $linkItem
  */
 public function setTokenBasedEnv($linkItem)
 {
     // Resolves reshares down to the last real share
     $rootLinkItem = Share::resolveReShare($linkItem);
     $origShareOwner = $rootLinkItem['uid_owner'];
     $this->userFolder = $this->rootFolder->getUserFolder($origShareOwner);
     // This is actually the node ID
     $this->sharedNodeId = $linkItem['file_source'];
     $this->fromRootToFolder = $this->buildFromRootToFolder($this->sharedNodeId);
     $this->folderName = $linkItem['file_target'];
     $this->userId = $rootLinkItem['uid_owner'];
     $this->sharePassword = $linkItem['share_with'];
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:18,代码来源:environment.php

示例8: getSharingOps

 protected function getSharingOps()
 {
     $where = 'AND `file_source`=?';
     $values = array($this->fileId);
     if (\OCP\User::isLoggedIn()) {
         $where .= ' AND ((`share_type`=' . \OCP\Share::SHARE_TYPE_USER . ' AND `share_with`=?) OR  `share_type`=' . \OCP\Share::SHARE_TYPE_LINK . ')';
         $values[] = \OCP\User::getUser();
     } else {
         $where .= ' AND (`share_type`=' . \OCP\Share::SHARE_TYPE_LINK . ')';
     }
     $query = \OC_DB::prepare('SELECT `*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `uid_owner`, ' . '`share_type`, `share_with`, `file_source`, `path`, `file_target`, ' . '`*PREFIX*share`.`permissions`, `expiration`, `storage`, `*PREFIX*filecache`.`parent` as `file_parent`, ' . '`name`, `mtime`, `mimetype`, `mimepart`, `size`, `encrypted`, `etag`' . 'FROM `*PREFIX*share` INNER JOIN `*PREFIX*filecache` ON `file_source` = `*PREFIX*filecache`.`fileid` WHERE `item_type` = \'file\' ' . $where);
     $result = $query->execute($values);
     $shares = $result->fetchAll();
     $origins = array();
     if (is_array($shares)) {
         foreach ($shares as $share) {
             $origin = \OCP\Share::resolveReShare($share);
             if (!isset($origin['path']) && isset($origin['file_target'])) {
                 $origin['path'] = 'files/' . $origin['file_target'];
             }
             $origins[] = $origin;
         }
     }
     return $origins;
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:25,代码来源:file.php

示例9: getPath

 /**
  * @param string $token
  * @return string Resolved file path of the token
  * @throws \Exception In case share could not get properly resolved
  */
 private function getPath($token)
 {
     $linkItem = Share::getShareByToken($token, false);
     if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
         // seems to be a valid share
         $rootLinkItem = Share::resolveReShare($linkItem);
         if (isset($rootLinkItem['uid_owner'])) {
             if (!$this->userManager->userExists($rootLinkItem['uid_owner'])) {
                 throw new \Exception('Owner of the share does not exist anymore');
             }
             OC_Util::tearDownFS();
             OC_Util::setupFS($rootLinkItem['uid_owner']);
             $path = Filesystem::getPath($linkItem['file_source']);
             if (!empty($path) && Filesystem::isReadable($path)) {
                 return $path;
             }
         }
     }
     throw new \Exception('No file found belonging to file.');
 }
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:25,代码来源:sharecontroller.php

示例10: resolveReShare

 /**
  *
  * @param array $linkItem
  *@return array || null
  */
 public function resolveReShare($linkItem)
 {
     return Share::resolveReShare($linkItem);
 }
开发者ID:Rotzbua,项目名称:calendarplus,代码行数:9,代码来源:shareconnector.php

示例11: getGuestSettingsCalendar

 /**
  * @PublicPage
  * @NoCSRFRequired
  */
 public function getGuestSettingsCalendar()
 {
     $token = $this->params('t');
     if (isset($token)) {
         $linkItem = \OCP\Share::getShareByToken($token, false);
         if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
             // seems to be a valid share
             if ($linkItem['item_type'] === CalendarApp::SHARECALENDAR) {
                 $sPrefix = CalendarApp::SHARECALENDARPREFIX;
             }
             if ($linkItem['item_type'] === CalendarApp::SHAREEVENT) {
                 $sPrefix = CalendarApp::SHAREEVENTPREFIX;
             }
             $itemSource = CalendarApp::validateItemSource($linkItem['item_source'], $sPrefix);
             $shareOwner = $linkItem['uid_owner'];
             $rootLinkItem = \OCP\Share::resolveReShare($linkItem);
             if (isset($rootLinkItem['uid_owner'])) {
                 \OCP\JSON::checkUserExists($rootLinkItem['uid_owner']);
                 $calendar = CalendarCalendar::find($itemSource);
                 if (!array_key_exists('active', $calendar)) {
                     $calendar['active'] = 1;
                 }
                 if ($calendar['active'] == 1) {
                     $eventSources[] = CalendarCalendar::getEventSourceInfo($calendar, true);
                     $eventSources[0]['url'] = \OC::$server->getURLGenerator()->linkToRoute($this->appName . '.public.getEventsPublic') . '?t=' . $token;
                     $calendarInfo[$calendar['id']] = array('bgcolor' => $calendar['calendarcolor'], 'color' => CalendarCalendar::generateTextColor($calendar['calendarcolor']));
                     $myRefreshChecker[$calendar['id']] = $calendar['ctag'];
                 }
             }
         }
         $defaultView = 'month';
         if ($this->session->get('public_currentView') != '') {
             $defaultView = (string) $this->session->get('public_currentView');
         }
         $params = ['status' => 'success', 'defaultView' => $defaultView, 'agendatime' => 'HH:mm { - HH:mm}', 'defaulttime' => 'HH:mm', 'firstDay' => '1', 'calendarId' => $calendar['id'], 'eventSources' => $eventSources, 'calendarcolors' => $calendarInfo, 'myRefreshChecker' => $myRefreshChecker];
         $response = new JSONResponse($params);
         return $response;
     }
 }
开发者ID:Bullnados,项目名称:calendarplus,代码行数:43,代码来源:publiccontroller.php

示例12: index

 /**
  *@PublicPage
  * @NoCSRFRequired
  * @UseSession
  */
 public function index($token)
 {
     if ($token) {
         $linkItem = Share::getShareByToken($token, false);
         if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
             $type = $linkItem['item_type'];
             $itemSource = CalendarApp::validateItemSource($linkItem['item_source'], CalendarApp::SHARETODOPREFIX);
             $shareOwner = $linkItem['uid_owner'];
             $calendarName = $linkItem['item_target'];
             $rootLinkItem = \OCP\Share::resolveReShare($linkItem);
             // stupid copy and paste job
             if (isset($linkItem['share_with'])) {
                 // Authenticate share_with
                 $password = $this->params('password');
                 if (isset($password)) {
                     if ($linkItem['share_type'] === \OCP\Share::SHARE_TYPE_LINK) {
                         // Check Password
                         $newHash = '';
                         if (\OC::$server->getHasher()->verify($password, $linkItem['share_with'], $newHash)) {
                             $this->session->set('public_link_authenticated', $linkItem['id']);
                             if (!empty($newHash)) {
                             }
                         } else {
                             \OCP\Util::addStyle('files_sharing', 'authenticate');
                             $params = array('wrongpw' => true);
                             return new TemplateResponse('files_sharing', 'authenticate', $params, 'guest');
                         }
                     } else {
                         \OCP\Util::writeLog('share', 'Unknown share type ' . $linkItem['share_type'] . ' for share id ' . $linkItem['id'], \OCP\Util::ERROR);
                         return false;
                     }
                 } else {
                     // Check if item id is set in session
                     if (!$this->session->exists('public_link_authenticated') || $this->session->get('public_link_authenticated') !== $linkItem['id']) {
                         // Prompt for password
                         \OCP\Util::addStyle('files_sharing', 'authenticate');
                         $params = array();
                         return new TemplateResponse('files_sharing', 'authenticate', $params, 'guest');
                     }
                 }
             }
             \OCP\Util::addStyle(CalendarApp::$appname, '3rdparty/fontello/css/animation');
             \OCP\Util::addStyle(CalendarApp::$appname, '3rdparty/fontello/css/fontello');
             \OCP\Util::addStyle($this->appName, 'style');
             \OCP\Util::addStyle($this->appName, 'share');
             \OCP\Util::addScript($this->appName, 'share');
             $data = TasksApp::getEventObject($itemSource, false, false);
             $l = \OC::$server->getL10N($this->appName);
             $object = VObject::parse($data['calendardata']);
             $vTodo = $object->VTODO;
             $id = $data['id'];
             $object = Object::cleanByAccessClass($id, $object);
             $accessclass = $vTodo->getAsString('CLASS');
             $permissions = TasksApp::getPermissions($id, TasksApp::TODO, $accessclass);
             if ($accessclass === 'PRIVATE') {
                 header('HTTP/1.0 404 Not Found');
                 $response = new TemplateResponse('core', '404', '', 'guest');
                 return $response;
             }
             $categories = $vTodo->getAsArray('CATEGORIES');
             $summary = strtr($vTodo->getAsString('SUMMARY'), array('\\,' => ',', '\\;' => ';'));
             $location = strtr($vTodo->getAsString('LOCATION'), array('\\,' => ',', '\\;' => ';'));
             $description = strtr($vTodo->getAsString('DESCRIPTION'), array('\\,' => ',', '\\;' => ';'));
             $priorityOptionsArray = TasksApp::getPriorityOptionsFilterd();
             //$priorityOptions=$priorityOptionsArray[(string)$vTodo->priority];
             $priorityOptions = 0;
             $link = strtr($vTodo->getAsString('URL'), array('\\,' => ',', '\\;' => ';'));
             $TaskDate = '';
             $TaskTime = '';
             if ($vTodo->DUE) {
                 $dateDueType = $vTodo->DUE->getValueType();
                 if ($dateDueType == 'DATE') {
                     $TaskDate = $vTodo->DUE->getDateTime()->format('d.m.Y');
                     $TaskTime = '';
                 }
                 if ($dateDueType == 'DATE-TIME') {
                     $TaskDate = $vTodo->DUE->getDateTime()->format('d.m.Y');
                     $TaskTime = $vTodo->DUE->getDateTime()->format('H:i');
                 }
             }
             $TaskStartTime = '';
             $TaskStartDate = '';
             if ($vTodo->DTSTART) {
                 $dateStartType = $vTodo->DTSTART->getValueType();
                 if ($dateStartType === 'DATE') {
                     $TaskStartDate = $vTodo->DTSTART->getDateTime()->format('d.m.Y');
                     $TaskStartTime = '';
                 }
                 if ($dateStartType === 'DATE-TIME') {
                     $TaskStartDate = $vTodo->DTSTART->getDateTime()->format('d.m.Y');
                     $TaskStartTime = $vTodo->DTSTART->getDateTime()->format('H:i');
                 }
             }
             //PERCENT-COMPLETE
             $cptlStatus = (string) $this->l10n->t('needs action');
//.........这里部分代码省略.........
开发者ID:ejouvin,项目名称:tasksplus,代码行数:101,代码来源:publiccontroller.php

示例13: setTokenBasedEnv

 /**
  * Creates the environment based on the linkItem the token links to
  *
  * @param array $linkItem
  */
 public function setTokenBasedEnv($linkItem)
 {
     // Resolves reshares down to the last real share
     $rootLinkItem = Share::resolveReShare($linkItem);
     $origShareOwner = $rootLinkItem['uid_owner'];
     $this->userFolder = $this->serverContainer->getUserFolder($origShareOwner);
     // TODO: Replace with this in 8.2 (https://github.com/owncloud/core/pull/16965)
     // You get root by calling getRootFolder() on the server container
     //$this->userFolder = $this->root->getUserFolder($origShareOwner);
     // This is actually the node ID
     $this->sharedNodeId = $linkItem['file_source'];
     $this->fromRootToFolder = $this->buildFromRootToFolder($this->sharedNodeId);
     $this->folderName = $linkItem['file_target'];
     $this->userId = $rootLinkItem['uid_owner'];
     $this->sharePassword = $linkItem['share_with'];
 }
开发者ID:patman15,项目名称:galleryplus,代码行数:21,代码来源:environment.php


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