diff options
-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 | ||||
-rw-r--r-- | mod/profiles.php | 283 | ||||
-rw-r--r-- | version.inc | 2 |
6 files changed, 210 insertions, 198 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; +}} + + diff --git a/mod/profiles.php b/mod/profiles.php index 611151563..f1e67b86b 100644 --- a/mod/profiles.php +++ b/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,8 +65,29 @@ 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'])) : ''); + $with = ((x($_POST,'with')) ? notags(trim($_POST['with'])) : ''); if(! strlen($howlong)) $howlong = '0000-00-00 00:00:00'; @@ -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) { @@ -535,18 +459,18 @@ function profiles_content(&$a) { $editselect = 'none'; $a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array( - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => $a->get_baseurl(true), '$editselect' => $editselect, )); $opt_tpl = get_markup_template("profile-hide_friends.tpl"); $hide_friends = replace_macros($opt_tpl,array( - '$desc' => t('Hide your contact/friend list from viewers of this profile?'), - '$yes_str' => t('Yes'), - '$no_str' => t('No'), + '$desc' => t('Hide your contact/friend list from viewers of this profile?'), + '$yes_str' => t('Yes'), + '$no_str' => t('No'), '$yes_selected' => (($r[0]['hide_friends']) ? " checked=\"checked\" " : ""), - '$no_selected' => (($r[0]['hide_friends'] == 0) ? " checked=\"checked\" " : "") + '$no_selected' => (($r[0]['hide_friends'] == 0) ? " checked=\"checked\" " : "") )); @@ -557,89 +481,93 @@ 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"), - '$banner' => t('Edit Profile Details'), - '$submit' => t('Submit'), - '$viewprof' => t('View this profile'), - '$cr_prof' => t('Create a new profile using these settings'), - '$cl_prof' => t('Clone this profile'), - '$del_prof' => t('Delete this profile'), + '$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'), + '$cr_prof' => t('Create a new profile using these settings'), + '$cl_prof' => t('Clone this profile'), + '$del_prof' => t('Delete this profile'), '$lbl_profname' => t('Profile Name:'), '$lbl_fullname' => t('Your Full Name:'), - '$lbl_title' => t('Title/Description:'), - '$lbl_gender' => t('Your Gender:'), - '$lbl_bd' => sprintf( t("Birthday \x28%s\x29:"),datesel_format($f)), - '$lbl_address' => t('Street Address:'), - '$lbl_city' => t('Locality/City:'), - '$lbl_zip' => t('Postal/Zip Code:'), - '$lbl_country' => t('Country:'), - '$lbl_region' => t('Region/State:'), - '$lbl_marital' => t('<span class="heart">♥</span> Marital Status:'), - '$lbl_with' => t("Who: \x28if applicable\x29"), - '$lbl_ex1' => t('Examples: cathy123, Cathy Williams, cathy@example.com'), - '$lbl_howlong' => t('Since [date]:'), - '$lbl_sexual' => t('Sexual Preference:'), + '$lbl_title' => t('Title/Description:'), + '$lbl_gender' => t('Your Gender:'), + '$lbl_bd' => sprintf( t("Birthday \x28%s\x29:"),datesel_format($f)), + '$lbl_address' => t('Street Address:'), + '$lbl_city' => t('Locality/City:'), + '$lbl_zip' => t('Postal/Zip Code:'), + '$lbl_country' => t('Country:'), + '$lbl_region' => t('Region/State:'), + '$lbl_marital' => t('<span class="heart">♥</span> Marital Status:'), + '$lbl_with' => t("Who: \x28if applicable\x29"), + '$lbl_ex1' => t('Examples: cathy123, Cathy Williams, cathy@example.com'), + '$lbl_howlong' => t('Since [date]:'), + '$lbl_sexual' => t('Sexual Preference:'), '$lbl_homepage' => t('Homepage URL:'), '$lbl_hometown' => t('Hometown:'), - '$lbl_politic' => t('Political Views:'), + '$lbl_politic' => t('Political Views:'), '$lbl_religion' => t('Religious Views:'), - '$lbl_pubkey' => t('Public Keywords:'), - '$lbl_prvkey' => t('Private Keywords:'), - '$lbl_likes' => t('Likes:'), + '$lbl_pubkey' => t('Public Keywords:'), + '$lbl_prvkey' => t('Private Keywords:'), + '$lbl_likes' => t('Likes:'), '$lbl_dislikes' => t('Dislikes:'), - '$lbl_ex2' => t('Example: fishing photography software'), - '$lbl_pubdsc' => t("\x28Used for suggesting potential friends, can be seen by others\x29"), - '$lbl_prvdsc' => t("\x28Used for searching profiles, never shown to others\x29"), - '$lbl_about' => t('Tell us about yourself...'), - '$lbl_hobbies' => t('Hobbies/Interests'), - '$lbl_social' => t('Contact information and Social Networks'), - '$lbl_music' => t('Musical interests'), - '$lbl_book' => t('Books, literature'), - '$lbl_tv' => t('Television'), - '$lbl_film' => t('Film/dance/culture/entertainment'), - '$lbl_love' => t('Love/romance'), - '$lbl_work' => t('Work/employment'), - '$lbl_school' => t('School/education'), - '$disabled' => (($is_default) ? 'onclick="return false;" style="color: #BBBBFF;"' : ''), - '$baseurl' => $a->get_baseurl(true), - '$profile_id' => $r[0]['id'], + '$lbl_ex2' => t('Example: fishing photography software'), + '$lbl_pubdsc' => t("\x28Used for suggesting potential friends, can be seen by others\x29"), + '$lbl_prvdsc' => t("\x28Used for searching profiles, never shown to others\x29"), + '$lbl_about' => t('Tell us about yourself...'), + '$lbl_hobbies' => t('Hobbies/Interests'), + '$lbl_social' => t('Contact information and Social Networks'), + '$lbl_music' => t('Musical interests'), + '$lbl_book' => t('Books, literature'), + '$lbl_tv' => t('Television'), + '$lbl_film' => t('Film/dance/culture/entertainment'), + '$lbl_love' => t('Love/romance'), + '$lbl_work' => t('Work/employment'), + '$lbl_school' => t('School/education'), + '$disabled' => (($is_default) ? 'onclick="return false;" style="color: #BBBBFF;"' : ''), + '$baseurl' => $a->get_baseurl(true), + '$profile_id' => $r[0]['id'], '$profile_name' => $r[0]['profile_name'], - '$default' => (($is_default) ? '<p id="profile-edit-default-desc">' . t('This is your <strong>public</strong> profile.<br />It <strong>may</strong> be visible to anybody using the internet.') . '</p>' : ""), - '$name' => $r[0]['name'], - '$pdesc' => $r[0]['pdesc'], - '$dob' => dob($r[0]['dob']), + '$default' => (($is_default) ? '<p id="profile-edit-default-desc">' . t('This is your <strong>public</strong> profile.<br />It <strong>may</strong> be visible to anybody using the internet.') . '</p>' : ""), + '$name' => $r[0]['name'], + '$pdesc' => $r[0]['pdesc'], + '$dob' => dob($r[0]['dob']), '$hide_friends' => $hide_friends, - '$address' => $r[0]['address'], - '$locality' => $r[0]['locality'], - '$region' => $r[0]['region'], - '$postal_code' => $r[0]['postal_code'], + '$address' => $r[0]['address'], + '$locality' => $r[0]['locality'], + '$region' => $r[0]['region'], + '$postal_code' => $r[0]['postal_code'], '$country_name' => $r[0]['country_name'], - '$age' => ((intval($r[0]['dob'])) ? '(' . t('Age: ') . age($r[0]['dob'],$a->user['timezone'],$a->user['timezone']) . ')' : ''), - '$gender' => gender_selector($r[0]['gender']), - '$marital' => marital_selector($r[0]['marital']), - '$with' => strip_tags($r[0]['with']), - '$howlong' => ($r[0]['howlong'] === '0000-00-00 00:00:00' ? '' : datetime_convert('UTC',date_default_timezone_get(),$r[0]['howlong'])), - '$sexual' => sexpref_selector($r[0]['sexual']), - '$about' => $r[0]['about'], - '$homepage' => $r[0]['homepage'], - '$hometown' => $r[0]['hometown'], - '$politic' => $r[0]['politic'], - '$religion' => $r[0]['religion'], + '$age' => ((intval($r[0]['dob'])) ? '(' . t('Age: ') . age($r[0]['dob'],$a->user['timezone'],$a->user['timezone']) . ')' : ''), + '$gender' => gender_selector($r[0]['gender']), + '$marital' => marital_selector($r[0]['marital']), + '$with' => strip_tags($r[0]['with']), + '$howlong' => ($r[0]['howlong'] === '0000-00-00 00:00:00' ? '' : datetime_convert('UTC',date_default_timezone_get(),$r[0]['howlong'])), + '$sexual' => sexpref_selector($r[0]['sexual']), + '$about' => $r[0]['about'], + '$homepage' => $r[0]['homepage'], + '$hometown' => $r[0]['hometown'], + '$politic' => $r[0]['politic'], + '$religion' => $r[0]['religion'], '$pub_keywords' => $r[0]['pub_keywords'], '$prv_keywords' => $r[0]['prv_keywords'], - '$likes' => $r[0]['likes'], - '$dislikes' => $r[0]['dislikes'], - '$music' => $r[0]['music'], - '$book' => $r[0]['book'], - '$tv' => $r[0]['tv'], - '$film' => $r[0]['film'], - '$interest' => $r[0]['interest'], - '$romance' => $r[0]['romance'], - '$work' => $r[0]['work'], - '$education' => $r[0]['education'], - '$contact' => $r[0]['contact'] + '$likes' => $r[0]['likes'], + '$dislikes' => $r[0]['dislikes'], + '$music' => $r[0]['music'], + '$book' => $r[0]['book'], + '$tv' => $r[0]['tv'], + '$film' => $r[0]['film'], + '$interest' => $r[0]['interest'], + '$romance' => $r[0]['romance'], + '$work' => $r[0]['work'], + '$education' => $r[0]['education'], + '$contact' => $r[0]['contact'] )); $arr = array('profile' => $r[0], 'entry' => $o); @@ -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>') )); } diff --git a/version.inc b/version.inc index ddd4c384e..d6d36e3ee 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2012-10-19.112 +2012-10-21.114 |