19 declare(strict_types=1);
38 $this->db = $db ?? $DIC->database();
50 $res = $this->db->queryF(
53 buddylist.usr_id, buddylist.buddy_usr_id, buddylist.ts, %s rel_type 55 INNER JOIN usr_data ud 56 ON ud.usr_id = buddylist.usr_id 57 INNER JOIN usr_data udbuddy 58 ON udbuddy.usr_id = buddylist.buddy_usr_id 59 WHERE buddylist.usr_id = %s 62 buddylist_requests.usr_id, buddylist_requests.buddy_usr_id, buddylist_requests.ts, (CASE WHEN ignored = 1 THEN %s ELSE %s END) rel_type 63 FROM buddylist_requests 64 INNER JOIN usr_data ud ON ud.usr_id = buddylist_requests.usr_id 65 INNER JOIN usr_data udbuddy ON udbuddy.usr_id = buddylist_requests.buddy_usr_id 66 WHERE buddylist_requests.usr_id = %s OR buddylist_requests.buddy_usr_id = %s 86 while ($row = $this->db->fetchAssoc(
$res)) {
88 $key = $this->usrId === $relation->getUsrId() ? $relation->getBuddyUsrId() : $relation->getUsrId();
89 $relations[
$key] = $relation;
97 if (self::TYPE_APPROVED === $row[
'rel_type']) {
100 (
int) $row[
'usr_id'],
101 (
int) $row[
'buddy_usr_id'],
102 (
int) $row[
'usr_id'] === $this->usrId,
107 if (self::TYPE_IGNORED === $row[
'rel_type']) {
110 (
int) $row[
'usr_id'],
111 (
int) $row[
'buddy_usr_id'],
112 (
int) $row[
'usr_id'] === $this->usrId,
119 (
int) $row[
'usr_id'],
120 (
int) $row[
'buddy_usr_id'],
121 (
int) $row[
'usr_id'] === $this->usrId,
128 $this->db->manipulateF(
129 'DELETE FROM buddylist WHERE usr_id = %s OR buddy_usr_id = %s',
130 [
'integer',
'integer'],
131 [$this->usrId, $this->usrId]
134 $this->db->manipulateF(
135 'DELETE FROM buddylist_requests WHERE usr_id = %s OR buddy_usr_id = %s',
136 [
'integer',
'integer'],
137 [$this->usrId, $this->usrId]
146 'usr_id' => [
'integer', $relation->
getUsrId()],
158 'buddy_usr_id' => [
'integer', $relation->
getUsrId()]
168 $this->db->manipulateF(
169 'DELETE FROM buddylist WHERE usr_id = %s AND buddy_usr_id = %s',
170 [
'integer',
'integer'],
174 $this->db->manipulateF(
175 'DELETE FROM buddylist WHERE buddy_usr_id = %s AND usr_id = %s',
176 [
'integer',
'integer'],
184 'buddylist_requests',
186 'usr_id' => [
'integer', $relation->
getUsrId()],
191 'ignored' => [
'integer', (
int) $ignored]
198 $this->db->manipulateF(
199 'DELETE FROM buddylist_requests WHERE usr_id = %s AND buddy_usr_id = %s',
200 [
'integer',
'integer'],
204 $this->db->manipulateF(
205 'DELETE FROM buddylist_requests WHERE buddy_usr_id = %s AND usr_id = %s',
206 [
'integer',
'integer'],
213 $ilAtomQuery = $this->db->buildAtomQuery();
214 $ilAtomQuery->addTableLock(
'buddylist_requests');
215 $ilAtomQuery->addTableLock(
'buddylist');
Class ilBuddySystemIgnoredRequestRelationState.
getAll()
Reads all items from database.
getRelationByDatabaseRecord(array $row)
removeFromRequestedBuddies(ilBuddySystemRelation $relation)
Class ilBuddySystemRelationRepository.
addToRequestedBuddies(ilBuddySystemRelation $relation, bool $ignored)
Class ilBuddySystemLinkedState.
save(ilBuddySystemRelation $relation)
Class ilBuddySystemRequestedRelationState.
removeFromApprovedBuddies(ilBuddySystemRelation $relation)
addToApprovedBuddies(ilBuddySystemRelation $relation)
__construct(int $usrId, ilDBInterface $db=null)