diff options
author | friendica <info@friendica.com> | 2012-10-21 17:23:21 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2012-10-21 17:23:21 -0700 |
commit | 87c171030c8de2e36f284fa6b58f11a5535a9a29 (patch) | |
tree | 6fb23786422aa14c408e7db916b707017fe000b1 /include | |
parent | 2651b60349fc38023a2512cd5504744949a5240a (diff) | |
download | volse-hubzilla-87c171030c8de2e36f284fa6b58f11a5535a9a29.tar.gz volse-hubzilla-87c171030c8de2e36f284fa6b58f11a5535a9a29.tar.bz2 volse-hubzilla-87c171030c8de2e36f284fa6b58f11a5535a9a29.zip |
upstream fixes
Diffstat (limited to 'include')
-rw-r--r-- | include/activities.php | 81 | ||||
-rw-r--r-- | include/auth.php | 20 | ||||
-rwxr-xr-x | include/items.php | 1 | ||||
-rw-r--r-- | include/security.php | 21 |
4 files changed, 103 insertions, 20 deletions
diff --git a/include/activities.php b/include/activities.php new file mode 100644 index 000000000..20b198976 --- /dev/null +++ b/include/activities.php @@ -0,0 +1,81 @@ +<?php + +function profile_activity($changed, $value) { + $a = get_app(); + + if(! local_user() || ! is_array($changed) || ! count($changed)) + return; + + if(! get_pconfig(local_user(),'system','post_profilechange')) + return; + + require_once('include/items.php'); + + $self = $a->get_channel(); + + if(! count($self)) + return; + + $arr = array(); + $arr['uri'] = $arr['parent_uri'] = item_message_id(); + $arr['uid'] = local_user(); + $arr['aid'] = $self['channel_account_id']; + $arr['owner_xchan'] = $arr['author_xchan'] = $self['xchan_hash']; + $arr['item_flags'] = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP; + $arr['verb'] = ACTIVITY_UPDATE; + $arr['obj_type'] = ACTIVITY_OBJ_PROFILE; + + $A = '[url=' . $self[0]['xchan_profile'] . ']' . $self[0]['xchan_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=' . $self[0]['xchan_profile'] . '?tab=profile' . ']' . t('public profile') . '[/url]'; + + if($t == 1 && strlen($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' => $self[0]['profile'] . '?tab=profile'); + $links[] = array('rel' => 'photo', 'type' => /*FIXME*/ 'image/jpeg', 'href' => $self[0]['xchan_photo']); + + $arr['object'] = json_encode(array( + 'type' => ACTIVITY_OBJ_PROFILE, + 'title' => $self[0]['channel_name'], + 'id' => $self[0]['xchan_profile'] . '/' . $self[0]['xchan_hash'], + 'link' => $links + )); + + + $arr['allow_cid'] = $self[0]['channel_allow_cid']; + $arr['allow_gid'] = $self[0]['channel_allow_gid']; + $arr['deny_cid'] = $self[0]['channel_deny_cid']; + $arr['deny_gid'] = $self[0]['channel_deny_gid']; + + $i = item_store($arr); + + 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'); + } + +} diff --git a/include/auth.php b/include/auth.php index d184b5ff7..3f877cd1d 100644 --- a/include/auth.php +++ b/include/auth.php @@ -185,23 +185,3 @@ else { } } -// Returns an array of group id's this contact is a member of. -// This array will only contain group id's related to the uid of this -// DFRN contact. They are *not* neccessarily unique across the entire site. - - -if(! function_exists('init_groups_visitor')) { -function init_groups_visitor($contact_id) { - $groups = array(); - $r = q("SELECT `gid` FROM `group_member` - WHERE `contact-id` = %d ", - intval($contact_id) - ); - if(count($r)) { - foreach($r as $rr) - $groups[] = $rr['gid']; - } - return $groups; -}} - - diff --git a/include/items.php b/include/items.php index 8319a358c..02bfed7cc 100755 --- a/include/items.php +++ b/include/items.php @@ -110,6 +110,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) killme(); $contact = $r[0]; + require_once('include/security.php'); $groups = init_groups_visitor($contact['id']); if(count($groups)) { diff --git a/include/security.php b/include/security.php index d1b3deca7..50c2337bf 100644 --- a/include/security.php +++ b/include/security.php @@ -440,3 +440,24 @@ function check_form_security_token_ForbiddenOnErr($typename = '', $formname = 'f killme(); } } + +// Returns an array of group id's this contact is a member of. +// This array will only contain group id's related to the uid of this +// DFRN contact. They are *not* neccessarily unique across the entire site. + + +if(! function_exists('init_groups_visitor')) { +function init_groups_visitor($contact_id) { + $groups = array(); + $r = q("SELECT `gid` FROM `group_member` + WHERE `contact-id` = %d ", + intval($contact_id) + ); + if(count($r)) { + foreach($r as $rr) + $groups[] = $rr['gid']; + } + return $groups; +}} + + |