summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-09-28 15:38:49 +0200
committerBart Visscher <bartv@thisnet.nl>2012-09-28 15:38:49 +0200
commitbf1057143cdff8ec289d9d766ab100d64d7ea45d (patch)
tree6c35d0d99a72f27a981a07c93f0ecbf600764cd4 /lib
parent3efe1d3b24e65ed76d521c24b0cfe4e0ff2e7af5 (diff)
parent5144d26088b98685a37c73c776a9a47203efa68a (diff)
downloadnextcloud-server-bf1057143cdff8ec289d9d766ab100d64d7ea45d.tar.gz
nextcloud-server-bf1057143cdff8ec289d9d766ab100d64d7ea45d.zip
Merge branch 'master' into routing
Conflicts: apps/files/js/filelist.js core/js/js.js lib/ocs.php
Diffstat (limited to 'lib')
-rwxr-xr-xlib/app.php168
-rw-r--r--lib/appconfig.php34
-rw-r--r--lib/archive/tar.php66
-rw-r--r--lib/archive/zip.php30
-rw-r--r--lib/base.php12
-rw-r--r--lib/cache/file.php2
-rw-r--r--lib/cache/xcache.php10
-rw-r--r--lib/config.php22
-rw-r--r--lib/connector/sabre/auth.php2
-rw-r--r--lib/connector/sabre/directory.php23
-rw-r--r--lib/connector/sabre/node.php12
-rw-r--r--lib/connector/sabre/principal.php12
-rw-r--r--lib/db.php133
-rw-r--r--lib/filecache.php2
-rw-r--r--lib/filecache/cached.php21
-rw-r--r--lib/filecache/update.php52
-rw-r--r--lib/filechunking.php58
-rw-r--r--lib/fileproxy/quota.php8
-rw-r--r--lib/files.php49
-rw-r--r--lib/filestorage/local.php2
-rw-r--r--lib/filesystem.php3
-rw-r--r--lib/filesystemview.php158
-rw-r--r--lib/group.php52
-rw-r--r--lib/group/backend.php27
-rw-r--r--lib/group/database.php47
-rw-r--r--lib/group/interface.php27
-rw-r--r--lib/helper.php154
-rw-r--r--lib/hook.php24
-rw-r--r--lib/image.php38
-rw-r--r--lib/l10n.php2
-rw-r--r--lib/l10n/da.php5
-rw-r--r--lib/l10n/de.php4
-rw-r--r--lib/l10n/el.php7
-rw-r--r--lib/l10n/eo.php5
-rw-r--r--lib/l10n/es_AR.php28
-rw-r--r--lib/l10n/et_EE.php5
-rw-r--r--lib/l10n/gl.php28
-rw-r--r--lib/l10n/pt_BR.php28
-rw-r--r--lib/l10n/ro.php28
-rw-r--r--lib/l10n/ru.php2
-rw-r--r--lib/l10n/ru_RU.php27
-rw-r--r--lib/l10n/sk_SK.php25
-rw-r--r--lib/l10n/sl.php6
-rw-r--r--lib/l10n/uk.php3
-rw-r--r--lib/l10n/vi.php28
-rw-r--r--lib/l10n/zh_CN.GB2312.php28
-rw-r--r--lib/migrate.php14
-rw-r--r--lib/migration/content.php19
-rw-r--r--lib/ocs.php146
-rw-r--r--lib/ocsclient.php2
-rw-r--r--lib/preferences.php66
-rw-r--r--lib/public/app.php169
-rw-r--r--lib/public/config.php117
-rw-r--r--lib/public/db.php9
-rw-r--r--lib/public/files.php23
-rw-r--r--lib/public/json.php2
-rw-r--r--lib/public/response.php10
-rw-r--r--lib/public/share.php179
-rw-r--r--lib/public/user.php38
-rw-r--r--lib/public/util.php33
-rw-r--r--lib/search/provider/file.php8
-rw-r--r--lib/setup.php388
-rw-r--r--lib/template.php94
-rw-r--r--lib/templatelayout.php12
-rw-r--r--lib/user.php43
-rw-r--r--lib/user/database.php2
-rwxr-xr-xlib/util.php24
-rw-r--r--lib/vcategories.php5
68 files changed, 1765 insertions, 1145 deletions
diff --git a/lib/app.php b/lib/app.php
index f5c328afe7c..7889339e420 100755
--- a/lib/app.php
+++ b/lib/app.php
@@ -40,7 +40,7 @@ class OC_App{
/**
* @brief loads all apps
* @param array $types
- * @returns true/false
+ * @return bool
*
* This function walks through the owncloud directory and loads all apps
* it can find. A directory contains an app if the file /appinfo/app.php
@@ -62,16 +62,13 @@ class OC_App{
ob_end_clean();
if (!defined('DEBUG') || !DEBUG) {
- if (is_null($types)) {
+ if (is_null($types)
+ && empty(OC_Util::$core_scripts)
+ && empty(OC_Util::$core_styles)) {
OC_Util::$core_scripts = OC_Util::$scripts;
OC_Util::$scripts = array();
OC_Util::$core_styles = OC_Util::$styles;
OC_Util::$styles = array();
-
- if (!OC_AppConfig::getValue('core', 'remote_core.css', false)) {
- OC_AppConfig::setValue('core', 'remote_core.css', '/core/minimizer.php');
- OC_AppConfig::setValue('core', 'remote_core.js', '/core/minimizer.php');
- }
}
}
// return
@@ -80,7 +77,7 @@ class OC_App{
/**
* load a single app
- * @param string app
+ * @param string $app
*/
public static function loadApp($app) {
if(is_file(self::getAppPath($app).'/appinfo/app.php')) {
@@ -93,6 +90,7 @@ class OC_App{
* check if an app is of a specific type
* @param string $app
* @param string/array $types
+ * @return bool
*/
public static function isType($app,$types) {
if(is_string($types)) {
@@ -159,8 +157,8 @@ class OC_App{
/**
* @brief checks whether or not an app is enabled
- * @param $app app
- * @returns true/false
+ * @param string $app app
+ * @return bool
*
* This function checks whether or not an app is enabled.
*/
@@ -174,8 +172,8 @@ class OC_App{
/**
* @brief enables an app
- * @param $app app
- * @returns true/false
+ * @param mixed $app app
+ * @return bool
*
* This function set an app as enabled in appconfig.
*/
@@ -205,13 +203,12 @@ class OC_App{
}else{
return false;
}
- return $app;
}
/**
* @brief disables an app
- * @param $app app
- * @returns true/false
+ * @param string $app app
+ * @return bool
*
* This function set an app as disabled in appconfig.
*/
@@ -222,8 +219,8 @@ class OC_App{
/**
* @brief adds an entry to the navigation
- * @param $data array containing the data
- * @returns true/false
+ * @param string $data array containing the data
+ * @return bool
*
* This function adds a new entry to the navigation visible to users. $data
* is an associative array.
@@ -248,8 +245,8 @@ class OC_App{
/**
* @brief marks a navigation entry as active
- * @param $id id of the entry
- * @returns true/false
+ * @param string $id id of the entry
+ * @return bool
*
* This function sets a navigation entry as active and removes the 'active'
* property from all other entries. The templates can use this for
@@ -262,7 +259,7 @@ class OC_App{
/**
* @brief gets the active Menu entry
- * @returns id or empty string
+ * @return string id or empty string
*
* This function returns the id of the active navigation entry (set by
* setActiveNavigationEntry
@@ -273,7 +270,7 @@ class OC_App{
/**
* @brief Returns the Settings Navigation
- * @returns associative array
+ * @return array
*
* This function returns an array containing all settings pages added. The
* entries are sorted by the key 'order' ascending.
@@ -294,7 +291,7 @@ class OC_App{
// personal menu
$settings[] = array( "id" => "personal", "order" => 1, "href" => OC_Helper::linkTo( "settings", "personal.php" ), "name" => $l->t("Personal"), "icon" => OC_Helper::imagePath( "settings", "personal.svg" ));
- // if there're some settings forms
+ // if there are some settings forms
if(!empty(self::$settingsForms))
// settings menu
$settings[]=array( "id" => "settings", "order" => 1000, "href" => OC_Helper::linkTo( "settings", "settings.php" ), "name" => $l->t("Settings"), "icon" => OC_Helper::imagePath( "settings", "settings.svg" ));
@@ -364,6 +361,7 @@ class OC_App{
return $app_dir[$appid]=$dir;
}
}
+ return false;
}
/**
* Get the directory for the given app.
@@ -373,6 +371,7 @@ class OC_App{
if( ($dir = self::findAppInDirectories($appid)) != false) {
return $dir['path'].'/'.$appid;
}
+ return false;
}
/**
@@ -383,6 +382,7 @@ class OC_App{
if( ($dir = self::findAppInDirectories($appid)) != false) {
return OC::$WEBROOT.$dir['url'].'/'.$appid;
}
+ return false;
}
/**
@@ -400,10 +400,11 @@ class OC_App{
}
/**
- * @brief Read app metadata from the info.xml file
+ * @brief Read all app metadata from the info.xml file
* @param string $appid id of the app or the path of the info.xml file
- * @param boolean path (optional)
- * @returns array
+ * @param boolean $path (optional)
+ * @return array
+ * @note all data is read from info.xml, not just pre-defined fields
*/
public static function getAppInfo($appid,$path=false) {
if($path) {
@@ -417,24 +418,36 @@ class OC_App{
$data=array();
$content=@file_get_contents($file);
if(!$content) {
- return;
+ return null;
}
$xml = new SimpleXMLElement($content);
$data['info']=array();
$data['remote']=array();
$data['public']=array();
foreach($xml->children() as $child) {
+ /**
+ * @var $child SimpleXMLElement
+ */
if($child->getName()=='remote') {
foreach($child->children() as $remote) {
+ /**
+ * @var $remote SimpleXMLElement
+ */
$data['remote'][$remote->getName()]=(string)$remote;
}
}elseif($child->getName()=='public') {
foreach($child->children() as $public) {
+ /**
+ * @var $public SimpleXMLElement
+ */
$data['public'][$public->getName()]=(string)$public;
}
}elseif($child->getName()=='types') {
$data['types']=array();
foreach($child->children() as $type) {
+ /**
+ * @var $type SimpleXMLElement
+ */
$data['types'][]=$type->getName();
}
}elseif($child->getName()=='description') {
@@ -445,12 +458,13 @@ class OC_App{
}
}
self::$appInfo[$appid]=$data;
+
return $data;
}
/**
* @brief Returns the navigation
- * @returns associative array
+ * @return array
*
* This function returns an array containing all entries added. The
* entries are sorted by the key 'order' ascending. Additional to the keys
@@ -495,6 +509,8 @@ class OC_App{
case 'personal':
$source=self::$personalForms;
break;
+ default:
+ return array();
}
foreach($source as $form) {
$forms[]=include $form;
@@ -524,20 +540,90 @@ class OC_App{
}
/**
- * get a list of all apps in the apps folder
+ * @brief: get a list of all apps in the apps folder
+ * @return array or app names (string IDs)
+ * @todo: change the name of this method to getInstalledApps, which is more accurate
*/
public static function getAllApps() {
+
$apps=array();
- foreach(OC::$APPSROOTS as $apps_dir) {
- $dh=opendir($apps_dir['path']);
- while($file=readdir($dh)) {
- if($file[0]!='.' and is_file($apps_dir['path'].'/'.$file.'/appinfo/app.php')) {
- $apps[]=$file;
+
+ foreach ( OC::$APPSROOTS as $apps_dir ) {
+ if(! is_readable($apps_dir['path'])) {
+ OC_Log::write('core', 'unable to read app folder : ' .$apps_dir['path'] , OC_Log::WARN);
+ continue;
+ }
+ $dh = opendir( $apps_dir['path'] );
+
+ while( $file = readdir( $dh ) ) {
+
+ if (
+ $file[0] != '.'
+ and is_file($apps_dir['path'].'/'.$file.'/appinfo/app.php' )
+ ) {
+
+ $apps[] = $file;
+
}
+
}
+
}
+
return $apps;
}
+
+ /**
+ * @brief: get a list of all apps on apps.owncloud.com
+ * @return array, multi-dimensional array of apps. Keys: id, name, type, typename, personid, license, detailpage, preview, changed, description
+ */
+ public static function getAppstoreApps( $filter = 'approved' ) {
+
+ $catagoryNames = OC_OCSClient::getCategories();
+
+ if ( is_array( $catagoryNames ) ) {
+
+ // Check that categories of apps were retrieved correctly
+ if ( ! $categories = array_keys( $catagoryNames ) ) {
+
+ return false;
+
+ }
+
+ $page = 0;
+
+ $remoteApps = OC_OCSClient::getApplications( $categories, $page, $filter );
+
+ $app1 = array();
+
+ $i = 0;
+
+ foreach ( $remoteApps as $app ) {
+
+ $app1[$i] = $app;
+
+ $app1[$i]['author'] = $app['personid'];
+
+ $app1[$i]['ocs_id'] = $app['id'];
+
+ $app1[$i]['internal'] = $app1[$i]['active'] = 0;
+
+ $i++;
+
+ }
+
+ }
+
+ if ( empty( $app1 ) ) {
+
+ return false;
+
+ } else {
+
+ return $app1;
+
+ }
+ }
/**
* check if the app need updating and update when needed
@@ -553,7 +639,13 @@ class OC_App{
$installedVersion = $versions[$app];
if (version_compare($currentVersion, $installedVersion, '>')) {
OC_Log::write($app, 'starting app upgrade from '.$installedVersion.' to '.$currentVersion, OC_Log::DEBUG);
- OC_App::updateApp($app);
+ try {
+ OC_App::updateApp($app);
+ }
+ catch (Exception $e) {
+ echo 'Failed to upgrade "'.$app.'". Exception="'.$e->getMessage().'"';
+ die;
+ }
OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app));
}
}
@@ -599,7 +691,7 @@ class OC_App{
/**
* update the database for the app and call the update script
- * @param string appid
+ * @param string $appid
*/
public static function updateApp($appid) {
if(file_exists(self::getAppPath($appid).'/appinfo/database.xml')) {
@@ -613,7 +705,7 @@ class OC_App{
include self::getAppPath($appid).'/appinfo/update.php';
}
- //set remote/public handelers
+ //set remote/public handlers
$appData=self::getAppInfo($appid);
foreach($appData['remote'] as $name=>$path) {
OCP\CONFIG::setAppValue('core', 'remote_'.$name, $appid.'/'.$path);
@@ -626,7 +718,7 @@ class OC_App{
}
/**
- * @param string appid
+ * @param string $appid
* @return OC_FilesystemView
*/
public static function getStorage($appid) {
@@ -643,7 +735,7 @@ class OC_App{
}
}else{
OC_Log::write('core', 'Can\'t get app storage, app '.$appid.' not enabled', OC_Log::ERROR);
- false;
+ return false;
}
}
}
diff --git a/lib/appconfig.php b/lib/appconfig.php
index 7f58b878504..6604e854d55 100644
--- a/lib/appconfig.php
+++ b/lib/appconfig.php
@@ -40,7 +40,7 @@
class OC_Appconfig{
/**
* @brief Get all apps using the config
- * @returns array with app ids
+ * @return array with app ids
*
* This function returns a list of all apps that have at least one
* entry in the appconfig table.
@@ -60,8 +60,8 @@ class OC_Appconfig{
/**
* @brief Get the available keys for an app
- * @param $app the app we are looking for
- * @returns array with key names
+ * @param string $app the app we are looking for
+ * @return array with key names
*
* This function gets all keys of an app. Please note that the values are
* not returned.
@@ -81,13 +81,13 @@ class OC_Appconfig{
/**
* @brief Gets the config value
- * @param $app app
- * @param $key key
- * @param $default = null, default value if the key does not exist
- * @returns the value or $default
+ * @param string $app app
+ * @param string $key key
+ * @param string $default = null, default value if the key does not exist
+ * @return string the value or $default
*
* This function gets a value from the appconfig table. If the key does
- * not exist the default value will be returnes
+ * not exist the default value will be returned
*/
public static function getValue( $app, $key, $default = null ) {
// At least some magic in here :-)
@@ -114,10 +114,10 @@ class OC_Appconfig{
/**
* @brief sets a value in the appconfig
- * @param $app app
- * @param $key key
- * @param $value value
- * @returns true/false
+ * @param string $app app
+ * @param string $key key
+ * @param string $value value
+ * @return bool
*
* Sets a value. If the key did not exist before it will be created.
*/
@@ -135,9 +135,9 @@ class OC_Appconfig{
/**
* @brief Deletes a key
- * @param $app app
- * @param $key key
- * @returns true/false
+ * @param string $app app
+ * @param string $key key
+ * @return bool
*
* Deletes a key.
*/
@@ -151,8 +151,8 @@ class OC_Appconfig{
/**
* @brief Remove app from appconfig
- * @param $app app
- * @returns true/false
+ * @param string $app app
+ * @return bool
*
* Removes all keys in appconfig belonging to the app.
*/
diff --git a/lib/archive/tar.php b/lib/archive/tar.php
index ebd581fc162..639d2392b63 100644
--- a/lib/archive/tar.php
+++ b/lib/archive/tar.php
@@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
-require_once '3rdparty/Archive/Tar.php';
+require_once 'Archive/Tar.php';
class OC_Archive_TAR extends OC_Archive{
const PLAIN=0;
@@ -24,7 +24,7 @@ class OC_Archive_TAR extends OC_Archive{
function __construct($source) {
$types=array(null,'gz','bz');
$this->path=$source;
- $this->tar=new Archive_Tar($source,$types[self::getTarType($source)]);
+ $this->tar=new Archive_Tar($source, $types[self::getTarType($source)]);
}
/**
@@ -33,8 +33,8 @@ class OC_Archive_TAR extends OC_Archive{
* @return str
*/
static public function getTarType($file) {
- if(strpos($file,'.')) {
- $extension=substr($file,strrpos($file,'.'));
+ if(strpos($file, '.')) {
+ $extension=substr($file, strrpos($file, '.'));
switch($extension) {
case 'gz':
case 'tgz':
@@ -57,13 +57,13 @@ class OC_Archive_TAR extends OC_Archive{
*/
function addFolder($path) {
$tmpBase=OC_Helper::tmpFolder();
- if(substr($path,-1,1)!='/') {
+ if(substr($path, -1, 1)!='/') {
$path.='/';
}
if($this->fileExists($path)) {
return false;
}
- $parts=explode('/',$path);
+ $parts=explode('/', $path);
$folder=$tmpBase;
foreach($parts as $part) {
$folder.='/'.$part;
@@ -71,7 +71,7 @@ class OC_Archive_TAR extends OC_Archive{
mkdir($folder);
}
}
- $result=$this->tar->addModify(array($tmpBase.$path),'',$tmpBase);
+ $result=$this->tar->addModify(array($tmpBase.$path), '', $tmpBase);
rmdir($tmpBase.$path);
$this->fileList=false;
return $result;
@@ -90,9 +90,9 @@ class OC_Archive_TAR extends OC_Archive{
$header=array();
$dummy='';
$this->tar->_openAppend();
- $result=$this->tar->_addfile($source,$header,$dummy,$dummy,$path);
+ $result=$this->tar->_addfile($source, $header, $dummy, $dummy, $path);
}else{
- $result=$this->tar->addString($path,$source);
+ $result=$this->tar->addString($path, $source);
}
$this->fileList=false;
return $result;
@@ -108,12 +108,12 @@ class OC_Archive_TAR extends OC_Archive{
//no proper way to delete, rename entire archive, rename file and remake archive
$tmp=OCP\Files::tmpFolder();
$this->tar->extract($tmp);
- rename($tmp.$source,$tmp.$dest);
+ rename($tmp.$source, $tmp.$dest);
$this->tar=null;
unlink($this->path);
- $types=array(null,'gz','bz');
- $this->tar=new Archive_Tar($this->path,$types[self::getTarType($this->path)]);
- $this->tar->createModify(array($tmp),'',$tmp.'/');
+ $types=array(null, 'gz', 'bz');
+ $this->tar=new Archive_Tar($this->path, $types[self::getTarType($this->path)]);
+ $this->tar->createModify(array($tmp), '', $tmp.'/');
$this->fileList=false;
return true;
}
@@ -158,14 +158,14 @@ class OC_Archive_TAR extends OC_Archive{
$pathLength=strlen($path);
foreach($files as $file) {
if($file[0]=='/') {
- $file=substr($file,1);
+ $file=substr($file, 1);
}
- if(substr($file,0,$pathLength)==$path and $file!=$path) {
- $result=substr($file,$pathLength);
- if($pos=strpos($result,'/')) {
- $result=substr($result,0,$pos+1);
+ if(substr($file, 0, $pathLength)==$path and $file!=$path) {
+ $result=substr($file, $pathLength);
+ if($pos=strpos($result, '/')) {
+ $result=substr($result, 0, $pos+1);
}
- if(array_search($result,$folderContent)===false) {
+ if(array_search($result, $folderContent)===false) {
$folderContent[]=$result;
}
}
@@ -208,12 +208,12 @@ class OC_Archive_TAR extends OC_Archive{
return false;
}
if($this->fileExists('/'.$path)) {
- $success=$this->tar->extractList(array('/'.$path),$tmp);
+ $success=$this->tar->extractList(array('/'.$path), $tmp);
}else{
- $success=$this->tar->extractList(array($path),$tmp);
+ $success=$this->tar->extractList(array($path), $tmp);
}
if($success) {
- rename($tmp.$path,$dest);
+ rename($tmp.$path, $dest);
}
OCP\Files::rmdirr($tmp);
return $success;
@@ -234,16 +234,16 @@ class OC_Archive_TAR extends OC_Archive{
*/
function fileExists($path) {
$files=$this->getFiles();
- if((array_search($path,$files)!==false) or (array_search($path.'/',$files)!==false)) {
+ if((array_search($path, $files)!==false) or (array_search($path.'/', $files)!==false)) {
return true;
}else{
$folderPath=$path;
- if(substr($folderPath,-1,1)!='/') {
+ if(substr($folderPath, -1, 1)!='/') {
$folderPath.='/';
}
$pathLength=strlen($folderPath);
foreach($files as $file) {
- if(strlen($file)>$pathLength and substr($file,0,$pathLength)==$folderPath) {
+ if(strlen($file)>$pathLength and substr($file, 0, $pathLength)==$folderPath) {
return true;
}
}
@@ -272,7 +272,7 @@ class OC_Archive_TAR extends OC_Archive{
$this->tar=null;
unlink($this->path);
$this->reopen();
- $this->tar->createModify(array($tmp),'',$tmp);
+ $this->tar->createModify(array($tmp), '', $tmp);
return true;
}
/**
@@ -282,23 +282,23 @@ class OC_Archive_TAR extends OC_Archive{
* @return resource
*/
function getStream($path,$mode) {
- if(strrpos($path,'.')!==false) {
- $ext=substr($path,strrpos($path,'.'));
+ if(strrpos($path, '.')!==false) {
+ $ext=substr($path, strrpos($path, '.'));
}else{
$ext='';
}
$tmpFile=OCP\Files::tmpFile($ext);
if($this->fileExists($path)) {
- $this->extractFile($path,$tmpFile);
+ $this->extractFile($path, $tmpFile);
}elseif($mode=='r' or $mode=='rb') {
return false;
}
if($mode=='r' or $mode=='rb') {
- return fopen($tmpFile,$mode);
+ return fopen($tmpFile, $mode);
}else{
OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack');
self::$tempFiles[$tmpFile]=$path;
- return fopen('close://'.$tmpFile,$mode);
+ return fopen('close://'.$tmpFile, $mode);
}
}
@@ -308,7 +308,7 @@ class OC_Archive_TAR extends OC_Archive{
*/
function writeBack($tmpFile) {
if(isset(self::$tempFiles[$tmpFile])) {
- $this->addFile(self::$tempFiles[$tmpFile],$tmpFile);
+ $this->addFile(self::$tempFiles[$tmpFile], $tmpFile);
unlink($tmpFile);
}
}
@@ -322,6 +322,6 @@ class OC_Archive_TAR extends OC_Archive{
$this->tar=null;
}
$types=array(null,'gz','bz');
- $this->tar=new Archive_Tar($this->path,$types[self::getTarType($this->path)]);
+ $this->tar=new Archive_Tar($this->path, $types[self::getTarType($this->path)]);
}
}
diff --git a/lib/archive/zip.php b/lib/archive/zip.php
index 45992ee3d89..a2b07f1a35d 100644
--- a/lib/archive/zip.php
+++ b/lib/archive/zip.php
@@ -16,9 +16,9 @@ class OC_Archive_ZIP extends OC_Archive{
function __construct($source) {
$this->path=$source;
$this->zip=new ZipArchive();
- if($this->zip->open($source,ZipArchive::CREATE)) {
+ if($this->zip->open($source, ZipArchive::CREATE)) {
}else{
- OCP\Util::writeLog('files_archive','Error while opening archive '.$source,OCP\Util::WARN);
+ OCP\Util::writeLog('files_archive', 'Error while opening archive '.$source, OCP\Util::WARN);
}
}
/**
@@ -37,9 +37,9 @@ class OC_Archive_ZIP extends OC_Archive{
*/
function addFile($path,$source='') {
if($source and $source[0]=='/' and file_exists($source)) {
- $result=$this->zip->addFile($source,$path);
+ $result=$this->zip->addFile($source, $path);
}else{
- $result=$this->zip->addFromString($path,$source);
+ $result=$this->zip->addFromString($path, $source);
}
if($result) {
$this->zip->close();//close and reopen to save the zip
@@ -56,7 +56,7 @@ class OC_Archive_ZIP extends OC_Archive{
function rename($source,$dest) {
$source=$this->stripPath($source);
$dest=$this->stripPath($dest);
- $this->zip->renameName($source,$dest);
+ $this->zip->renameName($source, $dest);
}
/**
* get the uncompressed size of a file in the archive
@@ -85,9 +85,9 @@ class OC_Archive_ZIP extends OC_Archive{
$folderContent=array();
$pathLength=strlen($path);
foreach($files as $file) {
- if(substr($file,0,$pathLength)==$path and $file!=$path) {
- if(strrpos(substr($file,0,-1),'/')<=$pathLength) {
- $folderContent[]=substr($file,$pathLength);
+ if(substr($file, 0, $pathLength)==$path and $file!=$path) {
+ if(strrpos(substr($file, 0, -1),'/')<=$pathLength) {
+ $folderContent[]=substr($file, $pathLength);
}
}
}
@@ -121,7 +121,7 @@ class OC_Archive_ZIP extends OC_Archive{
*/
function extractFile($path,$dest) {
$fp = $this->zip->getStream($path);
- file_put_contents($dest,$fp);
+ file_put_contents($dest, $fp);
}
/**
* extract the archive
@@ -162,18 +162,18 @@ class OC_Archive_ZIP extends OC_Archive{
if($mode=='r' or $mode=='rb') {
return $this->zip->getStream($path);
}else{//since we cant directly get a writable stream, make a temp copy of the file and put it back in the archive when the stream is closed
- if(strrpos($path,'.')!==false) {
- $ext=substr($path,strrpos($path,'.'));
+ if(strrpos($path, '.')!==false) {
+ $ext=substr($path, strrpos($path, '.'));
}else{
$ext='';
}
$tmpFile=OCP\Files::tmpFile($ext);
OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack');
if($this->fileExists($path)) {
- $this->extractFile($path,$tmpFile);
+ $this->extractFile($path, $tmpFile);
}
self::$tempFiles[$tmpFile]=$path;
- return fopen('close://'.$tmpFile,$mode);
+ return fopen('close://'.$tmpFile, $mode);
}
}
@@ -183,14 +183,14 @@ class OC_Archive_ZIP extends OC_Archive{
*/
function writeBack($tmpFile) {
if(isset(self::$tempFiles[$tmpFile])) {
- $this->addFile(self::$tempFiles[$tmpFile],$tmpFile);
+ $this->addFile(self::$tempFiles[$tmpFile], $tmpFile);
unlink($tmpFile);
}
}
private function stripPath($path) {
if(!$path || $path[0]=='/') {
- return substr($path,1);
+ return substr($path, 1);
}else{
return $path;
}
diff --git a/lib/base.php b/lib/base.php
index 6af558ae9da..fa777cb9343 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -79,7 +79,7 @@ class OC{
/** @TODO: Remove this when necessary
Remove "apps/" from inclusion path for smooth migration to mutli app dir
*/
- $path = preg_replace('/apps\//', '', OC::$CLASSPATH[$className]);
+ $path = str_replace('apps/', '', OC::$CLASSPATH[$className]);
require_once $path;
}
elseif(strpos($className, 'OC_')===0) {
@@ -226,8 +226,10 @@ class OC{
$tmpl->printPage();
exit;
}
- OC_Minimizer::clearCache();
-
+ $minimizerCSS = new OC_Minimizer_CSS();
+ $minimizerCSS->clearCache();
+ $minimizerJS = new OC_Minimizer_JS();
+ $minimizerJS->clearCache();
OC_Config::setValue('version', implode('.', OC_Util::getVersion()));
OC_App::checkAppsRequirements();
// load all apps to also upgrade enabled apps
@@ -317,14 +319,14 @@ class OC{
//set http auth headers for apache+php-cgi work around
if (isset($_SERVER['HTTP_AUTHORIZATION']) && preg_match('/Basic\s+(.*)$/i', $_SERVER['HTTP_AUTHORIZATION'], $matches)) {
- list($name, $password) = explode(':', base64_decode($matches[1]));
+ list($name, $password) = explode(':', base64_decode($matches[1]), 2);
$_SERVER['PHP_AUTH_USER'] = strip_tags($name);
$_SERVER['PHP_AUTH_PW'] = strip_tags($password);
}
//set http auth headers for apache+php-cgi work around if variable gets renamed by apache
if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) && preg_match('/Basic\s+(.*)$/i', $_SERVER['REDIRECT_HTTP_AUTHORIZATION'], $matches)) {
- list($name, $password) = explode(':', base64_decode($matches[1]));
+ list($name, $password) = explode(':', base64_decode($matches[1]), 2);
$_SERVER['PHP_AUTH_USER'] = strip_tags($name);
$_SERVER['PHP_AUTH_PW'] = strip_tags($password);
}
diff --git a/lib/cache/file.php b/lib/cache/file.php
index a4f83f76c94..27d8b19f36e 100644
--- a/lib/cache/file.php
+++ b/lib/cache/file.php
@@ -22,7 +22,7 @@ class OC_Cache_File{
$this->storage = new OC_FilesystemView('/'.OC_User::getUser().'/'.$subdir);
return $this->storage;
}else{
- OC_Log::write('core','Can\'t get cache storage, user not logged in', OC_Log::ERROR);
+ OC_Log::write('core', 'Can\'t get cache storage, user not logged in', OC_Log::ERROR);
return false;
}
}
diff --git a/lib/cache/xcache.php b/lib/cache/xcache.php
index 0739e4a2fa2..9f380f870b9 100644
--- a/lib/cache/xcache.php
+++ b/lib/cache/xcache.php
@@ -29,9 +29,9 @@ class OC_Cache_XCache {
public function set($key, $value, $ttl=0) {
if($ttl>0) {
- return xcache_set($this->getNamespace().$key,$value,$ttl);
+ return xcache_set($this->getNamespace().$key, $value, $ttl);
}else{
- return xcache_set($this->getNamespace().$key,$value);
+ return xcache_set($this->getNamespace().$key, $value);
}
}
@@ -44,6 +44,12 @@ class OC_Cache_XCache {
}
public function clear($prefix='') {
+ if(!function_exists('xcache_unset_by_prefix')) {
+ function xcache_unset_by_prefix($prefix) {
+ // Since we can't clear targetted cache, we'll clear all. :(
+ xcache_clear_cache(XC_TYPE_VAR, 0);
+ }
+ }
xcache_unset_by_prefix($this->getNamespace().$prefix);
return true;
}
diff --git a/lib/config.php b/lib/config.php
index 032d401264c..cbea9199320 100644
--- a/lib/config.php
+++ b/lib/config.php
@@ -47,7 +47,7 @@ class OC_Config{
/**
* @brief Lists all available config keys
- * @returns array with key names
+ * @return array with key names
*
* This function returns all keys saved in config.php. Please note that it
* does not return the values.
@@ -60,9 +60,9 @@ class OC_Config{
/**
* @brief Gets a value from config.php
- * @param $key key
- * @param $default = null default value
- * @returns the value or $default
+ * @param string $key key
+ * @param string $default = null default value
+ * @return string the value or $default
*
* This function gets the value from config.php. If it does not exist,
* $default will be returned.
@@ -79,9 +79,9 @@ class OC_Config{
/**
* @brief Sets a value
- * @param $key key
- * @param $value value
- * @returns true/false
+ * @param string $key key
+ * @param string $value value
+ * @return bool
*
* This function sets the value and writes the config.php. If the file can
* not be written, false will be returned.
@@ -99,8 +99,8 @@ class OC_Config{
/**
* @brief Removes a key from the config
- * @param $key key
- * @returns true/false
+ * @param string $key key
+ * @return bool
*
* This function removes a key from the config.php. If owncloud has no
* write access to config.php, the function will return false.
@@ -121,7 +121,7 @@ class OC_Config{
/**
* @brief Loads the config file
- * @returns true/false
+ * @return bool
*
* Reads the config file and saves it to the cache
*/
@@ -148,7 +148,7 @@ class OC_Config{
/**
* @brief Writes the config file
- * @returns true/false
+ * @return bool
*
* Saves the config to the config file.
*
diff --git a/lib/connector/sabre/auth.php b/lib/connector/sabre/auth.php
index 34fc5fee50c..0c34c7ea29f 100644
--- a/lib/connector/sabre/auth.php
+++ b/lib/connector/sabre/auth.php
@@ -36,7 +36,7 @@ class OC_Connector_Sabre_Auth extends Sabre_DAV_Auth_Backend_AbstractBasic {
return true;
} else {
OC_Util::setUpFS();//login hooks may need early access to the filesystem
- if(OC_User::login($username,$password)) {
+ if(OC_User::login($username, $password)) {
OC_Util::setUpFS($username);
return true;
}
diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php
index 8fff77ac749..413efef73b7 100644
--- a/lib/connector/sabre/directory.php
+++ b/lib/connector/sabre/directory.php
@@ -50,17 +50,19 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
public function createFile($name, $data = null) {
if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
$info = OC_FileChunking::decodeName($name);
+ if (empty($info)) {
+ throw new Sabre_DAV_Exception_NotImplemented();
+ }
$chunk_handler = new OC_FileChunking($info);
$chunk_handler->store($info['index'], $data);
if ($chunk_handler->isComplete()) {
$newPath = $this->path . '/' . $info['name'];
- $f = OC_Filesystem::fopen($newPath, 'w');
- $chunk_handler->assemble($f);
+ $chunk_handler->file_assemble($newPath);
return OC_Connector_Sabre_Node::getETagPropertyForPath($newPath);
}
} else {
$newPath = $this->path . '/' . $name;
- OC_Filesystem::file_put_contents($newPath,$data);
+ OC_Filesystem::file_put_contents($newPath, $data);
return OC_Connector_Sabre_Node::getETagPropertyForPath($newPath);
}
@@ -91,10 +93,12 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
$path = $this->path . '/' . $name;
if (is_null($info)) {
- $info = OC_FileCache::get($path);
+ $info = OC_Files::getFileInfo($path);
}
- if (!$info) throw new Sabre_DAV_Exception_NotFound('File with name ' . $path . ' could not be located');
+ if (!$info) {
+ throw new Sabre_DAV_Exception_NotFound('File with name ' . $path . ' could not be located');
+ }
if ($info['mimetype'] == 'httpd/unix-directory') {
$node = new OC_Connector_Sabre_Directory($path);
@@ -113,7 +117,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
*/
public function getChildren() {
- $folder_content = OC_FileCache::getFolderContent($this->path);
+ $folder_content = OC_Files::getDirectoryContent($this->path);
$paths = array();
foreach($folder_content as $info) {
$paths[] = $this->path.'/'.$info['name'];
@@ -195,10 +199,9 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
*/
public function getProperties($properties) {
$props = parent::getProperties($properties);
- if (in_array(self::GETETAG_PROPERTYNAME, $properties)
- && !isset($props[self::GETETAG_PROPERTYNAME])) {
- $props[self::GETETAG_PROPERTYNAME] =
- OC_Connector_Sabre_Node::getETagPropertyForPath($this->path);
+ if (in_array(self::GETETAG_PROPERTYNAME, $properties) && !isset($props[self::GETETAG_PROPERTYNAME])) {
+ $props[self::GETETAG_PROPERTYNAME]
+ = OC_Connector_Sabre_Node::getETagPropertyForPath($this->path);
}
return $props;
}
diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php
index 2916575e2d5..55fa0dfde66 100644
--- a/lib/connector/sabre/node.php
+++ b/lib/connector/sabre/node.php
@@ -23,7 +23,9 @@
abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IProperties {
const GETETAG_PROPERTYNAME = '{DAV:}getetag';
-
+ const LASTMODIFIED_PROPERTYNAME_DEPRECIATED = '{DAV:}lastmodified'; // FIXME: keept for the transition period, can be removed for OC 4.5.1 if the sync client update too
+ const GETLASTMODIFIED_PROPERTYNAME = '{DAV:}getlastmodified';
+
/**
* The path to the current node
*
@@ -142,7 +144,6 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
public function updateProperties($properties) {
$existing = $this->getProperties(array());
foreach($properties as $propertyName => $propertyValue) {
- $propertyName = preg_replace("/^{.*}/", "", $propertyName); // remove leading namespace from property name
// If it was null, we need to delete the property
if (is_null($propertyValue)) {
if(array_key_exists( $propertyName, $existing )) {
@@ -150,8 +151,9 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
$query->execute( array( OC_User::getUser(), $this->path, $propertyName ));
}
}
- else {
- if( strcmp( $propertyName, "lastmodified") === 0) {
+ else { //FIXME: first part of if statement can be removed together with the LASTMODIFIED_PROPERTYNAME_DEPRECIATED const for oc4.5.1 if the sync client was updated too
+ if( strcmp( $propertyName, self::LASTMODIFIED_PROPERTYNAME_DEPRECIATED) === 0 ||
+ strcmp( $propertyName, self::GETLASTMODIFIED_PROPERTYNAME) === 0 ) {
$this->touch($propertyValue);
} else {
if(!array_key_exists( $propertyName, $existing )) {
@@ -235,7 +237,7 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
static public function removeETagPropertyForPath($path) {
// remove tags from this and parent paths
$paths = array();
- while ($path != '/' && $path != '') {
+ while ($path != '/' && $path != '.' && $path != '') {
$paths[] = $path;
$path = dirname($path);
}
diff --git a/lib/connector/sabre/principal.php b/lib/connector/sabre/principal.php
index cfc72eda9f9..ee95ae63306 100644
--- a/lib/connector/sabre/principal.php
+++ b/lib/connector/sabre/principal.php
@@ -66,7 +66,7 @@ class OC_Connector_Sabre_Principal implements Sabre_DAVACL_IPrincipalBackend {
*/
public function getGroupMemberSet($principal) {
// TODO: for now the group principal has only one member, the user itself
- list($prefix,$name) = Sabre_DAV_URLUtil::splitPath($principal);
+ list($prefix, $name) = Sabre_DAV_URLUtil::splitPath($principal);
$principal = $this->getPrincipalByPath($prefix);
if (!$principal) throw new Sabre_DAV_Exception('Principal not found');
@@ -115,6 +115,12 @@ class OC_Connector_Sabre_Principal implements Sabre_DAVACL_IPrincipalBackend {
public function setGroupMemberSet($principal, array $members) {
throw new Sabre_DAV_Exception('Setting members of the group is not supported yet');
}
- function updatePrincipal($path, $mutations) {return 0;}
- function searchPrincipals($prefixPath, array $searchProperties) {return 0;}
+
+ function updatePrincipal($path, $mutations) {
+ return 0;
+ }
+
+ function searchPrincipals($prefixPath, array $searchProperties) {
+ return 0;
+ }
}
diff --git a/lib/db.php b/lib/db.php
index ee69e5f8299..256ae5b6bf3 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -28,18 +28,30 @@ class OC_DB {
const BACKEND_PDO=0;
const BACKEND_MDB2=1;
+ /**
+ * @var MDB2_Driver_Common
+ */
static private $connection; //the prefered connection to use, either PDO or MDB2
static private $backend=null;
- static private $MDB2=false;
- static private $PDO=false;
- static private $schema=false;
+ /**
+ * @var MDB2_Driver_Common
+ */
+ static private $MDB2=null;
+ /**
+ * @var PDO
+ */
+ static private $PDO=null;
+ /**
+ * @var MDB2_Schema
+ */
+ static private $schema=null;
static private $inTransaction=false;
static private $prefix=null;
static private $type=null;
/**
* check which backend we should use
- * @return BACKEND_MDB2 or BACKEND_PDO
+ * @return int BACKEND_MDB2 or BACKEND_PDO
*/
private static function getDBBackend() {
//check if we can use PDO, else use MDB2 (installation always needs to be done my mdb2)
@@ -59,37 +71,41 @@ class OC_DB {
/**
* @brief connects to the database
- * @returns true if connection can be established or nothing (die())
+ * @param int $backend
+ * @return bool true if connection can be established or false on error
*
* Connects to the database as specified in config.php
*/
public static function connect($backend=null) {
if(self::$connection) {
- return;
+ return true;
}
if(is_null($backend)) {
$backend=self::getDBBackend();
}
if($backend==self::BACKEND_PDO) {
- self::connectPDO();
+ $success = self::connectPDO();
self::$connection=self::$PDO;
self::$backend=self::BACKEND_PDO;
}else{
- self::connectMDB2();
+ $success = self::connectMDB2();
self::$connection=self::$MDB2;
self::$backend=self::BACKEND_MDB2;
}
+ return $success;
}
/**
* connect to the database using pdo
+ *
+ * @return bool
*/
public static function connectPDO() {
if(self::$connection) {
if(self::$backend==self::BACKEND_MDB2) {
self::disconnect();
}else{
- return;
+ return true;
}
}
// The global data we need
@@ -146,6 +162,8 @@ class OC_DB {
$dsn = 'oci:dbname=//' . $host . '/' . $name;
}
break;
+ default:
+ return false;
}
try{
self::$PDO=new PDO($dsn, $user, $pass, $opts);
@@ -168,7 +186,7 @@ class OC_DB {
if(self::$backend==self::BACKEND_PDO) {
self::disconnect();
}else{
- return;
+ return true;
}
}
// The global data we need
@@ -187,7 +205,7 @@ class OC_DB {
// Prepare options array
$options = array(
- 'portability' => MDB2_PORTABILITY_ALL & (!MDB2_PORTABILITY_FIX_CASE),
+ 'portability' => MDB2_PORTABILITY_ALL - MDB2_PORTABILITY_FIX_CASE,
'log_line_break' => '<br>',
'idxname_format' => '%s',
'debug' => true,
@@ -226,14 +244,18 @@ class OC_DB {
'phptype' => 'oci8',
'username' => $user,
'password' => $pass,
+ 'charset' => 'AL32UTF8',
);
if ($host != '') {
$dsn['hostspec'] = $host;
$dsn['database'] = $name;
} else { // use dbname for hostspec
$dsn['hostspec'] = $name;
+ $dsn['database'] = $user;
}
break;
+ default:
+ return false;
}
// Try to establish connection
@@ -244,7 +266,7 @@ class OC_DB {
echo( '<b>can not connect to database, using '.$type.'. ('.self::$MDB2->getUserInfo().')</center>');
OC_Log::write('core', self::$MDB2->getUserInfo(), OC_Log::FATAL);
OC_Log::write('core', self::$MDB2->getMessage(), OC_Log::FATAL);
- die( $error );
+ die();
}
// We always, really always want associative arrays
@@ -257,8 +279,10 @@ class OC_DB {
/**
* @brief Prepare a SQL query
- * @param $query Query string
- * @returns prepared SQL query
+ * @param string $query Query string
+ * @param int $limit
+ * @param int $offset
+ * @return MDB2_Statement_Common prepared SQL query
*
* SQL query via MDB2 prepare(), needs to be execute()'d!
*/
@@ -273,8 +297,10 @@ class OC_DB {
//FIXME: check limit notation for other dbs
//the following sql thus might needs to take into account db ways of representing it
//(oracle has no LIMIT / OFFSET)
- $limitsql = ' LIMIT ' . $limit;
+ $limit = (int)$limit;
+ $limitsql = ' LIMIT ' . $limit;
if (!is_null($offset)) {
+ $offset = (int)$offset;
$limitsql .= ' OFFSET ' . $offset;
}
//insert limitsql
@@ -297,7 +323,7 @@ class OC_DB {
// Die if we have an error (error means: bad query, not 0 results!)
if( PEAR::isError($result)) {
$entry = 'DB Error: "'.$result->getMessage().'"<br />';
- $entry .= 'Offending command was: '.$query.'<br />';
+ $entry .= 'Offending command was: '.htmlentities($query).'<br />';
OC_Log::write('core', $entry,OC_Log::FATAL);
error_log('DB error: '.$entry);
die( $entry );
@@ -307,7 +333,7 @@ class OC_DB {
$result=self::$connection->prepare($query);
}catch(PDOException $e) {
$entry = 'DB Error: "'.$e->getMessage().'"<br />';
- $entry .= 'Offending command was: '.$query.'<br />';
+ $entry .= 'Offending command was: '.htmlentities($query).'<br />';
OC_Log::write('core', $entry,OC_Log::FATAL);
error_log('DB error: '.$entry);
die( $entry );
@@ -319,8 +345,8 @@ class OC_DB {
/**
* @brief gets last value of autoincrement
- * @param $table string The optional table name (will replace *PREFIX*) and add sequence suffix
- * @returns id
+ * @param string $table The optional table name (will replace *PREFIX*) and add sequence suffix
+ * @return int id
*
* MDB2 lastInsertID()
*
@@ -332,14 +358,14 @@ class OC_DB {
if($table !== null) {
$prefix = OC_Config::getValue( "dbtableprefix", "oc_" );
$suffix = OC_Config::getValue( "dbsequencesuffix", "_id_seq" );
- $table = str_replace( '*PREFIX*', $prefix, $table );
+ $table = str_replace( '*PREFIX*', $prefix, $table ).$suffix;
}
- return self::$connection->lastInsertId($table.$suffix);
+ return self::$connection->lastInsertId($table);
}
/**
* @brief Disconnect
- * @returns true/false
+ * @return bool
*
* This is good bye, good bye, yeah!
*/
@@ -359,8 +385,9 @@ class OC_DB {
/**
* @brief saves database scheme to xml file
- * @param $file name of file
- * @returns true/false
+ * @param string $file name of file
+ * @param int $mode
+ * @return bool
*
* TODO: write more documentation
*/
@@ -381,8 +408,8 @@ class OC_DB {
/**
* @brief Creates tables from XML file
- * @param $file file to read structure from
- * @returns true/false
+ * @param string $file file to read structure from
+ * @return bool
*
* TODO: write more documentation
*/
@@ -443,11 +470,11 @@ class OC_DB {
/**
* @brief update the database scheme
- * @param $file file to read structure from
+ * @param string $file file to read structure from
+ * @return bool
*/
public static function updateDbFromStructure($file) {
$CONFIG_DBTABLEPREFIX = OC_Config::getValue( "dbtableprefix", "oc_" );
- $CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" );
self::connectScheme();
@@ -457,7 +484,8 @@ class OC_DB {
$previousSchema = self::$schema->getDefinitionFromDatabase();
if (PEAR::isError($previousSchema)) {
$error = $previousSchema->getMessage();
- OC_Log::write('core', 'Failed to get existing database structure for upgrading ('.$error.')', OC_Log::FATAL);
+ $detail = $previousSchema->getDebugInfo();
+ OC_Log::write('core', 'Failed to get existing database structure for upgrading ('.$error.', '.$detail.')', OC_Log::FATAL);
return false;
}
@@ -492,7 +520,7 @@ class OC_DB {
/**
* @brief connects to a MDB2 database scheme
- * @returns true/false
+ * @returns bool
*
* Connects to a MDB2 database scheme
*/
@@ -512,12 +540,12 @@ class OC_DB {
}
/**
- * @brief does minor chages to query
- * @param $query Query string
- * @returns corrected query string
+ * @brief does minor changes to query
+ * @param string $query Query string
+ * @return string corrected query string
*
* This function replaces *PREFIX* with the value of $CONFIG_DBTABLEPREFIX
- * and replaces the ` woth ' or " according to the database driver.
+ * and replaces the ` with ' or " according to the database driver.
*/
private static function processQuery( $query ) {
self::connect();
@@ -552,7 +580,7 @@ class OC_DB {
/**
* @brief drop a table
- * @param string $tableNamme the table to drop
+ * @param string $tableName the table to drop
*/
public static function dropTable($tableName) {
self::connectMDB2();
@@ -613,6 +641,7 @@ class OC_DB {
/**
* Start a transaction
+ * @return bool
*/
public static function beginTransaction() {
self::connect();
@@ -621,10 +650,12 @@ class OC_DB {
}
self::$connection->beginTransaction();
self::$inTransaction=true;
+ return true;
}
/**
* Commit the database changes done during a transaction that is in progress
+ * @return bool
*/
public static function commit() {
self::connect();
@@ -633,6 +664,7 @@ class OC_DB {
}
self::$connection->commit();
self::$inTransaction=false;
+ return true;
}
/**
@@ -649,12 +681,43 @@ class OC_DB {
return false;
}
}
+
+ /**
+ * returns the error code and message as a string for logging
+ * works with MDB2 and PDOException
+ * @param mixed $error
+ * @return string
+ */
+ public static function getErrorMessage($error) {
+ if ( self::$backend==self::BACKEND_MDB2 and PEAR::isError($error) ) {
+ $msg = $error->getCode() . ': ' . $error->getMessage();
+ if (defined('DEBUG') && DEBUG) {
+ $msg .= '(' . $error->getDebugInfo() . ')';
+ }
+ } elseif (self::$backend==self::BACKEND_PDO and self::$PDO) {
+ $msg = self::$PDO->errorCode() . ': ';
+ $errorInfo = self::$PDO->errorInfo();
+ if (is_array($errorInfo)) {
+ $msg .= 'SQLSTATE = '.$errorInfo[0] . ', ';
+ $msg .= 'Driver Code = '.$errorInfo[1] . ', ';
+ $msg .= 'Driver Message = '.$errorInfo[2];
+ }else{
+ $msg = '';
+ }
+ }else{
+ $msg = '';
+ }
+ return $msg;
+ }
}
/**
* small wrapper around PDOStatement to make it behave ,more like an MDB2 Statement
*/
class PDOStatementWrapper{
+ /**
+ * @var PDOStatement
+ */
private $statement=null;
private $lastArguments=array();
diff --git a/lib/filecache.php b/lib/filecache.php
index adcf97753ed..07099bcccd5 100644
--- a/lib/filecache.php
+++ b/lib/filecache.php
@@ -481,7 +481,7 @@ class OC_FileCache{
*/
public static function clear($user='') {
if($user) {
- $query=OC_DB::prepare('DELETE FROM `*PREFIX*fscache` WHERE user=?');
+ $query=OC_DB::prepare('DELETE FROM `*PREFIX*fscache` WHERE `user`=?');
$query->execute(array($user));
}else{
$query=OC_DB::prepare('DELETE FROM `*PREFIX*fscache`');
diff --git a/lib/filecache/cached.php b/lib/filecache/cached.php
index 261bd2f572b..9b1eb4f7803 100644
--- a/lib/filecache/cached.php
+++ b/lib/filecache/cached.php
@@ -18,11 +18,22 @@ class OC_FileCache_Cached{
$root=OC_Filesystem::getRoot();
}
$path=$root.$path;
- $query=OC_DB::prepare('SELECT `path`,`ctime`,`mtime`,`mimetype`,`size`,`encrypted`,`versioned`,`writable` FROM `*PREFIX*fscache` WHERE `path_hash`=?');
- $result=$query->execute(array(md5($path)))->fetchRow();
+ $stmt=OC_DB::prepare('SELECT `path`,`ctime`,`mtime`,`mimetype`,`size`,`encrypted`,`versioned`,`writable` FROM `*PREFIX*fscache` WHERE `path_hash`=?');
+ if ( ! OC_DB::isError($stmt) ) {
+ $result=$stmt->execute(array(md5($path)));
+ if ( ! OC_DB::isError($result) ) {
+ $result = $result->fetchRow();
+ } else {
+ OC:Log::write('OC_FileCache_Cached', 'could not execute get: '. OC_DB::getErrorMessage($result), OC_Log::ERROR);
+ $result = false;
+ }
+ } else {
+ OC_Log::write('OC_FileCache_Cached', 'could not prepare get: '. OC_DB::getErrorMessage($stmt), OC_Log::ERROR);
+ $result = false;
+ }
if(is_array($result)) {
if(isset(self::$savedData[$path])) {
- $result=array_merge($result,self::$savedData[$path]);
+ $result=array_merge($result, self::$savedData[$path]);
}
return $result;
}else{
@@ -54,7 +65,7 @@ class OC_FileCache_Cached{
if($root===false) {
$root=OC_Filesystem::getRoot();
}
- $parent=OC_FileCache::getId($path,$root);
+ $parent=OC_FileCache::getId($path, $root);
if($parent==-1) {
return array();
}
@@ -63,7 +74,7 @@ class OC_FileCache_Cached{
if(is_array($result)) {
return $result;
}else{
- OC_Log::write('files','getFolderContent(): file not found in cache ('.$path.')',OC_Log::DEBUG);
+ OC_Log::write('files', 'getFolderContent(): file not found in cache ('.$path.')', OC_Log::DEBUG);
return false;
}
}
diff --git a/lib/filecache/update.php b/lib/filecache/update.php
index 3d10f5ea7b6..2b64a2a90ff 100644
--- a/lib/filecache/update.php
+++ b/lib/filecache/update.php
@@ -27,13 +27,13 @@ class OC_FileCache_Update{
if(!$view->file_exists($path)) {
return false;
}
- $cachedData=OC_FileCache_Cached::get($path,$root);
+ $cachedData=OC_FileCache_Cached::get($path, $root);
if(isset($cachedData['mtime'])) {
$cachedMTime=$cachedData['mtime'];
if($folder) {
- return $view->hasUpdated($path.'/',$cachedMTime);
+ return $view->hasUpdated($path.'/', $cachedMTime);
}else{
- return $view->hasUpdated($path,$cachedMTime);
+ return $view->hasUpdated($path, $cachedMTime);
}
}else{//file not in cache, so it has to be updated
if(($path=='/' or $path=='') and $root===false) {//dont auto update the home folder, it will be scanned
@@ -59,9 +59,9 @@ class OC_FileCache_Update{
$file=$view->getRelativePath($path);
if(!$view->file_exists($file)) {
if($root===false) {//filesystem hooks are only valid for the default root
- OC_Hook::emit('OC_Filesystem','post_delete',array('path'=>$file));
+ OC_Hook::emit('OC_Filesystem', 'post_delete', array('path'=>$file));
}else{
- self::delete($file,$root);
+ self::delete($file, $root);
}
}
}
@@ -83,24 +83,24 @@ class OC_FileCache_Update{
while (($filename = readdir($dh)) !== false) {
if($filename != '.' and $filename != '..') {
$file=$path.'/'.$filename;
- if(self::hasUpdated($file,$root)) {
+ if(self::hasUpdated($file, $root)) {
if($root===false) {//filesystem hooks are only valid for the default root
- OC_Hook::emit('OC_Filesystem','post_write',array('path'=>$file));
+ OC_Hook::emit('OC_Filesystem', 'post_write', array('path'=>$file));
}else{
- self::update($file,$root);
+ self::update($file, $root);
}
}
}
}
}
- self::cleanFolder($path,$root);
+ self::cleanFolder($path, $root);
//update the folder last, so we can calculate the size correctly
if($root===false) {//filesystem hooks are only valid for the default root
- OC_Hook::emit('OC_Filesystem','post_write',array('path'=>$path));
+ OC_Hook::emit('OC_Filesystem', 'post_write', array('path'=>$path));
}else{
- self::update($path,$root);
+ self::update($path, $root);
}
}
@@ -132,7 +132,7 @@ class OC_FileCache_Update{
public static function fileSystemWatcherRename($params) {
$oldPath=$params['oldpath'];
$newPath=$params['newpath'];
- self::rename($oldPath,$newPath);
+ self::rename($oldPath, $newPath);
}
/**
@@ -154,24 +154,24 @@ class OC_FileCache_Update{
$cachedSize=isset($cached['size'])?$cached['size']:0;
if($view->is_dir($path.'/')) {
- if(OC_FileCache::inCache($path,$root)) {
- $cachedContent=OC_FileCache_Cached::getFolderContent($path,$root);
+ if(OC_FileCache::inCache($path, $root)) {
+ $cachedContent=OC_FileCache_Cached::getFolderContent($path, $root);
foreach($cachedContent as $file) {
$size+=$file['size'];
}
$mtime=$view->filemtime($path.'/');
$ctime=$view->filectime($path.'/');
$writable=$view->is_writable($path.'/');
- OC_FileCache::put($path,array('size'=>$size,'mtime'=>$mtime,'ctime'=>$ctime,'mimetype'=>$mimetype,'writable'=>$writable));
+ OC_FileCache::put($path, array('size'=>$size,'mtime'=>$mtime,'ctime'=>$ctime,'mimetype'=>$mimetype,'writable'=>$writable));
}else{
$count=0;
- OC_FileCache::scan($path,null,$count,$root);
+ OC_FileCache::scan($path, null, $count, $root);
return; //increaseSize is already called inside scan
}
}else{
- $size=OC_FileCache::scanFile($path,$root);
+ $size=OC_FileCache::scanFile($path, $root);
}
- OC_FileCache::increaseSize(dirname($path),$size-$cachedSize,$root);
+ OC_FileCache::increaseSize(dirname($path), $size-$cachedSize, $root);
}
/**
@@ -180,13 +180,13 @@ class OC_FileCache_Update{
* @param string root (optional)
*/
public static function delete($path,$root=false) {
- $cached=OC_FileCache_Cached::get($path,$root);
+ $cached=OC_FileCache_Cached::get($path, $root);
if(!isset($cached['size'])) {
return;
}
$size=$cached['size'];
- OC_FileCache::increaseSize(dirname($path),-$size,$root);
- OC_FileCache::delete($path,$root);
+ OC_FileCache::increaseSize(dirname($path), -$size, $root);
+ OC_FileCache::delete($path, $root);
}
/**
@@ -196,7 +196,7 @@ class OC_FileCache_Update{
* @param string root (optional)
*/
public static function rename($oldPath,$newPath,$root=false) {
- if(!OC_FileCache::inCache($oldPath,$root)) {
+ if(!OC_FileCache::inCache($oldPath, $root)) {
return;
}
if($root===false) {
@@ -205,10 +205,10 @@ class OC_FileCache_Update{
$view=new OC_FilesystemView($root);
}
- $cached=OC_FileCache_Cached::get($oldPath,$root);
+ $cached=OC_FileCache_Cached::get($oldPath, $root);
$oldSize=$cached['size'];
- OC_FileCache::increaseSize(dirname($oldPath),-$oldSize,$root);
- OC_FileCache::increaseSize(dirname($newPath),$oldSize,$root);
- OC_FileCache::move($oldPath,$newPath);
+ OC_FileCache::increaseSize(dirname($oldPath), -$oldSize, $root);
+ OC_FileCache::increaseSize(dirname($newPath), $oldSize, $root);
+ OC_FileCache::move($oldPath, $newPath);
}
} \ No newline at end of file
diff --git a/lib/filechunking.php b/lib/filechunking.php
index d03af226d8b..5ab33c77ad7 100644
--- a/lib/filechunking.php
+++ b/lib/filechunking.php
@@ -55,12 +55,13 @@ class OC_FileChunking {
public function assemble($f) {
$cache = $this->getCache();
$prefix = $this->getPrefix();
+ $count = 0;
for($i=0; $i < $this->info['chunkcount']; $i++) {
$chunk = $cache->get($prefix.$i);
$cache->remove($prefix.$i);
- fwrite($f,$chunk);
+ $count += fwrite($f,$chunk);
}
- fclose($f);
+ return $count;
}
public function signature_split($orgfile, $input) {
@@ -91,4 +92,57 @@ class OC_FileChunking {
'count' => $count,
);
}
+
+ public function file_assemble($path) {
+ $absolutePath = OC_Filesystem::normalizePath(OC_Filesystem::getView()->getAbsolutePath($path));
+ $data = '';
+ // use file_put_contents as method because that best matches what this function does
+ if (OC_FileProxy::runPreProxies('file_put_contents', $absolutePath, $data) && OC_Filesystem::isValidPath($path)) {
+ $path = OC_Filesystem::getView()->getRelativePath($absolutePath);
+ $exists = OC_Filesystem::file_exists($path);
+ $run = true;
+ if(!$exists) {
+ OC_Hook::emit(
+ OC_Filesystem::CLASSNAME,
+ OC_Filesystem::signal_create,
+ array(
+ OC_Filesystem::signal_param_path => $path,
+ OC_Filesystem::signal_param_run => &$run
+ )
+ );
+ }
+ OC_Hook::emit(
+ OC_Filesystem::CLASSNAME,
+ OC_Filesystem::signal_write,
+ array(
+ OC_Filesystem::signal_param_path => $path,
+ OC_Filesystem::signal_param_run => &$run
+ )
+ );
+ if(!$run) {
+ return false;
+ }
+ $target = OC_Filesystem::fopen($path, 'w');
+ if($target) {
+ $count = $this->assemble($target);
+ fclose($target);
+ if(!$exists) {
+ OC_Hook::emit(
+ OC_Filesystem::CLASSNAME,
+ OC_Filesystem::signal_post_create,
+ array( OC_Filesystem::signal_param_path => $path)
+ );
+ }
+ OC_Hook::emit(
+ OC_Filesystem::CLASSNAME,
+ OC_Filesystem::signal_post_write,
+ array( OC_Filesystem::signal_param_path => $path)
+ );
+ OC_FileProxy::runPostProxies('file_put_contents', $absolutePath, $count);
+ return $count > 0;
+ }else{
+ return false;
+ }
+ }
+ }
}
diff --git a/lib/fileproxy/quota.php b/lib/fileproxy/quota.php
index adbff3d301a..5a0dbdb6fe2 100644
--- a/lib/fileproxy/quota.php
+++ b/lib/fileproxy/quota.php
@@ -26,6 +26,7 @@
*/
class OC_FileProxy_Quota extends OC_FileProxy{
+ static $rootView;
private $userQuota=-1;
/**
@@ -86,7 +87,10 @@ class OC_FileProxy_Quota extends OC_FileProxy{
}
public function preCopy($path1,$path2) {
- return (OC_Filesystem::filesize($path1)<$this->getFreeSpace() or $this->getFreeSpace()==0);
+ if(!self::$rootView){
+ self::$rootView = new OC_FilesystemView('');
+ }
+ return (self::$rootView->filesize($path1)<$this->getFreeSpace() or $this->getFreeSpace()==0);
}
public function preFromTmpFile($tmpfile,$path) {
@@ -96,4 +100,4 @@ class OC_FileProxy_Quota extends OC_FileProxy{
public function preFromUploadedFile($tmpfile,$path) {
return (filesize($tmpfile)<$this->getFreeSpace() or $this->getFreeSpace()==0);
}
-} \ No newline at end of file
+}
diff --git a/lib/files.php b/lib/files.php
index 63dd96b9509..ac999a9bd15 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -29,6 +29,36 @@ class OC_Files {
static $tmpFiles=array();
/**
+ * get the filesystem info
+ * @param string path
+ * @return array
+ *
+ * returns an associative array with the following keys:
+ * - size
+ * - mtime
+ * - ctime
+ * - mimetype
+ * - encrypted
+ * - versioned
+ */
+ public static function getFileInfo($path) {
+ if (($path == '/Shared' || substr($path, 0, 8) == '/Shared/') && OC_App::isEnabled('files_sharing')) {
+ if ($path == '/Shared') {
+ $info = OCP\Share::getItemsSharedWith('file', OC_Share_Backend_File::FORMAT_FILE_APP_ROOT);
+ }
+ else {
+ $path = substr($path, 7);
+ $info = OCP\Share::getItemSharedWith('file', $path, OC_Share_Backend_File::FORMAT_FILE_APP);
+ }
+ $info = $info[0];
+ }
+ else {
+ $info = OC_FileCache::get($path);
+ }
+ return $info;
+ }
+
+ /**
* get the content of a directory
* @param dir $directory path under datadirectory
*/
@@ -78,7 +108,24 @@ class OC_Files {
return $files;
}
-
+ public static function searchByMime($mimetype_filter) {
+ $files = array();
+ $dirs_to_check = array('');
+ while (!empty($dirs_to_check)) {
+ // get next subdir to check
+ $dir = array_pop($dirs_to_check);
+ $dir_content = self::getDirectoryContent($dir, $mimetype_filter);
+ foreach($dir_content as $file) {
+ if ($file['type'] == 'file') {
+ $files[] = $dir.'/'.$file['name'];
+ }
+ else {
+ $dirs_to_check[] = $dir.'/'.$file['name'];
+ }
+ }
+ }
+ return $files;
+ }
/**
* return the content of a file or return a zip file containning multiply files
diff --git a/lib/filestorage/local.php b/lib/filestorage/local.php
index e26d3d3ef91..80aa548047c 100644
--- a/lib/filestorage/local.php
+++ b/lib/filestorage/local.php
@@ -161,7 +161,7 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{
}
public function free_space($path) {
- return disk_free_space($this->datadir.$path);
+ return @disk_free_space($this->datadir.$path);
}
public function search($query) {
diff --git a/lib/filesystem.php b/lib/filesystem.php
index 92eb4fa4778..f5c10923b32 100644
--- a/lib/filesystem.php
+++ b/lib/filesystem.php
@@ -357,7 +357,7 @@ class OC_Filesystem{
* @return string
*/
static public function getLocalPath($path) {
- $datadir = OC_User::getHome($user).'/files';
+ $datadir = OC_User::getHome(OC_User::getUser()).'/files';
$newpath = $path;
if (strncmp($newpath, $datadir, strlen($datadir)) == 0) {
$newpath = substr($path, strlen($datadir));
@@ -527,6 +527,7 @@ class OC_Filesystem{
} else {
$path=$params['oldpath'];
}
+ $path = self::normalizePath($path);
OC_Connector_Sabre_Node::removeETagPropertyForPath($path);
}
diff --git a/lib/filesystemview.php b/lib/filesystemview.php
index 743f9403011..02a0b521053 100644
--- a/lib/filesystemview.php
+++ b/lib/filesystemview.php
@@ -263,24 +263,26 @@ class OC_FilesystemView {
$path = $this->getRelativePath($absolutePath);
$exists = $this->file_exists($path);
$run = true;
- if(!$exists) {
+ if( $this->fakeRoot==OC_Filesystem::getRoot() ){
+ if(!$exists) {
+ OC_Hook::emit(
+ OC_Filesystem::CLASSNAME,
+ OC_Filesystem::signal_create,
+ array(
+ OC_Filesystem::signal_param_path => $path,
+ OC_Filesystem::signal_param_run => &$run
+ )
+ );
+ }
OC_Hook::emit(
OC_Filesystem::CLASSNAME,
- OC_Filesystem::signal_create,
+ OC_Filesystem::signal_write,
array(
OC_Filesystem::signal_param_path => $path,
OC_Filesystem::signal_param_run => &$run
)
);
}
- OC_Hook::emit(
- OC_Filesystem::CLASSNAME,
- OC_Filesystem::signal_write,
- array(
- OC_Filesystem::signal_param_path => $path,
- OC_Filesystem::signal_param_run => &$run
- )
- );
if(!$run) {
return false;
}
@@ -289,18 +291,20 @@ class OC_FilesystemView {
$count=OC_Helper::streamCopy($data, $target);
fclose($target);
fclose($data);
- if(!$exists) {
+ if( $this->fakeRoot==OC_Filesystem::getRoot() ){
+ if(!$exists) {
+ OC_Hook::emit(
+ OC_Filesystem::CLASSNAME,
+ OC_Filesystem::signal_post_create,
+ array( OC_Filesystem::signal_param_path => $path)
+ );
+ }
OC_Hook::emit(
OC_Filesystem::CLASSNAME,
- OC_Filesystem::signal_post_create,
+ OC_Filesystem::signal_post_write,
array( OC_Filesystem::signal_param_path => $path)
);
}
- OC_Hook::emit(
- OC_Filesystem::CLASSNAME,
- OC_Filesystem::signal_post_write,
- array( OC_Filesystem::signal_param_path => $path)
- );
OC_FileProxy::runPostProxies('file_put_contents', $absolutePath, $count);
return $count > 0;
}else{
@@ -330,14 +334,16 @@ class OC_FilesystemView {
return false;
}
$run=true;
- OC_Hook::emit(
- OC_Filesystem::CLASSNAME, OC_Filesystem::signal_rename,
- array(
- OC_Filesystem::signal_param_oldpath => $path1,
- OC_Filesystem::signal_param_newpath => $path2,
- OC_Filesystem::signal_param_run => &$run
- )
- );
+ if( $this->fakeRoot==OC_Filesystem::getRoot() ){
+ OC_Hook::emit(
+ OC_Filesystem::CLASSNAME, OC_Filesystem::signal_rename,
+ array(
+ OC_Filesystem::signal_param_oldpath => $path1,
+ OC_Filesystem::signal_param_newpath => $path2,
+ OC_Filesystem::signal_param_run => &$run
+ )
+ );
+ }
if($run) {
$mp1 = $this->getMountPoint($path1.$postFix1);
$mp2 = $this->getMountPoint($path2.$postFix2);
@@ -353,14 +359,16 @@ class OC_FilesystemView {
$storage1->unlink($this->getInternalPath($path1.$postFix1));
$result = $count>0;
}
- OC_Hook::emit(
- OC_Filesystem::CLASSNAME,
- OC_Filesystem::signal_post_rename,
- array(
- OC_Filesystem::signal_param_oldpath => $path1,
- OC_Filesystem::signal_param_newpath => $path2
- )
- );
+ if( $this->fakeRoot==OC_Filesystem::getRoot() ){
+ OC_Hook::emit(
+ OC_Filesystem::CLASSNAME,
+ OC_Filesystem::signal_post_rename,
+ array(
+ OC_Filesystem::signal_param_oldpath => $path1,
+ OC_Filesystem::signal_param_newpath => $path2
+ )
+ );
+ }
return $result;
}
}
@@ -378,35 +386,37 @@ class OC_FilesystemView {
return false;
}
$run=true;
- OC_Hook::emit(
- OC_Filesystem::CLASSNAME,
- OC_Filesystem::signal_copy,
- array(
- OC_Filesystem::signal_param_oldpath => $path1,
- OC_Filesystem::signal_param_newpath=>$path2,
- OC_Filesystem::signal_param_run => &$run
- )
- );
- $exists=$this->file_exists($path2);
- if($run and !$exists) {
+ if( $this->fakeRoot==OC_Filesystem::getRoot() ){
OC_Hook::emit(
OC_Filesystem::CLASSNAME,
- OC_Filesystem::signal_create,
+ OC_Filesystem::signal_copy,
array(
- OC_Filesystem::signal_param_path => $path2,
- OC_Filesystem::signal_param_run => &$run
- )
- );
- }
- if($run) {
- OC_Hook::emit(
- OC_Filesystem::CLASSNAME,
- OC_Filesystem::signal_write,
- array(
- OC_Filesystem::signal_param_path => $path2,
+ OC_Filesystem::signal_param_oldpath => $path1,
+ OC_Filesystem::signal_param_newpath=>$path2,
OC_Filesystem::signal_param_run => &$run
)
);
+ $exists=$this->file_exists($path2);
+ if($run and !$exists) {
+ OC_Hook::emit(
+ OC_Filesystem::CLASSNAME,
+ OC_Filesystem::signal_create,
+ array(
+ OC_Filesystem::signal_param_path => $path2,
+ OC_Filesystem::signal_param_run => &$run
+ )
+ );
+ }
+ if($run) {
+ OC_Hook::emit(
+ OC_Filesystem::CLASSNAME,
+ OC_Filesystem::signal_write,
+ array(
+ OC_Filesystem::signal_param_path => $path2,
+ OC_Filesystem::signal_param_run => &$run
+ )
+ );
+ }
}
if($run) {
$mp1=$this->getMountPoint($path1.$postFix1);
@@ -420,26 +430,30 @@ class OC_FilesystemView {
$target = $this->fopen($path2.$postFix2, 'w');
$result = OC_Helper::streamCopy($source, $target);
}
- OC_Hook::emit(
- OC_Filesystem::CLASSNAME,
- OC_Filesystem::signal_post_copy,
- array(
- OC_Filesystem::signal_param_oldpath => $path1,
- OC_Filesystem::signal_param_newpath=>$path2
- )
- );
- if(!$exists) {
+ if( $this->fakeRoot==OC_Filesystem::getRoot() ){
OC_Hook::emit(
OC_Filesystem::CLASSNAME,
- OC_Filesystem::signal_post_create,
- array(OC_Filesystem::signal_param_path => $path2)
+ OC_Filesystem::signal_post_copy,
+ array(
+ OC_Filesystem::signal_param_oldpath => $path1,
+ OC_Filesystem::signal_param_newpath=>$path2
+ )
);
+ if(!$exists) {
+ OC_Hook::emit(
+ OC_Filesystem::CLASSNAME,
+ OC_Filesystem::signal_post_create,
+ array(OC_Filesystem::signal_param_path => $path2)
+ );
+ }
+ OC_Hook::emit(
+ OC_Filesystem::CLASSNAME,
+ OC_Filesystem::signal_post_write,
+ array( OC_Filesystem::signal_param_path => $path2)
+ );
+ } else { // no real copy, file comes from somewhere else, e.g. version rollback -> just update the file cache without all the other post_write actions
+ OC_FileCache_Update::update($path2, $this->fakeRoot);
}
- OC_Hook::emit(
- OC_Filesystem::CLASSNAME,
- OC_Filesystem::signal_post_write,
- array( OC_Filesystem::signal_param_path => $path2)
- );
return $result;
}
}
diff --git a/lib/group.php b/lib/group.php
index b56a4ad456c..66892a99b60 100644
--- a/lib/group.php
+++ b/lib/group.php
@@ -35,12 +35,15 @@
*/
class OC_Group {
// The backend used for group management
+ /**
+ * @var OC_Group_Interface[]
+ */
private static $_usedBackends = array();
/**
* @brief set the group backend
* @param string $backend The backend to use for user managment
- * @returns true/false
+ * @return bool
*/
public static function useBackend( $backend ) {
if($backend instanceof OC_Group_Interface) {
@@ -57,10 +60,10 @@ class OC_Group {
/**
* @brief Try to create a new group
- * @param $gid The name of the group to create
- * @returns true/false
+ * @param string $gid The name of the group to create
+ * @return bool
*
- * Trys to create a new group. If the group name already exists, false will
+ * Tries to create a new group. If the group name already exists, false will
* be returned. Basic checking of Group name
*
* Allowed characters in the username are: "a-z", "A-Z", "0-9" and "_.@-"
@@ -94,6 +97,7 @@ class OC_Group {
return true;
}
+ return false;
}else{
return false;
}
@@ -101,8 +105,8 @@ class OC_Group {
/**
* @brief delete a group
- * @param $gid gid of the group to delete
- * @returns true/false
+ * @param string $gid gid of the group to delete
+ * @return bool
*
* Deletes a group and removes it from the group_user-table
*/
@@ -126,6 +130,7 @@ class OC_Group {
return true;
}
+ return false;
}else{
return false;
}
@@ -133,9 +138,9 @@ class OC_Group {
/**
* @brief is user in group?
- * @param $uid uid of the user
- * @param $gid gid of the group
- * @returns true/false
+ * @param string $uid uid of the user
+ * @param string $gid gid of the group
+ * @return bool
*
* Checks whether the user is member of a group or not.
*/
@@ -150,9 +155,9 @@ class OC_Group {
/**
* @brief Add a user to a group
- * @param $uid Name of the user to add to group
- * @param $gid Name of the group in which add the user
- * @returns true/false
+ * @param string $uid Name of the user to add to group
+ * @param string $gid Name of the group in which add the user
+ * @return bool
*
* Adds a user to a group.
*/
@@ -167,7 +172,7 @@ class OC_Group {
OC_Hook::emit( "OC_Group", "pre_addToGroup", array( "run" => &$run, "uid" => $uid, "gid" => $gid ));
if($run) {
- $succes=false;
+ $success=false;
//add the user to the all backends that have the group
foreach(self::$_usedBackends as $backend) {
@@ -175,13 +180,13 @@ class OC_Group {
continue;
if($backend->groupExists($gid)) {
- $succes|=$backend->addToGroup($uid, $gid);
+ $success|=$backend->addToGroup($uid, $gid);
}
}
- if($succes) {
+ if($success) {
OC_Hook::emit( "OC_User", "post_addToGroup", array( "uid" => $uid, "gid" => $gid ));
}
- return $succes;
+ return $success;
}else{
return false;
}
@@ -189,9 +194,9 @@ class OC_Group {
/**
* @brief Removes a user from a group
- * @param $uid Name of the user to remove from group
- * @param $gid Name of the group from which remove the user
- * @returns true/false
+ * @param string $uid Name of the user to remove from group
+ * @param string $gid Name of the group from which remove the user
+ * @return bool
*
* removes the user from a group.
*/
@@ -216,8 +221,8 @@ class OC_Group {
/**
* @brief Get all groups a user belongs to
- * @param $uid Name of the user
- * @returns array with group names
+ * @param string $uid Name of the user
+ * @return array with group names
*
* This function fetches all groups a user belongs to. It does not check
* if the user exists at all.
@@ -275,7 +280,10 @@ class OC_Group {
/**
* @brief get a list of all users in several groups
* @param array $gids
- * @returns array with user ids
+ * @param string $search
+ * @param int $limit
+ * @param int $offset
+ * @return array with user ids
*/
public static function usersInGroups($gids, $search = '', $limit = -1, $offset = 0) {
$users = array();
diff --git a/lib/group/backend.php b/lib/group/backend.php
index 1ba34c940cf..9ff432d0663 100644
--- a/lib/group/backend.php
+++ b/lib/group/backend.php
@@ -47,7 +47,7 @@ abstract class OC_Group_Backend implements OC_Group_Interface {
/**
* @brief Get all supported actions
- * @returns bitwise-or'ed actions
+ * @return int bitwise-or'ed actions
*
* Returns the supported actions as int to be
* compared with OC_USER_BACKEND_CREATE_USER etc.
@@ -65,8 +65,8 @@ abstract class OC_Group_Backend implements OC_Group_Interface {
/**
* @brief Check if backend implements actions
- * @param $actions bitwise-or'ed actions
- * @returns boolean
+ * @param int $actions bitwise-or'ed actions
+ * @return boolean
*
* Returns the supported actions as int to be
* compared with OC_GROUP_BACKEND_CREATE_GROUP etc.
@@ -77,9 +77,9 @@ abstract class OC_Group_Backend implements OC_Group_Interface {
/**
* @brief is user in group?
- * @param $uid uid of the user
- * @param $gid gid of the group
- * @returns true/false
+ * @param string $uid uid of the user
+ * @param string $gid gid of the group
+ * @return bool
*
* Checks whether the user is member of a group or not.
*/
@@ -89,8 +89,8 @@ abstract class OC_Group_Backend implements OC_Group_Interface {
/**
* @brief Get all groups a user belongs to
- * @param $uid Name of the user
- * @returns array with group names
+ * @param string $uid Name of the user
+ * @return array with group names
*
* This function fetches all groups a user belongs to. It does not check
* if the user exists at all.
@@ -101,7 +101,10 @@ abstract class OC_Group_Backend implements OC_Group_Interface {
/**
* @brief get a list of all groups
- * @returns array with group names
+ * @param string $search
+ * @param int $limit
+ * @param int $offset
+ * @return array with group names
*
* Returns a list with all groups
*/
@@ -121,7 +124,11 @@ abstract class OC_Group_Backend implements OC_Group_Interface {
/**
* @brief get a list of all users in a group
- * @returns array with user ids
+ * @param string $gid
+ * @param string $search
+ * @param int $limit
+ * @param int $offset
+ * @return array with user ids
*/
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
return array();
diff --git a/lib/group/database.php b/lib/group/database.php
index f3012563acf..6eca98ba019 100644
--- a/lib/group/database.php
+++ b/lib/group/database.php
@@ -44,10 +44,10 @@ class OC_Group_Database extends OC_Group_Backend {
/**
* @brief Try to create a new group
- * @param $gid The name of the group to create
- * @returns true/false
+ * @param string $gid The name of the group to create
+ * @return bool
*
- * Trys to create a new group. If the group name already exists, false will
+ * Tries to create a new group. If the group name already exists, false will
* be returned.
*/
public function createGroup( $gid ) {
@@ -70,28 +70,28 @@ class OC_Group_Database extends OC_Group_Backend {
/**
* @brief delete a group
- * @param $gid gid of the group to delete
- * @returns true/false
+ * @param string $gid gid of the group to delete
+ * @return bool
*
* Deletes a group and removes it from the group_user-table
*/
public function deleteGroup( $gid ) {
// Delete the group
$stmt = OC_DB::prepare( "DELETE FROM `*PREFIX*groups` WHERE `gid` = ?" );
- $result = $stmt->execute( array( $gid ));
+ $stmt->execute( array( $gid ));
// Delete the group-user relation
$stmt = OC_DB::prepare( "DELETE FROM `*PREFIX*group_user` WHERE `gid` = ?" );
- $result = $stmt->execute( array( $gid ));
+ $stmt->execute( array( $gid ));
return true;
}
/**
* @brief is user in group?
- * @param $uid uid of the user
- * @param $gid gid of the group
- * @returns true/false
+ * @param string $uid uid of the user
+ * @param string $gid gid of the group
+ * @return bool
*
* Checks whether the user is member of a group or not.
*/
@@ -105,9 +105,9 @@ class OC_Group_Database extends OC_Group_Backend {
/**
* @brief Add a user to a group
- * @param $uid Name of the user to add to group
- * @param $gid Name of the group in which add the user
- * @returns true/false
+ * @param string $uid Name of the user to add to group
+ * @param string $gid Name of the group in which add the user
+ * @return bool
*
* Adds a user to a group.
*/
@@ -124,9 +124,9 @@ class OC_Group_Database extends OC_Group_Backend {
/**
* @brief Removes a user from a group
- * @param $uid Name of the user to remove from group
- * @param $gid Name of the group from which remove the user
- * @returns true/false
+ * @param string $uid Name of the user to remove from group
+ * @param string $gid Name of the group from which remove the user
+ * @return bool
*
* removes the user from a group.
*/
@@ -139,8 +139,8 @@ class OC_Group_Database extends OC_Group_Backend {
/**
* @brief Get all groups a user belongs to
- * @param $uid Name of the user
- * @returns array with group names
+ * @param string $uid Name of the user
+ * @return array with group names
*
* This function fetches all groups a user belongs to. It does not check
* if the user exists at all.
@@ -160,7 +160,10 @@ class OC_Group_Database extends OC_Group_Backend {
/**
* @brief get a list of all groups
- * @returns array with group names
+ * @param string $search
+ * @param int $limit
+ * @param int $offset
+ * @return array with group names
*
* Returns a list with all groups
*/
@@ -190,7 +193,11 @@ class OC_Group_Database extends OC_Group_Backend {
/**
* @brief get a list of all users in a group
- * @returns array with user ids
+ * @param string $gid
+ * @param string $search
+ * @param int $limit
+ * @param int $offset
+ * @return array with user ids
*/
public function usersInGroup($gid, $search = '', $limit = null, $offset = null) {
$stmt = OC_DB::prepare('SELECT `uid` FROM `*PREFIX*group_user` WHERE `gid` = ? AND `uid` LIKE ?', $limit, $offset);
diff --git a/lib/group/interface.php b/lib/group/interface.php
index 12cc07a5374..4ef3663837f 100644
--- a/lib/group/interface.php
+++ b/lib/group/interface.php
@@ -24,8 +24,8 @@
interface OC_Group_Interface {
/**
* @brief Check if backend implements actions
- * @param $actions bitwise-or'ed actions
- * @returns boolean
+ * @param int $actions bitwise-or'ed actions
+ * @return boolean
*
* Returns the supported actions as int to be
* compared with OC_GROUP_BACKEND_CREATE_GROUP etc.
@@ -34,9 +34,9 @@ interface OC_Group_Interface {
/**
* @brief is user in group?
- * @param $uid uid of the user
- * @param $gid gid of the group
- * @returns true/false
+ * @param string $uid uid of the user
+ * @param string $gid gid of the group
+ * @return bool
*
* Checks whether the user is member of a group or not.
*/
@@ -44,8 +44,8 @@ interface OC_Group_Interface {
/**
* @brief Get all groups a user belongs to
- * @param $uid Name of the user
- * @returns array with group names
+ * @param string $uid Name of the user
+ * @return array with group names
*
* This function fetches all groups a user belongs to. It does not check
* if the user exists at all.
@@ -54,7 +54,10 @@ interface OC_Group_Interface {
/**
* @brief get a list of all groups
- * @returns array with group names
+ * @param string $search
+ * @param int $limit
+ * @param int $offset
+ * @return array with group names
*
* Returns a list with all groups
*/
@@ -69,8 +72,12 @@ interface OC_Group_Interface {
/**
* @brief get a list of all users in a group
- * @returns array with user ids
+ * @param string $gid
+ * @param string $search
+ * @param int $limit
+ * @param int $offset
+ * @return array with user ids
*/
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0);
-} \ No newline at end of file
+}
diff --git a/lib/helper.php b/lib/helper.php
index 269327b531d..f5eb2cc86bb 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -44,10 +44,10 @@ class OC_Helper {
/**
* @brief Creates an url
- * @param $app app
- * @param $file file
- * @param $args array with param=>value, will be appended to the returned url
- * @returns the url
+ * @param string $app app
+ * @param string $file file
+ * @param array $args array with param=>value, will be appended to the returned url
+ * @return string the url
*
* Returns a url to the given app and file.
*/
@@ -76,8 +76,11 @@ class OC_Helper {
}
}
- foreach($args as $k => $v) {
- $urlLinkTo .= '&'.$k.'='.$v;
+ if (!empty($args)) {
+ $urlLinkTo .= '?';
+ foreach($args as $k => $v) {
+ $urlLinkTo .= '&'.$k.'='.$v;
+ }
}
return $urlLinkTo;
@@ -85,10 +88,10 @@ class OC_Helper {
/**
* @brief Creates an absolute url
- * @param $app app
- * @param $file file
- * @param $args array with param=>value, will be appended to the returned url
- * @returns the url
+ * @param string $app app
+ * @param string $file file
+ * @param array $args array with param=>value, will be appended to the returned url
+ * @return string the url
*
* Returns a absolute url to the given app and file.
*/
@@ -99,8 +102,8 @@ class OC_Helper {
/**
* @brief Makes an $url absolute
- * @param $url the url
- * @returns the absolute url
+ * @param string $url the url
+ * @return string the absolute url
*
* Returns a absolute url to the given app and file.
*/
@@ -111,8 +114,8 @@ class OC_Helper {
/**
* @brief Creates an absolute url for remote use
- * @param $service id
- * @returns the url
+ * @param string $service id
+ * @return string the url
*
* Returns a absolute url to the given service.
*/
@@ -122,8 +125,8 @@ class OC_Helper {
/**
* @brief Creates an absolute url for public use
- * @param $service id
- * @returns the url
+ * @param string $service id
+ * @return string the url
*
* Returns a absolute url to the given service.
*/
@@ -133,9 +136,9 @@ class OC_Helper {
/**
* @brief Creates path to an image
- * @param $app app
- * @param $image image name
- * @returns the url
+ * @param string $app app
+ * @param string $image image name
+ * @return string the url
*
* Returns the path to the image.
*/
@@ -164,8 +167,8 @@ class OC_Helper {
/**
* @brief get path to icon of file type
- * @param $mimetype mimetype
- * @returns the url
+ * @param string $mimetype mimetype
+ * @return string the url
*
* Returns the path to the image of this file type.
*/
@@ -198,8 +201,8 @@ class OC_Helper {
/**
* @brief Make a human file size
- * @param $bytes file size in bytes
- * @returns a human readable file size
+ * @param int $bytes file size in bytes
+ * @return string a human readable file size
*
* Makes 2048 to 2 kB.
*/
@@ -223,15 +226,14 @@ class OC_Helper {
/**
* @brief Make a computer file size
- * @param $str file size in a fancy format
- * @returns a file size in bytes
+ * @param string $str file size in a fancy format
+ * @return int a file size in bytes
*
* Makes 2kB to 2048.
*
* Inspired by: http://www.php.net/manual/en/function.filesize.php#92418
*/
public static function computerFileSize( $str ) {
- $bytes = 0;
$str=strtolower($str);
$bytes_array = array(
@@ -260,10 +262,10 @@ class OC_Helper {
}
/**
- * @brief Recusive editing of file permissions
- * @param $path path to file or folder
- * @param $filemode unix style file permissions as integer
- *
+ * @brief Recursive editing of file permissions
+ * @param string $path path to file or folder
+ * @param int $filemode unix style file permissions
+ * @return bool
*/
static function chmodr($path, $filemode) {
if (!is_dir($path))
@@ -288,7 +290,7 @@ class OC_Helper {
}
/**
- * @brief Recusive copying of folders
+ * @brief Recursive copying of folders
* @param string $src source folder
* @param string $dest target folder
*
@@ -310,9 +312,9 @@ class OC_Helper {
}
/**
- * @brief Recusive deletion of folders
+ * @brief Recursive deletion of folders
* @param string $dir path to the folder
- *
+ * @return bool
*/
static function rmdirr($dir) {
if(is_dir($dir)) {
@@ -328,12 +330,14 @@ class OC_Helper {
}
if(file_exists($dir)) {
return false;
+ }else{
+ return true;
}
}
/**
* get the mimetype form a local file
- * @param string path
+ * @param string $path
* @return string
* does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead
*/
@@ -390,7 +394,7 @@ class OC_Helper {
/**
* get the mimetype form a data string
- * @param string data
+ * @param string $data
* @return string
*/
static function getStringMimeType($data) {
@@ -410,9 +414,9 @@ class OC_Helper {
/**
* @brief Checks $_REQUEST contains a var for the $s key. If so, returns the html-escaped value of this var; otherwise returns the default value provided by $d.
- * @param $s name of the var to escape, if set.
- * @param $d default value.
- * @returns the print-safe value.
+ * @param string $s name of the var to escape, if set.
+ * @param string $d default value.
+ * @return string the print-safe value.
*
*/
@@ -426,7 +430,7 @@ class OC_Helper {
}
/**
- * returns "checked"-attribut if request contains selected radio element OR if radio element is the default one -- maybe?
+ * returns "checked"-attribute if request contains selected radio element OR if radio element is the default one -- maybe?
* @param string $s Name of radio-button element name
* @param string $v Value of current radio-button element
* @param string $d Value of default radio-button element
@@ -439,8 +443,8 @@ class OC_Helper {
/**
* detect if a given program is found in the search PATH
*
- * @param string program name
- * @param string optional search path, defaults to $PATH
+ * @param string $program name
+ * @param string $optional search path, defaults to $PATH
* @return bool true if executable program found in path
*/
public static function canExecute($name, $path = false) {
@@ -462,18 +466,16 @@ class OC_Helper {
$dirs = explode(PATH_SEPARATOR, $path);
// WARNING : We have to check if open_basedir is enabled :
$obd = ini_get('open_basedir');
- if($obd != "none")
+ if($obd != "none"){
$obd_values = explode(PATH_SEPARATOR, $obd);
- if(count($obd_values) > 0 and $obd_values[0])
- {
- // open_basedir is in effect !
- // We need to check if the program is in one of these dirs :
- $dirs = $obd_values;
- }
- foreach($dirs as $dir)
- {
- foreach($exts as $ext)
- {
+ if(count($obd_values) > 0 and $obd_values[0]){
+ // open_basedir is in effect !
+ // We need to check if the program is in one of these dirs :
+ $dirs = $obd_values;
+ }
+ }
+ foreach($dirs as $dir){
+ foreach($exts as $ext){
if($check_fn("$dir/$name".$ext))
return true;
}
@@ -483,8 +485,8 @@ class OC_Helper {
/**
* copy the contents of one stream to another
- * @param resource source
- * @param resource target
+ * @param resource $source
+ * @param resource $target
* @return int the number of bytes copied
*/
public static function streamCopy($source,$target) {
@@ -500,7 +502,7 @@ class OC_Helper {
/**
* create a temporary file with an unique filename
- * @param string postfix
+ * @param string $postfix
* @return string
*
* temporary files are automatically cleaned up after the script is finished
@@ -564,10 +566,10 @@ class OC_Helper {
$ext = substr($filename, $pos);
} else {
$name = $filename;
+ $ext = '';
}
$newpath = $path . '/' . $filename;
- $newname = $filename;
$counter = 2;
while (OC_Filesystem::file_exists($newpath)) {
$newname = $name . ' (' . $counter . ')' . $ext;
@@ -581,8 +583,8 @@ class OC_Helper {
/*
* checks if $sub is a subdirectory of $parent
*
- * @param $sub
- * @param $parent
+ * @param string $sub
+ * @param string $parent
* @return bool
*/
public static function issubdirectory($sub, $parent) {
@@ -615,9 +617,9 @@ class OC_Helper {
/**
* @brief Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is.
*
- * @param $input The array to work on
- * @param $case Either MB_CASE_UPPER or MB_CASE_LOWER (default)
- * @param $encoding The encoding parameter is the character encoding. Defaults to UTF-8
+ * @param array $input The array to work on
+ * @param int $case Either MB_CASE_UPPER or MB_CASE_LOWER (default)
+ * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8
* @return array
*
* Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is.
@@ -636,11 +638,11 @@ class OC_Helper {
/**
* @brief replaces a copy of string delimited by the start and (optionally) length parameters with the string given in replacement.
*
- * @param $input The input string. .Opposite to the PHP build-in function does not accept an array.
- * @param $replacement The replacement string.
- * @param $start If start is positive, the replacing will begin at the start'th offset into string. If start is negative, the replacing will begin at the start'th character from the end of string.
- * @param $length Length of the part to be replaced
- * @param $encoding The encoding parameter is the character encoding. Defaults to UTF-8
+ * @param string $input The input string. .Opposite to the PHP build-in function does not accept an array.
+ * @param string $replacement The replacement string.
+ * @param int $start If start is positive, the replacing will begin at the start'th offset into string. If start is negative, the replacing will begin at the start'th character from the end of string.
+ * @param int $length Length of the part to be replaced
+ * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8
* @return string
*
*/
@@ -657,18 +659,18 @@ class OC_Helper {
/**
* @brief Replace all occurrences of the search string with the replacement string
*
- * @param $search The value being searched for, otherwise known as the needle. String.
- * @param $replace The replacement string.
- * @param $subject The string or array being searched and replaced on, otherwise known as the haystack.
- * @param $encoding The encoding parameter is the character encoding. Defaults to UTF-8
- * @param $count If passed, this will be set to the number of replacements performed.
+ * @param string $search The value being searched for, otherwise known as the needle.
+ * @param string $replace The replacement
+ * @param string $subject The string or array being searched and replaced on, otherwise known as the haystack.
+ * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8
+ * @param int $count If passed, this will be set to the number of replacements performed.
* @return string
*
*/
public static function mb_str_replace($search, $replace, $subject, $encoding = 'UTF-8', &$count = null) {
$offset = -1;
$length = mb_strlen($search, $encoding);
- while(($i = mb_strrpos($subject, $search, $offset, $encoding))) {
+ while(($i = mb_strrpos($subject, $search, $offset, $encoding)) !== false ) {
$subject = OC_Helper::mb_substr_replace($subject, $replace, $i, $length);
$offset = $i - mb_strlen($subject, $encoding) - 1;
$count++;
@@ -678,10 +680,10 @@ class OC_Helper {
/**
* @brief performs a search in a nested array
- * @param haystack the array to be searched
- * @param needle the search string
- * @param $index optional, only search this key name
- * @return the key of the matching field, otherwise false
+ * @param array $haystack the array to be searched
+ * @param string $needle the search string
+ * @param string $index optional, only search this key name
+ * @return mixed the key of the matching field, otherwise false
*
* performs a search in a nested array
*
diff --git a/lib/hook.php b/lib/hook.php
index 1bf80f604f6..26a53693748 100644
--- a/lib/hook.php
+++ b/lib/hook.php
@@ -9,11 +9,11 @@ class OC_Hook{
/**
* @brief connects a function to a hook
- * @param $signalclass class name of emitter
- * @param $signalname name of signal
- * @param $slotclass class name of slot
- * @param $slotname name of slot
- * @returns true/false
+ * @param string $signalclass class name of emitter
+ * @param string $signalname name of signal
+ * @param string $slotclass class name of slot
+ * @param string $slotname name of slot
+ * @return bool
*
* This function makes it very easy to connect to use hooks.
*
@@ -38,11 +38,11 @@ class OC_Hook{
}
/**
- * @brief emitts a signal
- * @param $signalclass class name of emitter
- * @param $signalname name of signal
- * @param $params defautl: array() array with additional data
- * @returns true if slots exists or false if not
+ * @brief emits a signal
+ * @param string $signalclass class name of emitter
+ * @param string $signalname name of signal
+ * @param array $params defautl: array() array with additional data
+ * @return bool, true if slots exists or false if not
*
* Emits a signal. To get data from the slot use references!
*
@@ -68,8 +68,8 @@ class OC_Hook{
/**
* clear hooks
- * @param string signalclass
- * @param string signalname
+ * @param string $signalclass
+ * @param string $signalname
*/
static public function clear($signalclass='', $signalname='') {
if($signalclass) {
diff --git a/lib/image.php b/lib/image.php
index f4b3c2cc071..861353e039d 100644
--- a/lib/image.php
+++ b/lib/image.php
@@ -543,21 +543,7 @@ class OC_Image {
$new_height = $maxsize;
}
- $process = imagecreatetruecolor(round($new_width), round($new_height));
- if ($process == false) {
- OC_Log::write('core',__METHOD__.'(): Error creating true color image',OC_Log::ERROR);
- imagedestroy($process);
- return false;
- }
-
- imagecopyresampled($process, $this->resource, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig);
- if ($process == false) {
- OC_Log::write('core',__METHOD__.'(): Error resampling process image '.$new_width.'x'.$new_height,OC_Log::ERROR);
- imagedestroy($process);
- return false;
- }
- imagedestroy($this->resource);
- $this->resource = $process;
+ $this->preciseResize(round($new_width), round($new_height));
return true;
}
@@ -666,6 +652,28 @@ class OC_Image {
return true;
}
+ /**
+ * @brief Resizes the image to fit within a boundry while preserving ratio.
+ * @param $maxWidth
+ * @param $maxHeight
+ * @returns bool
+ */
+ public function fitIn($maxWidth, $maxHeight) {
+ if(!$this->valid()) {
+ OC_Log::write('core',__METHOD__.'(): No image loaded', OC_Log::ERROR);
+ return false;
+ }
+ $width_orig=imageSX($this->resource);
+ $height_orig=imageSY($this->resource);
+ $ratio = $width_orig/$height_orig;
+
+ $newWidth = min($maxWidth, $ratio*$maxHeight);
+ $newHeight = min($maxHeight, $maxWidth/$ratio);
+
+ $this->preciseResize(round($newWidth), round($newHeight));
+ return true;
+ }
+
public function destroy() {
if($this->valid()) {
imagedestroy($this->resource);
diff --git a/lib/l10n.php b/lib/l10n.php
index 90877cbd747..4eb4c323d88 100644
--- a/lib/l10n.php
+++ b/lib/l10n.php
@@ -140,7 +140,7 @@ class OC_L10N{
/**
* @brief Translating
* @param $text String The text we need a translation for
- * @param array|\default $parameters default:array() Parameters for sprintf
+ * @param array $parameters default:array() Parameters for sprintf
* @return \OC_L10N_String Translation or the same text
*
* Returns the translation. If no translation is found, $text will be
diff --git a/lib/l10n/da.php b/lib/l10n/da.php
index 7a9ee26b477..09124c18290 100644
--- a/lib/l10n/da.php
+++ b/lib/l10n/da.php
@@ -21,5 +21,8 @@
"last month" => "Sidste måned",
"months ago" => "måneder siden",
"last year" => "Sidste år",
-"years ago" => "år siden"
+"years ago" => "år siden",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s er tilgængelig. Få <a href=\"%s\">mere information</a>",
+"up to date" => "opdateret",
+"updates check is disabled" => "Check for opdateringer er deaktiveret"
);
diff --git a/lib/l10n/de.php b/lib/l10n/de.php
index 4a567003de2..8c81be16582 100644
--- a/lib/l10n/de.php
+++ b/lib/l10n/de.php
@@ -11,13 +11,13 @@
"Selected files too large to generate zip file." => "Die gewählten Dateien sind zu groß, um eine ZIP-Datei zu erstellen.",
"Application is not enabled" => "Die Anwendung ist nicht aktiviert",
"Authentication error" => "Authentifizierungs-Fehler",
-"Token expired. Please reload page." => "Token abgelaufen. Bitte laden Sie die Seite neu.",
+"Token expired. Please reload page." => "Token abgelaufen. Bitte lade die Seite neu.",
"seconds ago" => "Vor wenigen Sekunden",
"1 minute ago" => "Vor einer Minute",
"%d minutes ago" => "Vor %d Minuten",
"today" => "Heute",
"yesterday" => "Gestern",
-"%d days ago" => "Vor %d Tagen",
+"%d days ago" => "Vor %d Tag(en)",
"last month" => "Letzten Monat",
"months ago" => "Vor Monaten",
"last year" => "Letztes Jahr",
diff --git a/lib/l10n/el.php b/lib/l10n/el.php
index d9f272258e1..e4e12490711 100644
--- a/lib/l10n/el.php
+++ b/lib/l10n/el.php
@@ -11,7 +11,7 @@
"Selected files too large to generate zip file." => "Τα επιλεγμένα αρχεία είναι μεγάλα ώστε να δημιουργηθεί αρχείο zip.",
"Application is not enabled" => "Δεν ενεργοποιήθηκε η εφαρμογή",
"Authentication error" => "Σφάλμα πιστοποίησης",
-"Token expired. Please reload page." => "Το αναγνωριστικό έληξε. Παρακαλώ επανα-φορτώστε την σελίδα.",
+"Token expired. Please reload page." => "Το αναγνωριστικό έληξε. Παρακαλώ φορτώστε ξανά την σελίδα.",
"seconds ago" => "δευτερόλεπτα πριν",
"1 minute ago" => "1 λεπτό πριν",
"%d minutes ago" => "%d λεπτά πριν",
@@ -21,5 +21,8 @@
"last month" => "τον προηγούμενο μήνα",
"months ago" => "μήνες πριν",
"last year" => "τον προηγούμενο χρόνο",
-"years ago" => "χρόνια πριν"
+"years ago" => "χρόνια πριν",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s είναι διαθέσιμα. Δείτε <a href=\"%s\">περισσότερες πληροφορίες</a>",
+"up to date" => "ενημερωμένο",
+"updates check is disabled" => "ο έλεγχος ενημερώσεων είναι απενεργοποιημένος"
);
diff --git a/lib/l10n/eo.php b/lib/l10n/eo.php
index 3f89e2eca73..b3c1c52ecee 100644
--- a/lib/l10n/eo.php
+++ b/lib/l10n/eo.php
@@ -21,5 +21,8 @@
"last month" => "lasta monato",
"months ago" => "monatojn antaŭe",
"last year" => "lasta jaro",
-"years ago" => "jarojn antaŭe"
+"years ago" => "jarojn antaŭe",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s haveblas. Ekhavu <a href=\"%s\">pli da informo</a>",
+"up to date" => "ĝisdata",
+"updates check is disabled" => "ĝisdateckontrolo estas malkapabligita"
);
diff --git a/lib/l10n/es_AR.php b/lib/l10n/es_AR.php
new file mode 100644
index 00000000000..fd50027d8a1
--- /dev/null
+++ b/lib/l10n/es_AR.php
@@ -0,0 +1,28 @@
+<?php $TRANSLATIONS = array(
+"Help" => "Ayuda",
+"Personal" => "Personal",
+"Settings" => "Ajustes",
+"Users" => "Usuarios",
+"Apps" => "Aplicaciones",
+"Admin" => "Administración",
+"ZIP download is turned off." => "La descarga en ZIP está desactivada.",
+"Files need to be downloaded one by one." => "Los archivos deben ser descargados de a uno.",
+"Back to Files" => "Volver a archivos",
+"Selected files too large to generate zip file." => "Los archivos seleccionados son demasiado grandes para generar el archivo zip.",
+"Application is not enabled" => "La aplicación no está habilitada",
+"Authentication error" => "Error de autenticación",
+"Token expired. Please reload page." => "Token expirado. Por favor, recargá la página.",
+"seconds ago" => "hace unos segundos",
+"1 minute ago" => "hace 1 minuto",
+"%d minutes ago" => "hace %d minutos",
+"today" => "hoy",
+"yesterday" => "ayer",
+"%d days ago" => "hace %d días",
+"last month" => "este mes",
+"months ago" => "hace meses",
+"last year" => "este año",
+"years ago" => "hace años",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s está disponible. Conseguí <a href=\"%s\">más información</a>",
+"up to date" => "actualizado",
+"updates check is disabled" => "comprobar actualizaciones está desactivado"
+);
diff --git a/lib/l10n/et_EE.php b/lib/l10n/et_EE.php
index d8da90a3cbf..87f222af838 100644
--- a/lib/l10n/et_EE.php
+++ b/lib/l10n/et_EE.php
@@ -21,5 +21,8 @@
"last month" => "eelmisel kuul",
"months ago" => "kuud tagasi",
"last year" => "eelmisel aastal",
-"years ago" => "aastat tagasi"
+"years ago" => "aastat tagasi",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s on saadaval. Vaata <a href=\"%s\">lisainfot</a>",
+"up to date" => "ajakohane",
+"updates check is disabled" => "uuenduste kontrollimine on välja lülitatud"
);
diff --git a/lib/l10n/gl.php b/lib/l10n/gl.php
new file mode 100644
index 00000000000..7a9de627c2d
--- /dev/null
+++ b/lib/l10n/gl.php
@@ -0,0 +1,28 @@
+<?php $TRANSLATIONS = array(
+"Help" => "Axuda",
+"Personal" => "Personal",
+"Settings" => "Preferencias",
+"Users" => "Usuarios",
+"Apps" => "Apps",
+"Admin" => "Administración",
+"ZIP download is turned off." => "Descargas ZIP está deshabilitadas",
+"Files need to be downloaded one by one." => "Os ficheiros necesitan ser descargados de un en un",
+"Back to Files" => "Voltar a ficheiros",
+"Selected files too large to generate zip file." => "Os ficheiros seleccionados son demasiado grandes para xerar un ficheiro ZIP",
+"Application is not enabled" => "O aplicativo non está habilitado",
+"Authentication error" => "Erro na autenticación",
+"Token expired. Please reload page." => "Testemuño caducado. Por favor recargue a páxina.",
+"seconds ago" => "hai segundos",
+"1 minute ago" => "hai 1 minuto",
+"%d minutes ago" => "hai %d minutos",
+"today" => "hoxe",
+"yesterday" => "onte",
+"%d days ago" => "hai %d días",
+"last month" => "último mes",
+"months ago" => "meses atrás",
+"last year" => "último ano",
+"years ago" => "anos atrás",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s está dispoñible. Obteña <a href=\"%s\">máis información</a>",
+"up to date" => "ao día",
+"updates check is disabled" => "comprobación de actualizacións está deshabilitada"
+);
diff --git a/lib/l10n/pt_BR.php b/lib/l10n/pt_BR.php
new file mode 100644
index 00000000000..1455eabbc94
--- /dev/null
+++ b/lib/l10n/pt_BR.php
@@ -0,0 +1,28 @@
+<?php $TRANSLATIONS = array(
+"Help" => "Ajuda",
+"Personal" => "Pessoal",
+"Settings" => "Ajustes",
+"Users" => "Usuários",
+"Apps" => "Aplicações",
+"Admin" => "Admin",
+"ZIP download is turned off." => "Download ZIP está desligado.",
+"Files need to be downloaded one by one." => "Arquivos precisam ser baixados um de cada vez.",
+"Back to Files" => "Voltar para Arquivos",
+"Selected files too large to generate zip file." => "Arquivos selecionados são muito grandes para gerar arquivo zip.",
+"Application is not enabled" => "Aplicação não está habilitada",
+"Authentication error" => "Erro de autenticação",
+"Token expired. Please reload page." => "Token expirou. Por favor recarregue a página.",
+"seconds ago" => "segundos atrás",
+"1 minute ago" => "1 minuto atrás",
+"%d minutes ago" => "%d minutos atrás",
+"today" => "hoje",
+"yesterday" => "ontem",
+"%d days ago" => "%d dias atrás",
+"last month" => "último mês",
+"months ago" => "meses atrás",
+"last year" => "último ano",
+"years ago" => "anos atrás",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s está disponível. Obtenha <a href=\"%s\">mais informações</a>",
+"up to date" => "atualizado",
+"updates check is disabled" => "checagens de atualização estão desativadas"
+);
diff --git a/lib/l10n/ro.php b/lib/l10n/ro.php
new file mode 100644
index 00000000000..5fffeec2335
--- /dev/null
+++ b/lib/l10n/ro.php
@@ -0,0 +1,28 @@
+<?php $TRANSLATIONS = array(
+"Help" => "Ajutor",
+"Personal" => "Personal",
+"Settings" => "Setări",
+"Users" => "Utilizatori",
+"Apps" => "Aplicații",
+"Admin" => "Admin",
+"ZIP download is turned off." => "Descărcarea ZIP este dezactivată.",
+"Files need to be downloaded one by one." => "Fișierele trebuie descărcate unul câte unul.",
+"Back to Files" => "Înapoi la fișiere",
+"Selected files too large to generate zip file." => "Fișierele selectate sunt prea mari pentru a genera un fișier zip.",
+"Application is not enabled" => "Aplicația nu este activată",
+"Authentication error" => "Eroare la autentificare",
+"Token expired. Please reload page." => "Token expirat. Te rugăm să reîncarci pagina.",
+"seconds ago" => "secunde în urmă",
+"1 minute ago" => "1 minut în urmă",
+"%d minutes ago" => "%d minute în urmă",
+"today" => "astăzi",
+"yesterday" => "ieri",
+"%d days ago" => "%d zile în urmă",
+"last month" => "ultima lună",
+"months ago" => "luni în urmă",
+"last year" => "ultimul an",
+"years ago" => "ani în urmă",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s este disponibil. Vezi <a href=\"%s\">mai multe informații</a>",
+"up to date" => "la zi",
+"updates check is disabled" => "verificarea după actualizări este dezactivată"
+);
diff --git a/lib/l10n/ru.php b/lib/l10n/ru.php
index 3b2681ba8d1..74425f0e134 100644
--- a/lib/l10n/ru.php
+++ b/lib/l10n/ru.php
@@ -22,5 +22,7 @@
"months ago" => "месяцы назад",
"last year" => "в прошлом году",
"years ago" => "годы назад",
+"%s is available. Get <a href=\"%s\">more information</a>" => "Возможно обновление до %s. <a href=\"%s\">Подробнее</a>",
+"up to date" => "актуальная версия",
"updates check is disabled" => "проверка обновлений отключена"
);
diff --git a/lib/l10n/ru_RU.php b/lib/l10n/ru_RU.php
new file mode 100644
index 00000000000..1e691993014
--- /dev/null
+++ b/lib/l10n/ru_RU.php
@@ -0,0 +1,27 @@
+<?php $TRANSLATIONS = array(
+"Help" => "Помощь",
+"Personal" => "Персональный",
+"Settings" => "Настройки",
+"Users" => "Пользователи",
+"Apps" => "Приложения",
+"Admin" => "Админ",
+"Files need to be downloaded one by one." => "Файлы должны быть загружены один за другим.",
+"Back to Files" => "Обратно к файлам",
+"Selected files too large to generate zip file." => "Выбранные файлы слишком велики для генерации zip-архива.",
+"Application is not enabled" => "Приложение не запущено",
+"Authentication error" => "Ошибка аутентификации",
+"Token expired. Please reload page." => "Маркер истек. Пожалуйста, перезагрузите страницу.",
+"seconds ago" => "секунд назад",
+"1 minute ago" => "1 минуту назад",
+"%d minutes ago" => "%d минут назад",
+"today" => "сегодня",
+"yesterday" => "вчера",
+"%d days ago" => "%d дней назад",
+"last month" => "в прошлом месяце",
+"months ago" => "месяц назад",
+"last year" => "в прошлом году",
+"years ago" => "год назад",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s доступно. Получите <a href=\"%s\">more information</a>",
+"up to date" => "до настоящего времени",
+"updates check is disabled" => "Проверка обновлений отключена"
+);
diff --git a/lib/l10n/sk_SK.php b/lib/l10n/sk_SK.php
new file mode 100644
index 00000000000..33b329c30bb
--- /dev/null
+++ b/lib/l10n/sk_SK.php
@@ -0,0 +1,25 @@
+<?php $TRANSLATIONS = array(
+"Help" => "Pomoc",
+"Personal" => "Osobné",
+"Settings" => "Nastavenia",
+"Users" => "Užívatelia",
+"Apps" => "Aplikácie",
+"Admin" => "Správca",
+"ZIP download is turned off." => "Sťahovanie súborov ZIP je vypnuté.",
+"Files need to be downloaded one by one." => "Súbory musia byť nahrávané jeden za druhým.",
+"Back to Files" => "Späť na súbory",
+"Selected files too large to generate zip file." => "Zvolené súbory sú príliž veľké na vygenerovanie zip súboru.",
+"Application is not enabled" => "Aplikácia nie je zapnutá",
+"Authentication error" => "Chyba autentifikácie",
+"1 minute ago" => "pred 1 minútou",
+"%d minutes ago" => "pred %d minútami",
+"today" => "dnes",
+"yesterday" => "včera",
+"%d days ago" => "pred %d dňami",
+"last month" => "minulý mesiac",
+"months ago" => "pred mesiacmi",
+"last year" => "minulý rok",
+"years ago" => "pred rokmi",
+"up to date" => "aktuálny",
+"updates check is disabled" => "sledovanie aktualizácií je vypnuté"
+);
diff --git a/lib/l10n/sl.php b/lib/l10n/sl.php
index 273773f2f7b..eac839e78f3 100644
--- a/lib/l10n/sl.php
+++ b/lib/l10n/sl.php
@@ -12,16 +12,16 @@
"Application is not enabled" => "Aplikacija ni omogočena",
"Authentication error" => "Napaka overitve",
"Token expired. Please reload page." => "Žeton je potekel. Prosimo, če spletno stran znova naložite.",
-"seconds ago" => "sekund nazaj",
+"seconds ago" => "pred nekaj sekundami",
"1 minute ago" => "pred minuto",
"%d minutes ago" => "pred %d minutami",
"today" => "danes",
"yesterday" => "včeraj",
"%d days ago" => "pred %d dnevi",
"last month" => "prejšnji mesec",
-"months ago" => "mesecev nazaj",
+"months ago" => "pred nekaj meseci",
"last year" => "lani",
-"years ago" => "let nazaj",
+"years ago" => "pred nekaj leti",
"%s is available. Get <a href=\"%s\">more information</a>" => "%s je na voljo. <a href=\"%s\">Več informacij.</a>",
"up to date" => "ažuren",
"updates check is disabled" => "preverjanje za posodobitve je onemogočeno"
diff --git a/lib/l10n/uk.php b/lib/l10n/uk.php
index 18f6a4a623d..423aa12b2d7 100644
--- a/lib/l10n/uk.php
+++ b/lib/l10n/uk.php
@@ -20,5 +20,6 @@
"last month" => "минулого місяця",
"months ago" => "місяці тому",
"last year" => "минулого року",
-"years ago" => "роки тому"
+"years ago" => "роки тому",
+"updates check is disabled" => "перевірка оновлень відключена"
);
diff --git a/lib/l10n/vi.php b/lib/l10n/vi.php
new file mode 100644
index 00000000000..fc41d69819a
--- /dev/null
+++ b/lib/l10n/vi.php
@@ -0,0 +1,28 @@
+<?php $TRANSLATIONS = array(
+"Help" => "Giúp đỡ",
+"Personal" => "Cá nhân",
+"Settings" => "Cài đặt",
+"Users" => "Người dùng",
+"Apps" => "Ứng dụng",
+"Admin" => "Quản trị",
+"ZIP download is turned off." => "Tải về ZIP đã bị tắt.",
+"Files need to be downloaded one by one." => "Tập tin cần phải được tải về từng người một.",
+"Back to Files" => "Trở lại tập tin",
+"Selected files too large to generate zip file." => "Tập tin được chọn quá lớn để tạo tập tin ZIP.",
+"Application is not enabled" => "Ứng dụng không được BẬT",
+"Authentication error" => "Lỗi xác thực",
+"Token expired. Please reload page." => "Mã Token đã hết hạn. Hãy tải lại trang.",
+"seconds ago" => "1 giây trước",
+"1 minute ago" => "1 phút trước",
+"%d minutes ago" => "%d phút trước",
+"today" => "hôm nay",
+"yesterday" => "hôm qua",
+"%d days ago" => "%d ngày trước",
+"last month" => "tháng trước",
+"months ago" => "tháng trước",
+"last year" => "năm trước",
+"years ago" => "năm trước",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s có sẵn. <a href=\"%s\">xem thêm ở đây</a>",
+"up to date" => "đến ngày",
+"updates check is disabled" => "đã TĂT chức năng cập nhật "
+);
diff --git a/lib/l10n/zh_CN.GB2312.php b/lib/l10n/zh_CN.GB2312.php
new file mode 100644
index 00000000000..4b0a5e9f4d2
--- /dev/null
+++ b/lib/l10n/zh_CN.GB2312.php
@@ -0,0 +1,28 @@
+<?php $TRANSLATIONS = array(
+"Help" => "帮助",
+"Personal" => "私人",
+"Settings" => "设置",
+"Users" => "用户",
+"Apps" => "程序",
+"Admin" => "管理员",
+"ZIP download is turned off." => "ZIP 下载已关闭",
+"Files need to be downloaded one by one." => "需要逐个下载文件。",
+"Back to Files" => "返回到文件",
+"Selected files too large to generate zip file." => "选择的文件太大而不能生成 zip 文件。",
+"Application is not enabled" => "应用未启用",
+"Authentication error" => "验证错误",
+"Token expired. Please reload page." => "会话过期。请刷新页面。",
+"seconds ago" => "秒前",
+"1 minute ago" => "1 分钟前",
+"%d minutes ago" => "%d 分钟前",
+"today" => "今天",
+"yesterday" => "昨天",
+"%d days ago" => "%d 天前",
+"last month" => "上个月",
+"months ago" => "月前",
+"last year" => "去年",
+"years ago" => "年前",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s 不可用。获知 <a href=\"%s\">详情</a>",
+"up to date" => "最新",
+"updates check is disabled" => "更新检测已禁用"
+);
diff --git a/lib/migrate.php b/lib/migrate.php
index 823b3574f16..611a935ee5d 100644
--- a/lib/migrate.php
+++ b/lib/migrate.php
@@ -84,21 +84,15 @@ class OC_Migrate{
$types = array( 'user', 'instance', 'system', 'userfiles' );
if( !in_array( $type, $types ) ) {
OC_Log::write( 'migration', 'Invalid export type', OC_Log::ERROR );
- return json_encode( array( array( 'success' => false ) ) );
+ return json_encode( array( 'success' => false ) );
}
self::$exporttype = $type;
// Userid?
if( self::$exporttype == 'user' ) {
// Check user exists
- if( !is_null($uid) ) {
- $db = new OC_User_Database;
- if( !$db->userExists( $uid ) ) {
- OC_Log::write('migration', 'User: '.$uid.' is not in the database and so cannot be exported.', OC_Log::ERROR);
- return json_encode( array( 'success' => false ) );
- }
- self::$uid = $uid;
- } else {
- self::$uid = OC_User::getUser();
+ self::$uid = is_null($uid) ? OC_User::getUser() : $uid;
+ if(!OC_User::userExists(self::$uid)){
+ return json_encode( array( 'success' => false) );
}
}
// Calculate zipname
diff --git a/lib/migration/content.php b/lib/migration/content.php
index 64b8168cd98..89b1e782d86 100644
--- a/lib/migration/content.php
+++ b/lib/migration/content.php
@@ -30,7 +30,7 @@ class OC_Migration_Content{
// Holds the MDB2 object
private $db=null;
// Holds an array of tmpfiles to delete after zip creation
- private $tmpfiles=false;
+ private $tmpfiles=array();
/**
* @brief sets up the
@@ -43,18 +43,21 @@ class OC_Migration_Content{
$this->zip = $zip;
$this->db = $db;
- if( !is_null( $db ) ) {
- // Get db path
- $db = $this->db->getDatabase();
- $this->tmpfiles[] = $db;
- }
-
}
// @brief prepares the db
// @param $query the sql query to prepare
public function prepare( $query ) {
-
+
+ // Only add database to tmpfiles if actually used
+ if( !is_null( $this->db ) ) {
+ // Get db path
+ $db = $this->db->getDatabase();
+ if(!in_array($db, $this->tmpfiles)){
+ $this->tmpfiles[] = $db;
+ }
+ }
+
// Optimize the query
$query = $this->processQuery( $query );
diff --git a/lib/ocs.php b/lib/ocs.php
index 85b5234379b..60577ec5d57 100644
--- a/lib/ocs.php
+++ b/lib/ocs.php
@@ -85,7 +85,7 @@ class OC_OCS {
$method='get';
}elseif($_SERVER['REQUEST_METHOD'] == 'PUT') {
$method='put';
- parse_str(file_get_contents("php://input"),$put_vars);
+ parse_str(file_get_contents("php://input"), $put_vars);
}elseif($_SERVER['REQUEST_METHOD'] == 'POST') {
$method='post';
}else{
@@ -249,7 +249,7 @@ class OC_OCS {
} catch (ResourceNotFoundException $e) {
$txt='Invalid query, please check the syntax. API specifications are here: http://www.freedesktop.org/wiki/Specifications/open-collaboration-services. DEBUG OUTPUT:'."\n";
$txt.=OC_OCS::getdebugoutput();
- echo(OC_OCS::generatexml($format,'failed',999,$txt));
+ echo(OC_OCS::generatexml($format, 'failed', 999, $txt));
} catch (MethodNotAllowedException $e) {
OC_Response::setStatus(405);
}
@@ -292,7 +292,7 @@ class OC_OCS {
$identifieduser='';
}
}else{
- if(!OC_User::login($authuser,$authpw)) {
+ if(!OC_User::login($authuser, $authpw)) {
if($forceuser) {
header('WWW-Authenticate: Basic realm="your valid user account or api key"');
header('HTTP/1.0 401 Unauthorized');
@@ -338,69 +338,69 @@ class OC_OCS {
$writer = xmlwriter_open_memory();
xmlwriter_set_indent( $writer, 2 );
xmlwriter_start_document($writer );
- xmlwriter_start_element($writer,'ocs');
- xmlwriter_start_element($writer,'meta');
- xmlwriter_write_element($writer,'status',$status);
- xmlwriter_write_element($writer,'statuscode',$statuscode);
- xmlwriter_write_element($writer,'message',$message);
+ xmlwriter_start_element($writer, 'ocs');
+ xmlwriter_start_element($writer, 'meta');
+ xmlwriter_write_element($writer, 'status', $status);
+ xmlwriter_write_element($writer, 'statuscode', $statuscode);
+ xmlwriter_write_element($writer, 'message', $message);
if($itemscount<>'') xmlwriter_write_element($writer,'totalitems',$itemscount);
- if(!empty($itemsperpage)) xmlwriter_write_element($writer,'itemsperpage',$itemsperpage);
+ if(!empty($itemsperpage)) xmlwriter_write_element($writer, 'itemsperpage', $itemsperpage);
xmlwriter_end_element($writer);
if($dimension=='0') {
// 0 dimensions
- xmlwriter_write_element($writer,'data',$data);
+ xmlwriter_write_element($writer, 'data', $data);
}elseif($dimension=='1') {
- xmlwriter_start_element($writer,'data');
+ xmlwriter_start_element($writer, 'data');
foreach($data as $key=>$entry) {
- xmlwriter_write_element($writer,$key,$entry);
+ xmlwriter_write_element($writer, $key, $entry);
}
xmlwriter_end_element($writer);
}elseif($dimension=='2') {
xmlwriter_start_element($writer,'data');
foreach($data as $entry) {
- xmlwriter_start_element($writer,$tag);
- if(!empty($tagattribute)) {
- xmlwriter_write_attribute($writer,'details',$tagattribute);
- }
- foreach($entry as $key=>$value) {
- if(is_array($value)) {
- foreach($value as $k=>$v) {
- xmlwriter_write_element($writer,$k,$v);
- }
- } else {
- xmlwriter_write_element($writer,$key,$value);
- }
- }
- xmlwriter_end_element($writer);
- }
+ xmlwriter_start_element($writer, $tag);
+ if(!empty($tagattribute)) {
+ xmlwriter_write_attribute($writer, 'details', $tagattribute);
+ }
+ foreach($entry as $key=>$value) {
+ if(is_array($value)) {
+ foreach($value as $k=>$v) {
+ xmlwriter_write_element($writer, $k, $v);
+ }
+ } else {
+ xmlwriter_write_element($writer, $key, $value);
+ }
+ }
+ xmlwriter_end_element($writer);
+ }
xmlwriter_end_element($writer);
}elseif($dimension=='3') {
- xmlwriter_start_element($writer,'data');
+ xmlwriter_start_element($writer, 'data');
foreach($data as $entrykey=>$entry) {
- xmlwriter_start_element($writer,$tag);
- if(!empty($tagattribute)) {
- xmlwriter_write_attribute($writer,'details',$tagattribute);
- }
- foreach($entry as $key=>$value) {
- if(is_array($value)) {
- xmlwriter_start_element($writer,$entrykey);
- foreach($value as $k=>$v) {
- xmlwriter_write_element($writer,$k,$v);
- }
- xmlwriter_end_element($writer);
- } else {
- xmlwriter_write_element($writer,$key,$value);
- }
- }
- xmlwriter_end_element($writer);
+ xmlwriter_start_element($writer, $tag);
+ if(!empty($tagattribute)) {
+ xmlwriter_write_attribute($writer, 'details', $tagattribute);
+ }
+ foreach($entry as $key=>$value) {
+ if(is_array($value)) {
+ xmlwriter_start_element($writer, $entrykey);
+ foreach($value as $k=>$v) {
+ xmlwriter_write_element($writer, $k, $v);
+ }
+ xmlwriter_end_element($writer);
+ } else {
+ xmlwriter_write_element($writer, $key, $value);
+ }
+ }
+ xmlwriter_end_element($writer);
}
xmlwriter_end_element($writer);
}elseif($dimension=='dynamic') {
- xmlwriter_start_element($writer,'data');
- OC_OCS::toxml($writer,$data,'comment');
+ xmlwriter_start_element($writer, 'data');
+ OC_OCS::toxml($writer, $data, 'comment');
xmlwriter_end_element($writer);
}
@@ -419,18 +419,15 @@ class OC_OCS {
$key = $node;
}
if (is_array($value)) {
- xmlwriter_start_element($writer,$key);
- OC_OCS::toxml($writer,$value,$node);
+ xmlwriter_start_element($writer, $key);
+ OC_OCS::toxml($writer,$value, $node);
xmlwriter_end_element($writer);
}else{
- xmlwriter_write_element($writer,$key,$value);
+ xmlwriter_write_element($writer, $key, $value);
}
}
}
-
-
-
/**
* return the config data of this server
* @param string $format
@@ -439,17 +436,16 @@ class OC_OCS {
public static function apiConfig($parameters) {
$format = $parameters['format'];
$user=OC_OCS::checkpassword(false);
- $url=substr(OCP\Util::getServerHost().$_SERVER['SCRIPT_NAME'],0,-11).'';
+ $url=substr(OCP\Util::getServerHost().$_SERVER['SCRIPT_NAME'], 0, -11).'';
$xml['version']='1.7';
$xml['website']='ownCloud';
$xml['host']=OCP\Util::getServerHost();
$xml['contact']='';
$xml['ssl']='false';
- echo(OC_OCS::generatexml($format,'ok',100,'',$xml,'config','',1));
+ echo(OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'config', '', 1));
}
-
/**
* check if the provided login/apikey/password is valid
* @param string $format
@@ -459,19 +455,17 @@ class OC_OCS {
*/
private static function personCheck($format,$login,$passwd) {
if($login<>'') {
- if(OC_User::login($login,$passwd)) {
+ if(OC_User::login($login, $passwd)) {
$xml['person']['personid']=$login;
- echo(OC_OCS::generatexml($format,'ok',100,'',$xml,'person','check',2));
+ echo(OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'person', 'check', 2));
}else{
- echo(OC_OCS::generatexml($format,'failed',102,'login not valid'));
+ echo(OC_OCS::generatexml($format, 'failed', 102, 'login not valid'));
}
}else{
- echo(OC_OCS::generatexml($format,'failed',101,'please specify all mandatory fields'));
+ echo(OC_OCS::generatexml($format, 'failed', 101, 'please specify all mandatory fields'));
}
}
-
-
// ACTIVITY API #############################################
/**
@@ -481,12 +475,12 @@ class OC_OCS {
* @param string $pagesize
* @return string xml/json
*/
- private static function activityGet($format,$page,$pagesize) {
+ private static function activityGet($format, $page, $pagesize) {
$user=OC_OCS::checkpassword();
//TODO
- $txt=OC_OCS::generatexml($format,'ok',100,'',$xml,'activity','full',2,$totalcount,$pagesize);
+ $txt=OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'activity', 'full', 2, $totalcount,$pagesize);
echo($txt);
}
@@ -499,7 +493,7 @@ class OC_OCS {
private static function activityPut($format,$message) {
// not implemented in ownCloud
$user=OC_OCS::checkpassword();
- echo(OC_OCS::generatexml($format,'ok',100,''));
+ echo(OC_OCS::generatexml($format, 'ok', 100, ''));
}
// PRIVATEDATA API #############################################
@@ -511,9 +505,9 @@ class OC_OCS {
* @param string $key
* @return string xml/json
*/
- private static function privateDataGet($format,$app="",$key="") {
+ private static function privateDataGet($format, $app="", $key="") {
$user=OC_OCS::checkpassword();
- $result=OC_OCS::getData($user,$app,$key);
+ $result=OC_OCS::getData($user, $app, $key);
$xml=array();
foreach($result as $i=>$log) {
$xml[$i]['key']=$log['key'];
@@ -536,8 +530,8 @@ class OC_OCS {
*/
private static function privateDataSet($format, $app, $key, $value) {
$user=OC_OCS::checkpassword();
- if(OC_OCS::setData($user,$app,$key,$value)) {
- echo(OC_OCS::generatexml($format,'ok',100,''));
+ if(OC_OCS::setData($user, $app, $key, $value)) {
+ echo(OC_OCS::generatexml($format, 'ok', 100, ''));
}
}
@@ -553,8 +547,8 @@ class OC_OCS {
return; //key and app are NOT optional here
}
$user=OC_OCS::checkpassword();
- if(OC_OCS::deleteData($user,$app,$key)) {
- echo(OC_OCS::generatexml($format,'ok',100,''));
+ if(OC_OCS::deleteData($user, $app, $key)) {
+ echo(OC_OCS::generatexml($format, 'ok', 100, ''));
}
}
@@ -566,7 +560,7 @@ class OC_OCS {
* @param bool $like use LIKE instead of = when comparing keys
* @return array
*/
- public static function getData($user,$app="",$key="") {
+ public static function getData($user, $app="", $key="") {
if($app) {
$apps=array($app);
}else{
@@ -576,14 +570,14 @@ class OC_OCS {
$keys=array($key);
}else{
foreach($apps as $app) {
- $keys=OC_Preferences::getKeys($user,$app);
+ $keys=OC_Preferences::getKeys($user, $app);
}
}
$result=array();
foreach($apps as $app) {
foreach($keys as $key) {
- $value=OC_Preferences::getValue($user,$app,$key);
- $result[]=array('app'=>$app,'key'=>$key,'value'=>$value);
+ $value=OC_Preferences::getValue($user, $app, $key);
+ $result[]=array('app'=>$app, 'key'=>$key, 'value'=>$value);
}
}
return $result;
@@ -598,7 +592,7 @@ class OC_OCS {
* @return bool
*/
public static function setData($user, $app, $key, $value) {
- return OC_Preferences::setValue($user,$app,$key,$value);
+ return OC_Preferences::setValue($user, $app, $key, $value);
}
/**
@@ -609,7 +603,7 @@ class OC_OCS {
* @return string xml/json
*/
public static function deleteData($user, $app, $key) {
- return OC_Preferences::deleteKey($user,$app,$key);
+ return OC_Preferences::deleteKey($user, $app, $key);
}
diff --git a/lib/ocsclient.php b/lib/ocsclient.php
index 8596ea0b3c7..6428a883679 100644
--- a/lib/ocsclient.php
+++ b/lib/ocsclient.php
@@ -53,7 +53,7 @@ class OC_OCSClient{
/**
* @brief Get all the categories from the OCS server
* @returns array with category ids
- *
+ * @note returns NULL if config value appstoreenabled is set to false
* This function returns a list of all the application categories on the OCS server
*/
public static function getCategories() {
diff --git a/lib/preferences.php b/lib/preferences.php
index 3d61887785c..b198a18415c 100644
--- a/lib/preferences.php
+++ b/lib/preferences.php
@@ -40,7 +40,7 @@
class OC_Preferences{
/**
* @brief Get all users using the preferences
- * @returns array with user ids
+ * @return array with user ids
*
* This function returns a list of all users that have at least one entry
* in the preferences table.
@@ -60,8 +60,8 @@ class OC_Preferences{
/**
* @brief Get all apps of a user
- * @param $user user
- * @returns array with app ids
+ * @param string $user user
+ * @return array with app ids
*
* This function returns a list of all apps of the user that have at least
* one entry in the preferences table.
@@ -81,9 +81,9 @@ class OC_Preferences{
/**
* @brief Get the available keys for an app
- * @param $user user
- * @param $app the app we are looking for
- * @returns array with key names
+ * @param string $user user
+ * @param string $app the app we are looking for
+ * @return array with key names
*
* This function gets all keys of an app of an user. Please note that the
* values are not returned.
@@ -103,14 +103,14 @@ class OC_Preferences{
/**
* @brief Gets the preference
- * @param $user user
- * @param $app app
- * @param $key key
- * @param $default = null, default value if the key does not exist
- * @returns the value or $default
+ * @param string $user user
+ * @param string $app app
+ * @param string $key key
+ * @param string $default = null, default value if the key does not exist
+ * @return string the value or $default
*
- * This function gets a value from the prefernces table. If the key does
- * not exist the default value will be returnes
+ * This function gets a value from the preferences table. If the key does
+ * not exist the default value will be returned
*/
public static function getValue( $user, $app, $key, $default = null ) {
// Try to fetch the value, return default if not exists.
@@ -127,11 +127,11 @@ class OC_Preferences{
/**
* @brief sets a value in the preferences
- * @param $user user
- * @param $app app
- * @param $key key
- * @param $value value
- * @returns true/false
+ * @param string $user user
+ * @param string $app app
+ * @param string $key key
+ * @param string $value value
+ * @return bool
*
* Adds a value to the preferences. If the key did not exist before, it
* will be added automagically.
@@ -155,63 +155,63 @@ class OC_Preferences{
/**
* @brief Deletes a key
- * @param $user user
- * @param $app app
- * @param $key key
- * @returns true/false
+ * @param string $user user
+ * @param string $app app
+ * @param string $key key
+ * @return bool
*
* Deletes a key.
*/
public static function deleteKey( $user, $app, $key ) {
// No need for more comments
$query = OC_DB::prepare( 'DELETE FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?' );
- $result = $query->execute( array( $user, $app, $key ));
+ $query->execute( array( $user, $app, $key ));
return true;
}
/**
* @brief Remove app of user from preferences
- * @param $user user
- * @param $app app
- * @returns true/false
+ * @param string $user user
+ * @param string $app app
+ * @return bool
*
* Removes all keys in appconfig belonging to the app and the user.
*/
public static function deleteApp( $user, $app ) {
// No need for more comments
$query = OC_DB::prepare( 'DELETE FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ?' );
- $result = $query->execute( array( $user, $app ));
+ $query->execute( array( $user, $app ));
return true;
}
/**
* @brief Remove user from preferences
- * @param $user user
- * @returns true/false
+ * @param string $user user
+ * @return bool
*
* Removes all keys in appconfig belonging to the user.
*/
public static function deleteUser( $user ) {
// No need for more comments
$query = OC_DB::prepare( 'DELETE FROM `*PREFIX*preferences` WHERE `userid` = ?' );
- $result = $query->execute( array( $user ));
+ $query->execute( array( $user ));
return true;
}
/**
* @brief Remove app from all users
- * @param $app app
- * @returns true/false
+ * @param string $app app
+ * @return bool
*
* Removes all keys in preferences belonging to the app.
*/
public static function deleteAppFromAllUsers( $app ) {
// No need for more comments
$query = OC_DB::prepare( 'DELETE FROM `*PREFIX*preferences` WHERE `appid` = ?' );
- $result = $query->execute( array( $app ));
+ $query->execute( array( $app ));
return true;
}
diff --git a/lib/public/app.php b/lib/public/app.php
index eb824f043e9..809a656f17f 100644
--- a/lib/public/app.php
+++ b/lib/public/app.php
@@ -34,120 +34,109 @@ namespace OCP;
* This class provides functions to manage apps in ownCloud
*/
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 true/false
- *
- * @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 ) {
+ /**
+ * @brief Makes owncloud aware of this app
+ * @brief This call is deprecated and not necessary to use.
+ * @param $data array with all information
+ * @returns true/false
+ *
+ * @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 ) {
return true; // don't do anything
- }
+ }
- /**
- * @brief adds an entry to the navigation
- * @param $data array containing the data
- * @returns true/false
- *
- * This function adds a new entry to the navigation visible to users. $data
- * is an associative array.
- * The following keys are required:
- * - id: unique id for this entry ('addressbook_index')
- * - href: link to the page
- * - name: Human readable name ('Addressbook')
- *
- * The following keys are optional:
- * - icon: path to the icon of the app
- * - order: integer, that influences the position of your application in
- * the navigation. Lower values come first.
- */
- public static function addNavigationEntry( $data ) {
+ /**
+ * @brief adds an entry to the navigation
+ * @param $data array containing the data
+ * @returns true/false
+ *
+ * This function adds a new entry to the navigation visible to users. $data
+ * is an associative array.
+ * The following keys are required:
+ * - id: unique id for this entry ('addressbook_index')
+ * - href: link to the page
+ * - name: Human readable name ('Addressbook')
+ *
+ * The following keys are optional:
+ * - icon: path to the icon of the app
+ * - order: integer, that influences the position of your application in
+ * the navigation. Lower values come first.
+ */
+ public static function addNavigationEntry( $data ) {
return \OC_App::addNavigationEntry( $data );
}
-
- /**
- * @brief marks a navigation entry as active
- * @param $id id of the entry
- * @returns true/false
- *
- * This function sets a navigation entry as active and removes the 'active'
- * property from all other entries. The templates can use this for
- * highlighting the current position of the user.
- */
- public static function setActiveNavigationEntry( $id ) {
+ /**
+ * @brief marks a navigation entry as active
+ * @param $id id of the entry
+ * @returns true/false
+ *
+ * This function sets a navigation entry as active and removes the 'active'
+ * property from all other entries. The templates can use this for
+ * highlighting the current position of the user.
+ */
+ public static function setActiveNavigationEntry( $id ) {
return \OC_App::setActiveNavigationEntry( $id );
}
-
- /**
- * @brief Register a Configuration Screen that should appear in the personal settings section.
- * @param $app string appid
- * @param $page string page to be included
- */
- public static function registerPersonal( $app, $page ) {
+ /**
+ * @brief Register a Configuration Screen that should appear in the personal settings section.
+ * @param $app string appid
+ * @param $page string page to be included
+ */
+ public static function registerPersonal( $app, $page ) {
return \OC_App::registerPersonal( $app, $page );
}
-
/**
- * @brief Register a Configuration Screen that should appear in the Admin section.
- * @param $app string appid
- * @param $page string page to be included
+ * @brief Register a Configuration Screen that should appear in the Admin section.
+ * @param $app string appid
+ * @param $page string page to be included
*/
public static function registerAdmin( $app, $page ) {
return \OC_App::registerAdmin( $app, $page );
}
-
- /**
- * @brief 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
- */
- public static function getAppInfo( $app, $path=false ) {
+ /**
+ * @brief 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
+ */
+ 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 true/false
- *
- * This function checks whether or not an app is enabled.
- */
- public static function isEnabled( $app ) {
+ /**
+ * @brief checks whether or not an app is enabled
+ * @param $app app
+ * @returns true/false
+ *
+ * This function checks whether or not an app is enabled.
+ */
+ public static function isEnabled( $app ) {
return \OC_App::isEnabled( $app );
}
+ /**
+ * @brief Check if the app is enabled, redirects to home if not
+ * @param $app app
+ * @returns true/false
+ */
+ public static function checkAppEnabled( $app ) {
+ return \OC_Util::checkAppEnabled( $app );
+ }
- /**
- * @brief Check if the app is enabled, redirects to home if not
- * @param $app app
- * @returns true/false
- */
- public static function checkAppEnabled( $app ) {
- return \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 true/false
- */
- public static function getAppVersion( $app ) {
+ /**
+ * @brief Get the last version of the app, either from appinfo/version or from appinfo/info.xml
+ * @param $app app
+ * @returns true/false
+ */
+ public static function getAppVersion( $app ) {
return \OC_App::getAppVersion( $app );
}
-
-
-
}
diff --git a/lib/public/config.php b/lib/public/config.php
index fa9658e7288..1f163d52617 100644
--- a/lib/public/config.php
+++ b/lib/public/config.php
@@ -38,13 +38,11 @@ namespace OCP;
* This class provides functions to read and write configuration data. configuration can be on a system, application or user level
*/
class Config {
-
-
/**
* @brief Gets a value from config.php
- * @param $key key
- * @param $default = null default value
- * @returns the value or $default
+ * @param string $key key
+ * @param string $default = null default value
+ * @return string the value or $default
*
* This function gets the value from config.php. If it does not exist,
* $default will be returned.
@@ -53,12 +51,11 @@ class Config {
return(\OC_Config::getValue( $key, $default ));
}
-
/**
* @brief Sets a value
- * @param $key key
- * @param $value value
- * @returns true/false
+ * @param string $key key
+ * @param string $value value
+ * @return bool
*
* This function sets the value and writes the config.php. If the file can
* not be written, false will be returned.
@@ -67,70 +64,60 @@ class Config {
return(\OC_Config::setValue( $key, $value ));
}
-
- /**
- * @brief Gets the config value
- * @param $app app
- * @param $key key
- * @param $default = null, default value if the key does not exist
- * @returns the value or $default
- *
- * This function gets a value from the appconfig table. If the key does
- * not exist the default value will be returnes
- */
- public static function getAppValue( $app, $key, $default = null ) {
+ /**
+ * @brief Gets the config value
+ * @param string $app app
+ * @param string $key key
+ * @param string $default = null, default value if the key does not exist
+ * @return string the value or $default
+ *
+ * This function gets a value from the appconfig table. If the key does
+ * not exist the default value will be returned
+ */
+ public static function getAppValue( $app, $key, $default = null ) {
return(\OC_Appconfig::getValue( $app, $key, $default ));
}
-
- /**
- * @brief sets a value in the appconfig
- * @param $app app
- * @param $key key
- * @param $value value
- * @returns true/false
- *
- * Sets a value. If the key did not exist before it will be created.
- */
- public static function setAppValue( $app, $key, $value ) {
+ /**
+ * @brief sets a value in the appconfig
+ * @param string $app app
+ * @param string $key key
+ * @param string $value value
+ * @return string true/false
+ *
+ * Sets a value. If the key did not exist before it will be created.
+ */
+ public static function setAppValue( $app, $key, $value ) {
return(\OC_Appconfig::setValue( $app, $key, $value ));
}
-
- /**
- * @brief Gets the preference
- * @param $user user
- * @param $app app
- * @param $key key
- * @param $default = null, default value if the key does not exist
- * @returns the value or $default
- *
- * This function gets a value from the prefernces table. If the key does
- * not exist the default value will be returnes
- */
- public static function getUserValue( $user, $app, $key, $default = null ) {
+ /**
+ * @brief Gets the preference
+ * @param string $user user
+ * @param string $app app
+ * @param string $key key
+ * @param string $default = null, default value if the key does not exist
+ * @return string the value or $default
+ *
+ * This function gets a value from the preferences table. If the key does
+ * not exist the default value will be returned
+ */
+ public static function getUserValue( $user, $app, $key, $default = null ) {
return(\OC_Preferences::getValue( $user, $app, $key, $default ));
}
-
- /**
- * @brief sets a value in the preferences
- * @param $user user
- * @param $app app
- * @param $key key
- * @param $value value
- * @returns true/false
- *
- * Adds a value to the preferences. If the key did not exist before, it
- * will be added automagically.
- */
- public static function setUserValue( $user, $app, $key, $value ) {
- return(\OC_Preferences::setValue( $user, $app, $key, $value ));
+ /**
+ * @brief sets a value in the preferences
+ * @param string $user user
+ * @param string $app app
+ * @param string $key key
+ * @param string $value value
+ * @returns bool
+ *
+ * Adds a value to the preferences. If the key did not exist before, it
+ * will be added automagically.
+ */
+ public static function setUserValue( $user, $app, $key, $value ) {
+ return(\OC_Preferences::setValue( $user, $app, $key, $value ));
}
-
-
-
-
-
-
}
diff --git a/lib/public/db.php b/lib/public/db.php
index 5ac356bb475..6ce62b27ca2 100644
--- a/lib/public/db.php
+++ b/lib/public/db.php
@@ -34,8 +34,6 @@ namespace OCP;
* This class provides access to the internal database system. Use this class exlusively if you want to access databases
*/
class DB {
-
-
/**
* @brief Prepare a SQL query
* @param $query Query string
@@ -47,7 +45,6 @@ class DB {
return(\OC_DB::prepare($query,$limit,$offset));
}
-
/**
* @brief gets last value of autoincrement
* @param $table string The optional table name (will replace *PREFIX*) and add sequence suffix
@@ -62,7 +59,6 @@ class DB {
return(\OC_DB::insertid($table));
}
-
/**
* @brief Start a transaction
*/
@@ -70,7 +66,6 @@ class DB {
return(\OC_DB::beginTransaction());
}
-
/**
* @brief Commit the database changes done during a transaction that is in progress
*/
@@ -78,7 +73,6 @@ class DB {
return(\OC_DB::commit());
}
-
/**
* @brief check if a result is an error, works with MDB2 and PDOException
* @param mixed $result
@@ -87,7 +81,4 @@ class DB {
public static function isError($result) {
return(\OC_DB::isError($result));
}
-
-
-
}
diff --git a/lib/public/files.php b/lib/public/files.php
index 2f4f459bd91..90889c59ad8 100644
--- a/lib/public/files.php
+++ b/lib/public/files.php
@@ -34,8 +34,6 @@ namespace OCP;
* This class provides access to the internal filesystem abstraction layer. Use this class exlusively if you want to access files
*/
class Files {
-
-
/**
* @brief Recusive deletion of folders
* @param string $dir path to the folder
@@ -45,7 +43,6 @@ class Files {
\OC_Helper::rmdirr( $dir );
}
-
/**
* get the mimetype form a local file
* @param string path
@@ -56,7 +53,6 @@ class Files {
return(\OC_Helper::getMimeType( $path ));
}
-
/**
* copy the contents of one stream to another
* @param resource source
@@ -67,7 +63,6 @@ class Files {
return(\OC_Helper::streamCopy( $source, $target ));
}
-
/**
* create a temporary file with an unique filename
* @param string postfix
@@ -79,7 +74,6 @@ class Files {
return(\OC_Helper::tmpFile( $postfix ));
}
-
/**
* create a temporary folder with an unique filename
* @return string
@@ -90,7 +84,6 @@ class Files {
return(\OC_Helper::tmpFolder());
}
-
/**
* Adds a suffix to the name in case the file exists
*
@@ -102,16 +95,12 @@ class Files {
return(\OC_Helper::buildNotExistingFileName( $path, $filename ));
}
- /**
- * @param string appid
- * @param $app app
- * @return OC_FilesystemView
- */
- public static function getStorage( $app ) {
+ /**
+ * @param string appid
+ * @param $app app
+ * @return OC_FilesystemView
+ */
+ public static function getStorage( $app ) {
return \OC_App::getStorage( $app );
}
-
-
-
-
}
diff --git a/lib/public/json.php b/lib/public/json.php
index 93be920c6d7..2186dd8ee49 100644
--- a/lib/public/json.php
+++ b/lib/public/json.php
@@ -34,7 +34,6 @@ namespace OCP;
* This class provides convinient functions to generate and send JSON data. Usefull for Ajax calls
*/
class JSON {
-
/**
* @brief Encode and print $data in JSON format
* @param array $data The data to use
@@ -170,5 +169,4 @@ class JSON {
public static function checkAdminUser() {
return(\OC_JSON::checkAdminUser());
}
-
}
diff --git a/lib/public/response.php b/lib/public/response.php
index febb3f14361..95e67a85720 100644
--- a/lib/public/response.php
+++ b/lib/public/response.php
@@ -34,8 +34,6 @@ namespace OCP;
* This class provides convinient functions to send the correct http response headers
*/
class Response {
-
-
/**
* @brief Enable response caching by sending correct HTTP headers
* @param $cache_time time to cache the response
@@ -47,7 +45,6 @@ class Response {
return(\OC_Response::enableCaching( $cache_time ));
}
-
/**
* Checks and set Last-Modified header, when the request matches sends a
* 'not modified' response
@@ -57,7 +54,6 @@ class Response {
return(\OC_Response::setLastModifiedHeader( $lastModified ));
}
-
/**
* @brief disable browser caching
* @see enableCaching with cache_time = 0
@@ -66,7 +62,6 @@ class Response {
return(\OC_Response::disableCaching());
}
-
/**
* Checks and set ETag header, when the request matches sends a
* 'not modified' response
@@ -76,7 +71,6 @@ class Response {
return(\OC_Response::setETagHeader( $etag ));
}
-
/**
* @brief Send file as response, checking and setting caching headers
* @param $filepath of file to send
@@ -102,6 +96,4 @@ class Response {
static public function redirect( $location ) {
return(\OC_Response::redirect( $location ));
}
-
-
-}
+} \ No newline at end of file
diff --git a/lib/public/share.php b/lib/public/share.php
index cf61681424f..1039d6f0dbf 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -252,26 +252,26 @@ class Share {
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
throw new \Exception($message);
return false;
- } else if ($shareType === self::SHARE_TYPE_CONTACT) {
- if (!\OC_App::isEnabled('contacts')) {
- $message = 'Sharing '.$itemSource.' failed, because the contacts app is not enabled';
- \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
- return false;
- }
- $vcard = \OC_Contacts_App::getContactVCard($shareWith);
- if (!isset($vcard)) {
- $message = 'Sharing '.$itemSource.' failed, because the contact does not exist';
- \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
- throw new \Exception($message);
- }
- $details = \OC_Contacts_VCard::structureContact($vcard);
- // TODO Add ownCloud user to contacts vcard
- if (!isset($details['EMAIL'])) {
- $message = 'Sharing '.$itemSource.' failed, because no email address is associated with the contact';
- \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
- throw new \Exception($message);
- }
- return self::shareItem($itemType, $itemSource, self::SHARE_TYPE_EMAIL, $details['EMAIL'], $permissions);
+// } else if ($shareType === self::SHARE_TYPE_CONTACT) {
+// if (!\OC_App::isEnabled('contacts')) {
+// $message = 'Sharing '.$itemSource.' failed, because the contacts app is not enabled';
+// \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
+// return false;
+// }
+// $vcard = \OC_Contacts_App::getContactVCard($shareWith);
+// if (!isset($vcard)) {
+// $message = 'Sharing '.$itemSource.' failed, because the contact does not exist';
+// \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
+// throw new \Exception($message);
+// }
+// $details = \OC_Contacts_VCard::structureContact($vcard);
+// // TODO Add ownCloud user to contacts vcard
+// if (!isset($details['EMAIL'])) {
+// $message = 'Sharing '.$itemSource.' failed, because no email address is associated with the contact';
+// \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
+// throw new \Exception($message);
+// }
+// return self::shareItem($itemType, $itemSource, self::SHARE_TYPE_EMAIL, $details['EMAIL'], $permissions);
} else {
// Future share types need to include their own conditions
$message = 'Share type '.$shareType.' is not valid for '.$itemSource;
@@ -337,10 +337,21 @@ class Share {
public static function unshareFromSelf($itemType, $itemTarget) {
if ($item = self::getItemSharedWith($itemType, $itemTarget)) {
if ((int)$item['share_type'] === self::SHARE_TYPE_GROUP) {
- // TODO
+ // Insert an extra row for the group share and set permission to 0 to prevent it from showing up for the user
+ $query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` (`item_type`, `item_source`, `item_target`, `parent`, `share_type`, `share_with`, `uid_owner`, `permissions`, `stime`, `file_source`, `file_target`) VALUES (?,?,?,?,?,?,?,?,?,?,?)');
+ $query->execute(array($item['item_type'], $item['item_source'], $item['item_target'], $item['id'], self::$shareTypeGroupUserUnique, \OC_User::getUser(), $item['uid_owner'], 0, $item['stime'], $item['file_source'], $item['file_target']));
+ \OC_DB::insertid('*PREFIX*share');
+ // Delete all reshares by this user of the group share
+ self::delete($item['id'], true, \OC_User::getUser());
+ } else if ((int)$item['share_type'] === self::$shareTypeGroupUserUnique) {
+ // Set permission to 0 to prevent it from showing up for the user
+ $query = \OC_DB::prepare('UPDATE `*PREFIX*share` SET `permissions` = ? WHERE `id` = ?');
+ $query->execute(array(0, $item['id']));
+ self::delete($item['id'], true);
+ } else {
+ self::delete($item['id']);
}
- // Delete
- return self::delete($item['id']);
+ return true;
}
return false;
}
@@ -406,6 +417,25 @@ class Share {
throw new \Exception($message);
}
+ public static function setExpirationDate($itemType, $itemSource, $date) {
+ if ($items = self::getItems($itemType, $itemSource, null, null, \OC_User::getUser(), self::FORMAT_NONE, null, -1, false)) {
+ if (!empty($items)) {
+ if ($date == '') {
+ $date = null;
+ } else {
+ $date = new \DateTime($date);
+ $date = date('Y-m-d H:i', $date->format('U') - $date->getOffset());
+ }
+ $query = \OC_DB::prepare('UPDATE `*PREFIX*share` SET `expiration` = ? WHERE `id` = ?');
+ foreach ($items as $item) {
+ $query->execute(array($date, $item['id']));
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* @brief Get the backend class for the specified item type
* @param string Item type
@@ -447,8 +477,11 @@ class Share {
$collectionTypes[] = $type;
}
}
- if (count($collectionTypes) > 1) {
+ if (!self::getBackend($itemType) instanceof Share_Backend_Collection) {
unset($collectionTypes[0]);
+ }
+ // Return array if collections were found or the item type is a collection itself - collections can be inside collections
+ if (count($collectionTypes) > 0) {
return $collectionTypes;
}
return false;
@@ -493,9 +526,13 @@ class Share {
$root = '';
if ($includeCollections && !isset($item) && ($collectionTypes = self::getCollectionItemTypes($itemType))) {
// If includeCollections is true, find collections of this item type, e.g. a music album contains songs
- $itemTypes = array_merge(array($itemType), $collectionTypes);
+ if (!in_array($itemType, $collectionTypes)) {
+ $itemTypes = array_merge(array($itemType), $collectionTypes);
+ } else {
+ $itemTypes = $collectionTypes;
+ }
$placeholders = join(',', array_fill(0, count($itemTypes), '?'));
- $where = ' WHERE `item_type` IN ('.$placeholders.')';
+ $where .= ' WHERE item_type IN ('.$placeholders.'))';
$queryArgs = $itemTypes;
} else {
$where = ' WHERE `item_type` = ?';
@@ -570,7 +607,7 @@ class Share {
}
}
$queryArgs[] = $item;
- if ($includeCollections && $collectionTypes = self::getCollectionItemTypes($itemType)) {
+ if ($includeCollections && $collectionTypes) {
$placeholders = join(',', array_fill(0, count($collectionTypes), '?'));
$where .= ' OR item_type IN ('.$placeholders.'))';
$queryArgs = array_merge($queryArgs, $collectionTypes);
@@ -594,23 +631,23 @@ class Share {
// TODO Optimize selects
if ($format == self::FORMAT_STATUSES) {
if ($itemType == 'file' || $itemType == 'folder') {
- $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `share_type`, `file_source`, `path`';
+ $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `share_type`, `file_source`, `path`, `expiration`';
} else {
- $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`';
+ $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `expiration`';
}
} else {
if (isset($uidOwner)) {
if ($itemType == 'file' || $itemType == 'folder') {
- $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `share_type`, `share_with`, `file_source`, `path`, `permissions`, `stime`';
+ $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `share_type`, `share_with`, `file_source`, `path`, `permissions`, `stime`, `expiration`';
} else {
- $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `permissions`, `stime`, `file_source`';
+ $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `permissions`, `stime`, `file_source`, `expiration`';
}
} else {
if ($fileDependent) {
if (($itemType == 'file' || $itemType == 'folder') && $format == \OC_Share_Backend_File::FORMAT_FILE_APP || $format == \OC_Share_Backend_File::FORMAT_FILE_APP_ROOT) {
- $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `share_type`, `share_with`, `file_source`, `path`, `file_target`, `permissions`, `name`, `ctime`, `mtime`, `mimetype`, `size`, `encrypted`, `versioned`, `writable`';
+ $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `share_type`, `share_with`, `file_source`, `path`, `file_target`, `permissions`, `expiration`, `name`, `ctime`, `mtime`, `mimetype`, `size`, `encrypted`, `versioned`, `writable`';
} else {
- $select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `item_target`, `*PREFIX*share`.`parent`, `share_type`, `share_with`, `uid_owner`, `file_source`, `path`, `file_target`, `permissions`, `stime`';
+ $select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `item_target`, `*PREFIX*share`.`parent`, `share_type`, `share_with`, `uid_owner`, `file_source`, `path`, `file_target`, `permissions`, `stime`, `expiration`';
}
} else {
$select = '*';
@@ -629,6 +666,9 @@ class Share {
$row['share_with'] = $items[$row['parent']]['share_with'];
// Remove the parent group share
unset($items[$row['parent']]);
+ if ($row['permissions'] == 0) {
+ continue;
+ }
} else if (!isset($uidOwner)) {
// Check if the same target already exists
if (isset($targets[$row[$column]])) {
@@ -662,6 +702,13 @@ class Share {
$row['path'] = substr($row['path'], $root);
}
}
+ if (isset($row['expiration'])) {
+ $time = new \DateTime();
+ if ($row['expiration'] < date('Y-m-d H:i', $time->format('U') - $time->getOffset())) {
+ self::delete($row['id']);
+ continue;
+ }
+ }
$items[$row['id']] = $row;
}
if (!empty($items)) {
@@ -676,29 +723,54 @@ class Share {
}
}
// Check if this is a collection of the requested item type
- if ($includeCollections && $row['item_type'] != $itemType) {
+ if ($includeCollections && $collectionTypes && in_array($row['item_type'], $collectionTypes)) {
if (($collectionBackend = self::getBackend($row['item_type'])) && $collectionBackend instanceof Share_Backend_Collection) {
- $row['collection'] = array('item_type' => $itemType, $column => $row[$column]);
- // Fetch all of the children sources
- $children = $collectionBackend->getChildren($row[$column]);
- foreach ($children as $child) {
- $childItem = $row;
- $childItem['item_source'] = $child;
- // $childItem['item_target'] = $child['target']; TODO
- if (isset($item)) {
- if ($childItem[$column] == $item) {
- // Return only the item instead of a 2-dimensional array
- if ($limit == 1 && $format == self::FORMAT_NONE) {
- return $childItem;
+ // Collections can be inside collections, check if the item is a collection
+ if (isset($item) && $row['item_type'] == $itemType && $row[$column] == $item) {
+ $collectionItems[] = $row;
+ } else {
+ $collection = array();
+ $collection['item_type'] = $row['item_type'];
+ if ($row['item_type'] == 'file' || $row['item_type'] == 'folder') {
+ $collection['path'] = basename($row['path']);
+ }
+ $row['collection'] = $collection;
+ // Fetch all of the children sources
+ $children = $collectionBackend->getChildren($row[$column]);
+ foreach ($children as $child) {
+ $childItem = $row;
+ $childItem['item_type'] = $itemType;
+ if ($row['item_type'] != 'file' && $row['item_type'] != 'folder') {
+ $childItem['item_source'] = $child['source'];
+ $childItem['item_target'] = $child['target'];
+ }
+ if ($backend instanceof Share_Backend_File_Dependent) {
+ if ($row['item_type'] == 'file' || $row['item_type'] == 'folder') {
+ $childItem['file_source'] = $child['source'];
} else {
- // Unset the items array and break out of both loops
- $items = array();
- $items[] = $childItem;
- break 2;
+ $childItem['file_source'] = \OC_FileCache::getId($child['file_path']);
}
+ $childItem['file_target'] = \OC_Filesystem::normalizePath($child['file_path']);
+ }
+ if (isset($item)) {
+ if ($childItem[$column] == $item) {
+ // Return only the item instead of a 2-dimensional array
+ if ($limit == 1) {
+ if ($format == self::FORMAT_NONE) {
+ return $childItem;
+ } else {
+ // Unset the items array and break out of both loops
+ $items = array();
+ $items[] = $childItem;
+ break 2;
+ }
+ } else {
+ $collectionItems[] = $childItem;
+ }
+ }
+ } else {
+ $collectionItems[] = $childItem;
}
- } else {
- $collectionItems[] = $childItem;
}
}
}
@@ -848,6 +920,7 @@ class Share {
// Insert an extra row for the group share if the item or file target is unique for this user
if ($itemTarget != $groupItemTarget || (isset($fileSource) && $fileTarget != $groupFileTarget)) {
$query->execute(array($itemType, $itemSource, $itemTarget, $parent, self::$shareTypeGroupUserUnique, $uid, $uidOwner, $permissions, time(), $fileSource, $fileTarget));
+ \OC_DB::insertid('*PREFIX*share');
}
}
if ($parentFolder === true) {
@@ -1153,7 +1226,7 @@ interface Share_Backend_Collection extends Share_Backend {
/**
* @brief Get the sources of the children of the item
* @param string Item source
- * @return array Returns an array of sources
+ * @return array Returns an array of children each inside an array with the keys: source, target, and file_path if applicable
*/
public function getChildren($itemSource);
diff --git a/lib/public/user.php b/lib/public/user.php
index b530321f21d..b320ce8ea0c 100644
--- a/lib/public/user.php
+++ b/lib/public/user.php
@@ -34,8 +34,6 @@ namespace OCP;
* This class provides access to the user management. You can get information about the currently logged in user and the permissions for example
*/
class User {
-
-
/**
* @brief get the user id of the user currently logged in.
* @return string uid or false
@@ -44,7 +42,6 @@ class User {
return \OC_USER::getUser();
}
-
/**
* @brief Get a list of all users
* @returns array with all uids
@@ -55,7 +52,6 @@ class User {
return \OC_USER::getUsers();
}
-
/**
* @brief Check if the user is logged in
* @returns true/false
@@ -66,7 +62,6 @@ class User {
return \OC_USER::isLoggedIn();
}
-
/**
* @brief check if a user exists
* @param string $uid the username
@@ -76,7 +71,6 @@ class User {
return \OC_USER::userExists( $uid );
}
-
/**
* @brief Loggs the user out including all the session data
* @returns true
@@ -87,7 +81,6 @@ class User {
return \OC_USER::logout();
}
-
/**
* @brief Check if the password is correct
* @param $uid The username
@@ -100,23 +93,18 @@ class User {
return \OC_USER::checkPassword( $uid, $password );
}
+ /**
+ * Check if the user is a admin, redirects to home if not
+ */
+ public static function checkAdminUser() {
+ \OC_Util::checkAdminUser();
+ }
- /**
- * Check if the user is a admin, redirects to home if not
- */
- public static function checkAdminUser() {
- \OC_Util::checkAdminUser();
- }
-
-
- /**
- * Check if the user is logged in, redirects to home if not. With
- * redirect URL parameter to the request URI.
- */
- public static function checkLoggedIn() {
- \OC_Util::checkLoggedIn();
- }
-
-
-
+ /**
+ * Check if the user is logged in, redirects to home if not. With
+ * redirect URL parameter to the request URI.
+ */
+ public static function checkLoggedIn() {
+ \OC_Util::checkLoggedIn();
+ }
}
diff --git a/lib/public/util.php b/lib/public/util.php
index ed23521b040..747448e62eb 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -34,8 +34,6 @@ namespace OCP;
* This class provides different helper functions to make the life of a developer easier
*/
class Util {
-
-
// consts for Logging
const DEBUG=0;
const INFO=1;
@@ -43,7 +41,6 @@ class Util {
const ERROR=3;
const FATAL=4;
-
/**
* @brief get the current installed version of ownCloud
* @return array
@@ -52,7 +49,6 @@ class Util {
return(\OC_Util::getVersion());
}
-
/**
* @brief send an email
* @param string $toaddress
@@ -68,18 +64,16 @@ class Util {
\OC_MAIL::send( $toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, $html=0, $altbody='', $ccaddress='', $ccname='', $bcc='');
}
-
- /**
+ /**
* @brief write a message in the log
* @param string $app
* @param string $message
* @param int level
- */
- public static function writeLog( $app, $message, $level ) {
- // call the internal log class
- \OC_LOG::write( $app, $message, $level );
- }
-
+ */
+ public static function writeLog( $app, $message, $level ) {
+ // call the internal log class
+ \OC_LOG::write( $app, $message, $level );
+ }
/**
* @brief add a css file
@@ -87,8 +81,7 @@ class Util {
*/
public static function addStyle( $application, $file = null ) {
\OC_Util::addStyle( $application, $file );
- }
-
+ }
/**
* @brief add a javascript file
@@ -97,7 +90,7 @@ class Util {
*/
public static function addScript( $application, $file = null ) {
\OC_Util::addScript( $application, $file );
- }
+ }
/**
* @brief Add a custom element to the header
@@ -118,8 +111,6 @@ class Util {
return(\OC_Util::formatDate( $timestamp,$dateOnly ));
}
-
-
/**
* @brief Creates an absolute url
* @param $app app
@@ -133,7 +124,6 @@ class Util {
return(\OC_Helper::linkToAbsolute( $app, $file, $args ));
}
-
/**
* @brief Creates an absolute url for remote use
* @param $service id
@@ -156,7 +146,6 @@ class Util {
return \OC_Helper::linkToPublic($service);
}
-
/**
* @brief Creates an url
* @param $app app
@@ -199,11 +188,10 @@ class Util {
*
* Returns the path to the image.
*/
- public static function imagePath( $app, $image ) {
+ public static function imagePath( $app, $image ) {
return(\OC_Helper::imagePath( $app, $image ));
}
-
/**
* @brief Make a human file size
* @param $bytes file size in bytes
@@ -244,7 +232,6 @@ class Util {
return(\OC_Hook::connect( $signalclass, $signalname, $slotclass, $slotname ));
}
-
/**
* @brief emitts a signal
* @param $signalclass class name of emitter
@@ -260,7 +247,6 @@ class Util {
return(\OC_Hook::emit( $signalclass, $signalname, $params ));
}
-
/**
* Register an get/post call. This is important to prevent CSRF attacks
* TODO: write example
@@ -269,7 +255,6 @@ class Util {
return(\OC_Util::callRegister());
}
-
/**
* Check an ajax get/post call if the request token is valid. exit if not.
* Todo: Write howto
diff --git a/lib/search/provider/file.php b/lib/search/provider/file.php
index 50e16457672..135e40667b1 100644
--- a/lib/search/provider/file.php
+++ b/lib/search/provider/file.php
@@ -15,16 +15,16 @@ class OC_Search_Provider_File extends OC_Search_Provider{
case 'audio':
break;
case 'text':
- $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('dir' => $file) ),'Text');
+ $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('file' => $file) ),'Text');
break;
case 'image':
- $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('dir' => $file) ),'Images');
+ $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('file' => $file) ),'Images');
break;
default:
if($mime=='application/xml') {
- $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('dir' => $file) ),'Text');
+ $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('file' => $file) ),'Text');
}else{
- $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('dir' => $file) ),'Files');
+ $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('file' => $file) ),'Files');
}
}
}
diff --git a/lib/setup.php b/lib/setup.php
index f27254a42a4..c21c8be3957 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -9,7 +9,7 @@ $opts = array(
'hasSQLite' => $hasSQLite,
'hasMySQL' => $hasMySQL,
'hasPostgreSQL' => $hasPostgreSQL,
- 'hasOracle' => $hasOracle,
+ 'hasOracle' => $hasOracle,
'directory' => $datadir,
'errors' => array(),
);
@@ -51,10 +51,10 @@ class OC_Setup {
if($dbtype=='mysql' or $dbtype == 'pgsql' or $dbtype == 'oci') { //mysql and postgresql needs more config options
if($dbtype=='mysql')
$dbprettyname = 'MySQL';
- else if($dbtype=='pgsql')
- $dbprettyname = 'PostgreSQL';
- else
- $dbprettyname = 'Oracle';
+ else if($dbtype=='pgsql')
+ $dbprettyname = 'PostgreSQL';
+ else
+ $dbprettyname = 'Oracle';
if(empty($options['dbuser'])) {
@@ -63,7 +63,7 @@ class OC_Setup {
if(empty($options['dbname'])) {
$error[] = "$dbprettyname enter the database name.";
}
- if(empty($options['dbhost'])) {
+ if($dbtype != 'oci' && empty($options['dbhost'])) {
$error[] = "$dbprettyname set the database host.";
}
}
@@ -232,117 +232,125 @@ class OC_Setup {
}
}
}
- elseif($dbtype == 'oci') {
- $dbuser = $options['dbuser'];
- $dbpass = $options['dbpass'];
- $dbname = $options['dbname'];
- $dbtablespace = $options['dbtablespace'];
- $dbhost = $options['dbhost'];
- $dbtableprefix = isset($options['dbtableprefix']) ? $options['dbtableprefix'] : 'oc_';
- OC_CONFIG::setValue('dbname', $dbname);
- OC_CONFIG::setValue('dbtablespace', $dbtablespace);
- OC_CONFIG::setValue('dbhost', $dbhost);
- OC_CONFIG::setValue('dbtableprefix', $dbtableprefix);
-
- $e_host = addslashes($dbhost);
- $e_dbname = addslashes($dbname);
- //check if the database user has admin right
- $connection_string = '//'.$e_host.'/'.$e_dbname;
- $connection = @oci_connect($dbuser, $dbpass, $connection_string);
- if(!$connection) {
- $e = oci_error();
- $error[] = array(
- 'error' => 'Oracle username and/or password not valid',
- 'hint' => 'You need to enter either an existing account or the administrator.'
- );
- return $error;
- } else {
- //check for roles creation rights in oracle
-
- $query="SELECT count(*) FROM user_role_privs, role_sys_privs WHERE user_role_privs.granted_role = role_sys_privs.role AND privilege = 'CREATE ROLE'";
- $stmt = oci_parse($connection, $query);
- if (!$stmt) {
- $entry='DB Error: "'.oci_last_error($connection).'"<br />';
- $entry.='Offending command was: '.$query.'<br />';
- echo($entry);
- }
- $result = oci_execute($stmt);
- if($result) {
- $row = oci_fetch_row($stmt);
- }
- if($result and $row[0] > 0) {
- //use the admin login data for the new database user
-
- //add prefix to the oracle user name to prevent collisions
- $dbusername='oc_'.$username;
- //create a new password so we don't need to store the admin config in the config file
- $dbpassword=md5(time().$dbpass);
-
- //oracle passwords are treated as identifiers:
- // must start with aphanumeric char
- // needs to be shortened to 30 bytes, as the two " needed to escape the identifier count towards the identifier length.
- $dbpassword=substr($dbpassword, 0, 30);
-
- self::oci_createDBUser($dbusername, $dbpassword, $dbtablespace, $connection);
-
- OC_CONFIG::setValue('dbuser', $dbusername);
- OC_CONFIG::setValue('dbname', $dbusername);
- OC_CONFIG::setValue('dbpassword', $dbpassword);
-
- //create the database not neccessary, oracle implies user = schema
- //self::oci_createDatabase($dbname, $dbusername, $connection);
- } else {
-
- OC_CONFIG::setValue('dbuser', $dbuser);
- OC_CONFIG::setValue('dbname', $dbname);
- OC_CONFIG::setValue('dbpassword', $dbpass);
-
- //create the database not neccessary, oracle implies user = schema
- //self::oci_createDatabase($dbname, $dbuser, $connection);
- }
-
- //FIXME check tablespace exists: select * from user_tablespaces
-
- // the connection to dbname=oracle is not needed anymore
- oci_close($connection);
-
- // connect to the oracle database (schema=$dbuser) an check if the schema needs to be filled
- $dbuser = OC_CONFIG::getValue('dbuser');
- //$dbname = OC_CONFIG::getValue('dbname');
- $dbpass = OC_CONFIG::getValue('dbpassword');
-
- $e_host = addslashes($dbhost);
- $e_dbname = addslashes($dbname);
-
- $connection_string = '//'.$e_host.'/'.$e_dbname;
- $connection = @oci_connect($dbuser, $dbpass, $connection_string);
- if(!$connection) {
- $error[] = array(
- 'error' => 'Oracle username and/or password not valid',
- 'hint' => 'You need to enter either an existing account or the administrator.'
- );
- return $error;
- } else {
- $query = "SELECT count(*) FROM user_tables WHERE table_name = :un";
- $stmt = oci_parse($connection, $query);
- $un = $dbtableprefix.'users';
- oci_bind_by_name($stmt, ':un', $un);
- if (!$stmt) {
- $entry='DB Error: "'.oci_last_error($connection).'"<br />';
- $entry.='Offending command was: '.$query.'<br />';
- echo($entry);
- }
- $result = oci_execute($stmt);
-
- if($result) {
- $row = oci_fetch_row($stmt);
- }
- if(!$result or $row[0]==0) {
- OC_DB::createDbFromStructure('db_structure.xml');
- }
- }
- }
- }
+ elseif($dbtype == 'oci') {
+ $dbuser = $options['dbuser'];
+ $dbpass = $options['dbpass'];
+ $dbname = $options['dbname'];
+ $dbtablespace = $options['dbtablespace'];
+ $dbhost = isset($options['dbhost'])?$options['dbhost']:'';
+ $dbtableprefix = isset($options['dbtableprefix']) ? $options['dbtableprefix'] : 'oc_';
+ OC_CONFIG::setValue('dbname', $dbname);
+ OC_CONFIG::setValue('dbtablespace', $dbtablespace);
+ OC_CONFIG::setValue('dbhost', $dbhost);
+ OC_CONFIG::setValue('dbtableprefix', $dbtableprefix);
+
+ $e_host = addslashes($dbhost);
+ $e_dbname = addslashes($dbname);
+ //check if the database user has admin right
+ if ($e_host == '') {
+ $easy_connect_string = $e_dbname; // use dbname as easy connect name
+ } else {
+ $easy_connect_string = '//'.$e_host.'/'.$e_dbname;
+ }
+ $connection = @oci_connect($dbuser, $dbpass, $easy_connect_string);
+ if(!$connection) {
+ $e = oci_error();
+ $error[] = array(
+ 'error' => 'Oracle username and/or password not valid',
+ 'hint' => 'You need to enter either an existing account or the administrator.'
+ );
+ return $error;
+ } else {
+ //check for roles creation rights in oracle
+
+ $query="SELECT count(*) FROM user_role_privs, role_sys_privs WHERE user_role_privs.granted_role = role_sys_privs.role AND privilege = 'CREATE ROLE'";
+ $stmt = oci_parse($connection, $query);
+ if (!$stmt) {
+ $entry='DB Error: "'.oci_last_error($connection).'"<br />';
+ $entry.='Offending command was: '.$query.'<br />';
+ echo($entry);
+ }
+ $result = oci_execute($stmt);
+ if($result) {
+ $row = oci_fetch_row($stmt);
+ }
+ if($result and $row[0] > 0) {
+ //use the admin login data for the new database user
+
+ //add prefix to the oracle user name to prevent collisions
+ $dbusername='oc_'.$username;
+ //create a new password so we don't need to store the admin config in the config file
+ $dbpassword=md5(time().$dbpass);
+
+ //oracle passwords are treated as identifiers:
+ // must start with aphanumeric char
+ // needs to be shortened to 30 bytes, as the two " needed to escape the identifier count towards the identifier length.
+ $dbpassword=substr($dbpassword, 0, 30);
+
+ self::oci_createDBUser($dbusername, $dbpassword, $dbtablespace, $connection);
+
+ OC_CONFIG::setValue('dbuser', $dbusername);
+ OC_CONFIG::setValue('dbname', $dbusername);
+ OC_CONFIG::setValue('dbpassword', $dbpassword);
+
+ //create the database not neccessary, oracle implies user = schema
+ //self::oci_createDatabase($dbname, $dbusername, $connection);
+ } else {
+
+ OC_CONFIG::setValue('dbuser', $dbuser);
+ OC_CONFIG::setValue('dbname', $dbname);
+ OC_CONFIG::setValue('dbpassword', $dbpass);
+
+ //create the database not neccessary, oracle implies user = schema
+ //self::oci_createDatabase($dbname, $dbuser, $connection);
+ }
+
+ //FIXME check tablespace exists: select * from user_tablespaces
+
+ // the connection to dbname=oracle is not needed anymore
+ oci_close($connection);
+
+ // connect to the oracle database (schema=$dbuser) an check if the schema needs to be filled
+ $dbuser = OC_CONFIG::getValue('dbuser');
+ //$dbname = OC_CONFIG::getValue('dbname');
+ $dbpass = OC_CONFIG::getValue('dbpassword');
+
+ $e_host = addslashes($dbhost);
+ $e_dbname = addslashes($dbname);
+
+ if ($e_host == '') {
+ $easy_connect_string = $e_dbname; // use dbname as easy connect name
+ } else {
+ $easy_connect_string = '//'.$e_host.'/'.$e_dbname;
+ }
+ $connection = @oci_connect($dbuser, $dbpass, $easy_connect_string);
+ if(!$connection) {
+ $error[] = array(
+ 'error' => 'Oracle username and/or password not valid',
+ 'hint' => 'You need to enter either an existing account or the administrator.'
+ );
+ return $error;
+ } else {
+ $query = "SELECT count(*) FROM user_tables WHERE table_name = :un";
+ $stmt = oci_parse($connection, $query);
+ $un = $dbtableprefix.'users';
+ oci_bind_by_name($stmt, ':un', $un);
+ if (!$stmt) {
+ $entry='DB Error: "'.oci_last_error($connection).'"<br />';
+ $entry.='Offending command was: '.$query.'<br />';
+ echo($entry);
+ }
+ $result = oci_execute($stmt);
+
+ if($result) {
+ $row = oci_fetch_row($stmt);
+ }
+ if(!$result or $row[0]==0) {
+ OC_DB::createDbFromStructure('db_structure.xml');
+ }
+ }
+ }
+ }
else {
//delete the old sqlite database first, might cause infinte loops otherwise
if(file_exists("$datadir/owncloud.db")) {
@@ -462,79 +470,79 @@ class OC_Setup {
}
}
}
- /**
- *
- * @param String $name
- * @param String $password
- * @param String $tablespace
- * @param resource $connection
- */
- private static function oci_createDBUser($name, $password, $tablespace, $connection) {
-
- $query = "SELECT * FROM all_users WHERE USERNAME = :un";
- $stmt = oci_parse($connection, $query);
- if (!$stmt) {
- $entry='DB Error: "'.oci_error($connection).'"<br />';
- $entry.='Offending command was: '.$query.'<br />';
- echo($entry);
- }
- oci_bind_by_name($stmt, ':un', $name);
- $result = oci_execute($stmt);
- if(!$result) {
- $entry='DB Error: "'.oci_error($connection).'"<br />';
- $entry.='Offending command was: '.$query.'<br />';
- echo($entry);
- }
-
- if(! oci_fetch_row($stmt)) {
- //user does not exists let's create it :)
- //password must start with alphabetic character in oracle
- $query = 'CREATE USER '.$name.' IDENTIFIED BY "'.$password.'" DEFAULT TABLESPACE '.$tablespace; //TODO set default tablespace
- $stmt = oci_parse($connection, $query);
- if (!$stmt) {
- $entry='DB Error: "'.oci_error($connection).'"<br />';
- $entry.='Offending command was: '.$query.'<br />';
- echo($entry);
- }
- //oci_bind_by_name($stmt, ':un', $name);
- $result = oci_execute($stmt);
- if(!$result) {
- $entry='DB Error: "'.oci_error($connection).'"<br />';
- $entry.='Offending command was: '.$query.', name:'.$name.', password:'.$password.'<br />';
- echo($entry);
- }
- } else { // change password of the existing role
- $query = "ALTER USER :un IDENTIFIED BY :pw";
- $stmt = oci_parse($connection, $query);
- if (!$stmt) {
- $entry='DB Error: "'.oci_error($connection).'"<br />';
- $entry.='Offending command was: '.$query.'<br />';
- echo($entry);
- }
- oci_bind_by_name($stmt, ':un', $name);
- oci_bind_by_name($stmt, ':pw', $password);
- $result = oci_execute($stmt);
- if(!$result) {
- $entry='DB Error: "'.oci_error($connection).'"<br />';
- $entry.='Offending command was: '.$query.'<br />';
- echo($entry);
- }
- }
- // grant neccessary roles
- $query = 'GRANT CREATE SESSION, CREATE TABLE, CREATE SEQUENCE, CREATE TRIGGER, UNLIMITED TABLESPACE TO '.$name;
- $stmt = oci_parse($connection, $query);
- if (!$stmt) {
- $entry='DB Error: "'.oci_error($connection).'"<br />';
- $entry.='Offending command was: '.$query.'<br />';
- echo($entry);
- }
- $result = oci_execute($stmt);
- if(!$result) {
- $entry='DB Error: "'.oci_error($connection).'"<br />';
- $entry.='Offending command was: '.$query.', name:'.$name.', password:'.$password.'<br />';
- echo($entry);
- }
- }
+ /**
+ *
+ * @param String $name
+ * @param String $password
+ * @param String $tablespace
+ * @param resource $connection
+ */
+ private static function oci_createDBUser($name, $password, $tablespace, $connection) {
+
+ $query = "SELECT * FROM all_users WHERE USERNAME = :un";
+ $stmt = oci_parse($connection, $query);
+ if (!$stmt) {
+ $entry='DB Error: "'.oci_error($connection).'"<br />';
+ $entry.='Offending command was: '.$query.'<br />';
+ echo($entry);
+ }
+ oci_bind_by_name($stmt, ':un', $name);
+ $result = oci_execute($stmt);
+ if(!$result) {
+ $entry='DB Error: "'.oci_error($connection).'"<br />';
+ $entry.='Offending command was: '.$query.'<br />';
+ echo($entry);
+ }
+
+ if(! oci_fetch_row($stmt)) {
+ //user does not exists let's create it :)
+ //password must start with alphabetic character in oracle
+ $query = 'CREATE USER '.$name.' IDENTIFIED BY "'.$password.'" DEFAULT TABLESPACE '.$tablespace; //TODO set default tablespace
+ $stmt = oci_parse($connection, $query);
+ if (!$stmt) {
+ $entry='DB Error: "'.oci_error($connection).'"<br />';
+ $entry.='Offending command was: '.$query.'<br />';
+ echo($entry);
+ }
+ //oci_bind_by_name($stmt, ':un', $name);
+ $result = oci_execute($stmt);
+ if(!$result) {
+ $entry='DB Error: "'.oci_error($connection).'"<br />';
+ $entry.='Offending command was: '.$query.', name:'.$name.', password:'.$password.'<br />';
+ echo($entry);
+ }
+ } else { // change password of the existing role
+ $query = "ALTER USER :un IDENTIFIED BY :pw";
+ $stmt = oci_parse($connection, $query);
+ if (!$stmt) {
+ $entry='DB Error: "'.oci_error($connection).'"<br />';
+ $entry.='Offending command was: '.$query.'<br />';
+ echo($entry);
+ }
+ oci_bind_by_name($stmt, ':un', $name);
+ oci_bind_by_name($stmt, ':pw', $password);
+ $result = oci_execute($stmt);
+ if(!$result) {
+ $entry='DB Error: "'.oci_error($connection).'"<br />';
+ $entry.='Offending command was: '.$query.'<br />';
+ echo($entry);
+ }
+ }
+ // grant neccessary roles
+ $query = 'GRANT CREATE SESSION, CREATE TABLE, CREATE SEQUENCE, CREATE TRIGGER, UNLIMITED TABLESPACE TO '.$name;
+ $stmt = oci_parse($connection, $query);
+ if (!$stmt) {
+ $entry='DB Error: "'.oci_error($connection).'"<br />';
+ $entry.='Offending command was: '.$query.'<br />';
+ echo($entry);
+ }
+ $result = oci_execute($stmt);
+ if(!$result) {
+ $entry='DB Error: "'.oci_error($connection).'"<br />';
+ $entry.='Offending command was: '.$query.', name:'.$name.', password:'.$password.'<br />';
+ echo($entry);
+ }
+ }
/**
* create .htaccess files for apache hosts
diff --git a/lib/template.php b/lib/template.php
index 8c872a2059b..0987d6f0d88 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -23,10 +23,10 @@
/**
* @brief make OC_Helper::linkTo available as a simple function
- * @param $app app
- * @param $file file
- * @param $args array with param=>value, will be appended to the returned url
- * @returns link to the file
+ * @param string $app app
+ * @param string $file file
+ * @param array $args array with param=>value, will be appended to the returned url
+ * @return string link to the file
*
* For further information have a look at OC_Helper::linkTo
*/
@@ -36,9 +36,9 @@ function link_to( $app, $file, $args = array() ) {
/**
* @brief make OC_Helper::imagePath available as a simple function
- * @param $app app
- * @param $image image
- * @returns link to the image
+ * @param string $app app
+ * @param string $image image
+ * @return string link to the image
*
* For further information have a look at OC_Helper::imagePath
*/
@@ -48,8 +48,8 @@ function image_path( $app, $image ) {
/**
* @brief make OC_Helper::mimetypeIcon available as a simple function
- * @param $mimetype mimetype
- * @returns link to the image
+ * @param string $mimetype mimetype
+ * @return string link to the image
*
* For further information have a look at OC_Helper::mimetypeIcon
*/
@@ -59,8 +59,8 @@ function mimetype_icon( $mimetype ) {
/**
* @brief make OC_Helper::humanFileSize available as a simple function
- * @param $bytes size in bytes
- * @returns size as string
+ * @param int $bytes size in bytes
+ * @return string size as string
*
* For further information have a look at OC_Helper::humanFileSize
*/
@@ -139,10 +139,10 @@ class OC_Template{
/**
* @brief Constructor
- * @param $app app providing the template
- * @param $file name of the template file (without suffix)
- * @param $renderas = ""; produce a full page
- * @returns OC_Template object
+ * @param string $app app providing the template
+ * @param string $file name of the template file (without suffix)
+ * @param string $renderas = ""; produce a full page
+ * @return OC_Template object
*
* This function creates an OC_Template object.
*
@@ -158,7 +158,8 @@ class OC_Template{
if($renderas == 'user') {
$this->vars['requesttoken'] = OC_Util::callRegister();
}
- $this->l10n = OC_L10N::get($app);
+ $parts = explode('/', $app); // fix translation when app is something like core/lostpassword
+ $this->l10n = OC_L10N::get($parts[0]);
header('X-Frame-Options: Sameorigin');
header('X-XSS-Protection: 1; mode=block');
header('X-Content-Type-Options: nosniff');
@@ -167,7 +168,7 @@ class OC_Template{
}
/**
- * autodetects the formfactor of the used device
+ * autodetect the formfactor of the used device
* default -> the normal desktop browser interface
* mobile -> interface for smartphones
* tablet -> interface for tablets
@@ -225,7 +226,7 @@ class OC_Template{
/**
* @brief find the template with the given name
- * @param $name of the template file (without suffix)
+ * @param string $name of the template file (without suffix)
*
* Will select the template file for the selected theme and formfactor.
* Checking all the possible locations.
@@ -270,13 +271,13 @@ class OC_Template{
/**
* @brief check Path For Template with and without $fext
- * @param $path to check
- * @param $name of the template file (without suffix)
- * @param $fext formfactor extension
+ * @param string $path to check
+ * @param string $name of the template file (without suffix)
+ * @param string $fext formfactor extension
* @return bool true when found
*
* Will set $this->template and $this->path if there is a template at
- * the specifief $path
+ * the specific $path
*/
protected function checkPathForTemplate($path, $name, $fext)
{
@@ -297,10 +298,10 @@ class OC_Template{
/**
* @brief Assign variables
- * @param $key key
- * @param $value value
- * @param $sanitizeHTML false, if data shouldn't get passed through htmlentities
- * @returns true
+ * @param string $key key
+ * @param string $value value
+ * @param bool $sanitizeHTML false, if data shouldn't get passed through htmlentities
+ * @return bool
*
* This function assigns a variable. It can be accessed via $_[$key] in
* the template.
@@ -315,9 +316,9 @@ class OC_Template{
/**
* @brief Appends a variable
- * @param $key key
- * @param $value value
- * @returns true
+ * @param string $key key
+ * @param string $value value
+ * @return bool
*
* This function assigns a variable in an array context. If the key already
* exists, the value will be appended. It can be accessed via
@@ -334,7 +335,7 @@ class OC_Template{
/**
* @brief Add a custom element to the header
- * @param string tag tag name of the element
+ * @param string $tag tag name of the element
* @param array $attributes array of attrobutes for the element
* @param string $text the text content for the element
*/
@@ -344,7 +345,7 @@ class OC_Template{
/**
* @brief Prints the proceeded template
- * @returns true/false
+ * @return bool
*
* This function proceeds the template and prints its output.
*/
@@ -361,7 +362,7 @@ class OC_Template{
/**
* @brief Proceeds the template
- * @returns content
+ * @return bool
*
* This function proceeds the template. If $this->renderas is set, it
* will produce a full page.
@@ -391,7 +392,7 @@ class OC_Template{
/**
* @brief doing the actual work
- * @returns content
+ * @return string content
*
* Includes the template file, fetches its output
*/
@@ -412,13 +413,12 @@ class OC_Template{
/**
* @brief Include template
- * @returns returns content of included template
+ * @return string returns content of included template
*
* Includes another template. use <?php echo $this->inc('template'); ?> to
* do this.
*/
public function inc( $file, $additionalparams = null ) {
- // $_ erstellen
$_ = $this->vars;
$l = $this->l10n;
@@ -438,10 +438,10 @@ class OC_Template{
/**
* @brief Shortcut to print a simple page for users
- * @param $application The application we render the template for
- * @param $name Name of the template
- * @param $parameters Parameters for the template
- * @returns true/false
+ * @param string $application The application we render the template for
+ * @param string $name Name of the template
+ * @param array $parameters Parameters for the template
+ * @return bool
*/
public static function printUserPage( $application, $name, $parameters = array() ) {
$content = new OC_Template( $application, $name, "user" );
@@ -453,10 +453,10 @@ class OC_Template{
/**
* @brief Shortcut to print a simple page for admins
- * @param $application The application we render the template for
- * @param $name Name of the template
- * @param $parameters Parameters for the template
- * @returns true/false
+ * @param string $application The application we render the template for
+ * @param string $name Name of the template
+ * @param array $parameters Parameters for the template
+ * @return bool
*/
public static function printAdminPage( $application, $name, $parameters = array() ) {
$content = new OC_Template( $application, $name, "admin" );
@@ -468,10 +468,10 @@ class OC_Template{
/**
* @brief Shortcut to print a simple page for guests
- * @param $application The application we render the template for
- * @param $name Name of the template
- * @param $parameters Parameters for the template
- * @returns true/false
+ * @param string $application The application we render the template for
+ * @param string $name Name of the template
+ * @param string $parameters Parameters for the template
+ * @return bool
*/
public static function printGuestPage( $application, $name, $parameters = array() ) {
$content = new OC_Template( $application, $name, "guest" );
diff --git a/lib/templatelayout.php b/lib/templatelayout.php
index ad013edad8c..c898628bcdf 100644
--- a/lib/templatelayout.php
+++ b/lib/templatelayout.php
@@ -41,9 +41,17 @@ class OC_TemplateLayout extends OC_Template {
}
$this->assign( 'apps_paths', str_replace('\\/', '/',json_encode($apps_paths)),false ); // Ugly unescape slashes waiting for better solution
+ if (OC_Config::getValue('installed', false) && !OC_AppConfig::getValue('core', 'remote_core.css', false)) {
+ OC_AppConfig::setValue('core', 'remote_core.css', '/core/minimizer.php');
+ OC_AppConfig::setValue('core', 'remote_core.js', '/core/minimizer.php');
+ }
+
// Add the js files
$jsfiles = self::findJavascriptFiles(OC_Util::$scripts);
$this->assign('jsfiles', array(), false);
+ if (!empty(OC_Util::$core_scripts)) {
+ $this->append( 'jsfiles', OC_Helper::linkToRemote('core.js', false));
+ }
foreach($jsfiles as $info) {
$root = $info[0];
$web = $info[1];
@@ -53,8 +61,10 @@ class OC_TemplateLayout extends OC_Template {
// Add the css files
$cssfiles = self::findStylesheetFiles(OC_Util::$styles);
-
$this->assign('cssfiles', array());
+ if (!empty(OC_Util::$core_styles)) {
+ $this->append( 'cssfiles', OC_Helper::linkToRemote('core.css', false));
+ }
foreach($cssfiles as $info) {
$root = $info[0];
$web = $info[1];
diff --git a/lib/user.php b/lib/user.php
index 89dab9f9647..7de2a4b7fe6 100644
--- a/lib/user.php
+++ b/lib/user.php
@@ -416,9 +416,16 @@ class OC_User {
* @param string $userid the user to disable
*/
public static function disableUser($userid) {
- $query = "INSERT INTO `*PREFIX*preferences` (`userid`, `appid`, `configkey`, `configvalue`) VALUES(?, ?, ?, ?)";
- $query = OC_DB::prepare($query);
- $query->execute(array($userid, 'core', 'enabled', 'false'));
+ $sql = "INSERT INTO `*PREFIX*preferences` (`userid`, `appid`, `configkey`, `configvalue`) VALUES(?, ?, ?, ?)";
+ $stmt = OC_DB::prepare($sql);
+ if ( ! OC_DB::isError($stmt) ) {
+ $result = $stmt->execute(array($userid, 'core', 'enabled', 'false'));
+ if ( OC_DB::isError($result) ) {
+ OC_Log::write('OC_User', 'could not enable user: '. OC_DB::getErrorMessage($result), OC_Log::ERROR);
+ }
+ } else {
+ OC_Log::write('OC_User', 'could not disable user: '. OC_DB::getErrorMessage($stmt), OC_Log::ERROR);
+ }
}
/**
@@ -426,9 +433,16 @@ class OC_User {
* @param string $userid
*/
public static function enableUser($userid) {
- $query = "DELETE FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ? AND `configvalue` = ?";
- $query = OC_DB::prepare($query);
- $query->execute(array($userid, 'core', 'enabled', 'false'));
+ $sql = "DELETE FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ? AND `configvalue` = ?";
+ $stmt = OC_DB::prepare($sql);
+ if ( ! OC_DB::isError($stmt) ) {
+ $result = $stmt->execute(array($userid, 'core', 'enabled', 'false'));
+ if ( OC_DB::isError($result) ) {
+ OC_Log::write('OC_User', 'could not enable user: '. OC_DB::getErrorMessage($result), OC_Log::ERROR);
+ }
+ } else {
+ OC_Log::write('OC_User', 'could not enable user: '. OC_DB::getErrorMessage($stmt), OC_Log::ERROR);
+ }
}
/**
@@ -437,10 +451,19 @@ class OC_User {
* @return bool
*/
public static function isEnabled($userid) {
- $query = "SELECT `userid` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ? AND `configvalue` = ?";
- $query = OC_DB::prepare($query);
- $results = $query->execute(array($userid, 'core', 'enabled', 'false'));
- return $results->numRows() ? false : true;
+ $sql = "SELECT `userid` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ? AND `configvalue` = ?";
+ $stmt = OC_DB::prepare($sql);
+ if ( ! OC_DB::isError($stmt) ) {
+ $result = $stmt->execute(array($userid, 'core', 'enabled', 'false'));
+ if ( ! OC_DB::isError($result) ) {
+ return $result->numRows() ? false : true;
+ } else {
+ OC_Log::write('OC_User', 'could not check if enabled: '. OC_DB::getErrorMessage($result), OC_Log::ERROR);
+ }
+ } else {
+ OC_Log::write('OC_User', 'could not check if enabled: '. OC_DB::getErrorMessage($stmt), OC_Log::ERROR);
+ }
+ return false;
}
/**
diff --git a/lib/user/database.php b/lib/user/database.php
index 76b44a2f6ca..25e24fcf7e4 100644
--- a/lib/user/database.php
+++ b/lib/user/database.php
@@ -155,7 +155,7 @@ class OC_User_Database extends OC_User_Backend {
* Get a list of all users.
*/
public function getUsers($search = '', $limit = null, $offset = null) {
- $query = OC_DB::prepare('SELECT `uid` FROM `*PREFIX*users` WHERE `uid` LIKE ?',$limit,$offset);
+ $query = OC_DB::prepare('SELECT `uid` FROM `*PREFIX*users` WHERE LOWER(`uid`) LIKE LOWER(?)',$limit,$offset);
$result = $query->execute(array($search.'%'));
$users = array();
while ($row = $result->fetchRow()) {
diff --git a/lib/util.php b/lib/util.php
index 5046550d6a2..c89c4d8c7c1 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -81,7 +81,7 @@ class OC_Util {
*/
public static function getVersion() {
// hint: We only can count up. So the internal version number of ownCloud 4.5 will be 4,9,0. This is not visible to the user
- return array(4,83,6);
+ return array(4,85,11);
}
/**
@@ -89,7 +89,7 @@ class OC_Util {
* @return string
*/
public static function getVersionString() {
- return '4.5 beta 2';
+ return '4.5 RC 1';
}
/**
@@ -200,22 +200,24 @@ class OC_Util {
public static function checkServer() {
$errors=array();
+ $web_server_restart= false;
//check for database drivers
if(!(is_callable('sqlite_open') or class_exists('SQLite3')) and !is_callable('mysql_connect') and !is_callable('pg_connect')) {
$errors[]=array('error'=>'No database drivers (sqlite, mysql, or postgresql) installed.<br/>','hint'=>'');//TODO: sane hint
+ $web_server_restart= true;
}
//common hint for all file permissons error messages
$permissionsHint="Permissions can usually be fixed by giving the webserver write access to the ownCloud directory";
// Check if config folder is writable.
- if(!is_writable(OC::$SERVERROOT."/config/")) {
+ if(!is_writable(OC::$SERVERROOT."/config/") or !is_readable(OC::$SERVERROOT."/config/")) {
$errors[]=array('error'=>"Can't write into config directory 'config'",'hint'=>"You can usually fix this by giving the webserver user write access to the config directory in owncloud");
}
// Check if there is a writable install folder.
if(OC_Config::getValue('appstoreenabled', true)) {
- if( OC_App::getInstallPath() === null || !is_writable(OC_App::getInstallPath())) {
+ if( OC_App::getInstallPath() === null || !is_writable(OC_App::getInstallPath()) || !is_readable(OC_App::getInstallPath()) ) {
$errors[]=array('error'=>"Can't write into apps directory",'hint'=>"You can usually fix this by giving the webserver user write access to the apps directory
in owncloud or disabling the appstore in the config file.");
}
@@ -255,35 +257,47 @@ class OC_Util {
if(!$success) {
$errors[]=array('error'=>"Can't create data directory (".$CONFIG_DATADIRECTORY.")",'hint'=>"You can usually fix this by giving the webserver write access to the ownCloud directory '".OC::$SERVERROOT."' (in a terminal, use the command 'chown -R www-data:www-data /path/to/your/owncloud/install/data' ");
}
- } else if(!is_writable($CONFIG_DATADIRECTORY)) {
+ } else if(!is_writable($CONFIG_DATADIRECTORY) or !is_readable($CONFIG_DATADIRECTORY)) {
$errors[]=array('error'=>'Data directory ('.$CONFIG_DATADIRECTORY.') not writable by ownCloud<br/>','hint'=>$permissionsHint);
}
// check if all required php modules are present
if(!class_exists('ZipArchive')) {
$errors[]=array('error'=>'PHP module zip not installed.<br/>','hint'=>'Please ask your server administrator to install the module.');
+ $web_server_restart= false;
}
if(!function_exists('mb_detect_encoding')) {
$errors[]=array('error'=>'PHP module mb multibyte not installed.<br/>','hint'=>'Please ask your server administrator to install the module.');
+ $web_server_restart= false;
}
if(!function_exists('ctype_digit')) {
$errors[]=array('error'=>'PHP module ctype is not installed.<br/>','hint'=>'Please ask your server administrator to install the module.');
+ $web_server_restart= false;
}
if(!function_exists('json_encode')) {
$errors[]=array('error'=>'PHP module JSON is not installed.<br/>','hint'=>'Please ask your server administrator to install the module.');
+ $web_server_restart= false;
}
if(!function_exists('imagepng')) {
$errors[]=array('error'=>'PHP module GD is not installed.<br/>','hint'=>'Please ask your server administrator to install the module.');
+ $web_server_restart= false;
}
if(!function_exists('gzencode')) {
$errors[]=array('error'=>'PHP module zlib is not installed.<br/>','hint'=>'Please ask your server administrator to install the module.');
+ $web_server_restart= false;
}
if(floatval(phpversion())<5.3) {
$errors[]=array('error'=>'PHP 5.3 is required.<br/>','hint'=>'Please ask your server administrator to update PHP to version 5.3 or higher. PHP 5.2 is no longer supported by ownCloud and the PHP community.');
+ $web_server_restart= false;
}
if(!defined('PDO::ATTR_DRIVER_NAME')) {
$errors[]=array('error'=>'PHP PDO module is not installed.<br/>','hint'=>'Please ask your server administrator to install the module.');
+ $web_server_restart= false;
+ }
+
+ if($web_server_restart) {
+ $errors[]=array('error'=>'PHP modules have been installed, but they are still listed as missing?<br/>','hint'=>'Please ask your server administrator to restart the web server.');
}
return $errors;
diff --git a/lib/vcategories.php b/lib/vcategories.php
index f5123adeeb6..6b1d6a316f1 100644
--- a/lib/vcategories.php
+++ b/lib/vcategories.php
@@ -55,7 +55,10 @@ class OC_VCategories {
$this->app = $app;
$this->user = is_null($user) ? OC_User::getUser() : $user;
$categories = trim(OC_Preferences::getValue($this->user, $app, self::PREF_CATEGORIES_LABEL, ''));
- $this->categories = $categories != '' ? @unserialize($categories) : $defcategories;
+ if ($categories) {
+ $categories = @unserialize($categories);
+ }
+ $this->categories = is_array($categories) ? $categories : $defcategories;
}
/**