function _photos_access_usersave in Album Photos 8.4
Same name and namespace in other branches
- 8.5 photos_access/photos_access.module \_photos_access_usersave()
- 7.3 photos_access/photos_access.module \_photos_access_usersave()
- 6.0.x photos_access/photos_access.module \_photos_access_usersave()
Save users to access album list.
1 call to _photos_access_usersave()
- photos_access_update_access in photos_access/
photos_access.module - Update access to album.
File
- photos_access/
photos_access.module, line 676 - Implementation of photos_access.module.
Code
function _photos_access_usersave($value, $id, $collaborate = TRUE) {
$values = [];
foreach ($value as $target) {
$values[] = [
'id' => $id,
'uid' => $target['target_id'],
'collaborate' => $collaborate ? 1 : 0,
];
}
if (!empty($values)) {
// @todo check for duplicates?
// Insert users into photos access table.
$db = \Drupal::database();
$query = $db
->insert('photos_access_user')
->fields([
'id',
'uid',
'collaborate',
]);
foreach ($values as $record) {
$query
->values($record);
}
$query
->execute();
}
}