From 7eeb320085b8164cbac711b925e960ca3c921863 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Thu, 4 Sep 2014 00:58:52 +0200 Subject: [PATCH] It is now possible to ignore threads. --- boot.php | 16 +- include/dbstructure.php | 5 +- include/enotify.php | 51 ++--- js/main.js | 24 ++- object/Item.php | 11 ++ update.php | 2 +- view/theme/vier/css/font2.css | 4 + view/theme/vier/font/fontawesome-webfont.svg | 189 +++++++++++++++---- view/theme/vier/templates/wall_thread.tpl | 4 + 9 files changed, 244 insertions(+), 62 deletions(-) mode change 100755 => 100644 view/theme/vier/font/fontawesome-webfont.svg diff --git a/boot.php b/boot.php index 122201839..181981787 100644 --- a/boot.php +++ b/boot.php @@ -14,7 +14,7 @@ require_once('include/features.php'); define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_VERSION', '3.2.1753' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1170 ); +define ( 'DB_UPDATE_VERSION', 1171 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); @@ -1016,9 +1016,17 @@ if(! function_exists('update_db')) { if(DB_UPDATE_VERSION == UPDATE_VERSION) { // Compare the current structure with the defined structure + + $t = get_config('database','dbupdate_'.DB_UPDATE_VERSION); + if($t !== false) + break; + set_config('database','dbupdate_'.DB_UPDATE_VERSION, time()); + require_once("include/dbstructure.php"); update_structure(false, true); + set_config('database','dbupdate_'.DB_UPDATE_VERSION, 'success'); + for($x = $stored; $x < $current; $x ++) { if(function_exists('update_' . $x)) { @@ -1058,11 +1066,13 @@ if(! function_exists('update_db')) { //try the logger logger('CRITICAL: Update Failed: '. $x); break; - } - else { + } else { set_config('database','update_' . $x, 'success'); set_config('system','build', $x + 1); } + } else { + set_config('database','update_' . $x, 'success'); + set_config('system','build', $x + 1); } } } diff --git a/include/dbstructure.php b/include/dbstructure.php index c13d8fe5b..1f604ae6e 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -95,6 +95,8 @@ function update_structure($verbose, $action) { $errors = false; + logger('updating structure', LOGGER_DEBUG); + // Get the current structure $database = array(); @@ -130,7 +132,7 @@ function update_structure($verbose, $action) { // Compare the field structure field by field foreach ($structure["fields"] AS $fieldname => $parameters) { if (!isset($database[$name]["fields"][$fieldname])) { - $sql2=db_add_table_field($name, $fieldname, $parameters); + $sql2=db_add_table_field($fieldname, $parameters); if ($sql3 == "") $sql3 = "ALTER TABLE `".$name."` ".$sql2; else @@ -1160,6 +1162,7 @@ function db_definition() { "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), + "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"), "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), diff --git a/include/enotify.php b/include/enotify.php index e72abd331..970ece82e 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -63,6 +63,15 @@ function notification($params) { $parent_id = $params['parent']; + $p = q("SELECT `ignored` FROM `thread` WHERE `iid` = %d AND `uid` = %d LIMIT 1", + intval($parent_id), + intval($params['uid']) + ); + if ($p AND count($p) AND ($p[0]["ignored"])) { + logger("Thread ".$parent_id." will be ignored", LOGGER_DEBUG); + return; + } + // Check to see if there was already a tag notify or comment notify for this post. // If so don't create a second notification @@ -117,11 +126,11 @@ function notification($params) { // Some mail softwares relies on subject field for threading. // So, we cannot have different subjects for notifications of the same thread. - // Before this we have the name of the replier on the subject rendering + // Before this we have the name of the replier on the subject rendering // differents subjects for messages on the same thread. $subject = sprintf( t('[Friendica:Notify] Comment to conversation #%1$d by %2$s'), $parent_id, $params['source_name']); - $preamble = sprintf( t('%s commented on an item/conversation you have been following.'), $params['source_name']); + $preamble = sprintf( t('%s commented on an item/conversation you have been following.'), $params['source_name']); $epreamble = $dest_str; $sitelink = t('Please visit %s to view and/or reply to the conversation.'); @@ -175,9 +184,9 @@ function notification($params) { $subject = sprintf( t('[Friendica:Notify] %1$s poked you') , $params['source_name']); $preamble = sprintf( t('%1$s poked you at %2$s') , $params['source_name'], $sitename); - $epreamble = sprintf( t('%1$s [url=%2$s]poked you[/url].') , + $epreamble = sprintf( t('%1$s [url=%2$s]poked you[/url].') , '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', - $params['link']); + $params['link']); $subject = str_replace('poked', t($params['activity']), $subject); $preamble = str_replace('poked', t($params['activity']), $preamble); @@ -194,7 +203,7 @@ function notification($params) { $preamble = sprintf( t('%1$s tagged your post at %2$s') , $params['source_name'], $sitename); $epreamble = sprintf( t('%1$s tagged [url=%2$s]your post[/url]') , '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', - $itemlink); + $itemlink); $sitelink = t('Please visit %s to view and/or reply to the conversation.'); $tsitelink = sprintf( $sitelink, $siteurl ); @@ -204,10 +213,10 @@ function notification($params) { if($params['type'] == NOTIFY_INTRO) { $subject = sprintf( t('[Friendica:Notify] Introduction received')); - $preamble = sprintf( t('You\'ve received an introduction from \'%1$s\' at %2$s'), $params['source_name'], $sitename); + $preamble = sprintf( t('You\'ve received an introduction from \'%1$s\' at %2$s'), $params['source_name'], $sitename); $epreamble = sprintf( t('You\'ve received [url=%1$s]an introduction[/url] from %2$s.'), $itemlink, - '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]'); + '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]'); $body = sprintf( t('You may visit their profile at %s'),$params['source_link']); $sitelink = t('Please visit %s to approve or reject the introduction.'); @@ -218,11 +227,11 @@ function notification($params) { if($params['type'] == NOTIFY_SUGGEST) { $subject = sprintf( t('[Friendica:Notify] Friend suggestion received')); - $preamble = sprintf( t('You\'ve received a friend suggestion from \'%1$s\' at %2$s'), $params['source_name'], $sitename); + $preamble = sprintf( t('You\'ve received a friend suggestion from \'%1$s\' at %2$s'), $params['source_name'], $sitename); $epreamble = sprintf( t('You\'ve received [url=%1$s]a friend suggestion[/url] for %2$s from %3$s.'), $itemlink, '[url=' . $params['item']['url'] . ']' . $params['item']['name'] . '[/url]', - '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]'); + '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]'); $body = t('Name:') . ' ' . $params['item']['name'] . "\n"; $body .= t('Photo:') . ' ' . $params['item']['photo'] . "\n"; @@ -242,11 +251,11 @@ function notification($params) { } $h = array( - 'params' => $params, + 'params' => $params, 'subject' => $subject, - 'preamble' => $preamble, - 'epreamble' => $epreamble, - 'body' => $body, + 'preamble' => $preamble, + 'epreamble' => $epreamble, + 'body' => $body, 'sitelink' => $sitelink, 'tsitelink' => $tsitelink, 'hsitelink' => $hsitelink, @@ -290,7 +299,7 @@ function notification($params) { $datarray['verb'] = $params['verb']; $datarray['otype'] = $params['otype']; $datarray['abort'] = false; - + call_hooks('enotify_store', $datarray); if($datarray['abort']) { @@ -391,11 +400,11 @@ function notification($params) { values(%d,%d,%d,%d)", intval($notify_id), intval($params['parent']), - intval($params['uid']), + intval($params['uid']), 0 ); $additional_mail_header .= "Message-ID: <${id_for_parent}>\n"; - $log_msg = "include/enotify: No previous notification found for this parent:\n" . + $log_msg = "include/enotify: No previous notification found for this parent:\n" . " parent: ${params['parent']}\n" . " uid : ${params['uid']}\n"; logger($log_msg, LOGGER_DEBUG); } else { @@ -461,7 +470,7 @@ function notification($params) { '$htmlversion' => $datarray['htmlversion'], '$content_allowed' => $content_allowed, )); - + // load the template for private message notifications $tpl = get_markup_template('email_notify_text.tpl'); $email_text_body = replace_macros($tpl,array( @@ -479,7 +488,7 @@ function notification($params) { '$thanks' => $datarray['thanks'], '$site_admin' => $datarray['site_admin'], '$title' => $datarray['title'], - '$textversion' => $datarray['textversion'], + '$textversion' => $datarray['textversion'], '$content_allowed' => $content_allowed, )); @@ -520,9 +529,9 @@ class enotify { */ static public function send($params) { - $fromName = email_header_encode(html_entity_decode($params['fromName'],ENT_QUOTES,'UTF-8'),'UTF-8'); + $fromName = email_header_encode(html_entity_decode($params['fromName'],ENT_QUOTES,'UTF-8'),'UTF-8'); $messageSubject = email_header_encode(html_entity_decode($params['messageSubject'],ENT_QUOTES,'UTF-8'),'UTF-8'); - + // generate a mime boundary $mimeBoundary =rand(0,9)."-" .rand(10000000000,9999999999)."-" @@ -532,7 +541,7 @@ class enotify { // generate a multipart/alternative message header $messageHeader = $params['additionalMailHeader'] . - "From: $fromName <{$params['fromEmail']}>\n" . + "From: $fromName <{$params['fromEmail']}>\n" . "Reply-To: $fromName <{$params['replyTo']}>\n" . "MIME-Version: 1.0\n" . "Content-Type: multipart/alternative; boundary=\"{$mimeBoundary}\""; diff --git a/js/main.js b/js/main.js index a7ffca8d8..14dbaf127 100644 --- a/js/main.js +++ b/js/main.js @@ -441,13 +441,33 @@ $('#star-' + ident).addClass('hidden'); $('#unstar-' + ident).removeClass('hidden'); } - else { + else { $('#starred-' + ident).addClass('unstarred'); $('#starred-' + ident).removeClass('starred'); $('#star-' + ident).removeClass('hidden'); $('#unstar-' + ident).addClass('hidden'); } - $('#like-rotator-' + ident).hide(); + $('#like-rotator-' + ident).hide(); + }); + } + + function doignore(ident) { + ident = ident.toString(); + $('#like-rotator-' + ident).show(); + $.get('ignored/' + ident, function(data) { + if(data.match(/1/)) { + $('#ignored-' + ident).addClass('ignored'); + $('#ignored-' + ident).removeClass('unignored'); + $('#ignore-' + ident).addClass('hidden'); + $('#unignore-' + ident).removeClass('hidden'); + } + else { + $('#ignored-' + ident).addClass('unignored'); + $('#ignored-' + ident).removeClass('ignored'); + $('#ignore-' + ident).removeClass('hidden'); + $('#unignore-' + ident).addClass('hidden'); + } + $('#like-rotator-' + ident).hide(); }); } diff --git a/object/Item.php b/object/Item.php index 283381ef5..90b0c3fea 100644 --- a/object/Item.php +++ b/object/Item.php @@ -101,6 +101,7 @@ class Item extends BaseObject { $buttons = ''; $dropping = false; $star = false; + $ignore = false; $isstarred = "unstarred"; $indent = ''; $shiny = ''; @@ -198,6 +199,14 @@ class Item extends BaseObject { 'classundo' => (($item['starred']) ? "" : "hidden"), 'starred' => t('starred'), ); + $ignore = array( + 'do' => t("ignore thread"), + 'undo' => t("unignore thread"), + 'toggle' => t("toggle ignore status"), + 'classdo' => (($item['starred']) ? "hidden" : ""), + 'classundo' => (($item['starred']) ? "" : "hidden"), + 'ignored' => t('ignored'), + ); $tagger = ''; if(feature_enabled($conv->get_profile_owner(),'commtag')) { $tagger = array( @@ -335,6 +344,8 @@ class Item extends BaseObject { 'edpost' => ((feature_enabled($conv->get_profile_owner(),'edit_posts')) ? $edpost : ''), 'isstarred' => $isstarred, 'star' => ((feature_enabled($conv->get_profile_owner(),'star_posts')) ? $star : ''), + /* 'ignore' => ((feature_enabled($conv->get_profile_owner(),'ignore_posts')) ? $ignore : ''), */ + 'ignore' => $ignore, 'tagger' => $tagger, 'filer' => ((feature_enabled($conv->get_profile_owner(),'filing')) ? $filer : ''), 'drop' => $drop, diff --git a/update.php b/update.php index 9303e5d19..ada6edbb3 100644 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@ + - + - + @@ -30,7 +31,7 @@ - + @@ -52,7 +53,7 @@ - + @@ -77,11 +78,11 @@ - - - - - + + + + + @@ -109,8 +110,8 @@ - - + + @@ -143,17 +144,17 @@ - - + + - + - + @@ -176,14 +177,14 @@ - + - + @@ -218,8 +219,8 @@ - - + + @@ -247,10 +248,10 @@ - + - + @@ -280,8 +281,8 @@ - - + + @@ -310,7 +311,7 @@ - + @@ -342,11 +343,11 @@ - + - - + + @@ -367,8 +368,8 @@ - - + + @@ -379,7 +380,7 @@ - + @@ -390,10 +391,130 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/view/theme/vier/templates/wall_thread.tpl b/view/theme/vier/templates/wall_thread.tpl index 22a878f7b..e9bd27052 100644 --- a/view/theme/vier/templates/wall_thread.tpl +++ b/view/theme/vier/templates/wall_thread.tpl @@ -115,6 +115,10 @@ {{/if}} + {{if $item.ignore}} + + + {{/if}} {{if $item.tagger}} {{/if}}