Code Duplication    Length = 9-12 lines in 4 locations

lib/private/group/database.php 1 location

@@ 160-171 (lines=12) @@
157
	 * This function fetches all groups a user belongs to. It does not check
158
	 * if the user exists at all.
159
	 */
160
	public function getUserGroups( $uid ) {
161
		// No magic!
162
		$stmt = OC_DB::prepare( "SELECT `gid` FROM `*PREFIX*group_user` WHERE `uid` = ?" );
163
		$result = $stmt->execute( array( $uid ));
164
165
		$groups = array();
166
		while( $row = $result->fetchRow()) {
167
			$groups[] = $row["gid"];
168
		}
169
170
		return $groups;
171
	}
172
173
	/**
174
	 * get a list of all groups

lib/private/subadmin.php 3 locations

@@ 69-77 (lines=9) @@
66
	 * @param string $uid uid of the SubAdmin
67
	 * @return array
68
	 */
69
	public static function getSubAdminsGroups($uid) {
70
		$stmt = OC_DB::prepare('SELECT `gid` FROM `*PREFIX*group_admin` WHERE `uid` = ?');
71
		$result = $stmt->execute(array($uid));
72
		$gids = array();
73
		while($row = $result->fetchRow()) {
74
			$gids[] = $row['gid'];
75
		}
76
		return $gids;
77
	}
78
79
	/**
80
	 * get SubAdmins of a group
@@ 84-92 (lines=9) @@
81
	 * @param string $gid gid of the group
82
	 * @return array
83
	 */
84
	public static function getGroupsSubAdmins($gid) {
85
		$stmt = OC_DB::prepare('SELECT `uid` FROM `*PREFIX*group_admin` WHERE `gid` = ?');
86
		$result = $stmt->execute(array($gid));
87
		$uids = array();
88
		while($row = $result->fetchRow()) {
89
			$uids[] = $row['uid'];
90
		}
91
		return $uids;
92
	}
93
94
	/**
95
	 * get all SubAdmins
@@ 98-106 (lines=9) @@
95
	 * get all SubAdmins
96
	 * @return array
97
	 */
98
	public static function getAllSubAdmins() {
99
		$stmt = OC_DB::prepare('SELECT * FROM `*PREFIX*group_admin`');
100
		$result = $stmt->execute();
101
		$subadmins = array();
102
		while($row = $result->fetchRow()) {
103
			$subadmins[] = $row;
104
		}
105
		return $subadmins;
106
	}
107
108
	/**
109
	 * checks if a user is a SubAdmin of a group