Code Duplication    Length = 7-10 lines in 3 locations

lib/private/group/database.php 3 locations

@@ 110-116 (lines=7) @@
107
	 *
108
	 * Checks whether the user is member of a group or not.
109
	 */
110
	public function inGroup( $uid, $gid ) {
111
		// check
112
		$stmt = OC_DB::prepare( "SELECT `uid` FROM `*PREFIX*group_user` WHERE `gid` = ? AND `uid` = ?" );
113
		$result = $stmt->execute( array( $gid, $uid ));
114
115
		return $result->fetchRow() ? true : false;
116
	}
117
118
	/**
119
	 * Add a user to a group
@@ 126-135 (lines=10) @@
123
	 *
124
	 * Adds a user to a group.
125
	 */
126
	public function addToGroup( $uid, $gid ) {
127
		// No duplicate entries!
128
		if( !$this->inGroup( $uid, $gid )) {
129
			$stmt = OC_DB::prepare( "INSERT INTO `*PREFIX*group_user` ( `uid`, `gid` ) VALUES( ?, ? )" );
130
			$stmt->execute( array( $uid, $gid ));
131
			return true;
132
		}else{
133
			return false;
134
		}
135
	}
136
137
	/**
138
	 * Removes a user from a group
@@ 204-211 (lines=8) @@
201
	 * @param string $gid
202
	 * @return bool
203
	 */
204
	public function groupExists($gid) {
205
		$query = OC_DB::prepare('SELECT `gid` FROM `*PREFIX*groups` WHERE `gid` = ?');
206
		$result = $query->execute(array($gid))->fetchOne();
207
		if ($result !== false) {
208
			return true;
209
		}
210
		return false;
211
	}
212
213
	/**
214
	 * get a list of all users in a group