Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit a051fa1

Browse files
committed
Mega-merge from deprototype branch
2 parents 18e4460 + a3c72c1 commit a051fa1

File tree

835 files changed

+25706
-25475
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

835 files changed

+25706
-25475
lines changed

core/src/.gitignore

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
.idea/*
1+
.idea/
22
data/cache/*
33
data/files/*
44
data/logs/*
55
data/personal/*
66
data/plugins/*
77
data/public/*
8-
data/tmp
8+
data/tmp
9+
node_modules/
10+
.DS_Store
11+
.jshintignore
12+
.jshintrc
13+
.validate.json

core/src/conf/bootstrap_context.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@
7777
define("AJXP_SERVER_DEBUG" , false);
7878
define("AJXP_SKIP_CACHE" , false);
7979

80+
// KEY-VALUE-CACHE
81+
define("AJXP_KVCACHE_PREFIX", "pydio-unique-id");
82+
define("AJXP_KVCACHE_IGNORE", true );
8083

8184
// PBKDF2 CONSTANTS FOR A SECURE STORAGE OF PASSWORDS
8285
// These constants may be changed without breaking existing hashes.

core/src/core/classes/class.AJXP_Controller.php

Lines changed: 4 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,13 @@ class AJXP_Controller
4545
/**
4646
* Initialize the queryable xPath object
4747
* @static
48+
* @param bool $useCache Whether to cache the registry version in a memory cache.
4849
* @return DOMXPath
4950
*/
50-
private static function initXPath()
51+
private static function initXPath($useCache = false)
5152
{
5253
if (!isSet(self::$xPath)) {
53-
54-
$registry = AJXP_PluginsService::getXmlRegistry( false );
55-
$changes = self::filterRegistryFromRole($registry);
56-
if($changes) AJXP_PluginsService::updateXmlRegistry($registry);
54+
$registry = ConfService::getFilteredXMLRegistry(false, false, $useCache);
5755
self::$xPath = new DOMXPath($registry);
5856
}
5957
return self::$xPath;
@@ -64,65 +62,14 @@ public static function registryReset(){
6462
self::$hooksCache = array();
6563
}
6664

67-
/**
68-
* Check the current user "specificActionsRights" and filter the full registry actions with these.
69-
* @static
70-
* @param DOMDocument $registry
71-
* @return bool
72-
*/
73-
public static function filterRegistryFromRole(&$registry)
74-
{
75-
if(!AuthService::usersEnabled()) return false ;
76-
$loggedUser = AuthService::getLoggedUser();
77-
if($loggedUser == null) return false;
78-
$crtRepo = ConfService::getRepository();
79-
$crtRepoId = AJXP_REPO_SCOPE_ALL; // "ajxp.all";
80-
if ($crtRepo != null && is_a($crtRepo, "Repository")) {
81-
$crtRepoId = $crtRepo->getId();
82-
}
83-
$actionRights = $loggedUser->mergedRole->listActionsStatesFor($crtRepo);
84-
$changes = false;
85-
$xPath = new DOMXPath($registry);
86-
foreach ($actionRights as $pluginName => $actions) {
87-
foreach ($actions as $actionName => $enabled) {
88-
if($enabled !== false) continue;
89-
$actions = $xPath->query("actions/action[@name='$actionName']");
90-
if (!$actions->length) {
91-
continue;
92-
}
93-
$action = $actions->item(0);
94-
$action->parentNode->removeChild($action);
95-
$changes = true;
96-
}
97-
}
98-
$parameters = $loggedUser->mergedRole->listParameters();
99-
foreach ($parameters as $scope => $paramsPlugs) {
100-
if ($scope == AJXP_REPO_SCOPE_ALL || $scope == $crtRepoId || ($crtRepo!=null && $crtRepo->hasParent() && $scope == AJXP_REPO_SCOPE_SHARED)) {
101-
foreach ($paramsPlugs as $plugId => $params) {
102-
foreach ($params as $name => $value) {
103-
// Search exposed plugin_configs, replace if necessary.
104-
$searchparams = $xPath->query("plugins/*[@id='$plugId']/plugin_configs/property[@name='$name']");
105-
if(!$searchparams->length) continue;
106-
$param = $searchparams->item(0);
107-
$newCdata = $registry->createCDATASection(json_encode($value));
108-
$param->removeChild($param->firstChild);
109-
$param->appendChild($newCdata);
110-
}
111-
}
112-
}
113-
}
114-
return $changes;
115-
}
116-
117-
11865
/**
11966
* @param $actionName
12067
* @param $path
12168
* @return bool
12269
*/
12370
public static function findRestActionAndApply($actionName, $path)
12471
{
125-
$xPath = self::initXPath();
72+
$xPath = self::initXPath(true);
12673
$actions = $xPath->query("actions/action[@name='$actionName']");
12774
if (!$actions->length) {
12875
self::$lastActionNeedsAuth = true;
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<?php
2+
/*
3+
* Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
4+
* This file is part of Pydio.
5+
*
6+
* Pydio is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Affero General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* Pydio is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Affero General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with Pydio. If not, see <http://www.gnu.org/licenses/>.
18+
*
19+
* The latest code can be found at <http://pyd.io/>.
20+
*/
21+
defined('AJXP_EXEC') or die( 'Access not allowed');
22+
23+
24+
/**
25+
* Class AJXP_KeyValueCache
26+
*
27+
* Simple Key/Value cache stored in memory, independant of the implementation.
28+
* Currently APC only, we should replace with the Doctrine/cache library (see https://github.com/doctrine/cache )
29+
* We do implement their Cache Interface for future migration.
30+
*/
31+
class AJXP_KeyValueCache {
32+
33+
protected function makeId($id){
34+
if(defined('AJXP_KVCACHE_PREFIX')){
35+
return AJXP_KVCACHE_PREFIX . " - ".$id;
36+
}
37+
return $id;
38+
}
39+
40+
/**
41+
* Fetches an entry from the cache.
42+
*
43+
* @param string $id The id of the cache entry to fetch.
44+
*
45+
* @return mixed The cached data or FALSE, if no cache entry exists for the given id.
46+
*/
47+
public function fetch($id){
48+
if(!function_exists('apc_fetch')) return FALSE;
49+
if(defined('AJXP_KVCACHE_IGNORE') && AJXP_KVCACHE_IGNORE) return FALSE;
50+
$result = apc_fetch($this->makeId($id), $success);
51+
if($success) return $result;
52+
else return false;
53+
}
54+
/**
55+
* Tests if an entry exists in the cache.
56+
*
57+
* @param string $id The cache id of the entry to check for.
58+
*
59+
* @return boolean TRUE if a cache entry exists for the given cache id, FALSE otherwise.
60+
*/
61+
public function contains($id){
62+
if(!function_exists('apc_fetch')) return FALSE;
63+
if(defined('AJXP_KVCACHE_IGNORE') && AJXP_KVCACHE_IGNORE) return FALSE;
64+
apc_fetch($this->makeId($id), $success);
65+
return $success;
66+
}
67+
/**
68+
* Puts data into the cache.
69+
*
70+
* @param string $id The cache id.
71+
* @param mixed $data The cache entry/data.
72+
* @param int $lifeTime The cache lifetime.
73+
* If != 0, sets a specific lifetime for this cache entry (0 => infinite lifeTime).
74+
*
75+
* @return boolean TRUE if the entry was successfully stored in the cache, FALSE otherwise.
76+
*/
77+
public function save($id, $data, $lifeTime = 0){
78+
if(!function_exists('apc_store')) return false;
79+
if(defined("AJXP_KVCACHE_IGNORE") && AJXP_KVCACHE_IGNORE) return false;
80+
$res = apc_store($this->makeId($id), $data, $lifeTime);
81+
if($res !== false) return true;
82+
return false;
83+
}
84+
85+
/**
86+
* Deletes a cache entry.
87+
*
88+
* @param string $id The cache id.
89+
*
90+
* @return boolean TRUE if the cache entry was successfully deleted, FALSE otherwise.
91+
*/
92+
public function delete($id){
93+
if(!function_exists('apc_delete')) return true;
94+
return apc_delete($this->makeId($id));
95+
}
96+
97+
/**
98+
* Flush a whole cache
99+
*/
100+
public function deleteAll(){
101+
if(function_exists('apc_clear_cache')){
102+
apc_clear_cache('user');
103+
}
104+
}
105+
106+
107+
}

0 commit comments

Comments
 (0)