]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #5620 from annando/fix-remove
authorTobias Diekershoff <tobias.diekershoff@gmx.net>
Wed, 15 Aug 2018 12:31:13 +0000 (14:31 +0200)
committerGitHub <noreply@github.com>
Wed, 15 Aug 2018 12:31:13 +0000 (14:31 +0200)
Fix a fatal error when removing contacts

mod/display.php
mod/ignored.php
mod/item.php
mod/network.php
mod/profile.php
src/Model/Item.php
view/theme/frio/templates/photo_view.tpl
view/theme/frio/templates/photos_upload.tpl

index c30e2262630f6412835c63e899d6783de9b8e6e2..2d32eed5eb504018f39cab567e920227fca5240f 100644 (file)
@@ -247,7 +247,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
        }
 
        // We are displaying an "alternate" link if that post was public. See issue 2864
-       $is_public = DBA::exists('item', ['id' => $item_id, 'private' => [0, 2]]);
+       $is_public = Item::exists(['id' => $item_id, 'private' => [0, 2]]);
        if ($is_public) {
                // For the atom feed the nickname doesn't matter at all, we only need the item id.
                $alternate = System::baseUrl().'/display/feed-item/'.$item_id.'.atom';
@@ -324,7 +324,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
 
        if (local_user() && (local_user() == $a->profile['uid'])) {
                $condition = ['parent-uri' => $item_parent_uri, 'uid' => local_user(), 'unseen' => true];
-               $unseen = DBA::exists('item', $condition);
+               $unseen = Item::exists($condition);
        } else {
                $unseen = false;
        }
index f42e3a8bd3571d1a9d8024ffe2cd2fb67eda4a01..8502874ce537ee04e01e2854e65aa05e08c887eb 100644 (file)
@@ -7,8 +7,6 @@ use Friendica\Model\Item;
 
 function ignored_init(App $a)
 {
-       $ignored = 0;
-
        if (!local_user()) {
                killme();
        }
@@ -26,9 +24,8 @@ function ignored_init(App $a)
                killme();
        }
 
-       if (!$thread['ignored']) {
-               $ignored = true;
-       }
+       // Numeric values are needed for the json output further below
+       $ignored = ($thread['ignored'] ? 0 : 1);
 
        if ($thread['uid'] != 0) {
                DBA::update('thread', ['ignored' => $ignored], ['iid' => $message_id]);
index be3af101d9e18f66879c38883579ab1891724014..733c6aee85306c8e78b4bcb23cec661e326a015d 100644 (file)
@@ -152,7 +152,7 @@ function item_post(App $a) {
 
        // Check for multiple posts with the same message id (when the post was created via API)
        if (($message_id != '') && ($profile_uid != 0)) {
-               if (DBA::exists('item', ['uri' => $message_id, 'uid' => $profile_uid])) {
+               if (Item::exists(['uri' => $message_id, 'uid' => $profile_uid])) {
                        logger("Message with URI ".$message_id." already exists for user ".$profile_uid, LOGGER_DEBUG);
                        return;
                }
index 49f9c7cb1b00b5afe5b57f58dd4d9108ca4b1aaf..6cee4d2b806f296a7870c06ef69b52b0709ba8e2 100644 (file)
@@ -318,7 +318,7 @@ function networkSetSeen($condition)
                return;
        }
 
-       $unseen = DBA::exists('item', $condition);
+       $unseen = Item::exists($condition);
 
        if ($unseen) {
                $r = Item::update(['unseen' => false], $condition);
index 6f201591ec9488b9e1a5b7fe7aa3f2e0f4f36915..5d7489ebb4159aaaae337fa5ab884ebf0a01641c 100644 (file)
@@ -347,7 +347,7 @@ function profile_content(App $a, $update = 0)
 
 
        if ($is_owner) {
-               $unseen = DBA::exists('item', ['wall' => true, 'unseen' => true, 'uid' => local_user()]);
+               $unseen = Item::exists(['wall' => true, 'unseen' => true, 'uid' => local_user()]);
                if ($unseen) {
                        $r = Item::update(['unseen' => false],
                                        ['wall' => true, 'unseen' => true, 'uid' => local_user()]);
index e22af0e261d337b7009b6f113ea308a5853f6dab..10526eaabeaf0b7de4f90e69d690b40c3f41c798 100644 (file)
@@ -80,7 +80,7 @@ class Item extends BaseObject
        // All fields in the item table
        const ITEM_FIELDLIST = ['id', 'uid', 'parent', 'uri', 'parent-uri', 'thr-parent', 'guid',
                        'contact-id', 'type', 'wall', 'gravity', 'extid', 'icid', 'iaid', 'psid',
-                       'created', 'edited', 'commented', 'received', 'changed', 'verb',
+                       'uri-hash', 'created', 'edited', 'commented', 'received', 'changed', 'verb',
                        'postopts', 'plink', 'resource-id', 'event-id', 'tag', 'attach', 'inform',
                        'file', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'post-type',
                        'private', 'pubmail', 'moderated', 'visible', 'starred', 'bookmark',
@@ -524,7 +524,7 @@ class Item extends BaseObject
 
                $fields['item'] = ['id', 'uid', 'parent', 'uri', 'parent-uri', 'thr-parent', 'guid',
                        'contact-id', 'owner-id', 'author-id', 'type', 'wall', 'gravity', 'extid',
-                       'created', 'edited', 'commented', 'received', 'changed', 'psid',
+                       'created', 'edited', 'commented', 'received', 'changed', 'psid', 'uri-hash',
                        'resource-id', 'event-id', 'tag', 'attach', 'post-type', 'file',
                        'private', 'pubmail', 'moderated', 'visible', 'starred', 'bookmark',
                        'unseen', 'deleted', 'origin', 'forum_mode', 'mention', 'global',
@@ -950,8 +950,8 @@ class Item extends BaseObject
         */
        public static function delete($condition, $priority = PRIORITY_HIGH)
        {
-               $items = DBA::select('item', ['id'], $condition);
-               while ($item = DBA::fetch($items)) {
+               $items = self::select(['id'], $condition);
+               while ($item = self::fetch($items)) {
                        self::deleteById($item['id'], $priority);
                }
                DBA::close($items);
@@ -969,8 +969,8 @@ class Item extends BaseObject
                        return;
                }
 
-               $items = DBA::select('item', ['id', 'uid'], $condition);
-               while ($item = DBA::fetch($items)) {
+               $items = self::select(['id', 'uid'], $condition);
+               while ($item = self::fetch($items)) {
                        // "Deleting" global items just means hiding them
                        if ($item['uid'] == 0) {
                                DBA::update('user-item', ['hidden' => true], ['iid' => $item['id'], 'uid' => $uid], true);
@@ -1073,15 +1073,15 @@ class Item extends BaseObject
 
                DBA::delete('item-delivery-data', ['iid' => $item['id']]);
 
-               if (!empty($item['iaid']) && !DBA::exists('item', ['iaid' => $item['iaid'], 'deleted' => false])) {
+               if (!empty($item['iaid']) && !self::exists(['iaid' => $item['iaid'], 'deleted' => false])) {
                        DBA::delete('item-activity', ['id' => $item['iaid']], ['cascade' => false]);
                }
-               if (!empty($item['icid']) && !DBA::exists('item', ['icid' => $item['icid'], 'deleted' => false])) {
+               if (!empty($item['icid']) && !self::exists(['icid' => $item['icid'], 'deleted' => false])) {
                        DBA::delete('item-content', ['id' => $item['icid']], ['cascade' => false]);
                }
                // When the permission set will be used in photo and events as well,
                // this query here needs to be extended.
-               if (!empty($item['psid']) && !DBA::exists('item', ['psid' => $item['psid'], 'deleted' => false])) {
+               if (!empty($item['psid']) && !self::exists(['psid' => $item['psid'], 'deleted' => false])) {
                        DBA::delete('permissionset', ['id' => $item['psid']], ['cascade' => false]);
                }
 
@@ -1360,7 +1360,7 @@ class Item extends BaseObject
                }
 
                // Ensure to always have the same creation date.
-               $existing = DBA::selectfirst('item', ['created', 'uri-hash'], ['uri' => $item['uri']]);
+               $existing = self::selectfirst(['created', 'uri-hash'], ['uri' => $item['uri']]);
                if (DBA::isResult($existing)) {
                        $item['created'] = $existing['created'];
                        $item['uri-hash'] = $existing['uri-hash'];
@@ -1617,7 +1617,7 @@ class Item extends BaseObject
                        $item["global"] = true;
 
                        // Set the global flag on all items if this was a global item entry
-                       DBA::update('item', ['global' => true], ['uri' => $item["uri"]]);
+                       self::update(['global' => true], ['uri' => $item["uri"]]);
                } else {
                        $item["global"] = self::exists(['uid' => 0, 'uri' => $item["uri"]]);
                }
@@ -1768,7 +1768,7 @@ class Item extends BaseObject
                }
 
                // Set parent id
-               DBA::update('item', ['parent' => $parent_id], ['id' => $current_post]);
+               self::update(['parent' => $parent_id], ['id' => $current_post]);
 
                $item['id'] = $current_post;
                $item['parent'] = $parent_id;
@@ -1776,9 +1776,9 @@ class Item extends BaseObject
                // update the commented timestamp on the parent
                // Only update "commented" if it is really a comment
                if (($item['gravity'] != GRAVITY_ACTIVITY) || !Config::get("system", "like_no_comment")) {
-                       DBA::update('item', ['commented' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
+                       self::update(['commented' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
                } else {
-                       DBA::update('item', ['changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
+                       self::update(['changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
                }
 
                if ($dsprsig) {
@@ -2076,7 +2076,7 @@ class Item extends BaseObject
 
                if ($item['uri'] != $item['parent-uri']) {
                        $parents = self::select(['uid', 'origin'], ["`uri` = ? AND `uid` != 0", $item['parent-uri']]);
-                       while ($parent = DBA::fetch($parents)) {
+                       while ($parent = self::fetch($parents)) {
                                $users[$parent['uid']] = $parent['uid'];
                                if ($parent['origin'] && !$origin) {
                                        $origin_uid = $parent['uid'];
@@ -2467,6 +2467,7 @@ class Item extends BaseObject
 
                // Does the given user have this item?
                if ($uid) {
+                       /// @todo This query has to be abstracted for the "uri-id" changes
                        $item = DBA::fetchFirst("SELECT `item`.`id`, `user`.`nickname` FROM `item`
                                INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
                                WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
@@ -2479,6 +2480,7 @@ class Item extends BaseObject
 
                // Or is it anywhere on the server?
                if ($nick == "") {
+                       /// @todo This query has to be abstracted for the "uri-id" changes
                        $item = DBA::fetchFirst("SELECT `item`.`id`, `user`.`nickname` FROM `item`
                                INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
                                WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
@@ -2579,7 +2581,7 @@ class Item extends BaseObject
                $fields = ['wall' => true, 'origin' => true, 'forum_mode' => $forum_mode, 'contact-id' => $self['id'],
                        'owner-id' => $owner_id, 'owner-link' => $self['url'], 'private' => $private, 'allow_cid' => $user['allow_cid'],
                        'allow_gid' => $user['allow_gid'], 'deny_cid' => $user['deny_cid'], 'deny_gid' => $user['deny_gid']];
-               DBA::update('item', $fields, ['id' => $item_id]);
+               self::update($fields, ['id' => $item_id]);
 
                self::updateThread($item_id);
 
index fd47097a5c03ae5dfb39b49f314cae734d0196b5..ce058f507e994ff38b684d01f86bcab1ed0a04e0 100644 (file)
@@ -3,7 +3,7 @@
 {{* "live-photos" is needed for js autoupdate *}}
 <div id="live-photos"></div>
 
-<div id="photo-view-{{$id}}" class="general-content-wrapper">
+<div id="photo-view-{{$id}}" class="generic-page-wrapper">
        <h3><a href="{{$album.0}}">{{$album.1}}</a></h3>
 
        <div id="photo-edit-link-wrap">
@@ -53,7 +53,7 @@
                <div id="photo-like-div">
                        {{$likebuttons}}
                        {{$like}}
-                       {{$dislike}}    
+                       {{$dislike}}
                </div>
                {{/if}}
                <hr>
index 4372b10264b2fa10c4ec21506779400e221ac5bc..1162dc3ac686c2f48179fce565f4af60a3a722bd 100644 (file)
@@ -1,52 +1,53 @@
+<div class="generic-page-wrapper">
 
-<h3>{{$pagename}}</h3>
+       <h3>{{$pagename}}</h3>
 
-<div id="photos-usage-message">{{$usage}}</div>
+       <div id="photos-usage-message">{{$usage}}</div>
 
-<form action="photos/{{$nickname}}" enctype="multipart/form-data" method="post" name="photos-upload-form" id="photos-upload-form" >
-       <div id="photos-upload-new-wrapper" >
-               <div id="photos-upload-newalbum-div">
-                       <label id="photos-upload-newalbum-text" for="photos-upload-newalbum" >{{$newalbum}}</label>
+       <form action="photos/{{$nickname}}" enctype="multipart/form-data" method="post" name="photos-upload-form" id="photos-upload-form">
+               <div id="photos-upload-new-wrapper" >
+                       <div id="photos-upload-newalbum-div">
+                               <label id="photos-upload-newalbum-text" for="photos-upload-newalbum" >{{$newalbum}}</label>
+                       </div>
+                       <input class="form-control" id="photos-upload-newalbum" type="text" name="newalbum" />
                </div>
-               <input class="form-control" id="photos-upload-newalbum" type="text" name="newalbum" />
-       </div>
-       <div id="photos-upload-new-end"></div>
-       <div id="photos-upload-exist-wrapper">
-               <div id="photos-upload-existing-album-div">
-                       <label id="photos-upload-existing-album-text" for="photos-upload-album-select">{{$existalbumtext}}</label>
+               <div id="photos-upload-new-end"></div>
+
+               <div id="photos-upload-exist-wrapper">
+                       <div id="photos-upload-existing-album-div">
+                               <label id="photos-upload-existing-album-text" for="photos-upload-album-select">{{$existalbumtext}}</label>
+                       </div>
+                       <select class="form-control" id="photos-upload-album-select" name="album" size="4">
+                               {{$albumselect}}
+                       </select>
                </div>
-               <select class="form-control" id="photos-upload-album-select" name="album" size="4">
-               {{$albumselect}}
-               </select>
-       </div>
-       <div id="photos-upload-exist-end"></div>
-
-       <div id="photos-upload-noshare-div" class="photos-upload-noshare-div pull-left" >
-               <input id="photos-upload-noshare" type="checkbox" name="not_visible" value="1" checked/>
-               <label id="photos-upload-noshare-text" for="photos-upload-noshare" >{{$nosharetext}}</label>
-       </div>
-
-
-       <div id="photos-upload-perms" class="photos-upload-perms pull-right" >
-               <a href="#photos-upload-permissions-wrapper" id="photos-upload-perms-menu" class="button popupbox" />
-               <span id="jot-perms-icon" class="icon {{$lockstate}}" ></span>{{$permissions}}
-               </a>
-       </div>
-       <div id="photos-upload-perms-end" class="clear"></div>
-
-       <div style="display: none;">
-               <div id="photos-upload-permissions-wrapper">
-                       {{$aclselect}}
+               <div id="photos-upload-exist-end"></div>
+
+               <div id="photos-upload-noshare-div" class="photos-upload-noshare-div pull-left" >
+                       <input id="photos-upload-noshare" type="checkbox" name="not_visible" value="1" checked/>
+                       <label id="photos-upload-noshare-text" for="photos-upload-noshare" >{{$nosharetext}}</label>
+               </div>
+
+               <div id="photos-upload-perms" class="photos-upload-perms pull-right" >
+                       <a href="#photos-upload-permissions-wrapper" id="photos-upload-perms-menu" class="button popupbox" />
+                               <span id="jot-perms-icon" class="icon {{$lockstate}}" ></span>{{$permissions}}
+                       </a>
                </div>
-       </div>
+               <div id="photos-upload-perms-end" class="clear"></div>
 
-       <div id="photos-upload-spacer"></div>
+               <div style="display: none;">
+                       <div id="photos-upload-permissions-wrapper">
+                               {{$aclselect}}
+                       </div>
+               </div>
 
-       {{$alt_uploader}}
+               <div id="photos-upload-spacer"></div>
 
-       {{$default_upload_box}}
-       {{$default_upload_submit}}
+               {{$alt_uploader}}
 
-       <div class="photos-upload-end" ></div>
-</form>
+               {{$default_upload_box}}
+               {{$default_upload_submit}}
 
+               <div class="photos-upload-end" ></div>
+       </form>
+</div>