Overview
Comment: | Some kind of progress, or not |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | dev |
Files: | files | file ages | folders |
SHA1: |
cd88e798f2879e5ccda1031a5268b8d1 |
User & Date: | bohwaz on 2020-12-11 01:11:14 |
Other Links: | branch diff | manifest | tags |
Context
2020-12-12
| ||
15:36 | Working migration, remove categories for now check-in: 916600f4fe user: bohwaz tags: dev | |
2020-12-11
| ||
01:11 | Some kind of progress, or not check-in: cd88e798f2 user: bohwaz tags: dev | |
2020-12-10
| ||
20:01 | Migrate more from Fichiers to File and Files check-in: 332a8b6494 user: bohwaz tags: dev | |
Changes
Modified src/include/data/1.1.0_schema.sql from [28445b9f61] to [e3756c8ea0].
︙ | ︙ | |||
251 252 253 254 255 256 257 258 259 260 261 | ( signal TEXT NOT NULL, plugin TEXT NOT NULL REFERENCES plugins (id), callback TEXT NOT NULL, PRIMARY KEY (signal, plugin) ); CREATE TABLE IF NOT EXISTS files -- Files metadata ( id INTEGER NOT NULL PRIMARY KEY, | > > | > < | 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | ( signal TEXT NOT NULL, plugin TEXT NOT NULL REFERENCES plugins (id), callback TEXT NOT NULL, PRIMARY KEY (signal, plugin) ); ---------- FILES ---------------- CREATE TABLE IF NOT EXISTS files -- Files metadata ( id INTEGER NOT NULL PRIMARY KEY, folder_id INTEGER NOT NULL REFERENCES files_folders, name TEXT NOT NULL, -- file name (eg. image1234.jpeg) type TEXT NULL, -- MIME type image INTEGER NOT NULL DEFAULT 0, -- 1 = image reconnue public INTEGER NOT NULL DEFAULT 0, size INTEGER NOT NULL DEFAULT 0, hash TEXT NOT NULL, -- Hash SHA1 du contenu du fichier storage TEXT NULL, -- Storage medium, NULL means stored in content BLOB storage_path TEXT NULL, created TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP CHECK (datetime(created) IS NOT NULL AND datetime(created) = created), author_id INTEGER NULL REFERENCES membres (id) ON DELETE SET NULL ); CREATE INDEX IF NOT EXISTS files_path ON files (path); CREATE INDEX IF NOT EXISTS files_date ON files (datetime); CREATE INDEX IF NOT EXISTS files_hash ON files (hash); |
︙ | ︙ | |||
289 290 291 292 293 294 295 | CREATE UNIQUE INDEX IF NOT EXISTS files_contents_hash ON files_contents (hash); CREATE TABLE IF NOT EXISTS files_folders ( id INTEGER NOT NULL PRIMARY KEY, parent_id INTEGER NULL REFERENCES files_folders(id) ON DELETE CASCADE, | | > > | | > | | > > > > > > > > > > > > > > > > > > > > > > > > > > | 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | CREATE UNIQUE INDEX IF NOT EXISTS files_contents_hash ON files_contents (hash); CREATE TABLE IF NOT EXISTS files_folders ( id INTEGER NOT NULL PRIMARY KEY, parent_id INTEGER NULL REFERENCES files_folders(id) ON DELETE CASCADE, name TEXT NOT NULL, system INTEGER NOT NULL DEFAULT 0 ); CREATE VIRTUAL TABLE IF NOT EXISTS files_search USING fts4 -- Search inside files content ( id INT PRIMARY KEY NOT NULL REFERENCES files_contents(id), title TEXT NULL, content TEXT NOT NULL -- Text content ); CREATE TABLE IF NOT EXISTS files_links -- This references use of a file outside of the documents module -- One file can only be linked to one thing ( id INTEGER NOT NULL PRIMARY KEY REFERENCES fichiers (id) ON DELETE CASCADE, file_id INTEGER NULL REFERENCES fichiers (id) ON DELETE CASCADE, user_id INTEGER NULL REFERENCES membres (id) ON DELETE CASCADE, transaction_id INTEGER NULL REFERENCES acc_transactions (id) ON DELETE CASCADE, config TEXT NULL REFERENCES config (valeur) ON DELETE CASCADE, web_page_id INTEGER NULL REFERENCES web_pages (id) ON DELETE CASCADE, web_category_id INTEGER NULL REFERENCES web_categories (id) ON DELETE CASCADE, -- Make sure that only one is filled CHECK ((user_id IS NULL) + (transaction_id IS NULL) + (config IS NULL) + (web_page_id IS NULL) + (web_category_id IS NULL) + (file_id IS NULL) = 1) ); CREATE UNIQUE INDEX files_links_unique ON files_links (file_id, user_id, transaction_id, config, web_pages, web_category_id); CREATE TABLE IF NOT EXISTS web_pages ( id INTEGER NOT NULL PRIMARY KEY REFERENCES files(id), category_id INTEGER NOT NULL REFERENCES web_categories(id) ON DELETE CASCADE, title TEXT NOT NULL, draft INTEGER NOT NULL DEFAULT 0, modified TEXT NULL CHECK (datetime(modified) IS NULL OR datetime(modified) = modified) ); CREATE TABLE IF NOT EXISTS web_categories ( id INTEGER NOT NULL PRIMARY KEY REFERENCES files(id), parent_id INTEGER NOT NULL REFERENCES web_categories(id) ON DELETE CASCADE, title TEXT NOT NULL ); CREATE TRIGGER IF NOT EXISTS web_page_insert AFTER INSERT ON web_pages BEGIN UPDATE files SET public = NEW.draft WHERE id = NEW.id; END; CREATE TRIGGER IF NOT EXISTS web_page_update AFTER UPDATE ON web_pages BEGIN UPDATE files SET public = NEW.draft WHERE id = NEW.id; END; -- FIXME: rename to english CREATE TABLE IF NOT EXISTS recherches -- Recherches enregistrées ( id INTEGER NOT NULL PRIMARY KEY, id_membre INTEGER NULL REFERENCES membres (id) ON DELETE CASCADE, -- Si non NULL, alors la recherche ne sera visible que par le membre associé |
︙ | ︙ |
Modified src/include/lib/Garradin/Entities/Files/File.php from [dee3022a27] to [f6bcbadbb9].
︙ | ︙ | |||
46 47 48 49 50 51 52 53 54 55 | /** * Tailles de miniatures autorisées, pour ne pas avoir 500 fichiers générés avec 500 tailles différentes * @var array */ const ALLOWED_THUMB_SIZES = [200, 500, 1200]; const LINK_USER = 'user_id'; const LINK_TRANSACTION = 'transaction_id'; const LINK_CONFIG = 'config'; | > > | | < < < < | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | /** * Tailles de miniatures autorisées, pour ne pas avoir 500 fichiers générés avec 500 tailles différentes * @var array */ const ALLOWED_THUMB_SIZES = [200, 500, 1200]; // Link to another file (ie. image included in a HTML file) const LINK_FILE = 'file_id'; const LINK_USER = 'user_id'; const LINK_TRANSACTION = 'transaction_id'; const LINK_CONFIG = 'config'; const LINK_WEB_PAGE = 'web_page_id'; const LINK_WEB_CATEGORY = 'web_category_id'; const THUMB_CACHE_ID = 'file.thumb.%d.%d'; public function selfCheck(): void { parent::selfCheck(); } |
︙ | ︙ | |||
448 449 450 451 452 453 454 455 456 457 458 459 460 461 | return $this->_public; } public function checkAccess(Session $session): bool { $link = DB::getInstance()->first('SELECT * FROM files_links WHERE id = ?;', $this->id()); $this->_public = false; // Everyone has access to web content as long it's not draft (0) if ($link->{LINK_WEB} == 1) { $this->_public = true; return true; | > > > > > | 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | return $this->_public; } public function checkAccess(Session $session): bool { $link = DB::getInstance()->first('SELECT * FROM files_links WHERE id = ?;', $this->id()); // If it's linked to a file, then we want to know what the parent file is linked to if ($link->{LINK_FILE}) { $link = DB::getInstance()->first('SELECT * FROM files_links WHERE id = ?;', $link->{LINK_FILE}); } $this->_public = false; // Everyone has access to web content as long it's not draft (0) if ($link->{LINK_WEB} == 1) { $this->_public = true; return true; |
︙ | ︙ |
Added src/include/lib/Garradin/Entities/Web/Category.php version [c921b48f36].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | <?php namespace Garradin\Entities\Web; use Garradin\Entity; use Garradin\UserException; use KD2\DB\EntityManager; class Category extends Entity { protected $id; protected $parent_id; protected $title; protected $_types = [ 'id' => 'int', 'parent_id' => 'int', 'title' => 'string', ]; protected $_file; public function file(): File { if (null === $this->_file) { $this->_file = EM::findOneById(File::class, $this->id); } return $this->_file; } public function save() { $file = $this->file(); $file->save(); $this->id($file->id()); parent::save(); } } |
Added src/include/lib/Garradin/Entities/Web/Page.php version [45f124fbff].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | <?php namespace Garradin\Entities\Web; use Garradin\Entity; use Garradin\UserException; use KD2\DB\EntityManager; class Page extends Entity { protected $id; protected $category_id; protected $title; protected $draft; protected $modified; protected $_types = [ 'id' => 'int', 'category_id' => 'int', 'title' => 'string', 'draft' => 'int', 'modified' => 'DateTime', ]; protected $_file; public function file(): File { if (null === $this->_file) { $this->_file = EM::findOneById(File::class, $this->id); } return $this->_file; } public function save() { $file = $this->file(); $file->save(); $this->id($file->id()); parent::save(); } } |