return true;
}
+function conv_get_blocklist()
+{
+ if (!local_user()) {
+ return [];
+ }
+
+ $str_blocked = PConfig::get(local_user(), 'system', 'blocked');
+ if (empty($str_blocked)) {
+ return [];
+ }
+
+ $blocklist = [];
+
+ foreach (explode(',', $str_blocked) as $entry) {
+ $cid = Contact::getIdForURL(trim($entry), 0, true);
+ if (!empty($cid)) {
+ $blocklist[] = $cid;
+ }
+ }
+
+ return $blocklist;
+}
+
/**
* "Render" a conversation or list of items for HTML display.
* There are two major forms of display:
*/
function conversation(App $a, array $items, $mode, $update, $preview = false, $order = 'commented', $uid = 0) {
- $ssl_state = ((local_user()) ? true : false);
+ $ssl_state = (local_user() ? true : false);
$profile_owner = 0;
$live_update_div = '';
- $arr_blocked = null;
-
- if (local_user()) {
- $str_blocked = PConfig::get(local_user(), 'system', 'blocked');
-
- if ($str_blocked) {
- $arr_blocked = explode(',', $str_blocked);
-
- for ($x = 0; $x < count($arr_blocked); $x ++) {
- $arr_blocked[$x] = trim($arr_blocked[$x]);
- }
- }
-
- }
+ $blocklist = conv_get_blocklist();
$previewing = (($preview) ? ' preview ' : '');
continue;
}
- if ($arr_blocked) {
- $blocked = false;
- foreach ($arr_blocked as $b) {
- if ($b && link_compare($item['author-link'], $b)) {
- $blocked = true;
- break;
- }
- }
- if ($blocked) {
- continue;
- }
+ if (in_array($item['author-id'], $blocklist)) {
+ continue;
}
-
$threadsid++;
$owner_url = '';
* But for now, this array respects the old style, just in case
*/
foreach ($items as $item) {
- if ($arr_blocked) {
- $blocked = false;
- foreach ($arr_blocked as $b) {
- if ($b && link_compare($item['author-link'], $b)) {
- $blocked = true;
- break;
- }
- }
- if ($blocked) {
- continue;
- }
+ if (in_array($item['author-id'], $blocklist)) {
+ continue;
}
// Can we put this after the visibility check?
return $parents;
}
+ $blocklist = conv_get_blocklist();
+
$item_array = [];
// Dedupes the item list on the uri to prevent infinite loops
foreach ($item_list as $item) {
+ if (in_array($item['author-id'], $blocklist)) {
+ continue;
+ }
+
$item_array[$item['uri']] = $item;
}