<?php
/**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
return true;
}
- $user = DBA::selectFirst('user', ['uid', 'username', 'nickname', 'pubkey', 'prvkey'], ['uid' => $uid]);
+ $user = DBA::selectFirst('user', ['uid', 'username', 'nickname', 'pubkey', 'prvkey'],
+ ['uid' => $uid, 'account_expired' => false]);
if (!DBA::isResult($user)) {
return false;
}
}
$fields = ['nickname', 'page-flags', 'account-type', 'prvkey', 'pubkey'];
- $user = DBA::selectFirst('user', $fields, ['uid' => $uid]);
+ $user = DBA::selectFirst('user', $fields, ['uid' => $uid, 'account_expired' => false]);
if (!DBA::isResult($user)) {
return;
}
/**
* Return the photo path for a given contact array in the given size
*
- * @param array $contact contact array
- * @param string $field Fieldname of the photo in the contact array
- * @param string $size Size of the avatar picture
- * @param string $avatar Avatar path that is displayed when no photo had been found
+ * @param array $contact contact array
+ * @param string $field Fieldname of the photo in the contact array
+ * @param string $size Size of the avatar picture
+ * @param string $avatar Avatar path that is displayed when no photo had been found
+ * @param bool $no_update Don't perfom an update if no cached avatar was found
* @return string photo path
*/
- private static function getAvatarPath(array $contact, string $field, string $size, string $avatar)
+ private static function getAvatarPath(array $contact, string $field, string $size, string $avatar, $no_update = false)
{
if (!empty($contact)) {
- $contact = self::checkAvatarCacheByArray($contact);
+ $contact = self::checkAvatarCacheByArray($contact, $no_update);
if (!empty($contact[$field])) {
$avatar = $contact[$field];
}
}
+ if ($no_update && empty($avatar) && !empty($contact['avatar'])) {
+ $avatar = $contact['avatar'];
+ }
+
if (empty($avatar)) {
$avatar = self::getDefaultAvatar([], $size);
}
/**
* Return the photo path for a given contact array
*
- * @param array $contact Contact array
- * @param string $avatar Avatar path that is displayed when no photo had been found
+ * @param array $contact Contact array
+ * @param string $avatar Avatar path that is displayed when no photo had been found
+ * @param bool $no_update Don't perfom an update if no cached avatar was found
* @return string photo path
*/
- public static function getPhoto(array $contact, string $avatar = '')
+ public static function getPhoto(array $contact, string $avatar = '', bool $no_update = false)
{
- return self::getAvatarPath($contact, 'photo', Proxy::SIZE_SMALL, $avatar);
+ return self::getAvatarPath($contact, 'photo', Proxy::SIZE_SMALL, $avatar, $no_update);
}
/**
* Return the photo path (thumb size) for a given contact array
*
- * @param array $contact Contact array
- * @param string $avatar Avatar path that is displayed when no photo had been found
+ * @param array $contact Contact array
+ * @param string $avatar Avatar path that is displayed when no photo had been found
+ * @param bool $no_update Don't perfom an update if no cached avatar was found
* @return string photo path
*/
- public static function getThumb(array $contact, string $avatar = '')
+ public static function getThumb(array $contact, string $avatar = '', bool $no_update = false)
{
- return self::getAvatarPath($contact, 'thumb', Proxy::SIZE_THUMB, $avatar);
+ return self::getAvatarPath($contact, 'thumb', Proxy::SIZE_THUMB, $avatar, $no_update);
}
/**
* Return the photo path (micro size) for a given contact array
*
- * @param array $contact Contact array
- * @param string $avatar Avatar path that is displayed when no photo had been found
+ * @param array $contact Contact array
+ * @param string $avatar Avatar path that is displayed when no photo had been found
+ * @param bool $no_update Don't perfom an update if no cached avatar was found
* @return string photo path
*/
- public static function getMicro(array $contact, string $avatar = '')
+ public static function getMicro(array $contact, string $avatar = '', bool $no_update = false)
{
- return self::getAvatarPath($contact, 'micro', Proxy::SIZE_MICRO, $avatar);
+ return self::getAvatarPath($contact, 'micro', Proxy::SIZE_MICRO, $avatar, $no_update);
}
/**
* Check the given contact array for avatar cache fields
*
* @param array $contact
+ * @param bool $no_update Don't perfom an update if no cached avatar was found
* @return array contact array with avatar cache fields
*/
- private static function checkAvatarCacheByArray(array $contact)
+ private static function checkAvatarCacheByArray(array $contact, bool $no_update = false)
{
$update = false;
$contact_fields = [];
}
}
- if (!$update) {
+ if (!$update || $no_update) {
return $contact;
}
public static function updateBirthdays()
{
$condition = [
- '`bd` != ""
- AND `bd` > "0001-01-01"
- AND SUBSTRING(`bd`, 1, 4) != `bdyear`
+ '`bd` > ?
AND (`contact`.`rel` = ? OR `contact`.`rel` = ?)
AND NOT `contact`.`pending`
AND NOT `contact`.`hidden`
AND NOT `contact`.`blocked`
AND NOT `contact`.`archive`
AND NOT `contact`.`deleted`',
+ DBA::NULL_DATE,
self::SHARING,
self::FRIEND
];
$count = 0;
foreach ($urls as $url) {
+ if (empty($url) || !is_string($url)) {
+ continue;
+ }
$contact = self::getByURL($url, false, ['id', 'updated']);
if (empty($contact['id'])) {
Worker::add(PRIORITY_LOW, 'AddContact', 0, $url);