3 * @copyright Copyright (C) 2020, Friendica
5 * @license GNU AGPL version 3 or any later version
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.
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.
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/>.
20 * Main view structure configuration file.
22 * Here are described all the view Friendica needs to work.
24 * Syntax (braces indicate optionale values):
27 * "<field name>" => ["table", "field"],
28 * "<field name>" => "SQL expression",
31 * "query" => "FROM `table` INNER JOIN `other-table` ..."
35 * If you need to make any change, make sure to increment the DB_UPDATE_VERSION constant value in dbstructure.config.php.
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"],
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`"
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",
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`"
71 "network-item-view" => [
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 "contact-type" => ["ownercontact", "contact-type"],
88 "query" => "FROM `item`
89 INNER JOIN `thread` ON `thread`.`iid` = `item`.`parent`
90 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
91 LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
92 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
93 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
94 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
95 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
96 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
97 AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
98 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
99 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
101 "network-thread-view" => [
103 "uri-id" => ["item", "uri-id"],
104 "uri" => ["item", "uri"],
105 "parent-uri-id" => ["item", "parent-uri-id"],
106 "parent" => ["thread", "iid"],
107 "received" => ["thread", "received"],
108 "commented" => ["thread", "commented"],
109 "created" => ["thread", "created"],
110 "uid" => ["thread", "uid"],
111 "starred" => ["thread", "starred"],
112 "mention" => ["thread", "mention"],
113 "network" => ["thread", "network"],
114 "contact-id" => ["thread", "contact-id"],
115 "contact-type" => ["ownercontact", "contact-type"],
117 "query" => "FROM `thread`
118 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
119 STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
120 LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
121 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
122 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
123 LEFT JOIN `contact` AS `ownercontact` ON `ownercontact`.`id` = `thread`.`owner-id`
124 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
125 AND (NOT `contact`.`readonly` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`)
126 AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
127 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
128 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
132 "id" => ["contact", "id"],
133 "uid" => ["contact", "uid"],
134 "created" => ["contact", "created"],
135 "updated" => ["contact", "updated"],
136 "self" => ["contact", "self"],
137 "remote_self" => ["contact", "remote_self"],
138 "rel" => ["contact", "rel"],
139 "duplex" => ["contact", "duplex"],
140 "network" => ["contact", "network"],
141 "protocol" => ["contact", "protocol"],
142 "name" => ["contact", "name"],
143 "nick" => ["contact", "nick"],
144 "location" => ["contact", "location"],
145 "about" => ["contact", "about"],
146 "keywords" => ["contact", "keywords"],
147 "gender" => ["contact", "gender"],
148 "xmpp" => ["contact", "xmpp"],
149 "attag" => ["contact", "attag"],
150 "avatar" => ["contact", "avatar"],
151 "photo" => ["contact", "photo"],
152 "thumb" => ["contact", "thumb"],
153 "micro" => ["contact", "micro"],
154 "site-pubkey" => ["contact", "site-pubkey"],
155 "issued-id" => ["contact", "issued-id"],
156 "dfrn-id" => ["contact", "dfrn-id"],
157 "url" => ["contact", "url"],
158 "nurl" => ["contact", "nurl"],
159 "addr" => ["contact", "addr"],
160 "alias" => ["contact", "alias"],
161 "pubkey" => ["contact", "pubkey"],
162 "prvkey" => ["contact", "prvkey"],
163 "batch" => ["contact", "batch"],
164 "request" => ["contact", "request"],
165 "notify" => ["contact", "notify"],
166 "poll" => ["contact", "poll"],
167 "confirm" => ["contact", "confirm"],
168 "poco" => ["contact", "poco"],
169 "aes_allow" => ["contact", "aes_allow"],
170 "ret-aes" => ["contact", "ret-aes"],
171 "usehub" => ["contact", "usehub"],
172 "subhub" => ["contact", "subhub"],
173 "hub-verify" => ["contact", "hub-verify"],
174 "last-update" => ["contact", "last-update"],
175 "success_update" => ["contact", "success_update"],
176 "failure_update" => ["contact", "failure_update"],
177 "name-date" => ["contact", "name-date"],
178 "uri-date" => ["contact", "uri-date"],
179 "avatar-date" => ["contact", "avatar-date"],
180 "picdate" => ["contact", "avatar-date"], /// @todo Replaces all uses of "picdate" with "avatar-date"
181 "term-date" => ["contact", "term-date"],
182 "last-item" => ["contact", "last-item"],
183 "priority" => ["contact", "priority"],
184 "blocked" => ["user", "blocked"],
185 "block_reason" => ["contact", "block_reason"],
186 "readonly" => ["contact", "readonly"],
187 "writable" => ["contact", "writable"],
188 "forum" => ["contact", "forum"],
189 "prv" => ["contact", "prv"],
190 "contact-type" => ["contact", "contact-type"],
191 "manually-approve" => ["contact", "manually-approve"],
192 "hidden" => ["contact", "hidden"],
193 "archive" => ["contact", "archive"],
194 "pending" => ["contact", "pending"],
195 "deleted" => ["contact", "deleted"],
196 "unsearchable" => ["contact", "unsearchable"],
197 "sensitive" => ["contact", "sensitive"],
198 "baseurl" => ["contact", "baseurl"],
199 "reason" => ["contact", "reason"],
200 "closeness" => ["contact", "closeness"],
201 "info" => ["contact", "info"],
202 "profile-id" => ["contact", "profile-id"],
203 "bdyear" => ["contact", "bdyear"],
204 "bd" => ["contact", "bd"],
205 "notify_new_posts" => ["contact", "notify_new_posts"],
206 "fetch_further_information" => ["contact", "fetch_further_information"],
207 "ffi_keyword_denylist" => ["contact", "ffi_keyword_denylist"],
208 "parent-uid" => ["user", "parent-uid"],
209 "guid" => ["user", "guid"],
210 "nickname" => ["user", "nickname"], /// @todo Replaces all uses of "nickname" with "nick"
211 "email" => ["user", "email"],
212 "openid" => ["user", "openid"],
213 "timezone" => ["user", "timezone"],
214 "language" => ["user", "language"],
215 "register_date" => ["user", "register_date"],
216 "login_date" => ["user", "login_date"],
217 "default-location" => ["user", "default-location"],
218 "allow_location" => ["user", "allow_location"],
219 "theme" => ["user", "theme"],
220 "upubkey" => ["user", "pubkey"],
221 "uprvkey" => ["user", "prvkey"],
222 "sprvkey" => ["user", "sprvkey"],
223 "spubkey" => ["user", "spubkey"],
224 "verified" => ["user", "verified"],
225 "blockwall" => ["user", "blockwall"],
226 "hidewall" => ["user", "hidewall"],
227 "blocktags" => ["user", "blocktags"],
228 "unkmail" => ["user", "unkmail"],
229 "cntunkmail" => ["user", "cntunkmail"],
230 "notify-flags" => ["user", "notify-flags"],
231 "page-flags" => ["user", "page-flags"],
232 "account-type" => ["user", "account-type"],
233 "prvnets" => ["user", "prvnets"],
234 "maxreq" => ["user", "maxreq"],
235 "expire" => ["user", "expire"],
236 "account_removed" => ["user", "account_removed"],
237 "account_expired" => ["user", "account_expired"],
238 "account_expires_on" => ["user", "account_expires_on"],
239 "expire_notification_sent" => ["user", "expire_notification_sent"],
240 "def_gid" => ["user", "def_gid"],
241 "allow_cid" => ["user", "allow_cid"],
242 "allow_gid" => ["user", "allow_gid"],
243 "deny_cid" => ["user", "deny_cid"],
244 "deny_gid" => ["user", "deny_gid"],
245 "openidserver" => ["user", "openidserver"],
246 "publish" => ["profile", "publish"],
247 "net-publish" => ["profile", "net-publish"],
248 "hide-friends" => ["profile", "hide-friends"],
249 "prv_keywords" => ["profile", "prv_keywords"],
250 "pub_keywords" => ["profile", "pub_keywords"],
251 "address" => ["profile", "address"],
252 "locality" => ["profile", "locality"],
253 "region" => ["profile", "region"],
254 "postal-code" => ["profile", "postal-code"],
255 "country-name" => ["profile", "country-name"],
256 "homepage" => ["profile", "homepage"],
257 "dob" => ["profile", "dob"],
259 "query" => "FROM `user`
260 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
261 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`"
265 "id" => ["register", "id"],
266 "hash" => ["register", "hash"],
267 "created" => ["register", "created"],
268 "uid" => ["register", "uid"],
269 "password" => ["register", "password"],
270 "language" => ["register", "language"],
271 "note" => ["register", "note"],
272 "self" => ["contact", "self"],
273 "name" => ["contact", "name"],
274 "url" => ["contact", "url"],
275 "micro" => ["contact", "micro"],
276 "email" => ["user", "email"],
277 "nick" => ["contact", "nick"],
279 "query" => "FROM `register`
280 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
281 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`"
283 "tag-search-view" => [
285 "uri-id" => ["post-tag", "uri-id"],
286 "iid" => ["item", "id"],
287 "uri" => ["item", "uri"],
288 "guid" => ["item", "guid"],
289 "uid" => ["item", "uid"],
290 "private" => ["item", "private"],
291 "wall" => ["item", "wall"],
292 "origin" => ["item", "origin"],
293 "gravity" => ["item", "gravity"],
294 "received" => ["item", "received"],
295 "name" => ["tag", "name"],
297 "query" => "FROM `post-tag`
298 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
299 INNER JOIN `item` ON `item`.`uri-id` = `post-tag`.`uri-id`
300 WHERE `post-tag`.`type` = 1"
302 "workerqueue-view" => [
304 "pid" => ["process", "pid"],
305 "priority" => ["workerqueue", "priority"],
307 "query" => "FROM `process`
308 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
309 WHERE NOT `workerqueue`.`done`"