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