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