本文整理匯總了PHP中UserSettings::filterUsersBySetting方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserSettings::filterUsersBySetting方法的具體用法?PHP UserSettings::filterUsersBySetting怎麽用?PHP UserSettings::filterUsersBySetting使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UserSettings
的用法示例。
在下文中一共展示了UserSettings::filterUsersBySetting方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: shareFileOrFolderWithGroup
/**
* @brief Sharing a file or folder with a group
* @param array $params The hook params
*/
public static function shareFileOrFolderWithGroup($params)
{
// User performing the share
self::shareNotificationForSharer('shared_group_self', $params['shareWith'], $params['fileSource'], $params['itemType']);
// Members of the new group
$affectedUsers = array();
$usersInGroup = \OC_Group::usersInGroup($params['shareWith']);
foreach ($usersInGroup as $user) {
$affectedUsers[$user] = $params['fileTarget'];
}
// Remove the triggering user, we already managed his notifications
unset($affectedUsers[\OCP\User::getUser()]);
if (empty($affectedUsers)) {
return;
}
$filteredStreamUsersInGroup = UserSettings::filterUsersBySetting($usersInGroup, 'stream', Data::TYPE_SHARED);
$filteredEmailUsersInGroup = UserSettings::filterUsersBySetting($usersInGroup, 'email', Data::TYPE_SHARED);
// Check when there was a naming conflict and the target is different
// for some of the users
$query = \OC_DB::prepare('SELECT `share_with`, `file_target` FROM `*PREFIX*share` WHERE `parent` = ? ');
$result = $query->execute(array($params['id']));
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('OCA\\Activity\\Hooks::shareFileOrFolderWithGroup', \OC_DB::getErrorMessage($result), \OC_Log::ERROR);
} else {
while ($row = $result->fetchRow()) {
$affectedUsers[$row['share_with']] = $row['file_target'];
}
}
foreach ($affectedUsers as $user => $path) {
if (empty($filteredStreamUsersInGroup[$user]) && empty($filteredEmailUsersInGroup[$user])) {
continue;
}
self::addNotificationsForUser($user, 'shared_with_by', array($path, \OCP\User::getUser()), $path, $params['itemType'] === 'file', !empty($filteredStreamUsersInGroup[$user]), !empty($filteredEmailUsersInGroup[$user]) ? $filteredEmailUsersInGroup[$user] : 0);
}
}