From 06a7d39024b2ad4057a997a4ef59d0cfc166d12c Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Tue, 19 Mar 2013 14:49:02 +0100 Subject: [PATCH 01/13] User list: Keep array of available groups. Should fix #873 --- settings/js/users.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/settings/js/users.js b/settings/js/users.js index 632136b7ff..7c935515c7 100644 --- a/settings/js/users.js +++ b/settings/js/users.js @@ -6,6 +6,7 @@ var UserList = { useUndo: true, + availableGroups: [], /** * @brief Initiate user deletion process in UI @@ -78,8 +79,7 @@ var UserList = { var subadminSelect = $(''; html += ''; From 8871629db577395e1f9d018ba1b62b5be8114620 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Thu, 21 Mar 2013 23:19:59 +0100 Subject: [PATCH 03/13] replace hardcoded css style with css class - ref owncloud/core#173 --- core/css/share.css | 4 ++++ core/js/share.js | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/core/css/share.css b/core/css/share.css index 2d6849b4bb..c97f27c281 100644 --- a/core/css/share.css +++ b/core/css/share.css @@ -97,3 +97,7 @@ overflow-y:auto; overflow-x:hidden; } + +.ui-menu-item a.ocGroup { + font-weight: bold; +} diff --git a/core/js/share.js b/core/js/share.js index 36b5f6bdd7..ca9c8f04ea 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -241,7 +241,8 @@ OC.Share={ var insert = ''; if(item.label.length > 8 && item.label.substr(item.label.length-8) === ' (group)') { // current label is group - insert = ' style="font-weight:bold;"'; + insert = ' class="ocGroup"'; // attribute to insert + // remove "(group)" item.label = item.label.substring(0, item.label.length-8) } return $( "
  • " ) From 79d99b9c967b4f8880b1ad76b2b5d72805fea907 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Fri, 22 Mar 2013 09:59:19 +0100 Subject: [PATCH 04/13] use simple markup to highlight groups in share autocomplete --- core/css/share.css | 4 ---- core/js/share.js | 10 ++++------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/core/css/share.css b/core/css/share.css index c97f27c281..2d6849b4bb 100644 --- a/core/css/share.css +++ b/core/css/share.css @@ -97,7 +97,3 @@ overflow-y:auto; overflow-x:hidden; } - -.ui-menu-item a.ocGroup { - font-weight: bold; -} diff --git a/core/js/share.js b/core/js/share.js index ca9c8f04ea..73eb686abb 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -238,15 +238,13 @@ OC.Share={ }) // customize internal _renderItem function to display groups and users differently .data("ui-autocomplete")._renderItem = function( ul, item ) { - var insert = ''; + var insert = $( "" ).text( item.label ); if(item.label.length > 8 && item.label.substr(item.label.length-8) === ' (group)') { - // current label is group - insert = ' class="ocGroup"'; // attribute to insert - // remove "(group)" - item.label = item.label.substring(0, item.label.length-8) + // current label is group - wrap "strong" element + insert = insert.wrapInner(''); } return $( "
  • " ) - .append( $( "" ).text( item.label ) ) + .append( insert ) .appendTo( ul ); }; } else { From 53fd122b89ff14b056094fcbcbd294bb63687778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Rodr=C3=ADguez=20Telep=20/=20Michael=20Rodr=C3=AD?= =?UTF-8?q?guez-Torrent?= Date: Tue, 26 Mar 2013 12:46:13 +0000 Subject: [PATCH 05/13] Minor typo, coding style fixes for OC_Util::getInstanceId --- lib/util.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/util.php b/lib/util.php index 7e8fc9b6bb..e8d4e56ef1 100755 --- a/lib/util.php +++ b/lib/util.php @@ -411,18 +411,18 @@ class OC_Util { exit(); } - /** - * get an id unqiue for this instance - * @return string - */ - public static function getInstanceId() { - $id=OC_Config::getValue('instanceid', null); - if(is_null($id)) { - $id=uniqid(); - OC_Config::setValue('instanceid', $id); - } - return $id; - } + /** + * get an id unique for this instance + * @return string + */ + public static function getInstanceId() { + $id = OC_Config::getValue('instanceid', null); + if(is_null($id)) { + $id = uniqid(); + OC_Config::setValue('instanceid', $id); + } + return $id; + } /** * @brief Static lifespan (in seconds) when a request token expires. From 93a6ed3dab8d54fa2c735381298bec2bbcdfde41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Rodr=C3=ADguez=20Telep=20/=20Michael=20Rodr=C3=AD?= =?UTF-8?q?guez-Torrent?= Date: Tue, 26 Mar 2013 21:49:32 +0000 Subject: [PATCH 06/13] Ensure instanceid contains a letter instanceid is generated by uniqid() and then used as the session_name. Because session_name requires at least one letter and uniqid() does not guarantee to provide that, in the case that uniqid() generates a string of only digits, the user will be stuck in an infinite login loop because every request will generate a new PHP session. --- lib/util.php | 3 ++- tests/lib/util.php | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/util.php b/lib/util.php index e8d4e56ef1..1fa3ad765d 100755 --- a/lib/util.php +++ b/lib/util.php @@ -418,7 +418,8 @@ class OC_Util { public static function getInstanceId() { $id = OC_Config::getValue('instanceid', null); if(is_null($id)) { - $id = uniqid(); + // We need to guarantee at least one letter in instanceid so it can be used as the session_name + $id = 'oc' . uniqid(); OC_Config::setValue('instanceid', $id); } return $id; diff --git a/tests/lib/util.php b/tests/lib/util.php index 1c9054264c..1f25382592 100644 --- a/tests/lib/util.php +++ b/tests/lib/util.php @@ -54,4 +54,9 @@ class Test_Util extends PHPUnit_Framework_TestCase { $this->assertEquals('no-reply@example.com', $email); OC_Config::deleteKey('mail_domain'); } + + function testGetInstanceIdGeneratesValidId() { + OC_Config::deleteKey('instanceid'); + $this->assertStringStartsWith('oc', OC_Util::getInstanceId()); + } } From 8dd7fa850786c801299ba48546e566781fac9bb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Rodr=C3=ADguez=20Telep=20/=20Michael=20Rodr=C3=AD?= =?UTF-8?q?guez-Torrent?= Date: Tue, 26 Mar 2013 22:19:15 +0000 Subject: [PATCH 07/13] Use isAppVersionCompatible in app installer --- lib/installer.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/installer.php b/lib/installer.php index 251d115b76..49ba449263 100644 --- a/lib/installer.php +++ b/lib/installer.php @@ -134,8 +134,10 @@ class OC_Installer{ } // check if the app is compatible with this version of ownCloud - $version=OC_Util::getVersion(); - if(!isset($info['require']) or ($version[0]>$info['require'])) { + if( + !isset($info['require']) + or !OC_App::isAppVersionCompatible(OC_Util::getVersion(), $info['require']) + ) { OC_Log::write('core', 'App can\'t be installed because it is not compatible with this version of ownCloud', OC_Log::ERROR); From d3ca97dd2f6a12de191cd8bf178ca9132959c451 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Wed, 27 Mar 2013 14:51:30 +0100 Subject: [PATCH 08/13] Make it possible to show less log entries again - fix owncloud/core#1593 * show "less" button only if there are more than 3 entries * only "remove" logs till last 3 entries --- settings/js/log.js | 22 +++++++++++++++++++--- settings/templates/admin.php | 1 + 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/settings/js/log.js b/settings/js/log.js index 09b8ec1ab4..fe40f6e5d5 100644 --- a/settings/js/log.js +++ b/settings/js/log.js @@ -26,9 +26,22 @@ OC.Log={ if(!result.remain){ $('#moreLog').css('display', 'none'); } + $('#lessLog').css('display', ''); } }); }, + showLess:function(count){ + count = count || 10; + $('#moreLog').css('display', ''); + $('html, body').animate({scrollTop: $(document).height()}, 800); + while(OC.Log.loaded > 3 && count){ + $('#log tr').last().remove() + OC.Log.loaded -= 1; + count--; + } + if(OC.Log.loaded <= 3) + $('#lessLog').css('display', 'none'); + }, addEntries:function(entries){ for(var i=0;i'); levelTd.text(OC.Log.levels[entry.level]); row.append(levelTd); - + var appTd=$(''); appTd.text(entry.app); row.append(appTd); - + var messageTd=$(''); messageTd.text(entry.message); row.append(messageTd); - + var timeTd=$(''); timeTd.text(formatDate(entry.time*1000)); row.append(timeTd); @@ -58,4 +71,7 @@ $(document).ready(function(){ $('#moreLog').click(function(){ OC.Log.getMore(); }) + $('#lessLog').click(function(){ + OC.Log.showLess(); + }) }); diff --git a/settings/templates/admin.php b/settings/templates/admin.php index dd5e89b8f8..bdf4e676c1 100644 --- a/settings/templates/admin.php +++ b/settings/templates/admin.php @@ -221,6 +221,7 @@ endfor;?> ...'> + ...'> From 97d73d41a82efa19b8966948e8c627b9fd3d5b64 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Wed, 27 Mar 2013 15:19:28 +0100 Subject: [PATCH 09/13] remove animation --- settings/js/log.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/settings/js/log.js b/settings/js/log.js index fe40f6e5d5..d9a991af01 100644 --- a/settings/js/log.js +++ b/settings/js/log.js @@ -33,9 +33,8 @@ OC.Log={ showLess:function(count){ count = count || 10; $('#moreLog').css('display', ''); - $('html, body').animate({scrollTop: $(document).height()}, 800); while(OC.Log.loaded > 3 && count){ - $('#log tr').last().remove() + $('#log tr').last().remove(); OC.Log.loaded -= 1; count--; } From 7c8a0a486b51f770a5d78c63a5c1026e1dfea27f Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Wed, 27 Mar 2013 16:53:51 +0100 Subject: [PATCH 10/13] add copyright note --- settings/js/log.js | 1 + 1 file changed, 1 insertion(+) diff --git a/settings/js/log.js b/settings/js/log.js index d9a991af01..2e20aba3aa 100644 --- a/settings/js/log.js +++ b/settings/js/log.js @@ -1,5 +1,6 @@ /** * Copyright (c) 2012, Robin Appelman + * Copyright (c) 2013, Morris Jobke * This file is licensed under the Affero General Public License version 3 or later. * See the COPYING-README file. */ From df74c0e43a1da9ca1565b23fb6a5a8608457f50a Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Thu, 28 Mar 2013 15:02:31 +0100 Subject: [PATCH 11/13] apply code review hints --- settings/js/log.js | 22 ++++++++++------------ settings/templates/admin.php | 6 +++--- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/settings/js/log.js b/settings/js/log.js index 2e20aba3aa..d91c180a52 100644 --- a/settings/js/log.js +++ b/settings/js/log.js @@ -17,30 +17,27 @@ OC.Log={ levels:['Debug','Info','Warning','Error','Fatal'], loaded:3,//are initially loaded getMore:function(count){ - if(!count){ - count=10; - } + count = count || 10; $.get(OC.filePath('settings','ajax','getlog.php'),{offset:OC.Log.loaded,count:count},function(result){ if(result.status=='success'){ OC.Log.addEntries(result.data); $('html, body').animate({scrollTop: $(document).height()}, 800); if(!result.remain){ - $('#moreLog').css('display', 'none'); + $('#moreLog').hide(); } - $('#lessLog').css('display', ''); + $('#lessLog').show(); } }); }, showLess:function(count){ count = count || 10; - $('#moreLog').css('display', ''); - while(OC.Log.loaded > 3 && count){ - $('#log tr').last().remove(); - OC.Log.loaded -= 1; - count--; - } + //calculate remaining items - at least 3 + OC.Log.loaded = Math.max(3,OC.Log.loaded-count); + $('#moreLog').hide(); + // remove all non-remaining items + $('#log tr').slice(OC.Log.loaded).remove(); if(OC.Log.loaded <= 3) - $('#lessLog').css('display', 'none'); + $('#lessLog').hide(); }, addEntries:function(entries){ for(var i=0;i - +
    @@ -220,8 +220,8 @@ endfor;?>
    - ...'> - ...'> + + From f19fd3027880d09ab94d34e31f42cc20ada060d7 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Thu, 28 Mar 2013 15:43:14 +0100 Subject: [PATCH 12/13] convert js call to css rule --- settings/css/settings.css | 1 + settings/js/log.js | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/settings/css/settings.css b/settings/css/settings.css index 265a29b8f7..46a0bbe7c3 100644 --- a/settings/css/settings.css +++ b/settings/css/settings.css @@ -79,6 +79,7 @@ span.version { margin-left:1em; margin-right:1em; color:#555; } /* LOG */ #log { white-space:normal; } +#lessLog { display:none; } /* ADMIN */ span.securitywarning {color:#C33; font-weight:bold; } diff --git a/settings/js/log.js b/settings/js/log.js index d91c180a52..1aced805a4 100644 --- a/settings/js/log.js +++ b/settings/js/log.js @@ -65,7 +65,6 @@ OC.Log={ } $(document).ready(function(){ - $('#lessLog').hide(); // initially hide the less button $('#moreLog').click(function(){ OC.Log.getMore(); }) From 866ca51d834632ace8a049465e7910113620e560 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Thu, 28 Mar 2013 16:11:46 +0100 Subject: [PATCH 13/13] fix typo and remove animation --- settings/js/log.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/settings/js/log.js b/settings/js/log.js index 1aced805a4..81117f9e82 100644 --- a/settings/js/log.js +++ b/settings/js/log.js @@ -21,7 +21,6 @@ OC.Log={ $.get(OC.filePath('settings','ajax','getlog.php'),{offset:OC.Log.loaded,count:count},function(result){ if(result.status=='success'){ OC.Log.addEntries(result.data); - $('html, body').animate({scrollTop: $(document).height()}, 800); if(!result.remain){ $('#moreLog').hide(); } @@ -33,7 +32,7 @@ OC.Log={ count = count || 10; //calculate remaining items - at least 3 OC.Log.loaded = Math.max(3,OC.Log.loaded-count); - $('#moreLog').hide(); + $('#moreLog').show(); // remove all non-remaining items $('#log tr').slice(OC.Log.loaded).remove(); if(OC.Log.loaded <= 3)