diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/contacts.php | 20 | ||||
-rw-r--r-- | mod/dfrn_confirm.php | 4 | ||||
-rw-r--r-- | mod/dfrn_notify.php | 14 | ||||
-rw-r--r-- | mod/dfrn_poll.php | 117 | ||||
-rw-r--r-- | mod/dfrn_request.php | 18 | ||||
-rw-r--r-- | mod/directory.php | 6 | ||||
-rw-r--r-- | mod/display.php | 5 | ||||
-rw-r--r-- | mod/editpost.php | 91 | ||||
-rw-r--r-- | mod/follow.php | 14 | ||||
-rw-r--r-- | mod/friendika.php | 47 | ||||
-rw-r--r-- | mod/home.php | 2 | ||||
-rw-r--r-- | mod/install.php | 62 | ||||
-rw-r--r-- | mod/invite.php | 10 | ||||
-rw-r--r-- | mod/item.php | 130 | ||||
-rw-r--r-- | mod/like.php | 12 | ||||
-rw-r--r-- | mod/lostpass.php | 2 | ||||
-rw-r--r-- | mod/manage.php | 2 | ||||
-rw-r--r-- | mod/match.php | 57 | ||||
-rw-r--r-- | mod/message.php | 9 | ||||
-rw-r--r-- | mod/network.php | 162 | ||||
-rw-r--r-- | mod/notifications.php | 13 | ||||
-rw-r--r-- | mod/oexchange.php | 53 | ||||
-rw-r--r-- | mod/openid.php | 2 | ||||
-rw-r--r-- | mod/photos.php | 3 | ||||
-rw-r--r-- | mod/profile.php | 94 | ||||
-rw-r--r-- | mod/profile_photo.php | 18 | ||||
-rw-r--r-- | mod/redir.php | 5 | ||||
-rw-r--r-- | mod/register.php | 22 | ||||
-rw-r--r-- | mod/regmod.php | 4 | ||||
-rw-r--r-- | mod/search.php | 1 | ||||
-rw-r--r-- | mod/settings.php | 11 | ||||
-rw-r--r-- | mod/uexport.php | 72 | ||||
-rw-r--r-- | mod/viewcontacts.php | 3 | ||||
-rw-r--r-- | mod/wall_upload.php | 2 |
34 files changed, 911 insertions, 176 deletions
diff --git a/mod/contacts.php b/mod/contacts.php index c2d28dc1f..aee6548fe 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -9,7 +9,10 @@ function contacts_init(&$a) { $a->page['aside'] .= group_side(); if($a->config['register_policy'] != REGISTER_CLOSED) - $a->page['aside'] .= '<div class="side-invite-link-wrapper" id="side-invite-link-wrapper" ><a href="invite" class="side-invite-link" id="side-invite-link">' . t("Invite Friends") . '</a></div>'; + $a->page['aside'] .= '<div class="side-link" id="side-invite-link" ><a href="invite" >' . t("Invite Friends") . '</a></div>'; + + if(strlen(get_config('system','directory_submit_url'))) + $a->page['aside'] .= '<div class="side-link" id="side-match-link"><a href="match" >' . t('Find People With Shared Interests') . '</a></div>'; $tpl = load_view_file('view/follow.tpl'); $a->page['aside'] .= replace_macros($tpl,array( @@ -18,6 +21,8 @@ function contacts_init(&$a) { '$follow' => t('Follow') )); + + } function contacts_post(&$a) { @@ -137,7 +142,8 @@ function contacts_content(&$a) { intval(local_user()) ); if($r) { - notice( t('Contact has been ') . (($blocked) ? t('blocked') : t('unblocked')) . EOL ); + //notice( t('Contact has been ') . (($blocked) ? t('blocked') : t('unblocked')) . EOL ); + notice( (($blocked) ? t('Contact has been blocked') : t('Contact has been unblocked')) . EOL ); } goaway($a->get_baseurl() . '/contacts/' . $contact_id); return; // NOTREACHED @@ -151,7 +157,7 @@ function contacts_content(&$a) { intval(local_user()) ); if($r) { - notice( t('Contact has been ') . (($readonly) ? t('ignored') : t('unignored')) . EOL ); + notice( (($readonly) ? t('Contact has been ignored') : t('Contact has been unignored')) . EOL ); } goaway($a->get_baseurl() . '/contacts/' . $contact_id); return; // NOTREACHED @@ -243,6 +249,9 @@ function contacts_content(&$a) { $sparkle = ''; } + $insecure = '<div id="profile-edit-insecure"><p><img src="images/unlock_icon.gif" alt="' . t('Privacy Unavailable') . '" /> ' + . t('Private communications are not available for this contact.') . '</p></div>'; + $last_update = (($r[0]['last-update'] == '0000-00-00 00:00:00') ? t('Never') : datetime_convert('UTC',date_default_timezone_get(),$r[0]['last-update'],'D, j M Y, g:i A')); @@ -265,7 +274,7 @@ function contacts_content(&$a) { '$contact_id' => $r[0]['id'], '$block_text' => (($r[0]['blocked']) ? t('Unblock this contact') : t('Block this contact') ), '$ignore_text' => (($r[0]['readonly']) ? t('Unignore this contact') : t('Ignore this contact') ), - '$insecure' => (($r[0]['network'] === 'stat') ? load_view_file('view/insecure_net.tpl') : ''), + '$insecure' => (($r[0]['network'] !== 'dfrn') ? $insecure : ''), '$info' => $r[0]['info'], '$blocked' => (($r[0]['blocked']) ? '<div id="block-message">' . t('Currently blocked') . '</div>' : ''), '$ignored' => (($r[0]['readonly']) ? '<div id="ignore-message">' . t('Currently ignored') . '</div>' : ''), @@ -364,13 +373,14 @@ function contacts_content(&$a) { $o .= replace_macros($tpl, array( - '$img_hover' => t('Visit ') . $rr['name'] . t('\'s profile'), + '$img_hover' => t('Visit $username\'s profile'), '$edit_hover' => t('Edit contact'), '$id' => $rr['id'], '$alt_text' => $alt_text, '$dir_icon' => $dir_icon, '$thumb' => $rr['thumb'], '$name' => substr($rr['name'],0,20), + '$username' => $rr['name'], '$sparkle' => $sparkle, '$url' => $url )); diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index 1b42c13b8..1bf1ba954 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -491,7 +491,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { dbesc($node)); if(! count($r)) { - $message = t('No user record found for ') . '\'' . $node . '\''; + $message = sprintf(t('No user record found for \'%s\' '), $node); xml_status(3,$message); // failure // NOTREACHED } @@ -645,7 +645,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { '$uid' => $newuid ) ); - $res = mail($r[0]['email'], t("Connection accepted at ") . $a->config['sitename'], + $res = mail($r[0]['email'], sprintf( t("Connection accepted at %s") , $a->config['sitename']), $email_tpl, 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] ); if(!$res) { // pointless throwing an error here and confusing the person at the other end of the wire. diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index f447b5453..cd67df1d7 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -262,10 +262,13 @@ function dfrn_notify_post(&$a) { $when = datetime_convert('UTC','UTC','now','Y-m-d H:i:s'); } if($deleted) { - $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", + + $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d AND `contact-id` = %d LIMIT 1", dbesc($uri), - intval($importer['importer_uid']) + intval($importer['importer_uid']), + intval($importer['id']) ); + if(count($r)) { $item = $r[0]; @@ -385,7 +388,7 @@ function dfrn_notify_post(&$a) { '$body' => html_entity_decode(strip_tags(bbcode(stripslashes($datarray['body']))), ENT_QUOTES, 'UTF-8') )); - $res = mail($importer['email'], $from . t(' commented on an item at ') . $a->config['sitename'], + $res = mail($importer['email'], sprintf(t('%s commented on an item at %s'), $from , $a->config['sitename']), $email_tpl, "From: " . t('Administrator') . '@' . $a->get_hostname() ); } } @@ -471,9 +474,8 @@ function dfrn_notify_post(&$a) { '$body' => html_entity_decode(strip_tags(bbcode(stripslashes($datarray['body']))), ENT_QUOTES, 'UTF-8') )); - $res = mail($importer['email'], $from . t(" commented on an item at ") - . $a->config['sitename'], - $email_tpl,t("From: Administrator@") . $a->get_hostname() ); + $res = mail($importer['email'], sprintf( t("%s commented on an item at %s") , $from ,$a->config['sitename']), + $email_tpl, "From: ".t("Administrator") . "@". $a->get_hostname() ); break; } } diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index 334e10307..5149dc3b2 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -75,7 +75,7 @@ function dfrn_poll_init(&$a) { $_SESSION['authenticated'] = 1; $_SESSION['visitor_id'] = $r[0]['id']; $_SESSION['visitor_home'] = $r[0]['url']; - notice( $r[0]['username'] . t(' welcomes ') . $r[0]['name'] . EOL); + notice( sprintf(t('%s welcomes %s'), $r[0]['username'] , $r[0]['name']) . EOL); // Visitors get 1 day session. $session_id = session_id(); $expire = time() + 86400; @@ -92,7 +92,7 @@ function dfrn_poll_init(&$a) { } - if($type === 'profile-check') { + if($type === 'profile-check' && $dfrn_version < 2.2 ) { if((strlen($challenge)) && (strlen($sec))) { @@ -182,8 +182,69 @@ function dfrn_poll_post(&$a) { $dfrn_id = ((x($_POST,'dfrn_id')) ? $_POST['dfrn_id'] : ''); $challenge = ((x($_POST,'challenge')) ? $_POST['challenge'] : ''); $url = ((x($_POST,'url')) ? $_POST['url'] : ''); + $sec = ((x($_POST,'sec')) ? $_POST['sec'] : ''); + $ptype = ((x($_POST,'type')) ? $_POST['type'] : ''); $dfrn_version = ((x($_POST,'dfrn_version')) ? (float) $_POST['dfrn_version'] : 2.0); + if($ptype === 'profile-check') { + + if((strlen($challenge)) && (strlen($sec))) { + + logger('dfrn_poll: POST: profile-check'); + + q("DELETE FROM `profile_check` WHERE `expire` < " . intval(time())); + $r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1", + dbesc($sec) + ); + if(! count($r)) { + xml_status(3, 'No ticket'); + // NOTREACHED + } + $orig_id = $r[0]['dfrn_id']; + if(strpos($orig_id, ':')) + $orig_id = substr($orig_id,2); + + $c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1", + intval($r[0]['cid']) + ); + if(! count($c)) { + xml_status(3, 'No profile'); + } + $contact = $c[0]; + + $sent_dfrn_id = hex2bin($dfrn_id); + $challenge = hex2bin($challenge); + + $final_dfrn_id = ''; + + if(($contact['duplex']) && strlen($contact['prvkey'])) { + openssl_private_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['prvkey']); + openssl_private_decrypt($challenge,$decoded_challenge,$contact['prvkey']); + } + else { + openssl_public_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['pubkey']); + openssl_public_decrypt($challenge,$decoded_challenge,$contact['pubkey']); + } + + $final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.')); + + if(strpos($final_dfrn_id,':') == 1) + $final_dfrn_id = substr($final_dfrn_id,2); + + if($final_dfrn_id != $orig_id) { + logger('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, LOGGER_DEBUG); + // did not decode properly - cannot trust this site + xml_status(3, 'Bad decryption'); + } + + header("Content-type: text/xml"); + echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?><dfrn_poll><status>0</status><challenge>$decoded_challenge</challenge><sec>$sec</sec></dfrn_poll>"; + killme(); + // NOTREACHED + } + + } + $direction = (-1); if(strpos($dfrn_id,':') == 1) { $direction = intval(substr($dfrn_id,0,1)); @@ -363,15 +424,45 @@ function dfrn_poll_content(&$a) { } if(($type === 'profile') && (strlen($sec))) { + // URL reply - $s = fetch_url($r[0]['poll'] - . '?dfrn_id=' . $encrypted_id - . '&type=profile-check' - . '&dfrn_version=' . DFRN_PROTOCOL_VERSION - . '&challenge=' . $challenge - . '&sec=' . $sec - ); + if($dfrn_version < 2.2) { + $s = fetch_url($r[0]['poll'] + . '?dfrn_id=' . $encrypted_id + . '&type=profile-check' + . '&dfrn_version=' . DFRN_PROTOCOL_VERSION + . '&challenge=' . $challenge + . '&sec=' . $sec + ); + } + else { + $s = post_url($r[0]['poll'], array( + 'dfrn_id' => $encrypted_id, + 'type' => 'profile-check', + 'dfrn_version' => DFRN_PROTOCOL_VERSION, + 'challenge' => $challenge, + 'sec' => $sec + )); + } + + $profile = $r[0]['nickname']; + + switch($destination_url) { + case 'profile': + $dest = $a->get_baseurl() . '/profile/' . $profile . '?tab=profile'; + break; + case 'photos': + $dest = $a->get_baseurl() . '/photos/' . $profile; + break; + case 'status': + case '': + $dest = $a->get_baseurl() . '/profile/' . $profile; + break; + default: + $dest = $destination_url; + break; + } logger("dfrn_poll: sec profile: " . $s, LOGGER_DATA); @@ -389,7 +480,7 @@ function dfrn_poll_content(&$a) { $_SESSION['authenticated'] = 1; $_SESSION['visitor_id'] = $r[0]['id']; $_SESSION['visitor_home'] = $r[0]['url']; - notice( $r[0]['username'] . t(' welcomes ') . $r[0]['name'] . EOL); + notice( sprintf(t('%s welcomes %s'), $r[0]['username'] , $r[0]['name']) . EOL); // Visitors get 1 day session. $session_id = session_id(); $expire = time() + 86400; @@ -398,10 +489,10 @@ function dfrn_poll_content(&$a) { dbesc($session_id) ); } - $profile = $r[0]['nickname']; - goaway((strlen($destination_url)) ? $destination_url : $a->get_baseurl() . '/profile/' . $profile); + + goaway($dest); } - goaway($a->get_baseurl()); + goaway($dest); // NOTREACHED } diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 24c466bba..3cd8473cf 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -123,9 +123,9 @@ function dfrn_request_post(&$a) { notice( t('Warning: profile location has no profile photo.') . EOL ); $invalid = validate_dfrn($parms); if($invalid) { - notice( $invalid . t(' required parameter') - . (($invalid == 1) ? t(" was ") : t("s were ") ) - . t("not found at the given location.") . EOL ) ; + notice( sprintf( tt("%d required parameter was not found at the given location", + "%d required parameters were not found at the given location", + $invalid), $invalid) . EOL ); return; } } @@ -238,7 +238,7 @@ function dfrn_request_post(&$a) { intval($uid) ); if(count($r) > $maxreq) { - notice( $a->profile['name'] . t(' has received too many connection requests today.') . EOL); + notice( sprintf( t('%s has received too many connection requests today.'), $a->profile['name']) . EOL); notice( t('Spam protection measures have been invoked.') . EOL); notice( t('Friends are advised to please try again in 24 hours.') . EOL); return; @@ -306,7 +306,7 @@ function dfrn_request_post(&$a) { return; } elseif($ret[0]['rel'] == REL_BUD) { - notice( t('Apparently you are already friends with .') . $a->profile['name'] . EOL); + notice( sprintf( t('Apparently you are already friends with %s.'), $a->profile['name']) . EOL); return; } else { @@ -354,9 +354,9 @@ function dfrn_request_post(&$a) { notice( t('Warning: profile location has no profile photo.') . EOL ); $invalid = validate_dfrn($parms); if($invalid) { - notice( $invalid . t(' required parameter') - . (($invalid == 1) ? t(" was ") : t("s were ") ) - . t("not found at the given location.") . EOL ) ; + notice( sprintf( tt("%d required parameter was not found at the given location", + "%d required parameters were not found at the given location", + $invalid), $invalid) . EOL ); return; } @@ -540,7 +540,7 @@ function dfrn_request_content(&$a) { '$sitename' => $a->config['sitename'] )); $res = mail($r[0]['email'], - t("Introduction received at ") . $a->config['sitename'], + t("Introduction received at ") . $a->config['sitename'], $email, 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] ); // This is a redundant notification - no point throwing errors if it fails. diff --git a/mod/directory.php b/mod/directory.php index 825e2a375..72c30fb31 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -86,10 +86,10 @@ function directory_content(&$a) { } if(strlen($rr['dob'])) { if(($years = age($rr['dob'],$rr['timezone'],'')) != 0) - $details .= "<br />Age: $years" ; + $details .= '<br />' . t('Age: ') . $years ; } if(strlen($rr['gender'])) - $details .= '<br />Gender: ' . $rr['gender']; + $details .= '<br />' . t('Gender: ') . $rr['gender']; $entry = replace_macros($tpl,array( '$id' => $rr['id'], @@ -115,7 +115,7 @@ function directory_content(&$a) { } else - notice("No entries (some entries may be hidden)."); + notice( t("No entries \x28some entries may be hidden\x29.") . EOL); return $o; }
\ No newline at end of file diff --git a/mod/display.php b/mod/display.php index 059952adc..f74137e0e 100644 --- a/mod/display.php +++ b/mod/display.php @@ -217,6 +217,9 @@ function display_content(&$a) { $profile_name = (((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']); $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $item['thumb']); + $edpost = ''; + if((local_user()) && ($item['uid'] == local_user()) && ($item['id'] == $item['parent']) && (intval($item['wall']) == 1)) + $edpost = '<a class="editpost" href="' . $a->get_baseurl() . '/editpost/' . $item['id'] . '" title="' . t('Edit') . '"><img src="images/pencil.gif" /></a>'; // Can we use our special contact URL for this author? if(strlen($item['author-link'])) { @@ -261,6 +264,7 @@ function display_content(&$a) { '$to' => t('to'), '$wall' => t('Wall-to-Wall'), '$vwall' => t('via Wall-To-Wall:'), + '$item_photo_menu' => item_photo_menu($item), '$profile_url' => $profile_link, '$name' => $profile_name, '$sparkle' => $sparkle, @@ -276,6 +280,7 @@ function display_content(&$a) { '$owner_photo' => $owner_photo, '$owner_name' => $owner_name, '$plink' => get_plink($item), + '$edpost' => $edpost, '$drop' => $drop, '$vote' => $likebuttons, '$like' => $like, diff --git a/mod/editpost.php b/mod/editpost.php new file mode 100644 index 000000000..862ba937f --- /dev/null +++ b/mod/editpost.php @@ -0,0 +1,91 @@ +<?php + +require_once('acl_selectors.php'); + +function editpost_content(&$a) { + + $o = ''; + + if(! local_user()) { + notice( t('Permission denied.') . EOL); + return; + } + + $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); + + if(! $post_id) { + notice( t('Item not found') . EOL); + return; + } + + $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($post_id), + intval(local_user()) + ); + + if(! count($r)) { + notice( t('Item not found') . EOL); + return; + } + + + $o .= '<h2>' . t('Edit post') . '</h2>'; + + $tpl = load_view_file('view/jot-header.tpl'); + + $a->page['htmlhead'] .= replace_macros($tpl, array( + '$baseurl' => $a->get_baseurl(), + '$geotag' => $geotag, + '$nickname' => $a->user['nickname'] + )); + + + $tpl = load_view_file("view/jot.tpl"); + + if(($group) || (is_array($a->user) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid']))))) + $lockstate = 'lock'; + else + $lockstate = 'unlock'; + + $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false); + + $jotplugins = ''; + $jotnets = ''; + call_hooks('jot_tool', $jotplugins); + call_hooks('jot_networks', $jotnets); + + $tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins)); + + $o .= replace_macros($tpl,array( + '$return_path' => $_SESSION['return_url'], + '$action' => 'item', + '$share' => t('Edit'), + '$upload' => t('Upload photo'), + '$weblink' => t('Insert web link'), + '$youtube' => t('Insert YouTube video'), + '$video' => t('Insert Vorbis [.ogg] video'), + '$audio' => t('Insert Vorbis [.ogg] audio'), + '$setloc' => t('Set your location'), + '$noloc' => t('Clear browser location'), + '$wait' => t('Please wait'), + '$permset' => t('Permission settings'), + '$content' => $r[0]['body'], + '$post_id' => $post_id, + '$baseurl' => $a->get_baseurl(), + '$defloc' => $a->user['default-location'], + '$visitor' => 'none', + '$emailcc' => t('CC: email addresses'), + '$jotnets' => $jotnets, + '$emtitle' => t('Example: bob@example.com, mary@example.com'), + '$lockstate' => $lockstate, + '$acl' => '', // populate_acl((($group) ? $group_acl : $a->user), $celeb), + '$bang' => (($group) ? '!' : ''), + '$profile_uid' => $_SESSION['uid'] + )); + + + return $o; + +} + + diff --git a/mod/follow.php b/mod/follow.php index 689ae8232..4ce3ccb82 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -11,7 +11,7 @@ function follow_post(&$a) { } $url = $orig_url = notags(trim($_POST['url'])); - + $diaspora = false; $email_conversant = false; if($url) { @@ -28,6 +28,9 @@ function follow_post(&$a) { $hcard = unamp($link['@attributes']['href']); if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') $profile = unamp($link['@attributes']['href']); + if($link['@attributes']['rel'] === 'http://joindiaspora.com/seed_location') + $diaspora = true; + } @@ -90,9 +93,12 @@ function follow_post(&$a) { } } - if(! $profile) - $profile = $url; - + if(! $profile) { + if($diaspora) + $profile = $hcard; + else + $profile = $url; + } if(! x($vcard,'fn')) if(x($vcard,'nick')) diff --git a/mod/friendika.php b/mod/friendika.php new file mode 100644 index 000000000..4a8240a11 --- /dev/null +++ b/mod/friendika.php @@ -0,0 +1,47 @@ +<?php + +function friendika_content(&$a) { + + $o = ''; + $o .= '<h3>Friendika</h3>'; + + + $o .= '<p></p><p>'; + + $o .= 'View <a href="LICENSE">License</a>' . '<br /><br />'; + $o .= t('This is Friendika version') . ' ' . FRIENDIKA_VERSION . ' '; + $o .= t('running at web location') . ' ' . $a->get_baseurl() . '</p><p>'; + + $o .= t('Shared content within the Friendika network is provided under the <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 license</a>') . '</p><p>'; + + $o .= t('Please visit <a href="http://project.friendika.com">Project.Friendika.com</a> to learn more about the Friendika project.') . '</p><p>'; + + $o .= t('Bug reports and issues: please visit') . ' ' . '<a href="http://bugs.friendika.com">Bugs.Friendika.com</a></p><p>'; + $o .= t('Suggestions, praise, donations, etc. - please email "Info" at Friendika - dot com') . '</p>'; + + $o .= '<p></p>'; + + if(count($a->plugins)) { + $o .= '<p>' . t('Installed plugins/addons/apps') . '</p>'; + $o .= '<ul>'; + foreach($a->plugins as $p) + if(strlen($p)) + $o .= '<li>' . $p . '</li>'; + $o .= '</ul>'; + } + else + $o .= '<p>' . t('No installed plugins/addons/apps'); + + return $o; + + + + + + + + + + + +}
\ No newline at end of file diff --git a/mod/home.php b/mod/home.php index 20d38cfca..225bd294d 100644 --- a/mod/home.php +++ b/mod/home.php @@ -20,7 +20,7 @@ function home_content(&$a) { if(x($_SESSION,'theme')) unset($_SESSION['theme']); - $o .= '<h1>' . ((x($a->config,'sitename')) ? t("Welcome to ").$a->config['sitename'] : "" ) . '</h1>'; + $o .= '<h1>' . ((x($a->config,'sitename')) ? sprintf( t("Welcome to %s") ,$a->config['sitename']) : "" ) . '</h1>'; if(file_exists('home.html')) $o .= file_get_contents('home.html'); diff --git a/mod/install.php b/mod/install.php index dc91f848e..5c508e4f2 100644 --- a/mod/install.php +++ b/mod/install.php @@ -14,17 +14,20 @@ function install_post(&$a) { $phpath = notags(trim($_POST['phpath'])); require_once("dba.php"); - + unset($db); $db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true); if(mysqli_connect_errno()) { + unset($db); $db = new dba($dbhost, $dbuser, $dbpass, '', true); if(! mysqli_connect_errno()) { $r = q("CREATE DATABASE '%s'", dbesc($dbdata) ); - if($r) + if($r) { + unset($db); $db = new dba($dbhost, $dbuser, $dbpass, $dbdata, true); + } } if(mysqli_connect_errno()) { notice( t('Could not create/connect to database.') . EOL); @@ -50,36 +53,47 @@ function install_post(&$a) { } $errors = load_database($db); - if(! $errors) { - // Our sessions normally are stored in the database. But as we have only managed - // to get it bootstrapped milliseconds ago, we have to apply a bit of trickery so - // that you'll see the following important notice (which is stored in the session). - - session_write_close(); - - require_once('session.php'); - session_start(); - session_regenerate_id(); - $_SESSION['sysmsg'] = ''; + if($errors) + $a->data['db_failed'] = true; + else + $a->data['db_installed'] = true; - notice( t('Database import succeeded.') . EOL - . t('IMPORTANT: You will need to [manually] setup a scheduled task for the poller.') . EOL - . t('Please see the file "INSTALL.txt".') . EOL ); - goaway($a->get_baseurl() . '/register' ); - } - else { - $db = null; // start fresh - notice( t('Database import failed.') . EOL - . t('You may need to import the file "database.sql" manually using phpmyadmin or mysql.') . EOL - . t('Please see the file "INSTALL.txt".') . EOL ); - } + return; } function install_content(&$a) { + global $db; $o = ''; + + if(x($a->data,'db_installed')) { + $o .= '<h2>' . t('Proceed with Installation') . '</h2>'; + $o .= '<p style="font-size: 130%;">'; + $o .= t('Your Friendika site database has been installed.') . EOL; + $o .= t('IMPORTANT: You will need to [manually] setup a scheduled task for the poller.') . EOL ; + $o .= t('Please see the file "INSTALL.txt".') . EOL ; + $o .= '<br />'; + $o .= '<a href="' . $a->get_baseurl() . '/register' . '">' . t('Proceed to registration') . '</a>' ; + $o .= '</p>'; + return $o; + } + + if(x($a->data,'db_failed')) { + $o .= t('Database import failed.') . EOL; + $o .= t('You may need to import the file "database.sql" manually using phpmyadmin or mysql.') . EOL; + $o .= t('Please see the file "INSTALL.txt".') . EOL ; + return $o; + } + + if($db && $db->connected) { + $r = q("SELECT COUNT(*) as `total` FROM `user`"); + if($r && count($r) && $r[0]['total']) { + notice( t('Permission denied.') . EOL); + return ''; + } + } notice( t('Welcome to Friendika.') . EOL); diff --git a/mod/invite.php b/mod/invite.php index f67432746..84fa978ad 100644 --- a/mod/invite.php +++ b/mod/invite.php @@ -25,21 +25,21 @@ function invite_post(&$a) { $recip = trim($recip); if(! valid_email($recip)) { - notice( $recip . t(' : ') . t('Not a valid email address.') . EOL); + notice( sprintf( t('%s : Not a valid email address.'), $recip) . EOL); continue; } - $res = mail($recip, t('Please join my network on ') . $a->config['sitename'], + $res = mail($recip, sprintf(t('Please join my network on %s'), $a->config['sitename']), $message, "From: " . $a->user['email']); if($res) { $total ++; } else { - notice( $recip . t(' : ') . t('Message delivery failed.') . EOL); + notice( sprintf( t('%s : Message delivery failed.'), $recip) . EOL); } } - notice( $total . t(' messages sent.') . EOL); + notice( sprintf( tt("%d message sent.", "%d messages sent.", $total) , $total) . EOL); return; } @@ -57,7 +57,7 @@ function invite_content(&$a) { '$invite' => t('Send invitations'), '$addr_text' => t('Enter email addresses, one per line:'), '$msg_text' => t('Your message:'), - '$default_message' => t('Please join my social network on ') . $a->config['sitename'] . "\r\n" . "\r\n" + '$default_message' => sprintf(t('Please join my social network on %s'), $a->config['sitename']) . "\r\n" . "\r\n" . t('To accept this invitation, please visit:') . "\r\n" . "\r\n" . $a->get_baseurl() . "\r\n" . "\r\n" . t('Once you have registered, please connect with me via my profile page at:') . "\r\n" . "\r\n" . $a->get_baseurl() . '/profile/' . $a->user['nickname'] , diff --git a/mod/item.php b/mod/item.php index 6e6e822d0..5cefb3be3 100644 --- a/mod/item.php +++ b/mod/item.php @@ -51,7 +51,7 @@ function item_post(&$a) { } $profile_uid = ((x($_POST,'profile_uid')) ? intval($_POST['profile_uid']) : 0); - + $post_id = ((x($_POST['post_id'])) ? intval($_POST['post_id']) : 0); if(! can_write_wall($a,$profile_uid)) { notice( t('Permission denied.') . EOL) ; @@ -60,6 +60,21 @@ function item_post(&$a) { killme(); } + + // is this an edited post? + + $orig_post = null; + + if($post_id) { + $i = q("SELECT * FROM `item` WHERE `uid` = %d AND `id` = %d LIMIT 1", + intval($profile_uid), + intval($post_id) + ); + if(! count($i)) + killme(); + $orig_post = $i[0]; + } + $user = null; $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", @@ -68,37 +83,51 @@ function item_post(&$a) { if(count($r)) $user = $r[0]; - - $str_group_allow = perms2str($_POST['group_allow']); - $str_contact_allow = perms2str($_POST['contact_allow']); - $str_group_deny = perms2str($_POST['group_deny']); - $str_contact_deny = perms2str($_POST['contact_deny']); - - $private = ((strlen($str_group_allow) || strlen($str_contact_allow) || strlen($str_group_deny) || strlen($str_contact_deny)) ? 1 : 0); - - if(($parent_item) && - (($parent_item['private']) - || strlen($parent_item['allow_cid']) - || strlen($parent_item['allow_gid']) - || strlen($parent_item['deny_cid']) - || strlen($parent_item['deny_gid']) - ) - ) { - $private = 1; + if($orig_post) { + $str_group_allow = $orig_post['allow_gid']; + $str_contact_allow = $orig_post['allow_cid']; + $str_group_deny = $orig_post['deny_gid']; + $str_contact_deny = $orig_post['deny_cid']; + $title = $orig_post['title']; + $location = $orig_post['location']; + $coord = $orig_post['coord']; + $verb = $orig_post['verb']; + $emailcc = $orig_post['emailcc']; + + $body = escape_tags(trim($_POST['body'])); + $private = $orig_post['private']; } + else { + $str_group_allow = perms2str($_POST['group_allow']); + $str_contact_allow = perms2str($_POST['contact_allow']); + $str_group_deny = perms2str($_POST['group_deny']); + $str_contact_deny = perms2str($_POST['contact_deny']); + $title = notags(trim($_POST['title'])); + $location = notags(trim($_POST['location'])); + $coord = notags(trim($_POST['coord'])); + $verb = notags(trim($_POST['verb'])); + $emailcc = notags(trim($_POST['emailcc'])); + + $body = escape_tags(trim($_POST['body'])); + $private = ((strlen($str_group_allow) || strlen($str_contact_allow) || strlen($str_group_deny) || strlen($str_contact_deny)) ? 1 : 0); + + if(($parent_item) && + (($parent_item['private']) + || strlen($parent_item['allow_cid']) + || strlen($parent_item['allow_gid']) + || strlen($parent_item['deny_cid']) + || strlen($parent_item['deny_gid']) + )) { + $private = 1; + } + - $title = notags(trim($_POST['title'])); - $body = escape_tags(trim($_POST['body'])); - $location = notags(trim($_POST['location'])); - $coord = notags(trim($_POST['coord'])); - $verb = notags(trim($_POST['verb'])); - $emailcc = notags(trim($_POST['emailcc'])); - - if(! strlen($body)) { - notice( t('Empty post discarded.') . EOL ); - if(x($_POST,'return')) - goaway($a->get_baseurl() . "/" . $_POST['return'] ); - killme(); + if(! strlen($body)) { + notice( t('Empty post discarded.') . EOL ); + if(x($_POST,'return')) + goaway($a->get_baseurl() . "/" . $_POST['return'] ); + killme(); + } } // get contact info for poster @@ -151,7 +180,6 @@ function item_post(&$a) { } } - /** * * When a photo was uploaded into the message using the (profile wall) ajax @@ -287,15 +315,13 @@ function item_post(&$a) { $str_tags .= ','; $str_tags .= '@[url=' . $alias . ']' . $newname . '[/url]'; } - } } } } - - $wall = 0; + if($post_type === 'wall' || $post_type === 'wall-comment') $wall = 1; @@ -346,9 +372,31 @@ function item_post(&$a) { $datarray['parent'] = $parent; $datarray['self'] = $self; + if($orig_post) + $datarray['edit'] = true; call_hooks('post_local',$datarray); + + if($orig_post) { + $r = q("UPDATE `item` SET `body` = '%s', `edited` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", + dbesc($body), + dbesc(datetime_convert()), + intval($post_id), + intval($profile_uid) + ); + + proc_run('php', "include/notifier.php", 'edit_post', "$post_id"); + if((x($_POST,'return')) && strlen($_POST['return'])) { + logger('return: ' . $_POST['return']); + goaway($a->get_baseurl() . "/" . $_POST['return'] ); + } + killme(); + } + else + $post_id = 0; + + $r = q("INSERT INTO `item` (`uid`,`type`,`wall`,`gravity`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`, `author-name`, `author-link`, `author-avatar`, `created`, `edited`, `changed`, `uri`, `title`, `body`, `location`, `coord`, `tag`, `inform`, `verb`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private` ) @@ -423,8 +471,8 @@ function item_post(&$a) { '$body' => strip_tags(bbcode($datarray['body'])) )); - $res = mail($user['email'], $from . t(" commented on your item at ") . $a->config['sitename'], - $email_tpl,t("From: Administrator@") . $a->get_hostname() ); + $res = mail($user['email'], sprintf( t("%s commented on your item at %s") ,$from,$a->config['sitename']), + $email_tpl,"From: " . t("Administrator") . "@" . $a->get_hostname() ); } } else { @@ -446,8 +494,8 @@ function item_post(&$a) { '$body' => strip_tags(bbcode($datarray['body'])) )); - $res = mail($user['email'], $from . t(" posted on your profile wall at ") . $a->config['sitename'], - $email_tpl,t("From: Administrator@") . $a->get_hostname() ); + $res = mail($user['email'], sprintf( t("%s posted on your profile wall at %s") ,$from, $a->config['sitename']), + $email_tpl,"From: " . t("Administrator") . "@" . $a->get_hostname() ); } } @@ -490,13 +538,13 @@ function item_post(&$a) { $addr = trim($recip); if(! strlen($addr)) continue; - $disclaimer = '<hr />' . t('This message was sent to you by ') . $a->user['username'] - . t(', a member of the Friendika social network.') . '<br />'; + $disclaimer = '<hr />' . sprintf(t('This message was sent to you by %s, a member of the Friendika social network.'),$a->user['username']) + . '<br />'; $disclaimer .= t('You may visit them online at') . ' ' . $a->get_baseurl() . '/profile/' . $a->user['nickname'] . '<br />'; $disclaimer .= t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . '<br />'; - $subject = '[Friendika]' . ' ' . $a->user['username'] . ' ' . t('posted an update.'); + $subject = '[Friendika]' . ' ' . sprintf( t('%s posted an update.'),$a->user['username']); $headers = 'From: ' . $a->user['username'] . ' <' . $a->user['email'] . '>' . "\n"; $headers .= 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-Type: text/html; charset=UTF-8' . "\n"; diff --git a/mod/like.php b/mod/like.php index 3a8ca4b7d..3e3d69529 100644 --- a/mod/like.php +++ b/mod/like.php @@ -124,9 +124,9 @@ function like_content(&$a) { </object> EOT; if($verb === 'like') - $bodyverb = t('likes'); + $bodyverb = t('%1$s likes %2$s\'s %3$s'); if($verb === 'dislike') - $bodyverb = t('doesn\'t like'); + $bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s'); if(! isset($bodyverb)) return; @@ -147,9 +147,11 @@ EOT; $arr['author-name'] = $contact['name']; $arr['author-link'] = $contact['url']; $arr['author-avatar'] = $contact['thumb']; - $arr['body'] = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]' . ' ' . $bodyverb . ' ' - . '[url=' . $item['author-link'] . ']' . $item['author-name'] . t('\'s') . '[/url]' . ' ' - . '[url=' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]' ; + + $ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]'; + $alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]'; + $plink = '[url=' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]'; + $arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink ); $arr['verb'] = $activity; $arr['object-type'] = $objtype; diff --git a/mod/lostpass.php b/mod/lostpass.php index 30bdc059c..3dcf41be7 100644 --- a/mod/lostpass.php +++ b/mod/lostpass.php @@ -35,7 +35,7 @@ function lostpass_post(&$a) { '$reset_link' => $a->get_baseurl() . '/lostpass?verify=' . $new_password )); - $res = mail($email, t('Password reset requested at ') . $a->config['sitename'], + $res = mail($email, sprintf(t('Password reset requested at %s'),$a->config['sitename']), $email_tpl, 'From: ' . t('Administrator') . '@' . $_SERVER[SERVER_NAME]); goaway($a->get_baseurl()); diff --git a/mod/manage.php b/mod/manage.php index 9981a0446..26f7315c3 100644 --- a/mod/manage.php +++ b/mod/manage.php @@ -34,7 +34,7 @@ function manage_post(&$a) { $_SESSION['page_flags'] = $r[0]['page-flags']; $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $r[0]['nickname']; - notice( t("Welcome back ") . $r[0]['username'] . EOL); + notice( sprintf( t("Welcome back %s") , $r[0]['username']) . EOL); $a->user = $r[0]; if(strlen($a->user['timezone'])) { diff --git a/mod/match.php b/mod/match.php new file mode 100644 index 000000000..092595a09 --- /dev/null +++ b/mod/match.php @@ -0,0 +1,57 @@ +<?php + + +function match_content(&$a) { + + $o = ''; + if(! local_user()) + return; + + $o .= '<h2>' . t('Profile Match') . '</h2>'; + + $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", + intval(local_user()) + ); + if(! count($r)) + return; + if(! $r[0]['pub_keywords'] && (! $r[0]['prv_keywords'])) { + notice('No keywords to match. Please add keywords to your default profile.'); + return; + + } + + $params = array(); + $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']); + if($tags) { + $params['s'] = $tags; + if($a->pager['page'] != 1) + $params['p'] = $a->pager['page']; + + $x = post_url('http://dir.friendika.com/msearch', $params); + + $j = json_decode($x); + + if($j->total) { + $a->set_pager_total($j->total); + $a->set_pager_itemspage($j->items_page); + } + + if(count($j->results)) { + foreach($j->results as $jj) { + $o .= '<div class="profile-match-wrapper"><div class="profile-match-photo">'; + $o .= '<a href="' . $jj->url . '">' . '<img src="' . $jj->photo . '" alt="' . $jj->name . '" title="' . $jj->name . '[' . $jj->url . ']' . '" /></a></div>'; + $o .= '<div class="profile-match-break"></div>'; + $o .= '<div class="profile-match-name"><a href="' . $jj->url . '" title="' . $jj->name . '[' . $jj->url .']' . '">' . $jj->name . '</a></div>'; + $o .= '<div class="profile-match-end"></div></div>'; + } + $o .= '<div id="profile-match-wrapper-end"></div>'; + } + else { + notice( t('No matches') . EOL); + } + + } + + $o .= paginate($a); + return $o; +}
\ No newline at end of file diff --git a/mod/message.php b/mod/message.php index 4821a45d2..7f17a362b 100644 --- a/mod/message.php +++ b/mod/message.php @@ -168,10 +168,13 @@ function message_content(&$a) { $a->page['htmlhead'] .= replace_macros($tpl, array( '$baseurl' => $a->get_baseurl(), - '$nickname' => $a->user['nickname'] + '$nickname' => $a->user['nickname'], + '$linkurl' => t('Please enter a link URL:') )); - $select = contact_select('messageto','message-to-select', false, 4, true); + $preselect = (isset($a->argv[2])?array($a->argv[2]):false); + + $select = contact_select('messageto','message-to-select', $preselect, 4, true); $tpl = load_view_file('view/prv_message.tpl'); $o .= replace_macros($tpl,array( '$header' => t('Send Private Message'), @@ -234,7 +237,7 @@ function message_content(&$a) { '$delete' => t('Delete conversation'), '$body' => $rr['body'], '$to_name' => $rr['name'], - '$date' => datetime_convert('UTC',date_default_timezone_get(),$rr['mailcreated'],'D, d M Y - g:i A') + '$date' => datetime_convert('UTC',date_default_timezone_get(),$rr['mailcreated'], t('D, d M Y - g:i A')) )); } $o .= paginate($a); diff --git a/mod/network.php b/mod/network.php index abdf59c48..42c6c0c29 100644 --- a/mod/network.php +++ b/mod/network.php @@ -54,6 +54,14 @@ function network_content(&$a, $update = 0) { } if(! $update) { + if(group) { + if(($t = group_public_members($group)) && (! get_pconfig(local_user(),'system','nowarn_insecure'))) { + $plural_form = sprintf( tt('%d member', '%d members', $t), $t); + notice( sprintf( t('Warning: This group contains %s from an insecure network.'), $plural_form ) . EOL); + notice( t('Private messages to this group are at risk of public disclosure.') . EOL); + } + } + $o .= '<script> $(document).ready(function() { $(\'#nav-network-link\').addClass(\'nav-selected\'); });</script>'; $_SESSION['return_url'] = $a->cmd; @@ -65,7 +73,13 @@ function network_content(&$a, $update = 0) { $a->page['htmlhead'] .= replace_macros($tpl, array( '$baseurl' => $a->get_baseurl(), '$geotag' => $geotag, - '$nickname' => $a->user['nickname'] + '$nickname' => $a->user['nickname'], + '$linkurl' => t('Please enter a link URL:'), + '$utubeurl' => t('Please enter a YouTube link:'), + '$vidurl' => t("Please enter a video\x28.ogg\x29 link/URL:"), + '$audurl' => t("Please enter an audio\x28.ogg\x29 link/URL:"), + '$whereareu' => t('Where are you right now?'), + '$title' => t('Enter a title for this item') )); @@ -96,6 +110,7 @@ function network_content(&$a, $update = 0) { '$audio' => t('Insert Vorbis [.ogg] audio'), '$setloc' => t('Set your location'), '$noloc' => t('Clear browser location'), + '$title' => t('Set title'), '$wait' => t('Please wait'), '$permset' => t('Permission settings'), '$content' => '', @@ -109,7 +124,7 @@ function network_content(&$a, $update = 0) { '$lockstate' => $lockstate, '$acl' => populate_acl((($group) ? $group_acl : $a->user), $celeb), '$bang' => (($group) ? '!' : ''), - '$profile_uid' => $_SESSION['uid'] + '$profile_uid' => local_user() )); @@ -178,10 +193,16 @@ function network_content(&$a, $update = 0) { intval($_SESSION['uid']) ); - if(count($r)) + if(count($r)) { $a->set_pager_total($r[0]['total']); + $a->set_pager_itemspage(40); + } + if($nouveau) { + + // "New Item View" - show all items unthreaded in reverse created date order + $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, @@ -196,25 +217,57 @@ function network_content(&$a, $update = 0) { intval($a->pager['start']), intval($a->pager['itemspage']) ); + } else { - $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, - `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, - `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` - FROM `item`, (SELECT `p`.`id`,`p`.`created` FROM `item` AS `p` WHERE `p`.`parent`=`p`.`id`) as `parentitem`, `contact` + + // Normal conversation view + // First fetch a known number of parent items + + $r = q("SELECT `item`.`id` 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 `contact`.`id` = `item`.`contact-id` AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - AND `item`.`parent` = `parentitem`.`id` + AND `item`.`parent` = `item`.`id` $sql_extra - ORDER BY `parentitem`.`created` DESC, `item`.`gravity` ASC, `item`.`created` ASC LIMIT %d ,%d ", + ORDER BY `item`.`created` DESC LIMIT %d ,%d ", intval(local_user()), intval($a->pager['start']), intval($a->pager['itemspage']) ); + + + // Then fetch all the children of the parents that are on this page + + $parents_arr = array(); + $parents_str = ''; + + if(count($r)) { + foreach($r as $rr) + $parents_arr[] = $rr['item_id']; + $parents_str = implode(', ', $parents_arr); + + $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, + `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, + `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, + `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` + FROM `item`, (SELECT `p`.`id`,`p`.`created` FROM `item` AS `p` WHERE `p`.`parent`=`p`.`id`) as `parentitem`, `contact` + WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 + AND `contact`.`id` = `item`.`contact-id` + AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 + AND `item`.`parent` = `parentitem`.`id` AND `item`.`parent` IN ( %s ) + $sql_extra + ORDER BY `parentitem`.`created` DESC, `item`.`gravity` ASC, `item`.`created` ASC ", + intval(local_user()), + dbesc($parents_str) + ); + } } + // find all the authors involved in remote conversations + // We will use a local profile photo if they are one of our contacts + // otherwise we have to get the photo from the item owner's site + $author_contacts = extract_item_authors($r,local_user()); $cmnt_tpl = load_view_file('view/comment_item.tpl'); @@ -230,6 +283,8 @@ function network_content(&$a, $update = 0) { if($nouveau) { + // "New Item View" - just loop through the items and format them minimally for display + $tpl = load_view_file('view/search_item.tpl'); $droptpl = load_view_file('view/wall_fake_drop.tpl'); @@ -269,11 +324,12 @@ function network_content(&$a, $update = 0) { $drop = replace_macros($droptpl,array('$id' => $item['id'])); $lock = '<div class="wall-item-lock"></div>'; - + $o .= replace_macros($tpl,array( '$id' => $item['item_id'], '$linktitle' => t('View $name\'s profile'), '$profile_url' => $profile_link, + '$item_photo_menu' => item_photo_menu($item), '$name' => $profile_name, '$sparkle' => $sparkle, '$lock' => $lock, @@ -297,13 +353,35 @@ function network_content(&$a, $update = 0) { } + // Normal View + + + // Figure out how many comments each parent has + // (Comments all have gravity of 6) + // Store the result in the $comments array + $comments = array(); + foreach($r as $rr) { + if(intval($rr['gravity']) == 6) { + if(! x($comments,$rr['parent'])) + $comments[$rr['parent']] = 1; + else + $comments[$rr['parent']] += 1; + } + } + + // map all the like/dislike activities for each parent item + // Store these in the $alike and $dlike arrays foreach($r as $item) { like_puller($a,$item,$alike,'like'); like_puller($a,$item,$dlike,'dislike'); } + $comments_collapsed = false; + $blowhard = 0; + $blowhard_count = 0; + foreach($r as $item) { $comment = ''; @@ -312,12 +390,53 @@ function network_content(&$a, $update = 0) { $sparkle = ''; $owner_url = $owner_photo = $owner_name = ''; - if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE))) && ($item['id'] != $item['parent'])) + + // We've already parsed out like/dislike for special treatment. We can ignore them now + + if(((activity_match($item['verb'],ACTIVITY_LIKE)) + || (activity_match($item['verb'],ACTIVITY_DISLIKE))) + && ($item['id'] != $item['parent'])) continue; - $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ; + // Take care of author collapsing and comment collapsing + // If a single author has more than 3 consecutive top-level posts, squash the remaining ones. + // If there are more than two comments, squash all but the last 2. + + if($item['id'] == $item['parent']) { + if($blowhard == $item['cid'] && (! $item['self'])) { + $blowhard_count ++; + if($blowhard_count == 3) { + $o .= '<div class="icollapse-wrapper fakelink" id="icollapse-wrapper-' . $item['parent'] . '" onclick="openClose(' . '\'icollapse-' . $item['parent'] . '\');" >' . t('See more posts like this') . '</div>' . '<div class="icollapse" id="icollapse-' . $item['parent'] . '" style="display: none;" >'; + } + } + else { + $blowhard = $item['cid']; + if($blowhard_count >= 3) + $o .= '</div>'; + $blowhard_count = 0; + } + + $comments_seen = 0; + $comments_collapsed = false; + } + else + $comments_seen ++; + if(($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) { + if(! $comments_collapsed) { + $o .= '<div class="ccollapse-wrapper fakelink" id="ccollapse-wrapper-' . $item['parent'] . '" onclick="openClose(' . '\'ccollapse-' . $item['parent'] . '\');" >' . sprintf( t('See all %d comments'), $comments[$item['parent']]) . '</div>'; + $o .= '<div class="ccollapse" id="ccollapse-' . $item['parent'] . '" style="display: none;" >'; + $comments_collapsed = true; + } + } + if(($comments[$item['parent']] > 2) && ($comments_seen == ($comments[$item['parent']] - 1))) { + $o .= '</div>'; + } + + + + $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ; $lock = ((($item['private']) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])))) @@ -387,6 +506,9 @@ function network_content(&$a, $update = 0) { )); } + $edpost = ''; + if(($item['id'] == $item['parent']) && (intval($item['wall']) == 1)) + $edpost = '<a class="editpost" href="' . $a->get_baseurl() . '/editpost/' . $item['id'] . '" title="' . t('Edit') . '"><img src="images/pencil.gif" /></a>'; $drop = replace_macros(load_view_file('view/wall_item_drop.tpl'), array('$id' => $item['id'], '$delete' => t('Delete'))); $photo = $item['photo']; @@ -431,6 +553,7 @@ function network_content(&$a, $update = 0) { $indent .= ' shiny'; + // Build the HTML $tmp_item = replace_macros($template,array( @@ -441,6 +564,7 @@ function network_content(&$a, $update = 0) { '$wall' => t('Wall-to-Wall'), '$vwall' => t('via Wall-To-Wall:'), '$profile_url' => $profile_link, + '$item_photo_menu' => item_photo_menu($item), '$name' => $profile_name, '$thumb' => $profile_avatar, '$osparkle' => $osparkle, @@ -455,6 +579,7 @@ function network_content(&$a, $update = 0) { '$owner_photo' => $owner_photo, '$owner_name' => $owner_name, '$plink' => get_plink($item), + '$edpost' => $edpost, '$drop' => $drop, '$vote' => $likebuttons, '$like' => $like, @@ -471,9 +596,16 @@ function network_content(&$a, $update = 0) { } if(! $update) { + + // if author collapsing is in force but didn't get closed, close it off now. + + if($blowhard_count >= 3) + $o .= '</div>'; + + $o .= paginate($a); $o .= '<div class="cc-license">' . t('Shared content is covered by the <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0</a> license.') . '</div>'; } return $o; -}
\ No newline at end of file +} diff --git a/mod/notifications.php b/mod/notifications.php index 93ca82bb0..ed0831aab 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -65,12 +65,11 @@ function notifications_content(&$a) { else $sql_extra = " AND `ignore` = 0 "; - - $tpl = load_view_file('view/intros-top.tpl'); - $o .= replace_macros($tpl,array( - '$hide_url' => ((strlen($sql_extra)) ? 'notifications/all' : 'notifications' ), - '$hide_text' => ((strlen($sql_extra)) ? t('Show Ignored Requests') : t('Hide Ignored Requests')) - )); + $o .= '<h1>' . t('Pending Friend/Connect Notifications') . '</h1>' . "\r\n"; + + $o .= '<div id="notification-show-hide-wrapper" >'; + $o .= '<a href="' . ((strlen($sql_extra)) ? 'notifications/all' : 'notifications' ) . '" id="notifications-show-hide-link" >' + . ((strlen($sql_extra)) ? t('Show Ignored Requests') : t('Hide Ignored Requests')) . '</a></div>' . "\r\n"; $r = q("SELECT COUNT(*) AS `total` FROM `intro` @@ -141,7 +140,7 @@ function notifications_content(&$a) { if ($a->config['register_policy'] == REGISTER_APPROVE && $a->config['admin_email'] === $a->user['email']){ - $o .= load_view_file('view/registrations-top.tpl'); + $o .= '<h1>' . t('User registrations waiting for confirm') . '</h1>' . "\r\n"; $r = q("SELECT `register`.*, `contact`.`name`, `user`.`email` FROM `register` diff --git a/mod/oexchange.php b/mod/oexchange.php new file mode 100644 index 000000000..f97356559 --- /dev/null +++ b/mod/oexchange.php @@ -0,0 +1,53 @@ +<?php + + +function oexchange_init(&$a) { + + if(($a->argc > 1) && ($a->argv[1] === 'xrd')) { + $tpl = load_view_file('view/oexchange_xrd.tpl'); + + $o = replace_macros($tpl, array('$base' => $a->get_baseurl())); + echo $o; + killme(); + } + + + + +} + +function oexchange_content(&$a) { + + if(! local_user()) { + $o = login(false); + return $o; + } + + if(($a->argc > 1) && $a->argv[1] === 'done') { + notice( t('Post successful.') . EOL); + return; + } + + $url = (((x($_GET,'url')) && strlen($_GET['url'])) ? notags(trim($_GET['url'])) : ''); + + $s = fetch_url($a->get_baseurl() . '/parse_url&url=' . $url); + + if(! strlen($s)) + return; + + require_once('include/html2bbcode.php'); + + $post = array(); + + $post['profile_uid'] = local_user(); + $post['return'] = '/oexchange/done' ; + $post['body'] = html2bbcode($s); + $post['type'] = 'wall'; + + $_POST = $post; + require_once('mod/item.php'); + item_post($a); + +} + + diff --git a/mod/openid.php b/mod/openid.php index 6ccd28e5b..68d7c3fd2 100644 --- a/mod/openid.php +++ b/mod/openid.php @@ -70,7 +70,7 @@ function openid_content(&$a) { $_SESSION['page_flags'] = $r[0]['page-flags']; $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $r[0]['nickname']; - notice( t("Welcome back ") . $r[0]['username'] . EOL); + notice( sprintf( t("Welcome back "), $r[0]['username']) . EOL); $a->user = $r[0]; if(strlen($a->user['timezone'])) { diff --git a/mod/photos.php b/mod/photos.php index 4bb6e3eab..061542c75 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -310,6 +310,7 @@ foreach($_FILES AS $key => $val) { $arr['deny_gid'] = $p[0]['deny_gid']; $arr['last-child'] = 1; $arr['visible'] = $visibility; + $arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.jpg' . '[/img]' . '[/url]'; @@ -1073,7 +1074,7 @@ function photos_content(&$a) { $tpl = load_view_file('view/photo_item.tpl'); $return_url = $a->cmd; - $like_tpl = load_view_file('view/lik_noshare.tpl'); + $like_tpl = load_view_file('view/like_noshare.tpl'); $likebuttons = ''; diff --git a/mod/profile.php b/mod/profile.php index c0989bd28..b421591f6 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -98,7 +98,10 @@ function profile_content(&$a, $update = 0) { $o .= replace_macros($tpl,array( '$url' => $a->get_baseurl() . '/' . $a->cmd, - '$phototab' => $a->get_baseurl() . '/photos/' . $a->profile['nickname'] + '$phototab' => $a->get_baseurl() . '/photos/' . $a->profile['nickname'], + '$status' => t('Status'), + '$profile' => t('Profile'), + '$photos' => t('Photos') )); @@ -130,7 +133,13 @@ function profile_content(&$a, $update = 0) { $a->page['htmlhead'] .= replace_macros($tpl, array( '$baseurl' => $a->get_baseurl(), '$geotag' => $geotag, - '$nickname' => $a->profile['nickname'] + '$nickname' => $a->profile['nickname'], + '$linkurl' => t('Please enter a link URL:'), + '$utubeurl' => t('Please enter a YouTube link:'), + '$vidurl' => t("Please enter a video\x28.ogg\x29 link/URL:"), + '$audurl' => t("Please enter an audio\x28.ogg\x29 link/URL:"), + '$whereareu' => t('Where are you right now?'), + '$title' => t('Enter a title for this item') )); require_once('include/acl_selectors.php'); @@ -161,6 +170,7 @@ function profile_content(&$a, $update = 0) { '$audio' => t('Insert Vorbis [.ogg] audio'), '$setloc' => t('Set your location'), '$noloc' => t('Clear browser location'), + '$title' => t('Set title'), '$wait' => t('Please wait'), '$permset' => t('Permission settings'), '$content' => '', @@ -235,31 +245,52 @@ function profile_content(&$a, $update = 0) { FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `wall` = 1 ) + AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1 $sql_extra ", intval($a->profile['profile_uid']) ); - if(count($r)) + if(count($r)) { $a->set_pager_total($r[0]['total']); + $a->set_pager_itemspage(40); + } - $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`, `contact`.`rel`, - `contact`.`thumb`, `contact`.`self`, - `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` + $r = q("SELECT `item`.`id` 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 `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `wall` = 1 ) + AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1 $sql_extra - ORDER BY `parent` DESC, `gravity` ASC, `id` ASC LIMIT %d ,%d ", + ORDER BY `item`.`created` DESC LIMIT %d ,%d ", intval($a->profile['profile_uid']), intval($a->pager['start']), intval($a->pager['itemspage']) ); + $parents_arr = array(); + $parents_str = ''; + + if(count($r)) { + foreach($r as $rr) + $parents_arr[] = $rr['item_id']; + $parents_str = implode(', ', $parents_arr); + + $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, + `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`, `contact`.`rel`, + `contact`.`thumb`, `contact`.`self`, + `contact`.`id` AS `cid`, `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 `contact`.`blocked` = 0 AND `contact`.`pending` = 0 + AND `item`.`parent` IN ( %s ) + $sql_extra + ORDER BY `parent` DESC, `gravity` ASC, `item`.`id` ASC ", + intval($a->profile['profile_uid']), + dbesc($parents_str) + ); + } if($is_owner && ! $update) $o .= get_birthdays(); @@ -284,11 +315,23 @@ function profile_content(&$a, $update = 0) { if($r !== false && count($r)) { + $comments = array(); + foreach($r as $rr) { + if(intval($rr['gravity']) == 6) { + if(! x($comments,$rr['parent'])) + $comments[$rr['parent']] = 1; + else + $comments[$rr['parent']] += 1; + } + } + foreach($r as $item) { like_puller($a,$item,$alike,'like'); like_puller($a,$item,$dlike,'dislike'); } + $comments_collapsed = false; + foreach($r as $item) { $sparkle = ''; @@ -303,6 +346,25 @@ function profile_content(&$a, $update = 0) { && ($item['id'] != $item['parent'])) continue; + if($item['id'] == $item['parent']) { + $comments_seen = 0; + $comments_collapsed = false; + } + else + $comments_seen ++; + + + if(($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) { + if(! $comments_collapsed) { + $o .= '<div class="ccollapse-wrapper fakelink" id="ccollapse-wrapper-' . $item['parent'] . '" onclick="openClose(' . '\'ccollapse-' . $item['parent'] . '\');" >' . sprintf( t('See all %d comments'), $comments[$item['parent']]) . '</div>'; + $o .= '<div class="ccollapse" id="ccollapse-' . $item['parent'] . '" style="display: none;" >'; + $comments_collapsed = true; + } + } + if(($comments[$item['parent']] > 2) && ($comments_seen == ($comments[$item['parent']] - 1))) { + $o .= '</div></div>'; + } + $lock = ((($item['private']) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])))) ? '<div class="wall-item-lock"><img src="images/lock_icon.gif" class="lockview" alt="' . t('Private Message') . '" onclick="lockview(event,' . $item['id'] . ');" /></div>' @@ -340,7 +402,7 @@ function profile_content(&$a, $update = 0) { // This is my profile page but I'm not the author of this post/comment. If it's somebody that's a fan or mutual friend, // I can go directly to their profile as an authenticated guest. - if(local_user() && ($item['contact-uid'] == $_SESSION['uid']) + if(local_user() && ($item['contact-uid'] == local_user()) && ($item['network'] === 'dfrn') && (! $item['self'] )) { $profile_url = $redirect_url; $sparkle = ' sparkle'; @@ -348,6 +410,12 @@ function profile_content(&$a, $update = 0) { else $sparkle = ''; + + $edpost = ''; + if((local_user()) && ($a->profile['profile_uid'] == local_user()) && ($item['id'] == $item['parent']) && (intval($item['wall']) == 1)) + $edpost = '<a class="editpost" href="' . $a->get_baseurl() . '/editpost/' . $item['id'] . '" title="' . t('Edit') . '"><img src="images/pencil.gif" /></a>'; + + // We would prefer to use our own avatar link for this item because the one in the author-avatar might reference a // remote site (which could be down). We will use author-avatar if we haven't got something stored locally. // We use this same logic block in mod/network.php to determine it this is a third party post and we don't have any @@ -386,10 +454,12 @@ function profile_content(&$a, $update = 0) { if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0) $indent .= ' shiny'; + $tmp_item = replace_macros($template,array( '$id' => $item['item_id'], '$linktitle' => t('View $name\'s profile'), '$profile_url' => $profile_link, + '$item_photo_menu' => item_photo_menu($item), '$name' => $profile_name, '$thumb' => $profile_avatar, '$sparkle' => $sparkle, @@ -400,6 +470,7 @@ function profile_content(&$a, $update = 0) { '$location' => $location, '$indent' => $indent, '$plink' => get_plink($item), + '$edpost' => $edpost, '$drop' => $drop, '$like' => $like, '$vote' => $likebuttons, @@ -422,6 +493,5 @@ function profile_content(&$a, $update = 0) { $o .= paginate($a); $o .= '<div class="cc-license">' . t('Shared content is covered by the <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0</a> license.') . '</div>'; - return $o; } diff --git a/mod/profile_photo.php b/mod/profile_photo.php index 5365aa3b8..48805fbdd 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -58,21 +58,21 @@ function profile_photo_post(&$a) { $r = $im->store(local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 4, 1); if($r === false) - notice ( t('Image size reduction [175] failed.') . EOL ); + notice ( sprintf(t('Image size reduction [%s] failed.'),"175") . EOL ); $im->scaleImage(80); $r = $im->store(local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 5, 1); if($r === false) - notice( t('Image size reduction [80] failed.') . EOL ); + notice( sprintf(t('Image size reduction [%s] failed.'),"80") . EOL ); $im->scaleImage(48); $r = $im->store(local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 6, 1); if($r === false) - notice( t('Image size reduction [48] failed.') . EOL ); + notice( sprintf(t('Image size reduction [%s] failed.'),"48") . EOL ); // Unset the profile photo flag from any other photos I own @@ -106,7 +106,7 @@ function profile_photo_post(&$a) { $maximagesize = get_config('system','maximagesize'); if(($maximagesize) && ($filesize > $maximagesize)) { - notice( t('Image exceeds size limit of ') . $maximagesize . EOL); + notice( sprintf(t('Image exceeds size limit of %d'), $maximagesize) . EOL); @unlink($src); return; } @@ -196,9 +196,11 @@ function profile_photo_content(&$a) { $o .= replace_macros($tpl,array( '$filename' => $filename, '$resource' => $a->config['imagecrop'] . '-' . $a->config['imagecrop_resolution'], - '$image_url' => $a->get_baseurl() . '/photo/' . $filename - )); - + '$image_url' => $a->get_baseurl() . '/photo/' . $filename, + '$title' => t('Crop Image'), + '$desc' => t('Please adjust the image cropping for optimum viewing.'), + '$done' => t('Done Editing') + )); return $o; } @@ -234,7 +236,7 @@ function profile_photo_crop_ui_head(&$a, $ph){ $r = $ph->store(local_user(), 0 , $hash, $filename, t('Profile Photos'), 1 ); if($r === false) - notice( t('Image size reduction [640] failed.') . EOL ); + notice( sprintf(t('Image size reduction [%s] failed.'),"640") . EOL ); else $smallest = 1; } diff --git a/mod/redir.php b/mod/redir.php index ac21aa17e..8d0c8f4b3 100644 --- a/mod/redir.php +++ b/mod/redir.php @@ -5,6 +5,7 @@ function redir_init(&$a) { if((! local_user()) || (! ($a->argc == 2)) || (! intval($a->argv[1]))) goaway($a->get_baseurl()); $cid = $a->argv[1]; + $url = ((x($_GET,'url')) ? $_GET['url'] : ''); $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($cid), @@ -37,8 +38,8 @@ function redir_init(&$a) { ); logger('mod_redir: ' . $r[0]['name'] . ' ' . $sec, LOGGER_DEBUG); - + $dest = (($url) ? '&destination_url=' . $url : ''); goaway ($r[0]['poll'] . '?dfrn_id=' . $dfrn_id - . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec); + . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest ); } diff --git a/mod/register.php b/mod/register.php index fdf488b1a..06ed1e0f1 100644 --- a/mod/register.php +++ b/mod/register.php @@ -199,6 +199,24 @@ function register_post(&$a) { return; } + /** + * if somebody clicked submit twice very quickly, they could end up with two accounts + * due to race condition. Remove this one. + */ + + $r = q("SELECT `uid` FROM `user` + WHERE `nickname` = '%s' ", + dbesc($nickname) + ); + if((count($r) > 1) && $newuid) { + $err .= t('Nickname is already registered. Please choose another.') . EOL; + q("DELETE FROM `user` WHERE `uid` = %d LIMIT 1", + intval($newuid) + ); + notice ($err); + return; + } + if(x($newuid) !== false) { $r = q("INSERT INTO `profile` ( `uid`, `profile-name`, `is-default`, `name`, `photo`, `thumb`, `publish`, `net-publish` ) VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, %d ) ", @@ -307,7 +325,7 @@ function register_post(&$a) { '$password' => $new_password, '$uid' => $newuid )); - $res = mail($email, t('Registration details for ') . $a->config['sitename'], + $res = mail($email, sprintf(t('Registration details for %s'), $a->config['sitename']), $email_tpl, 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME']); @@ -344,7 +362,7 @@ function register_post(&$a) { '$hash' => $hash )); - $res = mail($a->config['admin_email'], t('Registration request at ') . $a->config['sitename'], + $res = mail($a->config['admin_email'], sprintf(t('Registration request at %s'), $a->config['sitename']), $email_tpl,'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME']); if($res) { diff --git a/mod/regmod.php b/mod/regmod.php index 00cfa06e2..2cbe810bc 100644 --- a/mod/regmod.php +++ b/mod/regmod.php @@ -51,7 +51,7 @@ function regmod_content(&$a) { $r = q("DELETE FROM `register` WHERE `hash` = '%s' LIMIT 1", dbesc($register[0]['hash']) ); - notice( t('Registration revoked for ') . $user[0]['username'] . EOL); + notice( sprintf(t('Registration revoked for %s'), $user[0]['username']) . EOL); return; } @@ -89,7 +89,7 @@ function regmod_content(&$a) { '$uid' => $user[0]['uid'] )); - $res = mail($user[0]['email'], t('Registration details for '). $a->config['sitename'], + $res = mail($user[0]['email'], sprintf(t('Registration details for %s'), $a->config['sitename']), $email_tpl,'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] ); if($res) { diff --git a/mod/search.php b/mod/search.php index db7279fb5..64281dfcf 100644 --- a/mod/search.php +++ b/mod/search.php @@ -115,6 +115,7 @@ function search_content(&$a) { '$id' => $item['item_id'], '$linktitle' => t('View $name\'s profile'), '$profile_url' => $profile_link, + '$item_photo_menu' => item_photo_menu($item), '$name' => $profile_name, '$sparkle' => $sparkle, '$lock' => $lock, diff --git a/mod/settings.php b/mod/settings.php index 85029b3d7..b20f4d11b 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -5,6 +5,7 @@ function settings_init(&$a) { if(local_user()) { profile_load($a,$a->user['nickname']); } + } @@ -70,6 +71,7 @@ function settings_post(&$a) { $net_publish = (((x($_POST,'profile_in_netdirectory')) && (intval($_POST['profile_in_netdirectory']) == 1)) ? 1: 0); $old_visibility = (((x($_POST,'visibility')) && (intval($_POST['visibility']) == 1)) ? 1 : 0); $page_flags = (((x($_POST,'page-flags')) && (intval($_POST['page-flags']))) ? intval($_POST['page-flags']) : 0); + $blockwall = (((x($_POST,'blockwall')) && (intval($_POST['blockwall']) == 1)) ? 0: 1); // this setting is inverted! $notify = 0; @@ -140,7 +142,7 @@ function settings_post(&$a) { $openidserver = ''; } - $r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `openid` = '%s', `timezone` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d, `page-flags` = %d, `default-location` = '%s', `allow_location` = %d, `theme` = '%s', `maxreq` = %d, `expire` = %d, `openidserver` = '%s' WHERE `uid` = %d LIMIT 1", + $r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `openid` = '%s', `timezone` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d, `page-flags` = %d, `default-location` = '%s', `allow_location` = %d, `theme` = '%s', `maxreq` = %d, `expire` = %d, `openidserver` = '%s', `blockwall` = %d WHERE `uid` = %d LIMIT 1", dbesc($username), dbesc($email), dbesc($openid), @@ -157,6 +159,7 @@ function settings_post(&$a) { intval($maxreq), intval($expire), dbesc($openidserver), + intval($blockwall), intval(local_user()) ); if($r) @@ -241,6 +244,7 @@ function settings_content(&$a) { $openid = $a->user['openid']; $maxreq = $a->user['maxreq']; $expire = ((intval($a->user['expire'])) ? $a->user['expire'] : ''); + $blockwall = $a->user['blockwall']; if(! strlen($a->user['timezone'])) $timezone = date_default_timezone_get(); @@ -338,9 +342,13 @@ function settings_content(&$a) { $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false); + $uexport = '<div id="uexport-link"><a href="uexport" >' . t('Export Personal Data') . '</a></div>'; + + $o .= replace_macros($stpl,array( '$baseurl' => $a->get_baseurl(), '$oidhtml' => $oidhtml, + '$uexport' => $uexport, '$uid' => local_user(), '$username' => $username, '$openid' => $openid, @@ -362,6 +370,7 @@ function settings_content(&$a) { '$sel_notify5' => (($notify & NOTIFY_MAIL) ? ' checked="checked" ' : ''), '$maxreq' => $maxreq, '$expire' => $expire, + '$blockw_checked' => (($blockwall) ? '' : ' checked="checked" ' ), '$theme' => $theme_selector, '$pagetype' => $pagetype )); diff --git a/mod/uexport.php b/mod/uexport.php new file mode 100644 index 000000000..96f062c41 --- /dev/null +++ b/mod/uexport.php @@ -0,0 +1,72 @@ +<?php + +function uexport_init(&$a) { + + if(! local_user()) + killme(); + + $user = array(); + $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", + local_user() + ); + if(count($r)) { + foreach($r as $rr) + foreach($rr as $k => $v) + $user[$k] = $v; + + } + $contact = array(); + $r = q("SELECT * FROM `contact` WHERE `uid` = %d ", + intval(local_user()) + ); + if(count($r)) { + foreach($r as $rr) + foreach($rr as $k => $v) + $contact[][$k] = $v; + + } + + $profile = array(); + $r = q("SELECT * FROM `profile` WHERE `uid` = %d ", + intval(local_user()) + ); + if(count($r)) { + foreach($r as $rr) + foreach($rr as $k => $v) + $profile[][$k] = $v; + } + + $output = array('user' => $user, 'contact' => $contact, 'profile' => $profile ); + + header("Content-type: application/json"); + echo str_replace('\\/','/',json_encode($output)); + + $r = q("SELECT count(*) as `total` FROM `item` WHERE `uid` = %d ", + intval(local_user()) + ); + if(count($r)) + $total = $r[0]['total']; + + // chunk the output to avoid exhausting memory + + for($x = 0; $x < $total; $x += 500) { + $item = array(); + $r = q("SELECT * FROM `item` WHERE `uid` = %d LIMIT %d, %d", + intval(local_user()), + intval($x), + intval(500) + ); + if(count($r)) { + foreach($r as $rr) + foreach($rr as $k => $v) + $item[][$k] = $v; + } + + $output = array('item' => $item); + echo str_replace('\\/','/',json_encode($output)); + } + + + killme(); + +}
\ No newline at end of file diff --git a/mod/viewcontacts.php b/mod/viewcontacts.php index 90ff85b9d..063637bf9 100644 --- a/mod/viewcontacts.php +++ b/mod/viewcontacts.php @@ -41,9 +41,10 @@ function viewcontacts_content(&$a) { $o .= replace_macros($tpl, array( '$id' => $rr['id'], - '$alt_text' => t('Visit ') . $rr['name'] . t('\'s profile'), + '$alt_text' => t('Visit $username\'s profile'), '$thumb' => $rr['thumb'], '$name' => substr($rr['name'],0,20), + '$username' => $rr['name'], '$url' => $rr['url'] )); } diff --git a/mod/wall_upload.php b/mod/wall_upload.php index b5725311d..f7638b730 100644 --- a/mod/wall_upload.php +++ b/mod/wall_upload.php @@ -53,7 +53,7 @@ function wall_upload_post(&$a) { $maximagesize = get_config('system','maximagesize'); if(($maximagesize) && ($filesize > $maximagesize)) { - notice( t('Image exceeds size limit of ') . $maximagesize . EOL); + notice( sprintf(t('Image exceeds size limit of %d'), $maximagesize) . EOL); @unlink($src); return; } |