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