]> git.mxchange.org Git - friendica.git/blobdiff - mod/photos.php
Improve Console/Config display for array values
[friendica.git] / mod / photos.php
index 7bf857e0e407476eea9091f5cc62765ae6cf4abb..7c5f539d067783b286c5226c7c9085b7acfd62e0 100644 (file)
@@ -101,6 +101,8 @@ function photos_init(App $a) {
 
                if (local_user() && $a->data['user']['uid'] == local_user()) {
                        $can_post = true;
+               } else {
+                       $can_post = false;
                }
 
                if ($ret['success']) {
@@ -453,7 +455,7 @@ function photos_post(App $a)
                        $uri = Item::newURI($page_owner_uid);
 
                        $arr = [];
-                       $arr['guid']          = get_guid(32);
+                       $arr['guid']          = System::createGUID(32);
                        $arr['uid']           = $page_owner_uid;
                        $arr['uri']           = $uri;
                        $arr['parent-uri']    = $uri;
@@ -620,7 +622,7 @@ function photos_post(App $a)
                                        $uri = Item::newURI($page_owner_uid);
 
                                        $arr = [];
-                                       $arr['guid']          = get_guid(32);
+                                       $arr['guid']          = System::createGUID(32);
                                        $arr['uid']           = $page_owner_uid;
                                        $arr['uri']           = $uri;
                                        $arr['parent-uri']    = $uri;
@@ -640,6 +642,7 @@ function photos_post(App $a)
                                        $arr['deny_gid']      = $p[0]['deny_gid'];
                                        $arr['visible']       = 1;
                                        $arr['verb']          = ACTIVITY_TAG;
+                                       $arr['gravity']       = GRAVITY_PARENT;
                                        $arr['object-type']   = ACTIVITY_OBJ_PERSON;
                                        $arr['target-type']   = ACTIVITY_OBJ_IMAGE;
                                        $arr['tag']           = $tagged[4];
@@ -855,7 +858,7 @@ function photos_post(App $a)
                $arr['coord'] = $lat . ' ' . $lon;
        }
 
-       $arr['guid']          = get_guid(32);
+       $arr['guid']          = System::createGUID(32);
        $arr['uid']           = $page_owner_uid;
        $arr['uri']           = $uri;
        $arr['parent-uri']    = $uri;
@@ -949,6 +952,7 @@ function photos_content(App $a)
        $contact        = null;
        $remote_contact = false;
        $contact_id     = 0;
+       $edit           = false;
 
        $owner_uid = $a->data['user']['uid'];
 
@@ -1343,42 +1347,14 @@ function photos_content(App $a)
 
                if (DBM::is_result($linked_items)) {
                        // This is a workaround to not being forced to rewrite the while $sql_extra handling
-                       $link_item = Item::selectFirstForUser(local_user(), [], ['id' => $linked_items[0]['id']]);
-
-                       $r = q("SELECT COUNT(*) AS `total`
-                               FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
-                               WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0
-                               AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
-                               AND `item`.`uid` = %d
-                               $sql_extra ",
-                               dbesc($link_item['uri']),
-                               dbesc($link_item['uri']),
-                               intval($link_item['uid'])
-
-                       );
-
-                       if (DBM::is_result($r)) {
-                               $a->set_pager_total($r[0]['total']);
-                       }
+                       $link_item = Item::selectFirst([], ['id' => $linked_items[0]['id']]);
 
+                       $condition = ["`parent` = ? AND `parent` != `id`",  $link_item['parent']];
+                       $a->set_pager_total(dba::count('item', $condition));
 
-                       $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
-                               `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`,
-                               `contact`.`rel`, `contact`.`thumb`, `contact`.`self`,
-                               `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
-                               FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
-                               WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0
-                               AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
-                               AND `item`.`uid` = %d
-                               $sql_extra
-                               ORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ",
-                               dbesc($link_item['uri']),
-                               dbesc($link_item['uri']),
-                               intval($link_item['uid']),
-                               intval($a->pager['start']),
-                               intval($a->pager['itemspage'])
-
-                       );
+                       $params = ['order' => ['id'], 'limit' => [$a->pager['start'], $a->pager['itemspage']]];
+                       $result = Item::selectForUser($link_item['uid'], [], $condition, $params);
+                       $items = Item::inArray($result);
 
                        if (local_user() && (local_user() == $link_item['uid'])) {
                                Item::update(['unseen' => false], ['parent' => $link_item['parent']]);
@@ -1465,7 +1441,7 @@ function photos_content(App $a)
                                ]);
                        }
 
-                       if (!DBM::is_result($r)) {
+                       if (!DBM::is_result($items)) {
                                if (($can_post || can_write_wall($owner_uid))) {
                                        $comments .= replace_macros($cmnt_tpl, [
                                                '$return_path' => '',
@@ -1493,8 +1469,8 @@ function photos_content(App $a)
                        ];
 
                        // display comments
-                       if (DBM::is_result($r)) {
-                               foreach ($r as $item) {
+                       if (DBM::is_result($items)) {
+                               foreach ($items as $item) {
                                        builtin_activity_puller($item, $conv_responses);
                                }
 
@@ -1525,7 +1501,7 @@ function photos_content(App $a)
                                        ]);
                                }
 
-                               foreach ($r as $item) {
+                               foreach ($items as $item) {
                                        $comment = '';
                                        $template = $tpl;
                                        $sparkle = '';
@@ -1534,20 +1510,13 @@ function photos_content(App $a)
                                                continue;
                                        }
 
-                                       $profile_url = Contact::MagicLinkById($item['cid']);
+                                       $profile_url = Contact::MagicLinkById($item['author-id']);
                                        if (strpos($profile_url, 'redir/') === 0) {
                                                $sparkle = ' sparkle';
                                        } else {
                                                $sparkle = '';
                                        }
 
-                                       $diff_author = (($item['url'] !== $item['author-link']) ? true : false);
-
-                                       $profile_name   = ((strlen($item['author-name'])   && $diff_author) ? $item['author-name']   : $item['name']);
-                                       $profile_avatar = ((strlen($item['author-avatar']) && $diff_author) ? $item['author-avatar'] : $item['thumb']);
-
-                                       $profile_link = $profile_url;
-
                                        $dropping = (($item['contact-id'] == $contact_id) || ($item['uid'] == local_user()));
                                        $drop = [
                                                'dropping' => $dropping,
@@ -1556,15 +1525,14 @@ function photos_content(App $a)
                                                'delete' => L10n::t('Delete'),
                                        ];
 
-                                       $name_e = $profile_name;
                                        $title_e = $item['title'];
                                        $body_e = BBCode::convert($item['body']);
 
                                        $comments .= replace_macros($template,[
                                                '$id' => $item['item_id'],
-                                               '$profile_url' => $profile_link,
-                                               '$name' => $name_e,
-                                               '$thumb' => $profile_avatar,
+                                               '$profile_url' => $profile_url,
+                                               '$name' => $item['author-name'],
+                                               '$thumb' => $item['author-avatar'],
                                                '$sparkle' => $sparkle,
                                                '$title' => $title_e,
                                                '$body' => $body_e,