Review updates
Update function name, descriptive variable names.
This commit is contained in:
parent
41159cd14f
commit
430bd7c6ac
|
@ -33,14 +33,14 @@ function allfriends_content(App $a)
|
||||||
|
|
||||||
$uid = $a->user['uid'];
|
$uid = $a->user['uid'];
|
||||||
|
|
||||||
$c = dba::selectFirst('contact', ['name', 'url', 'photo'], ['id' => $cid, 'uid' => 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$a->page['aside'] = "";
|
$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);
|
$total = GContact::countAllFriends(local_user(), $cid);
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ function cal_init(App $a)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile = Profile::getProfiledataByNick($nick, $a->profile_uid);
|
$profile = Profile::getByNickname($nick, $a->profile_uid);
|
||||||
|
|
||||||
$account_type = Contact::getAccountType($profile);
|
$account_type = Contact::getAccountType($profile);
|
||||||
|
|
||||||
|
|
|
@ -36,19 +36,19 @@ function common_content(App $a)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cmd === 'loc' && $cid) {
|
if ($cmd === 'loc' && $cid) {
|
||||||
$c = dba::selectFirst('contact', ['name', 'url', 'photo'], ['id' => $cid, 'uid' => $uid]);
|
$contact = dba::selectFirst('contact', ['name', 'url', 'photo'], ['id' => $cid, 'uid' => $uid]);
|
||||||
|
|
||||||
if (DBM::is_result($c)) {
|
if (DBM::is_result($contact)) {
|
||||||
$a->page['aside'] = "";
|
$a->page['aside'] = "";
|
||||||
Profile::load($a, "", 0, Contact::getDetailsByURL($c["url"]));
|
Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$c = dba::selectFirst('contact', ['name', 'url', 'photo'], ['self' => true, 'uid' => $uid]);
|
$contact = dba::selectFirst('contact', ['name', 'url', 'photo'], ['self' => true, 'uid' => $uid]);
|
||||||
|
|
||||||
if (DBM::is_result($c)) {
|
if (DBM::is_result($contact)) {
|
||||||
$vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), array(
|
$vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), array(
|
||||||
'$name' => htmlentities($c['name']),
|
'$name' => htmlentities($contact['name']),
|
||||||
'$photo' => $c['photo'],
|
'$photo' => $contact['photo'],
|
||||||
'url' => 'contacts/' . $cid
|
'url' => 'contacts/' . $cid
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ function common_content(App $a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DBM::is_result($c)) {
|
if (!DBM::is_result($contact)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ use Friendica\Model\Profile;
|
||||||
|
|
||||||
function hcard_init(App $a)
|
function hcard_init(App $a)
|
||||||
{
|
{
|
||||||
$blocked = (((Config::get('system', 'block_public')) && (! local_user()) && (! remote_user())) ? true : false);
|
$blocked = Config::get('system', 'block_public') && !local_user() && !remote_user();
|
||||||
|
|
||||||
if ($a->argc > 1) {
|
if ($a->argc > 1) {
|
||||||
$which = $a->argv[1];
|
$which = $a->argv[1];
|
||||||
|
@ -38,7 +38,7 @@ function hcard_init(App $a)
|
||||||
$a->page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n";
|
$a->page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $blocked) {
|
if (!$blocked) {
|
||||||
$keywords = ((x($a->profile, 'pub_keywords')) ? $a->profile['pub_keywords'] : '');
|
$keywords = ((x($a->profile, 'pub_keywords')) ? $a->profile['pub_keywords'] : '');
|
||||||
$keywords = str_replace(array(',',' ',',,'), array(' ',',',','), $keywords);
|
$keywords = str_replace(array(',',' ',',,'), array(' ',',',','), $keywords);
|
||||||
if (strlen($keywords)) {
|
if (strlen($keywords)) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ function noscrape_init(App $a)
|
||||||
$keywords = str_replace(array('#',',',' ',',,'), array('',' ',',',','), $keywords);
|
$keywords = str_replace(array('#',',',' ',',,'), array('',' ',',',','), $keywords);
|
||||||
$keywords = explode(',', $keywords);
|
$keywords = explode(',', $keywords);
|
||||||
|
|
||||||
$r = dba::selectFirst('contact', ['photo'], ['self' => true, 'uid' => $a->profile['uid']]);
|
$contactPhoto = dba::selectFirst('contact', ['photo'], ['self' => true, 'uid' => $a->profile['uid']]);
|
||||||
|
|
||||||
$json_info = array(
|
$json_info = array(
|
||||||
'fn' => $a->profile['name'],
|
'fn' => $a->profile['name'],
|
||||||
|
@ -44,7 +44,7 @@ function noscrape_init(App $a)
|
||||||
'key' => $a->profile['pubkey'],
|
'key' => $a->profile['pubkey'],
|
||||||
'homepage' => System::baseUrl()."/profile/{$which}",
|
'homepage' => System::baseUrl()."/profile/{$which}",
|
||||||
'comm' => (x($a->profile, 'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY),
|
'comm' => (x($a->profile, 'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY),
|
||||||
'photo' => $r["photo"],
|
'photo' => $contactPhoto["photo"],
|
||||||
'tags' => $keywords
|
'tags' => $keywords
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ function photos_init(App $a) {
|
||||||
$a->profile_uid = $user[0]['uid'];
|
$a->profile_uid = $user[0]['uid'];
|
||||||
$is_owner = (local_user() && (local_user() == $a->profile_uid));
|
$is_owner = (local_user() && (local_user() == $a->profile_uid));
|
||||||
|
|
||||||
$profile = Profile::getProfiledataByNick($nick, $a->profile_uid);
|
$profile = Profile::getByNickname($nick, $a->profile_uid);
|
||||||
|
|
||||||
$account_type = Contact::getAccountType($profile);
|
$account_type = Contact::getAccountType($profile);
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ function videos_init(App $a) {
|
||||||
$a->data['user'] = $user[0];
|
$a->data['user'] = $user[0];
|
||||||
$a->profile_uid = $user[0]['uid'];
|
$a->profile_uid = $user[0]['uid'];
|
||||||
|
|
||||||
$profile = Profile::getProfiledataByNick($nick, $a->profile_uid);
|
$profile = Profile::getByNickname($nick, $a->profile_uid);
|
||||||
|
|
||||||
$account_type = Contact::getAccountType($profile);
|
$account_type = Contact::getAccountType($profile);
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ class Profile
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @brief Loads a profile into the page sidebar.
|
* Loads a profile into the page sidebar.
|
||||||
*
|
*
|
||||||
* The function requires a writeable copy of the main App structure, and the nickname
|
* The function requires a writeable copy of the main App structure, and the nickname
|
||||||
* of a registered local account.
|
* of a registered local account.
|
||||||
|
@ -77,6 +77,7 @@ class Profile
|
||||||
* the theme is chosen before the _init() function of a theme is run, which will usually
|
* the theme is chosen before the _init() function of a theme is run, which will usually
|
||||||
* load a lot of theme-specific content
|
* load a lot of theme-specific content
|
||||||
*
|
*
|
||||||
|
* @brief Loads a profile into the page sidebar.
|
||||||
* @param object $a App
|
* @param object $a App
|
||||||
* @param string $nickname string
|
* @param string $nickname string
|
||||||
* @param int $profile int
|
* @param int $profile int
|
||||||
|
@ -106,7 +107,7 @@ class Profile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$pdata = self::getProfiledataByNick($nickname, $user[0]['uid'], $profile);
|
$pdata = self::getByNickname($nickname, $user[0]['uid'], $profile);
|
||||||
|
|
||||||
if (empty($pdata) && empty($profiledata)) {
|
if (empty($pdata) && empty($profiledata)) {
|
||||||
logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
|
logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
|
||||||
|
@ -181,7 +182,7 @@ class Profile
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get all profil data of a local user
|
* Get all profile data of a local user
|
||||||
*
|
*
|
||||||
* If the viewer is an authenticated remote viewer, the profile displayed is the
|
* 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.
|
* one that has been configured for his/her viewing in the Contact manager.
|
||||||
|
@ -190,12 +191,13 @@ class Profile
|
||||||
*
|
*
|
||||||
* Includes all available profile data
|
* Includes all available profile data
|
||||||
*
|
*
|
||||||
|
* @brief Get all profile data of a local user
|
||||||
* @param string $nickname nick
|
* @param string $nickname nick
|
||||||
* @param int $uid uid
|
* @param int $uid uid
|
||||||
* @param int $profile_id ID of the profile
|
* @param int $profile_id ID of the profile
|
||||||
* @returns array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function getProfiledataByNick($nickname, $uid = 0, $profile_id = 0)
|
public static function getByNickname($nickname, $uid = 0, $profile_id = 0)
|
||||||
{
|
{
|
||||||
if (remote_user() && count($_SESSION['remote'])) {
|
if (remote_user() && count($_SESSION['remote'])) {
|
||||||
foreach ($_SESSION['remote'] as $visitor) {
|
foreach ($_SESSION['remote'] as $visitor) {
|
||||||
|
@ -243,11 +245,12 @@ class Profile
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Formats a profile for display in the sidebar.
|
* Formats a profile for display in the sidebar.
|
||||||
*
|
*
|
||||||
* It is very difficult to templatise the HTML completely
|
* It is very difficult to templatise the HTML completely
|
||||||
* because of all the conditional logic.
|
* because of all the conditional logic.
|
||||||
*
|
*
|
||||||
|
* @brief Formats a profile for display in the sidebar.
|
||||||
* @param array $profile
|
* @param array $profile
|
||||||
* @param int $block
|
* @param int $block
|
||||||
* @param boolean $show_connect Show connect link
|
* @param boolean $show_connect Show connect link
|
||||||
|
@ -997,7 +1000,7 @@ class Profile
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the user ID of the page owner
|
* Get the user ID of the page owner.
|
||||||
*
|
*
|
||||||
* Used from within PCSS themes to set theme parameters. If there's a
|
* 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
|
* puid request variable, that is the "page owner" and normally their theme
|
||||||
|
@ -1005,6 +1008,7 @@ class Profile
|
||||||
* system pconfig, which means they don't want to see anybody else's theme
|
* system pconfig, which means they don't want to see anybody else's theme
|
||||||
* settings except their own while on this site.
|
* settings except their own while on this site.
|
||||||
*
|
*
|
||||||
|
* @brief Get the user ID of the page owner
|
||||||
* @return int user ID
|
* @return int user ID
|
||||||
*
|
*
|
||||||
* @note Returns local_user instead of user ID if "always_my_theme"
|
* @note Returns local_user instead of user ID if "always_my_theme"
|
||||||
|
|
Loading…
Reference in a new issue