]> git.mxchange.org Git - friendica.git/commitdiff
Some standards
authorMichael <heluecht@pirati.ca>
Sat, 15 Jan 2022 21:45:08 +0000 (21:45 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 15 Jan 2022 21:45:08 +0000 (21:45 +0000)
src/Factory/Api/Friendica/Photo.php
src/Module/Api/Friendica/Photo.php
src/Module/Api/Friendica/Photo/Create.php
src/Module/Api/Friendica/Photo/Lists.php
src/Module/Api/Friendica/Photo/Update.php

index 2a2f2be22f025ef87879c44ffb55fc38beb935ac..85470c880615731bc42e407b5dea3ae7fd81b693 100644 (file)
@@ -59,12 +59,13 @@ class Photo extends BaseFactory
        public function createFromId(string $photo_id, int $scale = null, int $uid, string $type = 'json', bool $with_posts = true): array
        {
                $fields = ['resource-id', 'created', 'edited', 'title', 'desc', 'album', 'filename','type',
-               'height', 'width', 'datasize', 'profile', 'allow_cid', 'deny_cid', 'allow_gid', 'deny_gid',
-               'backend-class', 'backend-ref', 'id', 'scale'];
+                       'height', 'width', 'datasize', 'profile', 'allow_cid', 'deny_cid', 'allow_gid', 'deny_gid',
+                       'backend-class', 'backend-ref', 'id', 'scale'];
 
                $condition = ['uid' => $uid, 'resource-id' => $photo_id];
                if (is_int($scale)) {
                        $fields = array_merge(['data'], $fields);
+
                        $condition['scale'] = $scale;
                }
 
@@ -72,7 +73,7 @@ class Photo extends BaseFactory
                if (empty($photos)) {
                        throw new HTTPException\NotFoundException();
                }
-               $data = $photos[0];
+               $data       = $photos[0];
                $data['id'] = $data['resource-id'];
                if (is_int($scale)) {
                        $data['data'] = base64_encode(ModelPhoto::getImageDataForPhoto($data));
@@ -103,7 +104,7 @@ class Photo extends BaseFactory
                unset($data['backend-ref']);
                unset($data['resource-id']);
                unset($data['scale']);
-       
+
                if ($with_posts) {
                        // retrieve item element for getting activities (like, dislike etc.) related to photo
                        $condition = ['uid' => $uid, 'resource-id' => $photo_id];
@@ -111,20 +112,20 @@ class Photo extends BaseFactory
                }
                if (!empty($item)) {
                        $data['friendica_activities'] = $this->activities->createFromUriId($item['uri-id'], $item['uid'], $type);
-       
+
                        // retrieve comments on photo
                        $condition = ["`parent` = ? AND `uid` = ? AND `gravity` IN (?, ?)",
                                $item['parent'], $uid, GRAVITY_PARENT, GRAVITY_COMMENT];
-               
+
                        $statuses = Post::selectForUser($uid, [], $condition);
-               
+
                        // prepare output of comments
                        $commentData = [];
                        while ($status = DBA::fetch($statuses)) {
                                $commentData[] = $this->status->createFromUriId($status['uri-id'], $status['uid'])->toArray();
                        }
                        DBA::close($statuses);
-               
+
                        $comments = [];
                        if ($type == 'xml') {
                                $k = 0;
@@ -137,7 +138,7 @@ class Photo extends BaseFactory
                                }
                        }
                        $data['friendica_comments'] = $comments;
-               
+
                        // include info if rights on photo and rights on item are mismatching
                        $data['rights_mismatch'] = $data['allow_cid'] != $item['allow_cid'] ||
                                $data['deny_cid'] != $item['deny_cid'] ||
@@ -148,7 +149,7 @@ class Photo extends BaseFactory
                        $data['friendica_comments']   = [];
                        $data['rights_mismatch'] = false;
                }
-       
+
                return $data;
        }
 }
\ No newline at end of file
index a27abb371d2cb1e4ef12db6422eed9a3fcff96df..5c2f46fc2278b91eb6742c1a0eccd0608ea6196a 100644 (file)
@@ -26,7 +26,7 @@ use Friendica\Model\Contact;
 use Friendica\Module\BaseApi;
 use Friendica\Network\HTTPException;
 
-class Activity extends BaseApi
+class Photo extends BaseApi
 {
        protected function post(array $request = [])
        {
@@ -37,13 +37,13 @@ class Activity extends BaseApi
                if (empty($_REQUEST['photo_id'])) {
                        throw new HTTPException\BadRequestException('No photo id.');
                }
-       
+
                $scale = (!empty($_REQUEST['scale']) ? intval($_REQUEST['scale']) : false);
                $photo_id = $_REQUEST['photo_id'];
-       
+
                // prepare json/xml output with data from database for the requested photo
                $data = ['photo' => DI::friendicaPhoto()->createFromId($photo_id, $scale, $uid, $type)];
-       
+
                $this->response->exit('statuses', $data, $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid));
        }
 }
index fe99a175d2dfda70764cb400e0a4a0c456077fb4..8da6acbf4ebd5422dafec4fc031a297dadf2fd15 100644 (file)
@@ -45,19 +45,19 @@ class Create extends BaseApi
                $deny_cid  = $_REQUEST['deny_cid' ] ?? null;
                $allow_gid = $_REQUEST['allow_gid'] ?? null;
                $deny_gid  = $_REQUEST['deny_gid' ] ?? null;
-       
+
                // do several checks on input parameters
                // we do not allow calls without album string
                if ($album == null) {
                        throw new HTTPException\BadRequestException('no albumname specified');
                }
-       
+
                // error if no media posted in create-mode
                if (empty($_FILES['media'])) {
                        // Output error
                        throw new HTTPException\BadRequestException('no media data submitted');
                }
-       
+
                // checks on acl strings provided by clients
                $acl_input_error = false;
                $acl_input_error |= !ACL::isValidContact($allow_cid, $uid);
index 826e32d085c4c6239ec47e80372d81687437bdbe..d7080b442853410e37f572193c079883603fe37e 100644 (file)
@@ -42,15 +42,15 @@ class Lists extends BaseApi
 
                $photos = Photo::selectToArray(['resource-id'], ["`uid` = ? AND NOT `photo-type` IN (?, ?)", $uid, Photo::CONTACT_AVATAR, Photo::CONTACT_BANNER],
                        ['order' => ['id'], 'group_by' => ['resource-id']]);
-       
+
                $data = ['photo' => []];
                if (DBA::isResult($photos)) {
                        foreach ($photos as $photo) {
                                $element = DI::friendicaPhoto()->createFromId($photo['resource-id'], null, $uid, 'json', false);
-       
+
                                $element['thumb'] = end($element['link']);
                                unset($element['link']);
-       
+
                                if ($type == 'xml') {
                                        $thumb = $element['thumb'];
                                        unset($element['thumb']);
index 2b489bad35a65d017e8714da909d241f21e50000..c4bd6c70bf3cb112abed70435025e12605e82611 100644 (file)
@@ -37,7 +37,7 @@ class Update extends BaseApi
                BaseApi::checkAllowedScope(BaseApi::SCOPE_WRITE);
                $uid  = BaseApi::getCurrentUserID();
                $type = $this->parameters['extension'] ?? '';
-       
+
                // input params
                $photo_id  = $_REQUEST['photo_id']  ?? null;
                $desc      = $_REQUEST['desc']      ?? null;
@@ -47,7 +47,7 @@ class Update extends BaseApi
                $deny_cid  = $_REQUEST['deny_cid' ] ?? null;
                $allow_gid = $_REQUEST['allow_gid'] ?? null;
                $deny_gid  = $_REQUEST['deny_gid' ] ?? null;
-       
+
                // do several checks on input parameters
                // we do not allow calls without album string
                if ($album == null) {
@@ -58,7 +58,7 @@ class Update extends BaseApi
                if (!Photo::exists(['resource-id' => $photo_id, 'uid' => $uid, 'album' => $album])) {
                        throw new HTTPException\BadRequestException('photo not available');
                }
-       
+
                // checks on acl strings provided by clients
                $acl_input_error = false;
                $acl_input_error |= !ACL::isValidContact($allow_cid, $uid);
@@ -68,7 +68,7 @@ class Update extends BaseApi
                if ($acl_input_error) {
                        throw new HTTPException\BadRequestException('acl data invalid');
                }
-       
+
                $updated_fields = [];
 
                if (!is_null($desc)) {