Permalink
Browse files

Move Action plugins in dedicated namespaces

  • Loading branch information...
1 parent 74a5871 commit e64181a72dbe254bba9e9585ed49302c6d9fb7b4 @cdujeu cdujeu committed Jun 22, 2016
Showing with 619 additions and 399 deletions.
  1. +4 −0 core/src/core/src/pydio/Core/Http/Middleware/SessionRepositoryMiddleware.php
  2. +75 −39 core/src/plugins/action.antivirus/{class.AntivirusScanner.php → AntivirusScanner.php}
  3. +1 −1 core/src/plugins/action.antivirus/manifest.xml
  4. +5 −5 core/src/plugins/action.avatar/{class.AvatarProvider.php → AvatarProvider.php}
  5. +1 −1 core/src/plugins/action.avatar/manifest.xml
  6. +22 −10 core/src/plugins/action.cart/{class.CartManager.php → CartManager.php}
  7. +1 −1 core/src/plugins/action.cart/manifest.xml
  8. +21 −14 core/src/plugins/action.compression/{class.PluginCompression.php → PluginCompression.php}
  9. +1 −1 core/src/plugins/action.compression/manifest.xml
  10. +31 −18 core/src/plugins/action.disclaimer/{class.DisclaimerProvider.php → DisclaimerProvider.php}
  11. +1 −1 core/src/plugins/action.disclaimer/manifest.xml
  12. +37 −31 core/src/plugins/action.powerfs/{class.PowerFSController.php → PowerFSController.php}
  13. +1 −1 core/src/plugins/action.powerfs/manifest.xml
  14. +117 −99 core/src/plugins/action.scheduler/{class.AjxpScheduler.php → Scheduler.php}
  15. +1 −1 core/src/plugins/action.scheduler/manifest.xml
  16. +9 −7 core/src/plugins/action.skeleton/{class.PluginSkeleton.php → PluginSkeleton.php}
  17. +1 −1 core/src/plugins/action.skeleton/manifest.xml
  18. +34 −23 core/src/plugins/action.timestamp/{class.TimestampCreator.php → TimestampCreator.php}
  19. +1 −1 core/src/plugins/action.timestamp/manifest.xml
  20. +48 −36 core/src/plugins/action.updater/{class.UpdateController.php → UpdateController.php}
  21. +205 −107 core/src/plugins/action.updater/{class.AjaXplorerUpgrader.php → UpgradeManager.php}
  22. +1 −1 core/src/plugins/action.updater/manifest.xml
  23. +1 −0 core/src/plugins/authfront.session_login/SessionLoginFrontend.php
@@ -39,6 +39,10 @@
defined('AJXP_EXEC') or die('Access not allowed');
+/**
+ * Class SessionRepositoryMiddleware
+ * @package Pydio\Core\Http\Middleware
+ */
class SessionRepositoryMiddleware
{
/**
@@ -1,9 +1,39 @@
<?php
+/*
+ * Copyright 2007-2016 Charles du Jeu - Abstrium SAS <team (at) pyd.io>, Afterster
+ * This file is part of Pydio.
+ *
+ * Pydio is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pydio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with Pydio. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * The latest code can be found at <http://pyd.io/>.
+ */
+
+
+namespace Pydio\Action\Antivirus;
+
+use Exception;
use Pydio\Access\Core\Model\AJXP_Node;
use Pydio\Core\Utils\StatHelper;
use Pydio\Core\PluginFramework\Plugin;
-defined('AJXP_EXEC') or die( 'Access not allowed');
+defined('AJXP_EXEC') or die('Access not allowed');
+
+/**
+ * Class AntivirusScanner
+ * Use ClamAV to scan files
+ * @package Pydio\Action\Antivirus
+ */
class AntivirusScanner extends Plugin
{
const DEBUG_ON = 0;
@@ -21,43 +51,47 @@ class AntivirusScanner extends Plugin
* @param \Pydio\Access\Core\Model\AJXP_Node $newNode
* Main function, it is called by the hook.
*/
- public function scanFile ($oldNode = null, $newNode = null)
+ public function scanFile($oldNode = null, $newNode = null)
{
- if ($oldNode!=null || $newNode == null) {
+ if ($oldNode != null || $newNode == null) {
return;
}
// ADD THOSE TWO LINES
$newNode->loadNodeInfo();
- if(!$newNode->isLeaf()) return;
+ if (!$newNode->isLeaf()) return;
- $this->callSet($newNode); //initializes attributes
+ $this->callSet($newNode); //initializes attributes
// This block scans or doesn't scan the file. This is based on plugin parameters
$trace = $this->getContextualOption($newNode->getContext(), "TRACE");
if ($this->file_size < $this->scan_max_size) {
if ($this->scan_all == true) {
- if ($this->inList()==true) {
- if ($trace === false) {return;}
+ if ($this->inList() == true) {
+ if ($trace === false) {
+ return;
+ }
$this->scanLater();
- return ;
+ return;
} else {
$this->scanNow($newNode);
- return ;
+ return;
}
} else {
- if ($this->inList()==true) {
+ if ($this->inList() == true) {
$this->scanNow($newNode);
- return ;
+ return;
} else {
- if ($trace === false) {return;}
+ if ($trace === false) {
+ return;
+ }
$this->scanLater();
- return ;
+ return;
}
}
} else {
$this->scanLater();
- return ;
+ return;
}
}
@@ -71,7 +105,7 @@ private function inList()
$leng_ext = strlen($this->file_extension);
$result = substr($this->extension_scan, $start_pos);
$result = substr($result, $leng_ext, 1);
- if (preg_match("/[A-Za-z0-9]+/",$result)) {
+ if (preg_match("/[A-Za-z0-9]+/", $result)) {
$this->extension_scan = substr($this->extension_scan, $start_pos + $leng_ext);
} else {
return true;
@@ -91,7 +125,7 @@ private function scanNow($nodeObject)
ob_start();
passthru($command, $int);
- $output=ob_get_contents();
+ $output = ob_get_contents();
ob_end_clean();
if ($int != 0) {
@@ -100,7 +134,7 @@ private function scanNow($nodeObject)
} else {
$filename = strrchr($this->path, DIRECTORY_SEPARATOR);
$filename = substr($filename, 1);
- echo 'Virus has been found in : ' . $filename . ' File removed';
+ echo 'Virus has been found in : ' . $filename . ' File removed';
}
}
return;
@@ -111,21 +145,21 @@ private function scanNow($nodeObject)
*/
private function scanLater()
{
- $numero=0;
- $scanned=false;
+ $numero = 0;
+ $scanned = false;
if (is_dir($this->scan_diff_folder) == false) {
$create_folder = mkdir($this->scan_diff_folder, 0755);
if ($create_folder == false) {
throw new Exception("can-t create scan_diff_folder, check permission");
}
}
while ($scanned == false) {
- if (file_exists( $this->scan_diff_folder .DIRECTORY_SEPARATOR. 'file_' . $numero)) {
+ if (file_exists($this->scan_diff_folder . DIRECTORY_SEPARATOR . 'file_' . $numero)) {
$numero++;
} else {
- $command = 'echo "'. '\"' . $this->path . '\"' . '" >' . $this->scan_diff_folder .DIRECTORY_SEPARATOR. 'file_' . $numero;
+ $command = 'echo "' . '\"' . $this->path . '\"' . '" >' . $this->scan_diff_folder . DIRECTORY_SEPARATOR . 'file_' . $numero;
passthru($command);
- $scanned=true;
+ $scanned = true;
return;
}
}
@@ -149,7 +183,7 @@ private function callSet($nodeObject)
$debug = 'echo "' . $this->path . " " . $this->file_extension . " " . $this->extension_scan . " " . $this->scan_all . " " . $this->scan_diff_folder . " " . $this->scan_max_size . " " . $this->file_size . '" >> plugins/action.antivirus/debug';
passthru($debug);
}
- return ;
+ return;
}
/**
@@ -160,23 +194,25 @@ public function setPath($nodeObject)
{
$realpath = $nodeObject->getRealFile();
$realpath = realpath($realpath);
- $this->path= $realpath;
- return ;
+ $this->path = $realpath;
+ return;
}
/**
* This function initializes the file extension
* @param AJXP_Node $nodeObject
*/
- public function setFileExtension ($nodeObject)
+ public function setFileExtension($nodeObject)
{
$realpath = $nodeObject->getRealFile();
$realpath = realpath($realpath);
- $realpath = str_replace(" ", "_",$realpath );
+ $realpath = str_replace(" ", "_", $realpath);
$realpath = strrchr($realpath, DIRECTORY_SEPARATOR);
- $this->file_extension=strrchr($realpath, '.');
- if ($this->file_extension == ( "") ) {$this->file_extension = ".no_ext";}
- return ;
+ $this->file_extension = strrchr($realpath, '.');
+ if ($this->file_extension == ("")) {
+ $this->file_extension = ".no_ext";
+ }
+ return;
}
/**
@@ -185,8 +221,8 @@ public function setFileExtension ($nodeObject)
*/
public function setExtensionScan($nodeObject)
{
- $this->extension_scan = $this->getContextualOption($nodeObject->getContext(), "EXT");
- return ;
+ $this->extension_scan = $this->getContextualOption($nodeObject->getContext(), "EXT");
+ return;
}
/**
@@ -201,39 +237,39 @@ public function setScanAll($nodeObject)
} else {
$this->scan_all = false;
}
- return ;
+ return;
}
/**
* this function initializes the trace folder
* @param AJXP_Node $nodeObject
*/
- public function setScanDiffFolder ($nodeObject)
+ public function setScanDiffFolder($nodeObject)
{
$this->scan_diff_folder = $this->getContextualOption($nodeObject->getContext(), "PATH");
- return ;
+ return;
}
/**
* this function initializes max size of the scanned file
* @param AJXP_Node $nodeObject
*/
- public function setScanMaxSize ($nodeObject)
+ public function setScanMaxSize($nodeObject)
{
$this->scan_max_size = StatHelper::convertBytes($this->getContextualOption($nodeObject->getContext(), "SIZE"));
- return ;
+ return;
}
/**
* This function initializes the size of the file
* @param \Pydio\Access\Core\Model\AJXP_Node $nodeObject
*/
- public function setFileSize ($nodeObject)
+ public function setFileSize($nodeObject)
{
$realpath = $nodeObject->getRealFile();
$realpath = realpath($realpath);
$this->file_size = filesize($realpath);
- return ;
+ return;
}
}
@@ -2,7 +2,7 @@
<ajxp_plugin enabled="false" id="antivirus" label="CONF_MESSAGE[Antivirus]" description="CONF_MESSAGE[antivirus plugin adaptor]" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd">
<!-- class file -->
- <class_definition filename="plugins/action.antivirus/class.AntivirusScanner.php" classname="AntivirusScanner"/>
+ <class_definition filename="plugins/action.antivirus/AntivirusScanner.php" classname="Pydio\Action\Antivirus\AntivirusScanner"/>
<!-- plugin information -->
<plugin_info>
@@ -20,16 +20,16 @@
*/
+namespace Pydio\Action\Avatar;
+
use Pydio\Core\Services\ConfService;
use Pydio\Core\PluginFramework\Plugin;
use Pydio\Core\Services\UsersService;
-defined('AJXP_EXEC') or die( 'Access not allowed');
+defined('AJXP_EXEC') or die('Access not allowed');
/**
* Simple implementation of Avatar for Gravatar / Libravatar
- * @package AjaXplorer_Plugins
- * @subpackage Avatar
*/
class AvatarProvider extends Plugin
{
@@ -55,7 +55,7 @@ public function receiveAction(\Psr\Http\Message\ServerRequestInterface &$request
$url = "http://www.gravatar.com";
}
$url .= "/avatar/";
- $suffix .= "?s=80&r=g&d=".$type;
+ $suffix .= "?s=80&r=g&d=" . $type;
break;
case "libravatar":
// Federated Servers are not supported here without libravatar.org. Should query DNS server first.
@@ -65,7 +65,7 @@ public function receiveAction(\Psr\Http\Message\ServerRequestInterface &$request
$url = "http://cdn.libravatar.org";
}
$url .= "/avatar/";
- $suffix = "?s=80&d=".$type;
+ $suffix = "?s=80&d=" . $type;
break;
}
@@ -23,5 +23,5 @@
</action>
</actions>
</registry_contributions>
- <class_definition filename="plugins/action.avatar/class.AvatarProvider.php" classname="AvatarProvider"/>
+ <class_definition filename="plugins/action.avatar/AvatarProvider.php" classname="Pydio\Action\Avatar\AvatarProvider"/>
</ajxp_plugin>
@@ -19,42 +19,54 @@
* The latest code can be found at <http://pyd.io/>.
*/
+namespace Pydio\Action\Cart;
+
use Pydio\Core\Controller\Controller;
use Pydio\Core\PluginFramework\Plugin;
use Pydio\Core\PluginFramework\PluginsService;
+/**
+ * Class CartManager
+ * @package Pydio\Action\Cart
+ */
class CartManager extends Plugin
{
- public function switchAction (\Psr\Http\Message\ServerRequestInterface &$requestInterface, \Psr\Http\Message\ResponseInterface &$responseInterface)
+ /**
+ * @param \Psr\Http\Message\ServerRequestInterface $requestInterface
+ * @param \Psr\Http\Message\ResponseInterface $responseInterface
+ * @throws \Pydio\Core\Exception\ActionNotFoundException
+ * @throws \Pydio\Core\Exception\AuthRequiredException
+ */
+ public function switchAction(\Psr\Http\Message\ServerRequestInterface &$requestInterface, \Psr\Http\Message\ResponseInterface &$responseInterface)
{
- if($requestInterface->getAttribute("action") != "search-cart-download"){
+ if ($requestInterface->getAttribute("action") != "search-cart-download") {
return;
}
// Pipe SEARCH + DOWNLOAD actions.
$ctx = $requestInterface->getAttribute("ctx");
$indexer = PluginsService::getInstance($ctx)->getUniqueActivePluginForType("index");
- if($indexer == false) return;
+ if ($indexer == false) return;
$httpVars = $requestInterface->getParsedBody();
unset($httpVars["get_action"]);
$requestInterface = $requestInterface->withAttribute("action", "search")->withParsedBody($httpVars);
$response = Controller::run($requestInterface);
$body = $response->getBody();
- if($body instanceof \Pydio\Core\Http\Response\SerializableResponseStream){
+ if ($body instanceof \Pydio\Core\Http\Response\SerializableResponseStream) {
$chunks = $body->getChunks();
- foreach($chunks as $chunk){
- if($chunk instanceof \Pydio\Access\Core\Model\NodesList){
+ foreach ($chunks as $chunk) {
+ if ($chunk instanceof \Pydio\Access\Core\Model\NodesList) {
$res = $chunk->getChildren();
}
}
}
-
+
if (isSet($res) && is_array($res)) {
$newHttpVars = array(
- "selection_nodes" => $res,
- "dir" => "__AJXP_ZIP_FLAT__/",
- "archive_name" => $httpVars["archive_name"]
+ "selection_nodes" => $res,
+ "dir" => "__AJXP_ZIP_FLAT__/",
+ "archive_name" => $httpVars["archive_name"]
);
$requestInterface = $requestInterface->withAttribute("action", "download")->withParsedBody($newHttpVars);
$responseInterface = Controller::run($requestInterface);
@@ -290,5 +290,5 @@
</actions>
</registry_contributions>
- <class_definition classname="CartManager" filename="plugins/action.cart/class.CartManager.php"/>
+ <class_definition classname="Pydio\Action\Cart\CartManager" filename="plugins/action.cart/CartManager.php"/>
</ajxp_plugin>
Oops, something went wrong.

0 comments on commit e64181a

Please sign in to comment.