Merge branch 'master' into fix-7307

Conflicts:
	core/js/router.js
	settings/js/admin.js
This commit is contained in:
Thomas Müller 2014-03-06 00:15:08 +01:00
commit 32b29c9d73
47 changed files with 481 additions and 230 deletions

23
.scrutinizer.yml Normal file
View File

@ -0,0 +1,23 @@
filter:
excluded_paths:
- '3rdparty/*'
- 'apps/*/3rdparty/*'
- 'l10n/*'
- 'core/l10n/*'
- 'apps/*/l10n/*'
- 'lib/l10n/*'
- 'core/js/tests/lib/*.js'
- 'core/js/jquery-1.10.0.min.js'
- 'core/js/jquery-migrate-1.2.1.min.js'
- 'core/js/jquery-showpassword.js'
- 'core/js/jquery-tipsy.js'
- 'core/js/jquery.infieldlabel.js'
- 'core/js/jquery-ui-1.10.0.custom.js'
- 'core/js/jquery.inview.js'
- 'core/js/jquery.placeholder.js'
imports:
- javascript
- php

@ -1 +1 @@
Subproject commit c77c4ddbd4ae86a307d073647e76d602eafd0c64
Subproject commit 184f0a59f87c590ee7e89ced401205a87f213954

View File

@ -18,7 +18,7 @@ if(\OC\Files\Filesystem::file_exists($target . '/' . $file)) {
exit;
}
if ($dir != '' || $file != 'Shared') {
if ($target != '' || strtolower($file) != 'shared') {
$targetFile = \OC\Files\Filesystem::normalizePath($target . '/' . $file);
$sourceFile = \OC\Files\Filesystem::normalizePath($dir . '/' . $file);
if(\OC\Files\Filesystem::rename($sourceFile, $targetFile)) {

View File

@ -236,7 +236,7 @@ $(document).ready(function() {
var file = data.files[0];
try {
// FIXME: not so elegant... need to refactor that method to return a value
Files.isFileNameValid(file.name);
Files.isFileNameValid(file.name, FileList.getCurrentDirectory());
}
catch (errorMessage) {
data.textStatus = 'invalidcharacters';
@ -562,7 +562,7 @@ $(document).ready(function() {
throw t('files', 'URL cannot be empty');
} else if (type !== 'web' && !Files.isFileNameValid(filename)) {
// Files.isFileNameValid(filename) throws an exception itself
} else if ($('#dir').val() === '/' && filename === 'Shared') {
} else if (FileList.getCurrentDirectory() === '/' && filename.toLowerCase() === 'shared') {
throw t('files', 'In the home folder \'Shared\' is a reserved filename');
} else if (FileList.inList(filename)) {
throw t('files', '{new_name} already exists', {new_name: filename});

View File

@ -421,15 +421,12 @@ window.FileList={
len = input.val().length;
}
input.selectRange(0, len);
var checkInput = function () {
var filename = input.val();
if (filename !== oldname) {
if (!Files.isFileNameValid(filename)) {
// Files.isFileNameValid(filename) throws an exception itself
} else if($('#dir').val() === '/' && filename === 'Shared') {
throw t('files','In the home folder \'Shared\' is a reserved filename');
} else if (FileList.inList(filename)) {
Files.isFileNameValid(filename, FileList.getCurrentDirectory());
if (FileList.inList(filename)) {
throw t('files', '{new_name} already exists', {new_name: filename});
}
}
@ -1158,9 +1155,9 @@ $(document).ready(function() {
// need to initially switch the dir to the one from the hash (IE8)
FileList.changeDirectory(parseCurrentDirFromUrl(), false, true);
}
}
FileList.setCurrentDir(parseCurrentDirFromUrl(), false);
}
FileList.createFileSummary();
});

View File

@ -87,9 +87,12 @@ var Files = {
* Throws a string exception with an error message if
* the file name is not valid
*/
isFileNameValid: function (name) {
isFileNameValid: function (name, root) {
var trimmedName = name.trim();
if (trimmedName === '.' || trimmedName === '..') {
if (trimmedName === '.'
|| trimmedName === '..'
|| (root === '/' && trimmedName.toLowerCase() === 'shared'))
{
throw t('files', '"{name}" is an invalid file name.', {name: name});
} else if (trimmedName.length === 0) {
throw t('files', 'File name cannot be empty.');

View File

@ -17,7 +17,13 @@ $totalsize = 0; ?>
data-mime="<?php p($file['mimetype'])?>"
data-size="<?php p($file['size']);?>"
data-etag="<?php p($file['etag']);?>"
data-permissions="<?php p($file['permissions']); ?>">
data-permissions="<?php p($file['permissions']); ?>"
<?php if(isset($file['displayname_owner'])): ?>
data-share-owner="<?php p($file['displayname_owner']) ?>"
<?php endif; ?>
>
<?php if(isset($file['isPreviewAvailable']) and $file['isPreviewAvailable']): ?>
<td class="filename svg preview-icon"
<?php else: ?>
@ -34,17 +40,15 @@ $totalsize = 0; ?>
<span class="nametext">
<?php print_unescaped(htmlspecialchars($file['name']));?>
</span>
<span class="uploadtext" currentUploads="0">
</span>
</a>
<?php else: ?>
<a class="name" href="<?php p(rtrim($_['downloadURL'],'/').'/'.trim($directory,'/').'/'.$name); ?>">
<label class="filetext" title="" for="select-<?php p($file['fileid']); ?>"></label>
<span class="nametext"><?php print_unescaped(htmlspecialchars($file['basename']));?><span class='extension'><?php p($file['extension']);?></span></span>
</a>
<?php endif; ?>
<?php if($file['type'] == 'dir'):?>
<span class="uploadtext" currentUploads="0">
</span>
<?php endif;?>
</a>
</td>
<td class="filesize"
style="color:rgb(<?php p($simple_size_color.','.$simple_size_color.','.$simple_size_color) ?>)">

View File

@ -48,6 +48,41 @@ describe('Files tests', function() {
expect(error).toEqual(false);
}
});
it('Validates correct file names do not create Shared folder in root', function() {
// create shared file in subfolder
var error = false;
try {
expect(Files.isFileNameValid('shared', '/foo')).toEqual(true);
expect(Files.isFileNameValid('Shared', '/foo')).toEqual(true);
}
catch (e) {
error = e;
}
expect(error).toEqual(false);
// create shared file in root
var threwException = false;
try {
Files.isFileNameValid('Shared', '/');
console.error('Invalid file name not detected');
}
catch (e) {
threwException = true;
}
expect(threwException).toEqual(true);
// create shared file in root
var threwException = false;
try {
Files.isFileNameValid('shared', '/');
console.error('Invalid file name not detected');
}
catch (e) {
threwException = true;
}
expect(threwException).toEqual(true);
});
it('Detects invalid file names', function() {
var fileNames = [
'',

View File

@ -135,7 +135,6 @@ class Util {
// Set directories to check / create
$setUpDirs = array(
$this->userDir,
$this->userFilesDir,
$this->publicKeyDir,
$this->encryptionDir,
$this->keyfilesPath,

View File

@ -302,13 +302,23 @@ $(document).ready(function() {
});
$('#allowUserMounting').bind('change', function() {
OC.msg.startSaving('#userMountingMsg');
if (this.checked) {
OC.AppConfig.setValue('files_external', 'allow_user_mounting', 'yes');
$('#userMountingBackups').removeClass('hidden');
} else {
OC.AppConfig.setValue('files_external', 'allow_user_mounting', 'no');
$('#userMountingBackups').addClass('hidden');
}
OC.msg.finishedSaving('#userMountingMsg', {status: 'success', data: {message: t('settings', 'Saved')}});
});
$('input[name="allowUserMountingBackends\\[\\]"]').bind('change', function() {
OC.msg.startSaving('#userMountingMsg');
var user_mounting_backends = $('input[name="allowUserMountingBackends\\[\\]"]:checked').map(function(){return $(this).val();}).get();
OC.AppConfig.setValue('files_external', 'user_mounting_backends', user_mounting_backends.join());
OC.msg.finishedSaving('#userMountingMsg', {status: 'success', data: {message: t('settings', 'Saved')}});
});
});
})();

View File

@ -45,7 +45,7 @@ class OC_Mount_Config {
'datadir' => 'Location'));
$backends['\OC\Files\Storage\AmazonS3']=array(
'backend' => 'Amazon S3',
'backend' => 'Amazon S3 and compliant',
'configuration' => array(
'key' => 'Access Key',
'secret' => '*Secret Key',
@ -155,6 +155,35 @@ class OC_Mount_Config {
return($backends);
}
/**
* Get details on each of the external storage backends, used for the mount config UI
* Some backends are not available as a personal backend, f.e. Local and such that have
* been disabled by the admin.
*
* If a custom UI is needed, add the key 'custom' and a javascript file with that name will be loaded
* If the configuration parameter should be secret, add a '*' to the beginning of the value
* If the configuration parameter is a boolean, add a '!' to the beginning of the value
* If the configuration parameter is optional, add a '&' to the beginning of the value
* If the configuration parameter is hidden, add a '#' to the beginning of the value
* @return array
*/
public static function getPersonalBackends() {
$backends = self::getBackends();
// Remove local storage and other disabled storages
unset($backends['\OC\Files\Storage\Local']);
$allowed_backends = explode(',', OCP\Config::getAppValue('files_external', 'user_mounting_backends', ''));
foreach ($backends as $backend => $null) {
if (!in_array($backend, $allowed_backends)) {
unset($backends[$backend]);
}
}
return $backends;
}
/**
* Get the system mount points
* The returned array is not in the same format as getUserMountPoints()
@ -290,8 +319,9 @@ class OC_Mount_Config {
}
if ($isPersonal) {
// Verify that the mount point applies for the current user
// Prevent non-admin users from mounting local storage
if ($applicable !== OCP\User::getUser() || strtolower($class) === '\oc\files\storage\local') {
// Prevent non-admin users from mounting local storage and other disabled backends
$allowed_backends = self::getPersonalBackends();
if ($applicable != OCP\User::getUser() || !in_array($class, $allowed_backends)) {
return false;
}
$mountPoint = '/'.$applicable.'/files/'.ltrim($mountPoint, '/');
@ -446,7 +476,7 @@ class OC_Mount_Config {
*/
public static function checksmbclient() {
if(function_exists('shell_exec')) {
$output=shell_exec('which smbclient 2> /dev/null');
$output=shell_exec('command -v smbclient 2> /dev/null');
return !empty($output);
}else{
return false;

View File

@ -22,9 +22,8 @@
OCP\Util::addScript('files_external', 'settings');
OCP\Util::addStyle('files_external', 'settings');
$backends = OC_Mount_Config::getBackends();
// Remove local storage
unset($backends['\OC\Files\Storage\Local']);
$backends = OC_Mount_Config::getPersonalBackends();
$tmpl = new OCP\Template('files_external', 'settings');
$tmpl->assign('isAdminPage', false);
$tmpl->assign('mounts', OC_Mount_Config::getPersonalMountPoints());

View File

@ -26,10 +26,26 @@ OCP\Util::addScript('files_external', 'settings');
OCP\Util::addscript('3rdparty', 'chosen/chosen.jquery.min');
OCP\Util::addStyle('files_external', 'settings');
OCP\Util::addStyle('3rdparty', 'chosen/chosen');
$backends = OC_Mount_Config::getBackends();
$personal_backends = array();
$enabled_backends = explode(',', OCP\Config::getAppValue('files_external', 'user_mounting_backends', ''));
foreach ($backends as $class => $backend)
{
if ($class != '\OC\Files\Storage\Local')
{
$personal_backends[$class] = array(
'backend' => $backend['backend'],
'enabled' => in_array($class, $enabled_backends),
);
}
}
$tmpl = new OCP\Template('files_external', 'settings');
$tmpl->assign('isAdminPage', true);
$tmpl->assign('mounts', OC_Mount_Config::getSystemMountPoints());
$tmpl->assign('backends', OC_Mount_Config::getBackends());
$tmpl->assign('backends', $backends);
$tmpl->assign('personal_backends', $personal_backends);
$tmpl->assign('groups', OC_Group::getGroups());
$tmpl->assign('users', OCP\User::getUsers());
$tmpl->assign('userDisplayNames', OC_User::getDisplayNames());

View File

@ -122,12 +122,18 @@
<?php if ($_['isAdminPage']): ?>
<br />
<input type="checkbox"
name="allowUserMounting"
id="allowUserMounting"
<input type="checkbox" name="allowUserMounting" id="allowUserMounting"
value="1" <?php if ($_['allowUserMounting'] == 'yes') print_unescaped(' checked="checked"'); ?> />
<label for="allowUserMounting"><?php p($l->t('Enable User External Storage')); ?></label><br/>
<em><?php p($l->t('Allow users to mount their own external storage')); ?></em>
<label for="allowUserMounting"><?php p($l->t('Enable User External Storage')); ?></label> <span id="userMountingMsg" class="msg"></span>
<p id="userMountingBackups"<?php if ($_['allowUserMounting'] != 'yes'): ?> class="hidden"<?php endif; ?>>
<?php p($l->t('Allow users to mount the following external storage')); ?><br />
<?php $i = 0; foreach ($_['personal_backends'] as $class => $backend): ?>
<input type="checkbox" id="allowUserMountingBackends<?php p($i); ?>" name="allowUserMountingBackends[]" value="<?php p($class); ?>" <?php if ($backend['enabled']) print_unescaped(' checked="checked"'); ?> />
<label for="allowUserMountingBackends<?php p($i); ?>"><?php p($backend['backend']); ?></label> <br />
<?php $i++; ?>
<?php endforeach; ?>
</p>
<?php endif; ?>
</fieldset>
</form>

View File

@ -5,6 +5,14 @@ $(document).ready(function() {
if (typeof OC.Share !== 'undefined' && typeof FileActions !== 'undefined' && !disableSharing) {
$('#fileList').on('fileActionsReady',function(){
var allShared = $('#fileList').find('[data-share-owner]').find('[data-Action="Share"]');
allShared.addClass('permanent');
allShared.find('span').text(function(){
$owner = $(this).closest('tr').attr('data-share-owner');
return ' ' + t('files_sharing', 'Shared by {owner}', {owner: $owner});
});
if (!sharesLoaded){
OC.Share.loadIcons('file');
// assume that we got all shares, so switching directories
@ -17,16 +25,15 @@ $(document).ready(function() {
});
FileActions.register('all', 'Share', OC.PERMISSION_READ, OC.imagePath('core', 'actions/share'), function(filename) {
if ($('#dir').val() == '/') {
var item = $('#dir').val() + filename;
} else {
var item = $('#dir').val() + '/' + filename;
var dir = $('#dir').val();
var item = dir + '/' + filename;
if (dir == '/') {
item = dir + filename;
}
var tr = FileList.findFileEl(filename);
if ($(tr).data('type') == 'dir') {
var itemType = 'folder';
} else {
var itemType = 'file';
if ($(tr).data('type') == 'dir') {
itemType = 'folder';
}
var possiblePermissions = $(tr).data('permissions');
var appendTo = $(tr).find('td.filename');

View File

@ -137,9 +137,12 @@ class Shared_Cache extends Cache {
} else {
$cache = $this->getSourceCache($folder);
if ($cache) {
$parent = $this->storage->getFile($folder);
$sourceFolderContent = $cache->getFolderContents($this->files[$folder]);
foreach ($sourceFolderContent as $key => $c) {
$sourceFolderContent[$key]['usersPath'] = 'files/Shared/' . $folder . '/' . $c['name'];
$sourceFolderContent[$key]['uid_owner'] = $parent['uid_owner'];
$sourceFolderContent[$key]['displayname_owner'] = $parent['uid_owner'];
}
return $sourceFolderContent;

View File

@ -94,6 +94,9 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
$file['mtime'] = $item['mtime'];
$file['encrypted'] = $item['encrypted'];
$file['etag'] = $item['etag'];
$file['uid_owner'] = $item['uid_owner'];
$file['displayname_owner'] = $item['displayname_owner'];
$storage = \OC\Files\Filesystem::getStorage('/');
$cache = $storage->getCache();
if ($item['encrypted'] or ($item['unencrypted_size'] > 0 and $cache->getMimetype($item['mimetype']) === 'httpd/unix-directory')) {

View File

@ -120,7 +120,7 @@ class Helper {
$saveOtherConfigurations = '';
if(empty($prefix)) {
$saveOtherConfigurations = 'AND `Configkey` NOT LIKE \'s%\'';
$saveOtherConfigurations = 'AND `configkey` NOT LIKE \'s%\'';
}
$query = \OCP\DB::prepare('

View File

@ -54,8 +54,12 @@ class User_Proxy extends lib\Proxy implements \OCP\UserInterface {
protected function walkBackends($uid, $method, $parameters) {
$cacheKey = $this->getUserCacheKey($uid);
foreach($this->backends as $configPrefix => $backend) {
// print("walkBackend '$configPrefix'<br/>");
if($result = call_user_func_array(array($backend, $method), $parameters)) {
$instance = $backend;
if(!method_exists($instance, $method)
&& method_exists($this->getAccess($configPrefix), $method)) {
$instance = $this->getAccess($configPrefix);
}
if($result = call_user_func_array(array($instance, $method), $parameters)) {
$this->writeToCache($cacheKey, $configPrefix);
return $result;
}
@ -77,7 +81,12 @@ class User_Proxy extends lib\Proxy implements \OCP\UserInterface {
//in case the uid has been found in the past, try this stored connection first
if(!is_null($prefix)) {
if(isset($this->backends[$prefix])) {
$result = call_user_func_array(array($this->backends[$prefix], $method), $parameters);
$instance = $this->backends[$prefix];
if(!method_exists($instance, $method)
&& method_exists($this->getAccess($prefix), $method)) {
$instance = $this->getAccess($prefix);
}
$result = call_user_func_array(array($instance, $method), $parameters);
if($result === $passOnWhen) {
//not found here, reset cache to null if user vanished
//because sometimes methods return false with a reason

View File

@ -178,6 +178,9 @@ $CONFIG = array(
/* Enable or disable the logging of IP addresses in case of webform auth failures */
"log_authfailip" => false,
/* Whether http-basic username must equal username to login */
"basic_auth" => true,
/*
* Configure the size in bytes log rotation should happen, 0 or false disables the rotation.
* This rotates the current owncloud logfile to a new name, this way the total log usage

View File

@ -156,11 +156,15 @@
background-image: url('../img/actions/sound-off.svg');
}
.icon-star {
.icon-star,
.icon-starred:hover,
.icon-starred:focus {
background-image: url('../img/actions/star.svg');
}
.icon-starred {
.icon-starred,
.icon-star:hover,
.icon-star:focus {
background-image: url('../img/actions/starred.svg');
}

View File

@ -175,6 +175,7 @@ button, .button,
border: 1px solid rgba(190,190,190,.9);
cursor: pointer;
border-radius: 3px;
outline: none;
}
input[type="submit"]:hover, input[type="submit"]:focus,
input[type="button"]:hover, input[type="button"]:focus,
@ -204,18 +205,18 @@ textarea:disabled {
/* Primary action button, use sparingly */
.primary, input[type="submit"].primary, input[type="button"].primary, button.primary, .button.primary {
border: 1px solid #1d2d44;
background: #35537a;
background-color: #35537a;
color: #ddd;
}
.primary:hover, input[type="submit"].primary:hover, input[type="button"].primary:hover, button.primary:hover, .button.primary:hover,
.primary:focus, input[type="submit"].primary:focus, input[type="button"].primary:focus, button.primary:focus, .button.primary:focus {
border: 1px solid #1d2d44;
background: #304d76;
background-color: #304d76;
color: #fff;
}
.primary:active, input[type="submit"].primary:active, input[type="button"].primary:active, button.primary:active, .button.primary:active {
border: 1px solid #1d2d44;
background: #1d2d44;
background-color: #1d2d44;
color: #bbb;
}
@ -233,7 +234,7 @@ textarea:disabled {
}
input[type="submit"].enabled {
background: #66f866;
background-color: #66f866;
border: 1px solid #5e5;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -36,6 +36,7 @@ $(document).ready(function() {
$('#showAdvanced').click(function() {
$('#datadirContent').slideToggle(250);
$('#databaseBackend').slideToggle(250);
$('#databaseField').slideToggle(250);
});
$("form").submit(function(){
@ -73,6 +74,7 @@ $(document).ready(function() {
if (currentDbType === 'sqlite' || (dbtypes.sqlite && currentDbType === undefined)){
$('#datadirContent').hide(250);
$('#databaseBackend').hide(250);
$('#databaseField').hide(250);
}

View File

@ -84,7 +84,7 @@
<?php endif; ?>
<?php if(!$_['dbIsSet'] OR count($_['errors']) > 0): ?>
<fieldset id='databaseField'>
<fieldset id='databaseBackend'>
<?php if($_['hasMySQL'] or $_['hasPostgreSQL'] or $_['hasOracle'] or $_['hasMSSQL'])
$hasOtherDB = true; else $hasOtherDB =false; //other than SQLite ?>
<legend><?php p($l->t( 'Configure the database' )); ?></legend>
@ -100,8 +100,10 @@
<?php endif; ?>
<?php endforeach; ?>
</div>
</fieldset>
<?php if($hasOtherDB): ?>
<fieldset id='databaseField'>
<div id="use_other_db">
<p class="infield grouptop">
<label for="dbuser" class="infield"><?php p($l->t( 'Database user' )); ?></label>
@ -141,9 +143,9 @@
autocomplete="off" autocapitalize="off" autocorrect="off" />
</p>
</div>
<?php endif; ?>
</fieldset>
<?php endif; ?>
<?php endif; ?>
<div class="buttons"><input type="submit" class="primary" value="<?php p($l->t( 'Finish setup' )); ?>" data-finishing="<?php p($l->t( 'Finishing …' )); ?>" /></div>
</form>

View File

@ -2,15 +2,15 @@
<tr><td>
<table cellspacing="0" cellpadding="0" border="0" width="600px">
<tr>
<td bgcolor="#1d2d44" width="20px">&nbsp;</td>
<td bgcolor="#1d2d44">
<img src="<?php print_unescaped(OC_Helper::makeURLAbsolute(image_path('', 'logo-mail.gif'))); ?>" alt="<?php p($theme->getName()); ?>"/>
<td bgcolor="<?php p($theme->getMailHeaderColor());?>" width="20px">&nbsp;</td>
<td bgcolor="<?php p($theme->getMailHeaderColor());?>">
<img src="<?php p(OC_Helper::makeURLAbsolute(image_path('', 'logo-mail.gif'))); ?>" alt="<?php p($theme->getName()); ?>"/>
</td>
</tr>
<tr><td bgcolor="#f8f8f8" colspan="2">&nbsp;</td></tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr>
<td bgcolor="#f8f8f8" width="20px">&nbsp;</td>
<td bgcolor="#f8f8f8" style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">
<td width="20px">&nbsp;</td>
<td style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">
<?php
print_unescaped($l->t('Hey there,<br><br>just letting you know that %s shared <strong>%s</strong> with you.<br><a href="%s">View it!</a><br><br>', array($_['user_displayname'], $_['filename'], $_['link'])));
if ( isset($_['expiration']) ) {
@ -21,17 +21,17 @@ p($l->t('Cheers!'));
?>
</td>
</tr>
<tr><td bgcolor="#f8f8f8" colspan="2">&nbsp;</td></tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr>
<td bgcolor="#f8f8f8" width="20px">&nbsp;</td>
<td bgcolor="#f8f8f8" style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">--<br>
<td width="20px">&nbsp;</td>
<td style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">--<br>
<?php p($theme->getName()); ?> -
<?php p($theme->getSlogan()); ?>
<br><a href="<?php print_unescaped($theme->getBaseUrl()); ?>"><?php print_unescaped($theme->getBaseUrl());?></a>
<br><a href="<?php p($theme->getBaseUrl()); ?>"><?php p($theme->getBaseUrl());?></a>
</td>
</tr>
<tr>
<td bgcolor="#f8f8f8" colspan="2">&nbsp;</td>
<td colspan="2">&nbsp;</td>
</tr>
</table>
</td></tr>

View File

@ -553,7 +553,8 @@ class OC {
OC_User::useBackend(new OC_User_Database());
OC_Group::useBackend(new OC_Group_Database());
if (isset($_SERVER['PHP_AUTH_USER']) && self::$session->exists('loginname')
$basic_auth = OC_Config::getValue('basic_auth', true);
if ($basic_auth && isset($_SERVER['PHP_AUTH_USER']) && self::$session->exists('loginname')
&& $_SERVER['PHP_AUTH_USER'] !== self::$session->get('loginname')) {
$sessionUser = self::$session->get('loginname');
$serverUser = $_SERVER['PHP_AUTH_USER'];

View File

@ -219,6 +219,8 @@ class OC_App{
$appdata=OC_OCSClient::getApplication($app);
$download=OC_OCSClient::getApplicationDownload($app, 1);
if(isset($download['downloadlink']) and $download['downloadlink']!='') {
// Replace spaces in download link without encoding entire URL
$download['downloadlink'] = str_replace(' ', '%20', $download['downloadlink']);
$info = array('source'=>'http', 'href'=>$download['downloadlink'], 'appdata'=>$appdata);
$app=OC_Installer::installApp($info);
}

View File

@ -77,7 +77,7 @@ class Config {
/**
* @brief Gets a value from config.php
* @param string $key key
* @param string|null $default = null default value
* @param array|bool|string|null $default = null default value
* @return string the value or $default
*
* This function gets the value from config.php. If it does not exist,

View File

@ -50,7 +50,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
*/
public function createFile($name, $data = null) {
if ($name === 'Shared' && empty($this->path)) {
if (strtolower($name) === 'shared' && empty($this->path)) {
throw new \Sabre_DAV_Exception_Forbidden();
}
@ -86,7 +86,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
*/
public function createDirectory($name) {
if ($name === 'Shared' && empty($this->path)) {
if (strtolower($name) === 'shared' && empty($this->path)) {
throw new \Sabre_DAV_Exception_Forbidden();
}

View File

@ -94,6 +94,9 @@ class ObjectTree extends \Sabre_DAV_ObjectTree {
}
if ($sourceDir !== $destinationDir) {
// for a full move we need update privileges on sourcePath and sourceDir as well as destinationDir
if (ltrim($destinationDir, '/') === '' && strtolower($sourceNode->getName()) === 'shared') {
throw new \Sabre_DAV_Exception_Forbidden();
}
if (!$fs->isUpdatable($sourceDir)) {
throw new \Sabre_DAV_Exception_Forbidden();
}

View File

@ -41,7 +41,9 @@ class MDB2SchemaReader {
*/
public function loadSchemaFromFile($file) {
$schema = new \Doctrine\DBAL\Schema\Schema();
$loadEntities = libxml_disable_entity_loader(false);
$xml = simplexml_load_file($file);
libxml_disable_entity_loader($loadEntities);
foreach ($xml->children() as $child) {
/**
* @var \SimpleXMLElement $child

View File

@ -21,6 +21,7 @@ class OC_Defaults {
private $defaultDocBaseUrl;
private $defaultSlogan;
private $defaultLogoClaim;
private $defaultMailHeaderColor;
function __construct() {
$this->l = OC_L10N::get('core');
@ -33,6 +34,7 @@ class OC_Defaults {
$this->defaultDocBaseUrl = "http://doc.owncloud.org";
$this->defaultSlogan = $this->l->t("web services under your control");
$this->defaultLogoClaim = "";
$this->defaultMailHeaderColor = "#1d2d44"; /* header color of mail notifications */
if (class_exists("OC_Theme")) {
$this->theme = new OC_Theme();
@ -181,4 +183,16 @@ class OC_Defaults {
return $this->getDocBaseUrl() . '/server/6.0/go.php?to=' . $key;
}
/**
* Returns mail header color
* @return mail header color
*/
public function getMailHeaderColor() {
if ($this->themeExist('getMailHeaderColor')) {
return $this->theme->getMailHeaderColor();
} else {
return $this->defaultMailHeaderColor;
}
}
}

View File

@ -464,7 +464,7 @@ class OC_Installer{
// is the code checker enabled?
if(OC_Config::getValue('appcodechecker', true)) {
// check if grep is installed
$grep = exec('which grep');
$grep = exec('command -v grep');
if($grep=='') {
OC_Log::write('core',
'grep not installed. So checking the code of the app "'.$appname.'" was not possible',

View File

@ -73,8 +73,8 @@ class OC_L10N implements \OCP\IL10N {
/**
* get an L10N instance
* @param $app string
* @param $lang string|null
* @param string $app
* @param string|null $lang
* @return OC_L10N
*/
public static function get($app, $lang=null) {
@ -87,8 +87,8 @@ class OC_L10N implements \OCP\IL10N {
/**
* @brief The constructor
* @param $app string app requesting l10n
* @param $lang string default: null Language
* @param string $app app requesting l10n
* @param string $lang default: null Language
* @returns OC_L10N-Object
*
* If language is not set, the constructor tries to find the right
@ -237,7 +237,7 @@ class OC_L10N implements \OCP\IL10N {
/**
* @brief Translating
* @param $text String The text we need a translation for
* @param string $text The text we need a translation for
* @param array $parameters default:array() Parameters for sprintf
* @return \OC_L10N_String Translation or the same text
*
@ -250,9 +250,9 @@ class OC_L10N implements \OCP\IL10N {
/**
* @brief Translating
* @param $text_singular String the string to translate for exactly one object
* @param $text_plural String the string to translate for n objects
* @param $count Integer Number of objects
* @param string $text_singular the string to translate for exactly one object
* @param string $text_plural the string to translate for n objects
* @param integer $count Number of objects
* @param array $parameters default:array() Parameters for sprintf
* @return \OC_L10N_String Translation or the same text
*
@ -351,7 +351,7 @@ class OC_L10N implements \OCP\IL10N {
/**
* @brief Localization
* @param $type Type of localization
* @param string $type Type of localization
* @param $params parameters for this localization
* @returns String or false
*
@ -406,7 +406,7 @@ class OC_L10N implements \OCP\IL10N {
/**
* @brief Choose a language
* @param $texts Associative Array with possible strings
* @param array $text Associative Array with possible strings
* @returns String
*
* $text is an array 'de' => 'hallo welt', 'en' => 'hello world', ...
@ -421,7 +421,7 @@ class OC_L10N implements \OCP\IL10N {
/**
* @brief find the best language
* @param $app Array or string, details below
* @param array|string $app details below
* @returns string language
*
* If $app is an array, ownCloud assumes that these are the available
@ -494,7 +494,7 @@ class OC_L10N implements \OCP\IL10N {
/**
* @brief find the l10n directory
* @param $app App that needs to be translated
* @param string $app App that needs to be translated
* @returns directory
*/
protected static function findI18nDir($app) {
@ -514,7 +514,7 @@ class OC_L10N implements \OCP\IL10N {
/**
* @brief find all available languages for an app
* @param $app App that needs to be translated
* @param string $app App that needs to be translated
* @returns array an array of available languages
*/
public static function findAvailableLanguages($app=null) {
@ -533,7 +533,9 @@ class OC_L10N implements \OCP\IL10N {
}
/**
* @param string $app
* @param string $lang
* @returns bool
*/
public static function languageExists($app, $lang) {
if ($lang == 'en') {//english is always available

View File

@ -61,17 +61,29 @@ class OC_OCS_Cloud {
* the user from whom the information will be returned
*/
public static function getUser($parameters) {
$return = array();
// Check if they are viewing information on themselves
if($parameters['userid'] === OC_User::getUser()) {
// Self lookup
$storage = OC_Helper::getStorageInfo('/');
$quota = array(
$return['quota'] = array(
'free' => $storage['free'],
'used' => $storage['used'],
'total' => $storage['total'],
'relative' => $storage['relative'],
);
return new OC_OCS_Result(array('quota' => $quota));
}
if(OC_User::isAdminUser(OC_User::getUser())
|| OC_Subadmin::isUserAccessible(OC_User::getUser(), $parameters['userid'])) {
if(OC_User::userExists($parameters['userid'])) {
// Is an admin/subadmin so can see display name
$return['displayname'] = OC_User::getDisplayName($parameters['userid']);
} else {
return new OC_OCS_Result(null, 101);
}
}
if(count($return)) {
return new OC_OCS_Result($return);
} else {
// No permission to view this user data
return new OC_OCS_Result(null, 997);

View File

@ -52,6 +52,11 @@ class Preview {
static private $providers = array();
static private $registeredProviders = array();
/**
* @var \OCP\Files\FileInfo
*/
protected $info;
/**
* @brief check if thumbnail or bigger version of thumbnail of file is cached
* @param string $user userid - if no user is given, OC_User::getUser will be used
@ -160,6 +165,13 @@ class Preview {
return $this->configMaxY;
}
protected function getFileInfo() {
if (!$this->info) {
$this->info = $this->fileView->getFileInfo($this->file);
}
return $this->info;
}
/**
* @brief set the path of the file you want a thumbnail from
* @param string $file
@ -167,8 +179,9 @@ class Preview {
*/
public function setFile($file) {
$this->file = $file;
$this->info = null;
if ($file !== '') {
$this->mimetype = $this->fileView->getMimeType($this->file);
$this->mimetype = $this->getFileInfo()->getMimetype();
}
return $this;
}
@ -260,12 +273,11 @@ class Preview {
public function deletePreview() {
$file = $this->getFile();
$fileInfo = $this->fileView->getFileInfo($file);
$fileId = $fileInfo['fileid'];
$fileInfo = $this->getFileInfo($file);
$fileId = $fileInfo->getId();
$previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/' . $this->getMaxX() . '-' . $this->getMaxY() . '.png';
$this->userView->unlink($previewPath);
return !$this->userView->file_exists($previewPath);
return $this->userView->unlink($previewPath);
}
/**
@ -275,13 +287,12 @@ class Preview {
public function deleteAllPreviews() {
$file = $this->getFile();
$fileInfo = $this->fileView->getFileInfo($file);
$fileId = $fileInfo['fileid'];
$fileInfo = $this->getFileInfo($file);
$fileId = $fileInfo->getId();
$previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/';
$this->userView->deleteAll($previewPath);
$this->userView->rmdir($previewPath);
return !$this->userView->is_dir($previewPath);
return $this->userView->rmdir($previewPath);
}
/**
@ -297,8 +308,8 @@ class Preview {
$scalingUp = $this->getScalingUp();
$maxScaleFactor = $this->getMaxScaleFactor();
$fileInfo = $this->fileView->getFileInfo($file);
$fileId = $fileInfo['fileid'];
$fileInfo = $this->getFileInfo($file);
$fileId = $fileInfo->getId();
if (is_null($fileId)) {
return false;
@ -386,15 +397,18 @@ class Preview {
$maxY = $this->getMaxY();
$scalingUp = $this->getScalingUp();
$fileInfo = $this->fileView->getFileInfo($file);
$fileId = $fileInfo['fileid'];
$fileInfo = $this->getFileInfo($file);
$fileId = $fileInfo->getId();
$cached = $this->isCached();
if ($cached) {
$image = new \OC_Image($this->userView->file_get_contents($cached, 'r'));
$stream = $this->userView->fopen($cached, 'r');
$image = new \OC_Image();
$image->loadFromFileHandle($stream);
$this->preview = $image->valid() ? $image : null;
$this->resizeAndCrop();
fclose($stream);
}
if (is_null($this->preview)) {

View File

@ -9,7 +9,7 @@
namespace OC\Preview;
function findBinaryPath($program) {
exec('which ' . escapeshellarg($program) . ' 2> /dev/null', $output, $returnCode);
exec('command -v ' . escapeshellarg($program) . ' 2> /dev/null', $output, $returnCode);
if ($returnCode === 0 && count($output) > 0) {
return escapeshellcmd($output[0]);
}

View File

@ -64,12 +64,12 @@ if (!\OC_Util::runningOnWindows()) {
$cmd = \OC_Config::getValue('preview_libreoffice_path', null);
}
$whichLibreOffice = shell_exec('which libreoffice');
$whichLibreOffice = shell_exec('command -v libreoffice');
if($cmd === '' && !empty($whichLibreOffice)) {
$cmd = 'libreoffice';
}
$whichOpenOffice = shell_exec('which openoffice');
$whichOpenOffice = shell_exec('command -v openoffice');
if($cmd === '' && !empty($whichOpenOffice)) {
$cmd = 'openoffice';
}

View File

@ -11,9 +11,9 @@ if (extension_loaded('imagick') && count(@\Imagick::queryFormats("PDF")) === 1)
// LibreOffice preview is currently not supported on Windows
if (!\OC_Util::runningOnWindows()) {
$whichLibreOffice = ($isShellExecEnabled ? shell_exec('which libreoffice') : '');
$whichLibreOffice = ($isShellExecEnabled ? shell_exec('command -v libreoffice') : '');
$isLibreOfficeAvailable = !empty($whichLibreOffice);
$whichOpenOffice = ($isShellExecEnabled ? shell_exec('which libreoffice') : '');
$whichOpenOffice = ($isShellExecEnabled ? shell_exec('command -v libreoffice') : '');
$isOpenOfficeAvailable = !empty($whichOpenOffice);
//let's see if there is libreoffice or openoffice on this machine
if($isShellExecEnabled && ($isLibreOfficeAvailable || $isOpenOfficeAvailable || is_string(\OC_Config::getValue('preview_libreoffice_path', null)))) {

View File

@ -61,7 +61,7 @@ class Base {
/**
* @brief Assign variables
* @param string $key key
* @param string $value value
* @param array|bool|integer|string $value value
* @return bool
*
* This function assigns a variable. It can be accessed via $_[$key] in

View File

@ -73,6 +73,36 @@ class Controller {
\OC_JSON::success(array("data" => array( "message" => $l->t("Saved") )));
}
/**
* Send a mail to test the settings
*/
public static function sendTestMail() {
\OC_Util::checkAdminUser();
\OCP\JSON::callCheck();
$l = \OC_L10N::get('settings');
$email = \OC_Preferences::getValue(\OC_User::getUser(), 'settings', 'email', '');
if (!empty($email)) {
$defaults = new \OC_Defaults();
try {
\OC_Mail::send($email, $_POST['user'],
$l->t('test email settings'),
$l->t('If you received this email, the settings seem to be correct.'),
\OCP\Util::getDefaultEmailAddress('no-reply'), $defaults->getName());
} catch (\Exception $e) {
$message = $l->t('A problem occurred while sending the e-mail. Please revisit your settings.');
\OC_JSON::error( array( "data" => array( "message" => $message)) );
exit;
}
\OC_JSON::success(array("data" => array( "message" => $l->t("Email sent") )));
} else {
$message = $l->t('You need to set your user email before being able to send test emails.');
\OC_JSON::error( array( "data" => array( "message" => $message)) );
}
}
/**
* Get the field name to use it in error messages
*

View File

@ -62,10 +62,18 @@ $(document).ready(function(){
});
$('#mail_settings').change(function(){
OC.msg.startSaving('#mail_settings .msg');
OC.msg.startSaving('#mail_settings_msg');
var post = $( "#mail_settings" ).serialize();
$.post(OC.generateUrl('/settings/admin/mailsettings'), post, function(data){
OC.msg.finishedSaving('#mail_settings .msg', data);
});
});
$('#sendtestemail').click(function(){
OC.msg.startAction('#sendtestmail_msg', t('settings', 'Sending...'));
var post = $( "#sendtestemail" ).serialize();
$.post(OC.generateUrl('/settings/admin/mailtest'), post, function(data){
OC.msg.finishedAction('#sendtestmail_msg', data);
});
});
});

View File

@ -75,5 +75,8 @@ $this->create('settings_ajax_setloglevel', '/settings/ajax/setloglevel.php')
$this->create('settings_mail_settings', '/settings/admin/mailsettings')
->post()
->action('OC\Settings\Admin\Controller', 'setMailSettings');
$this->create('settings_admin_mail_test', '/settings/admin/mailtest')
->post()
->action('OC\Settings\Admin\Controller', 'sendTestMail');
$this->create('settings_ajax_setsecurity', '/settings/ajax/setsecurity.php')
->actionInclude('settings/ajax/setsecurity.php');

View File

@ -272,7 +272,7 @@ if (!$_['internetconnectionworking']) {
</fieldset>
<fieldset id="mail_settings" class="personalblock">
<h2><?php p($l->t('Email Server'));?> <span class="msg"></span></h2>
<h2><?php p($l->t('Email Server'));?> <span id="mail_settings_msg" class="msg"></span></h2>
<p><?php p($l->t('This is used for sending out notifications.')); ?></p>
@ -347,6 +347,10 @@ if (!$_['internetconnectionworking']) {
placeholder="<?php p($l->t('SMTP Password'))?>" value='<?php p($_['mail_smtppassword']) ?>' />
</p>
<br />
<em><?php p($l->t( 'Test email settings' )); ?></em>
<input type="submit" name="sendtestemail" id="sendtestemail" value="<?php p($l->t( 'Send email' )); ?>"/>
<span id="sendtestmail_msg" class="msg"></span>
</fieldset>
<fieldset class="personalblock">

View File

@ -83,7 +83,7 @@ if($_['passwordChangeSupported']) {
placeholder="<?php p($l->t('Your email address'));?>"
autocomplete="on" autocapitalize="off" autocorrect="off" />
<span class="msg"></span><br />
<em><?php p($l->t('Fill in an email address to enable password recovery'));?></em>
<em><?php p($l->t('Fill in an email address to enable password recovery and receive notifications'));?></em>
</fieldset>
</form>
<?php