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


PHP Share::getItemSharedWithUser方法代码示例

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


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

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

示例2: 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 = array();
     foreach ($recipientList as $recipient) {
         $recipientDisplayName = \OCP\User::getDisplayName($recipient);
         $to = \OC::$server->getConfig()->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) {
                 \OCP\Util::writeLog('sharing', "Couldn't read date: " . $e->getMessage(), \OCP\Util::ERROR);
             }
         }
         // 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($htmlMail, $alttextMail) = $this->createMailBody($filename, $link, $expiration);
         // send it out now
         try {
             \OC_MAIL::send($to, $recipientDisplayName, $subject, $htmlMail, $this->from, $this->senderDisplayName, 1, $alttextMail, '', '', '', $this->replyTo);
         } catch (\Exception $e) {
             \OCP\Util::writeLog('sharing', "Can't send mail to inform the user about an internal share: " . $e->getMessage(), \OCP\Util::ERROR);
             $noMail[] = $recipientDisplayName;
         }
     }
     return $noMail;
 }
开发者ID:kebenxiaoming,项目名称:owncloudRedis,代码行数:52,代码来源:mailnotifications.php

示例3: 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 = array();
     foreach ($recipientList as $recipient) {
         $recipientDisplayName = \OCP\User::getDisplayName($recipient);
         $to = \OC_Preferences::getValue($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) {
                 \OCP\Util::writeLog('sharing', "Couldn't read date: " . $e->getMessage(), \OCP\Util::ERROR);
             }
         }
         if ($itemType === 'folder') {
             $foldername = "/Shared/" . $filename;
         } else {
             // if it is a file we can just link to the Shared folder,
             // that's the place where the user will find the file
             $foldername = "/Shared";
         }
         $link = \OCP\Util::linkToAbsolute('files', 'index.php', array("dir" => $foldername));
         list($htmlMail, $alttextMail) = $this->createMailBody($filename, $link, $expiration);
         // send it out now
         try {
             \OCP\Util::sendMail($to, $recipientDisplayName, $subject, $htmlMail, $this->from, $this->senderDisplayName, 1, $alttextMail);
         } catch (\Exception $e) {
             \OCP\Util::writeLog('sharing', "Can't send mail to inform the user about an internal share: " . $e->getMessage(), \OCP\Util::ERROR);
             $noMail[] = $recipientDisplayName;
         }
     }
     return $noMail;
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:49,代码来源:mailnotifications.php

示例4: getParents

 /**
  * get shared parents
  *
  * @param int $itemSource item source ID
  * @param string $shareWith with whom should the item be shared
  * @param string $owner owner of the item
  * @return array with shares
  */
 public function getParents($itemSource, $shareWith = null, $owner = null)
 {
     $result = array();
     $parent = $this->getParentId($itemSource);
     while ($parent) {
         $shares = \OCP\Share::getItemSharedWithUser('folder', $parent, $shareWith, $owner);
         if ($shares) {
             foreach ($shares as $share) {
                 $name = substr($share['path'], strrpos($share['path'], '/') + 1);
                 $share['collection']['path'] = $name;
                 $share['collection']['item_type'] = 'folder';
                 $share['file_path'] = $name;
                 $displayNameOwner = \OCP\User::getDisplayName($share['uid_owner']);
                 $displayNameShareWith = \OCP\User::getDisplayName($share['share_with']);
                 $share['displayname_owner'] = $displayNameOwner ? $displayNameOwner : $share['uid_owner'];
                 $share['share_with_displayname'] = $displayNameShareWith ? $displayNameShareWith : $share['uid_owner'];
                 $result[] = $share;
             }
         }
         $parent = $this->getParentId($parent);
     }
     return $result;
 }
开发者ID:samj1912,项目名称:repo,代码行数:31,代码来源:folder.php

示例5: testGetItemSharedWithUserFromGroupShare

 public function testGetItemSharedWithUserFromGroupShare()
 {
     \OC_User::setUserId($this->user1);
     //add dummy values to the share table
     $query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` (' . ' `item_type`, `item_source`, `item_target`, `share_type`,' . ' `share_with`, `uid_owner`) VALUES (?,?,?,?,?,?)');
     $args = array('test', 99, 'target1', \OCP\Share::SHARE_TYPE_GROUP, $this->group1, $this->user1);
     $query->execute($args);
     $args = array('test', 99, 'target2', \OCP\Share::SHARE_TYPE_GROUP, $this->group2, $this->user1);
     $query->execute($args);
     $args = array('test', 99, 'target3', \OCP\Share::SHARE_TYPE_GROUP, $this->group1, $this->user2);
     $query->execute($args);
     $args = array('test', 99, 'target4', \OCP\Share::SHARE_TYPE_GROUP, $this->group1, $this->user4);
     $query->execute($args);
     // user2 is in group1 and group2
     $result1 = \OCP\Share::getItemSharedWithUser('test', 99, $this->user2, $this->user1);
     $this->assertSame(2, count($result1));
     $this->verifyResult($result1, array('target1', 'target2'));
     $result2 = \OCP\Share::getItemSharedWithUser('test', 99, null, $this->user1);
     $this->assertSame(2, count($result2));
     $this->verifyResult($result2, array('target1', 'target2'));
     // user3 is in group1 and group2
     $result3 = \OCP\Share::getItemSharedWithUser('test', 99, $this->user3);
     $this->assertSame(3, count($result3));
     $this->verifyResult($result3, array('target1', 'target3', 'target4'));
     $result4 = \OCP\Share::getItemSharedWithUser('test', 99, null, null);
     $this->assertSame(4, count($result4));
     $this->verifyResult($result4, array('target1', 'target2', 'target3', 'target4'));
     $result6 = \OCP\Share::getItemSharedWithUser('test', 99, $this->user6, null);
     $this->assertSame(0, count($result6));
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:30,代码来源:ShareTest.php

示例6: array

 $noMail = array();
 $recipientList = array();
 if ($shareType === \OCP\Share::SHARE_TYPE_USER) {
     $recipientList[] = $recipient;
 } elseif ($shareType === \OCP\Share::SHARE_TYPE_GROUP) {
     $recipientList = \OC_Group::usersInGroup($recipient);
 }
 // don't send a mail to the user who shared the file
 $recipientList = array_diff($recipientList, array(\OCP\User::getUser()));
 // send mail to all recipients with an email address
 foreach ($recipientList as $recipient) {
     //get correct target folder name
     $email = OC_Preferences::getValue($recipient, 'settings', 'email', '');
     if ($email !== '') {
         $displayName = \OCP\User::getDisplayName($recipient);
         $items = \OCP\Share::getItemSharedWithUser($itemType, $itemSource, $recipient);
         $filename = trim($items[0]['file_target'], '/');
         $subject = (string) $l->t('%s shared »%s« with you', array($ownerDisplayName, $filename));
         $expiration = null;
         if (isset($items[0]['expiration'])) {
             $date = new DateTime($items[0]['expiration']);
             $expiration = $date->format('Y-m-d');
         }
         if ($itemType === 'folder') {
             $foldername = "/Shared/" . $filename;
         } else {
             // if it is a file we can just link to the Shared folder,
             // that's the place where the user will find the file
             $foldername = "/Shared";
         }
         $link = \OCP\Util::linkToAbsolute('files', 'index.php', array("dir" => $foldername));
开发者ID:omusico,项目名称:isle-web-framework,代码行数:31,代码来源:share.php


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