Permalink
Browse files

Fixing broken merge

  • Loading branch information...
2 parents fd6aa36 + 2cf2a73 commit 30050f4872d7519b1bc481f1848f6b32b82ed815 @ghecquet ghecquet committed Jun 6, 2016
Showing with 140 additions and 125 deletions.
  1. +7 −5 core/src/core/src/pydio/Core/Controller/XMLWriter.php
  2. +3 −5 core/src/core/src/pydio/Core/Services/AuthService.php
  3. +6 −6 core/src/core/src/pydio/Core/Services/ConfService.php
  4. +8 −6 core/src/core/src/pydio/Core/Utils/Utils.php
  5. +25 −12 core/src/plugins/access.ajxp_conf/class.ajxp_confAccessDriver.php
  6. +12 −11 core/src/plugins/access.dropbox/class.dropboxAccessDriver.php
  7. +3 −3 core/src/plugins/access.fs/class.fsAccessDriver.php
  8. +2 −2 core/src/plugins/access.ftp/class.ftpAccessDriver.php
  9. +2 −2 core/src/plugins/action.compression/class.PluginCompression.php
  10. +1 −1 core/src/plugins/action.powerfs/class.PowerFSController.php
  11. +1 −1 core/src/plugins/action.scheduler/class.AjxpScheduler.php
  12. +2 −4 core/src/plugins/action.skeleton/class.PluginSkeleton.php
  13. +6 −4 core/src/plugins/authfront.cyphered/class.CypheredAuthFrontend.php
  14. +5 −3 core/src/plugins/authfront.duosecurity/class.DuoSecurityFrontend.php
  15. +8 −4 core/src/plugins/authfront.keystore/class.KeystoreAuthFrontend.php
  16. +4 −4 core/src/plugins/boot.conf/class.BootConfLoader.php
  17. +2 −2 core/src/plugins/core.access/src/AbstractAccessDriver.php
  18. +2 −2 core/src/plugins/core.auth/class.AbstractAuthDriver.php
  19. +6 −2 core/src/plugins/core.cache/class.AbstractCacheDriver.php
  20. +4 −4 core/src/plugins/core.conf/class.AbstractConfDriver.php
  21. +1 −1 core/src/plugins/core.index/class.CoreIndexer.php
  22. +2 −1 core/src/plugins/core.log/class.AJXP_Logger.php
  23. +1 −1 core/src/plugins/core.mq/class.MqManager.php
  24. +8 −12 core/src/plugins/core.notifications/class.AJXP_NotificationCenter.php
  25. +6 −14 core/src/plugins/core.tasks/src/TaskService.php
  26. +6 −6 core/src/plugins/gui.ajax/class.AJXP_ClientDriver.php
  27. +1 −1 core/src/plugins/index.elasticsearch/class.AjxpElasticSearch.php
  28. +2 −2 core/src/plugins/index.lucene/class.AjxpLuceneIndexer.php
  29. +3 −3 core/src/plugins/meta.syncable/class.ChangesTracker.php
  30. +1 −1 core/src/plugins/uploader.http/class.HttpDownloader.php
@@ -22,10 +22,10 @@
use Pydio\Access\Core\Model\AJXP_Node;
use Pydio\Access\Core\IAjxpWrapperProvider;
+use Pydio\Core\Model\ContextInterface;
use Pydio\Core\Model\RepositoryInterface;
use Pydio\Core\Utils\Utils;
use Pydio\Core\Services;
-use Pydio\Core\Services\AuthService;
use Pydio\Conf\Core\AbstractAjxpUser;
use Pydio\Core\Services\ConfService;
use Pydio\Core\PluginFramework\PluginsService;
@@ -498,24 +498,26 @@ public static function sendMessage($logMessage, $errorMessage, $print = true)
/**
* Extract all the user data and put it in XML
* @static
+ * @param ContextInterface $ctx
* @param AbstractAjxpUser|null $userObject
* @return string
*/
- public static function getUserXML($userObject = null)
+ public static function getUserXML(ContextInterface $ctx, $userObject = null)
{
$buffer = "";
- $loggedUser = AuthService::getLoggedUser();
+ $loggedUser = $ctx->getUser();
+ $currentRepoId = $ctx->getRepositoryId();
$confDriver = ConfService::getConfStorageImpl();
if($userObject != null) $loggedUser = $userObject;
if (!Services\AuthService::usersEnabled()) {
$buffer.="<user id=\"shared\">";
- $buffer.="<active_repo id=\"".ConfService::getCurrentRepositoryId()."\" write=\"1\" read=\"1\"/>";
+ $buffer.="<active_repo id=\"".$currentRepoId."\" write=\"1\" read=\"1\"/>";
$buffer.= XMLWriter::writeRepositoriesData(null);
$buffer.="</user>";
} else if ($loggedUser != null) {
$lock = $loggedUser->getLock();
$buffer.="<user id=\"".$loggedUser->id."\">";
- $buffer.="<active_repo id=\"".ConfService::getCurrentRepositoryId()."\" write=\"".($loggedUser->canWrite(ConfService::getCurrentRepositoryId())?"1":"0")."\" read=\"".($loggedUser->canRead(ConfService::getCurrentRepositoryId())?"1":"0")."\"/>";
+ $buffer.="<active_repo id=\"".$currentRepoId."\" write=\"".($loggedUser->canWrite($currentRepoId)?"1":"0")."\" read=\"".($loggedUser->canRead($currentRepoId)?"1":"0")."\"/>";
$buffer.= XMLWriter::writeRepositoriesData($loggedUser);
$buffer.="<preferences>";
$preferences = $confDriver->getExposedPreferences($loggedUser);
@@ -21,14 +21,12 @@
namespace Pydio\Core\Services;
use Pydio\Access\Core\Model\Repository;
use Pydio\Auth\Core\AJXP_Safe;
-use Pydio\Authfront\Core\AbstractAuthFrontend;
use Pydio\Conf\Core\AbstractAjxpUser;
use Pydio\Conf\Core\AJXP_Role;
use Pydio\Conf\Core\AjxpGroupPathProvider;
use Pydio\Conf\Core\AjxpRole;
-use Pydio\Core\Model\Context;
use Pydio\Core\Model\ContextInterface;
-use Pydio\Core\Services\ConfService;
+use Pydio\Core\Model\UserInterface;
use Pydio\Core\Controller\Controller;
use Pydio\Core\Utils\CookiesHelper;
use Pydio\Core\Utils\Utils;
@@ -189,7 +187,7 @@ public static function ignoreUserCase()
/**
* @static
- * @param AbstractAjxpUser $user
+ * @param UserInterface $user
*/
public static function refreshRememberCookie($user)
{
@@ -199,7 +197,7 @@ public static function refreshRememberCookie($user)
}
$rememberPass = CookiesHelper::getCookieString($user);
if(self::$useSession) {
- setcookie("AjaXplorer-remember", $user->id.":".$rememberPass, time()+3600*24*10, null, null, (isSet($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) == "on"), true);
+ setcookie("AjaXplorer-remember", $user->getId().":".$rememberPass, time()+3600*24*10, null, null, (isSet($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) == "on"), true);
}
}
@@ -475,7 +475,7 @@ public static function getRepositoriesList($scope = "user", $includeShared = tru
if ($scope == "user") {
return self::getInstance()->getLoadedRepositories();
} else {
- return self::getInstance()->initRepositoriesListInst("all", $includeShared);
+ return self::getInstance()->initRepositoriesListInst("all", null, $includeShared);
}
}
@@ -510,7 +510,7 @@ private function getLoadedRepositories()
unset($this->configs["REPOSITORIES"]);
}
}
- $this->configs["REPOSITORIES"] = $this->initRepositoriesListInst();
+ $this->configs["REPOSITORIES"] = $this->initRepositoriesListInst("user", AuthService::getLoggedUser());
$_SESSION["REPOSITORIES"] = $this->configs["REPOSITORIES"];
return $this->configs["REPOSITORIES"];
}
@@ -762,13 +762,13 @@ public static function listRepositoriesWithCriteria($criteria, &$count){
/**
* @param $scope String "user", "all"
+ * @param UserInterface|null $loggedUser
* @param bool $includeShared
* @return array
*/
- protected function initRepositoriesListInst($scope = "user", $includeShared = true)
+ protected function initRepositoriesListInst($scope = "user", $loggedUser = null, $includeShared = true)
{
// APPEND CONF FILE REPOSITORIES
- $loggedUser = AuthService::getLoggedUser();
$objList = array();
if($loggedUser != null){
$l = $loggedUser->getLock();
@@ -786,8 +786,8 @@ protected function initRepositoriesListInst($scope = "user", $includeShared = tr
$confDriver = self::getConfStorageImpl();
if($scope == "user"){
$acls = array();
- if(AuthService::getLoggedUser() != null){
- $acls = AuthService::getLoggedUser()->mergedRole->listAcls(true);
+ if($loggedUser != null){
+ $acls = $loggedUser->getMergedRole()->listAcls(true);
}
if(!count($acls)) {
$drvList = array();
@@ -22,6 +22,7 @@
use Psr\Http\Message\UploadedFileInterface;
use Pydio\Access\Core\Model\Repository;
+use Pydio\Core\Model\ContextInterface;
use Pydio\Core\Services\AuthService;
use Pydio\Core\Services\ConfService;
use Pydio\Core\PluginFramework\Plugin;
@@ -384,12 +385,13 @@ public static function parseFileDataErrors($boxData, $throwException=false)
* + skipIOS
* + gui
* @static
+ * @param ContextInterface $ctx
* @param $parameters
* @param $output
* @param $session
* @return void
*/
- public static function parseApplicationGetParameters($parameters, &$output, &$session)
+ public static function parseApplicationGetParameters(ContextInterface $ctx, $parameters, &$output, &$session)
{
$output["EXT_REP"] = "/";
@@ -411,7 +413,7 @@ public static function parseApplicationGetParameters($parameters, &$output, &$se
$parameters["repository_id"] = $repository->getId();
}
if (AuthService::usersEnabled()) {
- $loggedUser = AuthService::getLoggedUser();
+ $loggedUser = $ctx->getUser();
if ($loggedUser != null && $loggedUser->canSwitchTo($parameters["repository_id"])) {
$output["FORCE_REGISTRY_RELOAD"] = true;
$output["EXT_REP"] = TextEncoder::toUTF8(urldecode($parameters["folder"]));
@@ -1731,10 +1733,10 @@ public static function filterFormElementsFromMeta($metadata, &$nestedData, $user
}
}
- public static function parseStandardFormParameters(&$repDef, &$options, $userId = null, $prefix = "DRIVER_OPTION_", $binariesContext = null, $cypheredPassPrefix = "")
+ public static function parseStandardFormParameters(ContextInterface $ctx, &$repDef, &$options, $prefix = "DRIVER_OPTION_", $binariesContext = null, $cypheredPassPrefix = "")
{
if ($binariesContext === null) {
- $binariesContext = array("USER" => (AuthService::getLoggedUser()!= null)?AuthService::getLoggedUser()->getId():"shared");
+ $binariesContext = array("USER" => ($ctx->hasUser())?$ctx->getUser()->getId():"shared");
}
$replicationGroups = array();
$switchesGroups = array();
@@ -1752,10 +1754,10 @@ public static function parseStandardFormParameters(&$repDef, &$options, $userId
$value = intval($value);
} else if ($type == "array") {
$value = explode(",", $value);
- } else if ($type == "password" && $userId!=null) {
+ } else if ($type == "password" && $ctx->hasUser()) {
if (trim($value) != "" && $value != "__AJXP_VALUE_SET__" && function_exists('mcrypt_encrypt')) {
// We encode as base64 so if we need to store the result in a database, it can be stored in text column
- $value = $cypheredPassPrefix . base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($userId."\1CDAFx¨op#"), $value, MCRYPT_MODE_ECB));
+ $value = $cypheredPassPrefix . base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($ctx->getUser()->getId()."\1CDAFx¨op#"), $value, MCRYPT_MODE_ECB));
}
} else if ($type == "binary" && $binariesContext !== null) {
if (!empty($value)) {
@@ -28,6 +28,7 @@
use Pydio\Access\Core\Filter\AJXP_PermissionMask;
use Pydio\Access\Core\Model\Repository;
use Pydio\Access\Core\Model\UserSelection;
+use Pydio\Core\Model\Context;
use Pydio\Core\Model\ContextInterface;
use Pydio\Core\Model\UserInterface;
use Pydio\Core\Services\AuthService;
@@ -871,7 +872,10 @@ public function switchAction($action, $httpVars, $fileVars, ContextInterface $ct
$data = json_decode($jsonData, true);
$roleData = $data["ROLE"];
$binariesContext = array();
+ $parseContext = $ctx;
if (isset($userObject)) {
+ $parseContext = new Context(null, $ctx->getRepositoryId());
+ $parseContext->setUserObject($userObject);
$binariesContext = array("USER" => $userObject->getId());
}
if(isSet($data["FORMS"])){
@@ -880,9 +884,9 @@ public function switchAction($action, $httpVars, $fileVars, ContextInterface $ct
foreach ($plugData as $plugId => $formsData) {
$parsed = array();
Utils::parseStandardFormParameters(
+ $parseContext,
$formsData,
$parsed,
- ($userObject!=null?$usrId:null),
"ROLE_PARAM_",
$binariesContext,
AJXP_Role::$cypheredPassPrefix
@@ -1284,6 +1288,7 @@ public function switchAction($action, $httpVars, $fileVars, ContextInterface $ct
break;
case "save_custom_user_params" :
+
$userId = Utils::sanitize($httpVars["user_id"], AJXP_SANITIZE_EMAILCHARS);
if ($userId == $loggedUser->getId()) {
$user = $loggedUser;
@@ -1299,7 +1304,8 @@ public function switchAction($action, $httpVars, $fileVars, ContextInterface $ct
if(!is_array($custom)) $custom = array();
$options = $custom;
- $this->parseParameters($httpVars, $options, $userId, false, $custom);
+ $newCtx = new Context($userId, $ctx->getRepositoryId());
+ $this->parseParameters($newCtx, $httpVars, $options, false, $custom);
$custom = $options;
$user->setPref("CUSTOM_PARAMS", $custom);
$user->save();
@@ -1333,7 +1339,8 @@ public function switchAction($action, $httpVars, $fileVars, ContextInterface $ct
}
$options = $wallet[$repoID];
$existing = $options;
- $this->parseParameters($httpVars, $options, $userId, false, $existing);
+ $newCtx = new Context($userId, $ctx->getRepositoryId());
+ $this->parseParameters($newCtx, $httpVars, $options, false, $existing);
$wallet[$repoID] = $options;
$user->setPref("AJXP_WALLET", $wallet);
$user->save();
@@ -1448,7 +1455,7 @@ public function switchAction($action, $httpVars, $fileVars, ContextInterface $ct
$options = $repDef["DRIVER_OPTIONS"];
} else {
$options = array();
- $this->parseParameters($repDef, $options, null, true);
+ $this->parseParameters($ctx, $repDef, $options, true);
}
if (count($options)) {
$repDef["DRIVER_OPTIONS"] = $options;
@@ -1717,7 +1724,7 @@ public function switchAction($action, $httpVars, $fileVars, ContextInterface $ct
if(!$repo->isTemplate){
foreach($existing as $exK) $existingValues[$exK] = $repo->getOption($exK, true);
}
- $this->parseParameters($httpVars, $options, null, true, $existingValues);
+ $this->parseParameters($ctx, $httpVars, $options, true, $existingValues);
if (count($options)) {
foreach ($options as $key=>$value) {
if ($key == "AJXP_SLUG") {
@@ -1822,7 +1829,7 @@ public function switchAction($action, $httpVars, $fileVars, ContextInterface $ct
$options = json_decode(TextEncoder::magicDequote($httpVars["json_data"]), true);
} else {
$options = array();
- $this->parseParameters($httpVars, $options, null, true);
+ $this->parseParameters($ctx, $httpVars, $options, true);
}
$repoOptions = $repo->getOption("META_SOURCES");
if (is_array($repoOptions) && isSet($repoOptions[$metaSourceType])) {
@@ -1879,7 +1886,7 @@ public function switchAction($action, $httpVars, $fileVars, ContextInterface $ct
$options = json_decode(TextEncoder::magicDequote($httpVars["json_data"]), true);
} else {
$options = array();
- $this->parseParameters($httpVars, $options, null, true);
+ $this->parseParameters($ctx, $httpVars, $options, true);
}
if(isset($repoOptions[$metaSourceId])){
$this->mergeExistingParameters($options, $repoOptions[$metaSourceId]);
@@ -2094,7 +2101,7 @@ public function switchAction($action, $httpVars, $fileVars, ContextInterface $ct
case "run_plugin_action":
$options = array();
- $this->parseParameters($httpVars, $options, null, true);
+ $this->parseParameters($ctx, $httpVars, $options, true);
$pluginId = $httpVars["action_plugin_id"];
if (isSet($httpVars["button_key"])) {
$options = $options[$httpVars["button_key"]];
@@ -2117,7 +2124,7 @@ public function switchAction($action, $httpVars, $fileVars, ContextInterface $ct
case "edit_plugin_options":
$options = array();
- $this->parseParameters($httpVars, $options, null, true);
+ $this->parseParameters($ctx, $httpVars, $options, true);
$confStorage = ConfService::getConfStorageImpl();
$pluginId = Utils::sanitize($httpVars["plugin_id"], AJXP_SANITIZE_ALPHANUM);
list($pType, $pName) = explode(".", $pluginId);
@@ -2911,10 +2918,16 @@ public function updateUserRole(UserInterface $ctxUser, $userId, $roleId, $addOrR
}
-
- protected function parseParameters(&$repDef, &$options, $userId = null, $globalBinaries = false, $existingValues = array())
+ /**
+ * @param ContextInterface $ctx
+ * @param $repDef
+ * @param $options
+ * @param bool $globalBinaries
+ * @param array $existingValues
+ */
+ protected function parseParameters(ContextInterface $ctx, &$repDef, &$options, $globalBinaries = false, $existingValues = array())
{
- Utils::parseStandardFormParameters($repDef, $options, $userId, "DRIVER_OPTION_", ($globalBinaries?array():null));
+ Utils::parseStandardFormParameters($ctx, $repDef, $options, "DRIVER_OPTION_", ($globalBinaries?array():null));
if(!count($existingValues)){
return;
}
@@ -74,7 +74,7 @@ protected function initRepository(ContextInterface $contextInterface)
if(!empty($_SESSION["OAUTH_DROPBOX_TOKENS"])) return;
// TOKENS IN FILE ?
- $tokens = $this->getTokens();
+ $tokens = $this->getTokens($contextInterface);
if (!empty($tokens)) {
$_SESSION["OAUTH_DROPBOX_TOKENS"] = $tokens;
return;
@@ -108,7 +108,7 @@ protected function initRepository(ContextInterface $contextInterface)
}
$_SESSION['DROPBOX_NEGOCIATION_STATE'] = 3;
$_SESSION['OAUTH_DROPBOX_TOKENS'] = $tokens;
- $this->setTokens($tokens);
+ $this->setTokens($contextInterface, $tokens);
return;
}
@@ -128,14 +128,15 @@ public function isWriteable($dir, $type = "dir")
return true;
}
- public function getTokens()
+ public function getTokens(ContextInterface $ctx)
{
- if($this->repository->getOption("DROPBOX_OAUTH_TOKENS") !== null && is_array($this->repository->getOption("DROPBOX_OAUTH_TOKENS"))){
- return $this->repository->getOption("DROPBOX_OAUTH_TOKENS");
+ $repo = $ctx->getRepository();
+ if($repo->getOption("DROPBOX_OAUTH_TOKENS") !== null && is_array($repo->getOption("DROPBOX_OAUTH_TOKENS"))){
+ return $repo->getOption("DROPBOX_OAUTH_TOKENS");
}
- $repositoryId = $this->repository->getId();
+ $repositoryId = $repo->getId();
if(AuthService::usersEnabled()) {
- $u = AuthService::getLoggedUser();
+ $u = $ctx->getUser();
$userId = $u->getId();
if($u->getResolveAsParent()){
$userId = $u->getParent();
@@ -146,18 +147,18 @@ public function getTokens()
return Utils::loadSerialFile(AJXP_DATA_PATH."/plugins/access.dropbox/".$repositoryId."_".$userId."_tokens");
}
- public function setTokens($oauth_tokens)
+ public function setTokens(ContextInterface $ctx, $oauth_tokens)
{
- $repositoryId = $this->repository->getId();
- if(AuthService::usersEnabled()) $userId = AuthService::getLoggedUser()->getId();
+ $repositoryId = $ctx->getUser()->getId();
+ if(AuthService::usersEnabled()) $userId = $ctx->getUser()->getId();
else $userId = "shared";
Utils::saveSerialFile(AJXP_DATA_PATH."/plugins/access.dropbox/".$repositoryId."_".$userId."_tokens", $oauth_tokens, true);
}
public function makeSharedRepositoryOptions(ContextInterface $ctx, $httpVars)
{
$newOptions = parent::makeSharedRepositoryOptions($ctx, $httpVars);
- $newOptions["DROPBOX_OAUTH_TOKENS"] = $this->getTokens();
+ $newOptions["DROPBOX_OAUTH_TOKENS"] = $this->getTokens($ctx);
return $newOptions;
}
Oops, something went wrong.

0 comments on commit 30050f4

Please sign in to comment.