[Pkg-owncloud-commits] [owncloud] 98/153: Add a method to get the values for multiple users to OC\Preferences
David Prévot
taffit at moszumanska.debian.org
Tue May 27 03:05:42 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit cf3cd572b0410e6db7255e3373c8ec8230c4af5c
Author: Joas Schilling <nickvergessen at gmx.de>
Date: Wed May 21 11:11:47 2014 +0200
Add a method to get the values for multiple users to OC\Preferences
---
lib/private/preferences.php | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/lib/private/preferences.php b/lib/private/preferences.php
index e6d9f28..c000080 100644
--- a/lib/private/preferences.php
+++ b/lib/private/preferences.php
@@ -206,6 +206,41 @@ class Preferences {
}
/**
+ * Gets the preference for an array of users
+ * @param string $app
+ * @param string $key
+ * @param array $users
+ * @return array Mapped values: userid => value
+ */
+ public function getValueForUsers($app, $key, $users) {
+ if (empty($users) || !is_array($users)) return array();
+
+ $chunked_users = array_chunk($users, 50, true);
+ $placeholders_50 = implode(',', array_fill(0, 50, '?'));
+
+ $userValues = array();
+ foreach ($chunked_users as $chunk) {
+ $queryParams = $chunk;
+ array_unshift($queryParams, $key);
+ array_unshift($queryParams, $app);
+
+ $placeholders = (sizeof($chunk) == 50) ? $placeholders_50 : implode(',', array_fill(0, sizeof($users), '?'));
+
+ $query = 'SELECT `userid`, `configvalue` '
+ . ' FROM `*PREFIX*preferences` '
+ . ' WHERE `appid` = ? AND `configkey` = ?'
+ . ' AND `userid` IN (' . $placeholders . ')';
+ $result = $this->conn->executeQuery($query, $queryParams);
+
+ while ($row = $result->fetch()) {
+ $userValues[$row['userid']] = $row['configvalue'];
+ }
+ }
+
+ return $userValues;
+ }
+
+ /**
* Deletes a key
* @param string $user user
* @param string $app app
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list