define('FRIENDICA_CODENAME', 'The Tazmans Flax-lily');
define('FRIENDICA_VERSION', '2018.08-dev');
define('DFRN_PROTOCOL_VERSION', '2.23');
-define('DB_UPDATE_VERSION', 1281);
+define('DB_UPDATE_VERSION', 1282);
define('NEW_UPDATE_ROUTINE_VERSION', 1170);
/**
"fields": {
"iid": {"type": "int unsigned", "not null": "1", "default": "0", "primary": "1", "relation": {"item": "id"}, "comment": "Item id"},
"uid": {"type": "mediumint unsigned", "not null": "1", "default": "0", "primary": "1", "relation": {"user": "uid"}, "comment": "User id"},
- "hidden": {"type": "boolean", "not null": "1", "default": "0", "comment": "Marker to hide an item from the user"}
+ "hidden": {"type": "boolean", "not null": "1", "default": "0", "comment": "Marker to hide an item from the user"},
+ "ignored": {"type": "boolean", "comment": "Ignore this thread if set"}
},
"indexes": {
"PRIMARY": ["uid", "iid"]
-- ------------------------------------------
-- Friendica 2018.08-dev (The Tazmans Flax-lily)
--- DB_UPDATE_VERSION 1281
+-- DB_UPDATE_VERSION 1282
-- ------------------------------------------
`iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item id',
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
`hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide an item from the user',
+ `ignored` boolean COMMENT 'Ignore this thread if set',
PRIMARY KEY(`uid`,`iid`)
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific item data';
}
if ($params['type'] == NOTIFY_COMMENT) {
- $thread = DBA::selectFirst('thread', ['ignored'], ['iid' => $parent_id]);
+ $thread = Item::selectFirstThreadForUser($params['uid'] ,['ignored'], ['iid' => $parent_id]);
if (DBA::isResult($thread) && $thread["ignored"]) {
logger("Thread ".$parent_id." will be ignored", LOGGER_DEBUG);
return;
}
// Is it a post that the user had started or where he interacted?
- $parent = q("SELECT `thread`.`iid` FROM `thread` INNER JOIN `item` ON `item`.`parent` = `thread`.`iid`
- WHERE `thread`.`iid` = %d AND NOT `thread`.`ignored` AND
- (`thread`.`mention` OR `item`.`author-id` IN ($contact_list))
- LIMIT 1",
- intval($item["parent"]));
+ $fields = ['ignored', 'mention', 'author-id'];
+ $thread = Item::selectFirstThreadForUser($params['uid'], $fields, ['iid' => $item["parent"]]);
- if ($parent && !isset($params["type"])) {
+ if (($thread['mention'] || in_array($thread['author-id'], $contacts)) && !$thread['ignored'] && !isset($params["type"])) {
$params["type"] = NOTIFY_COMMENT;
$params["verb"] = ACTIVITY_POST;
}
use Friendica\App;
use Friendica\Core\System;
use Friendica\Database\DBA;
+use Friendica\Model\Item;
-function ignored_init(App $a) {
-
+function ignored_init(App $a)
+{
$ignored = 0;
- if (! local_user()) {
+ if (!local_user()) {
killme();
}
+
if ($a->argc > 1) {
$message_id = intval($a->argv[1]);
}
- if (! $message_id) {
+
+ if (!$message_id) {
killme();
}
- $r = q("SELECT `ignored` FROM `thread` WHERE `uid` = %d AND `iid` = %d LIMIT 1",
- intval(local_user()),
- intval($message_id)
- );
- if (! DBA::isResult($r)) {
+ $thread = Item::selectFirstThreadForUser(local_user(), ['uid', 'ignored'], ['iid' => $message_id]);
+ if (!DBA::isResult($thread)) {
killme();
}
- if (! intval($r[0]['ignored'])) {
- $ignored = 1;
+ if (!$thread['ignored']) {
+ $ignored = true;
}
- $r = q("UPDATE `thread` SET `ignored` = %d WHERE `uid` = %d and `iid` = %d",
- intval($ignored),
- intval(local_user()),
- intval($message_id)
- );
+ if ($thread['uid'] != 0) {
+ DBA::update('thread', ['ignored' => $ignored], ['iid' => $message_id]);
+ } else {
+ DBA::update('user-item', ['ignored' => $ignored], ['iid' => $message_id, 'uid' => local_user()], true);
+ }
// See if we've been passed a return path to redirect to
- $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
+ $return_path = defaults($_REQUEST, 'return', '');
if ($return_path) {
$rand = '_=' . time();
- if(strpos($return_path, '?')) $rand = "&$rand";
- else $rand = "?$rand";
+ if (strpos($return_path, '?')) {
+ $rand = "&$rand";
+ } else {
+ $rand = "?$rand";
+ }
goaway(System::baseUrl() . "/" . $return_path . $rand);
}
}
}
+ if (array_key_exists('ignored', $row) && array_key_exists('internal-user-ignored', $row) && !is_null($row['internal-user-ignored'])) {
+ $row['ignored'] = $row['internal-user-ignored'];
+ }
+
// Remove internal fields
unset($row['internal-activity']);
unset($row['internal-network']);
unset($row['internal-iid']);
unset($row['internal-iaid']);
unset($row['internal-icid']);
+ unset($row['internal-user-ignored']);
return $row;
}
$usermode = true;
}
- $fields = self::fieldlist($selected);
+ $fields = self::fieldlist($selected, $usermode);
$select_fields = self::constructSelectFields($fields, $selected);
$usermode = true;
}
- $fields = self::fieldlist($selected);
+ $fields = self::fieldlist($selected, $usermode);
+
+ $fields['thread'] = ['mention', 'ignored', 'iid'];
$threadfields = ['thread' => ['iid', 'uid', 'contact-id', 'owner-id', 'author-id',
'created', 'edited', 'commented', 'received', 'changed', 'wall', 'private',
*
* @return array field list
*/
- private static function fieldlist($selected)
+ private static function fieldlist($selected, $usermode)
{
$fields = [];
'network' => 'internal-network', 'icid' => 'internal-icid',
'iaid' => 'internal-iaid'];
+ if ($usermode) {
+ $fields['user-item'] = ['ignored' => 'internal-user-ignored'];
+ }
+
$fields['item-activity'] = ['activity', 'activity' => 'internal-activity'];
$fields['item-content'] = array_merge(self::CONTENT_FIELDLIST, self::MIXED_CONTENT_FIELDLIST);
$selected[] = 'internal-activity';
}
+ if (in_array('ignored', $selected)) {
+ $selected[] = 'internal-user-ignored';
+ }
+
$selection = [];
foreach ($fields as $table => $table_fields) {
foreach ($table_fields as $field => $select) {
$tagger = '';
if ($this->isToplevel()) {
+ $thread = Item::selectFirstThreadForUser(local_user(), ['ignored'], ['iid' => $item['id']]);
+ if (DBA::isResult($thread)) {
+ $ignore = [
+ 'do' => L10n::t("ignore thread"),
+ 'undo' => L10n::t("unignore thread"),
+ 'toggle' => L10n::t("toggle ignore status"),
+ 'classdo' => $thread['ignored'] ? "hidden" : "",
+ 'classundo' => $thread['ignored'] ? "" : "hidden",
+ 'ignored' => L10n::t('ignored'),
+ ];
+ }
+
if ($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) {
$isstarred = (($item['starred']) ? "starred" : "unstarred");
'starred' => L10n::t('starred'),
];
- $thread = DBA::selectFirst('thread', ['ignored'], ['uid' => $item['uid'], 'iid' => $item['id']]);
- if (DBA::isResult($thread)) {
- $ignore = [
- 'do' => L10n::t("ignore thread"),
- 'undo' => L10n::t("unignore thread"),
- 'toggle' => L10n::t("toggle ignore status"),
- 'classdo' => $thread['ignored'] ? "hidden" : "",
- 'classundo' => $thread['ignored'] ? "" : "hidden",
- 'ignored' => L10n::t('ignored'),
- ];
- }
-
if (Feature::isEnabled($conv->getProfileOwner(), 'commtag')) {
$tagger = [
'add' => L10n::t("add tag"),