more work on profile changes - the notify activity is still stuffed as we finalise the json structure for activitystream meta-data

This commit is contained in:
friendica 2012-10-19 15:40:13 -07:00
parent b60560812f
commit 112e4e6c9c
3 changed files with 37 additions and 31 deletions

View File

@ -206,7 +206,7 @@ function change_channel($change_channel) {
$ret = false; $ret = false;
if($change_channel) { if($change_channel) {
$r = q("select * from channel where channel_id = %d and channel_account_id = %d limit 1", $r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel_id = %d and channel_account_id = %d limit 1",
intval($change_channel), intval($change_channel),
intval(get_account_id()) intval(get_account_id())
); );

View File

@ -12,7 +12,7 @@ function profiles_post(&$a) {
call_hooks('profile_post', $_POST); call_hooks('profile_post', $_POST);
if(($a->argc > 1) && ($a->argv[1] !== "new") && intval($a->argv[1])) { if((argc() > 1) && (argv(1) !== "new") && intval(argv(1))) {
$orig = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", $orig = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[1]), intval($a->argv[1]),
intval(local_user()) intval(local_user())
@ -286,11 +286,13 @@ function profiles_post(&$a) {
if($r) if($r)
info( t('Profile updated.') . EOL); info( t('Profile updated.') . EOL);
$channel = $a->get_channel();
if($namechanged && $is_default) { if($namechanged && $is_default) {
$r = q("UPDATE `contact` SET `name_date` = '%s' WHERE `self` = 1 AND `uid` = %d LIMIT 1", $r = q("UPDATE xchan SET xchan_name = '%s', xchan_name_date` = '%s' WHERE xchan_hash = '%s' limit 1",
dbesc($name),
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval(local_user()) dbesc($channel['xchan_hash'])
); );
} }
@ -310,17 +312,19 @@ function profile_activity($changed, $value) {
if(! local_user() || ! is_array($changed) || ! count($changed)) if(! local_user() || ! is_array($changed) || ! count($changed))
return; return;
if($a->user['hidewall'] || get_config('system','block_public')) // FIXME (lots to fix)
// if($a->user['hidewall'] || get_config('system','block_public'))
// return;
return; return;
if(! get_pconfig(local_user(),'system','post_profilechange')) if(! get_pconfig(local_user(),'system','post_profilechange'))
return; return;
require_once('include/items.php'); require_once('include/items.php');
$self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", $self = $a->get_channel();
intval(local_user())
);
if(! count($self)) if(! count($self))
return; return;
@ -328,14 +332,14 @@ function profile_activity($changed, $value) {
$arr = array(); $arr = array();
$arr['uri'] = $arr['parent_uri'] = item_message_id(); $arr['uri'] = $arr['parent_uri'] = item_message_id();
$arr['uid'] = local_user(); $arr['uid'] = local_user();
$arr['contact-id'] = $self[0]['id']; // $arr['contact-id'] = $self[0]['id'];
$arr['wall'] = 1; // $arr['wall'] = 1;
$arr['type'] = 'wall'; // $arr['type'] = 'wall';
$arr['gravity'] = 0; // $arr['gravity'] = 0;
$arr['origin'] = 1; // $arr['origin'] = 1;
$arr['author-name'] = $arr['owner-name'] = $self[0]['name']; // $arr['author-name'] = $arr['owner-name'] = $self[0]['name'];
$arr['author-link'] = $arr['owner-link'] = $self[0]['url']; // $arr['author-link'] = $arr['owner-link'] = $self[0]['url'];
$arr['author-avatar'] = $arr['owner-avatar'] = $self[0]['thumb']; // $arr['author-avatar'] = $arr['owner-avatar'] = $self[0]['thumb'];
$arr['verb'] = ACTIVITY_UPDATE; $arr['verb'] = ACTIVITY_UPDATE;
$arr['obj_type'] = ACTIVITY_OBJ_PROFILE; $arr['obj_type'] = ACTIVITY_OBJ_PROFILE;
@ -368,20 +372,22 @@ function profile_activity($changed, $value) {
$arr['body'] = $message; $arr['body'] = $message;
$arr['object'] = '<object><type>' . ACTIVITY_OBJ_PROFILE . '</type><title>' . $self[0]['name'] . '</title>' // $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PROFILE . '</type><title>' . $self[0]['name'] . '</title>'
. '<id>' . $self[0]['url'] . '/' . $self[0]['name'] . '</id>'; // . '<id>' . $self[0]['url'] . '/' . $self[0]['name'] . '</id>';
$arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $self[0]['url'] . '?tab=profile' . '" />' . "\n"); // $arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $self[0]['url'] . '?tab=profile' . '" />' . "\n");
$arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $self[0]['thumb'] . '" />' . "\n"); // $arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $self[0]['thumb'] . '" />' . "\n");
$arr['object'] .= '</link></object>' . "\n"; // $arr['object'] .= '</link></object>' . "\n";
$arr['allow_cid'] = $a->user['allow_cid']; // $arr['allow_cid'] = $a->user['allow_cid'];
$arr['allow_gid'] = $a->user['allow_gid']; // $arr['allow_gid'] = $a->user['allow_gid'];
$arr['deny_cid'] = $a->user['deny_cid']; // $arr['deny_cid'] = $a->user['deny_cid'];
$arr['deny_gid'] = $a->user['deny_gid']; // $arr['deny_gid'] = $a->user['deny_gid'];
$i = item_store($arr); $i = item_store($arr);
if($i) { if($i) {
// ??? are we going to change plink structure? I'm guessing yes
// give it a permanent link // give it a permanent link
q("update item set plink = '%s' where id = %d limit 1", q("update item set plink = '%s' where id = %d limit 1",
dbesc($a->get_baseurl() . '/display/' . $a->user['nickname'] . '/' . $i), dbesc($a->get_baseurl() . '/display/' . $a->user['nickname'] . '/' . $i),
@ -404,7 +410,7 @@ function profiles_content(&$a) {
return; return;
} }
if(($a->argc > 2) && ($a->argv[1] === "drop") && intval($a->argv[2])) { if((argc() > 2) && (argv(1) === "drop") && intval(argv(2))) {
$r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is_default` = 0 LIMIT 1", $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is_default` = 0 LIMIT 1",
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
@ -440,7 +446,7 @@ function profiles_content(&$a) {
if(($a->argc > 1) && ($a->argv[1] === 'new')) { if((argc() > 1) && (argv(1) === 'new')) {
check_form_security_token_redirectOnErr('/profiles', 'profile_new', 't'); check_form_security_token_redirectOnErr('/profiles', 'profile_new', 't');
@ -476,7 +482,7 @@ function profiles_content(&$a) {
goaway($a->get_baseurl(true) . '/profiles'); goaway($a->get_baseurl(true) . '/profiles');
} }
if(($a->argc > 2) && ($a->argv[1] === 'clone')) { if((argc() > 2) && (argv(1) === 'clone')) {
check_form_security_token_redirectOnErr('/profiles', 'profile_clone', 't'); check_form_security_token_redirectOnErr('/profiles', 'profile_clone', 't');
@ -521,7 +527,7 @@ function profiles_content(&$a) {
} }
if(($a->argc > 1) && (intval($a->argv[1]))) { if((argc() > 1) && (intval(argv(1)))) {
$r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[1]), intval($a->argv[1]),
intval(local_user()) intval(local_user())

View File

@ -1 +1 @@
2012-10-18.111 2012-10-19.112