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