X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fprofiles.php;h=32ed24346fdd69d42721b69035c72fd379d3a3e6;hb=034d46196f0ceb99b0e5b42fefdc88c4d5b852a7;hp=7d2bceec1ac6b593447a7abd470036610fc9943e;hpb=6680ce1dd77b5b4b6fbfcd6d5b58b65710e52079;p=friendica.git diff --git a/mod/profiles.php b/mod/profiles.php index 7d2bceec1a..32ed24346f 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -1,13 +1,23 @@ argv[2]), intval(local_user()) ); - if (! dbm::is_result($r)) { + if (! DBM::is_result($r)) { notice( t('Profile not found.') . EOL); goaway('profiles'); return; // NOTREACHED @@ -37,7 +47,7 @@ function profiles_init(App $a) { intval($a->argv[2]), intval(local_user()) ); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { info(t('Profile deleted.').EOL); } @@ -52,7 +62,7 @@ function profiles_init(App $a) { $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d", intval(local_user())); - $num_profiles = (dbm::is_result($r0) ? count($r0) : 0); + $num_profiles = (DBM::is_result($r0) ? count($r0) : 0); $name = t('Profile-') . ($num_profiles + 1); @@ -74,7 +84,7 @@ function profiles_init(App $a) { ); info( t('New profile created.') . EOL); - if (dbm::is_result($r3) && count($r3) == 1) { + if (DBM::is_result($r3) && count($r3) == 1) { goaway('profiles/' . $r3[0]['id']); } @@ -88,14 +98,14 @@ function profiles_init(App $a) { $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d", intval(local_user())); - $num_profiles = (dbm::is_result($r0) ? count($r0) : 0); + $num_profiles = (DBM::is_result($r0) ? count($r0) : 0); $name = t('Profile-') . ($num_profiles + 1); $r1 = q("SELECT * FROM `profile` WHERE `uid` = %d AND `id` = %d LIMIT 1", intval(local_user()), intval($a->argv[2]) ); - if(! dbm::is_result($r1)) { + if(! DBM::is_result($r1)) { notice( t('Profile unavailable to clone.') . EOL); killme(); return; @@ -106,20 +116,14 @@ function profiles_init(App $a) { $r1[0]['net-publish'] = 0; $r1[0]['profile-name'] = dbesc($name); - dbm::esc_array($r1[0], true); - - $r2 = dbq("INSERT INTO `profile` (`" - . implode("`, `", array_keys($r1[0])) - . "`) VALUES (" - . implode(", ", array_values($r1[0])) - . ")" ); + dba::insert('profile', $r1[0]); $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1", intval(local_user()), dbesc($name) ); info( t('New profile created.') . EOL); - if ((dbm::is_result($r3)) && (count($r3) == 1)) { + if ((DBM::is_result($r3)) && (count($r3) == 1)) { goaway('profiles/'.$r3[0]['id']); } @@ -134,13 +138,13 @@ function profiles_init(App $a) { intval($a->argv[1]), intval(local_user()) ); - if (! dbm::is_result($r)) { + if (! DBM::is_result($r)) { notice( t('Profile not found.') . EOL); killme(); return; } - profile_load($a,$a->user['nickname'], $r[0]['id']); + Profile::load($a, $a->user['nickname'], $r[0]['id']); } @@ -151,7 +155,7 @@ function profile_clean_keywords($keywords) { $keywords = str_replace(",", " ", $keywords); $keywords = explode(" ", $keywords); - $cleaned = array(); + $cleaned = []; foreach ($keywords as $keyword) { $keyword = trim(strtolower($keyword)); $keyword = trim($keyword, "#"); @@ -181,7 +185,7 @@ function profiles_post(App $a) { intval($a->argv[1]), intval(local_user()) ); - if (! dbm::is_result($orig)) { + if (! DBM::is_result($orig)) { notice( t('Profile not found.') . EOL); return; } @@ -204,7 +208,7 @@ function profiles_post(App $a) { } else { $ignore_year = false; } - if (!in_array($dob, array('0000-00-00', '0001-01-01'))) { + if (!in_array($dob, ['0000-00-00', '0001-01-01'])) { if (strpos($dob, '0000-') === 0 || strpos($dob, '0001-') === 0) { $ignore_year = true; $dob = substr($dob, 5); @@ -275,13 +279,13 @@ function profiles_post(App $a) { dbesc($newname), intval(local_user()) ); - if (! dbm::is_result($r)) { + if (! DBM::is_result($r)) { $r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1", dbesc($lookup), intval(local_user()) ); } - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { $prf = $r[0]['url']; $newname = $r[0]['name']; } @@ -326,9 +330,9 @@ function profiles_post(App $a) { $hide_friends = (($_POST['hide-friends'] == 1) ? 1: 0); - set_pconfig(local_user(), 'system', 'detailled_profile', (($_POST['detailled_profile'] == 1) ? 1: 0)); + PConfig::set(local_user(), 'system', 'detailled_profile', (($_POST['detailled_profile'] == 1) ? 1: 0)); - $changes = array(); + $changes = []; $value = ''; if ($is_default) { if ($marital != $orig[0]['marital']) { @@ -488,7 +492,7 @@ function profiles_post(App $a) { } if ($is_default) { - $location = formatted_location(array("locality" => $locality, "region" => $region, "country-name" => $country_name)); + $location = Profile::formatLocation(["locality" => $locality, "region" => $region, "country-name" => $country_name]); q("UPDATE `contact` SET `about` = '%s', `location` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `self` AND `uid` = %d", dbesc($about), @@ -500,15 +504,14 @@ function profiles_post(App $a) { // Update global directory in background $url = $_SESSION['my_url']; - if ($url && strlen(get_config('system', 'directory'))) { - proc_run(PRIORITY_LOW, "include/directory.php", $url); + if ($url && strlen(Config::get('system', 'directory'))) { + Worker::add(PRIORITY_LOW, "Directory", $url); } - require_once 'include/profile_update.php'; - profile_change(); + Worker::add(PRIORITY_LOW, 'ProfileUpdate', local_user()); // Update the global contact for the user - update_gcontact_for_user(local_user()); + GContact::updateForUser(local_user()); } } } @@ -521,11 +524,11 @@ function profile_activity($changed, $value) { return; } - if ($a->user['hidewall'] || get_config('system', 'block_public')) { + if ($a->user['hidewall'] || Config::get('system', 'block_public')) { return; } - if (! get_pconfig(local_user(), 'system', 'post_profilechange')) { + if (! PConfig::get(local_user(), 'system', 'post_profilechange')) { return; } @@ -535,11 +538,11 @@ function profile_activity($changed, $value) { intval(local_user()) ); - if (! dbm::is_result($self)) { + if (! DBM::is_result($self)) { return; } - $arr = array(); + $arr = []; $arr['guid'] = get_guid(32); $arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), local_user()); @@ -590,7 +593,6 @@ function profile_activity($changed, $value) { $arr['object'] .= '' . xmlify('' . "\n"); $arr['object'] .= xmlify('' . "\n"); $arr['object'] .= '' . "\n"; - $arr['last-child'] = 1; $arr['allow_cid'] = $a->user['allow_cid']; $arr['allow_gid'] = $a->user['allow_gid']; @@ -599,7 +601,7 @@ function profile_activity($changed, $value) { $i = item_store($arr); if ($i) { - proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i); + Worker::add(PRIORITY_HIGH, "Notifier", "activity", $i); } } @@ -618,65 +620,57 @@ function profiles_content(App $a) { intval($a->argv[1]), intval(local_user()) ); - if (! dbm::is_result($r)) { + if (! DBM::is_result($r)) { notice( t('Profile not found.') . EOL); return; } - require_once 'include/profile_selectors.php'; - - - $a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array( - '$baseurl' => App::get_baseurl(true), - )); - $a->page['end'] .= replace_macros(get_markup_template('profed_end.tpl'), array( - '$baseurl' => App::get_baseurl(true), - )); + $a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), [ + '$baseurl' => System::baseUrl(true), + ]); + $a->page['end'] .= replace_macros(get_markup_template('profed_end.tpl'), [ + '$baseurl' => System::baseUrl(true), + ]); $opt_tpl = get_markup_template("profile-hide-friends.tpl"); - $hide_friends = replace_macros($opt_tpl,array( - '$yesno' => array( + $hide_friends = replace_macros($opt_tpl,[ + '$yesno' => [ 'hide-friends', //Name t('Hide contacts and friends:'), //Label !!$r[0]['hide-friends'], //Value '', //Help string - array(t('No'), t('Yes')) //Off - On strings - ), + [t('No'), t('Yes')] //Off - On strings + ], '$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\" " : "") - )); + ]); $personal_account = !(in_array($a->user["page-flags"], - array(PAGE_COMMUNITY, PAGE_PRVGROUP))); - - $detailled_profile = (get_pconfig(local_user(), 'system', 'detailled_profile') AND $personal_account); + [PAGE_COMMUNITY, PAGE_PRVGROUP])); - $f = get_config('system', 'birthday_input_format'); - if (! $f) { - $f = 'ymd'; - } + $detailled_profile = (PConfig::get(local_user(), 'system', 'detailled_profile') AND $personal_account); $is_default = (($r[0]['is-default']) ? 1 : 0); $tpl = get_markup_template("profile_edit.tpl"); - $o .= replace_macros($tpl, array( + $o .= replace_macros($tpl, [ '$personal_account' => $personal_account, '$detailled_profile' => $detailled_profile, - '$details' => array( + '$details' => [ 'detailled_profile', //Name t('Show more profile fields:'), //Label $detailled_profile, //Value '', //Help string - array(t('No'), t('Yes')) //Off - On strings - ), + [t('No'), t('Yes')] //Off - On strings + ], - '$multi_profiles' => feature_enabled(local_user(), 'multi_profiles'), + '$multi_profiles' => Feature::isEnabled(local_user(), 'multi_profiles'), '$form_security_token' => get_form_security_token("profile_edit"), '$form_security_token_photo' => get_form_security_token("profile_photo"), - '$profile_clone_link' => ((feature_enabled(local_user(), 'multi_profiles')) ? 'profiles/clone/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_clone") : ""), + '$profile_clone_link' => ((Feature::isEnabled(local_user(), 'multi_profiles')) ? '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_action' => t('Profile Actions'), @@ -707,59 +701,58 @@ function profiles_content(App $a) { '$lbl_ex2' => t('Example: fishing photography software'), '$disabled' => (($is_default) ? 'onclick="return false;" style="color: #BBBBFF;"' : ''), - '$baseurl' => App::get_baseurl(true), + '$baseurl' => System::baseUrl(true), '$profile_id' => $r[0]['id'], - '$profile_name' => array('profile_name', t('Profile Name:'), $r[0]['profile-name'], t('Required'), '*'), + '$profile_name' => ['profile_name', t('Profile Name:'), $r[0]['profile-name'], t('Required'), '*'], '$is_default' => $is_default, '$default' => (($is_default) ? '
' . t('This is your public profile.
It may be visible to anybody using the internet.') . '