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