Replace deprecated calls to q() in mod/fsuggest and mod/photos
This commit is contained in:
parent
7f2dc40601
commit
8a5ef2b6f4
2 changed files with 25 additions and 32 deletions
|
@ -23,15 +23,11 @@ function fsuggest_post(App $a)
|
||||||
|
|
||||||
$contact_id = intval($a->argv[1]);
|
$contact_id = intval($a->argv[1]);
|
||||||
|
|
||||||
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
|
||||||
intval($contact_id),
|
if (! DBA::isResult($contact)) {
|
||||||
intval(local_user())
|
|
||||||
);
|
|
||||||
if (! DBA::isResult($r)) {
|
|
||||||
notice(L10n::t('Contact not found.') . EOL);
|
notice(L10n::t('Contact not found.') . EOL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$contact = $r[0];
|
|
||||||
|
|
||||||
$new_contact = intval($_POST['suggest']);
|
$new_contact = intval($_POST['suggest']);
|
||||||
|
|
||||||
|
@ -49,10 +45,10 @@ function fsuggest_post(App $a)
|
||||||
VALUES ( %d, %d, '%s','%s','%s','%s','%s','%s')",
|
VALUES ( %d, %d, '%s','%s','%s','%s','%s','%s')",
|
||||||
intval(local_user()),
|
intval(local_user()),
|
||||||
intval($contact_id),
|
intval($contact_id),
|
||||||
DBA::escape($r[0]['name']),
|
DBA::escape($contact['name']),
|
||||||
DBA::escape($r[0]['url']),
|
DBA::escape($contact['url']),
|
||||||
DBA::escape($r[0]['request']),
|
DBA::escape($contact['request']),
|
||||||
DBA::escape($r[0]['photo']),
|
DBA::escape($contact['photo']),
|
||||||
DBA::escape($hash),
|
DBA::escape($hash),
|
||||||
DBA::escape(DateTimeFormat::utcNow())
|
DBA::escape(DateTimeFormat::utcNow())
|
||||||
);
|
);
|
||||||
|
@ -61,7 +57,7 @@ function fsuggest_post(App $a)
|
||||||
intval(local_user())
|
intval(local_user())
|
||||||
);
|
);
|
||||||
if (DBA::isResult($r)) {
|
if (DBA::isResult($r)) {
|
||||||
$fsuggest_id = $r[0]['id'];
|
$fsuggest_id = $contact['id'];
|
||||||
q("UPDATE `fsuggest` SET `note` = '%s' WHERE `id` = %d AND `uid` = %d",
|
q("UPDATE `fsuggest` SET `note` = '%s' WHERE `id` = %d AND `uid` = %d",
|
||||||
DBA::escape($note),
|
DBA::escape($note),
|
||||||
intval($fsuggest_id),
|
intval($fsuggest_id),
|
||||||
|
@ -88,16 +84,11 @@ function fsuggest_content(App $a)
|
||||||
|
|
||||||
$contact_id = intval($a->argv[1]);
|
$contact_id = intval($a->argv[1]);
|
||||||
|
|
||||||
$r = q(
|
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
|
||||||
"SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
if (! DBA::isResult($contact)) {
|
||||||
intval($contact_id),
|
|
||||||
intval(local_user())
|
|
||||||
);
|
|
||||||
if (! DBA::isResult($r)) {
|
|
||||||
notice(L10n::t('Contact not found.') . EOL);
|
notice(L10n::t('Contact not found.') . EOL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$contact = $r[0];
|
|
||||||
|
|
||||||
$o = '<h3>' . L10n::t('Suggest Friends') . '</h3>';
|
$o = '<h3>' . L10n::t('Suggest Friends') . '</h3>';
|
||||||
|
|
||||||
|
|
|
@ -409,9 +409,12 @@ function photos_post(App $a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$photo = Photo::getPhotoForUser($page_owner_uid, $resource_id);
|
$photos_stmt = DBA::select('photo', [], ['resource-id' => $resource_id, 'uid' => $page_owner_uid], ['order' => ['scale' => true]]);
|
||||||
|
|
||||||
if (DBA::isResult($photo)) {
|
$photos = DBA::toArray($photos_stmt);
|
||||||
|
|
||||||
|
if (DBA::isResult($photos)) {
|
||||||
|
$photo = $photos[0];
|
||||||
$ext = $phototypes[$photo['type']];
|
$ext = $phototypes[$photo['type']];
|
||||||
Photo::update(
|
Photo::update(
|
||||||
['desc' => $desc, 'album' => $albname, 'allow_cid' => $str_contact_allow, 'allow_gid' => $str_group_allow, 'deny_cid' => $str_contact_deny, 'deny_gid' => $str_group_deny],
|
['desc' => $desc, 'album' => $albname, 'allow_cid' => $str_contact_allow, 'allow_gid' => $str_group_allow, 'deny_cid' => $str_contact_deny, 'deny_gid' => $str_group_deny],
|
||||||
|
@ -422,16 +425,15 @@ function photos_post(App $a)
|
||||||
if ($albname !== $origaname) {
|
if ($albname !== $origaname) {
|
||||||
Photo::clearAlbumCache($page_owner_uid);
|
Photo::clearAlbumCache($page_owner_uid);
|
||||||
}
|
}
|
||||||
|
/* Don't make the item visible if the only change was the album name */
|
||||||
|
|
||||||
|
$visibility = 0;
|
||||||
|
if ($photo['desc'] !== $desc || strlen($rawtags)) {
|
||||||
|
$visibility = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't make the item visible if the only change was the album name */
|
if (DBA::isResult($photos) && !$item_id) {
|
||||||
|
|
||||||
$visibility = 0;
|
|
||||||
if ($photo['desc'] !== $desc || strlen($rawtags)) {
|
|
||||||
$visibility = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$item_id) {
|
|
||||||
// Create item container
|
// Create item container
|
||||||
$title = '';
|
$title = '';
|
||||||
$uri = Item::newURI($page_owner_uid);
|
$uri = Item::newURI($page_owner_uid);
|
||||||
|
@ -527,7 +529,7 @@ function photos_post(App $a)
|
||||||
if ($tagcid) {
|
if ($tagcid) {
|
||||||
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||||
intval($tagcid),
|
intval($tagcid),
|
||||||
intval($profile_uid)
|
intval($page_owner_uid)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$newname = str_replace('_',' ',$name);
|
$newname = str_replace('_',' ',$name);
|
||||||
|
@ -598,7 +600,7 @@ function photos_post(App $a)
|
||||||
Item::update($fields, $condition);
|
Item::update($fields, $condition);
|
||||||
|
|
||||||
$best = 0;
|
$best = 0;
|
||||||
foreach ($p as $scales) {
|
foreach ($photos as $scales) {
|
||||||
if (intval($scales['scale']) == 2) {
|
if (intval($scales['scale']) == 2) {
|
||||||
$best = 2;
|
$best = 2;
|
||||||
break;
|
break;
|
||||||
|
@ -646,13 +648,13 @@ function photos_post(App $a)
|
||||||
$arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $tagged[0] . '</title><id>' . $tagged[1] . '/' . $tagged[0] . '</id>';
|
$arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $tagged[0] . '</title><id>' . $tagged[1] . '/' . $tagged[0] . '</id>';
|
||||||
$arr['object'] .= '<link>' . XML::escape('<link rel="alternate" type="text/html" href="' . $tagged[1] . '" />' . "\n");
|
$arr['object'] .= '<link>' . XML::escape('<link rel="alternate" type="text/html" href="' . $tagged[1] . '" />' . "\n");
|
||||||
if ($tagged[3]) {
|
if ($tagged[3]) {
|
||||||
$arr['object'] .= XML::escape('<link rel="photo" type="'.$photo['type'].'" href="' . $tagged[3]['photo'] . '" />' . "\n");
|
$arr['object'] .= XML::escape('<link rel="photo" type="' . $photo['type'] . '" href="' . $tagged[3]['photo'] . '" />' . "\n");
|
||||||
}
|
}
|
||||||
$arr['object'] .= '</link></object>' . "\n";
|
$arr['object'] .= '</link></object>' . "\n";
|
||||||
|
|
||||||
$arr['target'] = '<target><type>' . ACTIVITY_OBJ_IMAGE . '</type><title>' . $photo['desc'] . '</title><id>'
|
$arr['target'] = '<target><type>' . ACTIVITY_OBJ_IMAGE . '</type><title>' . $photo['desc'] . '</title><id>'
|
||||||
. System::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . '</id>';
|
. System::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . '</id>';
|
||||||
$arr['target'] .= '<link>' . XML::escape('<link rel="alternate" type="text/html" href="' . System::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . '" />' . "\n" . '<link rel="preview" type="'.$photo['type'].'" href="' . System::baseUrl() . "/photo/" . $photo['resource-id'] . '-' . $best . '.' . $ext . '" />') . '</link></target>';
|
$arr['target'] .= '<link>' . XML::escape('<link rel="alternate" type="text/html" href="' . System::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . '" />' . "\n" . '<link rel="preview" type="' . $photo['type'] . '" href="' . System::baseUrl() . "/photo/" . $photo['resource-id'] . '-' . $best . '.' . $ext . '" />') . '</link></target>';
|
||||||
|
|
||||||
Item::insert($arr);
|
Item::insert($arr);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue