]> git.mxchange.org Git - friendica.git/blob - static/dbview.config.php
Fix several database issues
[friendica.git] / static / dbview.config.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2020, Friendica
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  * Main view structure configuration file.
21  *
22  * Here are described all the view Friendica needs to work.
23  *
24  * Syntax (braces indicate optionale values):
25  * "<view name>" => [
26  *      "fields" => [
27  *              "<field name>" => ["table", "field"],
28  *              "<field name>" => "SQL expression",
29  *              ...
30  *      ],
31  *      "query" => "FROM `table` INNER JOIN `other-table` ..."
32  *      ],
33  * ],
34  *
35  * If you need to make any change, make sure to increment the DB_UPDATE_VERSION constant value in dbstructure.config.php.
36  *
37  */
38
39  return [
40         "post-view" => [
41                 "fields" => [
42                         "id" => ["post-user", "id"],
43                         "item-id" => ["item", "id"],
44                         "post-user-id" => ["post-user", "id"],
45                         "uid" => ["post-user", "uid"],
46                         "parent" => ["parent-post", "id"],
47                         "uri" => ["item-uri", "uri"],
48                         "uri-id" => ["post-user", "uri-id"],
49                         "parent-uri" => ["parent-item-uri", "uri"],
50                         "parent-uri-id" => ["post-user", "parent-uri-id"],
51                         "thr-parent" => ["thr-parent-item-uri", "uri"],
52                         "thr-parent-id" => ["post-user", "thr-parent-id"],
53                         "guid" => ["item-uri", "guid"],
54                         "wall" => ["post-user", "wall"],
55                         "gravity" => ["post-user", "gravity"],
56                         "extid" => ["external-item-uri", "uri"],
57                         "external-id" => ["post-user", "external-id"],
58                         "created" => ["post-user", "created"],
59                         "edited" => ["post-user", "edited"],
60                         "commented" => ["post-thread-user", "commented"],
61                         "received" => ["post-user", "received"],
62                         "changed" => ["post-thread-user", "changed"],
63                         "post-type" => ["post-user", "post-type"],
64                         "private" => ["post-user", "private"],
65                         "pubmail" => ["post-thread-user", "pubmail"],
66                         "visible" => ["post-user", "visible"],
67                         "starred" => ["post-thread-user", "starred"],
68                         "unseen" => ["post-user", "unseen"],
69                         "deleted" => ["post-user", "deleted"],
70                         "origin" => ["post-user", "origin"],
71                         "forum_mode" => ["post-thread-user", "forum_mode"],
72                         "mention" => ["post-thread-user", "mention"],
73                         "global" => ["post-user", "global"],
74                         "network" => ["post-user", "network"],
75                         "vid" => ["post-user", "vid"],
76                         "psid" => ["post-user", "psid"],
77                         "verb" => "IF (`post-user`.`vid` IS NULL, '', `verb`.`name`)",
78                         "title" => ["post-content", "title"],
79                         "content-warning" => ["post-content", "content-warning"],
80                         "raw-body" => ["post-content", "raw-body"],
81                         "body" => ["post-content", "body"],
82                         "rendered-hash" => ["post-content", "rendered-hash"],
83                         "rendered-html" => ["post-content", "rendered-html"],
84                         "language" => ["post-content", "language"],
85                         "plink" => ["post-content", "plink"],
86                         "location" => ["post-content", "location"],
87                         "coord" => ["post-content", "coord"],
88                         "app" => ["post-content", "app"],
89                         "object-type" => ["post-content", "object-type"],
90                         "object" => ["post-content", "object"],
91                         "target-type" => ["post-content", "target-type"],
92                         "target" => ["post-content", "target"],
93                         "resource-id" => ["post-content", "resource-id"],
94                         "contact-id" => ["post-user", "contact-id"],
95                         "contact-link" => ["contact", "url"],
96                         "contact-addr" => ["contact", "addr"],
97                         "contact-name" => ["contact", "name"],
98                         "contact-nick" => ["contact", "nick"],
99                         "contact-avatar" => ["contact", "thumb"],
100                         "contact-network" => ["contact", "network"],
101                         "contact-blocked" => ["contact", "blocked"],
102                         "contact-hidden" => ["contact", "hidden"],
103                         "contact-readonly" => ["contact", "readonly"],
104                         "contact-archive" => ["contact", "archive"],
105                         "contact-pending" => ["contact", "pending"],
106                         "contact-rel" => ["contact", "rel"],
107                         "contact-uid" => ["contact", "uid"],
108                         "contact-contact-type" => ["contact", "contact-type"],
109                         "writable" => "IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`)",
110                         "self" => ["contact", "self"],
111                         "cid" => ["contact", "id"],
112                         "alias" => ["contact", "alias"],
113                         "photo" => ["contact", "photo"],
114                         "name-date" => ["contact", "name-date"],
115                         "uri-date" => ["contact", "uri-date"],
116                         "avatar-date" => ["contact", "avatar-date"],
117                         "thumb" => ["contact", "thumb"],
118                         "dfrn-id" => ["contact", "dfrn-id"],
119                         "author-id" => ["post-user", "author-id"],
120                         "author-link" => ["author", "url"],
121                         "author-addr" => ["author", "addr"],
122                         "author-name" => "IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`)",
123                         "author-nick" => ["author", "nick"],
124                         "author-avatar" => "IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`)",
125                         "author-network" => ["author", "network"],
126                         "author-blocked" => ["author", "blocked"],
127                         "author-hidden" => ["author", "hidden"],
128                         "owner-id" => ["post-user", "owner-id"],
129                         "owner-link" => ["owner", "url"],
130                         "owner-addr" => ["owner", "addr"],
131                         "owner-name" => "IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`)",
132                         "owner-nick" => ["owner", "nick"],
133                         "owner-avatar" => "IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`)",
134                         "owner-network" => ["owner", "network"],
135                         "owner-blocked" => ["owner", "blocked"],
136                         "owner-hidden" => ["owner", "hidden"],
137                         "causer-id" => ["post-user", "causer-id"],
138                         "causer-link" => ["causer", "url"],
139                         "causer-addr" => ["causer", "addr"],
140                         "causer-name" => ["causer", "name"],
141                         "causer-nick" => ["causer", "nick"], 
142                         "causer-avatar" => ["causer", "thumb"],
143                         "causer-network" => ["causer", "network"],
144                         "causer-blocked" => ["causer", "blocked"],
145                         "causer-hidden" => ["causer", "hidden"],
146                         "causer-contact-type" => ["causer", "contact-type"],
147                         "postopts" => ["post-delivery-data", "postopts"],
148                         "inform" => ["post-delivery-data", "inform"],
149                         "delivery_queue_count" => ["post-delivery-data", "queue_count"],
150                         "delivery_queue_done" => ["post-delivery-data", "queue_done"],
151                         "delivery_queue_failed" => ["post-delivery-data", "queue_failed"],
152                         "allow_cid" => "IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`)",
153                         "allow_gid" => "IF (`post-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`)",
154                         "deny_cid" => "IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`)",
155                         "deny_gid" => "IF (`post-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`)",
156                         "event-id" => ["post-user", "event-id"],
157                         "event-created" => ["event", "created"],
158                         "event-edited" => ["event", "edited"],
159                         "event-start" => ["event", "start"],
160                         "event-finish" => ["event", "finish"],
161                         "event-summary" => ["event", "summary"],
162                         "event-desc" => ["event", "desc"],
163                         "event-location" => ["event", "location"],
164                         "event-type" => ["event", "type"],
165                         "event-nofinish" => ["event", "nofinish"],
166                         "event-adjust" => ["event", "adjust"],
167                         "event-ignore" => ["event", "ignore"],
168                         "signed_text" => ["diaspora-interaction", "interaction"],
169                         "parent-guid" => ["parent-item-uri", "guid"],
170                         "parent-network" => ["parent-post", "network"],
171                         "parent-author-id" => ["parent-post", "author-id"],
172                         "parent-author-link" => ["parent-post-author", "url"],  
173                         "parent-author-name" => ["parent-post-author", "name"],
174                         "parent-author-network" => ["parent-post-author", "network"], 
175                 ],
176                 "query" => "FROM `post-user`
177                         STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
178                         LEFT JOIN `item` ON `item`.`uri-id` = `post-user`.`uri-id` AND `item`.`uid` = `post-user`.`uid`
179                         INNER JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
180                         INNER JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
181                         INNER JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
182                         INNER JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
183                         INNER JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
184                         INNER JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
185                         INNER JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
186                         LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
187                         INNER JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
188                         LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
189                         LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
190                         LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
191                         LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
192                         LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
193                         LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
194                         INNER JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`"
195         ],
196         "post-thread-view" => [
197                 "fields" => [
198                         "id" => ["post-user", "id"],
199                         "item-id" => ["item", "id"],
200                         "post-user-id" => ["post-user", "id"],
201                         "uid" => ["post-thread-user", "uid"],
202                         "parent" => ["parent-post", "id"],
203                         "uri" => ["item-uri", "uri"],
204                         "uri-id" => ["post-thread-user", "uri-id"],
205                         "parent-uri" => ["parent-item-uri", "uri"],
206                         "parent-uri-id" => ["post-user", "parent-uri-id"],
207                         "thr-parent" => ["thr-parent-item-uri", "uri"],
208                         "thr-parent-id" => ["post-user", "thr-parent-id"],
209                         "guid" => ["item-uri", "guid"],
210                         "wall" => ["post-thread-user", "wall"],
211                         "gravity" => ["post-user", "gravity"],
212                         "extid" => ["external-item-uri", "uri"],
213                         "external-id" => ["post-user", "external-id"],
214                         "created" => ["post-thread-user", "created"],
215                         "edited" => ["post-user", "edited"],
216                         "commented" => ["post-thread-user", "commented"],
217                         "received" => ["post-thread-user", "received"],
218                         "changed" => ["post-thread-user", "changed"],
219                         "post-type" => ["post-user", "post-type"],
220                         "private" => ["post-user", "private"],
221                         "pubmail" => ["post-thread-user", "pubmail"],
222                         "ignored" => ["post-thread-user", "ignored"],
223                         "visible" => ["post-user", "visible"],
224                         "starred" => ["post-thread-user", "starred"],
225                         "unseen" => ["post-thread-user", "unseen"],
226                         "deleted" => ["post-user", "deleted"],
227                         "origin" => ["post-thread-user", "origin"],
228                         "forum_mode" => ["post-thread-user", "forum_mode"],
229                         "mention" => ["post-thread-user", "mention"],
230                         "global" => ["post-user", "global"],
231                         "network" => ["post-thread-user", "network"],
232                         "vid" => ["post-user", "vid"],
233                         "psid" => ["post-thread-user", "psid"],
234                         "verb" => "IF (`post-user`.`vid` IS NULL, '', `verb`.`name`)",
235                         "title" => ["post-content", "title"],
236                         "content-warning" => ["post-content", "content-warning"],
237                         "raw-body" => ["post-content", "raw-body"],
238                         "body" => ["post-content", "body"],
239                         "rendered-hash" => ["post-content", "rendered-hash"],
240                         "rendered-html" => ["post-content", "rendered-html"],
241                         "language" => ["post-content", "language"],
242                         "plink" => ["post-content", "plink"],
243                         "location" => ["post-content", "location"],
244                         "coord" => ["post-content", "coord"],
245                         "app" => ["post-content", "app"],
246                         "object-type" => ["post-content", "object-type"],
247                         "object" => ["post-content", "object"],
248                         "target-type" => ["post-content", "target-type"],
249                         "target" => ["post-content", "target"],
250                         "resource-id" => ["post-content", "resource-id"],
251                         "contact-id" => ["post-thread-user", "contact-id"],
252                         "contact-link" => ["contact", "url"],
253                         "contact-addr" => ["contact", "addr"],
254                         "contact-name" => ["contact", "name"],
255                         "contact-nick" => ["contact", "nick"],
256                         "contact-avatar" => ["contact", "thumb"],
257                         "contact-network" => ["contact", "network"],
258                         "contact-blocked" => ["contact", "blocked"],
259                         "contact-hidden" => ["contact", "hidden"],
260                         "contact-readonly" => ["contact", "readonly"],
261                         "contact-archive" => ["contact", "archive"],
262                         "contact-pending" => ["contact", "pending"],
263                         "contact-rel" => ["contact", "rel"],
264                         "contact-uid" => ["contact", "uid"],
265                         "contact-contact-type" => ["contact", "contact-type"],
266                         "writable" => "IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`)",
267                         "self" => ["contact", "self"],
268                         "cid" => ["contact", "id"],
269                         "alias" => ["contact", "alias"],
270                         "photo" => ["contact", "photo"],
271                         "name-date" => ["contact", "name-date"],
272                         "uri-date" => ["contact", "uri-date"],
273                         "avatar-date" => ["contact", "avatar-date"],
274                         "thumb" => ["contact", "thumb"],
275                         "dfrn-id" => ["contact", "dfrn-id"],
276                         "author-id" => ["post-thread-user", "author-id"],
277                         "author-link" => ["author", "url"],
278                         "author-addr" => ["author", "addr"],
279                         "author-name" => "IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`)",
280                         "author-nick" => ["author", "nick"],
281                         "author-avatar" => "IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`)",
282                         "author-network" => ["author", "network"],
283                         "author-blocked" => ["author", "blocked"],
284                         "author-hidden" => ["author", "hidden"],
285                         "owner-id" => ["post-thread-user", "owner-id"],
286                         "owner-link" => ["owner", "url"],
287                         "owner-addr" => ["owner", "addr"],
288                         "owner-name" => "IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`)",
289                         "owner-nick" => ["owner", "nick"],
290                         "owner-avatar" => "IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`)",
291                         "owner-network" => ["owner", "network"],
292                         "owner-blocked" => ["owner", "blocked"],
293                         "owner-hidden" => ["owner", "hidden"],
294                         "causer-id" => ["post-thread-user", "causer-id"],
295                         "causer-link" => ["causer", "url"],
296                         "causer-addr" => ["causer", "addr"],
297                         "causer-name" => ["causer", "name"],
298                         "causer-nick" => ["causer", "nick"], 
299                         "causer-avatar" => ["causer", "thumb"],
300                         "causer-network" => ["causer", "network"],
301                         "causer-blocked" => ["causer", "blocked"],
302                         "causer-hidden" => ["causer", "hidden"],
303                         "causer-contact-type" => ["causer", "contact-type"],
304                         "postopts" => ["post-delivery-data", "postopts"],
305                         "inform" => ["post-delivery-data", "inform"],
306                         "delivery_queue_count" => ["post-delivery-data", "queue_count"],
307                         "delivery_queue_done" => ["post-delivery-data", "queue_done"],
308                         "delivery_queue_failed" => ["post-delivery-data", "queue_failed"],
309                         "allow_cid" => "IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`)",
310                         "allow_gid" => "IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`)",
311                         "deny_cid" => "IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`)",
312                         "deny_gid" => "IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`)",
313                         "event-id" => ["post-user", "event-id"],
314                         "event-created" => ["event", "created"],
315                         "event-edited" => ["event", "edited"],
316                         "event-start" => ["event", "start"],
317                         "event-finish" => ["event", "finish"],
318                         "event-summary" => ["event", "summary"],
319                         "event-desc" => ["event", "desc"],
320                         "event-location" => ["event", "location"],
321                         "event-type" => ["event", "type"],
322                         "event-nofinish" => ["event", "nofinish"],
323                         "event-adjust" => ["event", "adjust"],
324                         "event-ignore" => ["event", "ignore"],
325                         "signed_text" => ["diaspora-interaction", "interaction"],
326                         "parent-guid" => ["parent-item-uri", "guid"],
327                         "parent-network" => ["parent-post", "network"],
328                         "parent-author-id" => ["parent-post", "author-id"],
329                         "parent-author-link" => ["parent-post-author", "url"],  
330                         "parent-author-name" => ["parent-post-author", "name"],
331                         "parent-author-network" => ["parent-post-author", "network"], 
332                 ],
333                 "query" => "FROM `post-thread-user`
334                         INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
335                         LEFT JOIN `item` ON `item`.`uri-id` = `post-thread-user`.`uri-id` AND `item`.`uid` = `post-thread-user`.`uid`
336                         INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
337                         INNER JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
338                         INNER JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
339                         INNER JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
340                         INNER JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
341                         INNER JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
342                         INNER JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
343                         LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
344                         INNER JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
345                         LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
346                         LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
347                         LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
348                         LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
349                         LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
350                         LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
351                         INNER JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`"
352         ],
353         "category-view" => [
354                 "fields" => [
355                         "uri-id" => ["post-category", "uri-id"],
356                         "uid" => ["post-category", "uid"],
357                         "type" => ["post-category", "type"],
358                         "tid" => ["post-category", "tid"],
359                         "name" => ["tag", "name"],
360                         "url" => ["tag", "url"],
361                 ],
362                 "query" => "FROM `post-category`
363                         LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`"
364         ],
365         "tag-view" => [
366                 "fields" => [
367                         "uri-id" => ["post-tag", "uri-id"],
368                         "type" => ["post-tag", "type"],
369                         "tid" => ["post-tag", "tid"],
370                         "cid" => ["post-tag", "cid"],
371                         "name" => "CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END",
372                         "url" => "CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END",
373                 ],
374                 "query" => "FROM `post-tag`
375                         LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
376                         LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`"
377         ],
378         "network-item-view" => [
379                 "fields" => [
380                         "uri-id" => ["post-user", "uri-id"],
381                         "parent" => ["parent-post", "id"],
382                         "received" => ["post-user", "received"],
383                         "commented" => ["post-thread-user", "commented"],
384                         "created" => ["post-user", "created"],
385                         "uid" => ["post-user", "uid"],
386                         "starred" => ["post-thread-user", "starred"],
387                         "mention" => ["post-thread-user", "mention"],
388                         "network" => ["post-user", "network"],
389                         "unseen" => ["post-user", "unseen"],
390                         "gravity" => ["post-user", "gravity"],
391                         "contact-id" => ["post-user", "contact-id"],
392                         "contact-type" => ["ownercontact", "contact-type"],
393                 ],
394                 "query" => "FROM `post-user`
395                         STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`                  
396                         INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
397                         LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
398                         LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
399                         INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
400                         LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
401                         WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
402                         AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
403                         AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
404                         AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
405                         AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
406         ],
407         "network-thread-view" => [
408                 "fields" => [
409                         "uri-id" => ["post-thread-user", "uri-id"],
410                         "parent" => ["parent-post", "id"],
411                         "received" => ["post-thread-user", "received"],
412                         "commented" => ["post-thread-user", "commented"],
413                         "created" => ["post-thread-user", "created"],
414                         "uid" => ["post-thread-user", "uid"],
415                         "starred" => ["post-thread-user", "starred"],
416                         "mention" => ["post-thread-user", "mention"],
417                         "network" => ["post-thread-user", "network"],
418                         "contact-id" => ["post-thread-user", "contact-id"],
419                         "contact-type" => ["ownercontact", "contact-type"],
420                 ],
421                 "query" => "FROM `post-thread-user`
422                         INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
423                         STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
424                         LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
425                         LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
426                         LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
427                         LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
428                         WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
429                         AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
430                         AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
431                         AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
432                         AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
433         ],
434         "owner-view" => [
435                 "fields" => [
436                         "id" => ["contact", "id"],
437                         "uid" => ["contact", "uid"],
438                         "created" => ["contact", "created"],
439                         "updated" => ["contact", "updated"],
440                         "self" => ["contact", "self"],
441                         "remote_self" => ["contact", "remote_self"],
442                         "rel" => ["contact", "rel"],
443                         "duplex" => ["contact", "duplex"],
444                         "network" => ["contact", "network"],
445                         "protocol" => ["contact", "protocol"],
446                         "name" => ["contact", "name"],
447                         "nick" => ["contact", "nick"],
448                         "location" => ["contact", "location"],
449                         "about" => ["contact", "about"],
450                         "keywords" => ["contact", "keywords"],
451                         "gender" => ["contact", "gender"],
452                         "xmpp" => ["contact", "xmpp"],
453                         "attag" => ["contact", "attag"],
454                         "avatar" => ["contact", "avatar"],
455                         "photo" => ["contact", "photo"],
456                         "thumb" => ["contact", "thumb"],
457                         "micro" => ["contact", "micro"],
458                         "site-pubkey" => ["contact", "site-pubkey"],
459                         "issued-id" => ["contact", "issued-id"],
460                         "dfrn-id" => ["contact", "dfrn-id"],
461                         "url" => ["contact", "url"],
462                         "nurl" => ["contact", "nurl"],
463                         "addr" => ["contact", "addr"],
464                         "alias" => ["contact", "alias"],
465                         "pubkey" => ["contact", "pubkey"],
466                         "prvkey" => ["contact", "prvkey"],
467                         "batch" => ["contact", "batch"],
468                         "request" => ["contact", "request"],
469                         "notify" => ["contact", "notify"],
470                         "poll" => ["contact", "poll"],
471                         "confirm" => ["contact", "confirm"],
472                         "poco" => ["contact", "poco"],
473                         "aes_allow" => ["contact", "aes_allow"],
474                         "ret-aes" => ["contact", "ret-aes"],
475                         "usehub" => ["contact", "usehub"],
476                         "subhub" => ["contact", "subhub"],
477                         "hub-verify" => ["contact", "hub-verify"],
478                         "last-update" => ["contact", "last-update"],
479                         "success_update" => ["contact", "success_update"],
480                         "failure_update" => ["contact", "failure_update"],
481                         "name-date" => ["contact", "name-date"],
482                         "uri-date" => ["contact", "uri-date"],
483                         "avatar-date" => ["contact", "avatar-date"],
484                         "picdate" => ["contact", "avatar-date"], /// @todo Replaces all uses of "picdate" with "avatar-date"
485                         "term-date" => ["contact", "term-date"],
486                         "last-item" => ["contact", "last-item"],
487                         "priority" => ["contact", "priority"],
488                         "blocked" => ["user", "blocked"],
489                         "block_reason" => ["contact", "block_reason"],
490                         "readonly" => ["contact", "readonly"],
491                         "writable" => ["contact", "writable"],
492                         "forum" => ["contact", "forum"],
493                         "prv" => ["contact", "prv"],
494                         "contact-type" => ["contact", "contact-type"],
495                         "manually-approve" => ["contact", "manually-approve"],
496                         "hidden" => ["contact", "hidden"],
497                         "archive" => ["contact", "archive"],
498                         "pending" => ["contact", "pending"],
499                         "deleted" => ["contact", "deleted"],
500                         "unsearchable" => ["contact", "unsearchable"],
501                         "sensitive" => ["contact", "sensitive"],
502                         "baseurl" => ["contact", "baseurl"],
503                         "reason" => ["contact", "reason"],
504                         "closeness" => ["contact", "closeness"],
505                         "info" => ["contact", "info"],
506                         "profile-id" => ["contact", "profile-id"],
507                         "bdyear" => ["contact", "bdyear"],
508                         "bd" => ["contact", "bd"],
509                         "notify_new_posts" => ["contact", "notify_new_posts"],
510                         "fetch_further_information" => ["contact", "fetch_further_information"],
511                         "ffi_keyword_denylist" => ["contact", "ffi_keyword_denylist"],
512                         "parent-uid" => ["user", "parent-uid"],
513                         "guid" => ["user", "guid"],
514                         "nickname" => ["user", "nickname"], /// @todo Replaces all uses of "nickname" with "nick"
515                         "email" => ["user", "email"],
516                         "openid" => ["user", "openid"],
517                         "timezone" => ["user", "timezone"],
518                         "language" => ["user", "language"],
519                         "register_date" => ["user", "register_date"],
520                         "login_date" => ["user", "login_date"],
521                         "default-location" => ["user", "default-location"],
522                         "allow_location" => ["user", "allow_location"],
523                         "theme" => ["user", "theme"],
524                         "upubkey" => ["user", "pubkey"],
525                         "uprvkey" => ["user", "prvkey"],
526                         "sprvkey" => ["user", "sprvkey"],
527                         "spubkey" => ["user", "spubkey"],
528                         "verified" => ["user", "verified"],
529                         "blockwall" => ["user", "blockwall"],
530                         "hidewall" => ["user", "hidewall"],
531                         "blocktags" => ["user", "blocktags"],
532                         "unkmail" => ["user", "unkmail"],
533                         "cntunkmail" => ["user", "cntunkmail"],
534                         "notify-flags" => ["user", "notify-flags"],
535                         "page-flags" => ["user", "page-flags"],
536                         "account-type" => ["user", "account-type"],
537                         "prvnets" => ["user", "prvnets"],
538                         "maxreq" => ["user", "maxreq"],
539                         "expire" => ["user", "expire"],
540                         "account_removed" => ["user", "account_removed"],
541                         "account_expired" => ["user", "account_expired"],
542                         "account_expires_on" => ["user", "account_expires_on"],
543                         "expire_notification_sent" => ["user", "expire_notification_sent"],
544                         "def_gid" => ["user", "def_gid"],
545                         "allow_cid" => ["user", "allow_cid"],
546                         "allow_gid" => ["user", "allow_gid"],
547                         "deny_cid" => ["user", "deny_cid"],
548                         "deny_gid" => ["user", "deny_gid"],
549                         "openidserver" => ["user", "openidserver"],
550                         "publish" => ["profile", "publish"],
551                         "net-publish" => ["profile", "net-publish"],
552                         "hide-friends" => ["profile", "hide-friends"],
553                         "prv_keywords" => ["profile", "prv_keywords"],
554                         "pub_keywords" => ["profile", "pub_keywords"],
555                         "address" => ["profile", "address"],
556                         "locality" => ["profile", "locality"],
557                         "region" => ["profile", "region"],
558                         "postal-code" => ["profile", "postal-code"],
559                         "country-name" => ["profile", "country-name"],
560                         "homepage" => ["profile", "homepage"],
561                         "dob" => ["profile", "dob"],
562                 ],
563                 "query" => "FROM `user`
564                         INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
565                         INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`"
566         ],
567         "pending-view" => [
568                 "fields" => [
569                         "id" => ["register", "id"],
570                         "hash" => ["register", "hash"],
571                         "created" => ["register", "created"],
572                         "uid" => ["register", "uid"],
573                         "password" => ["register", "password"],
574                         "language" => ["register", "language"],
575                         "note" => ["register", "note"],
576                         "self" => ["contact", "self"],
577                         "name" => ["contact", "name"],
578                         "url" => ["contact", "url"],
579                         "micro" => ["contact", "micro"],
580                         "email" => ["user", "email"],
581                         "nick" => ["contact", "nick"],
582                 ],
583                 "query" => "FROM `register`
584                         INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
585                         INNER JOIN `user` ON `register`.`uid` = `user`.`uid`"
586         ],
587         "tag-search-view" => [
588                 "fields" => [
589                         "uri-id" => ["post-tag", "uri-id"],
590                         "uid" => ["post-user", "uid"],
591                         "iid" => ["post-user", "id"],
592                         "private" => ["post-user", "private"],
593                         "wall" => ["post-user", "wall"],
594                         "origin" => ["post-user", "origin"],
595                         "gravity" => ["post-user", "gravity"],
596                         "received" => ["post-user", "received"],
597                         "name" => ["tag", "name"],
598                 ],
599                 "query" => "FROM `post-tag`
600                         INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
601                         STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
602                         WHERE `post-tag`.`type` = 1"
603         ],
604         "workerqueue-view" => [
605                 "fields" => [
606                         "pid" => ["process", "pid"],
607                         "priority" => ["workerqueue", "priority"],
608                 ],
609                 "query" => "FROM `process`
610                         INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
611                         WHERE NOT `workerqueue`.`done`"
612         ],
613 ];
614