X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FPhoto.php;h=e64158e175ced54a67d79fecf190be2965c561b5;hb=af8a383be038ec0fe33b0e5b97bf818179a73766;hp=c622421cc039e74d0bd298284a26cf8471fd65f2;hpb=c845415a99ebc348103815a7b2c55b15c75cdd24;p=friendica.git diff --git a/src/Model/Photo.php b/src/Model/Photo.php index c622421cc0..e64158e175 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -10,11 +10,10 @@ use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\System; -use Friendica\Database\DBM; +use Friendica\Database\DBA; use Friendica\Object\Image; use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; -use dba; require_once 'include/dba.php'; @@ -41,14 +40,14 @@ class Photo */ public static function store(Image $Image, $uid, $cid, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '', $desc = '') { - $photo = dba::selectFirst('photo', ['guid'], ["`resource-id` = ? AND `guid` != ?", $rid, '']); - if (DBM::is_result($photo)) { + $photo = DBA::selectFirst('photo', ['guid'], ["`resource-id` = ? AND `guid` != ?", $rid, '']); + if (DBA::isResult($photo)) { $guid = $photo['guid']; } else { - $guid = get_guid(); + $guid = System::createGUID(); } - $existing_photo = dba::selectFirst('photo', ['id'], ['resource-id' => $rid, 'uid' => $uid, 'contact-id' => $cid, 'scale' => $scale]); + $existing_photo = DBA::selectFirst('photo', ['id'], ['resource-id' => $rid, 'uid' => $uid, 'contact-id' => $cid, 'scale' => $scale]); $fields = [ 'uid' => $uid, @@ -73,10 +72,10 @@ class Photo 'desc' => $desc ]; - if (DBM::is_result($existing_photo)) { - $r = dba::update('photo', $fields, ['id' => $existing_photo['id']]); + if (DBA::isResult($existing_photo)) { + $r = DBA::update('photo', $fields, ['id' => $existing_photo['id']]); } else { - $r = dba::insert('photo', $fields); + $r = DBA::insert('photo', $fields); } return $r; @@ -94,7 +93,7 @@ class Photo $thumb = ''; $micro = ''; - $photo = dba::selectFirst( + $photo = DBA::selectFirst( 'photo', ['resource-id'], ['uid' => $uid, 'contact-id' => $cid, 'scale' => 4, 'album' => 'Contact Photos'] ); if (x($photo['resource-id'])) { @@ -147,7 +146,7 @@ class Photo // Remove the cached photo $a = get_app(); - $basepath = $a->get_basepath(); + $basepath = $a->getBasePath(); if (is_dir($basepath . "/photo")) { $filename = $basepath . '/photo/' . $hash . '-4.' . $Image->getExt(); @@ -240,8 +239,8 @@ class Photo WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' $sql_extra GROUP BY `album` ORDER BY `created` DESC", intval($uid), - dbesc('Contact Photos'), - dbesc(L10n::t('Contact Photos')) + DBA::escape('Contact Photos'), + DBA::escape(L10n::t('Contact Photos')) ); } else { // This query doesn't do the count and is much faster @@ -249,8 +248,8 @@ class Photo FROM `photo` USE INDEX (`uid_album_scale_created`) WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' $sql_extra", intval($uid), - dbesc('Contact Photos'), - dbesc(L10n::t('Contact Photos')) + DBA::escape('Contact Photos'), + DBA::escape(L10n::t('Contact Photos')) ); } Cache::set($key, $albums, CACHE_DAY); @@ -275,6 +274,6 @@ class Photo */ public static function newResource() { - return get_guid(32, false); + return system::createGUID(32, false); } }