Merge branch 'master' into newui

This commit is contained in:
fabrixxm
2011-08-22 13:56:08 +02:00
52 changed files with 3730 additions and 1673 deletions

View File

@@ -141,7 +141,7 @@ function contacts_content(&$a) {
$cmd = $a->argv[2];
$orig_record = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
$orig_record = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d AND `self` = 0 LIMIT 1",
intval($contact_id),
intval(local_user())
);
@@ -222,7 +222,7 @@ function contacts_content(&$a) {
}
contact_remove($contact_id);
contact_remove($orig_record[0]['id']);
info( t('Contact has been removed.') . EOL );
goaway($a->get_baseurl() . '/contacts');
return; // NOTREACHED

View File

@@ -360,8 +360,14 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
}
$new_relation = $contact['rel'];
if($network === NETWORK_DIASPORA && $duplex)
$new_relation = CONTACT_IS_FRIEND;
$writable = $contact['writable'];
if($network === NETWORK_DIASPORA) {
if($duplex)
$new_relation = CONTACT_IS_FRIEND;
if($new_relation != CONTACT_IS_FOLLOWER)
$writable = 1;
}
$r = q("DELETE FROM `intro` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($intro_id),
@@ -380,6 +386,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
`blocked` = 0,
`pending` = 0,
`network` = '%s',
`writable` = %d,
`rel` = %d
WHERE `id` = %d LIMIT 1
",
@@ -392,6 +399,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
dbesc($notify),
dbesc($poll),
dbesc($network),
intval($writable),
intval($new_relation),
intval($contact_id)
);
@@ -640,7 +648,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
`blocked` = 0,
`pending` = 0,
`duplex` = %d,
`network` = 'dfrn' WHERE `id` = %d LIMIT 1
`network` = '%s' WHERE `id` = %d LIMIT 1
",
dbesc($photos[0]),
dbesc($photos[1]),
@@ -650,6 +658,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
dbesc(datetime_convert()),
dbesc(datetime_convert()),
intval($duplex),
dbesc(NETWORK_DFRN),
intval($dfrn_record)
);
if($r === false) { // indicates schema is messed up or total db failure

View File

@@ -58,6 +58,9 @@ function dfrn_notify_post(&$a) {
break; // NOTREACHED
}
// be careful - $importer will contain both the contact information for the contact
// sending us the post, and also the user information for the person receiving it.
// since they are mixed together, it is easy to get them confused.
$r = q("SELECT `contact`.*, `contact`.`uid` AS `importer_uid`,
`contact`.`pubkey` AS `cpubkey`,
@@ -512,17 +515,19 @@ function dfrn_notify_post(&$a) {
$msg['htmlversion']
= html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"), "<br />\n",$datarray['body']))));
$imgtouse = ((link_compare($datarray['author-link'],$importer['url'])) ? $importer['thumb'] : $datarray['author-avatar']);
// 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' => $importer['username'],
'$sitename' => $a->config['sitename'], // name of this site
'$siteurl' => $a->get_baseurl(), // descriptive url of this site
'$thumb' => $datarray['author-avatar'], // thumbnail url for sender icon
'$thumb' => $imgtouse, // thumbnail url for sender icon
'$email' => $importer['email'], // email address to send to
'$url' => $datarray['author-link'], // full url for the site
'$from' => $from, // name of the person sending the message
'$body' => $msg['htmlversion'], // html version of the message
'$url' => $datarray['author-link'], // 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/' . $importer['nickname'] . '/' . $posted_id,
));
@@ -532,10 +537,10 @@ function dfrn_notify_post(&$a) {
'$username' => $importer['username'],
'$sitename' => $a->config['sitename'], // name of this site
'$siteurl' => $a->get_baseurl(), // descriptive url of this site
'$thumb' => $datarray['author-avatar'], // thumbnail url for sender icon
'$thumb' => $imgtouse, // thumbnail url for sender icon
'$email' => $importer['email'], // email address to send to
'$url' => $datarray['author-link'], // full url for the site
'$from' => $from, // name of the person sending the message
'$url' => $datarray['author-link'], // 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/' . $importer['nickname'] . '/' . $posted_id,
));
@@ -643,15 +648,18 @@ function dfrn_notify_post(&$a) {
$msg['htmlversion']
= html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"), "<br />\n",$datarray['body']))));
$imgtouse = ((link_compare($datarray['author-link'],$importer['url'])) ? $importer['thumb'] : $datarray['author-avatar']);
// 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' => $importer['username'],
'$sitename' => $a->config['sitename'], // name of this site
'$siteurl' => $a->get_baseurl(), // descriptive url of this site
'$thumb' => $datarray['author-avatar'], // thumbnail url for sender icon
'$url' => $datarray['author-link'], // full url for the site
'$from' => $from, // name of the person sending the message
'$thumb' => $imgtouse, // thumbnail url for sender icon
'$url' => $datarray['author-link'], // 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/' . $importer['nickname'] . '/' . $posted_id,
));
@@ -662,9 +670,9 @@ function dfrn_notify_post(&$a) {
'$username' => $importer['username'],
'$sitename' => $a->config['sitename'], // name of this site
'$siteurl' => $a->get_baseurl(), // descriptive url of this site
'$thumb' => $datarray['author-avatar'], // thumbnail url for sender icon
'$url' => $datarray['author-link'], // full url for the site
'$from' => $from, // name of the person sending the message
'$thumb' => $imgtouse, // thumbnail url for sender icon
'$url' => $datarray['author-link'], // 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/' . $importer['nickname'] . '/' . $posted_id,
));

View File

@@ -12,10 +12,6 @@
if(! function_exists('dfrn_request_init')) {
function dfrn_request_init(&$a) {
if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
return;
}
if($a->argc > 1)
$which = $a->argv[1];
@@ -147,8 +143,8 @@ function dfrn_request_post(&$a) {
*/
$r = q("INSERT INTO `contact` ( `uid`, `created`,`url`, `name`, `nick`, `photo`, `site-pubkey`,
`request`, `confirm`, `notify`, `poll`, `aes_allow`)
VALUES ( %d, '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d)",
`request`, `confirm`, `notify`, `poll`, `network`, `aes_allow`)
VALUES ( %d, '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d)",
intval(local_user()),
datetime_convert(),
dbesc($dfrn_url),
@@ -160,6 +156,7 @@ function dfrn_request_post(&$a) {
$parms['dfrn-confirm'],
$parms['dfrn-notify'],
$parms['dfrn-poll'],
dbesc(NETWORK_DFRN),
intval($aes_allow)
);
}
@@ -298,7 +295,7 @@ function dfrn_request_post(&$a) {
}
if($network === 'dfrn') {
if($network === NETWORK_DFRN) {
$ret = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `self` = 0 LIMIT 1",
intval($uid),
dbesc($url)
@@ -373,8 +370,8 @@ function dfrn_request_post(&$a) {
dbesc_array($parms);
$r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `name`, `nick`, `issued-id`, `photo`, `site-pubkey`,
`request`, `confirm`, `notify`, `poll` )
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
`request`, `confirm`, `notify`, `poll`, `network` )
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
intval($uid),
datetime_convert(),
$parms['url'],
@@ -386,7 +383,8 @@ function dfrn_request_post(&$a) {
$parms['dfrn-request'],
$parms['dfrn-confirm'],
$parms['dfrn-notify'],
$parms['dfrn-poll']
$parms['dfrn-poll'],
dbesc(NETWORK_DFRN)
);
// find the contact record we just created
@@ -437,15 +435,16 @@ function dfrn_request_post(&$a) {
. (($aes_allow) ? "&aes_allow=1" : "")
);
// NOTREACHED
// END $network === 'dfrn'
// END $network === NETWORK_DFRN
}
elseif($network === 'stat') {
elseif($network === NETWORK_OSTATUS) {
/**
*
* OStatus network
* Check contact existence
* Try and scrape together enough information to create a contact record, with us as CONTACT_IS_FOLLOWER
* Try and scrape together enough information to create a contact record,
* with us as CONTACT_IS_FOLLOWER
* Substitute our user's feed URL into $url template
* Send the subscriber home to subscribe
*
@@ -454,7 +453,7 @@ function dfrn_request_post(&$a) {
$url = str_replace('{uri}', $a->get_baseurl() . '/dfrn_poll/' . $nickname, $url);
goaway($url);
// NOTREACHED
// END $network === 'stat'
// END $network === NETWORK_OSTATUS
}
} return;
@@ -466,8 +465,6 @@ function dfrn_request_post(&$a) {
if(! function_exists('dfrn_request_content')) {
function dfrn_request_content(&$a) {
if(($a->argc != 2) || (! count($a->profile)))
return "";
@@ -578,6 +575,7 @@ function dfrn_request_content(&$a) {
);
}
}
killme();
return; // NOTREACHED
}

View File

@@ -100,9 +100,9 @@ function follow_post(&$a) {
$new_relation = CONTACT_IS_FOLLOWER;
// create contact record
$r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `addr`, `alias`, `notify`, `poll`, `name`, `nick`, `photo`, `network`, `rel`, `priority`,
$r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `addr`, `alias`, `notify`, `poll`, `name`, `nick`, `photo`, `network`, `pubkey`, `rel`, `priority`,
`writable`, `blocked`, `readonly`, `pending` )
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0 ) ",
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0 ) ",
intval(local_user()),
dbesc(datetime_convert()),
dbesc($ret['url']),
@@ -114,6 +114,7 @@ function follow_post(&$a) {
dbesc($ret['nick']),
dbesc($ret['photo']),
dbesc($ret['network']),
dbesc($ret['pubkey']),
intval($new_relation),
intval($ret['priority']),
intval($writeable)
@@ -190,11 +191,12 @@ function follow_post(&$a) {
}
if($contact['network'] == NETWORK_DIASPORA) {
require_once('include/diaspora.php');
$ret = diaspora_share($a->user,$r[0]);
$ret = diaspora_share($a->user,$contact);
logger('mod_follow: diaspora_share returns: ' . $ret);
}
}
goaway($_SESSION['return_url']);
goaway($a->get_baseurl() . '/contacts/' . $contact_id);
// goaway($_SESSION['return_url']);
// NOTREACHED
}

View File

@@ -2,8 +2,7 @@
function hcard_init(&$a) {
if((get_config('system','block_public')) && (! local_user()) && (! remote_user()))
return;
$blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
if($a->argc > 1)
$which = $a->argv[1];
@@ -31,10 +30,12 @@ function hcard_init(&$a) {
$a->page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n";
}
$keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : '');
$keywords = str_replace(array(',',' ',',,'),array(' ',',',','),$keywords);
if(strlen($keywords))
$a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n" ;
if(! $blocked) {
$keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : '');
$keywords = str_replace(array(',',' ',',,'),array(' ',',',','),$keywords);
if(strlen($keywords))
$a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n" ;
}
$a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n" ;
$a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/dfrn_poll/' . $which .'" />' . "\r\n" ;

View File

@@ -19,14 +19,10 @@ function like_content(&$a) {
switch($verb) {
case 'like':
$activity = ACTIVITY_LIKE;
break;
case 'dislike':
$activity = ACTIVITY_DISLIKE;
break;
case 'unlike':
$activity = ACTIVITY_LIKE;
break;
case 'dislike':
case 'undislike':
$activity = ACTIVITY_DISLIKE;
break;

View File

@@ -1,6 +1,7 @@
<?php
require_once('include/acl_selectors.php');
require_once('include/message.php');
function message_post(&$a) {
@@ -14,97 +15,22 @@ function message_post(&$a) {
$body = ((x($_POST,'body')) ? escape_tags(trim($_POST['body'])) : '');
$recipient = ((x($_POST,'messageto')) ? intval($_POST['messageto']) : 0 );
if(! $recipient) {
notice( t('No recipient selected.') . EOL );
return;
}
if(! strlen($subject))
$subject = t('[no subject]');
$me = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
intval(local_user())
);
$contact = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($recipient),
intval(local_user())
);
if(! (count($me) && (count($contact)))) {
notice( t('Unable to locate contact information.') . EOL );
return;
}
$hash = random_string();
$uri = 'urn:X-dfrn:' . $a->get_baseurl() . ':' . local_user() . ':' . $hash ;
if(! strlen($replyto))
$replyto = $uri;
$r = q("INSERT INTO `mail` ( `uid`, `from-name`, `from-photo`, `from-url`,
`contact-id`, `title`, `body`, `seen`, `replied`, `uri`, `parent-uri`, `created`)
VALUES ( %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, '%s', '%s', '%s' )",
intval(local_user()),
dbesc($me[0]['name']),
dbesc($me[0]['thumb']),
dbesc($me[0]['url']),
intval($recipient),
dbesc($subject),
dbesc($body),
1,
0,
dbesc($uri),
dbesc($replyto),
datetime_convert()
);
$r = q("SELECT * FROM `mail` WHERE `uri` = '%s' and `uid` = %d LIMIT 1",
dbesc($uri),
intval(local_user())
);
if(count($r))
$post_id = $r[0]['id'];
/**
*
* When a photo was uploaded into the message using the (profile wall) ajax
* uploader, The permissions are initially set to disallow anybody but the
* owner from seeing it. This is because the permissions may not yet have been
* set for the post. If it's private, the photo permissions should be set
* appropriately. But we didn't know the final permissions on the post until
* now. So now we'll look for links of uploaded messages that are in the
* post and set them to the same permissions as the post itself.
*
*/
$match = null;
if(preg_match_all("/\[img\](.*?)\[\/img\]/",$body,$match)) {
$images = $match[1];
if(count($images)) {
foreach($images as $image) {
if(! stristr($image,$a->get_baseurl() . '/photo/'))
continue;
$image_uri = substr($image,strrpos($image,'/') + 1);
$image_uri = substr($image_uri,0, strpos($image_uri,'-'));
$r = q("UPDATE `photo` SET `allow_cid` = '%s'
WHERE `resource-id` = '%s' AND `album` = '%s' AND `uid` = %d ",
dbesc('<' . $recipient . '>'),
dbesc($image_uri),
dbesc( t('Wall Photos')),
intval(local_user())
);
}
}
}
if($post_id) {
proc_run('php',"include/notifier.php","mail","$post_id");
info( t('Message sent.') . EOL );
$ret = send_message($recipient, $body, $subject, $replyto);
switch($ret){
case -1:
notice( t('No recipient selected.') . EOL );
break;
case -2:
notice( t('Unable to locate contact information.') . EOL );
break;
case -3:
notice( t('Message could not be sent.') . EOL );
default:
info( t('Message sent.') . EOL );
}
else {
notice( t('Message could not be sent.') . EOL );
}
return;
}
function message_content(&$a) {

View File

@@ -2,8 +2,7 @@
function profile_init(&$a) {
if((get_config('system','block_public')) && (! local_user()) && (! remote_user()))
return;
$blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
if($a->argc > 1)
$which = $a->argv[1];
@@ -31,10 +30,12 @@ function profile_init(&$a) {
$a->page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n";
}
$keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : '');
$keywords = str_replace(array(',',' ',',,'),array(' ',',',','),$keywords);
if(strlen($keywords))
$a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n" ;
if(! $blocked) {
$keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : '');
$keywords = str_replace(array(',',' ',',,'),array(' ',',',','),$keywords);
if(strlen($keywords))
$a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n" ;
}
$a->page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . (($a->profile['net-publish']) ? 'true' : 'false') . '" />' . "\r\n" ;
$a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/dfrn_poll/' . $which .'" />' . "\r\n" ;

View File

@@ -15,6 +15,8 @@ function receive_post(&$a) {
if($a->argc != 3 || $a->argv[1] !== 'users')
http_status_exit(500);
logger('receive: raw input: ' . file_get_contents('php://input'), LOGGER_DATA);
$guid = $a->argv[2];
$r = q("SELECT * FROM `user` WHERE `guid` = '%s' LIMIT 1",

View File

@@ -55,7 +55,7 @@ function wall_upload_post(&$a) {
if(($maximagesize) && ($filesize > $maximagesize)) {
echo sprintf( t('Image exceeds size limit of %d'), $maximagesize) . EOL;
@unlink($src);
return;
killme();
}
$imagedata = @file_get_contents($src);