upstream fixes
This commit is contained in:
parent
2651b60349
commit
87c171030c
81
include/activities.php
Normal file
81
include/activities.php
Normal file
@ -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');
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}}
|
||||
|
||||
|
||||
|
@ -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)) {
|
||||
|
@ -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;
|
||||
}}
|
||||
|
||||
|
||||
|
133
mod/profiles.php
133
mod/profiles.php
@ -8,6 +8,8 @@ function profiles_post(&$a) {
|
||||
return;
|
||||
}
|
||||
|
||||
require_once('include/activities.php');
|
||||
|
||||
$namechanged = false;
|
||||
|
||||
call_hooks('profile_post', $_POST);
|
||||
@ -63,6 +65,27 @@ function profiles_post(&$a) {
|
||||
$prv_keywords = notags(trim($_POST['prv_keywords']));
|
||||
$marital = notags(trim($_POST['marital']));
|
||||
$howlong = notags(trim($_POST['howlong']));
|
||||
$sexual = notags(trim($_POST['sexual']));
|
||||
$homepage = notags(trim($_POST['homepage']));
|
||||
$hometown = notags(trim($_POST['hometown']));
|
||||
$politic = notags(trim($_POST['politic']));
|
||||
$religion = notags(trim($_POST['religion']));
|
||||
|
||||
$likes = fix_mce_lf(escape_tags(trim($_POST['likes'])));
|
||||
$dislikes = fix_mce_lf(escape_tags(trim($_POST['dislikes'])));
|
||||
|
||||
$about = fix_mce_lf(escape_tags(trim($_POST['about'])));
|
||||
$interest = fix_mce_lf(escape_tags(trim($_POST['interest'])));
|
||||
$contact = fix_mce_lf(escape_tags(trim($_POST['contact'])));
|
||||
$music = fix_mce_lf(escape_tags(trim($_POST['music'])));
|
||||
$book = fix_mce_lf(escape_tags(trim($_POST['book'])));
|
||||
$tv = fix_mce_lf(escape_tags(trim($_POST['tv'])));
|
||||
$film = fix_mce_lf(escape_tags(trim($_POST['film'])));
|
||||
$romance = fix_mce_lf(escape_tags(trim($_POST['romance'])));
|
||||
$work = fix_mce_lf(escape_tags(trim($_POST['work'])));
|
||||
$education = fix_mce_lf(escape_tags(trim($_POST['education'])));
|
||||
|
||||
$hide_friends = (($_POST['hide_friends'] == 1) ? 1: 0);
|
||||
|
||||
$with = ((x($_POST,'with')) ? notags(trim($_POST['with'])) : '');
|
||||
|
||||
@ -123,27 +146,6 @@ function profiles_post(&$a) {
|
||||
$with = $orig[0]['with'];
|
||||
}
|
||||
|
||||
$sexual = notags(trim($_POST['sexual']));
|
||||
$homepage = notags(trim($_POST['homepage']));
|
||||
$hometown = notags(trim($_POST['hometown']));
|
||||
$politic = notags(trim($_POST['politic']));
|
||||
$religion = notags(trim($_POST['religion']));
|
||||
|
||||
$likes = fix_mce_lf(escape_tags(trim($_POST['likes'])));
|
||||
$dislikes = fix_mce_lf(escape_tags(trim($_POST['dislikes'])));
|
||||
|
||||
$about = fix_mce_lf(escape_tags(trim($_POST['about'])));
|
||||
$interest = fix_mce_lf(escape_tags(trim($_POST['interest'])));
|
||||
$contact = fix_mce_lf(escape_tags(trim($_POST['contact'])));
|
||||
$music = fix_mce_lf(escape_tags(trim($_POST['music'])));
|
||||
$book = fix_mce_lf(escape_tags(trim($_POST['book'])));
|
||||
$tv = fix_mce_lf(escape_tags(trim($_POST['tv'])));
|
||||
$film = fix_mce_lf(escape_tags(trim($_POST['film'])));
|
||||
$romance = fix_mce_lf(escape_tags(trim($_POST['romance'])));
|
||||
$work = fix_mce_lf(escape_tags(trim($_POST['work'])));
|
||||
$education = fix_mce_lf(escape_tags(trim($_POST['education'])));
|
||||
|
||||
$hide_friends = (($_POST['hide_friends'] == 1) ? 1: 0);
|
||||
|
||||
|
||||
|
||||
@ -306,84 +308,6 @@ function profiles_post(&$a) {
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
proc_run('php',"include/notifier.php","activity","$i");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function profiles_content(&$a) {
|
||||
@ -557,9 +481,13 @@ function profiles_content(&$a) {
|
||||
$is_default = (($r[0]['is_default']) ? 1 : 0);
|
||||
$tpl = get_markup_template("profile_edit.tpl");
|
||||
$o .= replace_macros($tpl,array(
|
||||
|
||||
'$form_security_token' => get_form_security_token("profile_edit"),
|
||||
'$profile_clone_link' => 'profiles/clone/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_clone"),
|
||||
'$profile_drop_link' => 'profiles/drop/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_drop"),
|
||||
'$profile_clone_link' => 'profiles/clone/' . $r[0]['id'] . '?t='
|
||||
. get_form_security_token("profile_clone"),
|
||||
'$profile_drop_link' => 'profiles/drop/' . $r[0]['id'] . '?t='
|
||||
. get_form_security_token("profile_drop"),
|
||||
|
||||
'$banner' => t('Edit Profile Details'),
|
||||
'$submit' => t('Submit'),
|
||||
'$viewprof' => t('View this profile'),
|
||||
@ -670,7 +598,8 @@ function profiles_content(&$a) {
|
||||
'$id' => $rr['id'],
|
||||
'$alt' => t('Profile Image'),
|
||||
'$profile_name' => $rr['profile_name'],
|
||||
'$visible' => (($rr['is_default']) ? '<strong>' . t('visible to everybody') . '</strong>'
|
||||
'$visible' => (($rr['is_default'])
|
||||
? '<strong>' . t('visible to everybody') . '</strong>'
|
||||
: '<a href="' . $a->get_baseurl(true) . '/profperm/' . $rr['id'] . '" />' . t('Edit visibility') . '</a>')
|
||||
));
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
2012-10-19.112
|
||||
2012-10-21.114
|
||||
|
Reference in New Issue
Block a user