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


PHP StorageConfig::getApplicableUsers方法代码示例

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


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

示例1: populateStorageConfigWithLegacyOptions

 /**
  * Copy legacy storage options into the given storage config object.
  *
  * @param StorageConfig $storageConfig storage config to populate
  * @param string $mountType mount type
  * @param string $applicable applicable user or group
  * @param array $storageOptions legacy storage options
  *
  * @return StorageConfig populated storage config
  */
 protected function populateStorageConfigWithLegacyOptions(&$storageConfig, $mountType, $applicable, $storageOptions)
 {
     $storageConfig->setBackendClass($storageOptions['class']);
     $storageConfig->setBackendOptions($storageOptions['options']);
     if (isset($storageOptions['mountOptions'])) {
         $storageConfig->setMountOptions($storageOptions['mountOptions']);
     }
     if (isset($storageOptions['priority'])) {
         $storageConfig->setPriority($storageOptions['priority']);
     }
     if ($mountType === \OC_Mount_Config::MOUNT_TYPE_USER) {
         $applicableUsers = $storageConfig->getApplicableUsers();
         if ($applicable !== 'all') {
             $applicableUsers[] = $applicable;
             $storageConfig->setApplicableUsers($applicableUsers);
         }
     } else {
         if ($mountType === \OC_Mount_Config::MOUNT_TYPE_GROUP) {
             $applicableGroups = $storageConfig->getApplicableGroups();
             $applicableGroups[] = $applicable;
             $storageConfig->setApplicableGroups($applicableGroups);
         }
     }
     return $storageConfig;
 }
开发者ID:brunomilet,项目名称:owncloud-core,代码行数:35,代码来源:storagesservice.php

示例2: triggerHooks

 /**
  * Triggers $signal for all applicable users of the given
  * storage
  *
  * @param StorageConfig $storage storage data
  * @param string $signal signal to trigger
  */
 protected function triggerHooks(StorageConfig $storage, $signal)
 {
     // FIXME: Use as expression in empty once PHP 5.4 support is dropped
     $applicableUsers = $storage->getApplicableUsers();
     $applicableGroups = $storage->getApplicableGroups();
     if (empty($applicableUsers) && empty($applicableGroups)) {
         // raise for user "all"
         $this->triggerApplicableHooks($signal, $storage->getMountPoint(), \OC_Mount_Config::MOUNT_TYPE_USER, ['all']);
         return;
     }
     $this->triggerApplicableHooks($signal, $storage->getMountPoint(), \OC_Mount_Config::MOUNT_TYPE_USER, $applicableUsers);
     $this->triggerApplicableHooks($signal, $storage->getMountPoint(), \OC_Mount_Config::MOUNT_TYPE_GROUP, $applicableGroups);
 }
开发者ID:kenwi,项目名称:core,代码行数:20,代码来源:globalstoragesservice.php

示例3: populateStorageConfigWithLegacyOptions

 /**
  * Copy legacy storage options into the given storage config object.
  *
  * @param StorageConfig $storageConfig storage config to populate
  * @param string $mountType mount type
  * @param string $applicable applicable user or group
  * @param array $storageOptions legacy storage options
  *
  * @return StorageConfig populated storage config
  */
 protected function populateStorageConfigWithLegacyOptions(&$storageConfig, $mountType, $applicable, $storageOptions)
 {
     $backend = $this->backendService->getBackend($storageOptions['backend']);
     if (!$backend) {
         throw new \UnexpectedValueException('Invalid backend ' . $storageOptions['backend']);
     }
     $storageConfig->setBackend($backend);
     if (isset($storageOptions['authMechanism']) && $storageOptions['authMechanism'] !== 'builtin::builtin') {
         $authMechanism = $this->backendService->getAuthMechanism($storageOptions['authMechanism']);
     } else {
         $authMechanism = $backend->getLegacyAuthMechanism($storageOptions);
         $storageOptions['authMechanism'] = 'null';
         // to make error handling easier
     }
     if (!$authMechanism) {
         throw new \UnexpectedValueException('Invalid authentication mechanism ' . $storageOptions['authMechanism']);
     }
     $storageConfig->setAuthMechanism($authMechanism);
     $storageConfig->setBackendOptions($storageOptions['options']);
     if (isset($storageOptions['mountOptions'])) {
         $storageConfig->setMountOptions($storageOptions['mountOptions']);
     }
     if (!isset($storageOptions['priority'])) {
         $storageOptions['priority'] = $backend->getPriority();
     }
     $storageConfig->setPriority($storageOptions['priority']);
     if ($mountType === \OC_Mount_Config::MOUNT_TYPE_USER) {
         $applicableUsers = $storageConfig->getApplicableUsers();
         if ($applicable !== 'all') {
             $applicableUsers[] = $applicable;
             $storageConfig->setApplicableUsers($applicableUsers);
         }
     } else {
         if ($mountType === \OC_Mount_Config::MOUNT_TYPE_GROUP) {
             $applicableGroups = $storageConfig->getApplicableGroups();
             $applicableGroups[] = $applicable;
             $storageConfig->setApplicableGroups($applicableGroups);
         }
     }
     return $storageConfig;
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:51,代码来源:legacystoragesservice.php

示例4: prepareMountPointEntry

 /**
  * Convert a StorageConfig to the legacy mountPoints array format
  * There's a lot of extra information in here, to satisfy all of the legacy functions
  *
  * @param StorageConfig $storage
  * @param bool $isPersonal
  * @return array
  */
 private static function prepareMountPointEntry(StorageConfig $storage, $isPersonal)
 {
     $mountEntry = [];
     $mountEntry['mountpoint'] = substr($storage->getMountPoint(), 1);
     // remove leading slash
     $mountEntry['class'] = $storage->getBackend()->getIdentifier();
     $mountEntry['backend'] = $storage->getBackend()->getText();
     $mountEntry['authMechanism'] = $storage->getAuthMechanism()->getIdentifier();
     $mountEntry['personal'] = $isPersonal;
     $mountEntry['options'] = self::decryptPasswords($storage->getBackendOptions());
     $mountEntry['mountOptions'] = $storage->getMountOptions();
     $mountEntry['priority'] = $storage->getPriority();
     $mountEntry['applicable'] = ['groups' => $storage->getApplicableGroups(), 'users' => $storage->getApplicableUsers()];
     // if mountpoint is applicable to all users the old API expects ['all']
     if (empty($mountEntry['applicable']['groups']) && empty($mountEntry['applicable']['users'])) {
         $mountEntry['applicable']['users'] = ['all'];
     }
     $mountEntry['id'] = $storage->getId();
     return $mountEntry;
 }
开发者ID:DaubaKao,项目名称:owncloud-core,代码行数:28,代码来源:config.php

示例5: updateStorage

 /**
  * Update storage to the configuration
  *
  * @param StorageConfig $updatedStorage storage attributes
  *
  * @return StorageConfig storage config
  * @throws NotFoundException if the given storage does not exist in the config
  */
 public function updateStorage(StorageConfig $updatedStorage)
 {
     $id = $updatedStorage->getId();
     $existingMount = $this->dbConfig->getMountById($id);
     if (!is_array($existingMount)) {
         throw new NotFoundException('Storage with id "' . $id . '" not found while updating storage');
     }
     $oldStorage = $this->getStorageConfigFromDBMount($existingMount);
     $removedUsers = array_diff($oldStorage->getApplicableUsers(), $updatedStorage->getApplicableUsers());
     $removedGroups = array_diff($oldStorage->getApplicableGroups(), $updatedStorage->getApplicableGroups());
     $addedUsers = array_diff($updatedStorage->getApplicableUsers(), $oldStorage->getApplicableUsers());
     $addedGroups = array_diff($updatedStorage->getApplicableGroups(), $oldStorage->getApplicableGroups());
     $oldUserCount = count($oldStorage->getApplicableUsers());
     $oldGroupCount = count($oldStorage->getApplicableGroups());
     $newUserCount = count($oldStorage->getApplicableUsers());
     $newGroupCount = count($oldStorage->getApplicableGroups());
     $wasGlobal = $oldUserCount + $oldGroupCount === 0;
     $isGlobal = $newUserCount + $newGroupCount === 0;
     foreach ($removedUsers as $user) {
         $this->dbConfig->removeApplicable($id, DBConfigService::APPLICABLE_TYPE_USER, $user);
     }
     foreach ($removedGroups as $group) {
         $this->dbConfig->removeApplicable($id, DBConfigService::APPLICABLE_TYPE_GROUP, $group);
     }
     foreach ($addedUsers as $user) {
         $this->dbConfig->addApplicable($id, DBConfigService::APPLICABLE_TYPE_USER, $user);
     }
     foreach ($addedGroups as $group) {
         $this->dbConfig->addApplicable($id, DBConfigService::APPLICABLE_TYPE_GROUP, $group);
     }
     if ($wasGlobal && !$isGlobal) {
         $this->dbConfig->removeApplicable($id, DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
     } else {
         if (!$wasGlobal && $isGlobal) {
             $this->dbConfig->addApplicable($id, DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
         }
     }
     $changedConfig = array_diff_assoc($updatedStorage->getBackendOptions(), $oldStorage->getBackendOptions());
     $changedOptions = array_diff_assoc($updatedStorage->getMountOptions(), $oldStorage->getMountOptions());
     foreach ($changedConfig as $key => $value) {
         $this->dbConfig->setConfig($id, $key, $value);
     }
     foreach ($changedOptions as $key => $value) {
         $this->dbConfig->setOption($id, $key, $value);
     }
     $this->triggerChangeHooks($oldStorage, $updatedStorage);
     return $this->getStorage($id);
 }
开发者ID:loulancn,项目名称:core,代码行数:56,代码来源:storagesservice.php

示例6: isApplicable

 protected function isApplicable(StorageConfig $config)
 {
     $applicableUsers = $config->getApplicableUsers();
     $applicableGroups = $config->getApplicableGroups();
     if (count($applicableUsers) === 0 && count($applicableGroups) === 0) {
         return true;
     }
     if (in_array($this->getUser()->getUID(), $applicableUsers, true)) {
         return true;
     }
     $groupIds = $this->groupManager->getUserGroupIds($this->getUser());
     foreach ($groupIds as $groupId) {
         if (in_array($groupId, $applicableGroups, true)) {
             return true;
         }
     }
     return false;
 }
开发者ID:farukuzun,项目名称:core-1,代码行数:18,代码来源:userglobalstoragesservice.php

示例7: getPriorityType

 /**
  * Get a priority 'type', where a bigger number means higher priority
  * user applicable > group applicable > 'all'
  *
  * @param StorageConfig $storage
  * @return int
  */
 protected function getPriorityType(StorageConfig $storage)
 {
     $applicableUsers = $storage->getApplicableUsers();
     $applicableGroups = $storage->getApplicableGroups();
     if ($applicableUsers && $applicableUsers[0] !== 'all') {
         return 2;
     }
     if ($applicableGroups) {
         return 1;
     }
     return 0;
 }
开发者ID:unrealbato,项目名称:core,代码行数:19,代码来源:userglobalstoragesservice.php

示例8: isApplicable

 protected function isApplicable(StorageConfig $config)
 {
     return $config->getApplicableUsers() === [$this->getUser()->getUID()] && $config->getType() === StorageConfig::MOUNT_TYPE_PERSONAl;
 }
开发者ID:kenwi,项目名称:core,代码行数:4,代码来源:userstoragesservice.php

示例9: prepareMountPointEntry

 /**
  * Convert a StorageConfig to the legacy mountPoints array format
  * There's a lot of extra information in here, to satisfy all of the legacy functions
  *
  * @param StorageConfig $storage
  * @param bool $isPersonal
  * @return array
  */
 private static function prepareMountPointEntry(StorageConfig $storage, $isPersonal)
 {
     $mountEntry = [];
     $mountEntry['mountpoint'] = substr($storage->getMountPoint(), 1);
     // remove leading slash
     $mountEntry['class'] = $storage->getBackend()->getIdentifier();
     $mountEntry['backend'] = $storage->getBackend()->getText();
     $mountEntry['authMechanism'] = $storage->getAuthMechanism()->getIdentifier();
     $mountEntry['personal'] = $isPersonal;
     $mountEntry['options'] = self::decryptPasswords($storage->getBackendOptions());
     $mountEntry['mountOptions'] = $storage->getMountOptions();
     $mountEntry['priority'] = $storage->getPriority();
     $mountEntry['applicable'] = ['groups' => $storage->getApplicableGroups(), 'users' => $storage->getApplicableUsers()];
     $mountEntry['id'] = $storage->getId();
     // $mountEntry['storage_id'] = null; // we don't store this!
     return $mountEntry;
 }
开发者ID:GrumpyCrouton,项目名称:core,代码行数:25,代码来源:config.php


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