summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-11-26 23:07:37 +0000
committerBharat Mediratta <bharat@menalto.com>2008-11-26 23:07:37 +0000
commit691faa0e83790c0dc40a937f875e3032843d91c3 (patch)
treeb2efbcc1476e4ad24dade5d856131fe2a5010c67
parent91b1c4cf39c0b9ac6d2a0134bfc771e46d42e3dc (diff)
Draw an album tree in the access -> permissions tab.
-rw-r--r--core/controllers/welcome.php15
-rw-r--r--core/views/welcome.html.php22
2 files changed, 34 insertions, 3 deletions
diff --git a/core/controllers/welcome.php b/core/controllers/welcome.php
index 821744e8..3bfcf1fd 100644
--- a/core/controllers/welcome.php
+++ b/core/controllers/welcome.php
@@ -33,10 +33,12 @@ class Welcome_Controller extends Template_Controller {
$this->template->photo_count = ORM::factory("item")->where("type", "photo")->count_all();
$this->template->deepest_photo = ORM::factory("item")
->where("type", "photo")->orderby("level", "desc")->find();
+ $this->template->album_tree = $this->_load_album_tree();
} catch (Exception $e) {
$this->template->album_count = 0;
$this->template->photo_count = 0;
$this->template->deepest_photo = null;
+ $this->template->album_tree = array();
}
$this->_load_user_info();
@@ -424,4 +426,17 @@ class Welcome_Controller extends Template_Controller {
}
url::redirect("welcome");
}
+
+ public function _load_album_tree() {
+ $tree = array();
+ foreach (ORM::factory("item")->where("type", "album")->find_all() as $album) {
+ if ($album->parent_id) {
+ $tree[$album->parent_id]->children[] = $album->id;
+ }
+ $tree[$album->id]->album = $album;
+ $tree[$album->id]->children = array();
+ }
+
+ return $tree;
+ }
}
diff --git a/core/views/welcome.html.php b/core/views/welcome.html.php
index 70e9eb19..c0f27d3b 100644
--- a/core/views/welcome.html.php
+++ b/core/views/welcome.html.php
@@ -306,9 +306,25 @@
</div>
<div id="access_permissions" class="activity">
- <p>
- <i>Nothing yet</i>
- </p>
+ <? if ($album_tree): ?>
+ <? $stack = array(1); // hardcoded to the root album ?>
+ <? while ($stack): ?>
+ <? $current = array_pop($stack); ?>
+ <? if ($current != "CLOSE"): ?>
+ <? $current = $album_tree[$current]; ?>
+ <ul>
+ <li>
+ <?= $current->album->title ?>
+ <? $stack[] = "CLOSE"; ?>
+ <? if ($current->children): ?>
+ <? $stack = array_merge($stack, $current->children) ?>
+ <? endif ?>
+ <? else: ?>
+ </li>
+ </ul>
+ <? endif ?>
+ <? endwhile ?>
+ <? endif ?>
</div>
</div>