Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continuing the New User management #7151

Merged
merged 106 commits into from
Jun 3, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
0663d95
resolve conflicts while picking c0fb623
Jan 26, 2014
43ced8c
Splits Controls overlap in files and users.
Jan 28, 2014
b2ca595
Add GroupList Ajax to Users.
Jan 28, 2014
b506388
Reverts last commit, implements user in group count.
Jan 28, 2014
ce46cd3
Implements Group Creation from Sidebar
Jan 28, 2014
71160ff
Deletes Group Clientside Effectively.
Jan 30, 2014
78e1b71
Reverts Bogus Changes.
Feb 11, 2014
223e342
Fixes delete icon only on hover.
Feb 11, 2014
c7af9cd
Initial Commit : User Search, Fixes Typos
Feb 12, 2014
8e34316
Fixes User Search by username.
Feb 12, 2014
8e4bbe8
Adds class button to fix font sizes.
Feb 17, 2014
4a30665
Removes Delete Icon from Admin Group.
Feb 17, 2014
dc15233
Adds Admin to Grouplist Everywhere
Feb 17, 2014
dc28f58
add Storage Location col
blizzz Feb 18, 2014
970f899
Initial Commit : Changes Storage to Quota, Implements GroupName editing.
Feb 18, 2014
57ffadd
add Last Login column
blizzz Feb 18, 2014
3a92d48
reduce template function calls
blizzz Feb 18, 2014
f751e0b
Splits Code for Users and Groups.
Feb 19, 2014
e681e1e
Initial Commit: Takes Quota Settings inside Navigation, Changes Creat…
Feb 19, 2014
478393e
load groups when clicking on them
blizzz Feb 19, 2014
7d3ac19
do not show 0 when group has no users
blizzz Feb 19, 2014
1734cc0
sort groups by user count
blizzz Feb 19, 2014
bf88bd1
do not show 0 when administered group has no users
blizzz Feb 19, 2014
9ba4a76
resolving conflict when picking 8b81a0b
Feb 19, 2014
6364546
Fixes Markup in templates.
Feb 19, 2014
16fb48f
Adds admin check on groupname changes.
Feb 20, 2014
8a88002
Remove legacy "Check for user comment"
LukasReschke Feb 20, 2014
ed1a23c
Use OCP\JSON instead of OC_JSON
LukasReschke Feb 20, 2014
86d3cf5
Let's switch to OCP\JSON
LukasReschke Feb 20, 2014
f7903e9
do not forget to pass parameters to subtemplate
blizzz Feb 20, 2014
1f4bc7c
port scroll improvements
blizzz Feb 20, 2014
d650cd6
mark selected group active
blizzz Feb 20, 2014
f946a52
Rename and Delete Happens only on Active Group.
Feb 21, 2014
d51b384
Enhancement: Always show edit & delete for the active group.
Feb 21, 2014
ceb6c4d
Enhancement: Makes Edit and Delete Icons Tapable, 44px by 44px dimens…
Feb 21, 2014
6526b93
Enhancement: Transparency added to icons, changes opacity to 1 on hover.
Feb 21, 2014
eed108e
Enhancement : The edit icon looks like files app rename fileaction.
Feb 22, 2014
b3221f0
LDAP: adjust main template according to PR 7291
blizzz Feb 24, 2014
004dd73
fix user creation, checkSubAdminUser is only available in OC_JSON
blizzz Feb 25, 2014
506e065
stricter test for 0
blizzz Feb 25, 2014
17e640a
set admin gid to Admins filter. I.e. hard-coding the admin group, but…
blizzz Feb 25, 2014
65aa204
Enhancement : Toggle Add Group on Click, @blizzz have a look here.
Feb 25, 2014
faab6c0
move group-click initialization to groups.js and only react on elemen…
blizzz Feb 25, 2014
749afe7
when clicking on Add Group also put the focus into the group name field
blizzz Feb 25, 2014
330dfeb
group name input shall not vanish upon click, plus cleanup (groups do…
blizzz Feb 25, 2014
4801735
put Add Group elements hiding and showing into its own function
blizzz Feb 25, 2014
a4cfa95
restructure group.js and put functions to object, also add group list…
blizzz Feb 25, 2014
853ced6
hide Add Group when clicking away or pressing ESC
blizzz Feb 25, 2014
cfba7e2
don't hide add group when text is entered (except for ESC press)
blizzz Feb 25, 2014
b6b1332
Initial Commit with Group Toggle.
Feb 26, 2014
b3d68fc
refactor delete handling and apply it to users and groups
blizzz Feb 26, 2014
7aca126
Adds @blizzz to authors
Mar 6, 2014
e159f7e
Enhancement: Implements Grouplist Toggle, Courtesy Calendar App Setti…
Mar 6, 2014
d3cee79
Enhancement: Adding Group on the Sidebar updates the multiselect on t…
Mar 6, 2014
fe4b1f8
Enhancement: Adds Group to grouplist when added via multiselect
Mar 6, 2014
5f57d72
kick out deprecated and dislodged OC.Router
blizzz Apr 1, 2014
19fd7cd
When emptying a list, a hidden entry remains. If the user uid is the …
blizzz Apr 1, 2014
5b8ba79
make filter work on server-side
blizzz Apr 2, 2014
68dc665
dynamically decide whether to load 10 or 30 users
blizzz Apr 2, 2014
8df50ac
some documentation
blizzz Apr 2, 2014
dbc854d
Fire up server request only on typing printed or modifying characters…
blizzz Apr 3, 2014
249e42c
enable group filtering
blizzz Apr 14, 2014
2a8afb0
add PHP doc
blizzz Apr 16, 2014
cbcda49
get translations from settings, not core
blizzz Apr 16, 2014
08ad073
make string translatable
blizzz Apr 16, 2014
d779db5
js cleanup
DeepDiver1975 Apr 16, 2014
3c9788d
js cleanup + typos
DeepDiver1975 Apr 16, 2014
d87347e
update GroupList when a users is added or removed to a group
blizzz Apr 16, 2014
3e411c8
unify and consolidate group fetching method for initial template fill…
blizzz Apr 17, 2014
5444a11
cleanup
blizzz Apr 17, 2014
734dd70
add MetaData class for groups
blizzz Apr 17, 2014
7b8935a
show users whose username starts with the search pattern first
blizzz Apr 17, 2014
dea7f45
stick with current group when the filter is used
blizzz Apr 17, 2014
3ff123f
more appropriate label
blizzz Apr 17, 2014
a9bd416
add reset button for the filter field
blizzz Apr 17, 2014
b56d142
Rename $isadmin to $isAdmin
LukasReschke Apr 19, 2014
0067306
Remove uneeded last comma
LukasReschke Apr 19, 2014
59fef54
Rename $accessibleusers to $accessibleUsers
LukasReschke Apr 19, 2014
8141b91
Add space
LukasReschke Apr 19, 2014
f2fed6d
Rename $accessiblegroups to $accessibleGroups
LukasReschke Apr 19, 2014
f9f9550
small fixes / cleanup
blizzz Apr 22, 2014
1ae8ec6
Make sure group data is returned.
ringmaster May 5, 2014
66d00cf
user management: remove unneeded and erroneous user filter reset func…
jancborchardt May 7, 2014
57cc51d
user management: remove autocompletion of user/password fields, fix #…
jancborchardt May 7, 2014
1abf698
user management: display table at full width
jancborchardt May 7, 2014
f324aa7
fix some jshint errors
DeepDiver1975 May 7, 2014
747c011
More specific selectors, javascript cleanup.
ringmaster May 6, 2014
097887a
Add the admin group to the group list data.
ringmaster May 6, 2014
1115d68
Fix broken span.
ringmaster May 6, 2014
ad1c34d
Revisions from review.
ringmaster May 6, 2014
c38548a
Rebase cleanup.
ringmaster May 8, 2014
4de14fe
Javascript cleanup for groups.
ringmaster May 8, 2014
fc7438b
Fix UserList.empty(), use _.defer() instead of setTimeout()
ringmaster May 9, 2014
29ef2f7
user mgmt: hide group rename function because it’s not supported in t…
jancborchardt May 9, 2014
d030c28
bind undo to current deleteHandler
blizzz May 9, 2014
122ebf2
typo
blizzz May 9, 2014
a9e8d53
fix PHPDoc
blizzz May 9, 2014
7b63c2c
cleanup
blizzz May 13, 2014
ec57260
remove group rename stuff, there is not support in the backends yet. …
blizzz May 13, 2014
92b8344
replace setTimeout and clearTimeout handling by _.debounce
blizzz May 13, 2014
28a0124
polish JSDoc
blizzz May 13, 2014
2d83c68
make search parameter optional, which is already the case in the medt…
blizzz May 13, 2014
75cc16f
remove debug output
blizzz May 20, 2014
b15a5a7
undo lastLogin changes in base and user/user as this has now been pro…
blizzz Jun 2, 2014
e235de9
this line was lost on rebase
blizzz Jun 2, 2014
39982c2
fix grouplist behaviour (blank after filtering)
blizzz Jun 2, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ input[type="submit"].enabled {
position: fixed;
top:45px;
right: 0;
left: 0;
left:0;
height: 44px;
width: 100%;
padding: 0;
Expand Down
1 change: 1 addition & 0 deletions core/js/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,7 @@ function initCore() {
$('a.action.delete').tipsy({gravity:'e', fade:true, live:true});
$('a.action').tipsy({gravity:'s', fade:true, live:true});
$('td .modified').tipsy({gravity:'s', fade:true, live:true});
$('td.lastLogin').tipsy({gravity:'s', fade:true, html:true});
$('input').tipsy({gravity:'w', fade:true});

// toggle for menus
Expand Down
2 changes: 1 addition & 1 deletion lib/private/group/group.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function searchUsers($search, $limit = null, $offset = null) {
* @param string $search
* @return int|bool
*/
public function count($search) {
public function count($search = '') {
$users = false;
foreach ($this->backends as $backend) {
if($backend->implementsActions(OC_GROUP_BACKEND_COUNT_USERS)) {
Expand Down
188 changes: 188 additions & 0 deletions lib/private/group/metadata.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
<?php

/**
* Copyright (c) 2014 Arthur Schiwon <[email protected]>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/

namespace OC\Group;

class MetaData {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blizzz Can you please fix PHPDoc of the methods in this file? THX

const SORT_NONE = 0;
const SORT_USERCOUNT = 1;

/**
* @var string $user
*/
protected $user;

/**
* @var bool $isAdmin
*/
protected $isAdmin;

/**
* @var string[] $groups
*/
protected $groups = array();

/**
* @var \OC\Group\Manager $groupManager
*/
protected $groupManager;

/**
* @var int $sorting
*/
protected $sorting = false;

/**
* @var string $lastSearch
*/
protected $lastSearch;

/**
* @param string the uid of the current user
* @param bool whether the current users is an admin
* @param \OC\Group\Manager
*/
public function __construct(
$user,
$isAdmin,
\OC\Group\Manager $groupManager
) {
$this->user = $user;
$this->isAdmin = (bool)$isAdmin;
$this->groupManager = $groupManager;
}

/**
* returns an array with meta data about all available groups
* the array is structured as follows:
* [0] array containing meta data about admin groups
* [1] array containing meta data about unprivileged groups
* @param string only effective when instance was created with isAdmin being
* true
* @return array
*/
public function get($search = '') {
if($this->lastSearch !== $search) {
$this->lastSearch = $search;
$this->groups = array();
}

$adminGroups = array();
$groups = array();
$sortGroupsIndex = 0;
$sortGroupsKeys = array();
$sortAdminGroupsIndex = 0;
$sortAdminGroupsKeys = array();

foreach($this->getGroups($search) as $group) {
$groupMetaData = $this->generateGroupMetaData($group);
if (strtolower($group->getGID()) !== 'admin') {
$this->addEntry(
$groups,
$sortGroupsKeys,
$sortGroupsIndex,
$groupMetaData);
} else {
//admin group is hard coded to 'admin' for now. In future,
//backends may define admin groups too. Then the if statement
//has to be adjusted accordingly.
$this->addEntry(
$adminGroups,
$sortAdminGroupsKeys,
$sortAdminGroupsIndex,
$groupMetaData);
}
}

//whether sorting is necessary is will be checked in sort()
$this->sort($groups, $sortGroupsKeys);
$this->sort($adminGroups, $sortAdminGroupsKeys);

return array($adminGroups, $groups);
}

/**
* @brief sets the sort mode, currently 0 (none) and 1 (user entries,
* descending) are supported
* @param int the sortMode (SORT_NONE, SORT_USERCOUNT)
*/
public function setSorting($sortMode) {
if($sortMode >= 0 && $sortMode <= 1) {
$this->sorting = $sortMode;
} else {
$this->sorting = 0;
}
}

/**
* @brief adds an group entry to the resulting array
* @param array the resulting array, by reference
* @param array the sort key array, by reference
* @param array the sort key index, by reference
* @param array the group's meta data as returned by generateGroupMetaData()
* @return null
*/
private function addEntry(&$entries, &$sortKeys, &$sortIndex, $data) {
$entries[] = $data;
if($this->sorting === 1) {
$sortKeys[$sortIndex] = $data['usercount'];
$sortIndex++;
}
}

/**
* @brief creates an array containing the group meta data
* @param \OC\Group\Group
* @return array with the keys 'id', 'name' and 'usercount'
*/
private function generateGroupMetaData(\OC\Group\Group $group) {
return array(
'id' => str_replace(' ','', $group->getGID()),
'name' => $group->getGID(),
'usercount' => $group->count()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the PHPDoc the search parameter is missing here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm? we do not need any search parameter here, PHPDoc also states none.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm? we do not need any search parameter here, PHPDoc also states none.

Then count should be declared as public function count($search = "") { - otherwhise $search is undefined.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blizzz yes - please assign a meaningful default on the function count() THX

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now i got it, correct, thank you

);
}

/**
* @brief sorts the result array, if applicable
* @param array the result array, by reference
* @param array the array containing the sort keys
* @param return null
*/
private function sort(&$entries, $sortKeys) {
if($this->sorting > 0) {
array_multisort($sortKeys, SORT_DESC, $entries);
}
}

/**
* @brief returns the available groups
* @param string a search string
* @return \OC\Group\Group[]
*/
private function getGroups($search = '') {
if(count($this->groups) === 0) {
$this->fetchGroups($search);
}
return $this->groups;
}

/**
* @brief fetches the group using the group manager or the subAdmin API
* @param string a search string
* @return null
*/
private function fetchGroups($search = '') {
if($this->isAdmin) {
$this->groups = $this->groupManager->search($search);
} else {
$this->groups = \OC_SubAdmin::getSubAdminsGroups($this->user);
}
}
}
1 change: 1 addition & 0 deletions settings/ajax/creategroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
OC_JSON::checkAdminUser();

$groupname = $_POST["groupname"];
$l = OC_L10N::get('settings');

// Does the group exist?
if( in_array( $groupname, OC_Group::getGroups())) {
Expand Down
9 changes: 6 additions & 3 deletions settings/ajax/createuser.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@
OC_Group::addToGroup( $username, $i );
}

OC_JSON::success(array("data" =>
$userManager = \OC_User::getManager();
$user = $userManager->get($username);
OCP\JSON::success(array("data" =>
array(
// returns whether the home already existed
"homeExists" => $homeExists,
"username" => $username,
"groups" => OC_Group::getUserGroups( $username ))));
"groups" => OC_Group::getUserGroups( $username ),
'storageLocation' => $user->getHome())));
} catch (Exception $exception) {
OC_JSON::error(array("data" => array( "message" => $exception->getMessage())));
OCP\JSON::error(array("data" => array( "message" => $exception->getMessage())));
}
48 changes: 48 additions & 0 deletions settings/ajax/grouplist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
/**
* ownCloud
*
* @author Arthur Schiwon
* @copyright 2014 Arthur Schiwon <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/

OC_JSON::callCheck();
OC_JSON::checkSubAdminUser();
if (isset($_GET['pattern']) && !empty($_GET['pattern'])) {
$pattern = $_GET['pattern'];
} else {
$pattern = '';
}
$groups = array();
$adminGroups = array();
$groupManager = \OC_Group::getManager();
$isAdmin = OC_User::isAdminUser(OC_User::getUser());

//we pass isAdmin as true, because OC_SubAdmin has no search feature,
//groups will be filtered out later
$groupsInfo = new \OC\Group\MetaData(OC_User::getUser(), true, $groupManager);
$groupsInfo->setSorting($groupsInfo::SORT_USERCOUNT);
list($adminGroups, $groups) = $groupsInfo->get($pattern);

$accessibleGroups = $groupManager->search($pattern);
if(!$isAdmin) {
$subadminGroups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser());
$accessibleGroups = array_intersect($groups, $subadminGroups);
}

OC_JSON::success(
array('data' => array('adminGroups' => $adminGroups, 'groups' => $groups)));
51 changes: 40 additions & 11 deletions settings/ajax/userlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,55 @@
} else {
$limit = 10;
}
if (isset($_GET['gid']) && !empty($_GET['gid'])) {
$gid = $_GET['gid'];
} else {
$gid = false;
}
if (isset($_GET['pattern']) && !empty($_GET['pattern'])) {
$pattern = $_GET['pattern'];
} else {
$pattern = '';
}
$users = array();
$userManager = \OC_User::getManager();
if (OC_User::isAdminUser(OC_User::getUser())) {
$batch = OC_User::getDisplayNames('', $limit, $offset);
foreach ($batch as $user => $displayname) {
if($gid !== false) {
$batch = OC_Group::displayNamesInGroup($gid, $pattern, $limit, $offset);
} else {
$batch = OC_User::getDisplayNames($pattern, $limit, $offset);
}
foreach ($batch as $uid => $displayname) {
$user = $userManager->get($uid);
$users[] = array(
'name' => $user,
'name' => $uid,
'displayname' => $displayname,
'groups' => join(', ', OC_Group::getUserGroups($user)),
'subadmin' => join(', ', OC_SubAdmin::getSubAdminsGroups($user)),
'quota' => OC_Preferences::getValue($user, 'files', 'quota', 'default'));
'groups' => join(', ', OC_Group::getUserGroups($uid)),
'subadmin' => join(', ', OC_SubAdmin::getSubAdminsGroups($uid)),
'quota' => OC_Preferences::getValue($uid, 'files', 'quota', 'default'),
'storageLocation' => $user->getHome(),
'lastLogin' => $user->getLastLogin(),
);
}
} else {
$groups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser());
$batch = OC_Group::usersInGroups($groups, '', $limit, $offset);
foreach ($batch as $user) {
if($gid !== false && in_array($gid, $groups)) {
$groups = array($gid);
} elseif($gid !== false) {
//don't you try to investigate loops you must not know about
$groups = array();
}
$batch = OC_Group::usersInGroups($groups, $pattern, $limit, $offset);
foreach ($batch as $uid) {
$user = $userManager->get($uid);
$users[] = array(
'name' => $user,
'displayname' => OC_User::getDisplayName($user),
'groups' => join(', ', OC_Group::getUserGroups($user)),
'quota' => OC_Preferences::getValue($user, 'files', 'quota', 'default'));
'displayname' => $user->getDisplayName(),
'groups' => join(', ', OC_Group::getUserGroups($uid)),
'quota' => OC_Preferences::getValue($uid, 'files', 'quota', 'default'),
'storageLocation' => $user->getHome(),
'lastLogin' => $user->getLastLogin(),
);
}
}
OC_JSON::success(array('data' => $users));
Loading