From 2c6b444ae35d04545c172440c5909c41fc845a8c Mon Sep 17 00:00:00 2001 From: cdujeu Date: Wed, 21 Oct 2015 15:43:24 +0200 Subject: [PATCH] Code Inspection --- core/src/core/classes/class.AJXP_Cache.php | 4 +- .../core/classes/class.AJXP_Controller.php | 9 ++- core/src/core/classes/class.AJXP_JSPacker.php | 4 +- core/src/core/classes/class.AJXP_Node.php | 2 +- core/src/core/classes/class.AJXP_Plugin.php | 5 +- .../classes/class.AJXP_PluginsService.php | 21 +++++-- .../classes/class.AJXP_ProgressBarCLI.php | 1 + core/src/core/classes/class.AJXP_Role.php | 2 +- core/src/core/classes/class.AJXP_Utils.php | 59 +++++++------------ .../src/core/classes/class.AJXP_XMLWriter.php | 22 ++++--- core/src/core/classes/class.AbstractTest.php | 9 ++- core/src/core/classes/class.AuthService.php | 16 +++-- core/src/core/classes/class.ConfService.php | 32 +++++----- core/src/core/classes/class.ContentFilter.php | 2 +- core/src/core/classes/class.HTMLWriter.php | 5 +- core/src/core/classes/class.HttpClient.php | 11 +++- .../core/classes/class.PydioSdkGenerator.php | 5 +- core/src/core/classes/class.Repository.php | 3 + core/src/core/classes/class.UnixProcess.php | 4 +- core/src/core/classes/class.UserSelection.php | 3 + .../core/classes/securimage/securimage.php | 6 +- .../boot.conf/class.BootConfLoader.php | 6 +- .../conf.serial/class.serialConfDriver.php | 3 +- .../core.conf/class.AbstractAjxpUser.php | 15 +++++ .../core.conf/class.AbstractConfDriver.php | 8 +-- 25 files changed, 153 insertions(+), 104 deletions(-) diff --git a/core/src/core/classes/class.AJXP_Cache.php b/core/src/core/classes/class.AJXP_Cache.php index cf59ce01fd..1a26b54cef 100644 --- a/core/src/core/classes/class.AJXP_Cache.php +++ b/core/src/core/classes/class.AJXP_Cache.php @@ -27,8 +27,6 @@ */ class AJXP_Cache { - private static $instance; - protected $cacheDir; protected $cacheId; protected $masterFile; @@ -39,7 +37,7 @@ class AJXP_Cache * Create an AJXP_Cache instance * @param string $pluginId * @param string $filepath - * @param Function $dataCallback A function to generate the data cache. If no callback provided, will simply use the content of the master item as the cache data + * @param callable $dataCallback A function to generate the data cache. If no callback provided, will simply use the content of the master item as the cache data * @param string $idComputerCallback A function to generate the ID of the cache. If not provided, will generate a random hash * @return AJXP_Cache */ diff --git a/core/src/core/classes/class.AJXP_Controller.php b/core/src/core/classes/class.AJXP_Controller.php index 6f7d5bb77d..e667e0f903 100644 --- a/core/src/core/classes/class.AJXP_Controller.php +++ b/core/src/core/classes/class.AJXP_Controller.php @@ -344,6 +344,7 @@ public static function runCommandInBackground($cmd, $logFile) file_put_contents($tmpBat, $cmd); pclose(popen('start /b "CLI" "'.$tmpBat.'"', 'r')); } + return null; } else { $process = new UnixProcess($cmd, (AJXP_SERVER_DEBUG?$logFile:null)); AJXP_Logger::debug("Starting process and sending output dev null"); @@ -361,7 +362,7 @@ public static function runCommandInBackground($cmd, $logFile) * @param array $httpVars * @param array $fileVars * @param bool $multiple - * @return DOMElement|bool + * @return DOMElement|bool|DOMElement[] */ private static function getCallbackNode($xPath, $actionNode, $query ,$actionName, $httpVars, $fileVars, $multiple = true) { @@ -387,7 +388,7 @@ private static function getCallbackNode($xPath, $actionNode, $query ,$actionName * Check in the callback node if an applyCondition XML attribute exists, and eval its content. * The content must set an $apply boolean as result * @static - * @param DOMElement $callback + * @param DOMElement|DOMNode $callback * @param string $actionName * @param array $httpVars * @param array $fileVars @@ -441,6 +442,7 @@ private static function applyCallback($callback, &$actionName, &$httpVars, &$fil } else { throw new AJXP_Exception("Cannot find method $methodName for plugin $plugId!"); } + return null; } /** @@ -471,6 +473,9 @@ public static function applyHook($hookName, $args, $forceNonDefer = false) $callbacks = $xPath->query("hooks/serverCallback[@hookName='$hookName']"); if(!$callbacks->length) return ; self::$hooksCache[$hookName] = array(); + /** + * @var $callback DOMElement + */ foreach ($callbacks as $callback) { $defer = ($callback->getAttribute("defer") === "true"); $applyCondition = $callback->getAttribute("applyCondition"); diff --git a/core/src/core/classes/class.AJXP_JSPacker.php b/core/src/core/classes/class.AJXP_JSPacker.php index f9cc06bfbf..86637e6a17 100644 --- a/core/src/core/classes/class.AJXP_JSPacker.php +++ b/core/src/core/classes/class.AJXP_JSPacker.php @@ -31,10 +31,10 @@ class AJXP_JSPacker * Static function for packing all js and css into big files * Auto detect /js/*_list.txt files and /css/*_list.txt files and pack them. */ - public function pack() + public static function pack() { // Make sure that the gui.* plugin is loaded - $plug = AJXP_PluginsService::getInstance()->getPluginsByType("gui"); + AJXP_PluginsService::getInstance()->getPluginsByType("gui"); $sList = glob(CLIENT_RESOURCES_FOLDER."/js/*_list.txt"); foreach ($sList as $list) { diff --git a/core/src/core/classes/class.AJXP_Node.php b/core/src/core/classes/class.AJXP_Node.php index 45a3ca5703..2d84ae76d4 100644 --- a/core/src/core/classes/class.AJXP_Node.php +++ b/core/src/core/classes/class.AJXP_Node.php @@ -533,7 +533,7 @@ public function __get($varName) * Magic setter for metadata * @param $metaName * @param $metaValue - * @return + * @return void */ public function __set($metaName, $metaValue) { diff --git a/core/src/core/classes/class.AJXP_Plugin.php b/core/src/core/classes/class.AJXP_Plugin.php index 6bd86e32d8..164f78caba 100644 --- a/core/src/core/classes/class.AJXP_Plugin.php +++ b/core/src/core/classes/class.AJXP_Plugin.php @@ -210,7 +210,7 @@ public function isEnabled() /** * Main function for loading all the nodes under registry_contributions. - * @return void + * @param bool $dry */ protected function loadRegistryContributions($dry = false) { @@ -265,7 +265,7 @@ protected function loadRegistryContributions($dry = false) * @param string $xmlFile Path to the file from the base install path * @param array $include XPath query for XML Nodes to include * @param array $exclude XPath query for XML Nodes to exclude from the included ones. - * @return + * @param bool $dry Dry-run of the inclusion */ protected function initXmlContributionFile($xmlFile, $include=array("*"), $exclude=array(), $dry = false) { @@ -310,6 +310,7 @@ protected function initXmlContributionFile($xmlFile, $include=array("*"), $exclu } if(!count($selected)) return; $originalRegContrib = $this->xPath->query("registry_contributions")->item(0); + $localRegParent = null; foreach ($selected as $parentNodeName => $data) { $node = $data["parent"]->cloneNode(false); //$newNode = $originalRegContrib->ownerDocument->importNode($node, false); diff --git a/core/src/core/classes/class.AJXP_PluginsService.php b/core/src/core/classes/class.AJXP_PluginsService.php index d3121ee56c..bea7cc5318 100644 --- a/core/src/core/classes/class.AJXP_PluginsService.php +++ b/core/src/core/classes/class.AJXP_PluginsService.php @@ -216,6 +216,9 @@ public function softLoad($pluginId, $pluginOptions) // Try to get from cache list($type, $name) = explode(".", $pluginId); if(!empty($this->registry) && isSet($this->registry[$type][$name])) { + /** + * @var AJXP_Plugin $plugin + */ $plugin = $this->registry[$type][$name]; $plugin->init($pluginOptions); return clone $plugin; @@ -243,6 +246,9 @@ private function instanciatePluginClass($plugin) $filename = AJXP_INSTALL_PATH."/".$definition["filename"]; $className = $definition["classname"]; if (is_file($filename)) { + /** + * @var AJXP_Plugin $newPlugin + */ require_once($filename); $newPlugin = new $className($plugin->getId(), $plugin->getBaseDir()); $newPlugin->loadManifest(); @@ -252,10 +258,10 @@ private function instanciatePluginClass($plugin) return $plugin; } } + /** * Check that a plugin dependencies are loaded, disable it otherwise. - * @param $arrayToSort - * @return + * @param AJXP_Plugin[] $arrayToSort */ private function checkDependencies(&$arrayToSort) { @@ -306,7 +312,6 @@ public static function sortByDependencyIds($pluginIdA, $pluginIdB) public function getOrderByDependency($plugins, $withStatus = true) { - $orders = array(); $keys = array(); $unkowns = array(); if ($withStatus) { @@ -397,6 +402,9 @@ public function removePluginById($pluginId) */ public function initActivePlugins() { + /** + * @var AJXP_Plugin $pObject + */ $detected = $this->getDetectedPlugins(); $toActivate = array(); foreach ($detected as $pType => $pObjects) { @@ -631,11 +639,12 @@ public static function getXmlRegistry($extendedVersion = true) } return $self->xmlRegistry; } + /** * Replace the current xml registry * @static * @param $registry - * @return void + * @param bool $extendedVersion */ public static function updateXmlRegistry($registry, $extendedVersion = true) { @@ -677,6 +686,8 @@ public function patchPluginWithMixin(&$plugin, &$manifestDoc, $mixinName) * @param string $query * @param string $stringOrNodeFormat * @param boolean $limitToActivePlugins Whether to search only in active plugins or in all plugins + * @param bool $limitToEnabledPlugins + * @param bool $loadExternalFiles * @return DOMNode[] */ public static function searchAllManifests($query, $stringOrNodeFormat = "string", $limitToActivePlugins = false, $limitToEnabledPlugins = false, $loadExternalFiles = false) @@ -756,11 +767,11 @@ protected function mergeNodes(&$original, $parentName, $uuidAttr, $childrenNodes } } } + /** * Utilitary function * @param $new * @param $old - * @return */ protected function mergeChildByTagName($new, &$old) { diff --git a/core/src/core/classes/class.AJXP_ProgressBarCLI.php b/core/src/core/classes/class.AJXP_ProgressBarCLI.php index 38522a5407..0ab0eed03b 100644 --- a/core/src/core/classes/class.AJXP_ProgressBarCLI.php +++ b/core/src/core/classes/class.AJXP_ProgressBarCLI.php @@ -154,6 +154,7 @@ public function ago($time) { $remain=$remain%3600; $mins=intval($remain/60); $secs=$remain%60; + $timestring = "-"; if ($secs>=0) $timestring = "0m".$secs."s"; if ($mins>0) $timestring = $mins."m".$secs."s"; diff --git a/core/src/core/classes/class.AJXP_Role.php b/core/src/core/classes/class.AJXP_Role.php index ef1b97b1ef..4c59be22d5 100644 --- a/core/src/core/classes/class.AJXP_Role.php +++ b/core/src/core/classes/class.AJXP_Role.php @@ -491,7 +491,7 @@ public function array_merge_recursive2($array1, $array2) if (!is_array($arrays[$i])) { // also array_merge_recursive returns nothing in this case trigger_error('Argument #' . ($i+1) . ' is not an array - trying to merge array with scalar! Returning null!', E_USER_WARNING); - return; + return null; } } diff --git a/core/src/core/classes/class.AJXP_Utils.php b/core/src/core/classes/class.AJXP_Utils.php index ed21819745..deff7325be 100644 --- a/core/src/core/classes/class.AJXP_Utils.php +++ b/core/src/core/classes/class.AJXP_Utils.php @@ -77,7 +77,7 @@ public static function natksort(&$array) */ public static function natkrsort(&$array) { - natksort($array); + AJXP_Utils::natksort($array); $array = array_reverse($array, TRUE); return true; } @@ -610,6 +610,7 @@ public static function getImageMimeType($fileName) } else if (preg_match("/\.gif$/i", $fileName)) { return "image/gif"; } + return ""; } /** * Headers to send when streaming @@ -1047,7 +1048,9 @@ public function prettyPrintJSON($json) public static function extractConfStringsFromManifests() { $plugins = AJXP_PluginsService::getInstance()->getDetectedPlugins(); - $plug = new AJXP_Plugin("", ""); + /** + * @var AJXP_Plugin $plug + */ foreach ($plugins as $pType => $plugs) { foreach ($plugs as $plug) { $lib = $plug->getManifestRawContent("//i18n", "nodes"); @@ -1110,7 +1113,6 @@ public static function updateAllI18nLibraries($createLanguage = "") * @param $baseDir * @param bool $detectLanguages * @param string $createLanguage - * @return */ public static function updateI18nFiles($baseDir, $detectLanguages = true, $createLanguage = "") { @@ -1128,6 +1130,7 @@ public static function updateI18nFiles($baseDir, $detectLanguages = true, $creat $filenames = glob($baseDir . "/*.php"); } + $mess = array(); include($baseDir . "/en.php"); $reference = $mess; @@ -1141,11 +1144,11 @@ public static function updateI18nFiles($baseDir, $detectLanguages = true, $creat * @static * @param $filename * @param $reference - * @return */ public static function updateI18nFromRef($filename, $reference) { if (!is_file($filename)) return; + $mess = array(); include($filename); $missing = array(); foreach ($reference as $messKey => $message) { @@ -1253,6 +1256,7 @@ public static function runTests(&$outputArray, &$testedParams) } // PREPARE REPOSITORY LISTS $repoList = array(); + $REPOSITORIES = array(); require_once("../classes/class.ConfService.php"); require_once("../classes/class.Repository.php"); include(AJXP_CONF_PATH . "/bootstrap_repositories.php"); @@ -1330,6 +1334,7 @@ public static function isStream($path) * * @param String $filePath Full path to the file * @param Boolean $skipCheck do not test for file existence before opening + * @param string $format * @return Array */ public static function loadSerialFile($filePath, $skipCheck = false, $format="ser") @@ -1359,11 +1364,15 @@ public static function loadSerialFile($filePath, $skipCheck = false, $format="se * @param Array|Object $value The value to store * @param Boolean $createDir Whether to create the parent folder or not, if it does not exist. * @param bool $silent Silently write the file, are throw an exception on problem. - * @param string $format + * @param string $format "ser" or "json" + * @param bool $jsonPrettyPrint If json, use pretty printing * @throws Exception */ public static function saveSerialFile($filePath, $value, $createDir = true, $silent = false, $format="ser", $jsonPrettyPrint = false) { + if(!in_array($format, array("ser", "json"))){ + throw new Exception("Unsupported serialization format: ".$format); + } $filePath = AJXP_VarsFilter::filter($filePath); if ($createDir && !is_dir(dirname($filePath))) { @mkdir(dirname($filePath), 0755, true); @@ -1375,8 +1384,9 @@ public static function saveSerialFile($filePath, $value, $createDir = true, $sil } try { $fp = fopen($filePath, "w"); - if($format == "ser") $content = serialize($value); - else if ($format == "json") { + if($format == "ser") { + $content = serialize($value); + } else { $content = json_encode($value); if($jsonPrettyPrint) $content = self::prettyPrintJSON($content); } @@ -1395,8 +1405,6 @@ public static function saveSerialFile($filePath, $value, $createDir = true, $sil */ public static function userAgentIsMobile() { - $isMobile = false; - $op = strtolower($_SERVER['HTTP_X_OPERAMINI_PHONE'] OR ""); $ua = strtolower($_SERVER['HTTP_USER_AGENT']); $ac = strtolower($_SERVER['HTTP_ACCEPT']); @@ -1445,34 +1453,6 @@ public static function userAgentIsMobile() || strpos($ua, 'vodafone/') !== false || strpos($ua, 'wap1.') !== false || strpos($ua, 'wap2.') !== false; - /* - $isBot = false; - $ip = $_SERVER['REMOTE_ADDR']; - - $isBot = $ip == '66.249.65.39' - || strpos($ua, 'googlebot') !== false - || strpos($ua, 'mediapartners') !== false - || strpos($ua, 'yahooysmcm') !== false - || strpos($ua, 'baiduspider') !== false - || strpos($ua, 'msnbot') !== false - || strpos($ua, 'slurp') !== false - || strpos($ua, 'ask') !== false - || strpos($ua, 'teoma') !== false - || strpos($ua, 'spider') !== false - || strpos($ua, 'heritrix') !== false - || strpos($ua, 'attentio') !== false - || strpos($ua, 'twiceler') !== false - || strpos($ua, 'irlbot') !== false - || strpos($ua, 'fast crawler') !== false - || strpos($ua, 'fastmobilecrawl') !== false - || strpos($ua, 'jumpbot') !== false - || strpos($ua, 'googlebot-mobile') !== false - || strpos($ua, 'yahooseeker') !== false - || strpos($ua, 'motionbot') !== false - || strpos($ua, 'mediobot') !== false - || strpos($ua, 'chtml generic') !== false - || strpos($ua, 'nokia6230i/. fast crawler') !== false; - */ return $isMobile; } /** @@ -1756,6 +1736,7 @@ public static function parseStandardFormParameters(&$repDef, &$options, $userId } // DO SOMETHING WITH REPLICATED PARAMETERS? if (count($switchesGroups)) { + $gValues = array(); foreach ($switchesGroups as $fieldName => $groupName) { if (isSet($options[$fieldName])) { $gValues = array(); @@ -2082,11 +2063,11 @@ public static function regexpToLdap($regexp) } return $left.$regexp.$right; } + /** * Hide file or folder for Windows OS * @static - * @param $path - * @return void + * @param $file */ public static function winSetHidden($file) { diff --git a/core/src/core/classes/class.AJXP_XMLWriter.php b/core/src/core/classes/class.AJXP_XMLWriter.php index e32bbee4ae..b554871097 100644 --- a/core/src/core/classes/class.AJXP_XMLWriter.php +++ b/core/src/core/classes/class.AJXP_XMLWriter.php @@ -85,7 +85,7 @@ public static function write($data, $print) * @param integer $currentPage * @param integer $totalPages * @param integer $dirsCount - * @return void + * @param null $remoteSortAttributes */ public static function renderPaginationData($count, $currentPage, $totalPages, $dirsCount = -1, $remoteSortAttributes = null) { @@ -218,6 +218,7 @@ public static function renderNodeArray($array) { self::renderNode($array[0],$array[1],$array[2],$array[3]); } + /** * Error Catcher for PHP errors. Depending on the SERVER_DEBUG config * shows the file/line info or not. @@ -227,7 +228,6 @@ public static function renderNodeArray($array) * @param $fichier * @param $ligne * @param $context - * @return */ public static function catchError($code, $message, $fichier, $ligne, $context) { @@ -235,7 +235,6 @@ public static function catchError($code, $message, $fichier, $ligne, $context) return ; } AJXP_Logger::error(basename($fichier), "error l.$ligne", array("message" => $message)); - $loggedUser = AuthService::getLoggedUser(); if (ConfService::getConf("SERVER_DEBUG")) { $stack = debug_backtrace(); $stackLen = count($stack); @@ -371,13 +370,15 @@ public static function reloadDataNode($nodePath="", $pendingSelection="", $print /** * Send a XML instruction for refreshing the list * @static - * @param string $nodePath - * @param string $pendingSelection + * @param $diffNodes * @param bool $print * @return string */ public static function writeNodesDiff($diffNodes, $print = false) { + /** + * @var $ajxpNode AJXP_Node + */ $mess = ConfService::getMessages(); $buffer = ""; if (isSet($diffNodes["REMOVE"]) && count($diffNodes["REMOVE"])) { @@ -482,6 +483,7 @@ public static function triggerBgJSAction($jsCode, $messageId, $print=true, $dela */ public static function writeBookmarks($allBookmarks, $print = true, $format = "legacy") { + $driver = false; if ($format == "node_list") { $driver = ConfService::loadRepositoryDriver(); if (!is_a($driver, "AjxpWrapperProvider")) { @@ -509,8 +511,12 @@ public static function writeBookmarks($allBookmarks, $print = true, $format = "l $buffer .= ""; } } - if($print) print $buffer; - else return $buffer; + if($print) { + print $buffer; + return null; + } else { + return $buffer; + } } /** * Utilitary for generating a tag for the FilesList component @@ -534,8 +540,6 @@ public static function sendFilesListComponentConfig($config) */ public static function sendMessage($logMessage, $errorMessage, $print = true) { - $messageType = ""; - $message = ""; if ($errorMessage == null) { $messageType = "SUCCESS"; $message = AJXP_Utils::xmlContentEntities($logMessage); diff --git a/core/src/core/classes/class.AbstractTest.php b/core/src/core/classes/class.AbstractTest.php index da6b56cdff..d248508d0b 100644 --- a/core/src/core/classes/class.AbstractTest.php +++ b/core/src/core/classes/class.AbstractTest.php @@ -82,11 +82,16 @@ public function returnBytes($val) switch ($last) { // Le modifieur 'G' est disponible depuis PHP 5.1.0 case 'g': - $val *= 1024; + $val *= 1024 * 1024 * 1024; + break; case 'm': - $val *= 1024; + $val *= 1024 * 1024; + break; case 'k': $val *= 1024; + break; + default: + break; } return $val; diff --git a/core/src/core/classes/class.AuthService.php b/core/src/core/classes/class.AuthService.php index b432e52e80..acab0a8451 100644 --- a/core/src/core/classes/class.AuthService.php +++ b/core/src/core/classes/class.AuthService.php @@ -135,6 +135,9 @@ public static function preLogUser($httpVars) $frontends = AJXP_PluginsService::getInstance()->getActivePluginsForType("authfront"); $index = 0; + /** + * @var AbstractAuthFrontend $frontendPlugin + */ foreach($frontends as $frontendPlugin){ if(!$frontendPlugin->isEnabled()) continue; $res = $frontendPlugin->tryToLogUser($httpVars, ($index == count($frontends)-1)); @@ -550,8 +553,8 @@ public static function bootSequence(&$START_PARAMETERS) } $userObject->save("superuser"); $START_PARAMETERS["ALERT"] .= "Warning! User 'admin' was created with the initial password '". INITIAL_ADMIN_PASSWORD ."'. \\nPlease log in as admin and change the password now!"; + self::updateUser($userObject); } - self::updateUser($userObject); } else if ($adminCount == -1) { // Here we may come from a previous version! Check the "admin" user and set its right as admin. $confStorage = ConfService::getConfStorageImpl(); @@ -981,6 +984,9 @@ public static function listUsers($baseGroup = "/", $regexp = null, $offset = -1, $baseGroup = self::filterBaseGroup($baseGroup); $authDriver = ConfService::getAuthDriverImpl(); $confDriver = ConfService::getConfStorageImpl(); + /** + * @var $allUsers AbstractAjxpUser[] + */ $allUsers = array(); $paginated = false; if (($regexp != null || $offset != -1 || $limit != -1) && $authDriver->supportsUsersPagination()) { @@ -1035,6 +1041,7 @@ public static function listUsers($baseGroup = "/", $regexp = null, $offset = -1, * @param $baseGroup * @param $userLogin * @param $usersPerPage + * @param int $offset * @return int */ public static function findUserPage($baseGroup, $userLogin, $usersPerPage, $offset = 0){ @@ -1122,6 +1129,7 @@ public static function getRole($roleId, $createIfNotExists = false) * Create or update role * * @param AJXP_Role $roleObject + * @param null $userObject */ public static function updateRole($roleObject, $userObject = null) { @@ -1181,12 +1189,12 @@ public static function getFilteredRepositoryOption($pluginId, $repository, $opti } /** - * @param AJXP_User $parentUser + * @param string $parentUserId * @return AJXP_Role */ - public static function limitedRoleFromParent($parentUser) + public static function limitedRoleFromParent($parentUserId) { - $parentRole = self::getRole("AJXP_USR_/".$parentUser); + $parentRole = self::getRole("AJXP_USR_/".$parentUserId); if($parentRole === false) return null; // Inherit actions diff --git a/core/src/core/classes/class.ConfService.php b/core/src/core/classes/class.ConfService.php index 6fc007ef1e..40339176f3 100644 --- a/core/src/core/classes/class.ConfService.php +++ b/core/src/core/classes/class.ConfService.php @@ -96,6 +96,7 @@ public function initInst() if (is_file(AJXP_CONF_PATH."/bootstrap_repositories.php")) { + $REPOSITORIES = array(); include(AJXP_CONF_PATH."/bootstrap_repositories.php"); $this->configs["DEFAULT_REPOSITORIES"] = $REPOSITORIES; } else { @@ -223,8 +224,7 @@ public static function currentContextIsCommandLine() /** * Set or get if we are currently running REST * @static - * @param null $set - * @param string $baseUrl + * @param string $restBase * @return bool */ public static function currentContextIsRestAPI($restBase = '') @@ -560,7 +560,7 @@ private function removeRepositoryFromCache($repositoryId){ * @param AbstractAjxpUser $userObject * @param bool $details * @param bool $labelOnly - * @param bool $skipShared + * @param bool $includeShared * @return Repository[] */ public static function getAccessibleRepositories($userObject=null, $details=false, $labelOnly = false, $includeShared = true) @@ -723,6 +723,7 @@ public static function filterRepositoryListWithCriteria($repoList, $criteria){ foreach($criteria as $key => $value){ if(!in_array($key, $searchableKeys)) continue; $criteriumOk = false; + $comp = null; if($key == "uuid") $comp = $repoObject->getUniqueId(); else if($key == "parent_uuid") $comp = $repoObject->getParentId(); else if($key == "owner_user_id") $comp = $repoObject->getUniqueUser(); @@ -781,6 +782,7 @@ public static function listRepositoriesWithCriteria($criteria, &$count){ /** * @param $scope String "user", "all" + * @param bool $includeShared * @return array */ protected function initRepositoriesListInst($scope = "user", $includeShared = true) @@ -825,6 +827,9 @@ protected function initRepositoriesListInst($scope = "user", $includeShared = tr } } if (is_array($drvList)) { + /** + * @var $drvList Repository[] + */ foreach ($drvList as $repoId=>$repoObject) { $driver = AJXP_PluginsService::getInstance()->getPluginByTypeName("access", $repoObject->getAccessType()); if (!is_object($driver) || !$driver->isEnabled()) { @@ -993,12 +998,6 @@ public static function getRepositoryById($repoId) */ public function getRepositoryByIdInst($repoId) { - /* - $currentRepos = $this->getLoadedRepositories(); - if (isSet($currentRepos[$repoId])) { - return $currentRepos[$repoId]; - } - */ if (isSet($this->configs["REPOSITORIES"]) && isSet($this->configs["REPOSITORIES"][$repoId])) { return $this->configs["REPOSITORIES"][$repoId]; } @@ -1021,6 +1020,7 @@ public function getRepositoryByIdInst($repoId) $this->keyValueCache->save("repository:".$repoId, $repo); return $repo; } + return null; } /** @@ -1070,7 +1070,7 @@ public static function replaceRepository($oldId, $oRepositoryObject) * See static method * @param $oldId * @param $oRepositoryObject - * @return void + * @return int */ public function replaceRepositoryInst($oldId, $oRepositoryObject) { @@ -1078,11 +1078,12 @@ public function replaceRepositoryInst($oldId, $oRepositoryObject) $confStorage = self::getConfStorageImpl(); $res = $confStorage->saveRepository($oRepositoryObject, true); if ($res == -1) { - return $res; + return -1; } AJXP_Controller::applyHook("workspace.after_update", array($oRepositoryObject)); AJXP_Logger::info(__CLASS__,"Edit Repository", array("repo_name"=>$oRepositoryObject->getDisplay())); $this->invalidateLoadedRepositories(); + return 0; } /** * Set a temp repository id but not in the session @@ -1123,6 +1124,7 @@ public function deleteRepositoryInst($repoId) AJXP_Controller::applyHook("workspace.after_delete", array($repoId)); AJXP_Logger::info(__CLASS__,"Delete Repository", array("repo_id"=>$repoId)); $this->invalidateLoadedRepositories(); + return 0; } /** @@ -1176,7 +1178,7 @@ public static function getMessagesConf($forceRefresh = false) public function getMessagesInstConf($forceRefresh = false) { // make sure they are loaded - $mess = $this->getMessagesInst($forceRefresh); + $this->getMessagesInst($forceRefresh); return $this->configs["CONF_MESSAGES"]; } @@ -1235,6 +1237,7 @@ public function getMessagesInst($forceRefresh = false) $lang = "en"; } if (is_file($path."/conf/".$lang.".php")) { + $mess = array(); require($path."/conf/".$lang.".php"); $this->configs["CONF_MESSAGES"] = array_merge($this->configs["CONF_MESSAGES"], $mess); } @@ -1367,7 +1370,7 @@ public static function getConf($varName) */ public static function setConf($varName, $varValue) { - return self::getInstance()->setConfInst($varName, $varValue); + self::getInstance()->setConfInst($varName, $varValue); } /** * See static method @@ -1418,7 +1421,7 @@ public static function getCoreConf($varName, $coreType = "ajaxplorer") */ public static function setLanguage($lang) { - return self::getInstance()->setLanguageInst($lang); + self::getInstance()->setLanguageInst($lang); } /** * See static method @@ -1633,7 +1636,6 @@ public static function availableDriversToXML($filterByTagName = "", $filterByDri } $q = new DOMXPath($node->ownerDocument); $cNodes = $q->query("//".$filterByTagName, $node); - $nodeAttr = $node->attributes; $xmlBuffer .= "attributes as $attr) $xmlBuffer.= " $attr->name=\"$attr->value\" "; $xmlBuffer .=">"; diff --git a/core/src/core/classes/class.ContentFilter.php b/core/src/core/classes/class.ContentFilter.php index 1519e81902..275ae13788 100644 --- a/core/src/core/classes/class.ContentFilter.php +++ b/core/src/core/classes/class.ContentFilter.php @@ -108,7 +108,7 @@ public function movePath($oldPath, $newPath){ } /** - * @return Return public data as array, pre-utf8 encoded + * @return array public data as array, pre-utf8 encoded */ public function toArray(){ $data = array("filters" => array(), "virtualPaths" => array()); diff --git a/core/src/core/classes/class.HTMLWriter.php b/core/src/core/classes/class.HTMLWriter.php index 835d2badc7..e29348926e 100644 --- a/core/src/core/classes/class.HTMLWriter.php +++ b/core/src/core/classes/class.HTMLWriter.php @@ -100,9 +100,6 @@ public static function writeI18nMessagesClass($mess) /** * Send a simple Content-type header * @static - * @param string $type - * @param string $charset - * @return void */ public static function internetExplorerMainDocumentHeader() { @@ -133,12 +130,12 @@ public static function closeBodyAndPage() { print(""); } + /** * Write directly an error as a javascript instruction * @static * @param $errorType * @param $errorMessage - * @return */ public static function javascriptErrorHandler($errorType, $errorMessage) { diff --git a/core/src/core/classes/class.HttpClient.php b/core/src/core/classes/class.HttpClient.php index 3fb7c56dc5..66606acf73 100644 --- a/core/src/core/classes/class.HttpClient.php +++ b/core/src/core/classes/class.HttpClient.php @@ -47,7 +47,13 @@ class HttpClient public $postDataArray = array(); public $directForwarding = false; + /** + * @var bool|resource + */ public $contentDestStream = false; + /** + * @var bool|callable + */ public $eventListener = false; public $collectHeaders; @@ -134,10 +140,13 @@ public function doRequest() switch ($errno) { case -3: $this->errormsg = 'Socket creation failed (-3)'; + break; case -4: $this->errormsg = 'DNS lookup failure (-4)'; + break; case -5: $this->errormsg = 'Connection refused or timed out (-5)'; + break; default: $this->errormsg = 'Connection failed on '.$this->host.'('.$errno.')'; $this->errormsg .= ' '.$errstr; @@ -283,7 +292,7 @@ public function doRequest() $this->notify("close"); fclose($fp); if ($this->directForwarding) { - return ; + return true; } // If data is compressed, uncompress it if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] == 'gzip') { diff --git a/core/src/core/classes/class.PydioSdkGenerator.php b/core/src/core/classes/class.PydioSdkGenerator.php index 59ac31365a..d687f27f9a 100644 --- a/core/src/core/classes/class.PydioSdkGenerator.php +++ b/core/src/core/classes/class.PydioSdkGenerator.php @@ -24,7 +24,10 @@ class PydioSdkGenerator { public static function analyzeRegistry($versionString) { - if(!AJXP_SERVER_DEBUG) return; + if(!AJXP_SERVER_DEBUG) { + echo "Please switch the server to debug mode to use this API."; + return; + } $pServ = AJXP_PluginsService::getInstance(); $nodes = $pServ->searchAllManifests('//actions/*/processing/serverCallback[@developerComment]', 'node', false, false, true); diff --git a/core/src/core/classes/class.Repository.php b/core/src/core/classes/class.Repository.php index 7e98bac79a..fd2f9d28fd 100644 --- a/core/src/core/classes/class.Repository.php +++ b/core/src/core/classes/class.Repository.php @@ -315,12 +315,14 @@ public function addOption($oName, $oValue) } $this->options[$oName] = $oValue; } + /** * Get the repository options, filtered in various maners * @param string $oName * @param bool $safe Do not filter * @param AbstractAjxpUser $resolveUser * @return mixed|string + * @throws Exception */ public function getOption($oName, $safe=false, $resolveUser = null) { @@ -579,6 +581,7 @@ public function setDescription( $descriptionText ) /** * @param bool $public + * @param null $ownerLabel * @return String */ public function getDescription( $public = false, $ownerLabel = null ) diff --git a/core/src/core/classes/class.UnixProcess.php b/core/src/core/classes/class.UnixProcess.php index 472a0bb4cc..3e1921db00 100644 --- a/core/src/core/classes/class.UnixProcess.php +++ b/core/src/core/classes/class.UnixProcess.php @@ -102,8 +102,8 @@ public function status() */ public function start() { - if ($this->command != '')$this->runCom(); - else return true; + if ($this->command != '') $this->runCom(); + return true; } /** * Try to kill the process via command line. diff --git a/core/src/core/classes/class.UserSelection.php b/core/src/core/classes/class.UserSelection.php index 8f27e066d3..94e2d022ed 100644 --- a/core/src/core/classes/class.UserSelection.php +++ b/core/src/core/classes/class.UserSelection.php @@ -27,6 +27,9 @@ class UserSelection { public $files; + /** + * @var AJXP_Node[] + */ private $nodes; public $varPrefix = "file"; public $dirPrefix = "dir"; diff --git a/core/src/core/classes/securimage/securimage.php b/core/src/core/classes/securimage/securimage.php index 3bb63a1614..679a27441c 100644 --- a/core/src/core/classes/securimage/securimage.php +++ b/core/src/core/classes/securimage/securimage.php @@ -1547,9 +1547,9 @@ class Securimage_Color * Example: The code for the HTML color #4A203C is:
* $color = new Securimage_Color(0x4A, 0x20, 0x3C); * - * @param $red Red component 0-255 - * @param $green Green component 0-255 - * @param $blue Blue component 0-255 + * @param $red int|String Red component 0-255 + * @param $green int Green component 0-255 + * @param $blue int Blue component 0-255 */ public function Securimage_Color($red, $green = null, $blue = null) { diff --git a/core/src/plugins/boot.conf/class.BootConfLoader.php b/core/src/plugins/boot.conf/class.BootConfLoader.php index 19c17129cf..1e7b8bdaac 100644 --- a/core/src/plugins/boot.conf/class.BootConfLoader.php +++ b/core/src/plugins/boot.conf/class.BootConfLoader.php @@ -447,9 +447,10 @@ public function listRepositories($user = null) /** * Returns a list of available repositories (dynamic ones only, not the ones defined in the config file). * @param Array $criteria + * @param int $count * @return Array */ - public function listRepositoriesWithCriteria($criteria){ + public function listRepositoriesWithCriteria($criteria, &$count = null){ } @@ -515,9 +516,10 @@ public function saveRoles($roles) /** * @param AJXP_Role $role + * @param AbstractAjxpUser $userObject * @return void */ - public function updateRole($role) + public function updateRole($role, $userObject = null) { // TODO: Implement updateRole() method. } diff --git a/core/src/plugins/conf.serial/class.serialConfDriver.php b/core/src/plugins/conf.serial/class.serialConfDriver.php index 8353c3ae6b..db5ee4d5ec 100644 --- a/core/src/plugins/conf.serial/class.serialConfDriver.php +++ b/core/src/plugins/conf.serial/class.serialConfDriver.php @@ -128,9 +128,10 @@ public function listRepositories($user = null) /** * Returns a list of available repositories (dynamic ones only, not the ones defined in the config file). * @param Array $criteria + * @param $count * @return Array */ - public function listRepositoriesWithCriteria($criteria){ + public function listRepositoriesWithCriteria($criteria, &$count = null){ $all = AJXP_Utils::loadSerialFile($this->repoSerialFile); if ($criteria != null) { diff --git a/core/src/plugins/core.conf/class.AbstractAjxpUser.php b/core/src/plugins/core.conf/class.AbstractAjxpUser.php index 87372365fb..08dcac51c0 100644 --- a/core/src/plugins/core.conf/class.AbstractAjxpUser.php +++ b/core/src/plugins/core.conf/class.AbstractAjxpUser.php @@ -39,7 +39,13 @@ abstract class AbstractAjxpUser implements AjxpGroupPathProvider public $prefs; public $bookmarks; public $version; + /** + * @var string + */ public $parentUser; + /** + * @var bool + */ public $resolveAsParent = false; /** * @var bool @@ -278,16 +284,25 @@ public function setAdmin($boolean) $this->hasAdmin = $boolean; } + /** + * @return bool Whether the user has a parent or not + */ public function hasParent() { return isSet($this->parentUser); } + /** + * @param string $user A user ID + */ public function setParent($user) { $this->parentUser = $user; } + /** + * @return string Returns the ID of the parent user + */ public function getParent() { return $this->parentUser; diff --git a/core/src/plugins/core.conf/class.AbstractConfDriver.php b/core/src/plugins/core.conf/class.AbstractConfDriver.php index 9efef920a5..cac2e3ac91 100644 --- a/core/src/plugins/core.conf/class.AbstractConfDriver.php +++ b/core/src/plugins/core.conf/class.AbstractConfDriver.php @@ -238,16 +238,15 @@ abstract public function listRepositories($user = null); /** * Returns a list of available repositories (dynamic ones only, not the ones defined in the config file). * @param Array $criteria This parameter can take the following keys - * * - Search keys "uuid", "parent_uuid", "owner_user_id", "display", "accessType", "isTemplate", "slug", "groupPath", * Search values can be either string, array of string, AJXP_FILTER_EMPTY, AJXP_FILTER_NOT_EMPTY or regexp:RegexpString * - or "role" => AJXP_Role object: will search repositories accessible to this role * - ORDERBY = array("KEY"=>"", "DIR"=>""), GROUPBY, CURSOR = array("OFFSET" => 0, "LIMIT", 30) * - COUNT_ONLY - * + * @param $count int fill this integer with a count * @return Repository[] */ - abstract public function listRepositoriesWithCriteria($criteria); + abstract public function listRepositoriesWithCriteria($criteria, &$count=null); /** @@ -291,9 +290,10 @@ abstract public function saveRoles($roles); /** * @abstract * @param AJXP_Role $role + * @param AbstractAjxpUser $userObject * @return void */ - abstract public function updateRole($role); + abstract public function updateRole($role, $userObject = null); /** * @abstract