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

Commit

Permalink
Edit meta_sources as bulk data
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Jul 24, 2015
1 parent 7e4f0ba commit 31db26f
Showing 1 changed file with 39 additions and 14 deletions.
53 changes: 39 additions & 14 deletions core/src/plugins/access.ajxp_conf/class.ajxp_confAccessDriver.php
Expand Up @@ -1593,21 +1593,46 @@ public function switchAction($action, $httpVars, $fileVars)
if (!is_object($repo)) {
throw new Exception("Invalid workspace id! $repId");
}
$metaSourceId = $httpVars["plugId"];
$repoOptions = $repo->getOption("META_SOURCES");
if (!is_array($repoOptions)) {
$repoOptions = array();
}
if (isSet($httpVars["json_data"])) {
$options = json_decode(SystemTextEncoding::magicDequote($httpVars["json_data"]), true);
} else {
$options = array();
$this->parseParameters($httpVars, $options, null, true);
}
if(isset($repoOptions[$metaSourceId])){
$this->mergeExistingParameters($options, $repoOptions[$metaSourceId]);
if(isSet($httpVars["plugId"])){
$metaSourceId = $httpVars["plugId"];
$repoOptions = $repo->getOption("META_SOURCES");
if (!is_array($repoOptions)) {
$repoOptions = array();
}
if (isSet($httpVars["json_data"])) {
$options = json_decode(SystemTextEncoding::magicDequote($httpVars["json_data"]), true);
} else {
$options = array();
$this->parseParameters($httpVars, $options, null, true);
}
if(isset($repoOptions[$metaSourceId])){
$this->mergeExistingParameters($options, $repoOptions[$metaSourceId]);
}
$repoOptions[$metaSourceId] = $options;
}else if(isSet($httpVars["bulk_data"])){
$bulkData = json_decode(SystemTextEncoding::magicDequote($httpVars["bulk_data"]), true);
$repoOptions = $repo->getOption("META_SOURCES");
if (!is_array($repoOptions)) {
$repoOptions = array();
}
if(isSet($bulkData["delete"]) && count($bulkData["delete"])){
foreach($bulkData["delete"] as $key){
if(isSet($repoOptions[$key])) unset($repoOptions[$key]);
}
}
if(isSet($bulkData["add"]) && count($bulkData["add"])){
foreach($bulkData["add"] as $key => $value){
if(isSet($repoOptions[$key])) $this->mergeExistingParameters($value, $repoOptions[$key]);
$repoOptions[$key] = $value;
}
}
if(isSet($bulkData["edit"]) && count($bulkData["edit"])){
foreach($bulkData["edit"] as $key => $value){
if(isSet($repoOptions[$key])) $this->mergeExistingParameters($value, $repoOptions[$key]);
$repoOptions[$key] = $value;
}
}
}
$repoOptions[$metaSourceId] = $options;
uksort($repoOptions, array($this,"metaSourceOrderingFunction"));
$repo->addOption("META_SOURCES", $repoOptions);
ConfService::replaceRepository($repId, $repo);
Expand Down

0 comments on commit 31db26f

Please sign in to comment.