diff options
-rw-r--r-- | core/controllers/welcome.php | 14 | ||||
-rw-r--r-- | core/helpers/core_installer.php | 19 | ||||
-rw-r--r-- | core/models/access.php | 21 | ||||
-rw-r--r-- | core/views/welcome.html.php | 15 |
4 files changed, 58 insertions, 11 deletions
diff --git a/core/controllers/welcome.php b/core/controllers/welcome.php index 5cf6d7bf..b6c4f381 100644 --- a/core/controllers/welcome.php +++ b/core/controllers/welcome.php @@ -162,7 +162,7 @@ class Welcome_Controller extends Template_Controller { url::redirect("welcome"); } - function add_albums_and_photos($count) { + function add_albums_and_photos($count, $desired_type=null) { srand(time()); $parents = ORM::factory("item")->where("type", "album")->find_all()->as_array(); @@ -174,8 +174,14 @@ class Welcome_Controller extends Template_Controller { } for ($i = 0; $i < $count; $i++) { + set_time_limit(30); + $parent = $parents[array_rand($parents)]; - if (!rand(0, 10)) { + $type = $desired_type; + if (!$type) { + $type = rand(0, 10) ? "photo" : "album"; + } + if ($type == "album") { $parents[] = album::create( $parent->id, "rnd_" . rand(), "Rnd $i", "random album $i", $owner_id) ->set_thumbnail(DOCROOT . "core/tests/test.jpg", 200, 150) @@ -184,10 +190,6 @@ class Welcome_Controller extends Template_Controller { photo::create($parent->id, DOCROOT . "themes/default/images/thumbnail.jpg", "thumbnail.jpg", "rnd_" . rand(), "sample thumbnail", $owner_id); } - - if (!($i % 100)) { - set_time_limit(30); - } } url::redirect("welcome"); } diff --git a/core/helpers/core_installer.php b/core/helpers/core_installer.php index 1066b08c..792798ea 100644 --- a/core/helpers/core_installer.php +++ b/core/helpers/core_installer.php @@ -31,12 +31,12 @@ class core_installer { } if ($version == 0) { - $db->query("CREATE TABLE `modules` ( + $db->query("CREATE TABLE `access` ( `id` int(9) NOT NULL auto_increment, - `name` char(255) default NULL, - `version` int(9) default NULL, - PRIMARY KEY (`id`), - UNIQUE KEY(`name`)) + `item_id` int(9), + `group_id` int(9) NOT NULL, + `perm` char(255) default NULL, + PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE `items` ( @@ -62,6 +62,14 @@ class core_installer { KEY `type` (`type`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + $db->query("CREATE TABLE `modules` ( + `id` int(9) NOT NULL auto_increment, + `name` char(255) default NULL, + `version` int(9) default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY(`name`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + foreach (array("albums", "resizes") as $dir) { @mkdir(VARPATH . $dir); } @@ -83,6 +91,7 @@ class core_installer { public static function uninstall() { $db = Database::instance(); + $db->query("DROP TABLE IF EXISTS `access`;"); $db->query("DROP TABLE IF EXISTS `items`;"); $db->query("DROP TABLE IF EXISTS `modules`;"); system("/bin/rm -rf " . VARPATH . "albums"); diff --git a/core/models/access.php b/core/models/access.php new file mode 100644 index 00000000..f85e152d --- /dev/null +++ b/core/models/access.php @@ -0,0 +1,21 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2008 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ +class Access_Model extends ORM { +} diff --git a/core/views/welcome.html.php b/core/views/welcome.html.php index 5e683690..61c87c8b 100644 --- a/core/views/welcome.html.php +++ b/core/views/welcome.html.php @@ -214,6 +214,13 @@ <p> add: [ <? foreach (array(1, 10, 50, 100, 500, 1000) as $count): ?> + <?= html::anchor("welcome/add_albums_and_photos/$count/album", "$count") ?> + <? endforeach ?> + ] albums only + </p> + <p> + add: [ + <? foreach (array(1, 10, 50, 100, 500, 1000) as $count): ?> <?= html::anchor("welcome/add_comments/$count", "$count") ?> <? endforeach ?> ] comments @@ -328,6 +335,14 @@ <ul> <li> <?= html::anchor("albums/{$current->album->id}", $current->album->title) ?> + <? foreach (ORM::factory("item")->list_fields("items") as $field => $info): ?> + <? if (!strncmp($field, "view_", 5)): ?> + [<?= $field ?>=<?= $current->album->$field ?>] + <? endif ?> + <? endforeach ?> + <? foreach (ORM::factory("access")->where("item_id", $current->album->id)->find() as $access): ?> + [ <?= $access->id ?> ] + <? endforeach ?> <? $stack[] = "CLOSE"; ?> <? if ($current->children): ?> <? $stack = array_merge($stack, $current->children) ?> |