MCPcopy Create free account
hub / github.com/Rello/analytics / updateShareField

Method updateShareField

lib/Db/ShareMapper.php:309–333  ·  view source on GitHub ↗

Update only shares owned by the actor; audit only persisted changes. */

($shareId, string $field, $value, string $action)

Source from the content-addressed store, hash-verified

307
308 /** Update only shares owned by the actor; audit only persisted changes. */
309 private function updateShareField($shareId, string $field, $value, string $action): bool
310 {
311 $sql = $this->db->getQueryBuilder();
312 $sql->select('id', 'item_type', 'item_source', 'type', 'uid_owner', 'uid_initiator', $field)
313 ->from(self::TABLE_NAME)
314 ->where($sql->expr()->eq('uid_initiator', $sql->createNamedParameter($this->userSession->getUser()->getUID())))
315 ->andWhere($sql->expr()->eq('id', $sql->createNamedParameter($shareId)));
316 $statement = $sql->executeQuery();
317 $share = $statement->fetch();
318 $statement->closeCursor();
319 if (!$share || (string)$share[$field] === (string)$value) {
320 return true;
321 }
322
323 $sql->update(self::TABLE_NAME)->set($field, $sql->createNamedParameter($value));
324 if ($sql->executeStatement() > 0) {
325 // Password material must never enter either the message or event parameters.
326 $changes = $field === 'password' ? [] : [
327 'previous' => $share[$field],
328 'new' => $value,
329 ];
330 $this->auditShare($action, $share, $changes);
331 }
332 return true;
333 }
334
335 /** Preserve the original deletion predicates, including recipient/owner checks. */
336 private function deleteAuditedShares(IQueryBuilder $sql): void

Callers 3

updateSharePasswordMethod · 0.95
updateShareDomainMethod · 0.95

Calls 7

auditShareMethod · 0.95
eqMethod · 0.80
getUserMethod · 0.80
fetchMethod · 0.80
setMethod · 0.80
getUIDMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected