diff options
-rw-r--r-- | apps/files/appinfo/remote.php | 2 | ||||
-rw-r--r-- | autotest.cmd | 4 | ||||
-rw-r--r-- | core/templates/layout.user.php | 7 | ||||
-rw-r--r-- | lib/connector/sabre/server.php | 235 | ||||
-rw-r--r-- | lib/private/preview/movies.php | 52 | ||||
-rw-r--r-- | lib/private/preview/office-cl.php | 160 | ||||
-rw-r--r-- | lib/private/preview/office.php | 25 | ||||
-rw-r--r-- | lib/private/preview/provider.php | 12 | ||||
-rw-r--r-- | lib/private/preview/unknown.php | 26 | ||||
-rw-r--r-- | lib/public/app.php | 48 | ||||
-rw-r--r-- | lib/public/appframework/http/response.php | 14 | ||||
-rw-r--r-- | lib/public/config.php | 14 | ||||
-rw-r--r-- | lib/public/db.php | 12 | ||||
-rw-r--r-- | lib/public/files.php | 28 | ||||
-rw-r--r-- | lib/public/icache.php | 6 | ||||
-rw-r--r-- | lib/public/idbconnection.php | 16 | ||||
-rw-r--r-- | lib/public/il10n.php | 8 | ||||
-rw-r--r-- | lib/public/response.php | 10 | ||||
-rw-r--r-- | lib/public/share.php | 66 | ||||
-rw-r--r-- | lib/public/template.php | 60 | ||||
-rw-r--r-- | lib/public/user.php | 51 | ||||
-rw-r--r-- | tests/data/openssl.cnf | 350 | ||||
-rw-r--r-- | tests/preseed-config.php | 5 | ||||
-rw-r--r-- | tests/win32-phpunit.php | 347 |
24 files changed, 922 insertions, 636 deletions
diff --git a/apps/files/appinfo/remote.php b/apps/files/appinfo/remote.php index 0c1f2e6580c..75c80cd49f3 100644 --- a/apps/files/appinfo/remote.php +++ b/apps/files/appinfo/remote.php @@ -39,7 +39,7 @@ $rootDir = new OC_Connector_Sabre_Directory(''); $objectTree = new \OC\Connector\Sabre\ObjectTree($rootDir); // Fire up server -$server = new Sabre_DAV_Server($objectTree); +$server = new OC_Connector_Sabre_Server($objectTree); $server->httpRequest = $requestBackend; $server->setBaseUri($baseuri); diff --git a/autotest.cmd b/autotest.cmd index a511faef9c6..969e4a1ff38 100644 --- a/autotest.cmd +++ b/autotest.cmd @@ -6,7 +6,6 @@ :: :: @copyright 2012, 2013 Thomas Müller thomas.mueller@tmit.eu :: -@echo off set DATADIR=data-autotest set BASEDIR=%~dp0 @@ -119,7 +118,8 @@ goto:eof md coverage-html-%~1 php -f enable_all.php - php win32-phpunit.php --bootstrap bootstrap.php --configuration phpunit-autotest.xml --log-junit autotest-results-%~1.xml --coverage-clover autotest-clover-%~1.xml --coverage-html coverage-html-%~1 + call phpunit --bootstrap bootstrap.php --configuration phpunit-autotest.xml --log-junit autotest-results-%~1.xml --coverage-clover autotest-clover-%~1.xml --coverage-html coverage-html-%~1 + echo "Done with testing %~1 ..." cd %BASEDIR% goto:eof diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index d30313a67cc..9e1d8022ecb 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -8,9 +8,10 @@ <head data-user="<?php p($_['user_uid']); ?>" data-requesttoken="<?php p($_['requesttoken']); ?>"> <title> - <?php p(!empty($_['application'])?$_['application'].' | ':''); - p($theme->getTitle()); - p(trim($_['user_displayname']) != '' ?' ('.$_['user_displayname'].') ':'') ?> + <?php + p(!empty($_['application'])?$_['application'].' - ':''); + p($theme->getTitle()); + ?> </title> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> diff --git a/lib/connector/sabre/server.php b/lib/connector/sabre/server.php new file mode 100644 index 00000000000..41e8885917a --- /dev/null +++ b/lib/connector/sabre/server.php @@ -0,0 +1,235 @@ +<?php +/** + * ownCloud / SabreDAV + * + * @author Markus Goetz + * + * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. + * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + */ + +/** + * Class OC_Connector_Sabre_Server + * + * This class reimplements some methods from @see Sabre_DAV_Server. + * + * Basically we add handling of depth: infinity. + * + * The right way to handle this would have been to submit a patch to the upstream project + * and grab the corresponding version one merged. + * + * Due to time constrains and the limitations where we don't want to upgrade 3rdparty code in + * this stage of the release cycle we did choose this approach. + * + * For ownCloud 7 we will upgrade SabreDAV and submit the patch - if needed. + * + * @see Sabre_DAV_Server + */ +class OC_Connector_Sabre_Server extends Sabre_DAV_Server { + + /** + * @see Sabre_DAV_Server + */ + protected function httpPropfind($uri) { + + // $xml = new Sabre_DAV_XMLReader(file_get_contents('php://input')); + $requestedProperties = $this->parsePropFindRequest($this->httpRequest->getBody(true)); + + $depth = $this->getHTTPDepth(1); + // The only two options for the depth of a propfind is 0 or 1 + // if ($depth!=0) $depth = 1; + + $newProperties = $this->getPropertiesForPath($uri,$requestedProperties,$depth); + + // This is a multi-status response + $this->httpResponse->sendStatus(207); + $this->httpResponse->setHeader('Content-Type','application/xml; charset=utf-8'); + $this->httpResponse->setHeader('Vary','Brief,Prefer'); + + // Normally this header is only needed for OPTIONS responses, however.. + // iCal seems to also depend on these being set for PROPFIND. Since + // this is not harmful, we'll add it. + $features = array('1','3', 'extended-mkcol'); + foreach($this->plugins as $plugin) { + $features = array_merge($features,$plugin->getFeatures()); + } + + $this->httpResponse->setHeader('DAV',implode(', ',$features)); + + $prefer = $this->getHTTPPrefer(); + $minimal = $prefer['return-minimal']; + + $data = $this->generateMultiStatus($newProperties, $minimal); + $this->httpResponse->sendBody($data); + + } + + /** + * Small helper to support PROPFIND with DEPTH_INFINITY. + */ + private function addPathNodesRecursively(&$nodes, $path) { + foreach($this->tree->getChildren($path) as $childNode) { + $nodes[$path . '/' . $childNode->getName()] = $childNode; + if ($childNode instanceof Sabre_DAV_ICollection) + $this->addPathNodesRecursively($nodes, $path . '/' . $childNode->getName()); + } + } + + public function getPropertiesForPath($path, $propertyNames = array(), $depth = 0) { + + // if ($depth!=0) $depth = 1; + + $path = rtrim($path,'/'); + + $returnPropertyList = array(); + + $parentNode = $this->tree->getNodeForPath($path); + $nodes = array( + $path => $parentNode + ); + if ($depth==1 && $parentNode instanceof Sabre_DAV_ICollection) { + foreach($this->tree->getChildren($path) as $childNode) + $nodes[$path . '/' . $childNode->getName()] = $childNode; + } else if ($depth == self::DEPTH_INFINITY && $parentNode instanceof Sabre_DAV_ICollection) { + $this->addPathNodesRecursively($nodes, $path); + } + + // If the propertyNames array is empty, it means all properties are requested. + // We shouldn't actually return everything we know though, and only return a + // sensible list. + $allProperties = count($propertyNames)==0; + + foreach($nodes as $myPath=>$node) { + + $currentPropertyNames = $propertyNames; + + $newProperties = array( + '200' => array(), + '404' => array(), + ); + + if ($allProperties) { + // Default list of propertyNames, when all properties were requested. + $currentPropertyNames = array( + '{DAV:}getlastmodified', + '{DAV:}getcontentlength', + '{DAV:}resourcetype', + '{DAV:}quota-used-bytes', + '{DAV:}quota-available-bytes', + '{DAV:}getetag', + '{DAV:}getcontenttype', + ); + } + + // If the resourceType was not part of the list, we manually add it + // and mark it for removal. We need to know the resourcetype in order + // to make certain decisions about the entry. + // WebDAV dictates we should add a / and the end of href's for collections + $removeRT = false; + if (!in_array('{DAV:}resourcetype',$currentPropertyNames)) { + $currentPropertyNames[] = '{DAV:}resourcetype'; + $removeRT = true; + } + + $result = $this->broadcastEvent('beforeGetProperties',array($myPath, $node, &$currentPropertyNames, &$newProperties)); + // If this method explicitly returned false, we must ignore this + // node as it is inaccessible. + if ($result===false) continue; + + if (count($currentPropertyNames) > 0) { + + if ($node instanceof Sabre_DAV_IProperties) { + $nodeProperties = $node->getProperties($currentPropertyNames); + + // The getProperties method may give us too much, + // properties, in case the implementor was lazy. + // + // So as we loop through this list, we will only take the + // properties that were actually requested and discard the + // rest. + foreach($currentPropertyNames as $k=>$currentPropertyName) { + if (isset($nodeProperties[$currentPropertyName])) { + unset($currentPropertyNames[$k]); + $newProperties[200][$currentPropertyName] = $nodeProperties[$currentPropertyName]; + } + } + + } + + } + + foreach($currentPropertyNames as $prop) { + + if (isset($newProperties[200][$prop])) continue; + + switch($prop) { + case '{DAV:}getlastmodified' : if ($node->getLastModified()) $newProperties[200][$prop] = new Sabre_DAV_Property_GetLastModified($node->getLastModified()); break; + case '{DAV:}getcontentlength' : + if ($node instanceof Sabre_DAV_IFile) { + $size = $node->getSize(); + if (!is_null($size)) { + $newProperties[200][$prop] = (int)$node->getSize(); + } + } + break; + case '{DAV:}quota-used-bytes' : + if ($node instanceof Sabre_DAV_IQuota) { + $quotaInfo = $node->getQuotaInfo(); + $newProperties[200][$prop] = $quotaInfo[0]; + } + break; + case '{DAV:}quota-available-bytes' : + if ($node instanceof Sabre_DAV_IQuota) { + $quotaInfo = $node->getQuotaInfo(); + $newProperties[200][$prop] = $quotaInfo[1]; + } + break; + case '{DAV:}getetag' : if ($node instanceof Sabre_DAV_IFile && $etag = $node->getETag()) $newProperties[200][$prop] = $etag; break; + case '{DAV:}getcontenttype' : if ($node instanceof Sabre_DAV_IFile && $ct = $node->getContentType()) $newProperties[200][$prop] = $ct; break; + case '{DAV:}supported-report-set' : + $reports = array(); + foreach($this->plugins as $plugin) { + $reports = array_merge($reports, $plugin->getSupportedReportSet($myPath)); + } + $newProperties[200][$prop] = new Sabre_DAV_Property_SupportedReportSet($reports); + break; + case '{DAV:}resourcetype' : + $newProperties[200]['{DAV:}resourcetype'] = new Sabre_DAV_Property_ResourceType(); + foreach($this->resourceTypeMapping as $className => $resourceType) { + if ($node instanceof $className) $newProperties[200]['{DAV:}resourcetype']->add($resourceType); + } + break; + + } + + // If we were unable to find the property, we will list it as 404. + if (!$allProperties && !isset($newProperties[200][$prop])) $newProperties[404][$prop] = null; + + } + + $this->broadcastEvent('afterGetProperties',array(trim($myPath,'/'),&$newProperties, $node)); + + $newProperties['href'] = trim($myPath,'/'); + + // Its is a WebDAV recommendation to add a trailing slash to collectionnames. + // Apple's iCal also requires a trailing slash for principals (rfc 3744), though this is non-standard. + if ($myPath!='' && isset($newProperties[200]['{DAV:}resourcetype'])) { + $rt = $newProperties[200]['{DAV:}resourcetype']; + if ($rt->is('{DAV:}collection') || $rt->is('{DAV:}principal')) { + $newProperties['href'] .='/'; + } + } + + // If the resourcetype property was manually added to the requested property list, + // we will remove it again. + if ($removeRT) unset($newProperties[200]['{DAV:}resourcetype']); + + $returnPropertyList[] = $newProperties; + + } + + return $returnPropertyList; + + } +} diff --git a/lib/private/preview/movies.php b/lib/private/preview/movies.php index c318137ff0e..dc50d160346 100644 --- a/lib/private/preview/movies.php +++ b/lib/private/preview/movies.php @@ -8,40 +8,44 @@ */ namespace OC\Preview; -$isShellExecEnabled = !in_array('shell_exec', explode(', ', ini_get('disable_functions'))); -$whichAVCONV = shell_exec('which avconv'); -$isAVCONVAvailable = !empty($whichAVCONV); +// movie preview is currently not supported on Windows +if (!\OC_Util::runningOnWindows()) { + $isShellExecEnabled = !in_array('shell_exec', explode(', ', ini_get('disable_functions'))); + $whichAVCONV = shell_exec('which avconv'); + $isAVCONVAvailable = !empty($whichAVCONV); -if($isShellExecEnabled && $isAVCONVAvailable) { + if($isShellExecEnabled && $isAVCONVAvailable) { - class Movie extends Provider { + class Movie extends Provider { - public function getMimeType() { - return '/video\/.*/'; - } + public function getMimeType() { + return '/video\/.*/'; + } + + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { + $absPath = \OC_Helper::tmpFile(); + $tmpPath = \OC_Helper::tmpFile(); - public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { - $absPath = \OC_Helper::tmpFile(); - $tmpPath = \OC_Helper::tmpFile(); + $handle = $fileview->fopen($path, 'rb'); - $handle = $fileview->fopen($path, 'rb'); + $firstmb = stream_get_contents($handle, 1048576); //1024 * 1024 = 1048576 + file_put_contents($absPath, $firstmb); - $firstmb = stream_get_contents($handle, 1048576); //1024 * 1024 = 1048576 - file_put_contents($absPath, $firstmb); + //$cmd = 'ffmpeg -y -i ' . escapeshellarg($absPath) . ' -f mjpeg -vframes 1 -ss 1 -s ' . escapeshellarg($maxX) . 'x' . escapeshellarg($maxY) . ' ' . $tmpPath; + $cmd = 'avconv -an -y -ss 1 -i ' . escapeshellarg($absPath) . ' -f mjpeg -vframes 1 ' . escapeshellarg($tmpPath); - //$cmd = 'ffmpeg -y -i ' . escapeshellarg($absPath) . ' -f mjpeg -vframes 1 -ss 1 -s ' . escapeshellarg($maxX) . 'x' . escapeshellarg($maxY) . ' ' . $tmpPath; - $cmd = 'avconv -an -y -ss 1 -i ' . escapeshellarg($absPath) . ' -f mjpeg -vframes 1 ' . escapeshellarg($tmpPath); - - shell_exec($cmd); + shell_exec($cmd); - $image = new \OC_Image($tmpPath); + $image = new \OC_Image($tmpPath); - unlink($absPath); - unlink($tmpPath); + unlink($absPath); + unlink($tmpPath); - return $image->valid() ? $image : false; + return $image->valid() ? $image : false; + } } + + \OC\Preview::registerProvider('OC\Preview\Movie'); } +} - \OC\Preview::registerProvider('OC\Preview\Movie'); -}
\ No newline at end of file diff --git a/lib/private/preview/office-cl.php b/lib/private/preview/office-cl.php index 112909d6523..8f2e06c050b 100644 --- a/lib/private/preview/office-cl.php +++ b/lib/private/preview/office-cl.php @@ -7,128 +7,132 @@ */ namespace OC\Preview; -//we need imagick to convert -class Office extends Provider { +// office preview is currently not supported on Windows +if (!\OC_Util::runningOnWindows()) { - private $cmd; + //we need imagick to convert + class Office extends Provider { - public function getMimeType() { - return null; - } + private $cmd; - public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { - $this->initCmd(); - if(is_null($this->cmd)) { - return false; + public function getMimeType() { + return null; } - $absPath = $fileview->toTmpFile($path); + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { + $this->initCmd(); + if(is_null($this->cmd)) { + return false; + } + + $absPath = $fileview->toTmpFile($path); + + $tmpDir = get_temp_dir(); - $tmpDir = get_temp_dir(); + $defaultParameters = ' --headless --nologo --nofirststartwizard --invisible --norestore -convert-to pdf -outdir '; + $clParameters = \OCP\Config::getSystemValue('preview_office_cl_parameters', $defaultParameters); - $defaultParameters = ' --headless --nologo --nofirststartwizard --invisible --norestore -convert-to pdf -outdir '; - $clParameters = \OCP\Config::getSystemValue('preview_office_cl_parameters', $defaultParameters); + $exec = $this->cmd . $clParameters . escapeshellarg($tmpDir) . ' ' . escapeshellarg($absPath); + $export = 'export HOME=/' . $tmpDir; - $exec = $this->cmd . $clParameters . escapeshellarg($tmpDir) . ' ' . escapeshellarg($absPath); - $export = 'export HOME=/' . $tmpDir; + shell_exec($export . "\n" . $exec); - shell_exec($export . "\n" . $exec); + //create imagick object from pdf + try{ + $pdf = new \imagick($absPath . '.pdf' . '[0]'); + $pdf->setImageFormat('jpg'); + } catch (\Exception $e) { + unlink($absPath); + unlink($absPath . '.pdf'); + \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); + return false; + } + + $image = new \OC_Image($pdf); - //create imagick object from pdf - try{ - $pdf = new \imagick($absPath . '.pdf' . '[0]'); - $pdf->setImageFormat('jpg'); - } catch (\Exception $e) { unlink($absPath); unlink($absPath . '.pdf'); - \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); - return false; + + return $image->valid() ? $image : false; } - $image = new \OC_Image($pdf); + private function initCmd() { + $cmd = ''; - unlink($absPath); - unlink($absPath . '.pdf'); + if(is_string(\OC_Config::getValue('preview_libreoffice_path', null))) { + $cmd = \OC_Config::getValue('preview_libreoffice_path', null); + } - return $image->valid() ? $image : false; - } + $whichLibreOffice = shell_exec('which libreoffice'); + if($cmd === '' && !empty($whichLibreOffice)) { + $cmd = 'libreoffice'; + } - private function initCmd() { - $cmd = ''; + $whichOpenOffice = shell_exec('which openoffice'); + if($cmd === '' && !empty($whichOpenOffice)) { + $cmd = 'openoffice'; + } - if(is_string(\OC_Config::getValue('preview_libreoffice_path', null))) { - $cmd = \OC_Config::getValue('preview_libreoffice_path', null); - } + if($cmd === '') { + $cmd = null; + } - $whichLibreOffice = shell_exec('which libreoffice'); - if($cmd === '' && !empty($whichLibreOffice)) { - $cmd = 'libreoffice'; + $this->cmd = $cmd; } + } - $whichOpenOffice = shell_exec('which openoffice'); - if($cmd === '' && !empty($whichOpenOffice)) { - $cmd = 'openoffice'; - } + //.doc, .dot + class MSOfficeDoc extends Office { - if($cmd === '') { - $cmd = null; + public function getMimeType() { + return '/application\/msword/'; } - $this->cmd = $cmd; - } -} - -//.doc, .dot -class MSOfficeDoc extends Office { - - public function getMimeType() { - return '/application\/msword/'; } -} + \OC\Preview::registerProvider('OC\Preview\MSOfficeDoc'); -\OC\Preview::registerProvider('OC\Preview\MSOfficeDoc'); + //.docm, .dotm, .xls(m), .xlt(m), .xla(m), .ppt(m), .pot(m), .pps(m), .ppa(m) + class MSOffice2003 extends Office { -//.docm, .dotm, .xls(m), .xlt(m), .xla(m), .ppt(m), .pot(m), .pps(m), .ppa(m) -class MSOffice2003 extends Office { + public function getMimeType() { + return '/application\/vnd.ms-.*/'; + } - public function getMimeType() { - return '/application\/vnd.ms-.*/'; } -} + \OC\Preview::registerProvider('OC\Preview\MSOffice2003'); -\OC\Preview::registerProvider('OC\Preview\MSOffice2003'); + //.docx, .dotx, .xlsx, .xltx, .pptx, .potx, .ppsx + class MSOffice2007 extends Office { -//.docx, .dotx, .xlsx, .xltx, .pptx, .potx, .ppsx -class MSOffice2007 extends Office { + public function getMimeType() { + return '/application\/vnd.openxmlformats-officedocument.*/'; + } - public function getMimeType() { - return '/application\/vnd.openxmlformats-officedocument.*/'; } -} + \OC\Preview::registerProvider('OC\Preview\MSOffice2007'); -\OC\Preview::registerProvider('OC\Preview\MSOffice2007'); + //.odt, .ott, .oth, .odm, .odg, .otg, .odp, .otp, .ods, .ots, .odc, .odf, .odb, .odi, .oxt + class OpenDocument extends Office { -//.odt, .ott, .oth, .odm, .odg, .otg, .odp, .otp, .ods, .ots, .odc, .odf, .odb, .odi, .oxt -class OpenDocument extends Office { + public function getMimeType() { + return '/application\/vnd.oasis.opendocument.*/'; + } - public function getMimeType() { - return '/application\/vnd.oasis.opendocument.*/'; } -} + \OC\Preview::registerProvider('OC\Preview\OpenDocument'); -\OC\Preview::registerProvider('OC\Preview\OpenDocument'); + //.sxw, .stw, .sxc, .stc, .sxd, .std, .sxi, .sti, .sxg, .sxm + class StarOffice extends Office { -//.sxw, .stw, .sxc, .stc, .sxd, .std, .sxi, .sti, .sxg, .sxm -class StarOffice extends Office { + public function getMimeType() { + return '/application\/vnd.sun.xml.*/'; + } - public function getMimeType() { - return '/application\/vnd.sun.xml.*/'; } + \OC\Preview::registerProvider('OC\Preview\StarOffice'); } - -\OC\Preview::registerProvider('OC\Preview\StarOffice');
\ No newline at end of file diff --git a/lib/private/preview/office.php b/lib/private/preview/office.php index 5287bbd6ac1..673b16edc19 100644 --- a/lib/private/preview/office.php +++ b/lib/private/preview/office.php @@ -8,15 +8,22 @@ //both, libreoffice backend and php fallback, need imagick if (extension_loaded('imagick')) { $isShellExecEnabled = !in_array('shell_exec', explode(', ', ini_get('disable_functions'))); - $whichLibreOffice = shell_exec('which libreoffice'); - $isLibreOfficeAvailable = !empty($whichLibreOffice); - $whichOpenOffice = shell_exec('which libreoffice'); - $isOpenOfficeAvailable = !empty($whichOpenOffice); - //let's see if there is libreoffice or openoffice on this machine - if($isShellExecEnabled && ($isLibreOfficeAvailable || $isOpenOfficeAvailable || is_string(\OC_Config::getValue('preview_libreoffice_path', null)))) { - require_once('office-cl.php'); - }else{ + + // movie preview is currently not supported on Windows + if (!\OC_Util::runningOnWindows()) { + $whichLibreOffice = shell_exec('which libreoffice'); + $isLibreOfficeAvailable = !empty($whichLibreOffice); + $whichOpenOffice = shell_exec('which libreoffice'); + $isOpenOfficeAvailable = !empty($whichOpenOffice); + //let's see if there is libreoffice or openoffice on this machine + if($isShellExecEnabled && ($isLibreOfficeAvailable || $isOpenOfficeAvailable || is_string(\OC_Config::getValue('preview_libreoffice_path', null)))) { + require_once('office-cl.php'); + }else{ + //in case there isn't, use our fallback + require_once('office-fallback.php'); + } + } else { //in case there isn't, use our fallback require_once('office-fallback.php'); } -}
\ No newline at end of file +} diff --git a/lib/private/preview/provider.php b/lib/private/preview/provider.php index e4a730bafc8..65d09705f40 100644 --- a/lib/private/preview/provider.php +++ b/lib/private/preview/provider.php @@ -11,9 +11,15 @@ abstract class Provider { abstract public function getMimeType(); /** - * search for $query - * @param string $query - * @return + * get thumbnail for file at path $path + * @param string $path Path of file + * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image + * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image + * @param bool $scalingUp Disable/Enable upscaling of previews + * @param object $fileview fileview object of user folder + * @return mixed + * false if no preview was generated + * OC_Image object of the preview */ abstract public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview); } diff --git a/lib/private/preview/unknown.php b/lib/private/preview/unknown.php index 9e6cd68d401..4747f9e25ed 100644 --- a/lib/private/preview/unknown.php +++ b/lib/private/preview/unknown.php @@ -20,8 +20,30 @@ class Unknown extends Provider { $path = \OC_Helper::mimetypeIcon($mimetype); $path = \OC::$SERVERROOT . substr($path, strlen(\OC::$WEBROOT)); - return new \OC_Image($path); + $svgPath = substr_replace($path, 'svg', -3); + + if (extension_loaded('imagick') && file_exists($svgPath)) { + + // http://www.php.net/manual/de/imagick.setresolution.php#85284 + $svg = new \Imagick(); + $svg->readImage($svgPath); + $res = $svg->getImageResolution(); + $x_ratio = $res['x'] / $svg->getImageWidth(); + $y_ratio = $res['y'] / $svg->getImageHeight(); + $svg->removeImage(); + $svg->setResolution($maxX * $x_ratio, $maxY * $y_ratio); + $svg->setBackgroundColor(new \ImagickPixel('transparent')); + $svg->readImage($svgPath); + $svg->setImageFormat('png32'); + + $image = new \OC_Image(); + $image->loadFromData($svg); + } else { + $image = new \OC_Image($path); + } + + return $image; } } -\OC\Preview::registerProvider('OC\Preview\Unknown');
\ No newline at end of file +\OC\Preview::registerProvider('OC\Preview\Unknown'); diff --git a/lib/public/app.php b/lib/public/app.php index 0a5721b334e..18681670ddd 100644 --- a/lib/public/app.php +++ b/lib/public/app.php @@ -35,14 +35,12 @@ namespace OCP; */ class App { /** - * @brief Makes ownCloud aware of this app - * @brief This call is deprecated and not necessary to use. - * @param $data array with all information - * @returns boolean + * Makes ownCloud aware of this app + * @param array with all information + * @return boolean * - * @deprecated this method is deprecated - * Do not call it anymore - * It'll remain in our public API for compatibility reasons + * @deprecated This method is deprecated. Do not call it anymore. + * It'll remain in our public API for compatibility reasons. * */ public static function register( $data ) { @@ -50,9 +48,9 @@ class App { } /** - * @brief adds an entry to the navigation - * @param $data array containing the data - * @returns boolean + * Adds an entry to the navigation + * @param array containing the data + * @return boolean * * This function adds a new entry to the navigation visible to users. $data * is an associative array. @@ -71,9 +69,9 @@ class App { } /** - * @brief marks a navigation entry as active - * @param $id string id of the entry - * @returns boolean + * Marks a navigation entry as active + * @param string id of the entry + * @return boolean * * This function sets a navigation entry as active and removes the 'active' * property from all other entries. The templates can use this for @@ -84,7 +82,7 @@ class App { } /** - * @brief Register a Configuration Screen that should appear in the personal settings section. + * Register a Configuration Screen that should appear in the personal settings section. * @param $app string appid * @param $page string page to be included */ @@ -93,7 +91,7 @@ class App { } /** - * @brief Register a Configuration Screen that should appear in the Admin section. + * Register a Configuration Screen that should appear in the Admin section. * @param $app string appid * @param $page string page to be included */ @@ -102,19 +100,19 @@ class App { } /** - * @brief Read app metadata from the info.xml file + * Read app metadata from the info.xml file * @param string $app id of the app or the path of the info.xml file * @param boolean $path (optional) - * @returns array + * @return array */ public static function getAppInfo( $app, $path=false ) { return \OC_App::getAppInfo( $app, $path); } /** - * @brief checks whether or not an app is enabled - * @param $app app - * @returns boolean + * checks whether or not an app is enabled + * @param string + * @return boolean * * This function checks whether or not an app is enabled. */ @@ -123,17 +121,17 @@ class App { } /** - * @brief Check if the app is enabled, redirects to home if not - * @param $app app + * Check if the app is enabled, redirects to home if not + * @param string */ public static function checkAppEnabled( $app ) { \OC_Util::checkAppEnabled( $app ); } /** - * @brief Get the last version of the app, either from appinfo/version or from appinfo/info.xml - * @param $app app - * @returns boolean + * Get the last version of the app, either from appinfo/version or from appinfo/info.xml + * @param string + * @return boolean */ public static function getAppVersion( $app ) { return \OC_App::getAppVersion( $app ); diff --git a/lib/public/appframework/http/response.php b/lib/public/appframework/http/response.php index 64477258948..5ca389b9946 100644 --- a/lib/public/appframework/http/response.php +++ b/lib/public/appframework/http/response.php @@ -26,12 +26,15 @@ namespace OCP\AppFramework\Http; /** - * Base class for responses. Also used to just send headers + * Base class for responses. Also used to just send headers. + * + * It handles headers, HTTP status code, last modified and ETag. */ class Response { /** - * @var array default headers + * Headers - defaults to ['Cache-Control' => 'no-cache, must-revalidate'] + * @var array */ private $headers = array( 'Cache-Control' => 'no-cache, must-revalidate' @@ -39,18 +42,21 @@ class Response { /** + * HTTP status code - defaults to STATUS OK * @var string */ private $status = Http::STATUS_OK; /** + * Last modified date * @var \DateTime */ private $lastModified; /** + * ETag * @var string */ private $ETag; @@ -135,6 +141,7 @@ class Response { /** + * Get the ETag * @return string the etag */ public function getETag() { @@ -143,6 +150,7 @@ class Response { /** + * Get "last modified" date * @return string RFC2822 formatted last modified date */ public function getLastModified() { @@ -151,6 +159,7 @@ class Response { /** + * Set the ETag * @param string $ETag */ public function setETag($ETag) { @@ -159,6 +168,7 @@ class Response { /** + * Set "last modified" date * @param \DateTime $lastModified */ public function setLastModified($lastModified) { diff --git a/lib/public/config.php b/lib/public/config.php index 73476d7551d..74aaa4e1891 100644 --- a/lib/public/config.php +++ b/lib/public/config.php @@ -40,7 +40,7 @@ namespace OCP; */ class Config { /** - * @brief Gets a value from config.php + * Gets a value from config.php * @param string $key key * @param string $default = null default value * @return string the value or $default @@ -53,7 +53,7 @@ class Config { } /** - * @brief Sets a value + * Sets a value * @param string $key key * @param string $value value * @return bool @@ -71,7 +71,7 @@ class Config { } /** - * @brief Gets the config value + * Gets the config value * @param string $app app * @param string $key key * @param string $default = null, default value if the key does not exist @@ -85,7 +85,7 @@ class Config { } /** - * @brief sets a value in the appconfig + * Sets a value in the appconfig * @param string $app app * @param string $key key * @param string $value value @@ -103,7 +103,7 @@ class Config { } /** - * @brief Gets the preference + * Gets the preference * @param string $user user * @param string $app app * @param string $key key @@ -118,12 +118,12 @@ class Config { } /** - * @brief sets a value in the preferences + * Sets a value in the preferences * @param string $user user * @param string $app app * @param string $key key * @param string $value value - * @returns bool + * @return bool * * Adds a value to the preferences. If the key did not exist before, it * will be added automagically. diff --git a/lib/public/db.php b/lib/public/db.php index 9512cca2d19..fc6621f5b51 100644 --- a/lib/public/db.php +++ b/lib/public/db.php @@ -35,7 +35,7 @@ namespace OCP; */ class DB { /** - * @brief Prepare a SQL query + * Prepare a SQL query * @param string $query Query string * @return \MDB2_Statement_Common prepared SQL query * @@ -46,7 +46,7 @@ class DB { } /** - * @brief Insert a row if a matching row doesn't exists. + * Insert a row if a matching row doesn't exists. * @param $table string The table name (will replace *PREFIX*) to perform the replace on. * @param $input array * @@ -67,7 +67,7 @@ class DB { } /** - * @brief gets last value of autoincrement + * Gets last value of autoincrement * @param $table string The optional table name (will replace *PREFIX*) and add sequence suffix * @return int * @@ -81,21 +81,21 @@ class DB { } /** - * @brief Start a transaction + * Start a transaction */ public static function beginTransaction() { return(\OC_DB::beginTransaction()); } /** - * @brief Commit the database changes done during a transaction that is in progress + * Commit the database changes done during a transaction that is in progress */ public static function commit() { return(\OC_DB::commit()); } /** - * @brief check if a result is an error, works with MDB2 and PDOException + * Check if a result is an error, works with MDB2 and PDOException * @param mixed $result * @return bool */ diff --git a/lib/public/files.php b/lib/public/files.php index 852b041eefb..1e4c25c5ef1 100644 --- a/lib/public/files.php +++ b/lib/public/files.php @@ -36,9 +36,8 @@ namespace OCP; */ class Files { /** - * @brief Recusive deletion of folders - * @param string $dir path to the folder - * + * Recusive deletion of folders + * @param string path to the folder * @return bool */ static function rmdirr( $dir ) { @@ -46,7 +45,7 @@ class Files { } /** - * get the mimetype form a local file + * Get the mimetype form a local file * @param string path * @return string * does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead @@ -56,17 +55,16 @@ class Files { } /** - * search for files by mimetype - * - * @param string $query + * Search for files by mimetype + * @param string mimetype * @return array */ - static public function searchByMime($mimetype) { + static public function searchByMime( $mimetype ) { return(\OC\Files\Filesystem::searchByMime( $mimetype )); } /** - * copy the contents of one stream to another + * Copy the contents of one stream to another * @param resource source * @param resource target * @return int the number of bytes copied @@ -77,7 +75,7 @@ class Files { } /** - * create a temporary file with an unique filename + * Create a temporary file with an unique filename * @param string postfix * @return string * @@ -88,7 +86,7 @@ class Files { } /** - * create a temporary folder with an unique filename + * Create a temporary folder with an unique filename * @return string * * temporary files are automatically cleaned up after the script is finished @@ -99,9 +97,8 @@ class Files { /** * Adds a suffix to the name in case the file exists - * - * @param $path - * @param $filename + * @param string path + * @param string filename * @return string */ public static function buildNotExistingFileName( $path, $filename ) { @@ -109,8 +106,9 @@ class Files { } /** + * Gets the Storage for an app - creates the needed folder if they are not + * existant * @param string appid - * @param $app app * @return \OC\Files\View */ public static function getStorage( $app ) { diff --git a/lib/public/icache.php b/lib/public/icache.php index 436ee71b2b9..a73004ec9a7 100644 --- a/lib/public/icache.php +++ b/lib/public/icache.php @@ -14,7 +14,6 @@ interface ICache { /** * Get a value from the user cache - * * @param string $key * @return mixed */ @@ -22,7 +21,6 @@ interface ICache { /** * Set a value in the user cache - * * @param string $key * @param mixed $value * @param int $ttl Time To Live in seconds. Defaults to 60*60*24 @@ -32,7 +30,6 @@ interface ICache { /** * Check if a value is set in the user cache - * * @param string $key * @return bool */ @@ -40,14 +37,13 @@ interface ICache { /** * Remove an item from the user cache - * * @param string $key * @return bool */ public function remove($key); /** - * clear the user cache of all entries starting with a prefix + * Clear the user cache of all entries starting with a prefix * @param string $prefix (optional) * @return bool */ diff --git a/lib/public/idbconnection.php b/lib/public/idbconnection.php index c741a0f061a..252902eda6c 100644 --- a/lib/public/idbconnection.php +++ b/lib/public/idbconnection.php @@ -4,7 +4,7 @@ * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. - * + * */ namespace OCP; @@ -30,9 +30,9 @@ interface IDBConnection { public function lastInsertId($table = null); /** - * @brief Insert a row if a matching row doesn't exists. - * @param $table string The table name (will replace *PREFIX*) to perform the replace on. - * @param $input array + * Insert a row if a matching row doesn't exists. + * @param string The table name (will replace *PREFIX*) to perform the replace on. + * @param array * * The input array if in the form: * @@ -49,25 +49,25 @@ interface IDBConnection { public function insertIfNotExist($table, $input); /** - * @brief Start a transaction + * Start a transaction * @return bool TRUE on success or FALSE on failure */ public function beginTransaction(); /** - * @brief Commit the database changes done during a transaction that is in progress + * Commit the database changes done during a transaction that is in progress * @return bool TRUE on success or FALSE on failure */ public function commit(); /** - * @brief Rollback the database changes done during a transaction that is in progress + * Rollback the database changes done during a transaction that is in progress * @return bool TRUE on success or FALSE on failure */ public function rollBack(); /** - * returns the error code and message as a string for logging + * Gets the error code and message as a string for logging * @return string */ public function getError(); diff --git a/lib/public/il10n.php b/lib/public/il10n.php index 9cf9093d391..805c8988aa2 100644 --- a/lib/public/il10n.php +++ b/lib/public/il10n.php @@ -14,7 +14,7 @@ namespace OCP; */ interface IL10N { /** - * @brief Translating + * Translating * @param $text String The text we need a translation for * @param array $parameters default:array() Parameters for sprintf * @return \OC_L10N_String|string Translation or the same text @@ -25,7 +25,7 @@ interface IL10N { public function t($text, $parameters = array()); /** - * @brief Translating + * Translating * @param $text_singular String the string to translate for exactly one object * @param $text_plural String the string to translate for n objects * @param $count Integer Number of objects @@ -42,10 +42,10 @@ interface IL10N { public function n($text_singular, $text_plural, $count, $parameters = array()); /** - * @brief Localization + * Localization * @param $type Type of localization * @param $params parameters for this localization - * @returns String or false + * @return String or false * * Returns the localized data. * diff --git a/lib/public/response.php b/lib/public/response.php index de0c3f25347..f7f6afcec95 100644 --- a/lib/public/response.php +++ b/lib/public/response.php @@ -35,7 +35,7 @@ namespace OCP; */ class Response { /** - * @brief Enable response caching by sending correct HTTP headers + * Enable response caching by sending correct HTTP headers * @param int $cache_time time to cache the response * >0 cache time in seconds * 0 and <0 enable default browser caching @@ -55,7 +55,7 @@ class Response { } /** - * @brief disable browser caching + * Disable browser caching * @see enableCaching with cache_time = 0 */ static public function disableCaching() { @@ -72,7 +72,7 @@ class Response { } /** - * @brief Send file as response, checking and setting caching headers + * Send file as response, checking and setting caching headers * @param string $filepath of file to send */ static public function sendFile( $filepath ) { @@ -80,7 +80,7 @@ class Response { } /** - * @brief Set response expire time + * Set response expire time * @param string|\DateTime $expires date-time when the response expires * string for DateInterval from now * DateTime object when to expire response @@ -90,7 +90,7 @@ class Response { } /** - * @brief Send redirect response + * Send redirect response * @param string $location to redirect to */ static public function redirect( $location ) { diff --git a/lib/public/share.php b/lib/public/share.php index 66605dafee5..1b6f5d05f10 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -64,7 +64,7 @@ class Share { private static $isResharingAllowed; /** - * @brief Register a sharing backend class that implements OCP\Share_Backend for an item type + * Register a sharing backend class that implements OCP\Share_Backend for an item type * @param string Item type * @param string Backend class * @param string (optional) Depends on item type @@ -94,11 +94,10 @@ class Share { } /** - * @brief Check if the Share API is enabled + * Check if the Share API is enabled * @return Returns true if enabled or false * * The Share API is enabled by default if not configured - * */ public static function isEnabled() { if (\OC_Appconfig::getValue('core', 'shareapi_enabled', 'yes') == 'yes') { @@ -108,7 +107,7 @@ class Share { } /** - * @brief Prepare a path to be passed to DB as file_target + * Prepare a path to be passed to DB as file_target * @return string Prepared path */ public static function prepFileTarget( $path ) { @@ -125,7 +124,7 @@ class Share { } /** - * @brief Find which users can access a shared item + * Find which users can access a shared item * @param $path to the file * @param $user owner of the file * @param include owner to the list of users with access to the file @@ -232,7 +231,7 @@ class Share { } /** - * @brief Get the items of item type shared with the current user + * Get the items of item type shared with the current user * @param string Item type * @param int Format (optional) Format type must be defined by the backend * @param int Number of items to return (optional) Returns all by default @@ -245,7 +244,7 @@ class Share { } /** - * @brief Get the item of item type shared with the current user + * Get the item of item type shared with the current user * @param string $itemType * @param string $ItemTarget * @param int $format (optional) Format type must be defined by the backend @@ -258,7 +257,7 @@ class Share { } /** - * @brief Get the item of item type shared with a given user by source + * Get the item of item type shared with a given user by source * @param string $ItemType * @param string $ItemSource * @param string $user User user to whom the item was shared @@ -307,7 +306,7 @@ class Share { } /** - * @brief Get the item of item type shared with the current user by source + * Get the item of item type shared with the current user by source * @param string Item type * @param string Item source * @param int Format (optional) Format type must be defined by the backend @@ -320,7 +319,7 @@ class Share { } /** - * @brief Get the item of item type shared by a link + * Get the item of item type shared by a link * @param string Item type * @param string Item source * @param string Owner of link @@ -332,7 +331,7 @@ class Share { } /** - * @brief Get the item shared by a token + * Get the item shared by a token * @param string token * @return Item */ @@ -357,7 +356,7 @@ class Share { } /** - * @brief resolves reshares down to the last real share + * resolves reshares down to the last real share * @param $linkItem * @return $fileOwner */ @@ -380,7 +379,7 @@ class Share { /** - * @brief Get the shared items of item type owned by the current user + * Get the shared items of item type owned by the current user * @param string Item type * @param int Format (optional) Format type must be defined by the backend * @param int Number of items to return (optional) Returns all by default @@ -393,7 +392,7 @@ class Share { } /** - * @brief Get the shared item of item type owned by the current user + * Get the shared item of item type owned by the current user * @param string Item type * @param string Item source * @param int Format (optional) Format type must be defined by the backend @@ -429,7 +428,7 @@ class Share { } /** - * @brief Share an item with a user, group, or via private link + * Share an item with a user, group, or via private link * @param string Item type * @param string Item source * @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK @@ -606,7 +605,7 @@ class Share { } /** - * @brief Unshare an item from a user, group, or delete a private link + * Unshare an item from a user, group, or delete a private link * @param string Item type * @param string Item source * @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK @@ -639,7 +638,7 @@ class Share { } /** - * @brief Unshare an item from all users, groups, and remove all links + * Unshare an item from all users, groups, and remove all links * @param string Item type * @param string Item source * @return Returns true on success or false on failure @@ -666,7 +665,7 @@ class Share { } /** - * @brief Unshare an item shared with the current user + * Unshare an item shared with the current user * @param string Item type * @param string Item target * @return Returns true on success or false on failure @@ -703,7 +702,7 @@ class Share { return false; } /** - * @brief sent status if users got informed by mail about share + * sent status if users got informed by mail about share * @param string $itemType * @param string $itemSource * @param int $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK @@ -727,7 +726,7 @@ class Share { } /** - * @brief Set the permissions of an item for a specific user or group + * Set the permissions of an item for a specific user or group * @param string Item type * @param string Item source * @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK @@ -831,7 +830,7 @@ class Share { } /** - * @brief Get the backend class for the specified item type + * Get the backend class for the specified item type * @param string $itemType * @return Share_Backend */ @@ -860,7 +859,7 @@ class Share { } /** - * @brief Check if resharing is allowed + * Check if resharing is allowed * @return Returns true if allowed or false * * Resharing is allowed by default if not configured @@ -878,7 +877,7 @@ class Share { } /** - * @brief Get a list of collection item types for the specified item type + * Get a list of collection item types for the specified item type * @param string Item type * @return array */ @@ -902,7 +901,7 @@ class Share { } /** - * @brief Get shared items from the database + * Get shared items from the database * @param string Item type * @param string Item source or target (optional) * @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, SHARE_TYPE_LINK, $shareTypeUserAndGroups, or $shareTypeGroupUserUnique @@ -1307,7 +1306,7 @@ class Share { } /** - * @brief Put shared item into the database + * Put shared item into the database * @param string Item type * @param string Item source * @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK @@ -1543,7 +1542,7 @@ class Share { } /** - * @brief Generate a unique target for the item + * Generate a unique target for the item * @param string Item type * @param string Item source * @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK @@ -1659,7 +1658,7 @@ class Share { } /** - * @brief Delete all reshares of an item + * Delete all reshares of an item * @param int Id of item to delete * @param bool If true, exclude the parent from the delete (optional) * @param string The user that the parent was shared with (optinal) @@ -1797,7 +1796,7 @@ class Share { interface Share_Backend { /** - * @brief Get the source of the item to be stored in the database + * Get the source of the item to be stored in the database * @param string Item source * @param string Owner of the item * @return mixed|array|false Source @@ -1810,7 +1809,7 @@ interface Share_Backend { public function isValidSource($itemSource, $uidOwner); /** - * @brief Get a unique name of the item for the specified user + * Get a unique name of the item for the specified user * @param string Item source * @param string|false User the item is being shared with * @param array|null List of similar item names already existing as shared items @@ -1822,7 +1821,7 @@ interface Share_Backend { public function generateTarget($itemSource, $shareWith, $exclude = null); /** - * @brief Converts the shared item sources back into the item in the specified format + * Converts the shared item sources back into the item in the specified format * @param array Shared items * @param int Format * @return ? @@ -1853,10 +1852,7 @@ interface Share_Backend { interface Share_Backend_File_Dependent extends Share_Backend { /** - * @brief Get the file path of the item - * @param - * @param - * @return + * Get the file path of the item */ public function getFilePath($itemSource, $uidOwner); @@ -1869,7 +1865,7 @@ interface Share_Backend_File_Dependent extends Share_Backend { interface Share_Backend_Collection extends Share_Backend { /** - * @brief Get the sources of the children of the item + * Get the sources of the children of the item * @param string Item source * @return array Returns an array of children each inside an array with the keys: source, target, and file_path if applicable */ diff --git a/lib/public/template.php b/lib/public/template.php index a5c500b0e25..cf2dc7766f5 100644 --- a/lib/public/template.php +++ b/lib/public/template.php @@ -32,12 +32,12 @@ namespace OCP; /** - * @brief make OC_Helper::imagePath available as a simple function - * @param $app app - * @param $image image - * @returns link to the image + * Make OC_Helper::imagePath available as a simple function + * @param string app + * @param string image + * @return link to the image * - * For further information have a look at OC_Helper::imagePath + * @see OC_Helper::imagePath */ function image_path( $app, $image ) { return(\image_path( $app, $image )); @@ -45,40 +45,39 @@ function image_path( $app, $image ) { /** - * @brief make OC_Helper::mimetypeIcon available as a simple function - * Returns the path to the image of this file type. - * @param $mimetype mimetype - * @returns link to the image + * Make OC_Helper::mimetypeIcon available as a simple function + * @param string mimetype + * @return path to the image of this file type. */ function mimetype_icon( $mimetype ) { return(\mimetype_icon( $mimetype )); } /** - * @brief make preview_icon available as a simple function - * Returns the path to the preview of the image. - * @param $path path of file - * @returns link to the preview + * Make preview_icon available as a simple function + * @param string path of file + * @return path to the preview of the image */ function preview_icon( $path ) { return(\preview_icon( $path )); } /** - * @brief make publicpreview_icon available as a simple function + * Make publicpreview_icon available as a simple function * Returns the path to the preview of the image. - * @param $path path of file - * @returns link to the preview + * @param string path of file + * @param string token + * @return link to the preview */ function publicPreview_icon ( $path, $token ) { return(\publicPreview_icon( $path, $token )); } /** - * @brief make OC_Helper::humanFileSize available as a simple function - * Makes 2048 to 2 kB. - * @param $bytes size in bytes - * @returns size as string + * Make OC_Helper::humanFileSize available as a simple function + * Example: 2048 to 2 kB. + * @param int size in bytes + * @return size as string */ function human_file_size( $bytes ) { return(\human_file_size( $bytes )); @@ -86,20 +85,21 @@ function human_file_size( $bytes ) { /** - * @brief Return the relative date in relation to today. Returns something like "last hour" or "two month ago" - * @param $timestamp unix timestamp - * @returns human readable interpretation of the timestamp + * Return the relative date in relation to today. Returns something like "last hour" or "two month ago" + * @param int unix timestamp + * @param boolean date only + * @return human readable interpretation of the timestamp */ -function relative_modified_date($timestamp, $dateOnly = false) { +function relative_modified_date( $timestamp, $dateOnly = false ) { return(\relative_modified_date($timestamp, null, $dateOnly)); } /** - * @brief DEPRECATED Return a human readable outout for a file size. + * Return a human readable outout for a file size. * @deprecated human_file_size() instead - * @param $byte size of a file in byte - * @returns human readable interpretation of a file size + * @param integer size of a file in byte + * @return human readable interpretation of a file size */ function simple_file_size($bytes) { return(\human_file_size($bytes)); @@ -107,11 +107,11 @@ function simple_file_size($bytes) { /** - * @brief Generate html code for an options block. + * Generate html code for an options block. * @param $options the options * @param $selected which one is selected? - * @param $params the parameters - * @returns html options + * @param array the parameters + * @return html options */ function html_select_options($options, $selected, $params=array()) { return(\html_select_options($options, $selected, $params)); diff --git a/lib/public/user.php b/lib/public/user.php index 576a64d7048..b4931ecc0fa 100644 --- a/lib/public/user.php +++ b/lib/public/user.php @@ -36,7 +36,7 @@ namespace OCP; */ class User { /** - * @brief get the user id of the user currently logged in. + * Get the user id of the user currently logged in. * @return string uid or false */ public static function getUser() { @@ -44,45 +44,46 @@ class User { } /** - * @brief Get a list of all users - * @returns array with all uids - * - * Get a list of all users. + * Get a list of all users + * @param string search pattern + * @param int limit + * @param int offset + * @return array with all uids */ - public static function getUsers($search = '', $limit = null, $offset = null) { - return \OC_User::getUsers($search, $limit, $offset); + public static function getUsers( $search = '', $limit = null, $offset = null ) { + return \OC_User::getUsers( $search, $limit, $offset ); } /** - * @brief get the user display name of the user currently logged in. + * Get the user display name of the user currently logged in. + * @param string user id or null for current user * @return string display name */ - public static function getDisplayName($user=null) { - return \OC_User::getDisplayName($user); + public static function getDisplayName( $user = null ) { + return \OC_User::getDisplayName( $user ); } /** - * @brief Get a list of all display names - * @returns array with all display names (value) and the correspondig uids (key) - * * Get a list of all display names and user ids. + * @param string search pattern + * @param int limit + * @param int offset + * @return array with all display names (value) and the correspondig uids (key) */ - public static function getDisplayNames($search = '', $limit = null, $offset = null) { - return \OC_User::getDisplayNames($search, $limit, $offset); + public static function getDisplayNames( $search = '', $limit = null, $offset = null ) { + return \OC_User::getDisplayNames( $search, $limit, $offset ); } /** - * @brief Check if the user is logged in - * @returns true/false - * - * Checks if the user is logged in + * Check if the user is logged in + * @return boolean */ public static function isLoggedIn() { return \OC_User::isLoggedIn(); } /** - * @brief check if a user exists + * Check if a user exists * @param string $uid the username * @param string $excludingBackend (default none) * @return boolean @@ -91,7 +92,7 @@ class User { return \OC_User::userExists( $uid, $excludingBackend ); } /** - * @brief Loggs the user out including all the session data + * Logs the user out including all the session data * Logout, destroys session */ public static function logout() { @@ -99,10 +100,10 @@ class User { } /** - * @brief Check if the password is correct - * @param $uid The username - * @param $password The password - * @returns mixed username on success, false otherwise + * Check if the password is correct + * @param string The username + * @param string The password + * @return mixed username on success, false otherwise * * Check if the password is correct without logging in the user */ diff --git a/tests/data/openssl.cnf b/tests/data/openssl.cnf new file mode 100644 index 00000000000..1eb86c40126 --- /dev/null +++ b/tests/data/openssl.cnf @@ -0,0 +1,350 @@ +# +# OpenSSL example configuration file. +# This is mostly being used for generation of certificate requests. +# + +# This definition stops the following lines choking if HOME isn't +# defined. +HOME = . +RANDFILE = $ENV::HOME/.rnd + +# Extra OBJECT IDENTIFIER info: +#oid_file = $ENV::HOME/.oid +oid_section = new_oids + +# To use this configuration file with the "-extfile" option of the +# "openssl x509" utility, name here the section containing the +# X.509v3 extensions to use: +# extensions = +# (Alternatively, use a configuration file that has only +# X.509v3 extensions in its main [= default] section.) + +[ new_oids ] + +# We can add new OIDs in here for use by 'ca', 'req' and 'ts'. +# Add a simple OID like this: +# testoid1=1.2.3.4 +# Or use config file substitution like this: +# testoid2=${testoid1}.5.6 + +# Policies used by the TSA examples. +tsa_policy1 = 1.2.3.4.1 +tsa_policy2 = 1.2.3.4.5.6 +tsa_policy3 = 1.2.3.4.5.7 + +#################################################################### +[ ca ] +default_ca = CA_default # The default ca section + +#################################################################### +[ CA_default ] + +dir = ./demoCA # Where everything is kept +certs = $dir/certs # Where the issued certs are kept +crl_dir = $dir/crl # Where the issued crl are kept +database = $dir/index.txt # database index file. +#unique_subject = no # Set to 'no' to allow creation of + # several ctificates with same subject. +new_certs_dir = $dir/newcerts # default place for new certs. + +certificate = $dir/cacert.pem # The CA certificate +serial = $dir/serial # The current serial number +crlnumber = $dir/crlnumber # the current crl number + # must be commented out to leave a V1 CRL +crl = $dir/crl.pem # The current CRL +private_key = $dir/private/cakey.pem# The private key +RANDFILE = $dir/private/.rand # private random number file + +x509_extensions = usr_cert # The extentions to add to the cert + +# Comment out the following two lines for the "traditional" +# (and highly broken) format. +name_opt = ca_default # Subject Name options +cert_opt = ca_default # Certificate field options + +# Extension copying option: use with caution. +# copy_extensions = copy + +# Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs +# so this is commented out by default to leave a V1 CRL. +# crlnumber must also be commented out to leave a V1 CRL. +# crl_extensions = crl_ext + +default_days = 365 # how long to certify for +default_crl_days= 30 # how long before next CRL +default_md = default # use public key default MD +preserve = no # keep passed DN ordering + +# A few difference way of specifying how similar the request should look +# For type CA, the listed attributes must be the same, and the optional +# and supplied fields are just that :-) +policy = policy_match + +# For the CA policy +[ policy_match ] +countryName = match +stateOrProvinceName = match +organizationName = match +organizationalUnitName = optional +commonName = supplied +emailAddress = optional + +# For the 'anything' policy +# At this point in time, you must list all acceptable 'object' +# types. +[ policy_anything ] +countryName = optional +stateOrProvinceName = optional +localityName = optional +organizationName = optional +organizationalUnitName = optional +commonName = supplied +emailAddress = optional + +#################################################################### +[ req ] +default_bits = 2048 +default_keyfile = privkey.pem +distinguished_name = req_distinguished_name +attributes = req_attributes +x509_extensions = v3_ca # The extentions to add to the self signed cert + +# Passwords for private keys if not present they will be prompted for +# input_password = secret +# output_password = secret + +# This sets a mask for permitted string types. There are several options. +# default: PrintableString, T61String, BMPString. +# pkix : PrintableString, BMPString (PKIX recommendation before 2004) +# utf8only: only UTF8Strings (PKIX recommendation after 2004). +# nombstr : PrintableString, T61String (no BMPStrings or UTF8Strings). +# MASK:XXXX a literal mask value. +# WARNING: ancient versions of Netscape crash on BMPStrings or UTF8Strings. +string_mask = utf8only + +# req_extensions = v3_req # The extensions to add to a certificate request + +[ req_distinguished_name ] +countryName = Country Name (2 letter code) +countryName_default = AU +countryName_min = 2 +countryName_max = 2 + +stateOrProvinceName = State or Province Name (full name) +stateOrProvinceName_default = Some-State + +localityName = Locality Name (eg, city) + +0.organizationName = Organization Name (eg, company) +0.organizationName_default = Internet Widgits Pty Ltd + +# we can do this but it is not needed normally :-) +#1.organizationName = Second Organization Name (eg, company) +#1.organizationName_default = World Wide Web Pty Ltd + +organizationalUnitName = Organizational Unit Name (eg, section) +#organizationalUnitName_default = + +commonName = Common Name (e.g. server FQDN or YOUR name) +commonName_max = 64 + +emailAddress = Email Address +emailAddress_max = 64 + +# SET-ex3 = SET extension number 3 + +[ req_attributes ] +challengePassword = A challenge password +challengePassword_min = 4 +challengePassword_max = 20 + +unstructuredName = An optional company name + +[ usr_cert ] + +# These extensions are added when 'ca' signs a request. + +# This goes against PKIX guidelines but some CAs do it and some software +# requires this to avoid interpreting an end user certificate as a CA. + +basicConstraints=CA:FALSE + +# Here are some examples of the usage of nsCertType. If it is omitted +# the certificate can be used for anything *except* object signing. + +# This is OK for an SSL server. +# nsCertType = server + +# For an object signing certificate this would be used. +# nsCertType = objsign + +# For normal client use this is typical +# nsCertType = client, email + +# and for everything including object signing: +# nsCertType = client, email, objsign + +# This is typical in keyUsage for a client certificate. +# keyUsage = nonRepudiation, digitalSignature, keyEncipherment + +# This will be displayed in Netscape's comment listbox. +nsComment = "OpenSSL Generated Certificate" + +# PKIX recommendations harmless if included in all certificates. +subjectKeyIdentifier=hash +authorityKeyIdentifier=keyid,issuer + +# This stuff is for subjectAltName and issuerAltname. +# Import the email address. +# subjectAltName=email:copy +# An alternative to produce certificates that aren't +# deprecated according to PKIX. +# subjectAltName=email:move + +# Copy subject details +# issuerAltName=issuer:copy + +#nsCaRevocationUrl = http://www.domain.dom/ca-crl.pem +#nsBaseUrl +#nsRevocationUrl +#nsRenewalUrl +#nsCaPolicyUrl +#nsSslServerName + +# This is required for TSA certificates. +# extendedKeyUsage = critical,timeStamping + +[ v3_req ] + +# Extensions to add to a certificate request + +basicConstraints = CA:FALSE +keyUsage = nonRepudiation, digitalSignature, keyEncipherment + +[ v3_ca ] + + +# Extensions for a typical CA + + +# PKIX recommendation. + +subjectKeyIdentifier=hash + +authorityKeyIdentifier=keyid:always,issuer + +# This is what PKIX recommends but some broken software chokes on critical +# extensions. +#basicConstraints = critical,CA:true +# So we do this instead. +basicConstraints = CA:true + +# Key usage: this is typical for a CA certificate. However since it will +# prevent it being used as an test self-signed certificate it is best +# left out by default. +# keyUsage = cRLSign, keyCertSign + +# Some might want this also +# nsCertType = sslCA, emailCA + +# Include email address in subject alt name: another PKIX recommendation +# subjectAltName=email:copy +# Copy issuer details +# issuerAltName=issuer:copy + +# DER hex encoding of an extension: beware experts only! +# obj=DER:02:03 +# Where 'obj' is a standard or added object +# You can even override a supported extension: +# basicConstraints= critical, DER:30:03:01:01:FF + +[ crl_ext ] + +# CRL extensions. +# Only issuerAltName and authorityKeyIdentifier make any sense in a CRL. + +# issuerAltName=issuer:copy +authorityKeyIdentifier=keyid:always + +[ proxy_cert_ext ] +# These extensions should be added when creating a proxy certificate + +# This goes against PKIX guidelines but some CAs do it and some software +# requires this to avoid interpreting an end user certificate as a CA. + +basicConstraints=CA:FALSE + +# Here are some examples of the usage of nsCertType. If it is omitted +# the certificate can be used for anything *except* object signing. + +# This is OK for an SSL server. +# nsCertType = server + +# For an object signing certificate this would be used. +# nsCertType = objsign + +# For normal client use this is typical +# nsCertType = client, email + +# and for everything including object signing: +# nsCertType = client, email, objsign + +# This is typical in keyUsage for a client certificate. +# keyUsage = nonRepudiation, digitalSignature, keyEncipherment + +# This will be displayed in Netscape's comment listbox. +nsComment = "OpenSSL Generated Certificate" + +# PKIX recommendations harmless if included in all certificates. +subjectKeyIdentifier=hash +authorityKeyIdentifier=keyid,issuer + +# This stuff is for subjectAltName and issuerAltname. +# Import the email address. +# subjectAltName=email:copy +# An alternative to produce certificates that aren't +# deprecated according to PKIX. +# subjectAltName=email:move + +# Copy subject details +# issuerAltName=issuer:copy + +#nsCaRevocationUrl = http://www.domain.dom/ca-crl.pem +#nsBaseUrl +#nsRevocationUrl +#nsRenewalUrl +#nsCaPolicyUrl +#nsSslServerName + +# This really needs to be in place for it to be a proxy certificate. +proxyCertInfo=critical,language:id-ppl-anyLanguage,pathlen:3,policy:foo + +#################################################################### +[ tsa ] + +default_tsa = tsa_config1 # the default TSA section + +[ tsa_config1 ] + +# These are used by the TSA reply generation only. +dir = ./demoCA # TSA root directory +serial = $dir/tsaserial # The current serial number (mandatory) +crypto_device = builtin # OpenSSL engine to use for signing +signer_cert = $dir/tsacert.pem # The TSA signing certificate + # (optional) +certs = $dir/cacert.pem # Certificate chain to include in reply + # (optional) +signer_key = $dir/private/tsakey.pem # The TSA private key (optional) + +default_policy = tsa_policy1 # Policy if request did not specify it + # (optional) +other_policies = tsa_policy2, tsa_policy3 # acceptable policies (optional) +digests = md5, sha1 # Acceptable message digests (mandatory) +accuracy = secs:1, millisecs:500, microsecs:100 # (optional) +clock_precision_digits = 0 # number of digits after dot. (optional) +ordering = yes # Is ordering defined for timestamps? + # (optional, default: no) +tsa_name = yes # Must the TSA name be included in the reply? + # (optional, default: no) +ess_cert_id_chain = no # Must the ESS cert id chain be included? + # (optional, default: no) diff --git a/tests/preseed-config.php b/tests/preseed-config.php index 9791e713dac..95ffb4514bf 100644 --- a/tests/preseed-config.php +++ b/tests/preseed-config.php @@ -16,4 +16,9 @@ $CONFIG = array ( 'writable' => false, ) ), + ); + +if(substr(strtolower(PHP_OS), 0, 3) == "win") { + $CONFIG['openssl'] = array( 'config' => OC::$SERVERROOT.'/tests/data/openssl.cnf'); +} diff --git a/tests/win32-phpunit.php b/tests/win32-phpunit.php deleted file mode 100644 index ac8f95efcbf..00000000000 --- a/tests/win32-phpunit.php +++ /dev/null @@ -1,347 +0,0 @@ -<?php -OC_PHPUnit_Loader::checkIncludePath(); -OC_PHPUnit_Loader::detectPHPUnitVersionId(); - -//load PHPUnit -switch (OC_PHPUnit_Loader::$PHPUnitVersionId) { - case "36": { - OC_PHPUnit_Loader::load36(); - break; - } - case "37": { - OC_PHPUnit_Loader::load37(); - break; - } -} - -//load custom implementation of the PHPUnit_TextUI_ResultPrinter -switch (OC_PHPUnit_Loader::$PHPUnitVersionId) { - case "36": - case "37": { - class OC_PHPUnit_TextUI_ResultPrinter extends PHPUnit_TextUI_ResultPrinter - { - function __construct() - { - parent::__construct('php://stderr'); - } - - public function printResult(PHPUnit_Framework_TestResult $result) - { - $this->printHeader(); - $this->printFooter($result); - } - - protected function writeProgress($progress) - { - //ignore - } - } - break; - } -} - -//loading of OC_PHPUnit_TextUI_Command -switch (OC_PHPUnit_Loader::$PHPUnitVersionId) { - case "36": - case "37": { - class OC_PHPUnit_TextUI_Command extends PHPUnit_TextUI_Command - { - - public static function main($exit = TRUE) - { - $command = new OC_PHPUnit_TextUI_Command(); - $command->run($_SERVER['argv'], $exit); - } - - protected function handleArguments(array $argv) - { - parent::handleArguments($argv); - $this->arguments['listeners'][] = new OC_PHPUnit_Framework_TestListener(); - $this->arguments['printer'] = new OC_PHPUnit_TextUI_ResultPrinter(); - } - - protected function createRunner() - { - $coverage_Filter = new PHP_CodeCoverage_Filter(); - $coverage_Filter->addFileToBlacklist(__FILE__); - $runner = new PHPUnit_TextUI_TestRunner($this->arguments['loader'], $coverage_Filter); - return $runner; - } - } - break; - } -} - -class OC_PHPUnit_Loader -{ - - const SUCCESS_EXIT = 0; - const FAILURE_EXIT = 1; - const EXCEPTION_EXIT = 2; - - public static $PHPUnitVersionId; - - /** - * @return void - */ - public static function checkIncludePath() - { - //check include path - $PHPUnitParentDirectory = self::getPHPUnitParentDirectory(); - if (is_null($PHPUnitParentDirectory)) { - echo "Cannot find PHPUnit in include path (" . ini_get('include_path') . ")"; - exit(OC_PHPUnit_Loader::FAILURE_EXIT); - } - } - - /** - * @return null | string - */ - private static function getPHPUnitParentDirectory() - { - $pathArray = explode(PATH_SEPARATOR, ini_get('include_path')); - foreach ($pathArray as $path) - { - if (file_exists($path . DIRECTORY_SEPARATOR . 'PHPUnit/')) { - return $path; - } - } - return null; - } - - /** - * @return void - */ - public static function detectPHPUnitVersionId() - { - require_once 'PHPUnit/Runner/Version.php'; - - $PHPUnitVersion = PHPUnit_Runner_Version::id(); - - if ($PHPUnitVersion === "@package_version@") { - - self::$PHPUnitVersionId = "37"; - } - else if (version_compare($PHPUnitVersion, '3.7.0') >= 0) { - - self::$PHPUnitVersionId = "37"; - } - else if (version_compare($PHPUnitVersion, '3.6.0') >= 0) { - - self::$PHPUnitVersionId = "36"; - } - else if (version_compare($PHPUnitVersion, '3.6.0') >= 0) { - - echo "unsupported PHPUnit version: $PHPUnitVersion"; - exit(OC_PHPUnit_Loader::FAILURE_EXIT); - } - } - - /** - * @return void - */ - public static function load37() - { - - require 'PHPUnit/Autoload.php'; - - } - - - /** - * @return void - */ - public static function load36() - { - define('PHPUnit_MAIN_METHOD', 'OC_PHPUnit_TextUI_Command::main'); - - require 'PHPUnit/Autoload.php'; - - } -} - -class OC_PHPUnit_Framework_TestListener implements PHPUnit_Framework_TestListener -{ - - private $isSummaryTestCountPrinted = false; - - public static function printEvent($eventName, $params = array()) - { - self::printText("\n[$eventName"); - foreach ($params as $key => $value) { - self::printText(" $key='$value'"); - } - self::printText("]\n"); - } - - public static function printText($text) - { - file_put_contents('php://stderr', $text); - } - - private static function getMessage(Exception $e) - { - $message = ""; - if (strlen(get_class($e)) != 0) { - $message = $message . get_class($e); - } - if (strlen($message) != 0 && strlen($e->getMessage()) != 0) { - $message = $message . " : "; - } - $message = $message . $e->getMessage(); - return self::escapeValue($message); - } - - private static function getDetails(Exception $e) - { - return self::escapeValue($e->getTraceAsString()); - } - - public static function getValueAsString($value) - { - if (is_null($value)) { - return "null"; - } - else if (is_bool($value)) { - return $value == true ? "true" : "false"; - } - else if (is_array($value) || is_string($value)) { - $valueAsString = print_r($value, true); - if (strlen($valueAsString) > 10000) { - return null; - } - return $valueAsString; - } - else if (is_scalar($value)){ - return print_r($value, true); - } - return null; - } - - private static function escapeValue($text) { - $text = str_replace("|", "||", $text); - $text = str_replace("'", "|'", $text); - $text = str_replace("\n", "|n", $text); - $text = str_replace("\r", "|r", $text); - $text = str_replace("]", "|]", $text); - return $text; - } - - public static function getFileName($className) - { - $reflectionClass = new ReflectionClass($className); - $fileName = $reflectionClass->getFileName(); - return $fileName; - } - - public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) - { - self::printEvent("testFailed", array( - "name" => $test->getName(), - "message" => self::getMessage($e), - "details" => self::getDetails($e) - )); - } - - public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) - { - $params = array( - "name" => $test->getName(), - "message" => self::getMessage($e), - "details" => self::getDetails($e) - ); - if ($e instanceof PHPUnit_Framework_ExpectationFailedException) { - $comparisonFailure = $e->getComparisonFailure(); - if ($comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure) { - $actualResult = $comparisonFailure->getActual(); - $expectedResult = $comparisonFailure->getExpected(); - $actualString = self::getValueAsString($actualResult); - $expectedString = self::getValueAsString($expectedResult); - if (!is_null($actualString) && !is_null($expectedString)) { - $params['actual'] = self::escapeValue($actualString); - $params['expected'] = self::escapeValue($expectedString); - } - } - } - self::printEvent("testFailed", $params); - } - - public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) - { - self::printEvent("testIgnored", array( - "name" => $test->getName(), - "message" => self::getMessage($e), - "details" => self::getDetails($e) - )); - } - - public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) - { - self::printEvent("testIgnored", array( - "name" => $test->getName(), - "message" => self::getMessage($e), - "details" => self::getDetails($e) - )); - } - - public function startTest(PHPUnit_Framework_Test $test) - { - $testName = $test->getName(); - $params = array( - "name" => $testName - ); - if ($test instanceof PHPUnit_Framework_TestCase) { - $className = get_class($test); - $fileName = self::getFileName($className); - $params['locationHint'] = "php_qn://$fileName::\\$className::$testName"; - } - self::printEvent("testStarted", $params); - } - - public function endTest(PHPUnit_Framework_Test $test, $time) - { - self::printEvent("testFinished", array( - "name" => $test->getName(), - "duration" => (int)(round($time, 2) * 1000) - )); - } - - public function startTestSuite(PHPUnit_Framework_TestSuite $suite) - { - if (!$this->isSummaryTestCountPrinted) { - $this->isSummaryTestCountPrinted = true; - //print tests count - self::printEvent("testCount", array( - "count" => count($suite) - )); - } - - $suiteName = $suite->getName(); - if (empty($suiteName)) { - return; - } - $params = array( - "name" => $suiteName, - ); - if (class_exists($suiteName, false)) { - $fileName = self::getFileName($suiteName); - $params['locationHint'] = "php_qn://$fileName::\\$suiteName"; - } - self::printEvent("testSuiteStarted", $params); - } - - public function endTestSuite(PHPUnit_Framework_TestSuite $suite) - { - $suiteName = $suite->getName(); - if (empty($suiteName)) { - return; - } - self::printEvent("testSuiteFinished", - array( - "name" => $suite->getName() - )); - } - -} - -OC_PHPUnit_TextUI_Command::main(); |