]> git.mxchange.org Git - friendica.git/blob - static/dbview.config.php
5e5630fc960d0833ef34823db8eee6b6777bd65c
[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                         "post-user-id" => ["post-user", "id"],
44                         "uid" => ["post-user", "uid"],
45                         "parent" => ["parent-post", "id"],
46                         "uri" => ["item-uri", "uri"],
47                         "uri-id" => ["post-user", "uri-id"],
48                         "parent-uri" => ["parent-item-uri", "uri"],
49                         "parent-uri-id" => ["post-user", "parent-uri-id"],
50                         "thr-parent" => ["thr-parent-item-uri", "uri"],
51                         "thr-parent-id" => ["post-user", "thr-parent-id"],
52                         "guid" => ["item-uri", "guid"],
53                         "wall" => ["post-user", "wall"],
54                         "gravity" => ["post-user", "gravity"],
55                         "extid" => ["external-item-uri", "uri"],
56                         "external-id" => ["post-user", "external-id"],
57                         "created" => ["post-user", "created"],
58                         "edited" => ["post-user", "edited"],
59                         "commented" => ["post-thread-user", "commented"],
60                         "received" => ["post-user", "received"],
61                         "changed" => ["post-thread-user", "changed"],
62                         "post-type" => ["post-user", "post-type"],
63                         "private" => ["post-user", "private"],
64                         "pubmail" => ["post-thread-user", "pubmail"],
65                         "visible" => ["post-user", "visible"],
66                         "starred" => ["post-thread-user", "starred"],
67                         "unseen" => ["post-user", "unseen"],
68                         "deleted" => ["post-user", "deleted"],
69                         "origin" => ["post-user", "origin"],
70                         "parent-origin" => ["post-thread-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 `contact` ON `contact`.`id` = `post-user`.`contact-id`
179                         LEFT JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
180                         LEFT JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
181                         LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-user`.`causer-id`
182                         LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-user`.`uri-id`
183                         LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
184                         LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
185                         LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
186                         LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
187                         LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
188                         LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-user`.`uri-id`
189                         LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-user`.`uri-id`
190                         LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-user`.`uri-id` AND `post-user`.`origin`
191                         LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-user`.`psid`
192                         LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
193                         LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`"
194         ],
195         "post-thread-view" => [
196                 "fields" => [
197                         "id" => ["post-user", "id"],
198                         "post-user-id" => ["post-user", "id"],
199                         "uid" => ["post-thread-user", "uid"],
200                         "parent" => ["parent-post", "id"],
201                         "uri" => ["item-uri", "uri"],
202                         "uri-id" => ["post-thread-user", "uri-id"],
203                         "parent-uri" => ["parent-item-uri", "uri"],
204                         "parent-uri-id" => ["post-user", "parent-uri-id"],
205                         "thr-parent" => ["thr-parent-item-uri", "uri"],
206                         "thr-parent-id" => ["post-user", "thr-parent-id"],
207                         "guid" => ["item-uri", "guid"],
208                         "wall" => ["post-thread-user", "wall"],
209                         "gravity" => ["post-user", "gravity"],
210                         "extid" => ["external-item-uri", "uri"],
211                         "external-id" => ["post-user", "external-id"],
212                         "created" => ["post-thread-user", "created"],
213                         "edited" => ["post-user", "edited"],
214                         "commented" => ["post-thread-user", "commented"],
215                         "received" => ["post-thread-user", "received"],
216                         "changed" => ["post-thread-user", "changed"],
217                         "post-type" => ["post-user", "post-type"],
218                         "private" => ["post-user", "private"],
219                         "pubmail" => ["post-thread-user", "pubmail"],
220                         "ignored" => ["post-thread-user", "ignored"],
221                         "visible" => ["post-user", "visible"],
222                         "starred" => ["post-thread-user", "starred"],
223                         "unseen" => ["post-thread-user", "unseen"],
224                         "deleted" => ["post-user", "deleted"],
225                         "origin" => ["post-thread-user", "origin"],
226                         "forum_mode" => ["post-thread-user", "forum_mode"],
227                         "mention" => ["post-thread-user", "mention"],
228                         "global" => ["post-user", "global"],
229                         "network" => ["post-thread-user", "network"],
230                         "vid" => ["post-user", "vid"],
231                         "psid" => ["post-thread-user", "psid"],
232                         "verb" => "IF (`post-user`.`vid` IS NULL, '', `verb`.`name`)",
233                         "title" => ["post-content", "title"],
234                         "content-warning" => ["post-content", "content-warning"],
235                         "raw-body" => ["post-content", "raw-body"],
236                         "body" => ["post-content", "body"],
237                         "rendered-hash" => ["post-content", "rendered-hash"],
238                         "rendered-html" => ["post-content", "rendered-html"],
239                         "language" => ["post-content", "language"],
240                         "plink" => ["post-content", "plink"],
241                         "location" => ["post-content", "location"],
242                         "coord" => ["post-content", "coord"],
243                         "app" => ["post-content", "app"],
244                         "object-type" => ["post-content", "object-type"],
245                         "object" => ["post-content", "object"],
246                         "target-type" => ["post-content", "target-type"],
247                         "target" => ["post-content", "target"],
248                         "resource-id" => ["post-content", "resource-id"],
249                         "contact-id" => ["post-thread-user", "contact-id"],
250                         "contact-link" => ["contact", "url"],
251                         "contact-addr" => ["contact", "addr"],
252                         "contact-name" => ["contact", "name"],
253                         "contact-nick" => ["contact", "nick"],
254                         "contact-avatar" => ["contact", "thumb"],
255                         "contact-network" => ["contact", "network"],
256                         "contact-blocked" => ["contact", "blocked"],
257                         "contact-hidden" => ["contact", "hidden"],
258                         "contact-readonly" => ["contact", "readonly"],
259                         "contact-archive" => ["contact", "archive"],
260                         "contact-pending" => ["contact", "pending"],
261                         "contact-rel" => ["contact", "rel"],
262                         "contact-uid" => ["contact", "uid"],
263                         "contact-contact-type" => ["contact", "contact-type"],
264                         "writable" => "IF (`post-user`.`network` IN ('apub', 'dfrn', 'dspr', 'stat'), true, `contact`.`writable`)",
265                         "self" => ["contact", "self"],
266                         "cid" => ["contact", "id"],
267                         "alias" => ["contact", "alias"],
268                         "photo" => ["contact", "photo"],
269                         "name-date" => ["contact", "name-date"],
270                         "uri-date" => ["contact", "uri-date"],
271                         "avatar-date" => ["contact", "avatar-date"],
272                         "thumb" => ["contact", "thumb"],
273                         "dfrn-id" => ["contact", "dfrn-id"],
274                         "author-id" => ["post-thread-user", "author-id"],
275                         "author-link" => ["author", "url"],
276                         "author-addr" => ["author", "addr"],
277                         "author-name" => "IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`)",
278                         "author-nick" => ["author", "nick"],
279                         "author-avatar" => "IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`)",
280                         "author-network" => ["author", "network"],
281                         "author-blocked" => ["author", "blocked"],
282                         "author-hidden" => ["author", "hidden"],
283                         "owner-id" => ["post-thread-user", "owner-id"],
284                         "owner-link" => ["owner", "url"],
285                         "owner-addr" => ["owner", "addr"],
286                         "owner-name" => "IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`)",
287                         "owner-nick" => ["owner", "nick"],
288                         "owner-avatar" => "IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`)",
289                         "owner-network" => ["owner", "network"],
290                         "owner-blocked" => ["owner", "blocked"],
291                         "owner-hidden" => ["owner", "hidden"],
292                         "causer-id" => ["post-thread-user", "causer-id"],
293                         "causer-link" => ["causer", "url"],
294                         "causer-addr" => ["causer", "addr"],
295                         "causer-name" => ["causer", "name"],
296                         "causer-nick" => ["causer", "nick"], 
297                         "causer-avatar" => ["causer", "thumb"],
298                         "causer-network" => ["causer", "network"],
299                         "causer-blocked" => ["causer", "blocked"],
300                         "causer-hidden" => ["causer", "hidden"],
301                         "causer-contact-type" => ["causer", "contact-type"],
302                         "postopts" => ["post-delivery-data", "postopts"],
303                         "inform" => ["post-delivery-data", "inform"],
304                         "delivery_queue_count" => ["post-delivery-data", "queue_count"],
305                         "delivery_queue_done" => ["post-delivery-data", "queue_done"],
306                         "delivery_queue_failed" => ["post-delivery-data", "queue_failed"],
307                         "allow_cid" => "IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_cid`)",
308                         "allow_gid" => "IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`allow_gid`)",
309                         "deny_cid" => "IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_cid`)",
310                         "deny_gid" => "IF (`post-thread-user`.`psid` IS NULL, '', `permissionset`.`deny_gid`)",
311                         "event-id" => ["post-user", "event-id"],
312                         "event-created" => ["event", "created"],
313                         "event-edited" => ["event", "edited"],
314                         "event-start" => ["event", "start"],
315                         "event-finish" => ["event", "finish"],
316                         "event-summary" => ["event", "summary"],
317                         "event-desc" => ["event", "desc"],
318                         "event-location" => ["event", "location"],
319                         "event-type" => ["event", "type"],
320                         "event-nofinish" => ["event", "nofinish"],
321                         "event-adjust" => ["event", "adjust"],
322                         "event-ignore" => ["event", "ignore"],
323                         "signed_text" => ["diaspora-interaction", "interaction"],
324                         "parent-guid" => ["parent-item-uri", "guid"],
325                         "parent-network" => ["parent-post", "network"],
326                         "parent-author-id" => ["parent-post", "author-id"],
327                         "parent-author-link" => ["parent-post-author", "url"],  
328                         "parent-author-name" => ["parent-post-author", "name"],
329                         "parent-author-network" => ["parent-post-author", "network"], 
330                 ],
331                 "query" => "FROM `post-thread-user`
332                         INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
333                         LEFT JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
334                         LEFT JOIN `contact` AS `author` ON `author`.`id` = `post-thread-user`.`author-id`
335                         LEFT JOIN `contact` AS `owner` ON `owner`.`id` = `post-thread-user`.`owner-id`
336                         LEFT JOIN `contact` AS `causer` ON `causer`.`id` = `post-thread-user`.`causer-id`
337                         LEFT JOIN `item-uri` ON `item-uri`.`id` = `post-thread-user`.`uri-id`
338                         LEFT JOIN `item-uri` AS `thr-parent-item-uri` ON `thr-parent-item-uri`.`id` = `post-user`.`thr-parent-id`
339                         LEFT JOIN `item-uri` AS `parent-item-uri` ON `parent-item-uri`.`id` = `post-user`.`parent-uri-id`
340                         LEFT JOIN `item-uri` AS `external-item-uri` ON `external-item-uri`.`id` = `post-user`.`external-id`
341                         LEFT JOIN `verb` ON `verb`.`id` = `post-user`.`vid`
342                         LEFT JOIN `event` ON `event`.`id` = `post-user`.`event-id`
343                         LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `post-thread-user`.`uri-id`
344                         LEFT JOIN `post-content` ON `post-content`.`uri-id` = `post-thread-user`.`uri-id`
345                         LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `post-thread-user`.`uri-id` AND `post-thread-user`.`origin`
346                         LEFT JOIN `permissionset` ON `permissionset`.`id` = `post-thread-user`.`psid`
347                         LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-thread-user`.`uid`
348                         LEFT JOIN `contact` AS `parent-post-author` ON `parent-post-author`.`id` = `parent-post`.`author-id`"
349         ],
350         "category-view" => [
351                 "fields" => [
352                         "uri-id" => ["post-category", "uri-id"],
353                         "uid" => ["post-category", "uid"],
354                         "type" => ["post-category", "type"],
355                         "tid" => ["post-category", "tid"],
356                         "name" => ["tag", "name"],
357                         "url" => ["tag", "url"],
358                 ],
359                 "query" => "FROM `post-category`
360                         LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`"
361         ],
362         "tag-view" => [
363                 "fields" => [
364                         "uri-id" => ["post-tag", "uri-id"],
365                         "type" => ["post-tag", "type"],
366                         "tid" => ["post-tag", "tid"],
367                         "cid" => ["post-tag", "cid"],
368                         "name" => "CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END",
369                         "url" => "CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END",
370                 ],
371                 "query" => "FROM `post-tag`
372                         LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
373                         LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`"
374         ],
375         "network-item-view" => [
376                 "fields" => [
377                         "uri-id" => ["post-user", "uri-id"],
378                         "parent" => ["parent-post", "id"],
379                         "received" => ["post-user", "received"],
380                         "commented" => ["post-thread-user", "commented"],
381                         "created" => ["post-user", "created"],
382                         "uid" => ["post-user", "uid"],
383                         "starred" => ["post-thread-user", "starred"],
384                         "mention" => ["post-thread-user", "mention"],
385                         "network" => ["post-user", "network"],
386                         "unseen" => ["post-user", "unseen"],
387                         "gravity" => ["post-user", "gravity"],
388                         "contact-id" => ["post-user", "contact-id"],
389                         "contact-type" => ["ownercontact", "contact-type"],
390                 ],
391                 "query" => "FROM `post-user`
392                         STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`                  
393                         INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
394                         LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
395                         LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
396                         INNER JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
397                         LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
398                         WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
399                         AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
400                         AND (`post-user`.`hidden` IS NULL OR NOT `post-user`.`hidden`)
401                         AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
402                         AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
403         ],
404         "network-thread-view" => [
405                 "fields" => [
406                         "uri-id" => ["post-thread-user", "uri-id"],
407                         "parent" => ["parent-post", "id"],
408                         "received" => ["post-thread-user", "received"],
409                         "commented" => ["post-thread-user", "commented"],
410                         "created" => ["post-thread-user", "created"],
411                         "uid" => ["post-thread-user", "uid"],
412                         "starred" => ["post-thread-user", "starred"],
413                         "mention" => ["post-thread-user", "mention"],
414                         "network" => ["post-thread-user", "network"],
415                         "contact-id" => ["post-thread-user", "contact-id"],
416                         "contact-type" => ["ownercontact", "contact-type"],
417                 ],
418                 "query" => "FROM `post-thread-user`
419                         INNER JOIN `post-user` ON `post-user`.`id` = `post-thread-user`.`post-user-id`
420                         STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
421                         LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
422                         LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`
423                         LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `post-thread-user`.`owner-id`
424                         LEFT JOIN `post-user` AS `parent-post` ON `parent-post`.`uri-id` = `post-user`.`parent-uri-id` AND `parent-post`.`uid` = `post-user`.`uid`
425                         WHERE `post-user`.`visible` AND NOT `post-user`.`deleted`
426                         AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
427                         AND (`post-thread-user`.`hidden` IS NULL OR NOT `post-thread-user`.`hidden`)
428                         AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
429                         AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
430         ],
431         "owner-view" => [
432                 "fields" => [
433                         "id" => ["contact", "id"],
434                         "uid" => ["contact", "uid"],
435                         "created" => ["contact", "created"],
436                         "updated" => ["contact", "updated"],
437                         "self" => ["contact", "self"],
438                         "remote_self" => ["contact", "remote_self"],
439                         "rel" => ["contact", "rel"],
440                         "duplex" => ["contact", "duplex"],
441                         "network" => ["contact", "network"],
442                         "protocol" => ["contact", "protocol"],
443                         "name" => ["contact", "name"],
444                         "nick" => ["contact", "nick"],
445                         "location" => ["contact", "location"],
446                         "about" => ["contact", "about"],
447                         "keywords" => ["contact", "keywords"],
448                         "gender" => ["contact", "gender"],
449                         "xmpp" => ["contact", "xmpp"],
450                         "attag" => ["contact", "attag"],
451                         "avatar" => ["contact", "avatar"],
452                         "photo" => ["contact", "photo"],
453                         "thumb" => ["contact", "thumb"],
454                         "micro" => ["contact", "micro"],
455                         "site-pubkey" => ["contact", "site-pubkey"],
456                         "issued-id" => ["contact", "issued-id"],
457                         "dfrn-id" => ["contact", "dfrn-id"],
458                         "url" => ["contact", "url"],
459                         "nurl" => ["contact", "nurl"],
460                         "addr" => ["contact", "addr"],
461                         "alias" => ["contact", "alias"],
462                         "pubkey" => ["contact", "pubkey"],
463                         "prvkey" => ["contact", "prvkey"],
464                         "batch" => ["contact", "batch"],
465                         "request" => ["contact", "request"],
466                         "notify" => ["contact", "notify"],
467                         "poll" => ["contact", "poll"],
468                         "confirm" => ["contact", "confirm"],
469                         "poco" => ["contact", "poco"],
470                         "aes_allow" => ["contact", "aes_allow"],
471                         "ret-aes" => ["contact", "ret-aes"],
472                         "usehub" => ["contact", "usehub"],
473                         "subhub" => ["contact", "subhub"],
474                         "hub-verify" => ["contact", "hub-verify"],
475                         "last-update" => ["contact", "last-update"],
476                         "success_update" => ["contact", "success_update"],
477                         "failure_update" => ["contact", "failure_update"],
478                         "name-date" => ["contact", "name-date"],
479                         "uri-date" => ["contact", "uri-date"],
480                         "avatar-date" => ["contact", "avatar-date"],
481                         "picdate" => ["contact", "avatar-date"], /// @todo Replaces all uses of "picdate" with "avatar-date"
482                         "term-date" => ["contact", "term-date"],
483                         "last-item" => ["contact", "last-item"],
484                         "priority" => ["contact", "priority"],
485                         "blocked" => ["user", "blocked"],
486                         "block_reason" => ["contact", "block_reason"],
487                         "readonly" => ["contact", "readonly"],
488                         "writable" => ["contact", "writable"],
489                         "forum" => ["contact", "forum"],
490                         "prv" => ["contact", "prv"],
491                         "contact-type" => ["contact", "contact-type"],
492                         "manually-approve" => ["contact", "manually-approve"],
493                         "hidden" => ["contact", "hidden"],
494                         "archive" => ["contact", "archive"],
495                         "pending" => ["contact", "pending"],
496                         "deleted" => ["contact", "deleted"],
497                         "unsearchable" => ["contact", "unsearchable"],
498                         "sensitive" => ["contact", "sensitive"],
499                         "baseurl" => ["contact", "baseurl"],
500                         "reason" => ["contact", "reason"],
501                         "closeness" => ["contact", "closeness"],
502                         "info" => ["contact", "info"],
503                         "profile-id" => ["contact", "profile-id"],
504                         "bdyear" => ["contact", "bdyear"],
505                         "bd" => ["contact", "bd"],
506                         "notify_new_posts" => ["contact", "notify_new_posts"],
507                         "fetch_further_information" => ["contact", "fetch_further_information"],
508                         "ffi_keyword_denylist" => ["contact", "ffi_keyword_denylist"],
509                         "parent-uid" => ["user", "parent-uid"],
510                         "guid" => ["user", "guid"],
511                         "nickname" => ["user", "nickname"], /// @todo Replaces all uses of "nickname" with "nick"
512                         "email" => ["user", "email"],
513                         "openid" => ["user", "openid"],
514                         "timezone" => ["user", "timezone"],
515                         "language" => ["user", "language"],
516                         "register_date" => ["user", "register_date"],
517                         "login_date" => ["user", "login_date"],
518                         "default-location" => ["user", "default-location"],
519                         "allow_location" => ["user", "allow_location"],
520                         "theme" => ["user", "theme"],
521                         "upubkey" => ["user", "pubkey"],
522                         "uprvkey" => ["user", "prvkey"],
523                         "sprvkey" => ["user", "sprvkey"],
524                         "spubkey" => ["user", "spubkey"],
525                         "verified" => ["user", "verified"],
526                         "blockwall" => ["user", "blockwall"],
527                         "hidewall" => ["user", "hidewall"],
528                         "blocktags" => ["user", "blocktags"],
529                         "unkmail" => ["user", "unkmail"],
530                         "cntunkmail" => ["user", "cntunkmail"],
531                         "notify-flags" => ["user", "notify-flags"],
532                         "page-flags" => ["user", "page-flags"],
533                         "account-type" => ["user", "account-type"],
534                         "prvnets" => ["user", "prvnets"],
535                         "maxreq" => ["user", "maxreq"],
536                         "expire" => ["user", "expire"],
537                         "account_removed" => ["user", "account_removed"],
538                         "account_expired" => ["user", "account_expired"],
539                         "account_expires_on" => ["user", "account_expires_on"],
540                         "expire_notification_sent" => ["user", "expire_notification_sent"],
541                         "def_gid" => ["user", "def_gid"],
542                         "allow_cid" => ["user", "allow_cid"],
543                         "allow_gid" => ["user", "allow_gid"],
544                         "deny_cid" => ["user", "deny_cid"],
545                         "deny_gid" => ["user", "deny_gid"],
546                         "openidserver" => ["user", "openidserver"],
547                         "publish" => ["profile", "publish"],
548                         "net-publish" => ["profile", "net-publish"],
549                         "hide-friends" => ["profile", "hide-friends"],
550                         "prv_keywords" => ["profile", "prv_keywords"],
551                         "pub_keywords" => ["profile", "pub_keywords"],
552                         "address" => ["profile", "address"],
553                         "locality" => ["profile", "locality"],
554                         "region" => ["profile", "region"],
555                         "postal-code" => ["profile", "postal-code"],
556                         "country-name" => ["profile", "country-name"],
557                         "homepage" => ["profile", "homepage"],
558                         "dob" => ["profile", "dob"],
559                 ],
560                 "query" => "FROM `user`
561                         INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
562                         INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`"
563         ],
564         "pending-view" => [
565                 "fields" => [
566                         "id" => ["register", "id"],
567                         "hash" => ["register", "hash"],
568                         "created" => ["register", "created"],
569                         "uid" => ["register", "uid"],
570                         "password" => ["register", "password"],
571                         "language" => ["register", "language"],
572                         "note" => ["register", "note"],
573                         "self" => ["contact", "self"],
574                         "name" => ["contact", "name"],
575                         "url" => ["contact", "url"],
576                         "micro" => ["contact", "micro"],
577                         "email" => ["user", "email"],
578                         "nick" => ["contact", "nick"],
579                 ],
580                 "query" => "FROM `register`
581                         INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
582                         INNER JOIN `user` ON `register`.`uid` = `user`.`uid`"
583         ],
584         "tag-search-view" => [
585                 "fields" => [
586                         "uri-id" => ["post-tag", "uri-id"],
587                         "uid" => ["post-user", "uid"],
588                         "iid" => ["post-user", "id"],
589                         "private" => ["post-user", "private"],
590                         "wall" => ["post-user", "wall"],
591                         "origin" => ["post-user", "origin"],
592                         "gravity" => ["post-user", "gravity"],
593                         "received" => ["post-user", "received"],
594                         "name" => ["tag", "name"],
595                 ],
596                 "query" => "FROM `post-tag`
597                         INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
598                         STRAIGHT_JOIN `post-user` ON `post-user`.`uri-id` = `post-tag`.`uri-id`
599                         WHERE `post-tag`.`type` = 1"
600         ],
601         "workerqueue-view" => [
602                 "fields" => [
603                         "pid" => ["process", "pid"],
604                         "priority" => ["workerqueue", "priority"],
605                 ],
606                 "query" => "FROM `process`
607                         INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
608                         WHERE NOT `workerqueue`.`done`"
609         ],
610 ];
611