Additional method to fetch photo avatars
This commit is contained in:
parent
fb0e31791f
commit
80adad3ad2
|
@ -86,14 +86,31 @@ HELP;
|
|||
$total = $this->dba->count('contact', $condition);
|
||||
$contacts = $this->dba->select('contact', ['id', 'avatar', 'photo', 'uri-id', 'url', 'avatar'], $condition, ['order' => ['id']]);
|
||||
while ($contact = $this->dba->fetch($contacts)) {
|
||||
$valid = true;
|
||||
echo ++$count . '/' . $total . "\t" . $contact['id'] . "\t" . $contact['url'] . "\t";
|
||||
$resourceid = Photo::ridFromURI($contact['photo']);
|
||||
if (empty($resourceid)) {
|
||||
echo $this->l10n->t('no resource in photo %s', $contact['photo']) . ' ';
|
||||
$valid = false;
|
||||
}
|
||||
|
||||
$this->storeAvatar($resourceid, $contact);
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
$photos = $this->dba->p("SELECT `resource-id`, MAX(`contact-id`) AS `contact-id` FROM `photo` WHERE `contact-id` != ? AND `photo-type` = ? GROUP BY `resource-id`;", 0, Photo::CONTACT_AVATAR);
|
||||
while ($photo = $this->dba->fetch($photos)) {
|
||||
$contact = Contact::getById($photo['contact-id'], ['id', 'avatar', 'photo', 'uri-id', 'url', 'avatar']);
|
||||
if (empty($contact)) {
|
||||
continue;
|
||||
}
|
||||
echo ++$count . "\t" . $contact['id'] . "\t" . $contact['url'] . "\t";
|
||||
$this->storeAvatar($photo['resource-id'], $contact);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function storeAvatar(string $resourceid, array $contact)
|
||||
{
|
||||
$valid = !empty($resourceid);
|
||||
if ($valid) {
|
||||
echo '1';
|
||||
$photo = Photo::selectFirst([], ['resource-id' => $resourceid], ['order' => ['scale']]);
|
||||
|
@ -134,7 +151,4 @@ HELP;
|
|||
Photo::delete(['resource-id' => $resourceid]);
|
||||
echo ' ' . $fields['photo'] . "\n";
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user