diff --git a/boot.php b/boot.php index f592b4c27c..5ef24f4944 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', 1172 ); +define ( 'DB_UPDATE_VERSION', 1173 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); @@ -1016,8 +1016,35 @@ 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); + $retval = update_structure(false, true); + if($retval) { + //send the administrator an e-mail + $email_tpl = get_intltext_template("update_fail_eml.tpl"); + $email_msg = replace_macros($email_tpl, array( + '$sitename' => $a->config['sitename'], + '$siteurl' => $a->get_baseurl(), + '$update' => DB_UPDATE_VERSION, + '$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION) + )); + $subject=sprintf(t('Update Error at %s'), $a->get_baseurl()); + require_once('include/email.php'); + $subject = email_header_encode($subject,'UTF-8'); + mail($a->config['admin_email'], $subject, $email_msg, + 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n" + .'Content-type: text/plain; charset=UTF-8'."\n" + .'Content-transfer-encoding: 8bit'); + //try the logger + logger("CRITICAL: Database structure update failed: ".$retval); + break; + } else + set_config('database','dbupdate_'.DB_UPDATE_VERSION, 'success'); for($x = $stored; $x < $current; $x ++) { if(function_exists('update_' . $x)) { @@ -1058,11 +1085,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 5560c84b60..77482d41ba 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 @@ -173,7 +175,7 @@ function update_structure($verbose, $action) { if ($action) { $r = @$db->q($sql3); if(false === $r) - $errors .= t('Errors encountered performing database changes.').$sql3.EOL; + $errors .= t('Errors encountered performing database changes.').$sql3.EOL; } } } @@ -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 e72abd331e..970ece82eb 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/include/features.php b/include/features.php index 24955ba104..091dfc6e9d 100644 --- a/include/features.php +++ b/include/features.php @@ -60,6 +60,7 @@ function get_features() { array('filing', t('Saved Folders'), t('Ability to file posts under folders')), array('dislike', t('Dislike Posts'), t('Ability to dislike posts/comments')), array('star_posts', t('Star Posts'), t('Ability to mark special posts with a star indicator')), + array('ignore_posts', t('Mute Post Notifications'), t('Ability to mute notifications for a thread')), ), ); diff --git a/js/main.js b/js/main.js index a7ffca8d86..14dbaf127a 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/mod/admin.php b/mod/admin.php index fa4f6d7fb4..24069c5d9b 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -649,7 +649,7 @@ function admin_page_site(&$a) { '$proxy_disabled' => array('proxy_disabled', t("Disable picture proxy"), get_config('system','proxy_disabled'), t("The picture proxy increases performance and privacy. It shouldn't be used on systems with very low bandwith.")), '$relocate_url' => array('relocate_url', t("New base url"), $a->get_baseurl(), "Change base url for this server. Sends relocate message to all DFRN contacts of all users."), - + '$enable_noscrape'=> array('enable_noscrape', t("Enable noscrape"), get_config('system','enable_noscrape'), t("The noscrape feature speeds up directory submissions by using JSON data instead of HTML scraping.")), '$form_security_token' => get_form_security_token("admin_site") @@ -671,23 +671,37 @@ function admin_page_dbsync(&$a) { goaway($a->get_baseurl(true) . '/admin/dbsync'); } - if($a->argc > 2 && intval($a->argv[2])) { + if(($a->argc > 2) AND (intval($a->argv[2]) OR ($a->argv[2] === 'check'))) { + require_once("include/dbstructure.php"); + $retval = update_structure(false, true); + if (!$retval) { + $o .= sprintf(t("Database structure update %s was successfully applied."), DB_UPDATE_VERSION)."
"; + set_config('database', 'dbupdate_'.DB_UPDATE_VERSION, 'success'); + } else + $o .= sprintf(t("Executing of database structure update %s failed with error: %s"), + DB_UPDATE_VERSION, $retval)."
"; + if ($a->argv[2] === 'check') + return $o; + } + + if ($a->argc > 2 && intval($a->argv[2])) { require_once('update.php'); $func = 'update_' . intval($a->argv[2]); if(function_exists($func)) { $retval = $func(); if($retval === UPDATE_FAILED) { - $o .= sprintf( t('Executing %s failed. Check system logs.'), $func); + $o .= sprintf(t("Executing %s failed with error: %s"), $func, $retval); } elseif($retval === UPDATE_SUCCESS) { - $o .= sprintf( t('Update %s was successfully applied.', $func)); + $o .= sprintf(t('Update %s was successfully applied.', $func)); set_config('database',$func, 'success'); } else - $o .= sprintf( t('Update %s did not return a status. Unknown if it succeeded.'), $func); + $o .= sprintf(t('Update %s did not return a status. Unknown if it succeeded.'), $func); + } else { + $o .= sprintf(t('There was no additional update function %s that needed to be called.'), $func)."
"; + set_config('database',$func, 'success'); } - else - $o .= sprintf( t('Update function %s could not be found.'), $func); return $o; } @@ -701,17 +715,22 @@ function admin_page_dbsync(&$a) { $failed[] = $upd; } } - if(! count($failed)) - return '

' . t('No failed updates.') . '

'; - - $o = replace_macros(get_markup_template('failed_updates.tpl'),array( - '$base' => $a->get_baseurl(true), - '$banner' => t('Failed Updates'), - '$desc' => t('This does not include updates prior to 1139, which did not return a status.'), - '$mark' => t('Mark success (if update was manually applied)'), - '$apply' => t('Attempt to execute this update step automatically'), - '$failed' => $failed - )); + if(! count($failed)) { + $o = replace_macros(get_markup_template('structure_check.tpl'),array( + '$base' => $a->get_baseurl(true), + '$banner' => t('No failed updates.'), + '$check' => t('Check database structure'), + )); + } else { + $o = replace_macros(get_markup_template('failed_updates.tpl'),array( + '$base' => $a->get_baseurl(true), + '$banner' => t('Failed Updates'), + '$desc' => t('This does not include updates prior to 1139, which did not return a status.'), + '$mark' => t('Mark success (if update was manually applied)'), + '$apply' => t('Attempt to execute this update step automatically'), + '$failed' => $failed + )); + } return $o; diff --git a/mod/ignored.php b/mod/ignored.php new file mode 100644 index 0000000000..e876b4ef8b --- /dev/null +++ b/mod/ignored.php @@ -0,0 +1,45 @@ +argc > 1) + $message_id = intval($a->argv[1]); + 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(! count($r)) + killme(); + + if(! intval($r[0]['ignored'])) + $ignored = 1; + + $r = q("UPDATE `thread` SET `ignored` = %d WHERE `uid` = %d and `iid` = %d", + intval($ignored), + intval(local_user()), + intval($message_id) + ); + + // See if we've been passed a return path to redirect to + $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : ''); + if($return_path) { + $rand = '_=' . time(); + if(strpos($return_path, '?')) $rand = "&$rand"; + else $rand = "?$rand"; + + goaway($a->get_baseurl() . "/" . $return_path . $rand); + } + + // the json doesn't really matter, it will either be 0 or 1 + + echo json_encode($ignored); + killme(); +} diff --git a/object/Item.php b/object/Item.php index 283381ef51..19e3fdead1 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,21 @@ class Item extends BaseObject { 'classundo' => (($item['starred']) ? "" : "hidden"), 'starred' => t('starred'), ); + $r = q("SELECT `ignored` FROM `thread` WHERE `uid` = %d AND `iid` = %d LIMIT 1", + intval($item['uid']), + intval($item['id']) + ); + if (count($r)) { + $ignore = array( + 'do' => t("ignore thread"), + 'undo' => t("unignore thread"), + 'toggle' => t("toggle ignore status"), + 'classdo' => (($r[0]['ignored']) ? "hidden" : ""), + 'classundo' => (($r[0]['ignored']) ? "" : "hidden"), + 'ignored' => t('ignored'), + ); + } + $tagger = ''; if(feature_enabled($conv->get_profile_owner(),'commtag')) { $tagger = array( @@ -335,6 +351,7 @@ 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 : ''), 'tagger' => $tagger, 'filer' => ((feature_enabled($conv->get_profile_owner(),'filing')) ? $filer : ''), 'drop' => $drop, diff --git a/update.php b/update.php index f8c99135be..0ac59db951 100644 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@ {{$banner}} + +

{{$check}}

+ +
+ diff --git a/view/theme/vier/css/font2.css b/view/theme/vier/css/font2.css index 093982508b..c1b851105a 100644 --- a/view/theme/vier/css/font2.css +++ b/view/theme/vier/css/font2.css @@ -253,9 +253,13 @@ li.icon.icon-large:before { .icon-credit-card:before { content: "\f09d"; } .icon-rss:before { content: "\f09e"; } +.icon-bell-slash:before { content: "\f1f6"; } +.icon-bell-slash-o:before { content: "\f1f7"; } + .icon-hdd:before { content: "\f0a0"; } .icon-bullhorn:before { content: "\f0a1"; } .icon.notify:before { content: "\f0a2"; } +.icon.notify.show:before { content: "\f0f3"; } .icon-certificate:before { content: "\f0a3"; } .icon-hand-right:before { content: "\f0a4"; } .icon-hand-left:before { content: "\f0a5"; } diff --git a/view/theme/vier/font/FontAwesome.otf b/view/theme/vier/font/FontAwesome.otf index 70125459f7..81c9ad949b 100644 Binary files a/view/theme/vier/font/FontAwesome.otf and b/view/theme/vier/font/FontAwesome.otf differ diff --git a/view/theme/vier/font/fontawesome-webfont.eot b/view/theme/vier/font/fontawesome-webfont.eot old mode 100755 new mode 100644 index 0662cb96bf..84677bc0c5 Binary files a/view/theme/vier/font/fontawesome-webfont.eot and b/view/theme/vier/font/fontawesome-webfont.eot differ diff --git a/view/theme/vier/font/fontawesome-webfont.svg b/view/theme/vier/font/fontawesome-webfont.svg old mode 100755 new mode 100644 index 2edb4ec34c..d907b25ae6 --- a/view/theme/vier/font/fontawesome-webfont.svg +++ b/view/theme/vier/font/fontawesome-webfont.svg @@ -14,10 +14,11 @@ + - + - + @@ -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/font/fontawesome-webfont.ttf b/view/theme/vier/font/fontawesome-webfont.ttf old mode 100755 new mode 100644 index d365924691..96a3639cdd Binary files a/view/theme/vier/font/fontawesome-webfont.ttf and b/view/theme/vier/font/fontawesome-webfont.ttf differ diff --git a/view/theme/vier/font/fontawesome-webfont.woff b/view/theme/vier/font/fontawesome-webfont.woff old mode 100755 new mode 100644 index b9bd17e158..628b6a52a8 Binary files a/view/theme/vier/font/fontawesome-webfont.woff and b/view/theme/vier/font/fontawesome-webfont.woff differ diff --git a/view/theme/vier/templates/wall_thread.tpl b/view/theme/vier/templates/wall_thread.tpl index 22a878f7bf..e9bd270524 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}}