function check_ownership(Contact $user, Contact $partner = null, MessageSet $ms = null) { global $Now; list($when, $ownership) = [0, -1]; $always = $this->reposite->validate_ownership_always(); if ($this->notes && isset($this->notes["owner." . $user->contactId])) { list($when, $ownership) = $this->notes["owner." . $user->contactId]; } if ($Now - $when > ($ownership > 0 ? 86400 : 30) || $always) { $ownership = $this->validate_ownership($user, $partner, $ms); if (!$always) { Dbl::compare_and_swap($user->conf->dblink, "select notes from Repository where repoid=?", [$this->repoid], function ($value) use($user, $ownership) { $value = json_decode($value, true) ?: []; $value["owner." . $user->contactId] = [time(), $ownership]; $this->notes = $value; return json_encode($value); }, "update Repository set notes=?{desired} where notes?{expected}e and repoid=?", [$this->repoid]); } } if ($ownership == 0 && $ms && !$ms->has_problem("ownership")) { $ms->set_warning_html("ownership", $this->expand_message("repo_notowner", $ms->user)); } return $ownership; }