diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/dfrn_confirm.php | 13 | ||||
-rw-r--r-- | mod/dfrn_request.php | 30 | ||||
-rw-r--r-- | mod/item.php | 144 | ||||
-rw-r--r-- | mod/network.php | 25 | ||||
-rw-r--r-- | mod/notifications.php | 2 | ||||
-rw-r--r-- | mod/profile.php | 12 | ||||
-rw-r--r-- | mod/settings.php | 2 |
7 files changed, 75 insertions, 153 deletions
diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index ce6f4f95f..1b0985cef 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -71,12 +71,14 @@ function dfrn_confirm_post(&$a,$handsfree = null) { $dfrn_id = $handsfree['dfrn_id']; $intro_id = $handsfree['intro_id']; $duplex = $handsfree['duplex']; + $hidden = ((array_key_exists('hidden',$handsfree)) ? intval($handsfree['hidden']) : 0 ); } else { $dfrn_id = ((x($_POST,'dfrn_id')) ? notags(trim($_POST['dfrn_id'])) : ""); $intro_id = ((x($_POST,'intro_id')) ? intval($_POST['intro_id']) : 0 ); $duplex = ((x($_POST,'duplex')) ? intval($_POST['duplex']) : 0 ); $cid = ((x($_POST,'contact_id')) ? intval($_POST['contact_id']) : 0 ); + $hidden = ((x($_POST,'hidden')) ? intval($_POST['hidden']) : 0 ); } /** @@ -122,7 +124,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { $site_pubkey = $contact['site-pubkey']; $dfrn_confirm = $contact['confirm']; $aes_allow = $contact['aes_allow']; - + $network = ((strlen($contact['issued-id'])) ? NETWORK_DFRN : NETWORK_OSTATUS); if($contact['network']) @@ -316,7 +318,8 @@ function dfrn_confirm_post(&$a,$handsfree = null) { if(($relation == CONTACT_IS_SHARING) && ($duplex)) $duplex = 0; - $r = q("UPDATE `contact` SET `photo` = '%s', + $r = q("UPDATE `contact` SET + `photo` = '%s', `thumb` = '%s', `micro` = '%s', `rel` = %d, @@ -326,6 +329,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { `blocked` = 0, `pending` = 0, `duplex` = %d, + `hidden` = %d, `network` = 'dfrn' WHERE `id` = %d LIMIT 1 ", dbesc($photos[0]), @@ -336,6 +340,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { dbesc(datetime_convert()), dbesc(datetime_convert()), intval($duplex), + intval($hidden), intval($contact_id) ); } @@ -387,6 +392,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { `pending` = 0, `network` = '%s', `writable` = %d, + `hidden` = %d, `rel` = %d WHERE `id` = %d LIMIT 1 ", @@ -400,6 +406,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { dbesc($poll), dbesc($network), intval($writable), + intval($hidden), intval($new_relation), intval($contact_id) ); @@ -423,7 +430,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { $r = q("SELECT `hide-friends` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1", intval($uid) ); - if((count($r)) && ($r[0]['hide-friends'] == 0) && (is_array($contact)) && isset($new_relation) && ($new_relation == CONTACT_IS_FRIEND)) { + if((count($r)) && (! $hidden) && ($r[0]['hide-friends'] == 0) && (is_array($contact)) && isset($new_relation) && ($new_relation == CONTACT_IS_FRIEND)) { if($r[0]['network'] === NETWORK_DIASPORA) { require_once('include/diaspora.php'); diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index d7c918490..a96860403 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -568,24 +568,22 @@ function dfrn_request_content(&$a) { if(count($r)) { if($r[0]['page-flags'] != PAGE_NORMAL) $auto_confirm = true; - if(($r[0]['notify-flags'] & NOTIFY_INTRO) && (! $auto_confirm)) { - $email_tpl = get_intltext_template('request_notify_eml.tpl'); - $email = replace_macros($email_tpl, array( - '$requestor' => ((strlen(stripslashes($r[0]['name']))) ? stripslashes($r[0]['name']) : t('[Name Withheld]')), - '$url' => stripslashes($r[0]['url']), - '$myname' => $r[0]['username'], - '$siteurl' => $a->get_baseurl(), - '$sitename' => $a->config['sitename'] + + if(! $auto_confirm) { + require_once('include/enotify.php'); + notification(array( + 'type' => NOTIFY_INTRO, + 'notify_flags' => $r[0]['notify-flags'], + 'language' => $r[0]['language'], + 'to_name' => $r[0]['username'], + 'to_email' => $r[0]['email'], + 'link' => $a->get_baseurl() . '/notifications/intros', + 'source_name' => ((strlen(stripslashes($r[0]['name']))) ? stripslashes($r[0]['name']) : t('[Name Withheld]')), + 'source_link' => $r[0]['url'], + 'source_photo' => $r[0]['photo'] )); - $res = mail($r[0]['email'], - t("Introduction received at ") . $a->config['sitename'], - $email, - 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n" - . 'Content-type: text/plain; charset=UTF-8' . "\n" - . 'Content-transfer-encoding: 8bit' ); - - // This is a redundant notification - no point throwing errors if it fails. } + if($auto_confirm) { require_once('mod/dfrn_confirm.php'); $handsfree = array( diff --git a/mod/item.php b/mod/item.php index f72b17fc1..ece92f0f3 100644 --- a/mod/item.php +++ b/mod/item.php @@ -16,6 +16,7 @@ */ require_once('include/crypto.php'); +require_once('include/enotify.php'); function item_post(&$a) { @@ -679,68 +680,20 @@ function item_post(&$a) { intval($post_id) ); - // Send a notification email to the conversation owner, unless the owner is me and I wrote this item - if(($user['notify-flags'] & NOTIFY_COMMENT) && ($contact_record != $author)) { - push_lang($user['language']); - require_once('bbcode.php'); - $from = $author['name']; - - // name of the automated email sender - $msg['notificationfromname'] = stripslashes($datarray['author-name']);; - // noreply address to send from - $msg['notificationfromemail'] = t('noreply') . '@' . $a->get_hostname(); - - // text version - // process the message body to display properly in text mode - $msg['textversion'] - = html_entity_decode(strip_tags(bbcode(stripslashes($datarray['body']))), ENT_QUOTES, 'UTF-8'); - - // html version - // process the message body to display properly in text mode - $msg['htmlversion'] - = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"), "<br />\n",$datarray['body'])))); - - // load the template for private message notifications - $tpl = get_intltext_template('cmnt_received_html_body_eml.tpl'); - $email_html_body_tpl = replace_macros($tpl,array( - '$username' => $user['username'], - '$sitename' => $a->config['sitename'], // name of this site - '$siteurl' => $a->get_baseurl(), // descriptive url of this site - '$thumb' => $author['thumb'], // thumbnail url for sender icon - '$email' => $importer['email'], // email address to send to - '$url' => $author['url'], // full url for the site - '$from' => $from, // name of the person sending the message - '$body' => $msg['htmlversion'], // html version of the message - '$display' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id, + if($contact_record != $author) { + notification(array( + 'type' => NOTIFY_COMMENT, + 'notify_flags' => $user['notify-flags'], + 'language' => $user['language'], + 'to_name' => $user['username'], + 'to_email' => $user['email'], + 'item' => $datarray, + 'link' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id, + 'source_name' => $datarray['author-name'], + 'source_link' => $datarray['author-link'], + 'source_photo' => $datarray['author-avatar'] )); - // load the template for private message notifications - $tpl = get_intltext_template('cmnt_received_text_body_eml.tpl'); - $email_text_body_tpl = replace_macros($tpl,array( - '$username' => $user['username'], - '$sitename' => $a->config['sitename'], // name of this site - '$siteurl' => $a->get_baseurl(), // descriptive url of this site - '$thumb' => $author['thumb'], // thumbnail url for sender icon - '$email' => $importer['email'], // email address to send to - '$url' => $author['url'], // profile url for the author - '$from' => $from, // name of the person sending the message - '$body' => $msg['textversion'], // text version of the message - '$display' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id, - )); - - // use the EmailNotification library to send the message - require_once("include/EmailNotification.php"); - EmailNotification::sendTextHtmlEmail( - $msg['notificationfromname'], - t("Administrator@") . $a->get_hostname(), - t("noreply") . '@' . $a->get_hostname(), - $user['email'], - sprintf( t('%s commented on an item at %s'), $from , $a->config['sitename']), - $email_html_body_tpl, - $email_text_body_tpl - ); - - pop_lang(); } // We won't be able to sign Diaspora comments for authenticated visitors - we don't have their private key @@ -767,66 +720,19 @@ function item_post(&$a) { else { $parent = $post_id; - // let me know if somebody did a wall-to-wall post on my profile - - if(($user['notify-flags'] & NOTIFY_WALL) && ($contact_record != $author)) { - push_lang($user['language']); - require_once('bbcode.php'); - $from = $author['name']; - - // name of the automated email sender - $msg['notificationfromname'] = $from; - // noreply address to send from - $msg['notificationfromemail'] = t('noreply') . '@' . $a->get_hostname(); - - // text version - // process the message body to display properly in text mode - $msg['textversion'] - = html_entity_decode(strip_tags(bbcode(stripslashes($datarray['body']))), ENT_QUOTES, 'UTF-8'); - - // html version - // process the message body to display properly in text mode - $msg['htmlversion'] - = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"), "<br />\n",$datarray['body'])))); - - // load the template for private message notifications - $tpl = load_view_file('view/wall_received_html_body_eml.tpl'); - $email_html_body_tpl = replace_macros($tpl,array( - '$username' => $user['username'], - '$sitename' => $a->config['sitename'], // name of this site - '$siteurl' => $a->get_baseurl(), // descriptive url of this site - '$thumb' => $author['thumb'], // thumbnail url for sender icon - '$url' => $author['url'], // full url for the site - '$from' => $from, // name of the person sending the message - '$body' => $msg['htmlversion'], // html version of the message - '$display' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id, + if($contact_record != $author) { + notification(array( + 'type' => NOTIFY_WALL, + 'notify_flags' => $user['notify-flags'], + 'language' => $user['language'], + 'to_name' => $user['username'], + 'to_email' => $user['email'], + 'item' => $datarray, + 'link' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id, + 'source_name' => $datarray['author-name'], + 'source_link' => $datarray['author-link'], + 'source_photo' => $datarray['author-avatar'] )); - - // load the template for private message notifications - $tpl = load_view_file('view/wall_received_text_body_eml.tpl'); - $email_text_body_tpl = replace_macros($tpl,array( - '$username' => $user['username'], - '$sitename' => $a->config['sitename'], // name of this site - '$siteurl' => $a->get_baseurl(), // descriptive url of this site - '$thumb' => $author['thumb'], // thumbnail url for sender icon - '$url' => $author['url'], // full url for the site - '$from' => $from, // name of the person sending the message - '$body' => $msg['textversion'], // text version of the message - '$display' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id, - )); - - // use the EmailNotification library to send the message - require_once("include/EmailNotification.php"); - EmailNotification::sendTextHtmlEmail( - $msg['notificationfromname'], - t("Administrator@") . $a->get_hostname(), - t("noreply") . '@' . $a->get_hostname(), - $user['email'], - sprintf( t('%s posted to your profile wall at %s') , $from , $a->config['sitename']), - $email_html_body_tpl, - $email_text_body_tpl - ); - pop_lang(); } } diff --git a/mod/network.php b/mod/network.php index 57e120e86..55f5a8c95 100644 --- a/mod/network.php +++ b/mod/network.php @@ -271,12 +271,17 @@ function network_content(&$a, $update = 0) { // that belongs to you, hence you can see all of it. We will filter by group if // desired. - $star_sql = (($star) ? " AND `starred` = 1 " : ''); - if($bmark) - $star_sql .= " AND `bookmark` = 1 "; + $sql_options = (($star) ? " and starred = 1 " : ''); + $sql_options .= (($bmark) ? " and bookmark = 1 " : ''); - $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` $star_sql ) "; + + $sql_new = ''; + $sql_items = ''; + $sql_update = ''; + + + $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` $sql_options ) "; if($group) { $r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", @@ -300,21 +305,19 @@ function network_content(&$a, $update = 0) { info( t('Group is empty')); } - -// $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` $star_sql AND ( `contact-id` IN ( $contact_str ) OR `allow_gid` REGEXP '<" . intval($group) . ">' )) "; - $sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $star_sql AND ( `contact-id` IN ( $contact_str ) OR `allow_gid` REGEXP '<" . intval($group) . ">' )) "; + $sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND ( `contact-id` IN ( $contact_str ) OR `allow_gid` REGEXP '<" . intval($group) . ">' )) "; $o = '<h2>' . t('Group: ') . $r[0]['name'] . '</h2>' . $o; } elseif($cid) { - $r = q("SELECT `id`,`name`,`network`,`writable` FROM `contact` WHERE `id` = %d + $r = q("SELECT `id`,`name`,`network`,`writable`,`nurl` FROM `contact` WHERE `id` = %d AND `blocked` = 0 AND `pending` = 0 LIMIT 1", intval($cid) ); if(count($r)) { - $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` $star_sql AND `contact-id` IN ( " . intval($cid) . " )) "; + $sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND `contact-id` = " . intval($cid) . " ) "; $o = '<h2>' . t('Contact: ') . $r[0]['name'] . '</h2>' . $o; - if($r[0]['network'] !== NETWORK_MAIL && $r[0]['network'] !== NETWORK_DFRN && $r[0]['network'] !== NETWORK_FACEBOOK && $r[0]['network'] !== NETWORK_DIASPORA && $r[0]['writable'] && (! get_pconfig(local_user(),'system','nowarn_insecure'))) { + if($r[0]['network'] === NETWORK_OSTATUS && $r[0]['writable'] && (! get_pconfig(local_user(),'system','nowarn_insecure'))) { notice( t('Private messages to this person are at risk of public disclosure.') . EOL); } @@ -432,7 +435,7 @@ function network_content(&$a, $update = 0) { $r = q("SELECT distinct(`parent`) AS `item_id`, `contact`.`uid` AS `contact_uid` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 - and `item`.`parent` in ( select parent from item where unseen = 1 ) + and `item`.`unseen` = 1 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 $sql_extra ", intval(local_user()) diff --git a/mod/notifications.php b/mod/notifications.php index 5733e6e57..910b84e32 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -141,6 +141,7 @@ function notifications_content(&$a) { '$photo' => ((x($rr,'fphoto')) ? $rr['fphoto'] : "images/default-profile.jpg"), '$fullname' => $rr['fname'], '$url' => $rr['furl'], + '$hidden' => array('hidden', t('Hide this contact from others'), ($rr['hidden'] == 1), ''), '$knowyou' => $knowyou, '$approve' => t('Approve'), '$note' => $rr['note'], @@ -185,6 +186,7 @@ function notifications_content(&$a) { '$contact_id' => $rr['contact-id'], '$photo' => ((x($rr,'photo')) ? $rr['photo'] : "images/default-profile.jpg"), '$fullname' => $rr['name'], + '$hidden' => array('hidden', t('Hide this contact from others'), ($rr['hidden'] == 1), ''), '$url' => $rr['url'], '$knowyou' => $knowyou, '$approve' => t('Approve'), diff --git a/mod/profile.php b/mod/profile.php index d2f9d7e29..946499895 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -7,9 +7,15 @@ function profile_init(&$a) { if($a->argc > 1) $which = $a->argv[1]; else { - notice( t('No profile') . EOL ); - $a->error = 404; - return; + $r = q("select nickname from user where blocked = 0 and account_expired = 0 and verified = 1 order by rand() limit 1"); + if(count($r)) { + $which = $r[0]['nickname']; + } + else { + notice( t('Requested profile is not available.') . EOL ); + $a->error = 404; + return; + } } $profile = 0; diff --git a/mod/settings.php b/mod/settings.php index ad22ba1a6..35902f831 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -574,7 +574,7 @@ function settings_content(&$a) { '$mail_disabled' => (($mail_disabled) ? t('Email access is disabled on this site.') : ''), '$mail_server' => array('mail_server', t('IMAP server name:'), $mail_server, ''), '$mail_port' => array('mail_port', t('IMAP port:'), $mail_port, ''), - '$mail_ssl' => array('mail_ssl', t('Security:'), strtoupper($mail_ssl), '', array( ''=>t('None'), 'TSL'=>'TSL', 'SSL'=>'SSL')), + '$mail_ssl' => array('mail_ssl', t('Security:'), strtoupper($mail_ssl), '', array( ''=>t('None'), 'TLS'=>'TLS', 'SSL'=>'SSL')), '$mail_user' => array('mail_user', t('Email login name:'), $mail_user, ''), '$mail_pass' => array('mail_pass', t('Email password:'), '', ''), '$mail_replyto' => array('mail_replyto', t('Reply-to address:'), '', 'Optional'), |