Permalink
Browse files

Fix auto-apply profile and cache

  • Loading branch information...
1 parent 91b0292 commit c9f6c4018c2b0031948b02c6d598e1f97ef1da61 @cdujeu cdujeu committed Oct 13, 2016
@@ -146,6 +146,10 @@ public static function updateRole($roleObject, $userObject = null)
{
ConfService::getConfStorageImpl()->updateRole($roleObject, $userObject);
CacheService::saveWithTimestamp(AJXP_CACHE_SERVICE_NS_SHARED, "pydio:role:".$roleObject->getId(), $roleObject);
+ $profiles = $roleObject->listAutoApplies();
+ foreach($profiles as $profile){
+ CacheService::saveWithTimestamp(AJXP_CACHE_SERVICE_NS_SHARED, "pydio:profile:".$profile, time());
+ }
ConfService::getInstance()->invalidateLoadedRepositories();
$roleId = $roleObject->getId();
if(strpos($roleId, "AJXP_GRP_/") === 0){
@@ -85,8 +85,10 @@ public static function getUserById($userId, $checkExists = true){
// Try to get from cache
$test = CacheService::fetch(AJXP_CACHE_SERVICE_NS_SHARED, "pydio:user:" . $userId);
if($test !== false && $test instanceof UserInterface){
- // Second check : if roles were updated in cache
+ // Second check : if roles were updated in cache, or maybe profile with auto-apply feature
$roleCacheIds = array_map(function($k){ return "pydio:role:".$k; }, $test->getRolesKeys());
+ $profile = $test->getProfile();
+ if(!empty($profile)) $roleCacheIds[] = "pydio:profile:".$profile;
$test = CacheService::fetchWithTimestamps(AJXP_CACHE_SERVICE_NS_SHARED, "pydio:user:".$userId, $roleCacheIds);
if($test !== false){
if($test->getPersonalRole() === null){
@@ -181,6 +183,17 @@ public static function getRepositoriesForUser($user, $includeShared = true, $det
}
/**
+ * @param string $userId
+ * @param RepositoryInterface[] $repoList
+ */
+ private function setInCache($userId, $repoList){
+
+ $this->repositoriesCache[$userId] = $repoList;
+ SessionService::updateLoadedRepositories($repoList);
+
+ }
+
+ /**
* @param $userId
* @return mixed|null|\Pydio\Core\Model\RepositoryInterface[]
*/
@@ -203,17 +216,6 @@ private function getFromCaches($userId){
}
- /**
- * @param string $userId
- * @param RepositoryInterface[] $repoList
- */
- private function setInCache($userId, $repoList){
-
- $this->repositoriesCache[$userId] = $repoList;
- SessionService::updateLoadedRepositories($repoList);
-
- }
-
public static function invalidateCache(){
self::instance()->repositoriesCache = [];

0 comments on commit c9f6c40

Please sign in to comment.