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


PHP Share::getShareByToken方法代码示例

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


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

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

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

示例3: getByShareToken

 public static function getByShareToken($token)
 {
     $linkItem = \OCP\Share::getShareByToken($token);
     if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
         // seems to be a valid share
         $rootLinkItem = \OCP\Share::resolveReShare($linkItem);
         $fileOwner = $rootLinkItem['uid_owner'];
     } else {
         throw new \Exception('This file was probably unshared');
     }
     if (!isset($rootLinkItem['path']) && isset($rootLinkItem['file_target'])) {
         $rootLinkItem['path'] = 'files/' . $rootLinkItem['file_target'];
     }
     $file = new File($rootLinkItem['file_source'], array($rootLinkItem));
     if (isset($rootLinkItem['uid_owner'])) {
         \OC_Util::tearDownFS();
         \OC_Util::setupFS($rootLinkItem['uid_owner']);
         $file->setOwner($rootLinkItem['uid_owner']);
         $file->setPath('/files' . \OC\Files\Filesystem::getPath($linkItem['file_source']));
     }
     if (isset($linkItem['share_with']) && !empty($linkItem['share_with'])) {
         $file->setPasswordProtected(true);
     }
     return $file;
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:25,代码来源:file.php

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

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

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

示例7: 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
             $newHash = '';
             if (\OC::$server->getHasher()->verify($password, $linkItem['share_with'], $newHash)) {
                 /**
                  * FIXME: Migrate old hashes to new hash format
                  * Due to the fact that there is no reasonable functionality to update the password
                  * of an existing share no migration is yet performed there.
                  * The only possibility is to update the existing share which will result in a new
                  * share ID and is a major hack.
                  *
                  * In the future the migration should be performed once there is a proper method
                  * to update the share's password. (for example `$share->updatePassword($password)`
                  *
                  * @link https://github.com/owncloud/core/issues/10671
                  */
                 if (!empty($newHash)) {
                 }
                 return true;
             } else {
                 if (\OC::$server->getSession()->exists('public_link_authenticated') && \OC::$server->getSession()->get('public_link_authenticated') === $linkItem['id']) {
                     return true;
                 } else {
                     return false;
                 }
             }
         } else {
             if ($linkItem['share_type'] == \OCP\Share::SHARE_TYPE_REMOTE) {
                 return true;
             } else {
                 return false;
             }
         }
     } else {
         return true;
     }
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:58,代码来源:publicauth.php

示例8: testShowShareWithNotExistingUser

 /**
  * @expectedException \Exception
  * @expectedExceptionMessage Owner of the share does not exist anymore
  */
 public function testShowShareWithNotExistingUser()
 {
     $this->container['UserManager']->expects($this->once())->method('userExists')->with($this->user)->will($this->returnValue(false));
     $linkItem = Share::getShareByToken($this->token, false);
     \OC::$server->getSession()->set('public_link_authenticated', $linkItem['id']);
     $this->shareController->showShare($this->token);
 }
开发者ID:DaubaKao,项目名称:owncloud-core,代码行数:11,代码来源:sharecontroller.php

示例9: isset

<?php

\OCP\JSON::checkAppEnabled('gallery');
OCP\Util::addStyle('gallery', 'styles');
OCP\Util::addStyle('gallery', 'mobile');
$token = isset($_GET['t']) ? (string) $_GET['t'] : '';
if ($token) {
    $linkItem = \OCP\Share::getShareByToken($token, false);
    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'];
        $albumName = trim($linkItem['file_target'], '//');
        $ownerDisplayName = \OC_User::getDisplayName($fileOwner);
        // stupid copy and paste job
        if (isset($linkItem['share_with'])) {
            // Authenticate share_with
            $url = OCP\Util::linkToPublic('gallery') . '&t=' . $token;
            if (isset($_GET['file'])) {
                $url .= '&file=' . urlencode($_GET['file']);
            } else {
                if (isset($_GET['dir'])) {
                    $url .= '&dir=' . urlencode($_GET['dir']);
                }
            }
            if (isset($_POST['password'])) {
                $password = $_POST['password'];
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:31,代码来源:public.php

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

示例11: isset

<?php

/**
 * 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');
$square = isset($_GET['square']) ? (bool) $_GET['square'] : false;
$scale = isset($_GET['scale']) ? $_GET['scale'] : 1;
$images = explode(';', $_GET['image']);
if (!empty($_GET['token'])) {
    $linkItem = \OCP\Share::getShareByToken($_GET['token']);
    if (!(is_array($linkItem) && isset($linkItem['uid_owner']))) {
        exit;
    }
    // seems to be a valid share
    $rootLinkItem = \OCP\Share::resolveReShare($linkItem);
    $user = $rootLinkItem['uid_owner'];
    // Setup filesystem
    OCP\JSON::checkUserExists($user);
    OC_Util::tearDownFS();
    OC_Util::setupFS($user);
    $root = \OC\Files\Filesystem::getPath($linkItem['file_source']) . '/';
    $images = array_map(function ($image) use($root) {
        return $root . $image;
    }, $images);
} else {
    $root = '';
    OCP\JSON::checkLoggedIn();
开发者ID:yheric455042,项目名称:owncloud82,代码行数:31,代码来源:batch.php

示例12: DateTime

 $expiration = null;
 if (isset($_POST['expiration']) && $_POST['expiration'] !== '') {
     try {
         $date = new DateTime((string) $_POST['expiration']);
         $expiration = $date->getTimestamp();
     } catch (Exception $e) {
         \OCP\Util::writeLog('sharing', "Couldn't read date: " . $e->getMessage(), \OCP\Util::ERROR);
     }
 }
 $result = $mailNotification->sendLinkShareMail($to_address, $file, $link, $expiration);
 if (empty($result)) {
     // Get the token from the link
     $linkParts = explode('/', $link);
     $token = array_pop($linkParts);
     // Get the share for the token
     $share = \OCP\Share::getShareByToken($token, false);
     if ($share !== false) {
         $currentUser = \OC::$server->getUserSession()->getUser()->getUID();
         $file = '/' . ltrim($file, '/');
         // Check whether share belongs to the user and whether the file is the same
         if ($share['file_target'] === $file && $share['uid_owner'] === $currentUser) {
             // Get the path for the user
             $view = new \OC\Files\View('/' . $currentUser . '/files');
             $fileId = (int) $share['item_source'];
             $path = $view->getPath((int) $share['item_source']);
             if ($path !== null) {
                 $event = \OC::$server->getActivityManager()->generateEvent();
                 $event->setApp(\OCA\Files_Sharing\Activity::FILES_SHARING_APP)->setType(\OCA\Files_Sharing\Activity::TYPE_SHARED)->setAuthor($currentUser)->setAffectedUser($currentUser)->setObject('files', $fileId, $path)->setSubject(\OCA\Files_Sharing\Activity::SUBJECT_SHARED_EMAIL, [$path, $to_address]);
                 \OC::$server->getActivityManager()->publish($event);
             }
         }
开发者ID:yheric455042,项目名称:owncloud82,代码行数:31,代码来源:share.php

示例13: getShareByToken

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

示例14: list

<?php

/**
 * 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');
list($owner, $img) = explode('/', $_GET['file'], 2);
$linkItem = \OCP\Share::getShareByToken($owner);
if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
    // seems to be a valid share
    $rootLinkItem = \OCP\Share::resolveReShare($linkItem);
    $user = $rootLinkItem['uid_owner'];
    // Setup filesystem
    OCP\JSON::checkUserExists($user);
    OC_Util::tearDownFS();
    OC_Util::setupFS($user);
    $fullPath = \OC\Files\Filesystem::getPath($linkItem['file_source']);
    if ($fullPath === null) {
        exit;
    }
    $img = trim($fullPath . '/' . $img);
} else {
    OCP\JSON::checkLoggedIn();
    $user = OCP\User::getUser();
}
session_write_close();
$square = isset($_GET['square']) ? (bool) $_GET['square'] : false;
$image = new \OCA\Gallery\Thumbnail('/' . $img, $user, $square);
开发者ID:droiter,项目名称:openwrt-on-android,代码行数:31,代码来源:thumbnail.php

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


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