<?php
-
/**
* @file src/Model/Profile.php
*/
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Protocol\Diaspora;
+use dba;
+require_once 'include/dba.php';
require_once 'include/bbcode.php';
require_once 'mod/proxy.php';
/**
*
- * @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
* of a registered local account.
* the theme is chosen before the _init() function of a theme is run, which will usually
* load a lot of theme-specific content
*
- * @param object $a App
- * @param string $nickname string
- * @param int $profile int
- * @param array $profiledata array
+ * @brief Loads a profile into the page sidebar.
+ * @param object $a App
+ * @param string $nickname string
+ * @param int $profile int
+ * @param array $profiledata array
* @param boolean $show_connect Show connect link
*/
- function profile_load(App $a, $nickname, $profile = 0, $profiledata = array(), $show_connect = true)
+ public static function load(App $a, $nickname, $profile = 0, $profiledata = array(), $show_connect = true)
{
- $user = q(
- "SELECT `uid` FROM `user` WHERE `nickname` = '%s' LIMIT 1",
- dbesc($nickname)
- );
+ $user = dba::selectFirst('user', ['uid'], ['nickname' => $nickname]);
if (!$user && !count($user) && !count($profiledata)) {
logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
}
if ($profiledata) {
- $a->page['aside'] .= profile_sidebar($profiledata, true, $show_connect);
+ $a->page['aside'] .= self::sidebar($profiledata, true, $show_connect);
if (!DBM::is_result($user)) {
return;
}
}
- $pdata = get_profiledata_by_nick($nickname, $user[0]['uid'], $profile);
+ $pdata = self::getByNickname($nickname, $user[0]['uid'], $profile);
if (empty($pdata) && empty($profiledata)) {
logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
* 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);
+ $a->page['aside'] .= self::sidebar($a->profile, $block, $show_connect);
}
return;
}
/**
- * @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
* one that has been configured for his/her viewing in the Contact manager.
*
* 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
- * @returns array
+ * @return array
*/
- function get_profiledata_by_nick($nickname, $uid = 0, $profile_id = 0)
+ public static function getByNickname($nickname, $uid = 0, $profile_id = 0)
{
if (remote_user() && count($_SESSION['remote'])) {
foreach ($_SESSION['remote'] as $visitor) {
}
/**
- * @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
* 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
* @hooks 'profile_sidebar'
* array $arr
*/
- function profile_sidebar($profile, $block = 0, $show_connect = true)
+ private static function sidebar($profile, $block = 0, $show_connect = true)
{
$a = get_app();
$subscribe_feed = false;
}
- if (remote_user() || (get_my_url() && x($profile, 'unkmail') && ($profile['uid'] != local_user()))) {
+ if (remote_user() || (self::getMyURL() && x($profile, 'unkmail') && ($profile['uid'] != local_user()))) {
$wallmessage = t('Message');
$wallmessage_link = 'wallmessage/' . $profile['nickname'];
$r = q(
"SELECT `url` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `rel` = %d",
intval($profile['uid']),
- dbesc(normalise_link(get_my_url())),
+ dbesc(normalise_link(self::getMyURL())),
intval(CONTACT_IS_FRIEND)
);
}
return $o;
}
- function get_birthdays()
+ public static function getBirthdays()
{
$a = get_app();
$o = '';
));
}
- function get_events()
+ public static function getEvents()
{
require_once 'include/bbcode.php';
));
}
- function advanced_profile(App $a)
+ public static function getAdvanced(App $a)
{
$o = '';
$uid = $a->profile['uid'];
return '';
}
- function profile_tabs($a, $is_owner = false, $nickname = null)
+ public static function getTabs($a, $is_owner = false, $nickname = null)
{
if (is_null($nickname)) {
$nickname = $a->user['nickname'];
*
* @return string
*/
- function get_my_url()
+ public static function getMyURL()
{
if (x($_SESSION, 'my_url')) {
return $_SESSION['my_url'];
return null;
}
- function zrl_init(App $a)
+ public static function zrlInit(App $a)
{
- $my_url = get_my_url();
+ $my_url = self::getMyURL();
$my_url = validate_url($my_url);
if ($my_url) {
// Is it a DDoS attempt?
}
}
- function zrl($s, $force = false)
+ public static function zrl($s, $force = false)
{
if (!strlen($s)) {
return $s;
$s = $s . '/';
}
$achar = strpos($s, '?') ? '&' : '?';
- $mine = get_my_url();
+ $mine = self::getMyURL();
if ($mine && !link_compare($mine, $s)) {
return $s . $achar . 'zrl=' . urlencode($mine);
}
}
/**
- * @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
* puid request variable, that is the "page owner" and normally their 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
*/
- function get_theme_uid()
+ 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 $uid;
}
-
}