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

Commit

Permalink
Make all calls to ShareCenter no more static, and split this class in…
Browse files Browse the repository at this point in the history
…to a new ShareStore class, that will implement a DB-based storage (and maintain backward compat to publiclets).

Add a download preProcessor to count the downloads.
  • Loading branch information
cdujeu committed Apr 23, 2014
1 parent 98bfe30 commit f8752ce
Show file tree
Hide file tree
Showing 6 changed files with 336 additions and 192 deletions.
Expand Up @@ -1539,7 +1539,8 @@ public function switchAction($action, $httpVars, $fileVars)

case "clear_expired" :

$deleted = ShareCenter::clearExpiredFiles(false); // $this->clearExpiredFiles();
$shareCenter = AJXP_PluginsService::getInstance()->findPluginById("action.share");
$deleted = $shareCenter->clearExpiredFiles(false); // $this->clearExpiredFiles();
AJXP_XMLWriter::header();
if (count($deleted)) {
AJXP_XMLWriter::sendMessage(sprintf($mess["ajxp_shared.23"], count($deleted).""), null);
Expand Down Expand Up @@ -2295,8 +2296,9 @@ public function listSharedFiles()
$downloadBase = str_replace("\\", "/", $fullUrl.rtrim(str_replace(AJXP_INSTALL_PATH, "", $dlFolder), "/"));
}

$shareCenter = AJXP_PluginsService::getInstance()->findPluginById("action.share");
foreach ($files as $file) {
$publicletData = ShareCenter::loadPublicletData(array_shift(explode(".", basename($file))));
$publicletData = $shareCenter->loadPublicletData(array_shift(explode(".", basename($file))));
if (!is_a($publicletData["REPOSITORY"], "Repository")) {
continue;
}
Expand Down
Expand Up @@ -98,11 +98,12 @@ public function switchAction($action, $httpVars, $fileVars)
$selection->initFromHttpVars($httpVars);
$files = $selection->getFiles();
AJXP_XMLWriter::header();
$shareCenter = AJXP_PluginsService::findPluginById("action.share");
foreach ($files as $index => $element) {
$element = basename($element);
$ar = explode("shared_", $mime);
$mime = array_pop($ar);
ShareCenter::deleteSharedElement($mime, $element, $loggedUser);
$shareCenter->deleteSharedElement($mime, $element, $loggedUser);
if($mime == "repository") $out = $mess["ajxp_conf.59"];
else if($mime == "user") $out = $mess["ajxp_conf.60"];
else if($mime == "file") $out = $mess["ajxp_shared.13"];
Expand Down
Expand Up @@ -153,6 +153,7 @@ public function switchAction($action, $httpVars, $fileVars)
$files = $selection->getFiles();
AJXP_XMLWriter::header();
$minisites = $this->listSharedFiles("minisites");
$shareCenter = AJXP_PluginsService::findPluginById("action.share");
foreach ($files as $index => $element) {
$element = basename($element);
$ar = explode("shared_", $mime);
Expand All @@ -161,7 +162,7 @@ public function switchAction($action, $httpVars, $fileVars)
$mime = "minisite";
$element = $minisites[$element];
}
ShareCenter::deleteSharedElement($mime, $element, $loggedUser);
$shareCenter->deleteSharedElement($mime, $element, $loggedUser);
if($mime == "repository" || $mime == "minisite") $out = $mess["ajxp_conf.59"];
else if($mime == "user") $out = $mess["ajxp_conf.60"];
else if($mime == "file") $out = $mess["user_dash.13"];
Expand All @@ -173,7 +174,8 @@ public function switchAction($action, $httpVars, $fileVars)

case "clear_expired" :

$deleted = ShareCenter::clearExpiredFiles(true); // $this->clearExpiredFiles();
$shareCenter = AJXP_PluginsService::getInstance()->findPluginById("action.share");
$deleted = $shareCenter->clearExpiredFiles(true);
AJXP_XMLWriter::header();
if (count($deleted)) {
AJXP_XMLWriter::sendMessage(sprintf($mess["user_dash.23"], count($deleted).""), null);
Expand Down Expand Up @@ -237,12 +239,13 @@ public function listSharedFiles($mode = "files")
$downloadBase = str_replace("\\", "/", $fullUrl.rtrim(str_replace(AJXP_INSTALL_PATH, "", $dlFolder), "/"));
}
$minisites = array();
$shareCenter = AJXP_PluginsService::getInstance()->findPluginById("action.share");
foreach ($files as $file) {
$ar = explode(".", basename($file));
$id = array_shift($ar);
if($ar[0] != "php") continue;
//if(strlen($id) != 32) continue;
$publicletData = ShareCenter::loadPublicletData($id);
$publicletData = $shareCenter->loadPublicletData($id);
if($mode == "files"){
if(isSet($publicletData["AJXP_APPLICATION_BASE"]) || isSet($publicletData["TRAVEL_PATH_TO_ROOT"])
|| (isset($publicletData["OWNER_ID"]) && $publicletData["OWNER_ID"] != $userId)
Expand Down
3 changes: 2 additions & 1 deletion core/src/plugins/access.fs/class.fsAccessDriver.php
Expand Up @@ -1869,6 +1869,7 @@ public function makeZip ($src, $dest, $basedir)
public function recursivePurge($dirName, $hardPurgeTime, $softPurgeTime = 0)
{
$handle=opendir($dirName);
$shareCenter = AJXP_PluginsService::findPluginById("action.share");
while (false !== ($entry = readdir($handle))) {
if ($entry == "" || $entry == ".." || AJXP_Utils::isHidden($entry) ) {
continue;
Expand All @@ -1879,7 +1880,7 @@ public function recursivePurge($dirName, $hardPurgeTime, $softPurgeTime = 0)
if ($hardPurgeTime > 0 && $docAge > $hardPurgeTime) {
$this->purge($fileName);
} elseif ($softPurgeTime > 0 && $docAge > $softPurgeTime) {
if(!ShareCenter::isShared(new AJXP_Node($fileName))) {
if($shareCenter !== false && $shareCenter->isShared(new AJXP_Node($fileName))) {
$this->purge($fileName);
}
}
Expand Down

0 comments on commit f8752ce

Please sign in to comment.