summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJan-Christoph Borchardt <JanCBorchardt@fsfe.org>2011-08-11 13:29:22 +0200
committerJan-Christoph Borchardt <JanCBorchardt@fsfe.org>2011-08-11 13:29:22 +0200
commitb4e89871dd845ecff3d7207ecbf1132fb1cde23b (patch)
tree6ac74dbb87fbbd811aefd48afbf83234b792a05d /lib
parente1bde1a78eac82f981358e68af031d974ca81639 (diff)
parent592eacf37d7b845499ddce65b15fa86791cb3eae (diff)
downloadnextcloud-server-b4e89871dd845ecff3d7207ecbf1132fb1cde23b.tar.gz
nextcloud-server-b4e89871dd845ecff3d7207ecbf1132fb1cde23b.zip
merged master into sharing
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php2
-rw-r--r--lib/group.php21
-rw-r--r--lib/group/backend.php6
-rw-r--r--lib/group/database.php22
-rw-r--r--lib/template.php4
5 files changed, 46 insertions, 9 deletions
diff --git a/lib/base.php b/lib/base.php
index 93b8e0b584d..2e735514347 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -149,9 +149,11 @@ OC_Group::setBackend( OC_Config::getValue( "groupbackend", "database" ));
OC_Util::addScript( "jquery-1.6.2.min" );
OC_Util::addScript( "jquery-ui-1.8.14.custom.min" );
OC_Util::addScript( "js" );
+OC_Util::addScript( "multiselect" );
OC_Util::addScript('search','result');
OC_Util::addStyle( "jquery-ui-1.8.14.custom" );
OC_Util::addStyle( "styles" );
+OC_Util::addStyle( "multiselect" );
// Load Apps
// This includes plugins for users and filesystems as well
diff --git a/lib/group.php b/lib/group.php
index 1161b9035fa..65a23989a27 100644
--- a/lib/group.php
+++ b/lib/group.php
@@ -171,11 +171,11 @@ class OC_Group {
*/
public static function addToGroup( $uid, $gid ){
// Does the user exist?
- if( !in_array( $uid, OC_User::getUsers())){
+ if( !OC_User::userExists($uid)){
return false;
}
// Does the group exist?
- if( !in_array( $gid, self::getGroups())){
+ if( !OC_Group::groupExists($gid)){
return false;
}
@@ -234,4 +234,21 @@ class OC_Group {
public static function getGroups(){
return self::$_backend->getGroups();
}
+
+ /**
+ * check if a group exists
+ * @param string $gid
+ * @return bool
+ */
+ public static function groupExists($gid){
+ return in_array( $gid, self::getGroups());
+ }
+
+ /**
+ * @brief get a list of all users in a group
+ * @returns array with user ids
+ */
+ public static function usersInGroup($gid){
+ return self::$_backend->usersInGroup();
+ }
}
diff --git a/lib/group/backend.php b/lib/group/backend.php
index ebee8aacb91..43f94e7ea1a 100644
--- a/lib/group/backend.php
+++ b/lib/group/backend.php
@@ -93,4 +93,10 @@ abstract class OC_Group_Backend {
* Returns a list with all groups
*/
public static function getGroups(){}
+
+ /**
+ * @brief get a list of all users in a group
+ * @returns array with user ids
+ */
+ public static function usersInGroup($gid){}
}
diff --git a/lib/group/database.php b/lib/group/database.php
index 6ca80b93985..8a9fc53d39f 100644
--- a/lib/group/database.php
+++ b/lib/group/database.php
@@ -53,7 +53,7 @@ class OC_Group_Database extends OC_Group_Backend {
*/
public static function createGroup( $gid ){
// Check for existence
- $query = OC_DB::prepare( "SELECT * FROM `*PREFIX*groups` WHERE gid = ?" );
+ $query = OC_DB::prepare( "SELECT gid FROM `*PREFIX*groups` WHERE gid = ?" );
$result = $query->execute( array( $gid ));
if( $result->numRows() > 0 ){
@@ -98,7 +98,7 @@ class OC_Group_Database extends OC_Group_Backend {
*/
public static function inGroup( $uid, $gid ){
// check
- $query = OC_DB::prepare( "SELECT * FROM `*PREFIX*group_user` WHERE gid = ? AND uid = ?" );
+ $query = OC_DB::prepare( "SELECT uid FROM `*PREFIX*group_user` WHERE gid = ? AND uid = ?" );
$result = $query->execute( array( $gid, $uid ));
return $result->numRows() > 0 ? true : false;
@@ -146,7 +146,7 @@ class OC_Group_Database extends OC_Group_Backend {
*/
public static function getUserGroups( $uid ){
// No magic!
- $query = OC_DB::prepare( "SELECT * FROM `*PREFIX*group_user` WHERE uid = ?" );
+ $query = OC_DB::prepare( "SELECT gid FROM `*PREFIX*group_user` WHERE uid = ?" );
$result = $query->execute( array( $uid ));
$groups = array();
@@ -164,7 +164,7 @@ class OC_Group_Database extends OC_Group_Backend {
* Returns a list with all groups
*/
public static function getGroups(){
- $query = OC_DB::prepare( "SELECT * FROM `*PREFIX*groups`" );
+ $query = OC_DB::prepare( "SELECT gid FROM `*PREFIX*groups`" );
$result = $query->execute();
$groups = array();
@@ -174,4 +174,18 @@ class OC_Group_Database extends OC_Group_Backend {
return $groups;
}
+
+ /**
+ * @brief get a list of all users in a group
+ * @returns array with user ids
+ */
+ public static function usersInGroup($gid){
+ $query=OC_DB::prepare('SELECT uid FROM *PREFIX*group_user WHERE gid=?');
+ $users=array();
+ $result=$query->execute(array($gid));
+ while($row=$result->fetchRow()){
+ $users[]=$row['uid'];
+ }
+ return $users;
+ }
}
diff --git a/lib/template.php b/lib/template.php
index 2ba26eebac8..bb225bdd82f 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -230,9 +230,7 @@ class OC_Template{
// Decide which page we show
if( $this->renderas == "user" ){
$page = new OC_Template( "core", "layout.user" );
- $search=new OC_Template( 'core', 'part.searchbox');
- $search->assign('searchurl',OC_Helper::linkTo( 'search', 'index.php' ));
- $page->assign('searchbox', $search->fetchPage());
+ $page->assign('searchurl',OC_Helper::linkTo( 'search', 'index.php' ));
if(array_search(OC_APP::getCurrentApp(),array('settings','admin','help'))!==false){
$page->assign('bodyid','body-settings');
}else{