From 263f8bebfeb6be30a5dc327689dd1c1739f492e5 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 15 Oct 2013 17:59:59 +0200 Subject: [PATCH 1/2] Added FileList.setViewerMode to hide controls Some files app embed themselves under the controls (like the text editor). The new method FileList.setViewerMode() makes it possible to properly show/hide the control buttons using the correct permissions. Apps using this approach must call setViewerMode(true) when starting and setViewerMode(false) upon closing to restore the controls. This is needed for #5284 --- apps/files/js/filelist.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 84ff1093253..39b27ec9f3a 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -251,6 +251,31 @@ var FileList={ $('.creatable').toggleClass('hidden', !isCreatable); $('.notCreatable').toggleClass('hidden', isCreatable); }, + /** + * Shows/hides action buttons + * + * @param show true for enabling, false for disabling + */ + showActions: function(show){ + $('.actions,#file_action_panel').toggleClass('hidden', !show); + if (show){ + // make sure to display according to permissions + var permissions = $('#permissions').val(); + var isCreatable = (permissions & OC.PERMISSION_CREATE) !== 0; + $('.creatable').toggleClass('hidden', !isCreatable); + $('.notCreatable').toggleClass('hidden', isCreatable); + } + }, + /** + * Enables/disables viewer mode. + * In viewer mode, apps can embed themselves under the controls bar. + * In viewer mode, the actions of the file list will be hidden. + * @param show true for enabling, false for disabling + */ + setViewerMode: function(show){ + this.showActions(!show); + $('#filestable').toggleClass('hidden', show); + }, remove:function(name){ $('tr').filterAttr('data-file',name).find('td.filename').draggable('destroy'); $('tr').filterAttr('data-file',name).remove(); From 00f4928866bfdf824e5c9d4cab248646442bc518 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 22 Oct 2013 18:09:40 +0200 Subject: [PATCH 2/2] Added warning notification when user home already exists When creating a user and the home already exists in the data dir, a warning notification will be displayed. Fixes #5161 --- settings/ajax/createuser.php | 7 +++++++ settings/js/users.js | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/settings/ajax/createuser.php b/settings/ajax/createuser.php index ccc2a5d402e..915fcaf2d42 100644 --- a/settings/ajax/createuser.php +++ b/settings/ajax/createuser.php @@ -38,8 +38,15 @@ try { } OC_Group::addToGroup( $username, $i ); } + + // check whether the user's files home exists + $userDirectory = OC_User::getHome($username) . '/files/'; + $homeExists = file_exists($userDirectory); + OC_JSON::success(array("data" => array( + // returns whether the home already existed + "homeExists" => $homeExists, "username" => $username, "groups" => OC_Group::getUserGroups( $username )))); } catch (Exception $exception) { diff --git a/settings/js/users.js b/settings/js/users.js index 5b7802c1e36..4c2ad5417ca 100644 --- a/settings/js/users.js +++ b/settings/js/users.js @@ -467,6 +467,18 @@ $(document).ready(function () { var addedGroups = result.data.groups; UserList.availableGroups = $.unique($.merge(UserList.availableGroups, addedGroups)); } + if (result.data.homeExists){ + OC.Notification.hide(); + OC.Notification.show(t('settings', 'Warning: Home directory for user "{user}" already exists', {user: result.data.username})); + if (UserList.notificationTimeout){ + window.clearTimeout(UserList.notificationTimeout); + } + UserList.notificationTimeout = window.setTimeout( + function(){ + OC.Notification.hide(); + UserList.notificationTimeout = null; + }, 10000); + } if($('tr[data-uid="' + username + '"]').length === 0) { UserList.add(username, username, result.data.groups, null, 'default', true); }