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` AND (NOT `contact`.`blocked` OR `contact`.`pending`)
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 (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
95 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
96 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
98 "network-thread-view" => [
100 "uri-id" => ["item", "uri-id"],
101 "uri" => ["item", "uri"],
102 "parent-uri-id" => ["item", "parent-uri-id"],
103 "parent" => ["thread", "iid"],
104 "received" => ["thread", "received"],
105 "commented" => ["thread", "commented"],
106 "created" => ["thread", "created"],
107 "uid" => ["thread", "uid"],
108 "starred" => ["thread", "starred"],
109 "mention" => ["thread", "mention"],
110 "network" => ["thread", "network"],
111 "contact-id" => ["thread", "contact-id"],
113 "query" => "FROM `thread`
114 STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id` AND (NOT `contact`.`blocked` OR `contact`.`pending`)
115 STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
116 LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = `thread`.`uid`
117 LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `thread`.`uid` AND `author`.`cid` = `thread`.`author-id`
118 LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `thread`.`uid` AND `owner`.`cid` = `thread`.`owner-id`
119 WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
120 AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
121 AND (`author`.`blocked` IS NULL OR NOT `author`.`blocked`)
122 AND (`owner`.`blocked` IS NULL OR NOT `owner`.`blocked`)"
126 "id" => ["contact", "id"],
127 "uid" => ["contact", "uid"],
128 "created" => ["contact", "created"],
129 "updated" => ["contact", "updated"],
130 "self" => ["contact", "self"],
131 "remote_self" => ["contact", "remote_self"],
132 "rel" => ["contact", "rel"],
133 "duplex" => ["contact", "duplex"],
134 "network" => ["contact", "network"],
135 "protocol" => ["contact", "protocol"],
136 "name" => ["contact", "name"],
137 "nick" => ["contact", "nick"],
138 "location" => ["contact", "location"],
139 "about" => ["contact", "about"],
140 "keywords" => ["contact", "keywords"],
141 "gender" => ["contact", "gender"],
142 "xmpp" => ["contact", "xmpp"],
143 "attag" => ["contact", "attag"],
144 "avatar" => ["contact", "avatar"],
145 "photo" => ["contact", "photo"],
146 "thumb" => ["contact", "thumb"],
147 "micro" => ["contact", "micro"],
148 "site-pubkey" => ["contact", "site-pubkey"],
149 "issued-id" => ["contact", "issued-id"],
150 "dfrn-id" => ["contact", "dfrn-id"],
151 "url" => ["contact", "url"],
152 "nurl" => ["contact", "nurl"],
153 "addr" => ["contact", "addr"],
154 "alias" => ["contact", "alias"],
155 "pubkey" => ["contact", "pubkey"],
156 "prvkey" => ["contact", "prvkey"],
157 "batch" => ["contact", "batch"],
158 "request" => ["contact", "request"],
159 "notify" => ["contact", "notify"],
160 "poll" => ["contact", "poll"],
161 "confirm" => ["contact", "confirm"],
162 "poco" => ["contact", "poco"],
163 "aes_allow" => ["contact", "aes_allow"],
164 "ret-aes" => ["contact", "ret-aes"],
165 "usehub" => ["contact", "usehub"],
166 "subhub" => ["contact", "subhub"],
167 "hub-verify" => ["contact", "hub-verify"],
168 "last-update" => ["contact", "last-update"],
169 "success_update" => ["contact", "success_update"],
170 "failure_update" => ["contact", "failure_update"],
171 "name-date" => ["contact", "name-date"],
172 "uri-date" => ["contact", "uri-date"],
173 "avatar-date" => ["contact", "avatar-date"],
174 "picdate" => ["contact", "avatar-date"], /// @todo Replaces all uses of "picdate" with "avatar-date"
175 "term-date" => ["contact", "term-date"],
176 "last-item" => ["contact", "last-item"],
177 "priority" => ["contact", "priority"],
178 "blocked" => ["contact", "blocked"], /// @todo Check if "blocked" from contact or from the users table
179 "block_reason" => ["contact", "block_reason"],
180 "readonly" => ["contact", "readonly"],
181 "writable" => ["contact", "writable"],
182 "forum" => ["contact", "forum"],
183 "prv" => ["contact", "prv"],
184 "contact-type" => ["contact", "contact-type"],
185 "hidden" => ["contact", "hidden"],
186 "archive" => ["contact", "archive"],
187 "pending" => ["contact", "pending"],
188 "deleted" => ["contact", "deleted"],
189 "unsearchable" => ["contact", "unsearchable"],
190 "sensitive" => ["contact", "sensitive"],
191 "baseurl" => ["contact", "baseurl"],
192 "reason" => ["contact", "reason"],
193 "closeness" => ["contact", "closeness"],
194 "info" => ["contact", "info"],
195 "profile-id" => ["contact", "profile-id"],
196 "bdyear" => ["contact", "bdyear"],
197 "bd" => ["contact", "bd"],
198 "notify_new_posts" => ["contact", "notify_new_posts"],
199 "fetch_further_information" => ["contact", "fetch_further_information"],
200 "ffi_keyword_denylist" => ["contact", "ffi_keyword_denylist"],
201 "parent-uid" => ["user", "parent-uid"],
202 "guid" => ["user", "guid"],
203 "nickname" => ["user", "nickname"], /// @todo Replaces all uses of "nickname" with "nick"
204 "email" => ["user", "email"],
205 "openid" => ["user", "openid"],
206 "timezone" => ["user", "timezone"],
207 "language" => ["user", "language"],
208 "register_date" => ["user", "register_date"],
209 "login_date" => ["user", "login_date"],
210 "default-location" => ["user", "default-location"],
211 "allow_location" => ["user", "allow_location"],
212 "theme" => ["user", "theme"],
213 "upubkey" => ["user", "pubkey"],
214 "uprvkey" => ["user", "prvkey"],
215 "sprvkey" => ["user", "sprvkey"],
216 "spubkey" => ["user", "spubkey"],
217 "verified" => ["user", "verified"],
218 "blockwall" => ["user", "blockwall"],
219 "hidewall" => ["user", "hidewall"],
220 "blocktags" => ["user", "blocktags"],
221 "unkmail" => ["user", "unkmail"],
222 "cntunkmail" => ["user", "cntunkmail"],
223 "notify-flags" => ["user", "notify-flags"],
224 "page-flags" => ["user", "page-flags"],
225 "account-type" => ["user", "account-type"],
226 "prvnets" => ["user", "prvnets"],
227 "maxreq" => ["user", "maxreq"],
228 "expire" => ["user", "expire"],
229 "account_removed" => ["user", "account_removed"],
230 "account_expired" => ["user", "account_expired"],
231 "account_expires_on" => ["user", "account_expires_on"],
232 "expire_notification_sent" => ["user", "expire_notification_sent"],
233 "def_gid" => ["user", "def_gid"],
234 "allow_cid" => ["user", "allow_cid"],
235 "allow_gid" => ["user", "allow_gid"],
236 "deny_cid" => ["user", "deny_cid"],
237 "deny_gid" => ["user", "deny_gid"],
238 "openidserver" => ["user", "openidserver"],
239 "publish" => ["profile", "publish"],
240 "net-publish" => ["profile", "net-publish"],
241 "hide-friends" => ["profile", "hide-friends"],
242 "prv_keywords" => ["profile", "prv_keywords"],
243 "pub_keywords" => ["profile", "pub_keywords"],
244 "address" => ["profile", "address"],
245 "locality" => ["profile", "locality"],
246 "region" => ["profile", "region"],
247 "postal-code" => ["profile", "postal-code"],
248 "country-name" => ["profile", "country-name"],
249 "homepage" => ["profile", "homepage"],
250 "dob" => ["profile", "dob"],
252 "query" => "FROM `user`
253 INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
254 INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`"
258 "id" => ["register", "id"],
259 "hash" => ["register", "hash"],
260 "created" => ["register", "created"],
261 "uid" => ["register", "uid"],
262 "password" => ["register", "password"],
263 "language" => ["register", "language"],
264 "note" => ["register", "note"],
265 "self" => ["contact", "self"],
266 "name" => ["contact", "name"],
267 "url" => ["contact", "url"],
268 "micro" => ["contact", "micro"],
269 "email" => ["user", "email"],
270 "nick" => ["contact", "nick"],
272 "query" => "FROM `register`
273 INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
274 INNER JOIN `user` ON `register`.`uid` = `user`.`uid`"
276 "tag-search-view" => [
278 "uri-id" => ["post-tag", "uri-id"],
279 "iid" => ["item", "id"],
280 "uri" => ["item", "uri"],
281 "guid" => ["item", "guid"],
282 "uid" => ["item", "uid"],
283 "private" => ["item", "private"],
284 "wall" => ["item", "wall"],
285 "origin" => ["item", "origin"],
286 "gravity" => ["item", "gravity"],
287 "received" => ["item", "received"],
288 "name" => ["tag", "name"],
290 "query" => "FROM `post-tag`
291 INNER JOIN `tag` ON `tag`.`id` = `post-tag`.`tid`
292 INNER JOIN `item` ON `item`.`uri-id` = `post-tag`.`uri-id`
293 WHERE `post-tag`.`type` = 1"
295 "workerqueue-view" => [
297 "pid" => ["process", "pid"],
298 "priority" => ["workerqueue", "priority"],
300 "query" => "FROM `process`
301 INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid`
302 WHERE NOT `workerqueue`.`done`"