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


PHP Share::setExpirationDate方法代码示例

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


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

示例1: testClearExpireDateWhileEnforced

 /**
  * Ensure that we do not allow removing a an expiration date from a link share if this
  * is enforced by the settings.
  */
 public function testClearExpireDateWhileEnforced()
 {
     \OC_User::setUserId($this->user1);
     \OC::$server->getAppConfig()->setValue('core', 'shareapi_default_expire_date', 'yes');
     \OC::$server->getAppConfig()->setValue('core', 'shareapi_expire_after_n_days', '2');
     \OC::$server->getAppConfig()->setValue('core', 'shareapi_enforce_expire_date', 'yes');
     $token = \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ);
     $this->assertInternalType('string', $token, 'Failed asserting that user 1 successfully shared text.txt as link with token.');
     $setExpireDateFailed = false;
     try {
         $this->assertTrue(\OCP\Share::setExpirationDate('test', 'test.txt', '', ''), 'Failed asserting that user 1 successfully set an expiration date for the test.txt share.');
     } catch (\Exception $e) {
         $setExpireDateFailed = true;
     }
     $this->assertTrue($setExpireDateFailed);
     \OC::$server->getAppConfig()->deleteKey('core', 'shareapi_default_expire_date');
     \OC::$server->getAppConfig()->deleteKey('core', 'shareapi_expire_after_n_days');
     \OC::$server->getAppConfig()->deleteKey('core', 'shareapi_enforce_expire_date');
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:23,代码来源:ShareTest.php

示例2: testDefaultExpireDate

 public function testDefaultExpireDate()
 {
     \Test_Files_Sharing_Api::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER1);
     // TODO drop this once all code paths use the DI version - otherwise
     // the cache inside this config object is out of date because
     // OC_Appconfig is used and bypasses this cache which lead to integrity
     // constraint violations
     $config = \OC::$server->getConfig();
     $config->deleteAppValue('core', 'shareapi_default_expire_date');
     $config->deleteAppValue('core', 'shareapi_enforce_expire_date');
     $config->deleteAppValue('core', 'shareapi_expire_after_n_days');
     $config->setAppValue('core', 'shareapi_default_expire_date', 'yes');
     $config->setAppValue('core', 'shareapi_enforce_expire_date', 'yes');
     $config->setAppValue('core', 'shareapi_expire_after_n_days', '2');
     // default expire date is set to 2 days
     // the time when the share was created is set to 3 days in the past
     // user defined expire date is set to +2 days from now on
     // -> link should be already expired by the default expire date but the user
     //    share should still exists.
     $now = time();
     $dateFormat = 'Y-m-d H:i:s';
     $shareCreated = $now - 3 * 24 * 60 * 60;
     $expireDate = date($dateFormat, $now + 2 * 24 * 60 * 60);
     $info = OC\Files\Filesystem::getFileInfo($this->filename);
     $this->assertTrue($info instanceof \OC\Files\FileInfo);
     $result = \OCP\Share::shareItem('file', $info->getId(), \OCP\Share::SHARE_TYPE_LINK, null, \OCP\Constants::PERMISSION_READ);
     $this->assertTrue(is_string($result));
     $result = \OCP\Share::shareItem('file', $info->getId(), \OCP\Share::SHARE_TYPE_USER, \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2, 31);
     $this->assertTrue($result);
     $result = \OCP\Share::setExpirationDate('file', $info->getId(), $expireDate, $now);
     $this->assertTrue($result);
     //manipulate stime so that both shares are older then the default expire date
     $statement = "UPDATE `*PREFIX*share` SET `stime` = ? WHERE `share_type` = ?";
     $query = \OCP\DB::prepare($statement);
     $result = $query->execute(array($shareCreated, \OCP\Share::SHARE_TYPE_LINK));
     $this->assertSame(1, $result);
     $query = \OCP\DB::prepare($statement);
     $result = $query->execute(array($shareCreated, \OCP\Share::SHARE_TYPE_USER));
     $this->assertSame(1, $result);
     // now the link share should expire because of enforced default expire date
     // the user share should still exist
     $result = \OCP\Share::getItemShared('file', $info->getId());
     $this->assertTrue(is_array($result));
     $this->assertSame(1, count($result));
     $share = reset($result);
     $this->assertSame(\OCP\Share::SHARE_TYPE_USER, $share['share_type']);
     //cleanup
     $result = \OCP\Share::unshare('file', $info->getId(), \OCP\Share::SHARE_TYPE_USER, \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2);
     $this->assertTrue($result);
     $config->setAppValue('core', 'shareapi_default_expire_date', 'no');
     $config->setAppValue('core', 'shareapi_enforce_expire_date', 'no');
 }
开发者ID:evanjt,项目名称:core,代码行数:52,代码来源:api.php

示例3: updateExpireDate

 /**
  * set expire date for public link share
  * @param array $share information about the share
  * @param array $params contains 'expireDate' which needs to be a well formated date string, e.g DD-MM-YYYY
  * @return \OC_OCS_Result
  */
 private static function updateExpireDate($share, $params)
 {
     // only public links can have a expire date
     if ((int) $share['share_type'] !== \OCP\Share::SHARE_TYPE_LINK) {
         return new \OC_OCS_Result(null, 400, "expire date only exists for public link shares");
     }
     try {
         $expireDateSet = \OCP\Share::setExpirationDate($share['item_type'], $share['item_source'], $params['_put']['expireDate'], (int) $share['stime']);
         $result = $expireDateSet ? new \OC_OCS_Result() : new \OC_OCS_Result(null, 404, "couldn't set expire date");
     } catch (\Exception $e) {
         $result = new \OC_OCS_Result(null, 404, $e->getMessage());
     }
     return $result;
 }
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:20,代码来源:local.php


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