1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
<?php /** @file */
function profile_activity($changed, $value) {
$a = get_app();
if(! local_channel() || ! is_array($changed) || ! count($changed))
return;
if(! get_pconfig(local_channel(),'system','post_profilechange'))
return;
require_once('include/items.php');
$self = $a->get_channel();
if(! count($self))
return;
$arr = array();
$arr['mid'] = $arr['parent_mid'] = item_message_id();
$arr['uid'] = local_channel();
$arr['aid'] = $self['channel_account_id'];
$arr['owner_xchan'] = $arr['author_xchan'] = $self['xchan_hash'];
$arr['item_flags'] = ITEM_ORIGIN|ITEM_THREAD_TOP;
$arr['item_wall'] = 1;
$arr['verb'] = ACTIVITY_UPDATE;
$arr['obj_type'] = ACTIVITY_OBJ_PROFILE;
$arr['plink'] = z_root() . '/channel/' . $self['channel_address'] . '/?f=&mid=' . $arr['mid'];
$A = '[url=' . z_root() . '/channel/' . $self['channel_address'] . ']' . $self['channel_name'] . '[/url]';
$changes = '';
$t = count($changed);
$z = 0;
foreach($changed as $ch) {
if(strlen($changes)) {
if ($z == ($t - 1))
$changes .= t(' and ');
else
$changes .= ', ';
}
$z ++;
$changes .= $ch;
}
$prof = '[url=' . z_root() . '/profile/' . $self['channel_address'] . ']' . t('public profile') . '[/url]';
if($t == 1 && strlen($value)) {
// if it's a url, the HTML quotes will mess it up, so link it and don't try and zidify it because we don't know what it points to.
$value = preg_replace_callback("/([^\]\='".'"'."]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\+\,]+)/ism", 'red_zrl_callback', $value);
// take out the bookmark indicator
if(substr($value,0,2) === '#^')
$value = str_replace('#^','',$value);
$message = sprintf( t('%1$s changed %2$s to “%3$s”'), $A, $changes, $value);
$message .= "\n\n" . sprintf( t('Visit %1$s\'s %2$s'), $A, $prof);
}
else
$message = sprintf( t('%1$s has an updated %2$s, changing %3$s.'), $A, $prof, $changes);
$arr['body'] = $message;
$links = array();
$links[] = array('rel' => 'alternate', 'type' => 'text/html',
'href' => z_root() . '/profile/' . $self['channel_address']);
$links[] = array('rel' => 'photo', 'type' => $self['xchan_photo_mimetype'],
'href' => $self['xchan_photo_l']);
$arr['object'] = json_encode(array(
'type' => ACTIVITY_OBJ_PROFILE,
'title' => $self['channel_name'],
'id' => $self['xchan_url'] . '/' . $self['xchan_hash'],
'link' => $links
));
$arr['allow_cid'] = $self['channel_allow_cid'];
$arr['allow_gid'] = $self['channel_allow_gid'];
$arr['deny_cid'] = $self['channel_deny_cid'];
$arr['deny_gid'] = $self['channel_deny_gid'];
$res = item_store($arr);
$i = $res['item_id'];
if($i) {
// FIXME - limit delivery in notifier.php to those specificed in the perms argument
proc_run('php',"include/notifier.php","activity","$i", 'PERMS_R_PROFILE');
}
}
|