]> git.mxchange.org Git - friendica.git/blob - static/dbview.config.php
fa302b8669f27d0d31dae5ac3dac9714547d70a4
[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         "owner-view" => [
72                 "fields" => [
73                         "id" => ["contact", "id"],
74                         "uid" => ["contact", "uid"],
75                         "created" => ["contact", "created"],
76                         "updated" => ["contact", "updated"],
77                         "self" => ["contact", "self"],
78                         "remote_self" => ["contact", "remote_self"],
79                         "rel" => ["contact", "rel"],
80                         "duplex" => ["contact", "duplex"],
81                         "network" => ["contact", "network"],
82                         "protocol" => ["contact", "protocol"],
83                         "name" => ["contact", "name"],
84                         "nick" => ["contact", "nick"],
85                         "location" => ["contact", "location"],
86                         "about" => ["contact", "about"],
87                         "keywords" => ["contact", "keywords"],
88                         "gender" => ["contact", "gender"],
89                         "xmpp" => ["contact", "xmpp"],
90                         "attag" => ["contact", "attag"],
91                         "avatar" => ["contact", "avatar"],
92                         "photo" => ["contact", "photo"],
93                         "thumb" => ["contact", "thumb"],
94                         "micro" => ["contact", "micro"],
95                         "site-pubkey" => ["contact", "site-pubkey"],
96                         "issued-id" => ["contact", "issued-id"],
97                         "dfrn-id" => ["contact", "dfrn-id"],
98                         "url" => ["contact", "url"],
99                         "nurl" => ["contact", "nurl"],
100                         "addr" => ["contact", "addr"],
101                         "alias" => ["contact", "alias"],
102                         "pubkey" => ["contact", "pubkey"],
103                         "prvkey" => ["contact", "prvkey"],
104                         "batch" => ["contact", "batch"],
105                         "request" => ["contact", "request"],
106                         "notify" => ["contact", "notify"],
107                         "poll" => ["contact", "poll"],
108                         "confirm" => ["contact", "confirm"],
109                         "poco" => ["contact", "poco"],
110                         "aes_allow" => ["contact", "aes_allow"],
111                         "ret-aes" => ["contact", "ret-aes"],
112                         "usehub" => ["contact", "usehub"],
113                         "subhub" => ["contact", "subhub"],
114                         "hub-verify" => ["contact", "hub-verify"],
115                         "last-update" => ["contact", "last-update"],
116                         "success_update" => ["contact", "success_update"],
117                         "failure_update" => ["contact", "failure_update"],
118                         "name-date" => ["contact", "name-date"],
119                         "uri-date" => ["contact", "uri-date"],
120                         "avatar-date" => ["contact", "avatar-date"],
121                         "picdate" => ["contact", "avatar-date"], /// @todo Replaces all uses of "picdate" with "avatar-date"
122                         "term-date" => ["contact", "term-date"],
123                         "last-item" => ["contact", "last-item"],
124                         "priority" => ["contact", "priority"],
125                         "blocked" => ["contact", "blocked"], /// @todo Check if "blocked" from contact or from the users table
126                         "block_reason" => ["contact", "block_reason"],
127                         "readonly" => ["contact", "readonly"],
128                         "writable" => ["contact", "writable"],
129                         "forum" => ["contact", "forum"],
130                         "prv" => ["contact", "prv"],
131                         "contact-type" => ["contact", "contact-type"],
132                         "hidden" => ["contact", "hidden"],
133                         "archive" => ["contact", "archive"],
134                         "pending" => ["contact", "pending"],
135                         "deleted" => ["contact", "deleted"],
136                         "rating" => ["contact", "rating"],
137                         "unsearchable" => ["contact", "unsearchable"],
138                         "sensitive" => ["contact", "sensitive"],
139                         "baseurl" => ["contact", "baseurl"],
140                         "reason" => ["contact", "reason"],
141                         "closeness" => ["contact", "closeness"],
142                         "info" => ["contact", "info"],
143                         "profile-id" => ["contact", "profile-id"],
144                         "bdyear" => ["contact", "bdyear"],
145                         "bd" => ["contact", "bd"],
146                         "notify_new_posts" => ["contact", "notify_new_posts"],
147                         "fetch_further_information" => ["contact", "fetch_further_information"],
148                         "ffi_keyword_blacklist" => ["contact", "ffi_keyword_blacklist"],
149                         "parent-uid" => ["user", "parent-uid"],
150                         "guid" => ["user", "guid"],
151                         "nickname" => ["user", "nickname"], /// @todo Replaces all uses of "nickname" with "nick"
152                         "email" => ["user", "email"],
153                         "openid" => ["user", "openid"],
154                         "timezone" => ["user", "timezone"],
155                         "language" => ["user", "language"],
156                         "register_date" => ["user", "register_date"],
157                         "login_date" => ["user", "login_date"],
158                         "default-location" => ["user", "default-location"],
159                         "allow_location" => ["user", "allow_location"],
160                         "theme" => ["user", "theme"],
161                         "upubkey" => ["user", "pubkey"],
162                         "uprvkey" => ["user", "prvkey"],
163                         "sprvkey" => ["user", "sprvkey"],
164                         "spubkey" => ["user", "spubkey"],
165                         "verified" => ["user", "verified"],
166                         "blockwall" => ["user", "blockwall"],
167                         "hidewall" => ["user", "hidewall"],
168                         "blocktags" => ["user", "blocktags"],
169                         "unkmail" => ["user", "unkmail"],
170                         "cntunkmail" => ["user", "cntunkmail"],
171                         "notify-flags" => ["user", "notify-flags"],
172                         "page-flags" => ["user", "page-flags"],
173                         "account-type" => ["user", "account-type"],
174                         "prvnets" => ["user", "prvnets"],
175                         "maxreq" => ["user", "maxreq"],
176                         "expire" => ["user", "expire"],
177                         "account_removed" => ["user", "account_removed"],
178                         "account_expired" => ["user", "account_expired"],
179                         "account_expires_on" => ["user", "account_expires_on"],
180                         "expire_notification_sent" => ["user", "expire_notification_sent"],                     
181                         "def_gid" => ["user", "def_gid"],
182                         "allow_cid" => ["user", "allow_cid"],
183                         "allow_gid" => ["user", "allow_gid"],
184                         "deny_cid" => ["user", "deny_cid"],
185                         "deny_gid" => ["user", "deny_gid"],
186                         "openidserver" => ["user", "openidserver"],
187                         "publish" => ["profile", "publish"],
188                         "net-publish" => ["profile", "net-publish"],
189                         "hide-friends" => ["profile", "hide-friends"],
190                         "prv_keywords" => ["profile", "prv_keywords"],
191                         "pub_keywords" => ["profile", "pub_keywords"],
192                         "address" => ["profile", "address"],
193                         "locality" => ["profile", "locality"],
194                         "region" => ["profile", "region"],
195                         "postal-code" => ["profile", "postal-code"],
196                         "country-name" => ["profile", "country-name"],
197                         "homepage" => ["profile", "homepage"],
198                         "dob" => ["profile", "dob"],
199                 ],
200                 "query" => "FROM `user`
201                         INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
202                         INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`"
203         ],
204         "participation-view" => [
205                 "fields" => [
206                         "iid" => ["participation", "iid"],
207                         "id" => ["contact", "id"],
208                         "url" => ["contact", "url"],
209                         "name" => ["contact", "name"],
210                         "protocol" => ["contact", "protocol"],
211                         "batch" => "CASE `contact`.`batch` WHEN '' THEN `fcontact`.`batch` ELSE `contact`.`batch` END",
212                         "network" => "CASE `fcontact`.`network` WHEN '' THEN `contact`.`network` ELSE `fcontact`.`network` END",
213                 ],
214                 "query" => "FROM `participation`
215                         INNER JOIN `contact` ON `contact`.`id` = `participation`.`cid` AND NOT `contact`.`archive`
216                         INNER JOIN `fcontact` ON `fcontact`.`id` = `participation`.`fid`"
217         ],
218         "pending-view" => [
219                 "fields" => [
220                         "id" => ["register", "id"],
221                         "hash" => ["register", "hash"],
222                         "created" => ["register", "created"],
223                         "uid" => ["register", "uid"],
224                         "password" => ["register", "password"],
225                         "language" => ["register", "language"],
226                         "note" => ["register", "note"],
227                         "self" => ["contact", "self"],
228                         "name" => ["contact", "name"],
229                         "url" => ["contact", "url"],
230                         "micro" => ["contact", "micro"],
231                         "email" => ["user", "email"],
232                         "nick" => ["contact", "nick"],
233                 ],
234                 "query" => "FROM `register`
235                         INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
236                         INNER JOIN `user` ON `register`.`uid` = `user`.`uid`"
237         ],
238         "tag-search-view" => [
239                 "fields" => [
240                         "uri-id" => ["post-tag", "uri-id"],
241                         "iid" => ["item", "id"],
242                         "uri" => ["item", "uri"],
243                         "guid" => ["item", "guid"],
244                         "uid" => ["item", "uid"],
245                         "private" => ["item", "private"],
246                         "wall" => ["item", "wall"],
247                         "origin" => ["item", "origin"],
248                         "gravity" => ["item", "gravity"],
249                         "received" => ["item", "received"],                     
250                         "name" => ["tag", "name"],
251                 ],
252                 "query" => "FROM `post-tag`
253                         INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
254                         INNER JOIN `item` ON `item`.`uri-id` = `post-tag`.`uri-id`
255                         WHERE `post-tag`.`type` = 1"
256         ],
257         "workerqueue-view" => [
258                 "fields" => [
259                         "pid" => ["process", "pid"],
260                         "priority" => ["workerqueue", "priority"],
261                 ],
262                 "query" => "FROM `process`
263                         INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
264                         WHERE NOT `workerqueue`.`done`"
265         ],
266 ];
267