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

Commit 93afb31

Browse files
committed
Merge branch 'jscore-deprototype' of https://github.com/pydio/pydio-core into jscore-deprototype
2 parents 7f7f284 + 4c3e155 commit 93afb31

Some content is hidden

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

51 files changed

+7870
-5790
lines changed

core/src/conf/bootstrap_context.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@
7474
define("AJXP_SERVER_DEBUG" , false);
7575
define("AJXP_SKIP_CACHE" , false);
7676

77+
// KEY-VALUE-CACHE
78+
define("AJXP_KVCACHE_PREFIX", "pydio-unique-id");
79+
define("AJXP_KVCACHE_IGNORE", true );
7780

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

core/src/core/classes/class.AJXP_KeyValueCache.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ protected function makeId($id){
4646
*/
4747
public function fetch($id){
4848
if(!function_exists('apc_fetch')) return FALSE;
49+
if(defined('AJXP_KVCACHE_IGNORE') && AJXP_KVCACHE_IGNORE) return FALSE;
4950
$result = apc_fetch($this->makeId($id), $success);
5051
if($success) return $result;
5152
else return false;
@@ -59,6 +60,7 @@ public function fetch($id){
5960
*/
6061
public function contains($id){
6162
if(!function_exists('apc_fetch')) return FALSE;
63+
if(defined('AJXP_KVCACHE_IGNORE') && AJXP_KVCACHE_IGNORE) return FALSE;
6264
apc_fetch($this->makeId($id), $success);
6365
return $success;
6466
}

core/src/core/classes/class.AJXP_PermissionMask.php

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
defined('AJXP_EXEC') or die('Access not allowed');
2323

2424

25-
class AJXP_PermissionMask implements JsonSerializable
25+
class AJXP_PermissionMask implements JsonSerializable, Serializable
2626
{
2727
/**
2828
* @var array
@@ -210,7 +210,7 @@ private function pathToBranch($path, $permission){
210210
* @param string $currentRoot
211211
* @return AJXP_Permission[]
212212
*/
213-
private function flattenTree($tree = null, &$pathes = null, $currentRoot=""){
213+
public function flattenTree($tree = null, &$pathes = null, $currentRoot=""){
214214
if($tree == null) $tree = $this->getTree();
215215
if($pathes == null) $pathes = array();
216216
if(!is_array($tree) || $tree == null) $tree = array();
@@ -264,4 +264,29 @@ function jsonSerialize()
264264
{
265265
return $this->flattenTree();
266266
}
267+
268+
/**
269+
* String representation of object
270+
* @link http://php.net/manual/en/serializable.serialize.php
271+
* @return string the string representation of the object or null
272+
* @since 5.1.0
273+
*/
274+
public function serialize()
275+
{
276+
return serialize($this->permissionTree);
277+
}
278+
279+
/**
280+
* Constructs the object
281+
* @link http://php.net/manual/en/serializable.unserialize.php
282+
* @param string $serialized <p>
283+
* The string representation of the object.
284+
* </p>
285+
* @return void
286+
* @since 5.1.0
287+
*/
288+
public function unserialize($serialized)
289+
{
290+
$this->permissionTree = unserialize($serialized);
291+
}
267292
}

core/src/core/classes/class.AJXP_Role.php

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ class AJXP_Role implements AjxpGroupPathProvider
6363
*/
6464
protected $masks = array();
6565

66+
/**
67+
* @var integer
68+
*/
69+
protected $lastUpdated = 0;
70+
6671
static $cypheredPassPrefix = '$pydio_password$';
6772

6873
public function __construct($id)
@@ -270,13 +275,13 @@ public function setParameterValue($pluginId, $parameterName, $parameterValue, $r
270275
*/
271276
public function filterParameterValue($pluginId, $parameterName, $repositoryId, $parameterValue)
272277
{
273-
if (isSet($this->parameters[AJXP_REPO_SCOPE_ALL][$pluginId][$parameterName])) {
274-
$v = $this->parameters[AJXP_REPO_SCOPE_ALL][$pluginId][$parameterName];
278+
if (isSet($this->parameters[$repositoryId][$pluginId][$parameterName])) {
279+
$v = $this->parameters[$repositoryId][$pluginId][$parameterName];
275280
if($v === AJXP_VALUE_CLEAR) return "";
276281
else return $this->filterCypheredPasswordValue($v);
277282
}
278-
if (isSet($this->parameters[$repositoryId][$pluginId][$parameterName])) {
279-
$v = $this->parameters[$repositoryId][$pluginId][$parameterName];
283+
if (isSet($this->parameters[AJXP_REPO_SCOPE_ALL][$pluginId][$parameterName])) {
284+
$v = $this->parameters[AJXP_REPO_SCOPE_ALL][$pluginId][$parameterName];
280285
if($v === AJXP_VALUE_CLEAR) return "";
281286
else return $this->filterCypheredPasswordValue($v);
282287
}
@@ -391,13 +396,18 @@ public function override(AJXP_Role $role)
391396
{
392397
$newRole = new AJXP_Role($role->getId());
393398

394-
$newAcls = $this->array_merge_recursive2($role->listAcls(), $this->listAcls());
399+
$roleAcl = $role->listAcls();
400+
$newAcls = $this->array_merge_recursive2($roleAcl, $this->listAcls());
395401
foreach ($newAcls as $repoId => $rightString) {
396402
if($rightString == AJXP_VALUE_CLEAR) continue;
403+
if(empty($rightString) && !empty($roleAcl[$repoId])){
404+
$rightString = $roleAcl[$repoId];
405+
}
397406
$newRole->setAcl($repoId, $rightString);
398407
}
399408

400-
$newParams = $this->array_merge_recursive2($role->listParameters(true), $this->listParameters(true));
409+
$roleParameters = $role->listParameters(true);
410+
$newParams = $this->array_merge_recursive2($roleParameters, $this->listParameters(true));
401411
foreach ($newParams as $repoId => $data) {
402412
foreach ($data as $pluginId => $param) {
403413
foreach ($param as $parameterName => $parameterValue) {
@@ -406,6 +416,9 @@ public function override(AJXP_Role $role)
406416
continue;
407417
}
408418
if($parameterValue == AJXP_VALUE_CLEAR) continue;
419+
if($parameterValue === "" && !empty($roleParameters[$repoId][$pluginId][$parameterName])){
420+
$parameterValue = $newParams[$repoId][$pluginId][$parameterName];
421+
}
409422
$newRole->setParameterValue($pluginId, $parameterName, $parameterValue, $repoId);
410423
}
411424
}
@@ -424,7 +437,6 @@ public function override(AJXP_Role $role)
424437
$allKeys = array_merge(array_keys($this->masks), array_keys($roleMasks));
425438
foreach($allKeys as $repoId){
426439
if(isSet($roleMasks[$repoId]) && isSet($this->masks[$repoId])){
427-
//$newRole->setMask($repoId, $this->masks[$repoId]->override($roleMasks[$repoId]));
428440
$newRole->setMask($repoId, $roleMasks[$repoId]->override($this->masks[$repoId]));
429441
}else if(isSet($roleMasks[$repoId])){
430442
$newRole->setMask($repoId, $roleMasks[$repoId]);
@@ -556,4 +568,12 @@ public function autoAppliesTo($specificRight)
556568
return in_array($specificRight, $this->autoApplies);
557569
}
558570

571+
public function getLastUpdated(){
572+
return $this->lastUpdated;
573+
}
574+
575+
public function setLastUpdated($time){
576+
$this->lastUpdated = $time;
577+
}
578+
559579
}

core/src/core/classes/class.AJXP_XMLWriter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,8 @@ public static function writeRepositoriesData($loggedUser)
627627
AJXP_PluginsService::getInstance()->storeToPluginQueriesCache("//server_settings/param[contains(@scope,'repository') and @expose='true']", $exposed);
628628
}
629629

630-
foreach (ConfService::getAccessibleRepositories($loggedUser, false, false) as $repoId => $repoObject) {
630+
$accessible = ConfService::getAccessibleRepositories($loggedUser, false, false);
631+
foreach ($accessible as $repoId => $repoObject) {
631632
$toLast = false;
632633
if ($repoObject->getAccessType()=="ajxp_conf") {
633634
if(AuthService::usersEnabled() && !$loggedUser->isAdmin())continue;

core/src/core/classes/class.AuthService.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class AuthService
3131
public static $roles;
3232
public static $useSession = true;
3333
private static $currentUser;
34+
public static $bufferedMessage = null;
3435
/**
3536
* Whether the whole users management system is enabled or not.
3637
* @static
@@ -320,7 +321,18 @@ public static function logUser($user_id, $pwd, $bypass_pwd = false, $cookieLogin
320321
$confDriver = ConfService::getConfStorageImpl();
321322
if ($user_id == null) {
322323
if (self::$useSession) {
323-
if(isSet($_SESSION["AJXP_USER"]) && is_object($_SESSION["AJXP_USER"])) return 1;
324+
if(isSet($_SESSION["AJXP_USER"]) && is_object($_SESSION["AJXP_USER"])) {
325+
/**
326+
* @var AbstractAjxpUser $u
327+
*/
328+
$u = $_SESSION["AJXP_USER"];
329+
if($u->reloadRolesIfRequired()){
330+
ConfService::getInstance()->invalidateLoadedRepositories();
331+
self::$bufferedMessage = AJXP_XMLWriter::reloadRepositoryList(false);
332+
$_SESSION["AJXP_USER"] = $u;
333+
}
334+
return 1;
335+
}
324336
} else {
325337
if(isSet(self::$currentUser) && is_object(self::$currentUser)) return 1;
326338
}

core/src/core/classes/class.ConfService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ private function getLoadedRepositories()
536536
return $this->configs["REPOSITORIES"];
537537
}
538538

539-
private function invalidateLoadedRepositories()
539+
public function invalidateLoadedRepositories()
540540
{
541541
if(isSet($_SESSION["REPOSITORIES"])) unset($_SESSION["REPOSITORIES"]);
542542
$this->configs["REPOSITORIES"] = null;

core/src/plugins/access.ajxp_home/class.UserDashboardHome.js

Lines changed: 78 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,78 @@ Class.create("UserDashboardHome", AjxpPane, {
2424
_repoInfos: null,
2525
_repoInfosLoading:null,
2626

27+
_loadWsList: function(oFormObject, updateWsLegend, switchToRepo){
28+
29+
var wsElement = oFormObject.down('#workspaces_list');
30+
var simpleClickOpen = ajaxplorer.getPluginConfigs("access.ajxp_home").get("SIMPLE_CLICK_WS_OPEN");
31+
if(!wsElement) return;
32+
33+
var renderElement = function(repoObject){
34+
35+
var repoId = repoObject.getId();
36+
var repoEl = new Element('li').update(repoObject.getHtmlBadge() + "<h3>"+repoObject.getLabel() + "</h3><h4>" + repoObject.getDescription()+"</h4>");
37+
wsElement.insert(repoEl);
38+
var select = function(e){
39+
var target = Event.findElement(e, "li");
40+
target.nextSiblings().invoke('removeClassName', 'selected');
41+
target.previousSiblings().invoke('removeClassName', 'selected');
42+
target.addClassName('selected');
43+
oFormObject.down('#go_to_ws').removeClassName("disabled");
44+
oFormObject.down('#go_to_ws').CURRENT_REPO_ID = repoId;
45+
oFormObject.down('#go_to_ws').CURRENT_REPO_OBJECT = repoObject;
46+
if(window.ajxpMobile){
47+
switchToRepo(repoId);
48+
}
49+
};
50+
disableTextSelection(repoEl);
51+
if(simpleClickOpen){
52+
repoEl.observe("click", function(e){
53+
repoEl.stopObserving("click");
54+
select(e);
55+
Event.findElement(e, "li").setOpacity(0.7);
56+
switchToRepo(repoId);
57+
});
58+
}else{
59+
repoEl.observe("click", select);
60+
repoEl.observe("dblclick", function(e){
61+
repoEl.stopObserving("dblclick");
62+
select(e);
63+
Event.findElement(e, "li").setOpacity(0.7);
64+
switchToRepo(repoId);
65+
});
66+
}
67+
repoEl.observe("mouseover", function(){
68+
updateWsLegend(repoObject);
69+
});
70+
repoEl.observe("mouseout", function(){
71+
updateWsLegend(null);
72+
});
73+
74+
};
75+
76+
var myWS = ProtoCompat.map2hash(ajaxplorer.user.repositories).filter(function(pair){
77+
return (pair.value.owner === '' && !pair.value.getAccessType().startsWith('ajxp_'));
78+
}).sortBy(function(pair){
79+
return (pair.value.getLabel());
80+
});
81+
var sharedWS = ProtoCompat.map2hash(ajaxplorer.user.repositories).filter(function(pair){
82+
return (pair.value.owner !== '' && !pair.value.getAccessType().startsWith('ajxp_'));
83+
}).sortBy(function(pair){
84+
return (pair.value.getLabel());
85+
});
86+
87+
if(myWS.size()){
88+
wsElement.insert(new Element('li', {className:'ws_selector_title'}).update("<h3>"+MessageHash[468]+"</h3>"));
89+
myWS.each(function(pair){renderElement(pair.value);});
90+
}
91+
92+
if(sharedWS.size()){
93+
wsElement.insert(new Element('li', {className:'ws_selector_title'}).update("<h3>"+MessageHash[469]+"</h3>"));
94+
sharedWS.each(function(pair){renderElement(pair.value);});
95+
}
96+
97+
},
98+
2799
initialize: function($super, oFormObject, editorOptions){
28100

29101
$super(oFormObject, editorOptions);
@@ -43,10 +115,6 @@ Class.create("UserDashboardHome", AjxpPane, {
43115
}
44116
oFormObject.down("#welcome").update( MessageHash['user_home.40'].replace('%s', ajaxplorer.user.getPreference("USER_DISPLAY_NAME") || ajaxplorer.user.id));
45117

46-
var wsElement = oFormObject.down('#workspaces_list');
47-
48-
var simpleClickOpen = ajaxplorer.getPluginConfigs("access.ajxp_home").get("SIMPLE_CLICK_WS_OPEN");
49-
50118
var switchToRepo = function(repoId){
51119
if(!repoId) return;
52120
if(oFormObject.down('#save_ws_choice').checked){
@@ -140,69 +208,14 @@ Class.create("UserDashboardHome", AjxpPane, {
140208
}
141209
}.bind(this);
142210

143-
var renderElement = function(repoObject){
211+
this._loadWsList(oFormObject, updateWsLegend, switchToRepo);
144212

145-
var repoId = repoObject.getId();
146-
var repoEl = new Element('li').update(repoObject.getHtmlBadge() + "<h3>"+repoObject.getLabel() + "</h3><h4>" + repoObject.getDescription()+"</h4>");
147-
wsElement.insert(repoEl);
148-
var select = function(e){
149-
var target = Event.findElement(e, "li");
150-
target.nextSiblings().invoke('removeClassName', 'selected');
151-
target.previousSiblings().invoke('removeClassName', 'selected');
152-
target.addClassName('selected');
153-
oFormObject.down('#go_to_ws').removeClassName("disabled");
154-
oFormObject.down('#go_to_ws').CURRENT_REPO_ID = repoId;
155-
oFormObject.down('#go_to_ws').CURRENT_REPO_OBJECT = repoObject;
156-
if(window.ajxpMobile){
157-
switchToRepo(repoId);
158-
}
159-
};
160-
disableTextSelection(repoEl);
161-
if(simpleClickOpen){
162-
repoEl.observe("click", function(e){
163-
repoEl.stopObserving("click");
164-
select(e);
165-
Event.findElement(e, "li").setOpacity(0.7);
166-
switchToRepo(repoId);
167-
});
168-
}else{
169-
repoEl.observe("click", select);
170-
repoEl.observe("dblclick", function(e){
171-
repoEl.stopObserving("dblclick");
172-
select(e);
173-
Event.findElement(e, "li").setOpacity(0.7);
174-
switchToRepo(repoId);
175-
});
213+
document.observe("ajaxplorer:repository_list_refreshed", function(){
214+
if(oFormObject.down('#workspaces_list')) {
215+
$A(oFormObject.down('#workspaces_list').childElements()).invoke("remove");
176216
}
177-
repoEl.observe("mouseover", function(){
178-
updateWsLegend(repoObject);
179-
});
180-
repoEl.observe("mouseout", function(){
181-
updateWsLegend(null);
182-
});
183-
184-
};
185-
186-
var myWS = ProtoCompat.map2hash(ajaxplorer.user.repositories).filter(function(pair){
187-
return (pair.value.owner === '' && !pair.value.getAccessType().startsWith('ajxp_'));
188-
}).sortBy(function(pair){
189-
return (pair.value.getLabel());
190-
});
191-
var sharedWS = ProtoCompat.map2hash(ajaxplorer.user.repositories).filter(function(pair){
192-
return (pair.value.owner !== '' && !pair.value.getAccessType().startsWith('ajxp_'));
193-
}).sortBy(function(pair){
194-
return (pair.value.getLabel());
195-
});
196-
197-
if(myWS.size()){
198-
wsElement.insert(new Element('li', {className:'ws_selector_title'}).update("<h3>"+MessageHash[468]+"</h3>"));
199-
myWS.each(function(pair){renderElement(pair.value);});
200-
}
201-
202-
if(sharedWS.size()){
203-
wsElement.insert(new Element('li', {className:'ws_selector_title'}).update("<h3>"+MessageHash[469]+"</h3>"));
204-
sharedWS.each(function(pair){renderElement(pair.value);});
205-
}
217+
this._loadWsList(oFormObject, updateWsLegend, switchToRepo);
218+
}.bind(this));
206219

207220
if($('videos_pane')){
208221
$('videos_pane').select('div.tutorial_load_button').invoke("observe", "click", function(e){

core/src/plugins/access.fs/class.fsAccessDriver.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,9 @@ public function switchAction($action, $httpVars, $fileVars)
418418

419419
$node = $selection->getUniqueNode();
420420
$dlFile = $node->getUrl();
421+
if(!is_readable($dlFile)){
422+
throw new Exception("Cannot access file!");
423+
}
421424
$this->logInfo("Get_content", array("files"=>$this->addSlugToPath($selection)));
422425
if (AJXP_Utils::getStreamingMimeType(basename($dlFile))!==false) {
423426
$this->readFile($node->getUrl(), "stream_content");
@@ -432,15 +435,14 @@ public function switchAction($action, $httpVars, $fileVars)
432435
if(!isset($httpVars["content"])) break;
433436
// Load "code" variable directly from POST array, do not "securePath" or "sanitize"...
434437
$code = $httpVars["content"];
435-
$file = $selection->getUniqueFile();
436-
$this->logInfo("Online Edition", array("file"=>$this->addSlugToPath($file)));
438+
$currentNode = $selection->getUniqueNode();
439+
$fileName = $currentNode->getUrl();
440+
$this->logInfo("Online Edition", array("file"=>$fileName));
437441
if (isSet($httpVars["encode"]) && $httpVars["encode"] == "base64") {
438442
$code = base64_decode($code);
439443
} else {
440444
$code=str_replace("&lt;","<",SystemTextEncoding::magicDequote($code));
441445
}
442-
$fileName = $this->urlBase.$file;
443-
$currentNode = new AJXP_Node($fileName);
444446
try {
445447
AJXP_Controller::applyHook("node.before_change", array(&$currentNode, strlen($code)));
446448
} catch (Exception $e) {

0 commit comments

Comments
 (0)