diff --git a/boot.php b/boot.php
index 6b6d065ad..2fe73bc81 100644
--- a/boot.php
+++ b/boot.php
@@ -37,7 +37,6 @@ require_once 'include/text.php';
require_once 'include/datetime.php';
require_once 'include/pgettext.php';
require_once 'include/nav.php';
-require_once 'include/identity.php';
define('FRIENDICA_PLATFORM', 'Friendica');
define('FRIENDICA_CODENAME', 'Asparagus');
diff --git a/include/contact_widgets.php b/include/contact_widgets.php
index aa1bc2436..f8fb80c59 100644
--- a/include/contact_widgets.php
+++ b/include/contact_widgets.php
@@ -9,6 +9,7 @@ use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Database\DBM;
use Friendica\Model\GContact;
+use Friendica\Model\Profile;
function follow_widget($value = "")
{
@@ -223,13 +224,13 @@ function common_friends_visitor_widget($profile_uid)
}
if (!$cid) {
- if (get_my_url()) {
+ if (Profile::getMyURL()) {
$contact = dba::selectFirst('contact', ['id'],
- ['nurl' => normalise_link(get_my_url()), 'uid' => $profile_uid]);
+ ['nurl' => normalise_link(Profile::getMyURL()), 'uid' => $profile_uid]);
if (DBM::is_result($contact)) {
$cid = $contact['id'];
} else {
- $gcontact = dba::selectFirst('gcontact', ['id'], ['nurl' => normalise_link(get_my_url())]);
+ $gcontact = dba::selectFirst('gcontact', ['id'], ['nurl' => normalise_link(Profile::getMyURL())]);
if (DBM::is_result($gcontact)) {
$zcid = $gcontact['id'];
}
diff --git a/include/conversation.php b/include/conversation.php
index 0e45de558..80ea6a900 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -10,6 +10,7 @@ use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
+use Friendica\Model\Profile;
use Friendica\Object\Thread;
use Friendica\Object\Post;
@@ -194,10 +195,10 @@ function localize_item(&$item) {
}
}
- $A = '[url=' . zrl($Alink) . ']' . $Aname . '[/url]';
- $B = '[url=' . zrl($Blink) . ']' . $Bname . '[/url]';
+ $A = '[url=' . Profile::zrl($Alink) . ']' . $Aname . '[/url]';
+ $B = '[url=' . Profile::zrl($Blink) . ']' . $Bname . '[/url]';
if ($Bphoto != "") {
- $Bphoto = '[url=' . zrl($Blink) . '][img]' . $Bphoto . '[/img][/url]';
+ $Bphoto = '[url=' . Profile::zrl($Blink) . '][img]' . $Bphoto . '[/img][/url]';
}
$item['body'] = sprintf( t('%1$s is now friends with %2$s'), $A, $B)."\n\n\n".$Bphoto;
@@ -231,10 +232,10 @@ function localize_item(&$item) {
}
}
- $A = '[url=' . zrl($Alink) . ']' . $Aname . '[/url]';
- $B = '[url=' . zrl($Blink) . ']' . $Bname . '[/url]';
+ $A = '[url=' . Profile::zrl($Alink) . ']' . $Aname . '[/url]';
+ $B = '[url=' . Profile::zrl($Blink) . ']' . $Bname . '[/url]';
if ($Bphoto != "") {
- $Bphoto = '[url=' . zrl($Blink) . '][img=80x80]' . $Bphoto . '[/img][/url]';
+ $Bphoto = '[url=' . Profile::zrl($Blink) . '][img=80x80]' . $Bphoto . '[/img][/url]';
}
/*
@@ -266,8 +267,8 @@ function localize_item(&$item) {
$obj = $r[0];
- $author = '[url=' . zrl($item['author-link']) . ']' . $item['author-name'] . '[/url]';
- $objauthor = '[url=' . zrl($obj['author-link']) . ']' . $obj['author-name'] . '[/url]';
+ $author = '[url=' . Profile::zrl($item['author-link']) . ']' . $item['author-name'] . '[/url]';
+ $objauthor = '[url=' . Profile::zrl($obj['author-link']) . ']' . $obj['author-name'] . '[/url]';
switch ($obj['verb']) {
case ACTIVITY_POST:
@@ -320,8 +321,8 @@ function localize_item(&$item) {
$target = $r[0];
$Bname = $target['author-name'];
$Blink = $target['author-link'];
- $A = '[url=' . zrl($Alink) . ']' . $Aname . '[/url]';
- $B = '[url=' . zrl($Blink) . ']' . $Bname . '[/url]';
+ $A = '[url=' . Profile::zrl($Alink) . ']' . $Aname . '[/url]';
+ $B = '[url=' . Profile::zrl($Blink) . ']' . $Bname . '[/url]';
$P = '[url=' . $target['plink'] . ']' . t('post/item') . '[/url]';
$item['body'] = sprintf( t('%1$s marked %2$s\'s %3$s as favorite'), $A, $B, $P)."\n";
}
@@ -331,7 +332,7 @@ function localize_item(&$item) {
if (preg_match_all('/@\[url=(.*?)\]/is', $item['body'], $matches, PREG_SET_ORDER)) {
foreach ($matches as $mtch) {
if (! strpos($mtch[1], 'zrl=')) {
- $item['body'] = str_replace($mtch[0], '@[url=' . zrl($mtch[1]) . ']', $item['body']);
+ $item['body'] = str_replace($mtch[0], '@[url=' . Profile::zrl($mtch[1]) . ']', $item['body']);
}
}
}
@@ -339,7 +340,7 @@ function localize_item(&$item) {
// add zrl's to public images
$photo_pattern = "/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is";
if (preg_match($photo_pattern, $item['body'])) {
- $photo_replace = '[url=' . zrl('$1' . '/photos/' . '$2' . '/image/' . '$3' ,true) . '][img' . '$4' . ']h' . '$5' . '[/img][/url]';
+ $photo_replace = '[url=' . Profile::zrl('$1' . '/photos/' . '$2' . '/image/' . '$3' ,true) . '][img' . '$4' . ']h' . '$5' . '[/img][/url]';
$item['body'] = bb_tag_preg_replace($photo_pattern, $photo_replace, 'url', $item['body']);
}
@@ -709,7 +710,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
if ($sp) {
$sparkle = ' sparkle';
} else {
- $profile_link = zrl($profile_link);
+ $profile_link = Profile::zrl($profile_link);
}
if (!x($item, 'author-thumb') || ($item['author-thumb'] == "")) {
@@ -1037,7 +1038,7 @@ function item_photo_menu($item) {
$photos_link = $profile_link . '?url=photos';
$profile_link = $profile_link . '?url=profile';
} else {
- $profile_link = zrl($profile_link);
+ $profile_link = Profile::zrl($profile_link);
}
if ($cid && !$item['self']) {
@@ -1130,7 +1131,7 @@ function builtin_activity_puller($item, &$conv_responses) {
$url = 'redir/' . $item['contact-id'];
$sparkle = ' class="sparkle" ';
} else {
- $url = zrl($url);
+ $url = Profile::zrl($url);
}
$url = '' . htmlentities($item['author-name']) . '';
diff --git a/include/event.php b/include/event.php
index a9b82ed50..b8b60a86d 100644
--- a/include/event.php
+++ b/include/event.php
@@ -9,6 +9,7 @@ use Friendica\Content\Feature;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBM;
+use Friendica\Model\Profile;
use Friendica\Util\Map;
require_once 'include/bbcode.php';
@@ -964,7 +965,7 @@ function format_event_item($item) {
$profile_link = best_link_url($item, $sp);
if (!$sp) {
- $profile_link = zrl($profile_link);
+ $profile_link = Profile::zrl($profile_link);
}
$event = replace_macros(get_markup_template('event_stream_item.tpl'), array(
diff --git a/include/identity.php b/include/identity.php
deleted file mode 100644
index f370a9aec..000000000
--- a/include/identity.php
+++ /dev/null
@@ -1,984 +0,0 @@
-query_string, LOGGER_DEBUG);
- notice(t('Requested account is not available.') . EOL);
- $a->error = 404;
- return;
- }
-
- if (!x($a->page, 'aside')) {
- $a->page['aside'] = '';
- }
-
- if ($profiledata) {
- $a->page['aside'] .= profile_sidebar($profiledata, true, $show_connect);
-
- if (!DBM::is_result($user)) {
- return;
- }
- }
-
- $pdata = get_profiledata_by_nick($nickname, $user[0]['uid'], $profile);
-
- if (empty($pdata) && empty($profiledata)) {
- logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
- notice(t('Requested profile is not available.') . EOL);
- $a->error = 404;
- return;
- }
-
- // fetch user tags if this isn't the default profile
-
- if (!$pdata['is-default']) {
- $x = q(
- "SELECT `pub_keywords` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1",
- intval($pdata['profile_uid'])
- );
- if ($x && count($x)) {
- $pdata['pub_keywords'] = $x[0]['pub_keywords'];
- }
- }
-
- $a->profile = $pdata;
- $a->profile_uid = $pdata['profile_uid'];
-
- $a->profile['mobile-theme'] = PConfig::get($a->profile['profile_uid'], 'system', 'mobile_theme');
- $a->profile['network'] = NETWORK_DFRN;
-
- $a->page['title'] = $a->profile['name'] . ' @ ' . $a->config['sitename'];
-
- if (!$profiledata && !PConfig::get(local_user(), 'system', 'always_my_theme')) {
- $_SESSION['theme'] = $a->profile['theme'];
- }
-
- $_SESSION['mobile-theme'] = $a->profile['mobile-theme'];
-
- /*
- * load/reload current theme info
- */
-
- $a->set_template_engine(); // reset the template engine to the default in case the user's theme doesn't specify one
-
- $theme_info_file = 'view/theme/' . current_theme() . '/theme.php';
- if (file_exists($theme_info_file)) {
- require_once $theme_info_file;
- }
-
- if (!x($a->page, 'aside')) {
- $a->page['aside'] = '';
- }
-
- if (local_user() && local_user() == $a->profile['uid'] && $profiledata) {
- $a->page['aside'] .= replace_macros(
- get_markup_template('profile_edlink.tpl'), array(
- '$editprofile' => t('Edit profile'),
- '$profid' => $a->profile['id']
- )
- );
- }
-
- $block = ((Config::get('system', 'block_public') && !local_user() && !remote_user()) ? true : false);
-
- /**
- * @todo
- * By now, the contact block isn't shown, when a different profile is given
- * But: When this profile was on the same server, then we could display the contacts
- */
- if (!$profiledata) {
- $a->page['aside'] .= profile_sidebar($a->profile, $block, $show_connect);
- }
-
- return;
-}
-
-/**
- * @brief Get all profil data of a local user
- *
- * If the viewer is an authenticated remote viewer, the profile displayed is the
- * one that has been configured for his/her viewing in the Contact manager.
- * Passing a non-zero profile ID can also allow a preview of a selected profile
- * by the owner
- *
- * Includes all available profile data
- *
- * @param string $nickname nick
- * @param int $uid uid
- * @param int $profile_id ID of the profile
- * @returns array
- */
-function get_profiledata_by_nick($nickname, $uid = 0, $profile_id = 0)
-{
- if (remote_user() && count($_SESSION['remote'])) {
- foreach ($_SESSION['remote'] as $visitor) {
- if ($visitor['uid'] == $uid) {
- $contact = dba::selectFirst('contact', ['profile-id'], ['id' => $visitor['cid']]);
- if (DBM::is_result($contact)) {
- $profile_id = $contact['profile-id'];
- }
- break;
- }
- }
- }
-
- $profile = null;
-
- if ($profile_id) {
- $profile = dba::fetch_first(
- "SELECT `contact`.`id` AS `contact_id`, `contact`.`photo` AS `contact_photo`,
- `contact`.`thumb` AS `contact_thumb`, `contact`.`micro` AS `contact_micro`,
- `profile`.`uid` AS `profile_uid`, `profile`.*,
- `contact`.`avatar-date` AS picdate, `contact`.`addr`, `contact`.`url`, `user`.*
- FROM `profile`
- INNER JOIN `contact` on `contact`.`uid` = `profile`.`uid` AND `contact`.`self`
- INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
- WHERE `user`.`nickname` = ? AND `profile`.`id` = ? LIMIT 1",
- $nickname,
- intval($profile_id)
- );
- }
- if (!DBM::is_result($profile)) {
- $profile = dba::fetch_first(
- "SELECT `contact`.`id` AS `contact_id`, `contact`.`photo` as `contact_photo`,
- `contact`.`thumb` AS `contact_thumb`, `contact`.`micro` AS `contact_micro`,
- `profile`.`uid` AS `profile_uid`, `profile`.*,
- `contact`.`avatar-date` AS picdate, `contact`.`addr`, `contact`.`url`, `user`.*
- FROM `profile`
- INNER JOIN `contact` ON `contact`.`uid` = `profile`.`uid` AND `contact`.`self`
- INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
- WHERE `user`.`nickname` = ? AND `profile`.`is-default` LIMIT 1",
- $nickname
- );
- }
-
- return $profile;
-}
-
-/**
- * @brief Formats a profile for display in the sidebar.
- *
- * It is very difficult to templatise the HTML completely
- * because of all the conditional logic.
- *
- * @param array $profile
- * @param int $block
- * @param boolean $show_connect Show connect link
- *
- * @return HTML string suitable for sidebar inclusion
- *
- * @note Returns empty string if passed $profile is wrong type or not populated
- *
- * @hooks 'profile_sidebar_enter'
- * array $profile - profile data
- * @hooks 'profile_sidebar'
- * array $arr
- */
-function profile_sidebar($profile, $block = 0, $show_connect = true)
-{
- $a = get_app();
-
- $o = '';
- $location = false;
-
- // This function can also use contact information in $profile
- $is_contact = x($profile, 'cid');
-
- if (!is_array($profile) && !count($profile)) {
- return $o;
- }
-
- $profile['picdate'] = urlencode(defaults($profile, 'picdate', ''));
-
- if (($profile['network'] != '') && ($profile['network'] != NETWORK_DFRN)) {
- $profile['network_name'] = format_network_name($profile['network'], $profile['url']);
- } else {
- $profile['network_name'] = '';
- }
-
- call_hooks('profile_sidebar_enter', $profile);
-
-
- // don't show connect link to yourself
- $connect = $profile['uid'] != local_user() ? t('Connect') : false;
-
- // don't show connect link to authenticated visitors either
- if (remote_user() && count($_SESSION['remote'])) {
- foreach ($_SESSION['remote'] as $visitor) {
- if ($visitor['uid'] == $profile['uid']) {
- $connect = false;
- break;
- }
- }
- }
-
- if (!$show_connect) {
- $connect = false;
- }
-
- // Is the local user already connected to that user?
- if ($connect && local_user()) {
- if (isset($profile['url'])) {
- $profile_url = normalise_link($profile['url']);
- } else {
- $profile_url = normalise_link(System::baseUrl() . '/profile/' . $profile['nickname']);
- }
-
- if (dba::exists('contact', array('pending' => false, 'uid' => local_user(), 'nurl' => $profile_url))) {
- $connect = false;
- }
- }
-
- if ($connect && ($profile['network'] != NETWORK_DFRN) && !isset($profile['remoteconnect'])) {
- $connect = false;
- }
-
- $remoteconnect = null;
- if (isset($profile['remoteconnect'])) {
- $remoteconnect = $profile['remoteconnect'];
- }
-
- if ($connect && ($profile['network'] == NETWORK_DFRN) && !isset($remoteconnect)) {
- $subscribe_feed = t('Atom feed');
- } else {
- $subscribe_feed = false;
- }
-
- if (remote_user() || (get_my_url() && x($profile, 'unkmail') && ($profile['uid'] != local_user()))) {
- $wallmessage = t('Message');
- $wallmessage_link = 'wallmessage/' . $profile['nickname'];
-
- if (remote_user()) {
- $r = q(
- "SELECT `url` FROM `contact` WHERE `uid` = %d AND `id` = '%s' AND `rel` = %d",
- intval($profile['uid']),
- intval(remote_user()),
- intval(CONTACT_IS_FRIEND)
- );
- } else {
- $r = q(
- "SELECT `url` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `rel` = %d",
- intval($profile['uid']),
- dbesc(normalise_link(get_my_url())),
- intval(CONTACT_IS_FRIEND)
- );
- }
- if ($r) {
- $remote_url = $r[0]['url'];
- $message_path = preg_replace('=(.*)/profile/(.*)=ism', '$1/message/new/', $remote_url);
- $wallmessage_link = $message_path . base64_encode($profile['addr']);
- }
- } else {
- $wallmessage = false;
- $wallmessage_link = false;
- }
-
- // show edit profile to yourself
- if (!$is_contact && $profile['uid'] == local_user() && Feature::isEnabled(local_user(), 'multi_profiles')) {
- $profile['edit'] = array(System::baseUrl() . '/profiles', t('Profiles'), '', t('Manage/edit profiles'));
- $r = q(
- "SELECT * FROM `profile` WHERE `uid` = %d",
- local_user()
- );
-
- $profile['menu'] = array(
- 'chg_photo' => t('Change profile photo'),
- 'cr_new' => t('Create New Profile'),
- 'entries' => array(),
- );
-
- if (DBM::is_result($r)) {
- foreach ($r as $rr) {
- $profile['menu']['entries'][] = array(
- 'photo' => $rr['thumb'],
- 'id' => $rr['id'],
- 'alt' => t('Profile Image'),
- 'profile_name' => $rr['profile-name'],
- 'isdefault' => $rr['is-default'],
- 'visibile_to_everybody' => t('visible to everybody'),
- 'edit_visibility' => t('Edit visibility'),
- );
- }
- }
- }
- if (!$is_contact && $profile['uid'] == local_user() && !Feature::isEnabled(local_user(), 'multi_profiles')) {
- $profile['edit'] = array(System::baseUrl() . '/profiles/' . $profile['id'], t('Edit profile'), '', t('Edit profile'));
- $profile['menu'] = array(
- 'chg_photo' => t('Change profile photo'),
- 'cr_new' => null,
- 'entries' => array(),
- );
- }
-
- // Fetch the account type
- $account_type = Contact::getAccountType($profile);
-
- if (x($profile, 'address')
- || x($profile, 'location')
- || x($profile, 'locality')
- || x($profile, 'region')
- || x($profile, 'postal-code')
- || x($profile, 'country-name')
- ) {
- $location = t('Location:');
- }
-
- $gender = x($profile, 'gender') ? t('Gender:') : false;
- $marital = x($profile, 'marital') ? t('Status:') : false;
- $homepage = x($profile, 'homepage') ? t('Homepage:') : false;
- $about = x($profile, 'about') ? t('About:') : false;
- $xmpp = x($profile, 'xmpp') ? t('XMPP:') : false;
-
- if ((x($profile, 'hidewall') || $block) && !local_user() && !remote_user()) {
- $location = $gender = $marital = $homepage = $about = false;
- }
-
- $split_name = Diaspora::splitName($profile['name']);
- $firstname = $split_name['first'];
- $lastname = $split_name['last'];
-
- if (x($profile, 'guid')) {
- $diaspora = array(
- 'guid' => $profile['guid'],
- 'podloc' => System::baseUrl(),
- 'searchable' => (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false' ),
- 'nickname' => $profile['nickname'],
- 'fullname' => $profile['name'],
- 'firstname' => $firstname,
- 'lastname' => $lastname,
- 'photo300' => $profile['contact_photo'],
- 'photo100' => $profile['contact_thumb'],
- 'photo50' => $profile['contact_micro'],
- );
- } else {
- $diaspora = false;
- }
-
- $contact_block = '';
- $updated = '';
- $contacts = 0;
- if (!$block) {
- $contact_block = contact_block();
-
- if (is_array($a->profile) && !$a->profile['hide-friends']) {
- $r = q(
- "SELECT `gcontact`.`updated` FROM `contact` INNER JOIN `gcontact` WHERE `gcontact`.`nurl` = `contact`.`nurl` AND `self` AND `uid` = %d LIMIT 1",
- intval($a->profile['uid'])
- );
- if (DBM::is_result($r)) {
- $updated = date('c', strtotime($r[0]['updated']));
- }
-
- $r = q(
- "SELECT COUNT(*) AS `total` FROM `contact`
- WHERE `uid` = %d
- AND NOT `self` AND NOT `blocked` AND NOT `pending`
- AND NOT `hidden` AND NOT `archive`
- AND `network` IN ('%s', '%s', '%s', '')",
- intval($profile['uid']),
- dbesc(NETWORK_DFRN),
- dbesc(NETWORK_DIASPORA),
- dbesc(NETWORK_OSTATUS)
- );
- if (DBM::is_result($r)) {
- $contacts = intval($r[0]['total']);
- }
- }
- }
-
- $p = array();
- foreach ($profile as $k => $v) {
- $k = str_replace('-', '_', $k);
- $p[$k] = $v;
- }
-
- if (isset($p['about'])) {
- $p['about'] = bbcode($p['about']);
- }
-
- if (isset($p['address'])) {
- $p['address'] = bbcode($p['address']);
- } else {
- $p['address'] = bbcode($p['location']);
- }
-
- if (isset($p['photo'])) {
- $p['photo'] = proxy_url($p['photo'], false, PROXY_SIZE_SMALL);
- }
-
- $tpl = get_markup_template('profile_vcard.tpl');
- $o .= replace_macros($tpl, array(
- '$profile' => $p,
- '$xmpp' => $xmpp,
- '$connect' => $connect,
- '$remoteconnect' => $remoteconnect,
- '$subscribe_feed' => $subscribe_feed,
- '$wallmessage' => $wallmessage,
- '$wallmessage_link' => $wallmessage_link,
- '$account_type' => $account_type,
- '$location' => $location,
- '$gender' => $gender,
- '$marital' => $marital,
- '$homepage' => $homepage,
- '$about' => $about,
- '$network' => t('Network:'),
- '$contacts' => $contacts,
- '$updated' => $updated,
- '$diaspora' => $diaspora,
- '$contact_block' => $contact_block,
- ));
-
- $arr = array('profile' => &$profile, 'entry' => &$o);
-
- call_hooks('profile_sidebar', $arr);
-
- return $o;
-}
-
-function get_birthdays()
-{
- $a = get_app();
- $o = '';
-
- if (!local_user() || $a->is_mobile || $a->is_tablet) {
- return $o;
- }
-
- /*
- * $mobile_detect = new Mobile_Detect();
- * $is_mobile = $mobile_detect->isMobile() || $mobile_detect->isTablet();
- * if ($is_mobile)
- * return $o;
- */
-
- $bd_format = t('g A l F d'); // 8 AM Friday January 18
- $bd_short = t('F d');
-
- $cachekey = 'get_birthdays:' . local_user();
- $r = Cache::get($cachekey);
- if (is_null($r)) {
- $s = dba::p(
- "SELECT `event`.*, `event`.`id` AS `eid`, `contact`.* FROM `event`
- INNER JOIN `contact` ON `contact`.`id` = `event`.`cid`
- WHERE `event`.`uid` = ? AND `type` = 'birthday' AND `start` < ? AND `finish` > ?
- ORDER BY `start` ASC ",
- local_user(),
- datetime_convert('UTC', 'UTC', 'now + 6 days'),
- datetime_convert('UTC', 'UTC', 'now')
- );
- if (DBM::is_result($s)) {
- $r = dba::inArray($s);
- Cache::set($cachekey, $r, CACHE_HOUR);
- }
- }
- if (DBM::is_result($r)) {
- $total = 0;
- $now = strtotime('now');
- $cids = array();
-
- $istoday = false;
- foreach ($r as $rr) {
- if (strlen($rr['name'])) {
- $total ++;
- }
- if ((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) {
- $istoday = true;
- }
- }
- $classtoday = $istoday ? ' birthday-today ' : '';
- if ($total) {
- foreach ($r as &$rr) {
- if (!strlen($rr['name'])) {
- continue;
- }
-
- // avoid duplicates
-
- if (in_array($rr['cid'], $cids)) {
- continue;
- }
- $cids[] = $rr['cid'];
-
- $today = (((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) ? true : false);
- $url = $rr['url'];
- if ($rr['network'] === NETWORK_DFRN) {
- $url = System::baseUrl() . '/redir/' . $rr['cid'];
- }
-
- $rr['link'] = $url;
- $rr['title'] = $rr['name'];
- $rr['date'] = day_translate(datetime_convert('UTC', $a->timezone, $rr['start'], $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . t('[today]') : '');
- $rr['startime'] = null;
- $rr['today'] = $today;
- }
- }
- }
- $tpl = get_markup_template('birthdays_reminder.tpl');
- return replace_macros($tpl, array(
- '$baseurl' => System::baseUrl(),
- '$classtoday' => $classtoday,
- '$count' => $total,
- '$event_reminders' => t('Birthday Reminders'),
- '$event_title' => t('Birthdays this week:'),
- '$events' => $r,
- '$lbr' => '{', // raw brackets mess up if/endif macro processing
- '$rbr' => '}'
- ));
-}
-
-function get_events()
-{
- require_once 'include/bbcode.php';
-
- $a = get_app();
-
- if (!local_user() || $a->is_mobile || $a->is_tablet) {
- return $o;
- }
-
- /*
- * $mobile_detect = new Mobile_Detect();
- * $is_mobile = $mobile_detect->isMobile() || $mobile_detect->isTablet();
- * if ($is_mobile)
- * return $o;
- */
-
- $bd_format = t('g A l F d'); // 8 AM Friday January 18
- $classtoday = '';
-
- $s = dba::p(
- "SELECT `event`.* FROM `event`
- WHERE `event`.`uid` = ? AND `type` != 'birthday' AND `start` < ? AND `start` >= ?
- ORDER BY `start` ASC ",
- local_user(),
- datetime_convert('UTC', 'UTC', 'now + 7 days'),
- datetime_convert('UTC', 'UTC', 'now - 1 days')
- );
-
- $r = array();
-
- if (DBM::is_result($s)) {
- $istoday = false;
-
- while ($rr = dba::fetch($s)) {
- if (strlen($rr['name'])) {
- $total ++;
- }
-
- $strt = datetime_convert('UTC', $rr['convert'] ? $a->timezone : 'UTC', $rr['start'], 'Y-m-d');
- if ($strt === datetime_convert('UTC', $a->timezone, 'now', 'Y-m-d')) {
- $istoday = true;
- }
-
- $title = strip_tags(html_entity_decode(bbcode($rr['summary']), ENT_QUOTES, 'UTF-8'));
-
- if (strlen($title) > 35) {
- $title = substr($title, 0, 32) . '... ';
- }
-
- $description = substr(strip_tags(bbcode($rr['desc'])), 0, 32) . '... ';
- if (!$description) {
- $description = t('[No description]');
- }
-
- $strt = datetime_convert('UTC', $rr['convert'] ? $a->timezone : 'UTC', $rr['start']);
-
- if (substr($strt, 0, 10) < datetime_convert('UTC', $a->timezone, 'now', 'Y-m-d')) {
- continue;
- }
-
- $today = ((substr($strt, 0, 10) === datetime_convert('UTC', $a->timezone, 'now', 'Y-m-d')) ? true : false);
-
- $rr['title'] = $title;
- $rr['description'] = $description;
- $rr['date'] = day_translate(datetime_convert('UTC', $rr['adjust'] ? $a->timezone : 'UTC', $rr['start'], $bd_format)) . (($today) ? ' ' . t('[today]') : '');
- $rr['startime'] = $strt;
- $rr['today'] = $today;
-
- $r[] = $rr;
- }
- dba::close($s);
- $classtoday = (($istoday) ? 'event-today' : '');
- }
- $tpl = get_markup_template('events_reminder.tpl');
- return replace_macros($tpl, array(
- '$baseurl' => System::baseUrl(),
- '$classtoday' => $classtoday,
- '$count' => count($r),
- '$event_reminders' => t('Event Reminders'),
- '$event_title' => t('Events this week:'),
- '$events' => $r,
- ));
-}
-
-function advanced_profile(App $a)
-{
- $o = '';
- $uid = $a->profile['uid'];
-
- $o .= replace_macros(
- get_markup_template('section_title.tpl'), array(
- '$title' => t('Profile')
- )
- );
-
- if ($a->profile['name']) {
- $tpl = get_markup_template('profile_advanced.tpl');
-
- $profile = array();
-
- $profile['fullname'] = array(t('Full Name:'), $a->profile['name']);
-
- if ($a->profile['gender']) {
- $profile['gender'] = array(t('Gender:'), $a->profile['gender']);
- }
-
- if (($a->profile['dob']) && ($a->profile['dob'] > '0001-01-01')) {
- $year_bd_format = t('j F, Y');
- $short_bd_format = t('j F');
-
- $val = intval($a->profile['dob']) ?
- day_translate(datetime_convert('UTC', 'UTC', $a->profile['dob'] . ' 00:00 +00:00', $year_bd_format))
- : day_translate(datetime_convert('UTC', 'UTC', '2001-' . substr($a->profile['dob'], 5) . ' 00:00 +00:00', $short_bd_format));
-
- $profile['birthday'] = array(t('Birthday:'), $val);
- }
-
- if (!empty($a->profile['dob'])
- && $a->profile['dob'] > '0001-01-01'
- && $age = age($a->profile['dob'], $a->profile['timezone'], '')
- ) {
- $profile['age'] = array(t('Age:'), $age);
- }
-
- if ($a->profile['marital']) {
- $profile['marital'] = array(t('Status:'), $a->profile['marital']);
- }
-
- /// @TODO Maybe use x() here, plus below?
- if ($a->profile['with']) {
- $profile['marital']['with'] = $a->profile['with'];
- }
-
- if (strlen($a->profile['howlong']) && $a->profile['howlong'] >= NULL_DATE) {
- $profile['howlong'] = relative_date($a->profile['howlong'], t('for %1$d %2$s'));
- }
-
- if ($a->profile['sexual']) {
- $profile['sexual'] = array(t('Sexual Preference:'), $a->profile['sexual']);
- }
-
- if ($a->profile['homepage']) {
- $profile['homepage'] = array(t('Homepage:'), linkify($a->profile['homepage']));
- }
-
- if ($a->profile['hometown']) {
- $profile['hometown'] = array(t('Hometown:'), linkify($a->profile['hometown']));
- }
-
- if ($a->profile['pub_keywords']) {
- $profile['pub_keywords'] = array(t('Tags:'), $a->profile['pub_keywords']);
- }
-
- if ($a->profile['politic']) {
- $profile['politic'] = array(t('Political Views:'), $a->profile['politic']);
- }
-
- if ($a->profile['religion']) {
- $profile['religion'] = array(t('Religion:'), $a->profile['religion']);
- }
-
- if ($txt = prepare_text($a->profile['about'])) {
- $profile['about'] = array(t('About:'), $txt);
- }
-
- if ($txt = prepare_text($a->profile['interest'])) {
- $profile['interest'] = array(t('Hobbies/Interests:'), $txt);
- }
-
- if ($txt = prepare_text($a->profile['likes'])) {
- $profile['likes'] = array(t('Likes:'), $txt);
- }
-
- if ($txt = prepare_text($a->profile['dislikes'])) {
- $profile['dislikes'] = array(t('Dislikes:'), $txt);
- }
-
- if ($txt = prepare_text($a->profile['contact'])) {
- $profile['contact'] = array(t('Contact information and Social Networks:'), $txt);
- }
-
- if ($txt = prepare_text($a->profile['music'])) {
- $profile['music'] = array(t('Musical interests:'), $txt);
- }
-
- if ($txt = prepare_text($a->profile['book'])) {
- $profile['book'] = array(t('Books, literature:'), $txt);
- }
-
- if ($txt = prepare_text($a->profile['tv'])) {
- $profile['tv'] = array(t('Television:'), $txt);
- }
-
- if ($txt = prepare_text($a->profile['film'])) {
- $profile['film'] = array(t('Film/dance/culture/entertainment:'), $txt);
- }
-
- if ($txt = prepare_text($a->profile['romance'])) {
- $profile['romance'] = array(t('Love/Romance:'), $txt);
- }
-
- if ($txt = prepare_text($a->profile['work'])) {
- $profile['work'] = array(t('Work/employment:'), $txt);
- }
-
- if ($txt = prepare_text($a->profile['education'])) {
- $profile['education'] = array(t('School/education:'), $txt);
- }
-
- //show subcribed forum if it is enabled in the usersettings
- if (Feature::isEnabled($uid, 'forumlist_profile')) {
- $profile['forumlist'] = array(t('Forums:'), ForumManager::profileAdvanced($uid));
- }
-
- if ($a->profile['uid'] == local_user()) {
- $profile['edit'] = array(System::baseUrl() . '/profiles/' . $a->profile['id'], t('Edit profile'), '', t('Edit profile'));
- }
-
- return replace_macros($tpl, array(
- '$title' => t('Profile'),
- '$basic' => t('Basic'),
- '$advanced' => t('Advanced'),
- '$profile' => $profile
- ));
- }
-
- return '';
-}
-
-function profile_tabs($a, $is_owner = false, $nickname = null)
-{
- if (is_null($nickname)) {
- $nickname = $a->user['nickname'];
- }
-
- $tab = false;
- if (x($_GET, 'tab')) {
- $tab = notags(trim($_GET['tab']));
- }
-
- $url = System::baseUrl() . '/profile/' . $nickname;
-
- $tabs = array(
- array(
- 'label' => t('Status'),
- 'url' => $url,
- 'sel' => !$tab && $a->argv[0] == 'profile' ? 'active' : '',
- 'title' => t('Status Messages and Posts'),
- 'id' => 'status-tab',
- 'accesskey' => 'm',
- ),
- array(
- 'label' => t('Profile'),
- 'url' => $url . '/?tab=profile',
- 'sel' => $tab == 'profile' ? 'active' : '',
- 'title' => t('Profile Details'),
- 'id' => 'profile-tab',
- 'accesskey' => 'r',
- ),
- array(
- 'label' => t('Photos'),
- 'url' => System::baseUrl() . '/photos/' . $nickname,
- 'sel' => !$tab && $a->argv[0] == 'photos' ? 'active' : '',
- 'title' => t('Photo Albums'),
- 'id' => 'photo-tab',
- 'accesskey' => 'h',
- ),
- array(
- 'label' => t('Videos'),
- 'url' => System::baseUrl() . '/videos/' . $nickname,
- 'sel' => !$tab && $a->argv[0] == 'videos' ? 'active' : '',
- 'title' => t('Videos'),
- 'id' => 'video-tab',
- 'accesskey' => 'v',
- ),
- );
-
- // the calendar link for the full featured events calendar
- if ($is_owner && $a->theme_events_in_profile) {
- $tabs[] = array(
- 'label' => t('Events'),
- 'url' => System::baseUrl() . '/events',
- 'sel' => !$tab && $a->argv[0] == 'events' ? 'active' : '',
- 'title' => t('Events and Calendar'),
- 'id' => 'events-tab',
- 'accesskey' => 'e',
- );
- // if the user is not the owner of the calendar we only show a calendar
- // with the public events of the calendar owner
- } elseif (!$is_owner) {
- $tabs[] = array(
- 'label' => t('Events'),
- 'url' => System::baseUrl() . '/cal/' . $nickname,
- 'sel' => !$tab && $a->argv[0] == 'cal' ? 'active' : '',
- 'title' => t('Events and Calendar'),
- 'id' => 'events-tab',
- 'accesskey' => 'e',
- );
- }
-
- if ($is_owner) {
- $tabs[] = array(
- 'label' => t('Personal Notes'),
- 'url' => System::baseUrl() . '/notes',
- 'sel' => !$tab && $a->argv[0] == 'notes' ? 'active' : '',
- 'title' => t('Only You Can See This'),
- 'id' => 'notes-tab',
- 'accesskey' => 't',
- );
- }
-
- if ((!$is_owner) && ((count($a->profile)) || (!$a->profile['hide-friends']))) {
- $tabs[] = array(
- 'label' => t('Contacts'),
- 'url' => System::baseUrl() . '/viewcontacts/' . $nickname,
- 'sel' => !$tab && $a->argv[0] == 'viewcontacts' ? 'active' : '',
- 'title' => t('Contacts'),
- 'id' => 'viewcontacts-tab',
- 'accesskey' => 'k',
- );
- }
-
- $arr = array('is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => $tab, 'tabs' => $tabs);
- call_hooks('profile_tabs', $arr);
-
- $tpl = get_markup_template('common_tabs.tpl');
-
- return replace_macros($tpl, array('$tabs' => $arr['tabs']));
-}
-
-/**
- * Retrieves the my_url session variable
- *
- * @return string
- */
-function get_my_url()
-{
- if (x($_SESSION, 'my_url')) {
- return $_SESSION['my_url'];
- }
- return null;
-}
-
-function zrl_init(App $a)
-{
- $my_url = get_my_url();
- $my_url = validate_url($my_url);
- if ($my_url) {
- // Is it a DDoS attempt?
- // The check fetches the cached value from gprobe to reduce the load for this system
- $urlparts = parse_url($my_url);
-
- $result = Cache::get('gprobe:' . $urlparts['host']);
- if ((!is_null($result)) && (in_array($result['network'], array(NETWORK_FEED, NETWORK_PHANTOM)))) {
- logger('DDoS attempt detected for ' . $urlparts['host'] . ' by ' . $_SERVER['REMOTE_ADDR'] . '. server data: ' . print_r($_SERVER, true), LOGGER_DEBUG);
- return;
- }
-
- Worker::add(PRIORITY_LOW, 'GProbe', $my_url);
- $arr = array('zrl' => $my_url, 'url' => $a->cmd);
- call_hooks('zrl_init', $arr);
- }
-}
-
-function zrl($s, $force = false)
-{
- if (!strlen($s)) {
- return $s;
- }
- if ((!strpos($s, '/profile/')) && (!$force)) {
- return $s;
- }
- if ($force && substr($s, -1, 1) !== '/') {
- $s = $s . '/';
- }
- $achar = strpos($s, '?') ? '&' : '?';
- $mine = get_my_url();
- if ($mine && !link_compare($mine, $s)) {
- return $s . $achar . 'zrl=' . urlencode($mine);
- }
- return $s;
-}
-
-/**
- * @brief Get the user ID of the page owner
- *
- * Used from within PCSS themes to set theme parameters. If there's a
- * puid request variable, that is the "page owner" and normally their theme
- * settings take precedence; unless a local user sets the "always_my_theme"
- * system pconfig, which means they don't want to see anybody else's theme
- * settings except their own while on this site.
- *
- * @return int user ID
- *
- * @note Returns local_user instead of user ID if "always_my_theme"
- * is set to true
- */
-function get_theme_uid()
-{
- $uid = ((!empty($_REQUEST['puid'])) ? intval($_REQUEST['puid']) : 0);
- if ((local_user()) && ((PConfig::get(local_user(), 'system', 'always_my_theme')) || (!$uid))) {
- return local_user();
- }
-
- return $uid;
-}
diff --git a/include/nav.php b/include/nav.php
index 312e3de52..5c2d6efa0 100644
--- a/include/nav.php
+++ b/include/nav.php
@@ -7,6 +7,7 @@ use Friendica\Content\Feature;
use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Database\DBM;
+use Friendica\Model\Profile;
function nav(App $a) {
@@ -104,9 +105,9 @@ function nav_info(App $a)
}
// "Home" should also take you home from an authenticated remote profile connection
- $homelink = get_my_url();
+ $homelink = Profile::getMyURL();
if (! $homelink) {
- $homelink = ((x($_SESSION,'visitor_home')) ? $_SESSION['visitor_home'] : '');
+ $homelink = ((x($_SESSION, 'visitor_home')) ? $_SESSION['visitor_home'] : '');
}
if (($a->module != 'home') && (! (local_user()))) {
@@ -145,7 +146,7 @@ function nav_info(App $a)
if (strlen(Config::get('system', 'singleuser'))) {
$gdir = Config::get('system', 'directory');
if (strlen($gdir)) {
- $gdirpath = zrl($gdir, true);
+ $gdirpath = Profile::zrl($gdir, true);
}
}
diff --git a/include/text.php b/include/text.php
index b34c3e902..66918e9a6 100644
--- a/include/text.php
+++ b/include/text.php
@@ -10,6 +10,7 @@ use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBM;
+use Friendica\Model\Profile;
use Friendica\Model\Term;
use Friendica\Util\Map;
@@ -1011,7 +1012,7 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
$url = $redirect_url;
$sparkle = ' sparkle';
} else {
- $url = zrl($url);
+ $url = Profile::zrl($url);
}
}
diff --git a/index.php b/index.php
index 7436a5112..74a88eb7e 100644
--- a/index.php
+++ b/index.php
@@ -14,6 +14,7 @@ use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
+use Friendica\Model\Profile;
use Friendica\Module\Login;
require_once 'boot.php';
@@ -128,7 +129,7 @@ if ((x($_GET, 'zrl')) && (!$install && !$maintenance)) {
) {
$_SESSION['my_url'] = $_GET['zrl'];
$a->query_string = preg_replace('/[\?&]zrl=(.*?)([\?&]|$)/is', '', $a->query_string);
- zrl_init($a);
+ Profile::zrlInit($a);
} else {
// Someone came with an invalid parameter, maybe as a DDoS attempt
// We simply stop processing here
diff --git a/mod/allfriends.php b/mod/allfriends.php
index 88dddb3ee..86f3f27e2 100644
--- a/mod/allfriends.php
+++ b/mod/allfriends.php
@@ -1,5 +1,4 @@
user['uid'];
- $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
- intval($cid),
- intval(local_user())
- );
+ $contact = dba::selectFirst('contact', ['name', 'url', 'photo'], ['id' => $cid, 'uid' => local_user()]);
- if (!DBM::is_result($c)) {
+ if (!DBM::is_result($contact)) {
return;
}
$a->page['aside'] = "";
- profile_load($a, "", 0, Contact::getDetailsByURL($c[0]["url"]));
+ Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
$total = GContact::countAllFriends(local_user(), $cid);
@@ -71,7 +70,7 @@ function allfriends_content(App $a)
} else {
$connlnk = System::baseUrl() . '/follow/?url=' . $rr['url'];
$photo_menu = array(
- 'profile' => array(t("View Profile"), zrl($rr['url'])),
+ 'profile' => array(t("View Profile"), Profile::zrl($rr['url'])),
'follow' => array(t("Connect/Follow"), $connlnk)
);
}
diff --git a/mod/cal.php b/mod/cal.php
index dece5ac18..31ab5976b 100644
--- a/mod/cal.php
+++ b/mod/cal.php
@@ -5,7 +5,6 @@
* This calendar is for profile visitors and contains only the events
* of the profile owner
*/
-
use Friendica\App;
use Friendica\Content\Feature;
use Friendica\Core\Config;
@@ -13,6 +12,7 @@ use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
+use Friendica\Model\Profile;
use Friendica\Protocol\DFRN;
require_once 'include/event.php';
@@ -45,7 +45,7 @@ function cal_init(App $a)
return;
}
- $profile = get_profiledata_by_nick($nick, $a->profile_uid);
+ $profile = Profile::getByNickname($nick, $a->profile_uid);
$account_type = Contact::getAccountType($profile);
@@ -144,7 +144,7 @@ function cal_content(App $a)
$sql_extra = " AND `event`.`cid` = 0 " . $sql_perms;
// get the tab navigation bar
- $tabs = profile_tabs($a, false, $a->data['user']['nickname']);
+ $tabs = Profile::getTabs($a, false, $a->data['user']['nickname']);
// The view mode part is similiar to /mod/events.php
if ($mode == 'view') {
diff --git a/mod/common.php b/mod/common.php
index 11bddf6b5..cfeb531f7 100644
--- a/mod/common.php
+++ b/mod/common.php
@@ -1,5 +1,4 @@
page['aside'] = "";
- profile_load($a, "", 0, Contact::getDetailsByURL($c[0]["url"]));
- } else {
- $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
- intval($uid)
- );
- /// @TODO Handle $c with DBM::is_result()
- $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), array(
- '$name' => htmlentities($c[0]['name']),
- '$photo' => $c[0]['photo'],
- 'url' => 'contacts/' . $cid
- ));
+ $contact = dba::selectFirst('contact', ['name', 'url', 'photo'], ['id' => $cid, 'uid' => $uid]);
- if (!x($a->page, 'aside')) {
- $a->page['aside'] = '';
+ if (DBM::is_result($contact)) {
+ $a->page['aside'] = "";
+ Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
+ }
+ } else {
+ $contact = dba::selectFirst('contact', ['name', 'url', 'photo'], ['self' => true, 'uid' => $uid]);
+
+ if (DBM::is_result($contact)) {
+ $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), array(
+ '$name' => htmlentities($contact['name']),
+ '$photo' => $contact['photo'],
+ 'url' => 'contacts/' . $cid
+ ));
+
+ if (!x($a->page, 'aside')) {
+ $a->page['aside'] = '';
+ }
+ $a->page['aside'] .= $vcard_widget;
}
- $a->page['aside'] .= $vcard_widget;
}
- if (!DBM::is_result($c)) {
+ if (!DBM::is_result($contact)) {
return;
}
- if (!$cid && get_my_url()) {
- $contact = dba::selectFirst('contact', ['id'], ['nurl' => normalise_link(get_my_url()), 'uid' => $uid]);
+ if (!$cid && Profile::getMyURL()) {
+ $contact = dba::selectFirst('contact', ['id'], ['nurl' => normalise_link(Profile::getMyURL()), 'uid' => $uid]);
if (DBM::is_result($contact)) {
$cid = $contact['id'];
} else {
- $gcontact = dba::selectFirst('gcontact', ['id'], ['nurl' => normalise_link(get_my_url())]);
+ $gcontact = dba::selectFirst('gcontact', ['id'], ['nurl' => normalise_link(Profile::getMyURL())]);
if (DBM::is_result($gcontact)) {
$zcid = $gcontact['id'];
}
diff --git a/mod/contacts.php b/mod/contacts.php
index f213b8370..22b5b87e7 100644
--- a/mod/contacts.php
+++ b/mod/contacts.php
@@ -1,9 +1,7 @@
$contact_id]);
if (DBM::is_result($contact)) {
$a->page['aside'] = "";
- profile_load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
+ Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
$o .= Contact::getPostsFromUrl($contact["url"]);
}
diff --git a/mod/crepair.php b/mod/crepair.php
index 94d161dc5..cfe0e3e28 100644
--- a/mod/crepair.php
+++ b/mod/crepair.php
@@ -1,5 +1,4 @@
data['contact'] = $contact;
- profile_load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
+ Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
}
}
diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php
index ca43998cb..d42e649bf 100644
--- a/mod/dfrn_request.php
+++ b/mod/dfrn_request.php
@@ -19,6 +19,7 @@ use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\User;
+use Friendica\Model\Profile;
use Friendica\Module\Login;
use Friendica\Network\Probe;
@@ -26,10 +27,11 @@ require_once 'include/enotify.php';
function dfrn_request_init(App $a)
{
- if ($a->argc > 1)
+ if ($a->argc > 1) {
$which = $a->argv[1];
+ }
- profile_load($a, $which);
+ Profile::load($a, $which);
return;
}
@@ -183,7 +185,7 @@ function dfrn_request_post(App $a)
}
// (ignore reply, nothing we can do it failed)
- // Old: goaway(zrl($dfrn_url));
+ // Old: goaway(Profile::zrl($dfrn_url));
goaway($forwardurl);
return; // NOTREACHED
}
@@ -618,7 +620,7 @@ function dfrn_request_content(App $a)
}
} else {
// last, try a zrl
- $myaddr = get_my_url();
+ $myaddr = Profile::getMyURL();
}
$target_addr = $a->profile['nickname'] . '@' . substr(System::baseUrl(), strpos(System::baseUrl(), '://') + 3);
diff --git a/mod/directory.php b/mod/directory.php
index f29e3eb69..9dc08f0fb 100644
--- a/mod/directory.php
+++ b/mod/directory.php
@@ -1,9 +1,12 @@
set_pager_itemspage(60);
@@ -46,7 +49,7 @@ function directory_content(App $a) {
$gdirpath = '';
$dirurl = Config::get('system','directory');
if(strlen($dirurl)) {
- $gdirpath = zrl($dirurl,true);
+ $gdirpath = Profile::zrl($dirurl,true);
}
if($search) {
@@ -146,7 +149,7 @@ function directory_content(App $a) {
$location_e = $location;
$photo_menu = array(
- 'profile' => array(t("View Profile"), zrl($profile_link))
+ 'profile' => array(t("View Profile"), Profile::zrl($profile_link))
);
$entry = array(
diff --git a/mod/dirfind.php b/mod/dirfind.php
index 06bb1d8da..4260ce827 100644
--- a/mod/dirfind.php
+++ b/mod/dirfind.php
@@ -9,6 +9,7 @@ use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
+use Friendica\Model\Profile;
use Friendica\Network\Probe;
use Friendica\Protocol\PortableContact;
@@ -214,7 +215,7 @@ function dirfind_content(App $a, $prefix = "") {
$connlnk = System::baseUrl().'/follow/?url='.(($jj->connect) ? $jj->connect : $jj->url);
$conntxt = t('Connect');
$photo_menu = array(
- 'profile' => array(t("View Profile"), zrl($jj->url)),
+ 'profile' => array(t("View Profile"), Profile::zrl($jj->url)),
'follow' => array(t("Connect/Follow"), $connlnk)
);
}
@@ -223,7 +224,7 @@ function dirfind_content(App $a, $prefix = "") {
$entry = array(
'alt_text' => $alt_text,
- 'url' => zrl($jj->url),
+ 'url' => Profile::zrl($jj->url),
'itemurl' => $itemurl,
'name' => htmlentities($jj->name),
'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB),
diff --git a/mod/display.php b/mod/display.php
index 25dd9b3af..2bd2b9a5d 100644
--- a/mod/display.php
+++ b/mod/display.php
@@ -1,15 +1,19 @@
theme_events_in_profile) {
- $tabs = profile_tabs($a, true);
+ $tabs = Profile::getTabs($a, true);
}
$mode = 'view';
diff --git a/mod/follow.php b/mod/follow.php
index 2194321de..f1a53e953 100644
--- a/mod/follow.php
+++ b/mod/follow.php
@@ -6,9 +6,9 @@ use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Model\Contact;
+use Friendica\Model\Profile;
use Friendica\Network\Probe;
-
function follow_post(App $a) {
if (!local_user()) {
@@ -163,7 +163,7 @@ function follow_content(App $a) {
'$nickname' => "",
'$name' => $ret["name"],
'$url' => $ret["url"],
- '$zrl' => zrl($ret["url"]),
+ '$zrl' => Profile::zrl($ret["url"]),
'$url_label' => t("Profile URL"),
'$myaddr' => $myaddr,
'$request' => $request,
@@ -177,7 +177,7 @@ function follow_content(App $a) {
$a->page['aside'] = "";
- profile_load($a, "", 0, Contact::getDetailsByURL($ret["url"]), false);
+ Profile::load($a, "", 0, Contact::getDetailsByURL($ret["url"]), false);
if ($gcontact_id <> 0) {
$o .= replace_macros(get_markup_template('section_title.tpl'),
diff --git a/mod/hcard.php b/mod/hcard.php
index f8d4cfc3b..87f5ef320 100644
--- a/mod/hcard.php
+++ b/mod/hcard.php
@@ -1,18 +1,20 @@
argc > 1) {
$which = $a->argv[1];
- }
- else {
- notice( t('No profile') . EOL );
+ } else {
+ notice(t('No profile') . EOL);
$a->error = 404;
return;
}
@@ -23,22 +25,22 @@ function hcard_init(App $a) {
$profile = $a->argv[1];
}
- profile_load($a,$which,$profile);
+ Profile::load($a, $which, $profile);
- if ((x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY)) {
+ if ((x($a->profile, 'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY)) {
$a->page['htmlhead'] .= '';
}
- if (x($a->profile,'openidserver')) {
+ if (x($a->profile, 'openidserver')) {
$a->page['htmlhead'] .= '' . "\r\n";
}
- if (x($a->profile,'openid')) {
- $delegate = ((strstr($a->profile['openid'],'://')) ? $a->profile['openid'] : 'http://' . $a->profile['openid']);
+ if (x($a->profile, 'openid')) {
+ $delegate = ((strstr($a->profile['openid'], '://')) ? $a->profile['openid'] : 'http://' . $a->profile['openid']);
$a->page['htmlhead'] .= '' . "\r\n";
}
- if (! $blocked) {
- $keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : '');
- $keywords = str_replace(array(',',' ',',,'),array(' ',',',','),$keywords);
+ if (!$blocked) {
+ $keywords = ((x($a->profile, 'pub_keywords')) ? $a->profile['pub_keywords'] : '');
+ $keywords = str_replace(array(',',' ',',,'), array(' ',',',','), $keywords);
if (strlen($keywords)) {
$a->page['htmlhead'] .= '' . "\r\n" ;
}
@@ -54,5 +56,4 @@ function hcard_init(App $a) {
foreach ($dfrn_pages as $dfrn) {
$a->page['htmlhead'] .= "\r\n";
}
-
}
diff --git a/mod/hovercard.php b/mod/hovercard.php
index d7ba0f4f5..9bf477405 100644
--- a/mod/hovercard.php
+++ b/mod/hovercard.php
@@ -11,6 +11,7 @@ use Friendica\App;
use Friendica\Core\Config;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
+use Friendica\Model\Profile;
function hovercard_init(App $a)
{
@@ -70,7 +71,7 @@ function hovercard_content()
'nick' => $contact['nick'],
'addr' => defaults($contact, 'addr', $contact['url']),
'thumb' => proxy_url($contact['thumb'], false, PROXY_SIZE_THUMB),
- 'url' => $cid ? ('redir/' . $cid) : zrl($contact['url']),
+ 'url' => $cid ? ('redir/' . $cid) : Profile::zrl($contact['url']),
'nurl' => $contact['nurl'], // We additionally store the nurl as identifier
'location' => $contact['location'],
'gender' => $contact['gender'],
diff --git a/mod/match.php b/mod/match.php
index 563ce5bed..7da56bffa 100644
--- a/mod/match.php
+++ b/mod/match.php
@@ -7,6 +7,7 @@ use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
+use Friendica\Model\Profile;
require_once 'include/text.php';
require_once 'include/contact_widgets.php';
@@ -83,14 +84,14 @@ function match_content(App $a)
$jj->photo = str_replace("http:///photo/", get_server()."/photo/", $jj->photo);
$connlnk = System::baseUrl() . '/follow/?url=' . $jj->url;
$photo_menu = array(
- 'profile' => array(t("View Profile"), zrl($jj->url)),
+ 'profile' => array(t("View Profile"), Profile::zrl($jj->url)),
'follow' => array(t("Connect/Follow"), $connlnk)
);
$contact_details = Contact::getDetailsByURL($jj->url, local_user());
$entry = array(
- 'url' => zrl($jj->url),
+ 'url' => Profile::zrl($jj->url),
'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $jj->url),
'name' => $jj->name,
'details' => $contact_details['location'],
diff --git a/mod/network.php b/mod/network.php
index 9b6e3f1c3..870bb7553 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -11,6 +11,7 @@ use Friendica\Core\PConfig;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
+use Friendica\Model\Profile;
use Friendica\Module\Login;
require_once 'include/conversation.php';
@@ -459,9 +460,9 @@ function networkFlatView(App $a, $update = 0) {
$o .= status_editor($a, $x);
- if (!Config::get('theme','hide_eventlist')) {
- $o .= get_birthdays();
- $o .= get_events();
+ if (!Config::get('theme', 'hide_eventlist')) {
+ $o .= Profile::getBirthdays();
+ $o .= Profile::getEvents();
}
}
@@ -700,9 +701,9 @@ function networkThreadedView(App $a, $update = 0) {
}
}
- if (!$gid && !$cid && !$update && !Config::get('theme','hide_eventlist')) {
- $o .= get_birthdays();
- $o .= get_events();
+ if (!$gid && !$cid && !$update && !Config::get('theme', 'hide_eventlist')) {
+ $o .= Profile::getBirthdays();
+ $o .= Profile::getEvents();
}
if ($datequery) {
diff --git a/mod/noscrape.php b/mod/noscrape.php
index fb5dea872..bbf9020e8 100644
--- a/mod/noscrape.php
+++ b/mod/noscrape.php
@@ -1,23 +1,27 @@
argc > 1)
+function noscrape_init(App $a)
+{
+ if ($a->argc > 1) {
$which = $a->argv[1];
- else
+ } else {
killme();
+ }
$profile = 0;
- if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
+ if ((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
$which = $a->user['nickname'];
$profile = $a->argv[1];
}
- profile_load($a,$which,$profile);
+ Profile::load($a, $which, $profile);
if (!$a->profile['net-publish'] || $a->profile['hidewall']) {
header('Content-type: application/json; charset=utf-8');
@@ -26,12 +30,11 @@ function noscrape_init(App $a) {
exit;
}
- $keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : '');
- $keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$keywords);
+ $keywords = ((x($a->profile, 'pub_keywords')) ? $a->profile['pub_keywords'] : '');
+ $keywords = str_replace(array('#',',',' ',',,'), array('',' ',',',','), $keywords);
$keywords = explode(',', $keywords);
- $r = q("SELECT `photo` FROM `contact` WHERE `self` AND `uid` = %d",
- intval($a->profile['uid']));
+ $contactPhoto = dba::selectFirst('contact', ['photo'], ['self' => true, 'uid' => $a->profile['uid']]);
$json_info = array(
'fn' => $a->profile['name'],
@@ -40,8 +43,8 @@ function noscrape_init(App $a) {
'guid' => $a->profile['guid'],
'key' => $a->profile['pubkey'],
'homepage' => System::baseUrl()."/profile/{$which}",
- 'comm' => (x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY),
- 'photo' => $r[0]["photo"],
+ 'comm' => (x($a->profile, 'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY),
+ 'photo' => $contactPhoto["photo"],
'tags' => $keywords
);
@@ -99,5 +102,4 @@ function noscrape_init(App $a) {
header('Content-type: application/json; charset=utf-8');
echo json_encode($json_info);
exit;
-
}
diff --git a/mod/notes.php b/mod/notes.php
index c5c45be72..dbf84337e 100644
--- a/mod/notes.php
+++ b/mod/notes.php
@@ -1,7 +1,10 @@
' . t('Personal Notes') . '';
diff --git a/mod/photos.php b/mod/photos.php
index bc8734798..ac1f06f8e 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -11,6 +11,7 @@ use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\Photo;
+use Friendica\Model\Profile;
use Friendica\Network\Probe;
use Friendica\Object\Image;
use Friendica\Protocol\DFRN;
@@ -48,7 +49,7 @@ function photos_init(App $a) {
$a->profile_uid = $user[0]['uid'];
$is_owner = (local_user() && (local_user() == $a->profile_uid));
- $profile = get_profiledata_by_nick($nick, $a->profile_uid);
+ $profile = Profile::getByNickname($nick, $a->profile_uid);
$account_type = Contact::getAccountType($profile);
@@ -1074,7 +1075,7 @@ function photos_content(App $a)
// tabs
$is_owner = (local_user() && (local_user() == $owner_uid));
- $o .= profile_tabs($a, $is_owner, $a->data['user']['nickname']);
+ $o .= Profile::getTabs($a, $is_owner, $a->data['user']['nickname']);
// Display upload form
if ($datatype === 'upload') {
diff --git a/mod/profile.php b/mod/profile.php
index 0dd723379..59762f479 100644
--- a/mod/profile.php
+++ b/mod/profile.php
@@ -8,6 +8,7 @@ use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Group;
+use Friendica\Model\Profile;
use Friendica\Module\Login;
use Friendica\Protocol\DFRN;
@@ -41,7 +42,7 @@ function profile_init(App $a)
DFRN::autoRedir($a, $which);
}
- profile_load($a, $which, $profile);
+ Profile::load($a, $which, $profile);
$blocked = !local_user() && !remote_user() && Config::get('system', 'block_public');
$userblock = !local_user() && !remote_user() && $a->profile['hidewall'];
@@ -175,10 +176,10 @@ function profile_content(App $a, $update = 0)
$tab = notags(trim($_GET['tab']));
}
- $o .= profile_tabs($a, $is_owner, $a->profile['nickname']);
+ $o .= Profile::getTabs($a, $is_owner, $a->profile['nickname']);
if ($tab === 'profile') {
- $o .= advanced_profile($a);
+ $o .= Profile::getAdvanced($a);
call_hooks('profile_advanced', $o);
return $o;
}
@@ -346,8 +347,8 @@ function profile_content(App $a, $update = 0)
}
if ($is_owner && !$update && !Config::get('theme', 'hide_eventlist')) {
- $o .= get_birthdays();
- $o .= get_events();
+ $o .= Profile::getBirthdays();
+ $o .= Profile::getEvents();
}
diff --git a/mod/profile_photo.php b/mod/profile_photo.php
index 5b75e654d..8cd1fcb6a 100644
--- a/mod/profile_photo.php
+++ b/mod/profile_photo.php
@@ -8,15 +8,16 @@ use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\Photo;
+use Friendica\Model\Profile;
use Friendica\Object\Image;
-function profile_photo_init(App $a) {
-
+function profile_photo_init(App $a)
+{
if (! local_user()) {
return;
}
- profile_load($a,$a->user['nickname']);
+ Profile::load($a, $a->user['nickname']);
}
function profile_photo_post(App $a) {
diff --git a/mod/profiles.php b/mod/profiles.php
index cc01f74dd..279a198aa 100644
--- a/mod/profiles.php
+++ b/mod/profiles.php
@@ -142,7 +142,7 @@ function profiles_init(App $a) {
return;
}
- profile_load($a,$a->user['nickname'], $r[0]['id']);
+ Profile::load($a, $a->user['nickname'], $r[0]['id']);
}
diff --git a/mod/profperm.php b/mod/profperm.php
index 99b58516d..ee5190660 100644
--- a/mod/profperm.php
+++ b/mod/profperm.php
@@ -1,12 +1,15 @@
user['nickname'];
$profile = $a->argv[1];
- profile_load($a,$which,$profile);
-
+ Profile::load($a, $which, $profile);
}
diff --git a/mod/randprof.php b/mod/randprof.php
index 40ad09271..c5154c12d 100644
--- a/mod/randprof.php
+++ b/mod/randprof.php
@@ -1,14 +1,18 @@
array(t("View Profile"), zrl($rr["url"])),
+ 'profile' => array(t("View Profile"), Profile::zrl($rr["url"])),
'follow' => array(t("Connect/Follow"), $connlnk),
'hide' => array(t('Ignore/Hide'), $ignlnk)
);
@@ -90,7 +91,7 @@ function suggest_content(App $a) {
$contact_details = Contact::getDetailsByURL($rr["url"], local_user(), $rr);
$entry = array(
- 'url' => zrl($rr['url']),
+ 'url' => Profile::zrl($rr['url']),
'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
'img_hover' => $rr['url'],
'name' => $contact_details['name'],
diff --git a/mod/unfollow.php b/mod/unfollow.php
index a68c4de90..b84e1079d 100644
--- a/mod/unfollow.php
+++ b/mod/unfollow.php
@@ -6,9 +6,10 @@ use Friendica\App;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
+use Friendica\Model\Profile;
-function unfollow_post(App $a) {
-
+function unfollow_post(App $a)
+{
if (!local_user()) {
notice(t('Permission denied.') . EOL);
goaway($_SESSION['return_url']);
@@ -116,7 +117,7 @@ function unfollow_content(App $a) {
'$nickname' => "",
'$name' => $contact["name"],
'$url' => $contact["url"],
- '$zrl' => zrl($contact["url"]),
+ '$zrl' => Profile::zrl($contact["url"]),
'$url_label' => t("Profile URL"),
'$myaddr' => $myaddr,
'$request' => $request,
@@ -125,11 +126,9 @@ function unfollow_content(App $a) {
));
$a->page['aside'] = "";
- profile_load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
+ Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
- $o .= replace_macros(get_markup_template('section_title.tpl'),
- array('$title' => t('Status Messages and Posts')
- ));
+ $o .= replace_macros(get_markup_template('section_title.tpl'), array('$title' => t('Status Messages and Posts')));
// Show last public posts
$o .= Contact::getPostsFromUrl($contact["url"]);
diff --git a/mod/videos.php b/mod/videos.php
index 640c2a3b5..1a9f57a39 100644
--- a/mod/videos.php
+++ b/mod/videos.php
@@ -9,6 +9,7 @@ use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
+use Friendica\Model\Profile;
use Friendica\Protocol\DFRN;
require_once 'include/items.php';
@@ -41,7 +42,7 @@ function videos_init(App $a) {
$a->data['user'] = $user[0];
$a->profile_uid = $user[0]['uid'];
- $profile = get_profiledata_by_nick($nick, $a->profile_uid);
+ $profile = Profile::getByNickname($nick, $a->profile_uid);
$account_type = Contact::getAccountType($profile);
@@ -327,7 +328,7 @@ function videos_content(App $a) {
// tabs
$_is_owner = (local_user() && (local_user() == $owner_uid));
- $o .= profile_tabs($a,$_is_owner, $a->data['user']['nickname']);
+ $o .= Profile::getTabs($a, $_is_owner, $a->data['user']['nickname']);
//
// dispatch request
diff --git a/mod/viewcontacts.php b/mod/viewcontacts.php
index e4ebe3abb..64dd24e16 100644
--- a/mod/viewcontacts.php
+++ b/mod/viewcontacts.php
@@ -1,10 +1,13 @@
profile_uid = $r[0]['uid'];
$is_owner = (local_user() && (local_user() == $a->profile_uid));
- profile_load($a,$a->argv[1]);
+ Profile::load($a, $a->argv[1]);
}
}
@@ -44,7 +47,7 @@ function viewcontacts_content(App $a) {
$o = "";
// tabs
- $o .= profile_tabs($a,$is_owner, $a->data['user']['nickname']);
+ $o .= Profile::getTabs($a, $is_owner, $a->data['user']['nickname']);
if(((! count($a->profile)) || ($a->profile['hide-friends']))) {
notice( t('Permission denied.') . EOL);
@@ -97,7 +100,7 @@ function viewcontacts_content(App $a) {
if($is_owner && ($rr['network'] === NETWORK_DFRN) && ($rr['rel']))
$url = 'redir/' . $rr['id'];
else
- $url = zrl($url);
+ $url = Profile::zrl($url);
$contact_details = Contact::getDetailsByURL($rr['url'], $a->profile['uid'], $rr);
diff --git a/mod/wallmessage.php b/mod/wallmessage.php
index 1ac54c9f8..5c7ebca9f 100644
--- a/mod/wallmessage.php
+++ b/mod/wallmessage.php
@@ -1,14 +1,17 @@
$it['contact-id'],
'photo' => ((x($it, 'fphoto')) ? proxy_url($it['fphoto'], false, PROXY_SIZE_SMALL) : "images/person-175.jpg"),
'name' => $it['fname'],
- 'url' => zrl($it['furl']),
+ 'url' => Profile::zrl($it['furl']),
'hidden' => $it['hidden'] == 1,
'post_newfriend' => (intval(PConfig::get(local_user(), 'system', 'post_newfriend')) ? '1' : 0),
'knowyou' => $knowyou,
@@ -848,7 +849,7 @@ class NotificationsManager extends BaseObject
'hidden' => $it['hidden'] == 1,
'post_newfriend' => (intval(PConfig::get(local_user(), 'system', 'post_newfriend')) ? '1' : 0),
'url' => $it['url'],
- 'zrl' => zrl($it['url']),
+ 'zrl' => Profile::zrl($it['url']),
'addr' => $it['gaddr'],
'network' => $it['gnetwork'],
'knowyou' => $it['knowyou'],
diff --git a/src/Model/Contact.php b/src/Model/Contact.php
index 99183295b..96a2e32c6 100644
--- a/src/Model/Contact.php
+++ b/src/Model/Contact.php
@@ -1,9 +1,7 @@
array(t('View Profile'), $profile_link, true));
return $menu;
@@ -501,7 +500,7 @@ class Contact extends BaseObject
if (DBM::is_result($contact_own)) {
return self::photoMenu($contact_own, $uid);
} else {
- $profile_link = zrl($contact['url']);
+ $profile_link = Profile::zrl($contact['url']);
$connlnk = 'follow/?url=' . $contact['url'];
$menu = array(
'profile' => array(t('View Profile'), $profile_link, true),
diff --git a/src/Model/Profile.php b/src/Model/Profile.php
index 0916e66c8..573af02c9 100644
--- a/src/Model/Profile.php
+++ b/src/Model/Profile.php
@@ -1,11 +1,27 @@
$nickname]);
+
+ if (!$user && !count($user) && !count($profiledata)) {
+ logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
+ notice(t('Requested account is not available.') . EOL);
+ $a->error = 404;
+ return;
+ }
+
+ if (!x($a->page, 'aside')) {
+ $a->page['aside'] = '';
+ }
+
+ if ($profiledata) {
+ $a->page['aside'] .= self::sidebar($profiledata, true, $show_connect);
+
+ if (!DBM::is_result($user)) {
+ return;
+ }
+ }
+
+ $pdata = self::getByNickname($nickname, $user[0]['uid'], $profile);
+
+ if (empty($pdata) && empty($profiledata)) {
+ logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
+ notice(t('Requested profile is not available.') . EOL);
+ $a->error = 404;
+ return;
+ }
+
+ // fetch user tags if this isn't the default profile
+
+ if (!$pdata['is-default']) {
+ $x = q(
+ "SELECT `pub_keywords` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1",
+ intval($pdata['profile_uid'])
+ );
+ if ($x && count($x)) {
+ $pdata['pub_keywords'] = $x[0]['pub_keywords'];
+ }
+ }
+
+ $a->profile = $pdata;
+ $a->profile_uid = $pdata['profile_uid'];
+
+ $a->profile['mobile-theme'] = PConfig::get($a->profile['profile_uid'], 'system', 'mobile_theme');
+ $a->profile['network'] = NETWORK_DFRN;
+
+ $a->page['title'] = $a->profile['name'] . ' @ ' . $a->config['sitename'];
+
+ if (!$profiledata && !PConfig::get(local_user(), 'system', 'always_my_theme')) {
+ $_SESSION['theme'] = $a->profile['theme'];
+ }
+
+ $_SESSION['mobile-theme'] = $a->profile['mobile-theme'];
+
+ /*
+ * load/reload current theme info
+ */
+
+ $a->set_template_engine(); // reset the template engine to the default in case the user's theme doesn't specify one
+
+ $theme_info_file = 'view/theme/' . current_theme() . '/theme.php';
+ if (file_exists($theme_info_file)) {
+ require_once $theme_info_file;
+ }
+
+ if (!x($a->page, 'aside')) {
+ $a->page['aside'] = '';
+ }
+
+ if (local_user() && local_user() == $a->profile['uid'] && $profiledata) {
+ $a->page['aside'] .= replace_macros(
+ get_markup_template('profile_edlink.tpl'),
+ array(
+ '$editprofile' => t('Edit profile'),
+ '$profid' => $a->profile['id']
+ )
+ );
+ }
+
+ $block = ((Config::get('system', 'block_public') && !local_user() && !remote_user()) ? true : false);
+
+ /**
+ * @todo
+ * By now, the contact block isn't shown, when a different profile is given
+ * But: When this profile was on the same server, then we could display the contacts
+ */
+ if (!$profiledata) {
+ $a->page['aside'] .= self::sidebar($a->profile, $block, $show_connect);
+ }
+
+ return;
+ }
+
+ /**
+ * Get all profile data of a local user
+ *
+ * If the viewer is an authenticated remote viewer, the profile displayed is the
+ * one that has been configured for his/her viewing in the Contact manager.
+ * Passing a non-zero profile ID can also allow a preview of a selected profile
+ * by the owner
+ *
+ * Includes all available profile data
+ *
+ * @brief Get all profile data of a local user
+ * @param string $nickname nick
+ * @param int $uid uid
+ * @param int $profile_id ID of the profile
+ * @return array
+ */
+ public static function getByNickname($nickname, $uid = 0, $profile_id = 0)
+ {
+ if (remote_user() && count($_SESSION['remote'])) {
+ foreach ($_SESSION['remote'] as $visitor) {
+ if ($visitor['uid'] == $uid) {
+ $contact = dba::selectFirst('contact', ['profile-id'], ['id' => $visitor['cid']]);
+ if (DBM::is_result($contact)) {
+ $profile_id = $contact['profile-id'];
+ }
+ break;
+ }
+ }
+ }
+
+ $profile = null;
+
+ if ($profile_id) {
+ $profile = dba::fetch_first(
+ "SELECT `contact`.`id` AS `contact_id`, `contact`.`photo` AS `contact_photo`,
+ `contact`.`thumb` AS `contact_thumb`, `contact`.`micro` AS `contact_micro`,
+ `profile`.`uid` AS `profile_uid`, `profile`.*,
+ `contact`.`avatar-date` AS picdate, `contact`.`addr`, `contact`.`url`, `user`.*
+ FROM `profile`
+ INNER JOIN `contact` on `contact`.`uid` = `profile`.`uid` AND `contact`.`self`
+ INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
+ WHERE `user`.`nickname` = ? AND `profile`.`id` = ? LIMIT 1",
+ $nickname,
+ intval($profile_id)
+ );
+ }
+ if (!DBM::is_result($profile)) {
+ $profile = dba::fetch_first(
+ "SELECT `contact`.`id` AS `contact_id`, `contact`.`photo` as `contact_photo`,
+ `contact`.`thumb` AS `contact_thumb`, `contact`.`micro` AS `contact_micro`,
+ `profile`.`uid` AS `profile_uid`, `profile`.*,
+ `contact`.`avatar-date` AS picdate, `contact`.`addr`, `contact`.`url`, `user`.*
+ FROM `profile`
+ INNER JOIN `contact` ON `contact`.`uid` = `profile`.`uid` AND `contact`.`self`
+ INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
+ WHERE `user`.`nickname` = ? AND `profile`.`is-default` LIMIT 1",
+ $nickname
+ );
+ }
+
+ return $profile;
+ }
+
+ /**
+ * Formats a profile for display in the sidebar.
+ *
+ * It is very difficult to templatise the HTML completely
+ * because of all the conditional logic.
+ *
+ * @brief Formats a profile for display in the sidebar.
+ * @param array $profile
+ * @param int $block
+ * @param boolean $show_connect Show connect link
+ *
+ * @return HTML string suitable for sidebar inclusion
+ *
+ * @note Returns empty string if passed $profile is wrong type or not populated
+ *
+ * @hooks 'profile_sidebar_enter'
+ * array $profile - profile data
+ * @hooks 'profile_sidebar'
+ * array $arr
+ */
+ private static function sidebar($profile, $block = 0, $show_connect = true)
+ {
+ $a = get_app();
+
+ $o = '';
+ $location = false;
+
+ // This function can also use contact information in $profile
+ $is_contact = x($profile, 'cid');
+
+ if (!is_array($profile) && !count($profile)) {
+ return $o;
+ }
+
+ $profile['picdate'] = urlencode(defaults($profile, 'picdate', ''));
+
+ if (($profile['network'] != '') && ($profile['network'] != NETWORK_DFRN)) {
+ $profile['network_name'] = format_network_name($profile['network'], $profile['url']);
+ } else {
+ $profile['network_name'] = '';
+ }
+
+ call_hooks('profile_sidebar_enter', $profile);
+
+
+ // don't show connect link to yourself
+ $connect = $profile['uid'] != local_user() ? t('Connect') : false;
+
+ // don't show connect link to authenticated visitors either
+ if (remote_user() && count($_SESSION['remote'])) {
+ foreach ($_SESSION['remote'] as $visitor) {
+ if ($visitor['uid'] == $profile['uid']) {
+ $connect = false;
+ break;
+ }
+ }
+ }
+
+ if (!$show_connect) {
+ $connect = false;
+ }
+
+ // Is the local user already connected to that user?
+ if ($connect && local_user()) {
+ if (isset($profile['url'])) {
+ $profile_url = normalise_link($profile['url']);
+ } else {
+ $profile_url = normalise_link(System::baseUrl() . '/profile/' . $profile['nickname']);
+ }
+
+ if (dba::exists('contact', array('pending' => false, 'uid' => local_user(), 'nurl' => $profile_url))) {
+ $connect = false;
+ }
+ }
+
+ if ($connect && ($profile['network'] != NETWORK_DFRN) && !isset($profile['remoteconnect'])) {
+ $connect = false;
+ }
+
+ $remoteconnect = null;
+ if (isset($profile['remoteconnect'])) {
+ $remoteconnect = $profile['remoteconnect'];
+ }
+
+ if ($connect && ($profile['network'] == NETWORK_DFRN) && !isset($remoteconnect)) {
+ $subscribe_feed = t('Atom feed');
+ } else {
+ $subscribe_feed = false;
+ }
+
+ if (remote_user() || (self::getMyURL() && x($profile, 'unkmail') && ($profile['uid'] != local_user()))) {
+ $wallmessage = t('Message');
+ $wallmessage_link = 'wallmessage/' . $profile['nickname'];
+
+ if (remote_user()) {
+ $r = q(
+ "SELECT `url` FROM `contact` WHERE `uid` = %d AND `id` = '%s' AND `rel` = %d",
+ intval($profile['uid']),
+ intval(remote_user()),
+ intval(CONTACT_IS_FRIEND)
+ );
+ } else {
+ $r = q(
+ "SELECT `url` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `rel` = %d",
+ intval($profile['uid']),
+ dbesc(normalise_link(self::getMyURL())),
+ intval(CONTACT_IS_FRIEND)
+ );
+ }
+ if ($r) {
+ $remote_url = $r[0]['url'];
+ $message_path = preg_replace('=(.*)/profile/(.*)=ism', '$1/message/new/', $remote_url);
+ $wallmessage_link = $message_path . base64_encode($profile['addr']);
+ }
+ } else {
+ $wallmessage = false;
+ $wallmessage_link = false;
+ }
+
+ // show edit profile to yourself
+ if (!$is_contact && $profile['uid'] == local_user() && Feature::isEnabled(local_user(), 'multi_profiles')) {
+ $profile['edit'] = array(System::baseUrl() . '/profiles', t('Profiles'), '', t('Manage/edit profiles'));
+ $r = q(
+ "SELECT * FROM `profile` WHERE `uid` = %d",
+ local_user()
+ );
+
+ $profile['menu'] = array(
+ 'chg_photo' => t('Change profile photo'),
+ 'cr_new' => t('Create New Profile'),
+ 'entries' => array(),
+ );
+
+ if (DBM::is_result($r)) {
+ foreach ($r as $rr) {
+ $profile['menu']['entries'][] = array(
+ 'photo' => $rr['thumb'],
+ 'id' => $rr['id'],
+ 'alt' => t('Profile Image'),
+ 'profile_name' => $rr['profile-name'],
+ 'isdefault' => $rr['is-default'],
+ 'visibile_to_everybody' => t('visible to everybody'),
+ 'edit_visibility' => t('Edit visibility'),
+ );
+ }
+ }
+ }
+ if (!$is_contact && $profile['uid'] == local_user() && !Feature::isEnabled(local_user(), 'multi_profiles')) {
+ $profile['edit'] = array(System::baseUrl() . '/profiles/' . $profile['id'], t('Edit profile'), '', t('Edit profile'));
+ $profile['menu'] = array(
+ 'chg_photo' => t('Change profile photo'),
+ 'cr_new' => null,
+ 'entries' => array(),
+ );
+ }
+
+ // Fetch the account type
+ $account_type = Contact::getAccountType($profile);
+
+ if (x($profile, 'address')
+ || x($profile, 'location')
+ || x($profile, 'locality')
+ || x($profile, 'region')
+ || x($profile, 'postal-code')
+ || x($profile, 'country-name')
+ ) {
+ $location = t('Location:');
+ }
+
+ $gender = x($profile, 'gender') ? t('Gender:') : false;
+ $marital = x($profile, 'marital') ? t('Status:') : false;
+ $homepage = x($profile, 'homepage') ? t('Homepage:') : false;
+ $about = x($profile, 'about') ? t('About:') : false;
+ $xmpp = x($profile, 'xmpp') ? t('XMPP:') : false;
+
+ if ((x($profile, 'hidewall') || $block) && !local_user() && !remote_user()) {
+ $location = $gender = $marital = $homepage = $about = false;
+ }
+
+ $split_name = Diaspora::splitName($profile['name']);
+ $firstname = $split_name['first'];
+ $lastname = $split_name['last'];
+
+ if (x($profile, 'guid')) {
+ $diaspora = array(
+ 'guid' => $profile['guid'],
+ 'podloc' => System::baseUrl(),
+ 'searchable' => (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false' ),
+ 'nickname' => $profile['nickname'],
+ 'fullname' => $profile['name'],
+ 'firstname' => $firstname,
+ 'lastname' => $lastname,
+ 'photo300' => $profile['contact_photo'],
+ 'photo100' => $profile['contact_thumb'],
+ 'photo50' => $profile['contact_micro'],
+ );
+ } else {
+ $diaspora = false;
+ }
+
+ $contact_block = '';
+ $updated = '';
+ $contacts = 0;
+ if (!$block) {
+ $contact_block = contact_block();
+
+ if (is_array($a->profile) && !$a->profile['hide-friends']) {
+ $r = q(
+ "SELECT `gcontact`.`updated` FROM `contact` INNER JOIN `gcontact` WHERE `gcontact`.`nurl` = `contact`.`nurl` AND `self` AND `uid` = %d LIMIT 1",
+ intval($a->profile['uid'])
+ );
+ if (DBM::is_result($r)) {
+ $updated = date('c', strtotime($r[0]['updated']));
+ }
+
+ $r = q(
+ "SELECT COUNT(*) AS `total` FROM `contact`
+ WHERE `uid` = %d
+ AND NOT `self` AND NOT `blocked` AND NOT `pending`
+ AND NOT `hidden` AND NOT `archive`
+ AND `network` IN ('%s', '%s', '%s', '')",
+ intval($profile['uid']),
+ dbesc(NETWORK_DFRN),
+ dbesc(NETWORK_DIASPORA),
+ dbesc(NETWORK_OSTATUS)
+ );
+ if (DBM::is_result($r)) {
+ $contacts = intval($r[0]['total']);
+ }
+ }
+ }
+
+ $p = array();
+ foreach ($profile as $k => $v) {
+ $k = str_replace('-', '_', $k);
+ $p[$k] = $v;
+ }
+
+ if (isset($p['about'])) {
+ $p['about'] = bbcode($p['about']);
+ }
+
+ if (isset($p['address'])) {
+ $p['address'] = bbcode($p['address']);
+ } else {
+ $p['address'] = bbcode($p['location']);
+ }
+
+ if (isset($p['photo'])) {
+ $p['photo'] = proxy_url($p['photo'], false, PROXY_SIZE_SMALL);
+ }
+
+ $tpl = get_markup_template('profile_vcard.tpl');
+ $o .= replace_macros($tpl, array(
+ '$profile' => $p,
+ '$xmpp' => $xmpp,
+ '$connect' => $connect,
+ '$remoteconnect' => $remoteconnect,
+ '$subscribe_feed' => $subscribe_feed,
+ '$wallmessage' => $wallmessage,
+ '$wallmessage_link' => $wallmessage_link,
+ '$account_type' => $account_type,
+ '$location' => $location,
+ '$gender' => $gender,
+ '$marital' => $marital,
+ '$homepage' => $homepage,
+ '$about' => $about,
+ '$network' => t('Network:'),
+ '$contacts' => $contacts,
+ '$updated' => $updated,
+ '$diaspora' => $diaspora,
+ '$contact_block' => $contact_block,
+ ));
+
+ $arr = array('profile' => &$profile, 'entry' => &$o);
+
+ call_hooks('profile_sidebar', $arr);
+
+ return $o;
+ }
+
+ public static function getBirthdays()
+ {
+ $a = get_app();
+ $o = '';
+
+ if (!local_user() || $a->is_mobile || $a->is_tablet) {
+ return $o;
+ }
+
+ /*
+ * $mobile_detect = new Mobile_Detect();
+ * $is_mobile = $mobile_detect->isMobile() || $mobile_detect->isTablet();
+ * if ($is_mobile)
+ * return $o;
+ */
+
+ $bd_format = t('g A l F d'); // 8 AM Friday January 18
+ $bd_short = t('F d');
+
+ $cachekey = 'get_birthdays:' . local_user();
+ $r = Cache::get($cachekey);
+ if (is_null($r)) {
+ $s = dba::p(
+ "SELECT `event`.*, `event`.`id` AS `eid`, `contact`.* FROM `event`
+ INNER JOIN `contact` ON `contact`.`id` = `event`.`cid`
+ WHERE `event`.`uid` = ? AND `type` = 'birthday' AND `start` < ? AND `finish` > ?
+ ORDER BY `start` ASC ",
+ local_user(),
+ datetime_convert('UTC', 'UTC', 'now + 6 days'),
+ datetime_convert('UTC', 'UTC', 'now')
+ );
+ if (DBM::is_result($s)) {
+ $r = dba::inArray($s);
+ Cache::set($cachekey, $r, CACHE_HOUR);
+ }
+ }
+ if (DBM::is_result($r)) {
+ $total = 0;
+ $now = strtotime('now');
+ $cids = array();
+
+ $istoday = false;
+ foreach ($r as $rr) {
+ if (strlen($rr['name'])) {
+ $total ++;
+ }
+ if ((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) {
+ $istoday = true;
+ }
+ }
+ $classtoday = $istoday ? ' birthday-today ' : '';
+ if ($total) {
+ foreach ($r as &$rr) {
+ if (!strlen($rr['name'])) {
+ continue;
+ }
+
+ // avoid duplicates
+
+ if (in_array($rr['cid'], $cids)) {
+ continue;
+ }
+ $cids[] = $rr['cid'];
+
+ $today = (((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) ? true : false);
+ $url = $rr['url'];
+ if ($rr['network'] === NETWORK_DFRN) {
+ $url = System::baseUrl() . '/redir/' . $rr['cid'];
+ }
+
+ $rr['link'] = $url;
+ $rr['title'] = $rr['name'];
+ $rr['date'] = day_translate(datetime_convert('UTC', $a->timezone, $rr['start'], $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . t('[today]') : '');
+ $rr['startime'] = null;
+ $rr['today'] = $today;
+ }
+ }
+ }
+ $tpl = get_markup_template('birthdays_reminder.tpl');
+ return replace_macros($tpl, array(
+ '$baseurl' => System::baseUrl(),
+ '$classtoday' => $classtoday,
+ '$count' => $total,
+ '$event_reminders' => t('Birthday Reminders'),
+ '$event_title' => t('Birthdays this week:'),
+ '$events' => $r,
+ '$lbr' => '{', // raw brackets mess up if/endif macro processing
+ '$rbr' => '}'
+ ));
+ }
+
+ public static function getEvents()
+ {
+ require_once 'include/bbcode.php';
+
+ $a = get_app();
+
+ if (!local_user() || $a->is_mobile || $a->is_tablet) {
+ return $o;
+ }
+
+ /*
+ * $mobile_detect = new Mobile_Detect();
+ * $is_mobile = $mobile_detect->isMobile() || $mobile_detect->isTablet();
+ * if ($is_mobile)
+ * return $o;
+ */
+
+ $bd_format = t('g A l F d'); // 8 AM Friday January 18
+ $classtoday = '';
+
+ $s = dba::p(
+ "SELECT `event`.* FROM `event`
+ WHERE `event`.`uid` = ? AND `type` != 'birthday' AND `start` < ? AND `start` >= ?
+ ORDER BY `start` ASC ",
+ local_user(),
+ datetime_convert('UTC', 'UTC', 'now + 7 days'),
+ datetime_convert('UTC', 'UTC', 'now - 1 days')
+ );
+
+ $r = array();
+
+ if (DBM::is_result($s)) {
+ $istoday = false;
+
+ while ($rr = dba::fetch($s)) {
+ if (strlen($rr['name'])) {
+ $total ++;
+ }
+
+ $strt = datetime_convert('UTC', $rr['convert'] ? $a->timezone : 'UTC', $rr['start'], 'Y-m-d');
+ if ($strt === datetime_convert('UTC', $a->timezone, 'now', 'Y-m-d')) {
+ $istoday = true;
+ }
+
+ $title = strip_tags(html_entity_decode(bbcode($rr['summary']), ENT_QUOTES, 'UTF-8'));
+
+ if (strlen($title) > 35) {
+ $title = substr($title, 0, 32) . '... ';
+ }
+
+ $description = substr(strip_tags(bbcode($rr['desc'])), 0, 32) . '... ';
+ if (!$description) {
+ $description = t('[No description]');
+ }
+
+ $strt = datetime_convert('UTC', $rr['convert'] ? $a->timezone : 'UTC', $rr['start']);
+
+ if (substr($strt, 0, 10) < datetime_convert('UTC', $a->timezone, 'now', 'Y-m-d')) {
+ continue;
+ }
+
+ $today = ((substr($strt, 0, 10) === datetime_convert('UTC', $a->timezone, 'now', 'Y-m-d')) ? true : false);
+
+ $rr['title'] = $title;
+ $rr['description'] = $description;
+ $rr['date'] = day_translate(datetime_convert('UTC', $rr['adjust'] ? $a->timezone : 'UTC', $rr['start'], $bd_format)) . (($today) ? ' ' . t('[today]') : '');
+ $rr['startime'] = $strt;
+ $rr['today'] = $today;
+
+ $r[] = $rr;
+ }
+ dba::close($s);
+ $classtoday = (($istoday) ? 'event-today' : '');
+ }
+ $tpl = get_markup_template('events_reminder.tpl');
+ return replace_macros($tpl, array(
+ '$baseurl' => System::baseUrl(),
+ '$classtoday' => $classtoday,
+ '$count' => count($r),
+ '$event_reminders' => t('Event Reminders'),
+ '$event_title' => t('Events this week:'),
+ '$events' => $r,
+ ));
+ }
+
+ public static function getAdvanced(App $a)
+ {
+ $o = '';
+ $uid = $a->profile['uid'];
+
+ $o .= replace_macros(
+ get_markup_template('section_title.tpl'),
+ array('$title' => t('Profile'))
+ );
+
+ if ($a->profile['name']) {
+ $tpl = get_markup_template('profile_advanced.tpl');
+
+ $profile = array();
+
+ $profile['fullname'] = array(t('Full Name:'), $a->profile['name']);
+
+ if ($a->profile['gender']) {
+ $profile['gender'] = array(t('Gender:'), $a->profile['gender']);
+ }
+
+ if (($a->profile['dob']) && ($a->profile['dob'] > '0001-01-01')) {
+ $year_bd_format = t('j F, Y');
+ $short_bd_format = t('j F');
+
+ $val = intval($a->profile['dob']) ?
+ day_translate(datetime_convert('UTC', 'UTC', $a->profile['dob'] . ' 00:00 +00:00', $year_bd_format))
+ : day_translate(datetime_convert('UTC', 'UTC', '2001-' . substr($a->profile['dob'], 5) . ' 00:00 +00:00', $short_bd_format));
+
+ $profile['birthday'] = array(t('Birthday:'), $val);
+ }
+
+ if (!empty($a->profile['dob'])
+ && $a->profile['dob'] > '0001-01-01'
+ && $age = age($a->profile['dob'], $a->profile['timezone'], '')
+ ) {
+ $profile['age'] = array(t('Age:'), $age);
+ }
+
+ if ($a->profile['marital']) {
+ $profile['marital'] = array(t('Status:'), $a->profile['marital']);
+ }
+
+ /// @TODO Maybe use x() here, plus below?
+ if ($a->profile['with']) {
+ $profile['marital']['with'] = $a->profile['with'];
+ }
+
+ if (strlen($a->profile['howlong']) && $a->profile['howlong'] >= NULL_DATE) {
+ $profile['howlong'] = relative_date($a->profile['howlong'], t('for %1$d %2$s'));
+ }
+
+ if ($a->profile['sexual']) {
+ $profile['sexual'] = array(t('Sexual Preference:'), $a->profile['sexual']);
+ }
+
+ if ($a->profile['homepage']) {
+ $profile['homepage'] = array(t('Homepage:'), linkify($a->profile['homepage']));
+ }
+
+ if ($a->profile['hometown']) {
+ $profile['hometown'] = array(t('Hometown:'), linkify($a->profile['hometown']));
+ }
+
+ if ($a->profile['pub_keywords']) {
+ $profile['pub_keywords'] = array(t('Tags:'), $a->profile['pub_keywords']);
+ }
+
+ if ($a->profile['politic']) {
+ $profile['politic'] = array(t('Political Views:'), $a->profile['politic']);
+ }
+
+ if ($a->profile['religion']) {
+ $profile['religion'] = array(t('Religion:'), $a->profile['religion']);
+ }
+
+ if ($txt = prepare_text($a->profile['about'])) {
+ $profile['about'] = array(t('About:'), $txt);
+ }
+
+ if ($txt = prepare_text($a->profile['interest'])) {
+ $profile['interest'] = array(t('Hobbies/Interests:'), $txt);
+ }
+
+ if ($txt = prepare_text($a->profile['likes'])) {
+ $profile['likes'] = array(t('Likes:'), $txt);
+ }
+
+ if ($txt = prepare_text($a->profile['dislikes'])) {
+ $profile['dislikes'] = array(t('Dislikes:'), $txt);
+ }
+
+ if ($txt = prepare_text($a->profile['contact'])) {
+ $profile['contact'] = array(t('Contact information and Social Networks:'), $txt);
+ }
+
+ if ($txt = prepare_text($a->profile['music'])) {
+ $profile['music'] = array(t('Musical interests:'), $txt);
+ }
+
+ if ($txt = prepare_text($a->profile['book'])) {
+ $profile['book'] = array(t('Books, literature:'), $txt);
+ }
+
+ if ($txt = prepare_text($a->profile['tv'])) {
+ $profile['tv'] = array(t('Television:'), $txt);
+ }
+
+ if ($txt = prepare_text($a->profile['film'])) {
+ $profile['film'] = array(t('Film/dance/culture/entertainment:'), $txt);
+ }
+
+ if ($txt = prepare_text($a->profile['romance'])) {
+ $profile['romance'] = array(t('Love/Romance:'), $txt);
+ }
+
+ if ($txt = prepare_text($a->profile['work'])) {
+ $profile['work'] = array(t('Work/employment:'), $txt);
+ }
+
+ if ($txt = prepare_text($a->profile['education'])) {
+ $profile['education'] = array(t('School/education:'), $txt);
+ }
+
+ //show subcribed forum if it is enabled in the usersettings
+ if (Feature::isEnabled($uid, 'forumlist_profile')) {
+ $profile['forumlist'] = array(t('Forums:'), ForumManager::profileAdvanced($uid));
+ }
+
+ if ($a->profile['uid'] == local_user()) {
+ $profile['edit'] = array(System::baseUrl() . '/profiles/' . $a->profile['id'], t('Edit profile'), '', t('Edit profile'));
+ }
+
+ return replace_macros($tpl, array(
+ '$title' => t('Profile'),
+ '$basic' => t('Basic'),
+ '$advanced' => t('Advanced'),
+ '$profile' => $profile
+ ));
+ }
+
+ return '';
+ }
+
+ public static function getTabs($a, $is_owner = false, $nickname = null)
+ {
+ if (is_null($nickname)) {
+ $nickname = $a->user['nickname'];
+ }
+
+ $tab = false;
+ if (x($_GET, 'tab')) {
+ $tab = notags(trim($_GET['tab']));
+ }
+
+ $url = System::baseUrl() . '/profile/' . $nickname;
+
+ $tabs = array(
+ array(
+ 'label' => t('Status'),
+ 'url' => $url,
+ 'sel' => !$tab && $a->argv[0] == 'profile' ? 'active' : '',
+ 'title' => t('Status Messages and Posts'),
+ 'id' => 'status-tab',
+ 'accesskey' => 'm',
+ ),
+ array(
+ 'label' => t('Profile'),
+ 'url' => $url . '/?tab=profile',
+ 'sel' => $tab == 'profile' ? 'active' : '',
+ 'title' => t('Profile Details'),
+ 'id' => 'profile-tab',
+ 'accesskey' => 'r',
+ ),
+ array(
+ 'label' => t('Photos'),
+ 'url' => System::baseUrl() . '/photos/' . $nickname,
+ 'sel' => !$tab && $a->argv[0] == 'photos' ? 'active' : '',
+ 'title' => t('Photo Albums'),
+ 'id' => 'photo-tab',
+ 'accesskey' => 'h',
+ ),
+ array(
+ 'label' => t('Videos'),
+ 'url' => System::baseUrl() . '/videos/' . $nickname,
+ 'sel' => !$tab && $a->argv[0] == 'videos' ? 'active' : '',
+ 'title' => t('Videos'),
+ 'id' => 'video-tab',
+ 'accesskey' => 'v',
+ ),
+ );
+
+ // the calendar link for the full featured events calendar
+ if ($is_owner && $a->theme_events_in_profile) {
+ $tabs[] = array(
+ 'label' => t('Events'),
+ 'url' => System::baseUrl() . '/events',
+ 'sel' => !$tab && $a->argv[0] == 'events' ? 'active' : '',
+ 'title' => t('Events and Calendar'),
+ 'id' => 'events-tab',
+ 'accesskey' => 'e',
+ );
+ // if the user is not the owner of the calendar we only show a calendar
+ // with the public events of the calendar owner
+ } elseif (!$is_owner) {
+ $tabs[] = array(
+ 'label' => t('Events'),
+ 'url' => System::baseUrl() . '/cal/' . $nickname,
+ 'sel' => !$tab && $a->argv[0] == 'cal' ? 'active' : '',
+ 'title' => t('Events and Calendar'),
+ 'id' => 'events-tab',
+ 'accesskey' => 'e',
+ );
+ }
+
+ if ($is_owner) {
+ $tabs[] = array(
+ 'label' => t('Personal Notes'),
+ 'url' => System::baseUrl() . '/notes',
+ 'sel' => !$tab && $a->argv[0] == 'notes' ? 'active' : '',
+ 'title' => t('Only You Can See This'),
+ 'id' => 'notes-tab',
+ 'accesskey' => 't',
+ );
+ }
+
+ if ((!$is_owner) && ((count($a->profile)) || (!$a->profile['hide-friends']))) {
+ $tabs[] = array(
+ 'label' => t('Contacts'),
+ 'url' => System::baseUrl() . '/viewcontacts/' . $nickname,
+ 'sel' => !$tab && $a->argv[0] == 'viewcontacts' ? 'active' : '',
+ 'title' => t('Contacts'),
+ 'id' => 'viewcontacts-tab',
+ 'accesskey' => 'k',
+ );
+ }
+
+ $arr = array('is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => $tab, 'tabs' => $tabs);
+ call_hooks('profile_tabs', $arr);
+
+ $tpl = get_markup_template('common_tabs.tpl');
+
+ return replace_macros($tpl, array('$tabs' => $arr['tabs']));
+ }
+
+ /**
+ * Retrieves the my_url session variable
+ *
+ * @return string
+ */
+ public static function getMyURL()
+ {
+ if (x($_SESSION, 'my_url')) {
+ return $_SESSION['my_url'];
+ }
+ return null;
+ }
+
+ public static function zrlInit(App $a)
+ {
+ $my_url = self::getMyURL();
+ $my_url = validate_url($my_url);
+ if ($my_url) {
+ // Is it a DDoS attempt?
+ // The check fetches the cached value from gprobe to reduce the load for this system
+ $urlparts = parse_url($my_url);
+
+ $result = Cache::get('gprobe:' . $urlparts['host']);
+ if ((!is_null($result)) && (in_array($result['network'], array(NETWORK_FEED, NETWORK_PHANTOM)))) {
+ logger('DDoS attempt detected for ' . $urlparts['host'] . ' by ' . $_SERVER['REMOTE_ADDR'] . '. server data: ' . print_r($_SERVER, true), LOGGER_DEBUG);
+ return;
+ }
+
+ Worker::add(PRIORITY_LOW, 'GProbe', $my_url);
+ $arr = array('zrl' => $my_url, 'url' => $a->cmd);
+ call_hooks('zrl_init', $arr);
+ }
+ }
+
+ public static function zrl($s, $force = false)
+ {
+ if (!strlen($s)) {
+ return $s;
+ }
+ if ((!strpos($s, '/profile/')) && (!$force)) {
+ return $s;
+ }
+ if ($force && substr($s, -1, 1) !== '/') {
+ $s = $s . '/';
+ }
+ $achar = strpos($s, '?') ? '&' : '?';
+ $mine = self::getMyURL();
+ if ($mine && !link_compare($mine, $s)) {
+ return $s . $achar . 'zrl=' . urlencode($mine);
+ }
+ return $s;
+ }
+
+ /**
+ * Get the user ID of the page owner.
+ *
+ * Used from within PCSS themes to set theme parameters. If there's a
+ * puid request variable, that is the "page owner" and normally their theme
+ * settings take precedence; unless a local user sets the "always_my_theme"
+ * system pconfig, which means they don't want to see anybody else's theme
+ * settings except their own while on this site.
+ *
+ * @brief Get the user ID of the page owner
+ * @return int user ID
+ *
+ * @note Returns local_user instead of user ID if "always_my_theme"
+ * is set to true
+ */
+ public static function getThemeUid()
+ {
+ $uid = ((!empty($_REQUEST['puid'])) ? intval($_REQUEST['puid']) : 0);
+ if ((local_user()) && ((PConfig::get(local_user(), 'system', 'always_my_theme')) || (!$uid))) {
+ return local_user();
+ }
+
+ return $uid;
+ }
}
diff --git a/src/Object/Post.php b/src/Object/Post.php
index dada4dd65..9a131e903 100644
--- a/src/Object/Post.php
+++ b/src/Object/Post.php
@@ -10,6 +10,7 @@ use Friendica\Content\Feature;
use Friendica\Core\PConfig;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
+use Friendica\Model\Profile;
use dba;
require_once 'include/dba.php';
@@ -190,7 +191,7 @@ class Post extends BaseObject
if ($sp) {
$sparkle = ' sparkle';
} else {
- $profile_link = zrl($profile_link);
+ $profile_link = Profile::zrl($profile_link);
}
if (!isset($item['author-thumb']) || ($item['author-thumb'] == "")) {
@@ -832,7 +833,7 @@ class Post extends BaseObject
// This will have been stored in $a->page_contact by our calling page.
// Put this person as the wall owner of the wall-to-wall notice.
- $this->owner_url = zrl($a->page_contact['url']);
+ $this->owner_url = Profile::zrl($a->page_contact['url']);
$this->owner_photo = $a->page_contact['thumb'];
$this->owner_name = $a->page_contact['name'];
$this->wall_to_wall = true;
@@ -860,7 +861,7 @@ class Post extends BaseObject
) {
$this->owner_url = $this->getRedirectUrl();
} else {
- $this->owner_url = zrl($this->getDataValue('owner-link'));
+ $this->owner_url = Profile::zrl($this->getDataValue('owner-link'));
}
}
}
diff --git a/view/theme/duepuntozero/style.php b/view/theme/duepuntozero/style.php
index 48be1e026..5d841f108 100644
--- a/view/theme/duepuntozero/style.php
+++ b/view/theme/duepuntozero/style.php
@@ -1,31 +1,48 @@
profile_uid;
if (is_null($uid)) {
- $uid = get_theme_uid();
+ $uid = Profile::getThemeUid();
}
$schema = PConfig::get($uid, 'frio', 'schema');
if (($schema) && ($schema != '---')) {
diff --git a/view/theme/frio/style.php b/view/theme/frio/style.php
index 5d820af52..7bc9629d4 100644
--- a/view/theme/frio/style.php
+++ b/view/theme/frio/style.php
@@ -1,8 +1,12 @@
module !== 'install') {
// Get the UID of the profile owner.
- $uid = get_theme_uid();
+ $uid = Profile::getThemeUid();
if ($uid) {
PConfig::load($uid, 'frio');
@@ -80,11 +84,11 @@ if (($schema) && ($schema != '---')) {
// should leave it for admins to define for themselves.
// default.php and default.css MUST be symlinks to existing schema files.
if (! $schema) {
- if(file_exists('view/theme/frio/schema/default.php')) {
+ if (file_exists('view/theme/frio/schema/default.php')) {
$schemefile = 'view/theme/frio/schema/default.php';
require_once $schemefile;
}
- if(file_exists('view/theme/frio/schema/default.css')) {
+ if (file_exists('view/theme/frio/schema/default.css')) {
$schemecssfile = 'view/theme/frio/schema/default.css';
}
}
@@ -135,7 +139,6 @@ if (!isset($link_hover_color)) {
} else {
$link_hover_color = '#' . $lhc->lighten(5);
}
-
}
// Convert $bg_image_options into css.
diff --git a/view/theme/frio/theme.php b/view/theme/frio/theme.php
index 559fc94a2..b135fa0d6 100644
--- a/view/theme/frio/theme.php
+++ b/view/theme/frio/theme.php
@@ -13,6 +13,7 @@ use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBM;
+use Friendica\Model\Profile;
use Friendica\Object\Image;
$frio = "view/theme/frio";
@@ -197,7 +198,7 @@ function frio_contact_photo_menu(App $a, &$args)
function frio_remote_nav($a, &$nav)
{
// get the homelink from $_XSESSION
- $homelink = get_my_url();
+ $homelink = Profile::getMyURL();
if (!$homelink) {
$homelink = defaults($_SESSION, 'visitor_home', '');
}
@@ -234,7 +235,7 @@ function frio_remote_nav($a, &$nav)
} elseif (!local_user() && remote_user()) {
$r = q("SELECT `name`, `nick`, `micro` AS `photo` FROM `contact` WHERE `id` = %d", intval(remote_user()));
$nav['remote'] = t("Guest");
- } elseif (get_my_url()) {
+ } elseif (Profile::getMyURL()) {
$r = q("SELECT `name`, `nick`, `photo` FROM `gcontact`
WHERE `addr` = '%s' AND `network` = 'dfrn'",
dbesc($webbie));
diff --git a/view/theme/quattro/style.php b/view/theme/quattro/style.php
index 2aaf3af50..815846832 100644
--- a/view/theme/quattro/style.php
+++ b/view/theme/quattro/style.php
@@ -1,65 +1,68 @@
$modified)
+if ($stylemodified > $modified) {
$modified = $stylemodified;
+}
$modified = gmdate('r', $modified);
diff --git a/view/theme/vier/theme.php b/view/theme/vier/theme.php
index b7c76b02e..26066ccb0 100644
--- a/view/theme/vier/theme.php
+++ b/view/theme/vier/theme.php
@@ -16,6 +16,7 @@ use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\GContact;
+use Friendica\Model\Profile;
require_once "include/plugin.php";
require_once "mod/proxy.php";
@@ -150,7 +151,7 @@ function vier_community_info() {
foreach ($r as $rr) {
$entry = replace_macros($tpl,array(
'$id' => $rr['id'],
- //'$profile_link' => zrl($rr['url']),
+ //'$profile_link' => Profile::zrl($rr['url']),
'$profile_link' => 'follow/?url='.urlencode($rr['url']),
'$photo' => proxy_url($rr['photo'], false, PROXY_SIZE_MICRO),
'$alt_text' => $rr['name'],
@@ -280,7 +281,7 @@ function vier_community_info() {
}
foreach ($r AS $index => $helper)
- $r[$index]["url"] = zrl($helper["url"]);
+ $r[$index]["url"] = Profile::zrl($helper["url"]);
$r[] = array("url" => "help/Quick-Start-guide", "name" => t("Quick Start"));