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

Commit

Permalink
Massive Share dialog rework
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Jul 24, 2014
1 parent a512b5f commit 934db67
Show file tree
Hide file tree
Showing 12 changed files with 665 additions and 216 deletions.
201 changes: 159 additions & 42 deletions core/src/plugins/action.share/class.ShareCenter.js

Large diffs are not rendered by default.

143 changes: 96 additions & 47 deletions core/src/plugins/action.share/class.ShareCenter.php
Expand Up @@ -1273,7 +1273,16 @@ public function computeSharedRepositoryAccessRights($repoId, $mixUsersAndGroups,
public function createSharedMinisite($httpVars, $repository, $accessDriver)
{
$uniqueUser = null;
if (isSet($httpVars["create_guest_user"])) {
if(isSet($httpVars["repository_id"]) && isSet($httpVars["guest_user_id"])){

$uniqueUser = $httpVars["guest_user_id"];
if(!empty($httpVars["guest_user_pass"])){
//$userPass = $httpVars["guest_user_pass"];
// UPDATE GUEST USER PASS HERE
AuthService::updatePassword($uniqueUser, $httpVars["guest_user_pass"]);
}

}else if (isSet($httpVars["create_guest_user"])) {
// Create a guest user
$userId = substr(md5(time()), 0, 12);
$pref = $this->getFilteredOption("SHARED_USERS_TMP_PREFIX", $this->repository->getId());
Expand All @@ -1285,38 +1294,44 @@ public function createSharedMinisite($httpVars, $repository, $accessDriver)
}else{
$userPass = substr(md5(time()), 13, 24);
}
$httpVars["user_0"] = $userId;
$httpVars["user_pass_0"] = $httpVars["shared_pass"] = $userPass;
$uniqueUser = $userId;
}
if(isSet($uniqueUser)){
if(isSet($userPass)) {
$httpVars["user_pass_0"] = $httpVars["shared_pass"] = $userPass;
}
$httpVars["user_0"] = $uniqueUser;
$httpVars["entry_type_0"] = "user";
$httpVars["right_read_0"] = (isSet($httpVars["simple_right_read"]) ? "true" : "false");
$httpVars["right_write_0"] = (isSet($httpVars["simple_right_write"]) ? "true" : "false");
$httpVars["right_watch_0"] = "false";
$httpVars["disable_download"] = (isSet($httpVars["simple_right_download"]) ? false : true);
if ($httpVars["right_write_0"] == "false" && $httpVars["right_read_0"] == "false") {
return "share_center.58";
}
if ($httpVars["right_read_0"] == "false" && !$httpVars["disable_download"]) {
$httpVars["right_read_0"] = "true";
}
$uniqueUser = $userId;
if ($httpVars["right_write_0"] == "false" && $httpVars["right_read_0"] == "false") {
return "share_center.58";
}
}

$httpVars["minisite"] = true;
$httpVars["selection"] = true;
$userSelection = new UserSelection($repository, $httpVars);
$setFilter = false;
if($userSelection->isUnique()){
$node = $userSelection->getUniqueNode($this->accessDriver);
$node->loadNodeInfo();
if($node->isLeaf()){
if(!isSet($userSelection)){
$userSelection = new UserSelection($repository, $httpVars);
$setFilter = false;
if($userSelection->isUnique()){
$node = $userSelection->getUniqueNode($this->accessDriver);
$node->loadNodeInfo();
if($node->isLeaf()){
$setFilter = true;
$httpVars["file"] = "/";
}
}else{
$setFilter = true;
$httpVars["file"] = "/";
}
}else{
$setFilter = true;
}
if($setFilter){
$httpVars["filter_nodes"] = $userSelection->buildNodes($this->accessDriver);
if($setFilter){
$httpVars["filter_nodes"] = $userSelection->buildNodes($this->accessDriver);
}
}
$newRepo = $this->createSharedRepository($httpVars, $repository, $accessDriver, $uniqueUser);

Expand All @@ -1326,20 +1341,21 @@ public function createSharedMinisite($httpVars, $repository, $accessDriver)
$downloadFolder = ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER");
$this->initPublicFolder($downloadFolder);

$data = array(
"REPOSITORY"=>$newId
);
if(isset($httpVars["repository_id"])){
$data = $this->shareStore->loadShare($httpVars["hash"]);
}else{
$data = array(
"REPOSITORY"=>$newId
);
}
if(isSet($httpVars["create_guest_user"]) && isSet($userId)){
if(empty($httpVars["guest_user_pass"])){
$data["PRELOG_USER"] = $userId;
}else{
$data["PRESET_LOGIN"] = $userId;
}
}
if ($httpVars["disable_download"]) {
$data["DOWNLOAD_DISABLED"] = true;
}

$data["DOWNLOAD_DISABLED"] = $httpVars["disable_download"];
$data["AJXP_APPLICATION_BASE"] = AJXP_Utils::detectServerURL(true);
if(isSet($httpVars["minisite_layout"])){
$data["AJXP_TEMPLATE_NAME"] = $httpVars["minisite_layout"];
Expand All @@ -1354,21 +1370,38 @@ public function createSharedMinisite($httpVars, $repository, $accessDriver)
$data["OWNER_ID"] = AuthService::getLoggedUser()->getId();
}

try{
$hash = $this->getShareStore()->storeShare($repository->getId(), $data);
}catch(Exception $e){
return $e->getMessage();
if(!isSet($httpVars["repository_id"])){
try{
$hash = $this->getShareStore()->storeShare($repository->getId(), $data);
}catch(Exception $e){
return $e->getMessage();
}
$url = $this->buildPublicletLink($hash);
AJXP_Controller::applyHook("node.share.create", array(
'type' => 'minisite',
'repository' => &$repository,
'accessDriver' => &$accessDriver,
'data' => &$data,
'url' => $url,
'new_repository' => &$newRepo
));
}else{
try{
$hash = $httpVars["hash"];
$this->getShareStore()->storeShare($repository->getId(), $data, "minisite", $hash);
}catch(Exception $e){
return $e->getMessage();
}
$url = $this->buildPublicletLink($hash);
AJXP_Controller::applyHook("node.share.update", array(
'type' => 'minisite',
'repository' => &$repository,
'accessDriver' => &$accessDriver,
'data' => &$data,
'url' => $url,
'new_repository' => &$newRepo
));
}
$url = $this->buildPublicletLink($hash);

AJXP_Controller::applyHook("node.share.create", array(
'type' => 'minisite',
'repository' => &$repository,
'accessDriver' => &$accessDriver,
'data' => &$data,
'url' => $url,
'new_repository' => &$newRepo
));

return array($hash, $url);
}
Expand Down Expand Up @@ -1519,11 +1552,16 @@ public function createSharedRepository($httpVars, $repository, $accessDriver, $u
}
if (isSet($editingRepo)) {
$newRepo = $editingRepo;
$replace = false;
if ($editingRepo->getDisplay() != $label) {
$newRepo->setDisplay($label);
ConfService::replaceRepository($httpVars["repository_id"], $newRepo);
$replace= true;
}
if($editingRepo->getDescription() != $description){
$newRepo->setDescription($description);
$replace = true;
}
$editingRepo->setDescription($description);
if($replace) ConfService::replaceRepository($httpVars["repository_id"], $newRepo);
} else {
if ($repository->getOption("META_SOURCES")) {
$options["META_SOURCES"] = $repository->getOption("META_SOURCES");
Expand Down Expand Up @@ -1623,6 +1661,11 @@ public function createSharedRepository($httpVars, $repository, $accessDriver, $u
// CREATE USER WITH NEW REPO RIGHTS
$userObject->personalRole->setAcl($newRepo->getUniqueId(), $uRights[$userName]);
if (isSet($httpVars["minisite"])) {
if(isset($editingRepo)){
try{
AuthService::deleteRole("AJXP_SHARED-".$newRepo->getUniqueId());
}catch (Exception $e){}
}
$newRole = new AJXP_Role("AJXP_SHARED-".$newRepo->getUniqueId());
$r = AuthService::getRole("MINISITE");
if (is_a($r, "AJXP_Role")) {
Expand Down Expand Up @@ -1682,7 +1725,7 @@ public function createSharedRepository($httpVars, $repository, $accessDriver, $u
}

if (array_key_exists("minisite", $httpVars) && $httpVars["minisite"] != true) {
AJXP_Controller::applyHook("node.share.create", array(
AJXP_Controller::applyHook( (isSet($editingRepo) ? "node.share.update" : "node.share.create"), array(
'type' => 'repository',
'repository' => &$repository,
'accessDriver' => &$accessDriver,
Expand Down Expand Up @@ -2076,7 +2119,7 @@ public function shareToJson($shareId, $shareData, $node = null){
$minisiteData = $this->getShareStore()->loadShare($shareId);
$repoId = $minisiteData["REPOSITORY"];
$minisiteIsPublic = isSet($minisiteData["PRELOG_USER"]);
$dlDisabled = isSet($minisiteData["DOWNLOAD_DISABLED"]);
$dlDisabled = isSet($minisiteData["DOWNLOAD_DISABLED"]) && $minisiteData["DOWNLOAD_DISABLED"] === true;
if (isSet($shareData["short_form_url"])) {
$minisiteLink = $shareData["short_form_url"];
} else {
Expand Down Expand Up @@ -2131,15 +2174,21 @@ public function shareToJson($shareId, $shareData, $node = null){
$jsonData["download_limit"] = $minisiteData["DOWNLOAD_LIMIT"];
}
if(!empty($minisiteData["EXPIRE_TIME"])){
$delta = $minisiteData["EXPIRE_TIME"] - time();
$days = round($delta / (60*60*24));
$jsonData["expire_time"] = date($messages["date_format"], $minisiteData["EXPIRE_TIME"]);
$jsonData["expire_after"] = $days;
}else{
$jsonData["expire_after"] = 0;
}
if(isSet($minisiteData["AJXP_TEMPLATE_NAME"])){
$jsonData["minisite_layout"] = $minisiteData["AJXP_TEMPLATE_NAME"];
}
$jsonData["minisite"] = array(
"public" => $minisiteIsPublic?"true":"false",
"public_link" => $minisiteLink,
"disable_download" => $dlDisabled
"public" => $minisiteIsPublic?"true":"false",
"public_link" => $minisiteLink,
"disable_download" => $dlDisabled,
"hash" => $shareId
);
foreach($this->getShareStore()->modifiableShareKeys as $key){
if(isSet($minisiteData[$key])) $jsonData[$key] = $minisiteData[$key];
Expand Down

0 comments on commit 934db67

Please sign in to comment.