aboutsummaryrefslogtreecommitdiffstats
path: root/include/sharedwithme.php
blob: b342f51d5ac05e30eeb59334324ccc57cfcb9f20 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php

function apply_updates() {

	//check for updated items and remove them
	$x = q("SELECT mid, max(obj) AS obj FROM item WHERE verb = '%s' AND obj_type = '%s' GROUP BY mid",
		dbesc(ACTIVITY_UPDATE),
		dbesc(ACTIVITY_OBJ_FILE)
	);

	if($x) {

		foreach($x as $xx) {

			$object = json_decode($xx['obj'],true);

			$d_mid = $object['d_mid'];
			$u_mid = $xx['mid'];

			$y = q("DELETE FROM item WHERE obj_type = '%s' AND (verb = '%s' AND mid = '%s') OR (verb = '%s' AND mid = '%s')",
				dbesc(ACTIVITY_OBJ_FILE),
				dbesc(ACTIVITY_POST),
				dbesc($d_mid),
				dbesc(ACTIVITY_UPDATE),
				dbesc($u_mid)
			);

		}

	}

}