logger("Contact-id was missing for post ".$arr["guid"]." from user id ".$uid." - now set to ".$arr["contact-id"], LOGGER_DEBUG);
}
- if ($arr["gcontact-id"] == 0) {
+ if (defaults($arr, "gcontact-id", 0) === 0) {
/*
* The gcontact should mostly behave like the contact. But is is supposed to be global for the system.
* This means that wall posts, repeated posts, etc. should have the gcontact id of the owner.
function micropro($contact, $redirect = false, $class = '', $textmode = false) {
// Use the contact URL if no address is available
- if ($contact["addr"] == "") {
+ if (!x($contact, "addr")) {
$contact["addr"] = $contact["url"];
}
}
return replace_macros(get_markup_template(($textmode)?'micropro_txt.tpl':'micropro_img.tpl'),array(
- '$click' => (($contact['click']) ? $contact['click'] : ''),
+ '$click' => defaults($contact, 'click', ''),
'$class' => $class,
'$url' => $url,
'$photo' => proxy_url($contact['thumb'], false, PROXY_SIZE_THUMB),
}
}
-function put_item_in_cache(&$item, $update = false) {
-
- if (($item["rendered-hash"] != hash("md5", $item["body"])) || ($item["rendered-hash"] == "") ||
- ($item["rendered-html"] == "") || Config::get("system", "ignore_cache")) {
+function put_item_in_cache(&$item, $update = false)
+{
+ $rendered_hash = defaults($item, 'rendered-hash', '');
+ if ($rendered_hash == ''
+ || $item["rendered-html"] == ""
+ || $rendered_hash != hash("md5", $item["body"])
+ || Config::get("system", "ignore_cache")
+ ) {
// The function "redir_private_images" changes the body.
// I'm not sure if we should store it permanently, so we save the old value.
$body = $item["body"];
}
function formatBytes($bytes, $precision = 2) {
- $units = array('B', 'KB', 'MB', 'GB', 'TB');
+ $units = array('B', 'KB', 'MB', 'GB', 'TB');
$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
if ($update) {
$item_id = $_REQUEST['item_id'];
- $item = dba::select('item', ['uid'], ['id' => $item_id], ['limit' => 1]);
+ $item = dba::select('item', ['uid', 'parent'], ['id' => $item_id], ['limit' => 1]);
$a->profile = array('uid' => intval($item['uid']), 'profile_uid' => intval($item['uid']));
+ $item_parent = $item['parent'];
} else {
$item_id = (($a->argc > 2) ? $a->argv[2] : 0);
$contact_id = 0;
- if (is_array($_SESSION['remote'])) {
+ if (x($_SESSION, 'remote') && is_array($_SESSION['remote'])) {
foreach ($_SESSION['remote'] as $v) {
if ($v['uid'] == $a->profile['uid']) {
$contact_id = $v['cid'];
}
$is_owner = (local_user() && (in_array($a->profile['profile_uid'], [local_user(), 0])) ? true : false);
- if ($a->profile['hidewall'] && !$is_owner && !$remote_contact) {
+ if (x($a->profile, 'hidewall') && !$is_owner && !$remote_contact) {
notice(t('Access to this profile has been restricted.') . EOL);
return;
}
$contact_details = Contact::getDetailsByURL($rr['url'], local_user(), $rr);
$contacts[] = array(
- 'img_hover' => sprintf(t('Visit %s\'s profile [%s]'), $contact_details['name'], $rr['url']),
+ 'img_hover' => t('Visit %s\'s profile [%s]', $contact_details['name'], $rr['url']),
'edit_hover' => t('Edit contact'),
'photo_menu' => Contact::photoMenu($rr),
'id' => $rr['id'],
- 'alt_text' => $alt_text,
- 'dir_icon' => $dir_icon,
'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
'name' => $contact_details['name'],
'username' => $contact_details['name'],
'details' => $contact_details['location'],
'tags' => $contact_details['keywords'],
'about' => $contact_details['about'],
- 'sparkle' => $sparkle,
'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
'url' => $rr['url'],
- 'network' => network_to_name($rr['network'], $url),
+ 'network' => network_to_name($rr['network'], $rr['url']),
);
}
}
$tpl = get_markup_template("nogroup-template.tpl");
- $o .= replace_macros(
+ $o = replace_macros(
$tpl,
array(
'$header' => t('Contacts who are not members of a group'),
if (intval(Feature::isEnabled(local_user(), 'forumlist_widget'))) {
$forum_counts = ForumManager::countUnseenItems();
- if (DBM::is_result($forums_counts)) {
- foreach ($forums_counts as $forum_count) {
+ if (DBM::is_result($forum_counts)) {
+ foreach ($forum_counts as $forum_count) {
if ($forum_count['count'] > 0) {
$forums_unseen[] = $forum_count;
}
$notification["href"] = System::baseUrl() . "/notify/view/" . $notification["id"];
- if ($notification["visible"] && !$notification["spam"]
- && !$notification["deleted"] && !is_array($result[$notification["parent"]])
+ if ($notification["visible"]
+ && !$notification["spam"]
+ && !$notification["deleted"]
+ && !(x($result, $notification["parent"]) && is_array($result[$notification["parent"]]))
) {
// Should we condense the notifications or show them all?
if (PConfig::get(local_user(), 'system', 'detailed_notif')) {
use Friendica\Database\DBM;
use Friendica\Model\Contact;
-require_once('include/items.php');
-require_once('include/acl_selectors.php');
-require_once('include/bbcode.php');
-require_once('include/security.php');
-require_once('include/redir.php');
+require_once 'include/items.php';
+require_once 'include/acl_selectors.php';
+require_once 'include/bbcode.php';
+require_once 'include/security.php';
+require_once 'include/redir.php';
function videos_init(App $a) {
$tpl = get_markup_template("vcard-widget.tpl");
- $vcard_widget .= replace_macros($tpl, array(
+ $vcard_widget = replace_macros($tpl, array(
'$name' => $profile['name'],
'$photo' => $profile['photo'],
- '$addr' => (($profile['addr'] != "") ? $profile['addr'] : ""),
+ '$addr' => defaults($profile, 'addr', ''),
'$account_type' => $account_type,
- '$pdesc' => (($profile['pdesc'] != "") ? $profile['pdesc'] : ""),
+ '$pdesc' => defaults($profile, 'pdesc', ''),
));
}
}
- // perhaps they're visiting - but not a community page, so they wouldn't have write access
+ $groups = [];
+ // perhaps they're visiting - but not a community page, so they wouldn't have write access
if(remote_user() && (! $visitor)) {
$contact_id = 0;
if(is_array($_SESSION['remote'])) {
return;
}
- $sql_extra = permissions_sql($owner_uid,$remote_contact,$groups);
+ $sql_extra = permissions_sql($owner_uid, $remote_contact, $groups);
$o = "";
$exponent = 3;
$slope = $maxworkers / pow($maxsysload, $exponent);
$queues = ceil($slope * pow(max(0, $maxsysload - $load), $exponent));
+ $processlist = '';
if (Config::get('system', 'worker_debug')) {
// Create a list of queue entries grouped by their priority
if (!DBM::is_result($contact)) {
// The link could be provided as http although we stored it as https
$ssl_url = str_replace('http://', 'https://', $url);
- $r = dba::select('contact', array('id', 'avatar-date'), array('`alias` IN (?, ?, ?) AND `uid` = ?', $url, normalise_link($url), $ssl_url, $uid), array('limit' => 1));
+ $r = dba::select('contact', array('id', 'avatar', 'avatar-date'), array('`alias` IN (?, ?, ?) AND `uid` = ?', $url, normalise_link($url), $ssl_url, $uid), array('limit' => 1));
$contact = dba::fetch($r);
dba::close($r);
}
$update_contact = ($contact['avatar-date'] < datetime_convert('', '', 'now -7 days'));
// We force the update if the avatar is empty
- if ($contact['avatar'] == '') {
+ if (!x($contact, 'avatar')) {
$update_contact = true;
}
$data["url"] = $uri;
}
- if ($data["photo"] != "") {
+ if (x($data, "photo")) {
$data["baseurl"] = matching_url(normalise_link($data["baseurl"]), normalise_link($data["photo"]));
} else {
$data["photo"] = System::baseUrl().'/images/person-175.jpg';
$data["name"] = $data["nick"];
}
- if ($data["name"] == "") {
+ if (!x($data, "name")) {
$data["name"] = $data["url"];
}
}