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


PHP Share::getUsersItemShared方法代码示例

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


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

示例1: 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;
         }
     }
 }
开发者ID:Werdffelynir,项目名称:owncollab_talks,代码行数:28,代码来源:files.php

示例2: shareFiles

 /**
  * Share selected files with selected users
  */
 public function shareFiles()
 {
     $this->prepareUsersForShare();
     $files = array();
     foreach ($this->files as $id) {
         $files[] = $file = $this->files->getById($id)[0];
         $fileOwner = \OC\Files\Filesystem::getOwner($file['path']);
         $sharetype = $file['mimetype'] == 2 ? 'folder' : 'file';
         $sharedWith = \OCP\Share::getUsersItemShared($sharetype, $file['fileid'], $fileOwner, false, true);
         foreach ($this->subscriberToShare as $userid) {
             if (isset($file['fileid']) && is_array($file) && !in_array($userid, $sharedWith) && !($userid == $this->author) && ($fileOwner == $this->author || $file['permissions'] >= 16)) {
                 \OCP\Share::shareItem($sharetype, $file['fileid'], \OCP\Share::SHARE_TYPE_USER, $userid, 1);
             }
         }
     }
     $this->forSend['messagedata']['attachlinks'] = Helper::makeAttachLinks($this->files, $files);
 }
开发者ID:bogolubov,项目名称:owncollab_talks-1,代码行数:20,代码来源:answers.php

示例3: shareHook

 /**
  * @param array $params
  */
 public static function shareHook($params)
 {
     if ($params['itemType'] === 'file' || $params['itemType'] === 'folder') {
         if (isset($params['uidOwner'])) {
             $uidOwner = $params['uidOwner'];
         } else {
             $uidOwner = \OCP\User::getUser();
         }
         $users = \OCP\Share::getUsersItemShared($params['itemType'], $params['fileSource'], $uidOwner, true, false);
         if (!empty($users)) {
             while (!empty($users)) {
                 $reshareUsers = array();
                 foreach ($users as $user) {
                     if ($user !== $uidOwner) {
                         $etag = \OC\Files\Filesystem::getETag('');
                         \OCP\Config::setUserValue($user, 'files_sharing', 'etag', $etag);
                         // Look for reshares
                         $reshareUsers = array_merge($reshareUsers, \OCP\Share::getUsersItemShared('file', $params['fileSource'], $user, true));
                     }
                 }
                 $users = $reshareUsers;
             }
         }
     }
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:28,代码来源:updater.php

示例4: save

 public function save()
 {
     $files = $this->connect->files();
     $users = $this->connect->users();
     //$user = $users->getById($this->userId)[0];
     //Helper::uploadFile($_FILES['uploadfile'], $this->userId);
     foreach ($_POST['users'] as $s => $subscriber) {
         if (!($subscriber == $this->userId)) {
             $subscribers[$subscriber] = $users->getUserDetails($subscriber);
         }
     }
     // Get subscribers group
     foreach ($_POST['groups'] as $group) {
         $groupsid = array();
         if (!empty($group)) {
             $groupsid[] = $group;
         }
     }
     $from = count($groupsid) > 0 ? $groupsid : $this->userId;
     // Share selected files with selected users
     $filesid = array();
     foreach ($_POST['upload-files'] as $id) {
         $file = $files->getById($id)[0];
         $fileOwner = \OC\Files\Filesystem::getOwner($file['path']);
         $sharetype = $file['mimetype'] == 2 ? 'folder' : 'file';
         $sharedWith = \OCP\Share::getUsersItemShared($sharetype, $file['fileid'], $fileOwner, false, true);
         foreach ($subscribers as $userid => $user) {
             if (isset($file['fileid']) && is_array($file) && isset($file['fileid']) && !in_array($userid, $sharedWith) && !($userid == $this->userId)) {
                 \OCP\Share::shareItem($sharetype, $file['fileid'], \OCP\Share::SHARE_TYPE_USER, $userid, 1);
                 $filesid[] = $id;
             }
         }
     }
     foreach ($_POST['select-files'] as $id => $on) {
         if ($on == 'on') {
             $file = $files->getById($id)[0];
             $fileOwner = \OC\Files\Filesystem::getOwner($file['path']);
             $sharetype = $file['mimetype'] == 2 ? 'folder' : 'file';
             $sharedWith = \OCP\Share::getUsersItemShared($sharetype, $file['fileid'], $fileOwner, false, true);
             foreach ($subscribers as $userid => $user) {
                 if (isset($file['fileid']) && is_array($file) && isset($file['fileid']) && !in_array($userid, $sharedWith) && !($userid == $this->userId)) {
                     //Helper::shareFile($file['name'], $user, $userid);
                     \OCP\Share::shareItem($sharetype, $file['fileid'], \OCP\Share::SHARE_TYPE_USER, $userid, 1);
                     $filesid[] = $id;
                 }
             }
         }
     }
     $messagedata = array('rid' => $_POST['replyid'], 'date' => date("Y-m-d h:i:s"), 'title' => $_POST['title'], 'text' => Helper::checkTxt($_POST['message-body']), 'attachements' => implode(',', $filesid), 'author' => $this->userId, 'subscribers' => implode(',', array_keys($subscribers)), 'hash' => isset($_POST['talkhash']) && !empty($_POST['talkhash']) ? $_POST['talkhash'] : md5(date("Y-m-d h:i:s") . '' . $_POST['title']), 'status' => 0);
     $messages = $this->connect->messages();
     $saved = $messages->save($messagedata);
     if ($saved) {
         $messagedata['attachlinks'] = Helper::makeAttachLinks($filesid, $files);
         $this->sendMessage($saved, $subscribers, $from, $messagedata);
     }
     $canwrite = true;
     //TODO: Створити перевірку на право починати бесіди
     $usermessages = $this->getUserMessages();
     $talks = $usermessages->getByAuthorOrSubscriber($this->userId, '0');
     $firsttalk = $messages->getByParent($talks[0]['messageid'], 'date ASC');
     if ($canwrite) {
         header('Location: /index.php/apps/' . $this->appName . '/all');
         exit;
         /* $params = array(
         				'user' => $this->userId,
         				'message' => $_POST,
         				'messages' => $talks,
         				'answers' => $firsttalk,
         				'appname' => $this->appName,
         				'files' => $files,
         				'mode' => 'list',
         				'menu' => 'all'
         			);
         
         			return new TemplateResponse($this->appName, 'talk', $params);  // templates/talk.php
         			 */
     } else {
         return;
     }
 }
开发者ID:bogolubov,项目名称:owncollab_talks-1,代码行数:80,代码来源:maincontroller.29.04.2016.php

示例5: shareFileToUsers

 private function shareFileToUsers(\OC\Files\FileInfo $file, array $uids)
 {
     $user = $this->configurator->get('collab_user');
     $result = [];
     $owner = $user;
     $shareType = $file['mimetype'] == 2 ? 'folder' : 'file';
     $sharedWith = \OCP\Share::getUsersItemShared($shareType, $file['fileid'], $owner, false, true);
     $isEnabled = \OCP\Share::isEnabled();
     $isAllowed = \OCP\Share::isResharingAllowed();
     if ($isEnabled && $isAllowed) {
         $sharedUsers = is_array($sharedWith) ? array_values($sharedWith) : [];
         foreach ($uids as $uid) {
             if ($owner == $uid || in_array($uid, $sharedUsers)) {
                 continue;
             }
             // \OCP\Share::SHARE_TYPE_USER
             // \OCP\Constants::PERMISSION_ALL
             //$resultToken = \OCP\Share::shareItem($shareType, $file['fileid'], 0, $uid, 31);
             $resultToken = $this->connect->files()->shareFile($owner, $uid, $file['fileid'], \OCP\Constants::PERMISSION_ALL);
             $result[$uid] = ['uid' => $uid, 'file' => $file['path'], 'file_token' => $resultToken];
         }
     }
     return $result;
 }
开发者ID:raceface2nd,项目名称:owncollab,代码行数:24,代码来源:apicontroller.php

示例6: shareFiles

 /**
  * Share selected files with selected users
  */
 public function shareFiles()
 {
     $this->prepareUsersForShare();
     $files = array();
     foreach ($this->files as $id) {
         $file = $this->Files->getById($id)[0];
         $fileOwner = \OC\Files\Filesystem::getOwner($file['path']);
         $sharetype = $file['mimetype'] == 2 ? 'folder' : 'file';
         $sharedWith = \OCP\Share::getUsersItemShared($sharetype, $file['fileid'], $fileOwner, false, true);
         $isenabled = \OCP\Share::isEnabled();
         $isallowed = \OCP\Share::isResharingAllowed();
         foreach ($this->subscriberToShare as $userid) {
             if (isset($file['fileid']) && is_array($file) && !in_array($userid, $sharedWith) && !($userid == $this->author) && ($fileOwner == $this->author || $file['permissions'] >= 16) && $isenabled && $isallowed) {
                 //try {
                 \OCP\Share::shareItem($sharetype, $file['fileid'], \OCP\Share::SHARE_TYPE_USER, $userid, 1);
                 $files[] = $file['fileid'];
                 //}
                 //catch (\Exception $e) {
                 //	echo $e->getMessage();
                 //}
             }
         }
     }
     $this->forSaveData['attachements'] = $files;
     $this->fileLinks = Helper::makeAttachLinks($files, $this->Files);
     //print_r($this->fileLinks);
     //file_put_contents('/tmp/inb.log', "\n\nfileLinks : "print_r($this->fileLinks, true)."\n", FILE_APPEND);
     /* foreach ($_POST['select-files'] as $id => $on) {
     			if ($on == 'on') {
     				$file = $files->getById($id)[0];
     				$fileOwner = \OC\Files\Filesystem::getOwner($file['path']);
     				$sharetype = $file['mimetype'] == 2 ? 'folder' : 'file';
     				$sharedWith = \OCP\Share::getUsersItemShared($sharetype, $file['fileid'], $fileOwner, false, true);
     				foreach ($allusers as $userid => $user) {
     					if (isset($file['fileid']) && is_array($file) && isset($file['fileid']) && !in_array($userid, $sharedWith) && !($userid == $this->userId)) {
     						//Helper::shareFile($file['name'], $user, $userid);
     						\OCP\Share::shareItem($sharetype, $file['fileid'], \OCP\Share::SHARE_TYPE_USER, $userid, 1);
     						$filesid[] = $id;
     					}
     				}
     			}
     		} */
 }
开发者ID:Werdffelynir,项目名称:owncollab_talks,代码行数:46,代码来源:talks.php


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