Permalink
Browse files

Full namespace-ize action.share

  • Loading branch information...
1 parent 69df964 commit b3d35c8903a5c6d55e5cbea3e1be6f81238ea83b @cdujeu cdujeu committed May 27, 2016
Showing with 217 additions and 200 deletions.
  1. +1 −6 core/src/plugins/access.ajxp_home/class.HomePagePlugin.php
  2. +3 −31 core/src/plugins/access.ajxp_user/class.UserDashboardDriver.php
  3. +2 −3 core/src/plugins/access.fs/class.fsAccessDriver.php
  4. +1 −1 core/src/plugins/action.powerfs/class.PowerFSController.php
  5. +1 −1 core/src/plugins/action.share/manifest.xml
  6. +29 −12 core/src/plugins/action.share/{class.LegacyPubliclet.php → src/Legacy/LegacyPubliclet.php}
  7. +3 −1 core/src/plugins/action.share/{class.PublicletCounter.php → src/Legacy/PublicletCounter.php}
  8. +6 −2 core/src/plugins/action.share/{class.CompositeShare.php → src/Model/CompositeShare.php}
  9. +42 −11 core/src/plugins/action.share/{class.ShareLink.php → src/Model/ShareLink.php}
  10. +57 −50 core/src/plugins/action.share/{class.ShareCenter.php → src/ShareCenter.php}
  11. +2 −0 core/src/plugins/action.share/{class.ShareMetaManager.php → src/Store/ShareMetaManager.php}
  12. +19 −17 core/src/plugins/action.share/{class.ShareRightsManager.php → src/Store/ShareRightsManager.php}
  13. +30 −51 core/src/plugins/action.share/{class.ShareStore.php → src/Store/ShareStore.php}
  14. +4 −1 core/src/plugins/action.share/{class.MinisiteRenderer.php → src/View/MinisiteRenderer.php}
  15. +1 −0 core/src/plugins/action.share/{class.PublicAccessManager.php → src/View/PublicAccessManager.php}
  16. +2 −2 core/src/plugins/core.ajaxplorer/routes.json
  17. +2 −2 core/src/plugins/core.notifications/class.AJXP_Notification.php
  18. +6 −3 core/src/plugins/core.ocs/src/Model/TargettedLink.php
  19. +1 −1 core/src/plugins/core.ocs/src/Server/Dav/AuthSharingBackend.php
  20. +1 −1 core/src/plugins/core.ocs/src/Server/Dav/Server.php
  21. +1 −1 core/src/plugins/meta.watch/manifest.xml
  22. +2 −2 core/src/proxy.php
  23. +1 −1 core/src/publicLet.inc.php
@@ -32,12 +32,7 @@
*/
class HomePagePlugin extends AbstractAccessDriver
{
-
- public function initRepository()
- {
- //require_once AJXP_INSTALL_PATH."/".AJXP_PLUGINS_FOLDER."/action.share/class.ShareCenter.php";
- }
-
+
public function parseSpecificContributions(&$contribNode){
parent::parseSpecificContributions($contribNode);
if($contribNode->nodeName == "client_configs"){
@@ -24,7 +24,6 @@
use DOMXPath;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
-use PublicletCounter;
use Pydio\Access\Core\AbstractAccessDriver;
use Pydio\Access\Core\Model\AJXP_Node;
use Pydio\Access\Core\Model\NodesList;
@@ -35,7 +34,7 @@
use Pydio\Core\Services\AuthService;
use Pydio\Core\Services\ConfService;
use Pydio\Core\PluginFramework\PluginsService;
-use ShareCenter;
+use Pydio\Share\ShareCenter;
use Zend\Diactoros\Response\EmptyResponse;
defined('AJXP_EXEC') or die( 'Access not allowed');
@@ -50,7 +49,7 @@ class UserDashboardDriver extends AbstractAccessDriver
public function initRepository()
{
- require_once AJXP_INSTALL_PATH."/".AJXP_PLUGINS_FOLDER."/action.share/class.ShareCenter.php";
+ require_once AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/action.share/vendor/autoload.php";
}
public function parseSpecificContributions(&$contribNode){
@@ -161,34 +160,7 @@ public function switchAction(ServerRequestInterface $requestInterface, ResponseI
}
$x->addChunk(new ReloadMessage());
break;
-
- case "clear_expired" :
-
- /**
- * @var ShareCenter $shareCenter
- */
- $shareCenter = PluginsService::getInstance()->findPluginById("action.share");
- $deleted = $shareCenter->getShareStore()->clearExpiredFiles(true);
- if (count($deleted)) {
- $x->addChunk(new UserMessage(sprintf($mess["user_dash.23"], count($deleted)."")));
- $x->addChunk(new ReloadMessage());
- } else {
- $x->addChunk(new UserMessage($mess["user_dash.24"]));
- }
-
- break;
-
- case "reset_download_counter" :
-
- $selection = new UserSelection();
- $selection->initFromHttpVars($httpVars);
- $elements = $selection->getFiles();
- foreach ($elements as $element) {
- PublicletCounter::reset(str_replace(".php", "", basename($element)));
- }
- $x->addChunk(new ReloadMessage());
- break;
-
+
default:
break;
}
@@ -52,7 +52,6 @@
use Pydio\Core\Utils\TextEncoder;
use Pydio\Tasks\Task;
use Pydio\Tasks\TaskService;
-use ShareCenter;
use Zend\Diactoros\Response;
use Zend\Diactoros\ServerRequestFactory;
@@ -2265,8 +2264,8 @@ public function recursivePurge($dirName, $hardPurgeTime, $softPurgeTime = 0)
{
$handle=opendir($dirName);
$shareCenter = false;
- if(class_exists("ShareCenter")){
- $shareCenter = ShareCenter::getShareCenter();
+ if(class_exists("\\Pydio\\Share\\ShareCenter")){
+ $shareCenter = \Pydio\Share\ShareCenter::getShareCenter();
}
if($handle === false){
$this->logError(__FUNCTION__, "Cannot open folder ".$dirName);
@@ -43,7 +43,7 @@ class PowerFSController extends Plugin
{
public function performChecks(){
- if(ShareCenter::currentContextIsLinkDownload()) {
+ if(class_exists("\\Pydio\\Share\\ShareCenter") && \Pydio\Share\ShareCenter::currentContextIsLinkDownload()) {
throw new Exception("Disable during link download");
}
}
@@ -367,7 +367,7 @@
<serverCallback methodName="forwardEventToShares" hookName="node.change" defer="true"/>
</hooks>
</registry_contributions>
- <class_definition filename="plugins/action.share/class.ShareCenter.php" classname="ShareCenter"/>
+ <class_definition filename="plugins/action.share/src/ShareCenter.php" classname="Pydio\Share\ShareCenter"/>
<dependencies>
<activePlugin pluginName="access.AJXP_STREAM_PROVIDER|access.ajxp_user|access.ajxp_conf|access.ajxp_admin"/>
</dependencies>
@@ -19,16 +19,26 @@
* The latest code can be found at <http://pyd.io/>.
*/
+namespace Pydio\Share\Legacy;
+
+use MetaWatchRegister;
use Pydio\Access\Core\AbstractAccessDriver;
+use Pydio\Access\Core\Filter\ContentFilter;
+use Pydio\Access\Core\Model\AJXP_Node;
use Pydio\Access\Core\Model\Repository;
-use Pydio\Auth\Core\AJXP_Safe;
+use Pydio\Access\Core\Model\UserSelection;
use Pydio\Core\Services\AuthService;
use Pydio\Core\Services\ConfService;
use Pydio\Core\Controller\Controller;
-use Pydio\Core\Controller\HTMLWriter;
use Pydio\Core\PluginFramework\PluginsService;
use Pydio\Core\Utils\TextEncoder;
use Pydio\Log\Core\AJXP_Logger;
+use Pydio\Share\Model\ShareLink;
+use Pydio\Share\ShareCenter;
+use Pydio\Share\Store\ShareRightsManager;
+use Pydio\Share\Store\ShareStore;
+use Pydio\Share\View\MinisiteRenderer;
+use Pydio\Share\View\PublicAccessManager;
defined('AJXP_EXEC') or die('Access not allowed');
@@ -37,7 +47,6 @@ class LegacyPubliclet
{
private static function renderError($data, $hash, $message = null){
- require_once("class.MinisiteRenderer.php");
MinisiteRenderer::renderError($data, $hash, $message);
}
@@ -238,7 +247,7 @@ public function writePubliclet(&$data, $accessDriver, $repository, $shareStore,
try{
$hash = $shareStore->storeShare($repository->getId(), $data, "publiclet");
- }catch(Exception $e){
+ }catch(\Exception $e){
return $e->getMessage();
}
@@ -268,7 +277,7 @@ public function writePubliclet(&$data, $accessDriver, $repository, $shareStore,
* @param PublicAccessManager $publicAccessManager
* @param MetaWatchRegister|null $watcher
* @return array|false
- * @throws Exception
+ * @throws \Exception
*/
public static function publicletToJson($shareId, $shareMeta, $shareStore, $publicAccessManager, $watcher, $node){
@@ -283,7 +292,7 @@ public static function publicletToJson($shareId, $shareMeta, $shareStore, $publi
if(isSet($pData[$key])) $shareMeta[$key] = $pData[$key];
}
if ($pData["OWNER_ID"] != AuthService::getLoggedUser()->getId() && !AuthService::getLoggedUser()->isAdmin()) {
- throw new Exception($messages["share_center.48"]);
+ throw new \Exception($messages["share_center.48"]);
}
if (isSet($shareMeta["short_form_url"])) {
$link = $shareMeta["short_form_url"];
@@ -305,12 +314,12 @@ public static function publicletToJson($shareId, $shareMeta, $shareStore, $publi
$jsonData = array_merge(array(
"element_id" => $shareId,
"publiclet_link" => $link,
- "download_counter" => $shareStore->getCurrentDownloadCounter($shareId),
+ "download_counter" => 0,
"download_limit" => $pData["DOWNLOAD_LIMIT"],
"expire_time" => ($pData["EXPIRE_TIME"]!=0?date($messages["date_format"], $pData["EXPIRE_TIME"]):0),
"has_password" => (!empty($pData["PASSWORD"])),
"element_watch" => $elementWatch,
- "is_expired" => $shareStore->isShareExpired($shareId, $pData)
+ "is_expired" => ShareLink::isShareExpired($pData)
), $shareMeta);
return $jsonData;
@@ -324,6 +333,8 @@ public static function publicletToJson($shareId, $shareMeta, $shareStore, $publi
public static function migrateLegacyMeta($shareCenter, $shareStore, $shareRightManager, $dryRun = true){
$metaStoreDir = AJXP_DATA_PATH."/plugins/metastore.serial";
$publicFolder = ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER");
+ // TODO 1: Check all metastores of all repositories?
+ // TODO 2: load $publicFolder/.ajxp_publiclet_counters.ser and reassign download counts
$metastores = glob($metaStoreDir."/ajxp_meta_0");
if($dryRun){
print("RUNNING A DRY RUN FOR META MIGRATION");
@@ -383,7 +394,7 @@ public static function migrateLegacyMeta($shareCenter, $shareStore, $shareRightM
$shareLink->save();
}
$meta["ajxp_shared"] = ["shares" => [$element => ["type" => "minisite"], $sharedRepoId => ["type" => "repository"]]];
- }catch(Exception $e){
+ }catch(\Exception $e){
print("\n-- Error ".$e->getMessage());
}
@@ -397,9 +408,15 @@ public static function migrateLegacyMeta($shareCenter, $shareStore, $shareRightM
if(isSet($publiclet["EXPIRE_TIME"])) $parameters["expiration"] = $publiclet["EXPIRE_TIME"];
if(isSet($publiclet["DOWNLOAD_LIMIT"])) $parameters["downloadlimit"] = $publiclet["DOWNLOAD_LIMIT"];
$link->parseHttpVars($parameters);
+ /**
+ * @var Repository $parentRepositoryObject
+ */
$parentRepositoryObject = $publiclet["REPOSITORY"];
- $driverInstance = AJXP_PluginsService::findPlugin("access", $parentRepositoryObject->getAccessType());
+ /**
+ * @var AbstractAccessDriver $driverInstance
+ */
+ $driverInstance = PluginsService::findPlugin("access", $parentRepositoryObject->getAccessType());
if(empty($driverInstance)){
print("\n-- ERROR: Cannot find driver instance!");
continue;
@@ -419,7 +436,7 @@ public static function migrateLegacyMeta($shareCenter, $shareStore, $shareRightM
}
$newRepo->setDescription("");
// Smells like dirty hack!
- $newRepo->options["PATH"] = SystemTextEncoding::fromStorageEncoding($newRepo->options["PATH"]);
+ $newRepo->options["PATH"] = TextEncoder::fromStorageEncoding($newRepo->options["PATH"]);
$newRepo->setContentFilter(new ContentFilter([new AJXP_Node("pydio://".$parentRepositoryObject->getId().$filePath)]));
if(!$dryRun){
@@ -452,7 +469,7 @@ public static function migrateLegacyMeta($shareCenter, $shareStore, $shareRightM
// UPDATE METADATA
$meta["ajxp_shared"] = ["shares" => [$element => array("type" => "minisite")]];
- }catch(Exception $e){
+ }catch(\Exception $e){
print("\n-- ERROR: ".$e->getMessage());
}
@@ -18,6 +18,8 @@
*
* The latest code can be found at <http://pyd.io/>.
*/
+namespace Pydio\Share\Legacy;
+
use Pydio\Core\Services\ConfService;
use Pydio\Core\Utils\Utils;
@@ -73,7 +75,7 @@ public static function delete($publiclet)
private static function isActive()
{
- return (is_dir(ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER")) && is_writable(ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER")));
+ return true; //(is_dir(ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER")) && is_writable(ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER")));
}
private static function loadCounters()
@@ -18,12 +18,16 @@
*
* The latest code can be found at <http://pyd.io/>.
*/
+namespace Pydio\Share\Model;
+
use Pydio\Access\Core\Model\AJXP_Node;
use Pydio\Access\Core\Model\Repository;
use Pydio\Core\Services\AuthService;
use Pydio\Core\Services\ConfService;
use Pydio\Core\Utils\Utils;
+use Pydio\Share\Store\ShareRightsManager;
+use Pydio\Share\View\PublicAccessManager;
defined('AJXP_EXEC') or die('Access not allowed');
@@ -108,7 +112,7 @@ public function isInvalid(){
}
/**
- * @param MetaWatchRegister|false $watcher
+ * @param \MetaWatchRegister|false $watcher
* @param ShareRightsManager $rightsManager
* @param PublicAccessManager $publicAccessManager
* @param array $messages
@@ -122,7 +126,7 @@ public function toJson($watcher, $rightsManager, $publicAccessManager, $messages
$elementWatch = $watcher->hasWatchOnNode(
$repoRootNode,
AuthService::getLoggedUser()->getId(),
- MetaWatchRegister::$META_WATCH_NAMESPACE
+ \MetaWatchRegister::$META_WATCH_NAMESPACE
);
}
$sharedEntries = $rightsManager->computeSharedRepositoryAccessRights($this->getRepositoryId(), true, $repoRootNode);
Oops, something went wrong.

0 comments on commit b3d35c8

Please sign in to comment.