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"],
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`)"
99 "network-thread-view" => [
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"],
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`)"
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 "hidden" => ["contact", "hidden"],
188 "archive" => ["contact", "archive"],
189 "pending" => ["contact", "pending"],
190 "deleted" => ["contact", "deleted"],
191 "unsearchable" => ["contact", "unsearchable"],
192 "sensitive" => ["contact", "sensitive"],
193 "baseurl" => ["contact", "baseurl"],
194 "reason" => ["contact", "reason"],
195 "closeness" => ["contact", "closeness"],
196 "info" => ["contact", "info"],
197 "profile-id" => ["contact", "profile-id"],
198 "bdyear" => ["contact", "bdyear"],
199 "bd" => ["contact", "bd"],
200 "notify_new_posts" => ["contact", "notify_new_posts"],
201 "fetch_further_information" => ["contact", "fetch_further_information"],
202 "ffi_keyword_denylist" => ["contact", "ffi_keyword_denylist"],
203 "parent-uid" => ["user", "parent-uid"],
204 "guid" => ["user", "guid"],
205 "nickname" => ["user", "nickname"], /// @todo Replaces all uses of "nickname" with "nick"
206 "email" => ["user", "email"],
207 "openid" => ["user", "openid"],
208 "timezone" => ["user", "timezone"],
209 "language" => ["user", "language"],
210 "register_date" => ["user", "register_date"],
211 "login_date" => ["user", "login_date"],
212 "default-location" => ["user", "default-location"],
213 "allow_location" => ["user", "allow_location"],
214 "theme" => ["user", "theme"],
215 "upubkey" => ["user", "pubkey"],
216 "uprvkey" => ["user", "prvkey"],
217 "sprvkey" => ["user", "sprvkey"],
218 "spubkey" => ["user", "spubkey"],
219 "verified" => ["user", "verified"],
220 "blockwall" => ["user", "blockwall"],
221 "hidewall" => ["user", "hidewall"],
222 "blocktags" => ["user", "blocktags"],
223 "unkmail" => ["user", "unkmail"],
224 "cntunkmail" => ["user", "cntunkmail"],
225 "notify-flags" => ["user", "notify-flags"],
226 "page-flags" => ["user", "page-flags"],
227 "account-type" => ["user", "account-type"],
228 "prvnets" => ["user", "prvnets"],
229 "maxreq" => ["user", "maxreq"],
230 "expire" => ["user", "expire"],
231 "account_removed" => ["user", "account_removed"],
232 "account_expired" => ["user", "account_expired"],
233 "account_expires_on" => ["user", "account_expires_on"],
234 "expire_notification_sent" => ["user", "expire_notification_sent"],
235 "def_gid" => ["user", "def_gid"],
236 "allow_cid" => ["user", "allow_cid"],
237 "allow_gid" => ["user", "allow_gid"],
238 "deny_cid" => ["user", "deny_cid"],
239 "deny_gid" => ["user", "deny_gid"],
240 "openidserver" => ["user", "openidserver"],
241 "publish" => ["profile", "publish"],
242 "net-publish" => ["profile", "net-publish"],
243 "hide-friends" => ["profile", "hide-friends"],
244 "prv_keywords" => ["profile", "prv_keywords"],
245 "pub_keywords" => ["profile", "pub_keywords"],
246 "address" => ["profile", "address"],
247 "locality" => ["profile", "locality"],
248 "region" => ["profile", "region"],
249 "postal-code" => ["profile", "postal-code"],
250 "country-name" => ["profile", "country-name"],
251 "homepage" => ["profile", "homepage"],
252 "dob" => ["profile", "dob"],
254 "query" => "FROM `user`
255 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
256 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`"
260 "id" => ["register", "id"],
261 "hash" => ["register", "hash"],
262 "created" => ["register", "created"],
263 "uid" => ["register", "uid"],
264 "password" => ["register", "password"],
265 "language" => ["register", "language"],
266 "note" => ["register", "note"],
267 "self" => ["contact", "self"],
268 "name" => ["contact", "name"],
269 "url" => ["contact", "url"],
270 "micro" => ["contact", "micro"],
271 "email" => ["user", "email"],
272 "nick" => ["contact", "nick"],
274 "query" => "FROM `register`
275 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
276 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`"
278 "tag-search-view" => [
280 "uri-id" => ["post-tag", "uri-id"],
281 "iid" => ["item", "id"],
282 "uri" => ["item", "uri"],
283 "guid" => ["item", "guid"],
284 "uid" => ["item", "uid"],
285 "private" => ["item", "private"],
286 "wall" => ["item", "wall"],
287 "origin" => ["item", "origin"],
288 "gravity" => ["item", "gravity"],
289 "received" => ["item", "received"],
290 "name" => ["tag", "name"],
292 "query" => "FROM `post-tag`
293 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
294 INNER JOIN `item` ON `item`.`uri-id` = `post-tag`.`uri-id`
295 WHERE `post-tag`.`type` = 1"
297 "workerqueue-view" => [
299 "pid" => ["process", "pid"],
300 "priority" => ["workerqueue", "priority"],
302 "query" => "FROM `process`
303 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
304 WHERE NOT `workerqueue`.`done`"