diff --git a/boot.php b/boot.php index 8c1054e642..ca7829ff51 100644 --- a/boot.php +++ b/boot.php @@ -1482,12 +1482,11 @@ if(! function_exists('profile_sidebar')) { call_hooks('profile_sidebar_enter', $profile); - + // don't show connect link to yourself $connect = (($profile['uid'] != local_user()) ? t('Connect') : False); // don't show connect link to authenticated visitors either - if(remote_user() && count($_SESSION['remote'])) { foreach($_SESSION['remote'] as $visitor) { if($visitor['uid'] == $profile['uid']) { @@ -1497,20 +1496,28 @@ if(! function_exists('profile_sidebar')) { } } + // Is the local user already connected to that user? + if ($connect AND local_user()) { + $profile_url = normalise_link($a->get_baseurl()."/profile/".$profile["nickname"]); + + $r = q("SELECT * FROM `contact` WHERE NOT `pending` AND `uid` = %d AND `nurl` = '%s'", + local_user(), $profile_url); + if (count($r)) + $connect = false; + } + if( get_my_url() && $profile['unkmail'] && ($profile['uid'] != local_user()) ) $wallmessage = t('Message'); else $wallmessage = false; - - // show edit profile to yourself if ($profile['uid'] == local_user() && feature_enabled(local_user(),'multi_profiles')) { $profile['edit'] = array($a->get_baseurl(). '/profiles', t('Profiles'),"", t('Manage/edit profiles')); - + $r = q("SELECT * FROM `profile` WHERE `uid` = %d", local_user()); - + $profile['menu'] = array( 'chg_photo' => t('Change profile photo'), 'cr_new' => t('Create New Profile'), @@ -1535,18 +1542,15 @@ if(! function_exists('profile_sidebar')) { } } - if ($profile['uid'] == local_user() && !feature_enabled(local_user(),'multi_profiles')) { - $profile['edit'] = array($a->get_baseurl(). '/profiles/'.$profile['id'], t('Edit profile'),"", t('Edit profile')); - $profile['menu'] = array( + if ($profile['uid'] == local_user() && !feature_enabled(local_user(),'multi_profiles')) { + $profile['edit'] = array($a->get_baseurl(). '/profiles/'.$profile['id'], t('Edit profile'),"", t('Edit profile')); + $profile['menu'] = array( 'chg_photo' => t('Change profile photo'), 'cr_new' => null, 'entries' => array(), ); - } + } - - - if((x($profile,'address') == 1) || (x($profile,'locality') == 1) || (x($profile,'region') == 1) diff --git a/include/bbcode.php b/include/bbcode.php index 7cf8b71fe5..8f973c9486 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -11,11 +11,11 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) { $type = ""; preg_match("/type='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") - $type = $matches[1]; + $type = strtolower($matches[1]); preg_match('/type="(.*?)"/ism', $attributes, $matches); if ($matches[1] != "") - $type = $matches[1]; + $type = strtolower($matches[1]); if ($type == "") return($match[0]); @@ -42,22 +42,26 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) { $title = $matches[1]; $image = ""; - preg_match("/image='(.*?)'/ism", $attributes, $matches); - if ($matches[1] != "") - $image = $matches[1]; + if ($type != "video") { + preg_match("/image='(.*?)'/ism", $attributes, $matches); + if ($matches[1] != "") + $image = $matches[1]; - preg_match('/image="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $image = $matches[1]; + preg_match('/image="(.*?)"/ism', $attributes, $matches); + if ($matches[1] != "") + $image = $matches[1]; + } $preview = ""; - preg_match("/preview='(.*?)'/ism", $attributes, $matches); - if ($matches[1] != "") - $preview = $matches[1]; + if ($type != "video") { + preg_match("/preview='(.*?)'/ism", $attributes, $matches); + if ($matches[1] != "") + $preview = $matches[1]; - preg_match('/preview="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $preview = $matches[1]; + preg_match('/preview="(.*?)"/ism', $attributes, $matches); + if ($matches[1] != "") + $preview = $matches[1]; + } if ($plaintext) $text = sprintf('%s', $url, $title); @@ -156,6 +160,10 @@ function bb_cleanup_share($shared, $plaintext, $nolink) { if (($text == "") AND ($title != "") AND ($link == "")) $text .= "\n\n".trim($title); + // If the link already is included in the post, don't add it again + if (($link != "") AND strpos($text, $link)) + return(trim($text)); + if (($link != "") AND ($title != "")) $text .= "\n[url=".trim($link)."]".trim($title)."[/url]"; elseif (($link != "")) diff --git a/include/enotify.php b/include/enotify.php index 7449edffa2..e72abd331e 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -28,6 +28,13 @@ function notification($params) { $sender_email = t('noreply') . '@' . $hostname; $additional_mail_header = ""; + $additional_mail_header .= "Precedence: list\n"; + $additional_mail_header .= "X-Friendica-Host: ".$hostname."\n"; + $additional_mail_header .= "X-Friendica-Platform: ".FRIENDICA_PLATFORM."\n"; + $additional_mail_header .= "X-Friendica-Version: ".FRIENDICA_VERSION."\n"; + $additional_mail_header .= "List-ID: \n"; + $additional_mail_header .= "List-Archive: <".$a->get_baseurl()."/notifications/system>\n"; + if(array_key_exists('item',$params)) { $title = $params['item']['title']; $body = $params['item']['body']; @@ -216,7 +223,7 @@ function notification($params) { $itemlink, '[url=' . $params['item']['url'] . ']' . $params['item']['name'] . '[/url]', '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]'); - + $body = t('Name:') . ' ' . $params['item']['name'] . "\n"; $body .= t('Photo:') . ' ' . $params['item']['photo'] . "\n"; $body .= sprintf( t('You may visit their profile at %s'),$params['item']['url']); @@ -245,7 +252,7 @@ function notification($params) { 'hsitelink' => $hsitelink, 'itemlink' => $itemlink ); - + call_hooks('enotify',$h); $subject = $h['subject']; @@ -367,40 +374,37 @@ function notification($params) { logger('notification: sending notification email'); - $id_for_parent = "${params['parent']}@${hostname}"; + if (isset($params['parent']) AND (intval($params['parent']) != 0)) { + $id_for_parent = $params['parent']."@".$hostname; - // Is this the first email notification for this parent item and user? + // Is this the first email notification for this parent item and user? - $r = q("select `id` from `notify-threads` where `master-parent-item` = %d and `receiver-uid` = %d limit 1", - intval($params['parent']), - intval($params['uid']) ); - - // If so, create the record of it and use a message-id smtp header. - - if(!$r) { - logger("notify_id:" . intval($notify_id). ", parent: " . intval($params['parent']) . "uid: " . -intval($params['uid']), LOGGER_DEBUG); - $r = q("insert into `notify-threads` (`notify-id`, `master-parent-item`, `receiver-uid`, `parent-item`) - values(%d,%d,%d,%d)", - intval($notify_id), + $r = q("select `id` from `notify-threads` where `master-parent-item` = %d and `receiver-uid` = %d limit 1", intval($params['parent']), - intval($params['uid']), - 0 ); + intval($params['uid']) ); - $additional_mail_header .= "Message-ID: <${id_for_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); + // If so, create the record of it and use a message-id smtp header. + + if(!$r) { + logger("notify_id:".intval($notify_id).", parent: ".intval($params['parent'])."uid: ".intval($params['uid']), LOGGER_DEBUG); + $r = q("insert into `notify-threads` (`notify-id`, `master-parent-item`, `receiver-uid`, `parent-item`) + values(%d,%d,%d,%d)", + intval($notify_id), + intval($params['parent']), + 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" . + " parent: ${params['parent']}\n" . " uid : ${params['uid']}\n"; + logger($log_msg, LOGGER_DEBUG); + } else { + // If not, just "follow" the thread. + $additional_mail_header .= "References: <${id_for_parent}>\nIn-Reply-To: <${id_for_parent}>\n"; + logger("include/enotify: There's already a notification for this parent:\n" . print_r($r, true), LOGGER_DEBUG); + } } - // If not, just "follow" the thread. - - else { - $additional_mail_header = "References: <${id_for_parent}>\nIn-Reply-To: <${id_for_parent}>\n"; - logger("include/enotify: There's already a notification for this parent:\n" . print_r($r, true), LOGGER_DEBUG); - } - - $textversion = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n", $body))),ENT_QUOTES,'UTF-8')); diff --git a/include/items.php b/include/items.php index fbbc5e7aed..d929278e23 100644 --- a/include/items.php +++ b/include/items.php @@ -1567,7 +1567,8 @@ function tag_deliver($uid,$item_id) { 'source_link' => $item['author-link'], 'source_photo' => $photo, 'verb' => ACTIVITY_TAG, - 'otype' => 'item' + 'otype' => 'item', + 'parent' => $item['parent'] )); @@ -1970,7 +1971,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) } if((is_array($contact)) && ($photo_timestamp) && (strlen($photo_url)) && ($photo_timestamp > $contact['avatar-date'])) { - logger('consume_feed: Updating photo for ' . $contact['name']); + logger('consume_feed: Updating photo for '.$contact['name'].' from '.$photo_url.' uid: '.$contact['uid']); require_once("include/Photo.php"); $photo_failure = false; $have_photo = false; diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index c18b1670d0..6f6ce61a98 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -111,9 +111,9 @@ function dfrn_request_post(&$a) { */ require_once('include/Scrape.php'); - + $parms = scrape_dfrn($dfrn_url); - + if(! count($parms)) { notice( t('Profile location is not valid or does not contain profile information.') . EOL ); return; @@ -123,7 +123,7 @@ function dfrn_request_post(&$a) { notice( t('Warning: profile location has no identifiable owner name.') . EOL ); if(! x($parms,'photo')) notice( t('Warning: profile location has no profile photo.') . EOL ); - $invalid = validate_dfrn($parms); + $invalid = validate_dfrn($parms); if($invalid) { notice( sprintf( tt("%d required parameter was not found at the given location", "%d required parameters were not found at the given location", @@ -194,7 +194,7 @@ function dfrn_request_post(&$a) { if(strlen($dfrn_request) && strlen($confirm_key)) $s = fetch_url($dfrn_request . '?confirm_key=' . $confirm_key); - + // (ignore reply, nothing we can do it failed) goaway(zrl($dfrn_url)); @@ -432,7 +432,7 @@ function dfrn_request_post(&$a) { dbesc(datetime_convert()), 1 ); - + // Next send an email verify form to the requestor. } @@ -585,7 +585,7 @@ function dfrn_request_post(&$a) { dbesc(datetime_convert()) ); } - + // This notice will only be seen by the requestor if the requestor and requestee are on the same server. if(! $failed) @@ -768,27 +768,22 @@ function dfrn_request_content(&$a) { * Try to auto-fill the profile address */ - if(local_user()) { + // At first look if an address was provided + // Otherwise take the local address + if (x($_GET,'addr') AND ($_GET['addr'] != "")) + $myaddr = hex2bin($_GET['addr']); + elseif (x($_GET,'address') AND ($_GET['address'] != "")) + $myaddr = $_GET['address']; + elseif(local_user()) { if(strlen($a->path)) { $myaddr = $a->get_baseurl() . '/profile/' . $a->user['nickname']; } else { $myaddr = $a->user['nickname'] . '@' . substr(z_root(), strpos(z_root(),'://') + 3 ); } - } - elseif(x($_GET,'addr')) { - $myaddr = hex2bin($_GET['addr']); - } - else { - /* $_GET variables are already urldecoded */ - $myaddr = ((x($_GET,'address')) ? $_GET['address'] : ''); - } - - // last, try a zrl - if(! strlen($myaddr)) + } else // last, try a zrl $myaddr = get_my_url(); - $target_addr = $a->profile['nickname'] . '@' . substr(z_root(), strpos(z_root(),'://') + 3 ); @@ -805,9 +800,6 @@ function dfrn_request_content(&$a) { else $tpl = get_markup_template('auto_request.tpl'); - # $page_desc = sprintf( t('Diaspora members: Please do not use this form. Instead, enter "%s" into your Diaspora search bar.'), - # $target_addr) . EOL . EOL; - $page_desc .= t("Please enter your 'Identity Address' from one of the following supported communications networks:"); // see if we are allowed to have NETWORK_MAIL2 contacts @@ -824,7 +816,9 @@ function dfrn_request_content(&$a) { $mail_disabled = 1; } - $emailnet = (($mail_disabled) ? '' : t("Connect as an email follower \x28Coming soon\x29")); + // "coming soon" is disabled for now + //$emailnet = (($mail_disabled) ? '' : t("Connect as an email follower \x28Coming soon\x29")); + $emailnet = ""; $invite_desc = t('If you are not yet a member of the free social web, follow this link to find a public Friendica site and join us today.'); @@ -832,9 +826,10 @@ function dfrn_request_content(&$a) { '$header' => t('Friend/Connection Request'), '$desc' => t('Examples: jojo@demo.friendica.com, http://demo.friendica.com/profile/jojo, testuser@identi.ca'), '$pls_answer' => t('Please answer the following:'), - '$does_know' => sprintf( t('Does %s know you?'),$a->profile['name']), + '$does_know_you' => array('knowyou', sprintf(t('Does %s know you?'),$a->profile['name']), false, '', array(t('No'),t('Yes'))), + /*'$does_know' => sprintf( t('Does %s know you?'),$a->profile['name']), '$yes' => t('Yes'), - '$no' => t('No'), + '$no' => t('No'), */ '$add_note' => t('Add a personal note:'), '$page_desc' => $page_desc, '$friendica' => t('Friendica'), diff --git a/mod/profiles.php b/mod/profiles.php index b715fc3eed..4914ae1eff 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -167,7 +167,7 @@ function profiles_post(&$a) { $profile_name = notags(trim($_POST['profile_name'])); if(! strlen($profile_name)) { - notify( t('Profile Name is required.') . EOL); + notice( t('Profile Name is required.') . EOL); return; } diff --git a/view/templates/auto_request.tpl b/view/templates/auto_request.tpl index 662ca2447e..61a772cba1 100644 --- a/view/templates/auto_request.tpl +++ b/view/templates/auto_request.tpl @@ -6,6 +6,7 @@

{{$header}}

+{{if $myaddr == ""}}

{{$page_desc}}