From eac29badb2fade43dfe3fd6373ffc675858143dd Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 30 Aug 2012 18:17:38 -0700 Subject: start on contacts/profiles --- mod/dfrn_confirm.php | 8 ++++---- mod/directory.php | 14 +++++++------- mod/hcard.php | 1 - mod/match.php | 2 +- mod/msearch.php | 4 ++-- mod/poco.php | 6 +++--- mod/profile_photo.php | 6 +++--- mod/profiles.php | 35 +++++++++++++++++------------------ mod/profperm.php | 2 +- mod/regmod.php | 4 ++-- mod/settings.php | 23 +++++++---------------- mod/viewcontacts.php | 2 +- mod/viewsrc.php | 16 ++++++++-------- mod/zfinger.php | 16 +++++++++++++--- 14 files changed, 69 insertions(+), 70 deletions(-) (limited to 'mod') diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index eef80f8dd..7002b870f 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -424,11 +424,11 @@ function dfrn_confirm_post(&$a,$handsfree = null) { // Send a new friend post if we are allowed to... - $r = q("SELECT `hide-friends` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1", + $r = q("SELECT `hide_friends` FROM `profile` WHERE `uid` = %d AND `is_default` = 1 LIMIT 1", intval($uid) ); - if((count($r)) && ($r[0]['hide-friends'] == 0) && ($activity) && (! $hidden)) { + if((count($r)) && ($r[0]['hide_friends'] == 0) && ($activity) && (! $hidden)) { require_once('include/items.php'); @@ -745,11 +745,11 @@ function dfrn_confirm_post(&$a,$handsfree = null) { // Send a new friend post if we are allowed to... if($page && intval(get_pconfig($local_uid,'system','post_joingroup'))) { - $r = q("SELECT `hide-friends` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1", + $r = q("SELECT `hide_friends` FROM `profile` WHERE `uid` = %d AND `is_default` = 1 LIMIT 1", intval($local_uid) ); - if((count($r)) && ($r[0]['hide-friends'] == 0)) { + if((count($r)) && ($r[0]['hide_friends'] == 0)) { require_once('include/items.php'); diff --git a/mod/directory.php b/mod/directory.php index 8a5685c9a..4e7626ed5 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -61,19 +61,19 @@ function directory_content(&$a) { if($search) $search = dbesc($search); - $sql_extra = ((strlen($search)) ? " AND MATCH (`profile`.`name`, `user`.`nickname`, `pdesc`, `locality`,`region`,`country-name`,`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`,`pub_keywords`,`prv_keywords` ) AGAINST ('$search' IN BOOLEAN MODE) " : ""); + $sql_extra = ((strlen($search)) ? " AND MATCH (`profile`.`name`, `user`.`nickname`, `pdesc`, `locality`,`region`,`country_name`,`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`,`pub_keywords`,`prv_keywords` ) AGAINST ('$search' IN BOOLEAN MODE) " : ""); $publish = ((get_config('system','publish_all')) ? '' : " AND `publish` = 1 " ); - $r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra "); + $r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is_default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra "); if(count($r)) $a->set_pager_total($r[0]['total']); $order = " ORDER BY `name` ASC "; - $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra $order LIMIT %d , %d ", + $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is_default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra $order LIMIT %d , %d ", intval($a->pager['start']), intval($a->pager['itemspage']) ); @@ -99,10 +99,10 @@ function directory_content(&$a) { $details .= ', '; $details .= $rr['region']; } - if(strlen($rr['country-name'])) { + if(strlen($rr['country_name'])) { if(strlen($details)) $details .= ', '; - $details .= $rr['country-name']; + $details .= $rr['country_name']; } if(strlen($rr['dob'])) { if(($years = age($rr['dob'],$rr['timezone'],'')) != 0) @@ -127,8 +127,8 @@ function directory_content(&$a) { if((x($profile,'address') == 1) || (x($profile,'locality') == 1) || (x($profile,'region') == 1) - || (x($profile,'postal-code') == 1) - || (x($profile,'country-name') == 1)) + || (x($profile,'postal_code') == 1) + || (x($profile,'country_name') == 1)) $location = t('Location:'); $gender = ((x($profile,'gender') == 1) ? t('Gender:') : False); diff --git a/mod/hcard.php b/mod/hcard.php index 6d2d9e2eb..7a2c81c13 100644 --- a/mod/hcard.php +++ b/mod/hcard.php @@ -37,7 +37,6 @@ function hcard_init(&$a) { $a->page['htmlhead'] .= '' . "\r\n" ; } - $a->page['htmlhead'] .= '' . "\r\n" ; $a->page['htmlhead'] .= '' . "\r\n" ; $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : '')); $a->page['htmlhead'] .= '' . "\r\n"; diff --git a/mod/match.php b/mod/match.php index 926df1dff..fbe3aa91f 100644 --- a/mod/match.php +++ b/mod/match.php @@ -11,7 +11,7 @@ function match_content(&$a) { $o .= '

' . t('Profile Match') . '

'; - $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", + $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is_default` = 1 AND `uid` = %d LIMIT 1", intval(local_user()) ); if(! count($r)) diff --git a/mod/msearch.php b/mod/msearch.php index c4d69839c..e8e7d447b 100644 --- a/mod/msearch.php +++ b/mod/msearch.php @@ -10,13 +10,13 @@ function msearch_post(&$a) { if(! strlen($search)) killme(); - $r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') ", + $r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is_default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') ", dbesc($search) ); if(count($r)) $total = $r[0]['total']; - $r = q("SELECT `pub_keywords`, `username`, `nickname`, `user`.`uid` FROM `user` LEFT JOIN `profile` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') LIMIT %d , %d ", + $r = q("SELECT `pub_keywords`, `username`, `nickname`, `user`.`uid` FROM `user` LEFT JOIN `profile` ON `user`.`uid` = `profile`.`uid` WHERE `is_default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') LIMIT %d , %d ", dbesc($search), intval($startrec), intval($perpage) diff --git a/mod/poco.php b/mod/poco.php index acfa3ffaa..2a5d47909 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -33,11 +33,11 @@ function poco_init(&$a) { if(! $system_mode) { - $r = q("SELECT `user`.*,`profile`.`hide-friends` from user left join profile on `user`.`uid` = `profile`.`uid` - where `user`.`nickname` = '%s' and `profile`.`is-default` = 1 limit 1", + $r = q("SELECT `user`.*,`profile`.`hide_friends` from user left join profile on `user`.`uid` = `profile`.`uid` + where `user`.`nickname` = '%s' and `profile`.`is_default` = 1 limit 1", dbesc($user) ); - if(! count($r) || $r[0]['hidewall'] || $r[0]['hide-friends']) + if(! count($r) || $r[0]['hidewall'] || $r[0]['hide_friends']) http_status_exit(404); $user = $r[0]; diff --git a/mod/profile_photo.php b/mod/profile_photo.php index 1285bf08e..058948ef0 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -28,11 +28,11 @@ function profile_photo_post(&$a) { $is_default_profile = 1; if($_REQUEST['profile']) { - $r = q("select id, `is-default` from profile where id = %d and uid = %d limit 1", + $r = q("select id, `is_default` from profile where id = %d and uid = %d limit 1", intval($_REQUEST['profile']), intval(local_user()) ); - if(count($r) && (! intval($r[0]['is-default']))) + if(count($r) && (! intval($r[0]['is_default']))) $is_default_profile = 0; } @@ -225,7 +225,7 @@ function profile_photo_content(&$a) { // go ahead as we have jus uploaded a new photo to crop } - $profiles = q("select `id`,`profile_name` as `name`,`is-default` as `default` from profile where uid = %d", + $profiles = q("select `id`,`profile_name` as `name`,`is_default` as `default` from profile where uid = %d", intval(local_user()) ); diff --git a/mod/profiles.php b/mod/profiles.php index db063cccb..276fcaf64 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -24,7 +24,7 @@ function profiles_post(&$a) { check_form_security_token_redirectOnErr('/profiles', 'profile_edit'); - $is_default = (($orig[0]['is-default']) ? 1 : 0); + $is_default = (($orig[0]['is_default']) ? 1 : 0); $profile_name = notags(trim($_POST['profile_name'])); if(! strlen($profile_name)) { @@ -144,7 +144,7 @@ function profiles_post(&$a) { $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); + $hide_friends = (($_POST['hide_friends'] == 1) ? 1: 0); @@ -201,7 +201,7 @@ function profiles_post(&$a) { // profile but that doesn't mean we have to broadcast it to everybody. } if($locality != $orig[0]['locality'] || $region != $orig[0]['region'] - || $country_name != $orig[0]['country-name']) { + || $country_name != $orig[0]['country_name']) { $changes[] = t('Location'); $comma1 = ((($locality) && ($region || $country_name)) ? ', ' : ' '); $comma2 = (($region && $country_name) ? ', ' : ''); @@ -221,8 +221,8 @@ function profiles_post(&$a) { `address` = '%s', `locality` = '%s', `region` = '%s', - `postal-code` = '%s', - `country-name` = '%s', + `postal_code` = '%s', + `country_name` = '%s', `marital` = '%s', `with` = '%s', `howlong` = '%s', @@ -245,7 +245,7 @@ function profiles_post(&$a) { `romance` = '%s', `work` = '%s', `education` = '%s', - `hide-friends` = %d + `hide_friends` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1", dbesc($profile_name), dbesc($name), @@ -406,7 +406,7 @@ function profiles_content(&$a) { } if(($a->argc > 2) && ($a->argv[1] === "drop") && intval($a->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(local_user()) ); @@ -420,7 +420,7 @@ function profiles_content(&$a) { // move every contact using this profile as their default to the user default - $r = q("UPDATE `contact` SET `profile-id` = (SELECT `profile`.`id` AS `profile-id` FROM `profile` WHERE `profile`.`is-default` = 1 AND `profile`.`uid` = %d LIMIT 1) WHERE `profile-id` = %d AND `uid` = %d ", + $r = q("UPDATE `contact` SET `profile-id` = (SELECT `profile`.`id` AS `profile-id` FROM `profile` WHERE `profile`.`is_default` = 1 AND `profile`.`uid` = %d LIMIT 1) WHERE `profile-id` = %d AND `uid` = %d ", intval(local_user()), intval($a->argv[2]), intval(local_user()) @@ -450,7 +450,7 @@ function profiles_content(&$a) { $name = t('Profile-') . ($num_profiles + 1); - $r1 = q("SELECT `name`, `photo`, `thumb` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1", + $r1 = q("SELECT `name`, `photo`, `thumb` FROM `profile` WHERE `uid` = %d AND `is_default` = 1 LIMIT 1", intval(local_user())); $r2 = q("INSERT INTO `profile` (`uid` , `profile_name` , `name`, `photo`, `thumb`) @@ -492,9 +492,8 @@ function profiles_content(&$a) { return; } unset($r1[0]['id']); - $r1[0]['is-default'] = 0; + $r1[0]['is_default'] = 0; $r1[0]['publish'] = 0; - $r1[0]['net-publish'] = 0; $r1[0]['profile_name'] = dbesc($name); dbesc_array($r1[0]); @@ -544,13 +543,13 @@ function profiles_content(&$a) { )); - $opt_tpl = get_markup_template("profile-hide-friends.tpl"); + $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'), - '$yes_selected' => (($r[0]['hide-friends']) ? " checked=\"checked\" " : ""), - '$no_selected' => (($r[0]['hide-friends'] == 0) ? " checked=\"checked\" " : "") + '$yes_selected' => (($r[0]['hide_friends']) ? " checked=\"checked\" " : ""), + '$no_selected' => (($r[0]['hide_friends'] == 0) ? " checked=\"checked\" " : "") )); $a->page['htmlhead'] .= ""; @@ -563,7 +562,7 @@ function profiles_content(&$a) { if(! $f) $f = 'ymd'; - $is_default = (($r[0]['is-default']) ? 1 : 0); + $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"), @@ -623,8 +622,8 @@ function profiles_content(&$a) { '$address' => $r[0]['address'], '$locality' => $r[0]['locality'], '$region' => $r[0]['region'], - '$postal_code' => $r[0]['postal-code'], - '$country_name' => $r[0]['country-name'], + '$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']), @@ -679,7 +678,7 @@ function profiles_content(&$a) { '$id' => $rr['id'], '$alt' => t('Profile Image'), '$profile_name' => $rr['profile_name'], - '$visible' => (($rr['is-default']) ? '' . t('visible to everybody') . '' + '$visible' => (($rr['is_default']) ? '' . t('visible to everybody') . '' : '' . t('Edit visibility') . '') )); } diff --git a/mod/profperm.php b/mod/profperm.php index c7ab45324..d29581beb 100644 --- a/mod/profperm.php +++ b/mod/profperm.php @@ -47,7 +47,7 @@ function profperm_content(&$a) { if(($a->argc > 1) && (intval($a->argv[1]))) { - $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[1]), intval(local_user()) ); diff --git a/mod/regmod.php b/mod/regmod.php index 21f41eb01..120d21cae 100644 --- a/mod/regmod.php +++ b/mod/regmod.php @@ -28,10 +28,10 @@ function user_allow($hash) { intval($register[0]['uid']) ); - $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1", + $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is_default` = 1", intval($user[0]['uid']) ); - if(count($r) && $r[0]['net-publish']) { + if(count($r) && $r[0]['publish']) { $url = $a->get_baseurl() . '/profile/' . $user[0]['nickname']; if($url && strlen(get_config('system','directory_submit_url'))) proc_run('php',"include/directory.php","$url"); diff --git a/mod/settings.php b/mod/settings.php index 478158b68..0699e94d8 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -251,7 +251,7 @@ function settings_post(&$a) { $unkmail = (((x($_POST,'unkmail')) && (intval($_POST['unkmail']) == 1)) ? 1: 0); $cntunkmail = ((x($_POST,'cntunkmail')) ? intval($_POST['cntunkmail']) : 0); $suggestme = ((x($_POST,'suggestme')) ? intval($_POST['suggestme']) : 0); - $hide_friends = (($_POST['hide-friends'] == 1) ? 1: 0); + $hide_friends = (($_POST['hide_friends'] == 1) ? 1: 0); $hidewall = (($_POST['hidewall'] == 1) ? 1: 0); $post_newfriend = (($_POST['post_newfriend'] == 1) ? 1: 0); $post_joingroup = (($_POST['post_joingroup'] == 1) ? 1: 0); @@ -387,11 +387,9 @@ function settings_post(&$a) { $r = q("UPDATE `profile` SET `publish` = %d, - `net-publish` = %d, - `hide-friends` = %d - WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", + `hide_friends` = %d + WHERE `is_default` = 1 AND `uid` = %d LIMIT 1", intval($publish), - intval($net_publish), intval($hide_friends), intval(local_user()) ); @@ -636,7 +634,7 @@ function settings_content(&$a) { require_once('include/acl_selectors.php'); - $p = q("SELECT * FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", + $p = q("SELECT * FROM `profile` WHERE `is_default` = 1 AND `uid` = %d LIMIT 1", intval(local_user()) ); if(count($p)) @@ -727,17 +725,11 @@ function settings_content(&$a) { )); } - if(strlen(get_config('system','directory_submit_url'))) { - $profile_in_net_dir = replace_macros($opt_tpl,array( - '$field' => array('profile_in_netdirectory', t('Publish your default profile in the global social directory?'), $profile['net-publish'], '', array(t('No'),t('Yes'))), - )); - } - else - $profile_in_net_dir = ''; + $profile_in_net_dir = ''; $hide_friends = replace_macros($opt_tpl,array( - '$field' => array('hide-friends', t('Hide your contact/friend list from viewers of your default profile?'), $profile['hide-friends'], '', array(t('No'),t('Yes'))), + '$field' => array('hide_friends', t('Hide your contact/friend list from viewers of your default profile?'), $profile['hide_friends'], '', array(t('No'),t('Yes'))), )); $hide_wall = replace_macros($opt_tpl,array( @@ -768,8 +760,7 @@ function settings_content(&$a) { )); - $invisible = (((! $profile['publish']) && (! $profile['net-publish'])) - ? true : false); + $invisible = ((! $profile['publish']) ? true : false); if($invisible) info( t('Profile is not published.') . EOL ); diff --git a/mod/viewcontacts.php b/mod/viewcontacts.php index 8e261e711..3c595567f 100644 --- a/mod/viewcontacts.php +++ b/mod/viewcontacts.php @@ -18,7 +18,7 @@ function viewcontacts_content(&$a) { return; } - if(((! count($a->profile)) || ($a->profile['hide-friends']))) { + if(((! count($a->profile)) || ($a->profile['hide_friends']))) { notice( t('Permission denied.') . EOL); return; } diff --git a/mod/viewsrc.php b/mod/viewsrc.php index 3fa4eaed5..bc7f771d6 100644 --- a/mod/viewsrc.php +++ b/mod/viewsrc.php @@ -8,7 +8,7 @@ function viewsrc_content(&$a) { return; } - $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); + $item_id = ((argc() > 1) ? intval(argv(1)) : 0); if(! $item_id) { $a->error = 404; @@ -19,18 +19,18 @@ function viewsrc_content(&$a) { $r = q("SELECT `item`.`body` FROM `item` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 - AND `item`.`id` = '%s' LIMIT 1", + AND `item`.`id` = %d LIMIT 1", intval(local_user()), - dbesc($item_id) + intval($item_id) ); - if(count($r)) + if(count($r)) { + $o = str_replace("\n",'
',$r[0]['body']); if(is_ajax()) { - echo str_replace("\n",'
',$r[0]['body']); + echo $o; killme(); - } else { - $o .= str_replace("\n",'
',$r[0]['body']); - } + } + } return $o; } diff --git a/mod/zfinger.php b/mod/zfinger.php index 5b02d4695..550d613b5 100644 --- a/mod/zfinger.php +++ b/mod/zfinger.php @@ -33,6 +33,17 @@ function zfinger_init(&$a) { $e = $r[0]; + $id = $e['entity_id']; + $r = q("select contact.*, profile.* + from contact left join profile on contact.uid = profile.uid + where contact.uid = %d && contact.self = 1 and profile.is_default = 1 limit 1", + intval($id) + ); + if($r && count($r)) { + $profile = $r[0]; + } + + $ret['success'] = true; // Communication details @@ -43,6 +54,8 @@ function zfinger_init(&$a) { $ret['name'] = $e['entity_name']; $ret['address'] = $e['entity_address']; + $ret['profile'] = $profile; + // array of (verified) hubs this entity uses $ret['hubs'] = array(); @@ -61,9 +74,6 @@ function zfinger_init(&$a) { } } - - // more stuff, e.g. the basic public profile - json_return_and_die($ret); } \ No newline at end of file -- cgit v1.2.3