]> git.mxchange.org Git - friendica.git/blob - static/dbview.config.php
cd835ddfae22ecc98cdaf4be93fb93d90b554c06
[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         "item-view" => [
41                 "fields" => [
42                         "id" => ["item", "id"], 
43                         "item_id" => ["item", "id"], 
44                         "uid" => ["item", "uid"], 
45                         "parent" => ["item", "parent"], 
46                         "uri" => ["item", "uri"], 
47                         "parent-uri" => ["item", "parent-uri"], 
48                         "thr-parent" => ["item", "thr-parent"],
49                         "guid" => ["item", "guid"], 
50                         "uri-id" => ["item", "uri-id"], 
51                         "parent-uri-id" => ["item", "parent-uri-id"], 
52                         "thr-parent-id" => ["item", "thr-parent-id"],
53                         "contact-id" => ["item", "contact-id"], 
54                         "type" => ["item", "type"], 
55                         "wall" => ["item", "wall"], 
56                         "gravity" => ["item", "gravity"], 
57                         "extid" => ["item", "extid"], 
58                         "iaid" => ["item", "iaid"],
59                         "icid" => ["item", "icid"],
60                         "psid" => ["item", "psid"],
61                         "created" => ["item", "created"], 
62                         "edited" => ["item", "edited"], 
63                         "commented" => ["item", "commented"], 
64                         "received" => ["item", "received"], 
65                         "changed" => ["item", "changed"], 
66                         "verb" => ["item-content", "verb"], 
67                         "plink" => ["item-content", "plink"], 
68                         "language" => ["item-content", "language"],
69                         "resource-id" => ["item", "resource-id"], 
70                         "event-id" => ["item", "event-id"], 
71                         "attach" => ["item", "attach"], 
72                         "postopts" => ["post-delivery-data", "postopts"], 
73                         "inform" => ["post-delivery-data", "inform"], 
74                         "file" => "NULL", 
75                         "allow_cid" => ["permissionset", "allow_cid"], 
76                         "allow_gid" => ["permissionset", "allow_gid"], 
77                         "deny_cid" => ["permissionset", "deny_cid"], 
78                         "deny_gid" => ["permissionset", "deny_gid"], 
79                         "post-type" => ["item", "post-type"], 
80                         "private" => ["item", "private"], 
81                         "pubmail" => ["item", "pubmail"], 
82                         "moderated" => ["item", "moderated"], 
83                         "visible" => ["item", "visible"], 
84                         "starred" => ["item", "starred"], 
85                         "bookmark" => ["thread", "bookmark"], 
86                         "unseen" => ["item", "unseen"], 
87                         "deleted" => ["item", "deleted"], 
88                         "origin" => ["item", "origin"], 
89                         "forum_mode" => ["item", "forum_mode"], 
90                         "mention" => ["item", "mention"], 
91                         "global" => ["item", "global"], 
92                         "network" => ["item", "network"], 
93                         "title" => ["item-content", "title"], 
94                         "content-warning" => ["item-content", "content-warning"], 
95                         "body" => ["item-content", "body"], 
96                         "location" => ["item-content", "location"], 
97                         "coord" => ["item-content", "coord"], 
98                         "app" => ["item-content", "app"], 
99                         "rendered-hash" => ["item-content", "rendered-hash"], 
100                         "rendered-html" => ["item-content", "rendered-html"], 
101                         "object-type" => ["item-content", "object-type"], 
102                         "object" => ["item-content", "object"], 
103                         "target-type" => ["item-content", "target-type"], 
104                         "target" => ["item-content", "target"], 
105                         "author-id" => ["item", "author-id"], 
106                         "author-link" => ["author", "url"], 
107                         "author-name" => ["author", "name"], 
108                         "author-avatar" => ["author", "thumb"], 
109                         "author-network" => ["author", "network"], 
110                         "owner-id" => ["item", "owner-id"], 
111                         "owner-link" => ["owner", "url"], 
112                         "owner-addr" => ["owner", "addr"], 
113                         "owner-avatar"  => ["owner", "thumb"],
114                         "owner-nick" => ["owner", "nick"], 
115                         "owner-name" => ["owner", "name"], 
116                         "owner-network" => ["owner", "network"],
117                         "contact-uid" => ["contact", "uid"],
118                         "parent-guid" => ["parent-item", "guid"],
119                         "parent-network" => ["parent-item", "network"],
120                         "signed_text" => ["diaspora-interaction", "interaction"],
121                         "signature" => "NULL",
122                         "signer" => "NULL"
123                 ],
124                 "query" => "FROM `item`
125                         LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
126                         LEFT JOIN `contact` AS `author` ON `author`.`id` = `item`.`author-id`
127                         LEFT JOIN `contact` AS `owner` ON `owner`.`id` = `item`.`owner-id`
128                         LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `item`.`uri-id`
129                         LEFT JOIN `item-activity` ON `item-activity`.`uri-id` = `item`.`uri-id`
130                         LEFT JOIN `item-content` ON `item-content`.`uri-id` = `item`.`uri-id`
131                         LEFT JOIN `post-delivery-data` ON `post-delivery-data`.`uri-id` = `item`.`uri-id` AND `item`.`origin`
132                         LEFT JOIN `permissionset` ON `permissionset`.`id` = `item`.`psid`
133                         LEFT JOIN `thread` ON `thread`.`iid` = `item`.`parent`
134                         STRAIGHT_JOIN `item` AS `parent-item` ON `parent-item`.`id` = `item`.`parent`"
135         ],
136         "category-view" => [
137                 "fields" => [
138                         "uri-id" => ["post-category", "uri-id"],
139                         "uid" => ["post-category", "uid"],
140                         "uri" => ["item-uri", "uri"],
141                         "guid" => ["item-uri", "guid"],
142                         "type" => ["post-category", "type"],
143                         "tid" => ["post-category", "tid"],
144                         "name" => ["tag", "name"],
145                         "url" => ["tag", "url"],
146                 ],
147                 "query" => "FROM `post-category`
148                         INNER JOIN `item-uri` ON `item-uri`.id = `post-category`.`uri-id`
149                         LEFT JOIN `tag` ON `post-category`.`tid` = `tag`.`id`"
150         ],
151         "tag-view" => [
152                 "fields" => [
153                         "uri-id" => ["post-tag", "uri-id"],
154                         "uri" => ["item-uri", "uri"],
155                         "guid" => ["item-uri", "guid"],
156                         "type" => ["post-tag", "type"],
157                         "tid" => ["post-tag", "tid"],
158                         "cid" => ["post-tag", "cid"],
159                         "name" => "CASE `cid` WHEN 0 THEN `tag`.`name` ELSE `contact`.`name` END",
160                         "url" => "CASE `cid` WHEN 0 THEN `tag`.`url` ELSE `contact`.`url` END",
161                 ],
162                 "query" => "FROM `post-tag`
163                         INNER JOIN `item-uri` ON `item-uri`.id = `post-tag`.`uri-id`
164                         LEFT JOIN `tag` ON `post-tag`.`tid` = `tag`.`id`
165                         LEFT JOIN `contact` ON `post-tag`.`cid` = `contact`.`id`"
166         ],
167         "network-item-view" => [
168                 "fields" => [
169                         "uri-id" => ["item", "parent-uri-id"],
170                         "uri" => ["item", "parent-uri"],
171                         "parent" => ["item", "parent"],
172                         "received" => ["item", "received"],
173                         "commented" => ["item", "commented"],
174                         "created" => ["item", "created"],
175                         "uid" => ["item", "uid"],
176                         "starred" => ["item", "starred"],
177                         "mention" => ["item", "mention"],
178                         "network" => ["item", "network"],
179                         "unseen" => ["item", "unseen"],
180                         "gravity" => ["item", "gravity"],
181                         "contact-id" => ["item", "contact-id"],
182                         "contact-type" => ["ownercontact", "contact-type"],
183                 ],
184                 "query" => "FROM `item`
185                         INNER JOIN `thread` ON `thread`.`iid` = `item`.`parent`
186                         STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
187                         LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
188                         LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
189                         LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
190                         LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
191                         WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
192                         AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
193                         AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
194                         AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
195                         AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
196         ],
197         "network-thread-view" => [
198                 "fields" => [
199                         "uri-id" => ["item", "uri-id"],
200                         "uri" => ["item", "uri"],
201                         "parent-uri-id" => ["item", "parent-uri-id"],
202                         "parent" => ["thread", "iid"],
203                         "received" => ["thread", "received"],
204                         "commented" => ["thread", "commented"],
205                         "created" => ["thread", "created"],
206                         "uid" => ["thread", "uid"],
207                         "starred" => ["thread", "starred"],
208                         "mention" => ["thread", "mention"],
209                         "network" => ["thread", "network"],
210                         "contact-id" => ["thread", "contact-id"],
211                         "contact-type" => ["ownercontact", "contact-type"],
212                 ],
213                 "query" => "FROM `thread`
214                         STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
215                         STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
216                         LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
217                         LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
218                         LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
219                         LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
220                         WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
221                         AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
222                         AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
223                         AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
224                         AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
225         ],
226         "owner-view" => [
227                 "fields" => [
228                         "id" => ["contact", "id"],
229                         "uid" => ["contact", "uid"],
230                         "created" => ["contact", "created"],
231                         "updated" => ["contact", "updated"],
232                         "self" => ["contact", "self"],
233                         "remote_self" => ["contact", "remote_self"],
234                         "rel" => ["contact", "rel"],
235                         "duplex" => ["contact", "duplex"],
236                         "network" => ["contact", "network"],
237                         "protocol" => ["contact", "protocol"],
238                         "name" => ["contact", "name"],
239                         "nick" => ["contact", "nick"],
240                         "location" => ["contact", "location"],
241                         "about" => ["contact", "about"],
242                         "keywords" => ["contact", "keywords"],
243                         "gender" => ["contact", "gender"],
244                         "xmpp" => ["contact", "xmpp"],
245                         "attag" => ["contact", "attag"],
246                         "avatar" => ["contact", "avatar"],
247                         "photo" => ["contact", "photo"],
248                         "thumb" => ["contact", "thumb"],
249                         "micro" => ["contact", "micro"],
250                         "site-pubkey" => ["contact", "site-pubkey"],
251                         "issued-id" => ["contact", "issued-id"],
252                         "dfrn-id" => ["contact", "dfrn-id"],
253                         "url" => ["contact", "url"],
254                         "nurl" => ["contact", "nurl"],
255                         "addr" => ["contact", "addr"],
256                         "alias" => ["contact", "alias"],
257                         "pubkey" => ["contact", "pubkey"],
258                         "prvkey" => ["contact", "prvkey"],
259                         "batch" => ["contact", "batch"],
260                         "request" => ["contact", "request"],
261                         "notify" => ["contact", "notify"],
262                         "poll" => ["contact", "poll"],
263                         "confirm" => ["contact", "confirm"],
264                         "poco" => ["contact", "poco"],
265                         "aes_allow" => ["contact", "aes_allow"],
266                         "ret-aes" => ["contact", "ret-aes"],
267                         "usehub" => ["contact", "usehub"],
268                         "subhub" => ["contact", "subhub"],
269                         "hub-verify" => ["contact", "hub-verify"],
270                         "last-update" => ["contact", "last-update"],
271                         "success_update" => ["contact", "success_update"],
272                         "failure_update" => ["contact", "failure_update"],
273                         "name-date" => ["contact", "name-date"],
274                         "uri-date" => ["contact", "uri-date"],
275                         "avatar-date" => ["contact", "avatar-date"],
276                         "picdate" => ["contact", "avatar-date"], /// @todo Replaces all uses of "picdate" with "avatar-date"
277                         "term-date" => ["contact", "term-date"],
278                         "last-item" => ["contact", "last-item"],
279                         "priority" => ["contact", "priority"],
280                         "blocked" => ["user", "blocked"],
281                         "block_reason" => ["contact", "block_reason"],
282                         "readonly" => ["contact", "readonly"],
283                         "writable" => ["contact", "writable"],
284                         "forum" => ["contact", "forum"],
285                         "prv" => ["contact", "prv"],
286                         "contact-type" => ["contact", "contact-type"],
287                         "manually-approve" => ["contact", "manually-approve"],
288                         "hidden" => ["contact", "hidden"],
289                         "archive" => ["contact", "archive"],
290                         "pending" => ["contact", "pending"],
291                         "deleted" => ["contact", "deleted"],
292                         "unsearchable" => ["contact", "unsearchable"],
293                         "sensitive" => ["contact", "sensitive"],
294                         "baseurl" => ["contact", "baseurl"],
295                         "reason" => ["contact", "reason"],
296                         "closeness" => ["contact", "closeness"],
297                         "info" => ["contact", "info"],
298                         "profile-id" => ["contact", "profile-id"],
299                         "bdyear" => ["contact", "bdyear"],
300                         "bd" => ["contact", "bd"],
301                         "notify_new_posts" => ["contact", "notify_new_posts"],
302                         "fetch_further_information" => ["contact", "fetch_further_information"],
303                         "ffi_keyword_denylist" => ["contact", "ffi_keyword_denylist"],
304                         "parent-uid" => ["user", "parent-uid"],
305                         "guid" => ["user", "guid"],
306                         "nickname" => ["user", "nickname"], /// @todo Replaces all uses of "nickname" with "nick"
307                         "email" => ["user", "email"],
308                         "openid" => ["user", "openid"],
309                         "timezone" => ["user", "timezone"],
310                         "language" => ["user", "language"],
311                         "register_date" => ["user", "register_date"],
312                         "login_date" => ["user", "login_date"],
313                         "default-location" => ["user", "default-location"],
314                         "allow_location" => ["user", "allow_location"],
315                         "theme" => ["user", "theme"],
316                         "upubkey" => ["user", "pubkey"],
317                         "uprvkey" => ["user", "prvkey"],
318                         "sprvkey" => ["user", "sprvkey"],
319                         "spubkey" => ["user", "spubkey"],
320                         "verified" => ["user", "verified"],
321                         "blockwall" => ["user", "blockwall"],
322                         "hidewall" => ["user", "hidewall"],
323                         "blocktags" => ["user", "blocktags"],
324                         "unkmail" => ["user", "unkmail"],
325                         "cntunkmail" => ["user", "cntunkmail"],
326                         "notify-flags" => ["user", "notify-flags"],
327                         "page-flags" => ["user", "page-flags"],
328                         "account-type" => ["user", "account-type"],
329                         "prvnets" => ["user", "prvnets"],
330                         "maxreq" => ["user", "maxreq"],
331                         "expire" => ["user", "expire"],
332                         "account_removed" => ["user", "account_removed"],
333                         "account_expired" => ["user", "account_expired"],
334                         "account_expires_on" => ["user", "account_expires_on"],
335                         "expire_notification_sent" => ["user", "expire_notification_sent"],
336                         "def_gid" => ["user", "def_gid"],
337                         "allow_cid" => ["user", "allow_cid"],
338                         "allow_gid" => ["user", "allow_gid"],
339                         "deny_cid" => ["user", "deny_cid"],
340                         "deny_gid" => ["user", "deny_gid"],
341                         "openidserver" => ["user", "openidserver"],
342                         "publish" => ["profile", "publish"],
343                         "net-publish" => ["profile", "net-publish"],
344                         "hide-friends" => ["profile", "hide-friends"],
345                         "prv_keywords" => ["profile", "prv_keywords"],
346                         "pub_keywords" => ["profile", "pub_keywords"],
347                         "address" => ["profile", "address"],
348                         "locality" => ["profile", "locality"],
349                         "region" => ["profile", "region"],
350                         "postal-code" => ["profile", "postal-code"],
351                         "country-name" => ["profile", "country-name"],
352                         "homepage" => ["profile", "homepage"],
353                         "dob" => ["profile", "dob"],
354                 ],
355                 "query" => "FROM `user`
356                         INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
357                         INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`"
358         ],
359         "pending-view" => [
360                 "fields" => [
361                         "id" => ["register", "id"],
362                         "hash" => ["register", "hash"],
363                         "created" => ["register", "created"],
364                         "uid" => ["register", "uid"],
365                         "password" => ["register", "password"],
366                         "language" => ["register", "language"],
367                         "note" => ["register", "note"],
368                         "self" => ["contact", "self"],
369                         "name" => ["contact", "name"],
370                         "url" => ["contact", "url"],
371                         "micro" => ["contact", "micro"],
372                         "email" => ["user", "email"],
373                         "nick" => ["contact", "nick"],
374                 ],
375                 "query" => "FROM `register`
376                         INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
377                         INNER JOIN `user` ON `register`.`uid` = `user`.`uid`"
378         ],
379         "tag-search-view" => [
380                 "fields" => [
381                         "uri-id" => ["post-tag", "uri-id"],
382                         "iid" => ["item", "id"],
383                         "uri" => ["item", "uri"],
384                         "guid" => ["item", "guid"],
385                         "uid" => ["item", "uid"],
386                         "private" => ["item", "private"],
387                         "wall" => ["item", "wall"],
388                         "origin" => ["item", "origin"],
389                         "gravity" => ["item", "gravity"],
390                         "received" => ["item", "received"],                     
391                         "name" => ["tag", "name"],
392                 ],
393                 "query" => "FROM `post-tag`
394                         INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
395                         INNER JOIN `item` ON `item`.`uri-id` = `post-tag`.`uri-id`
396                         WHERE `post-tag`.`type` = 1"
397         ],
398         "workerqueue-view" => [
399                 "fields" => [
400                         "pid" => ["process", "pid"],
401                         "priority" => ["workerqueue", "priority"],
402                 ],
403                 "query" => "FROM `process`
404                         INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
405                         WHERE NOT `workerqueue`.`done`"
406         ],
407 ];
408