示例#1
0
 static function site($menu, $theme)
 {
     if (file_exists(APPPATH . "controllers/welcome.php")) {
         $menu->append(Menu::factory("link")->id("browse")->label("Scaffold")->url(url::site("welcome")));
     }
     $menu->append(Menu::factory("link")->id("home")->label(t("Home"))->url(url::site("albums/1")));
     $item = $theme->item();
     if ($item && access::can("edit", $item)) {
         $menu->append($options_menu = Menu::factory("submenu")->id("options_menu")->label(t("Options"))->append(Menu::factory("dialog")->id("edit_item")->label($item->type == "album" ? t("Edit album") : t("Edit photo"))->url(url::site("form/edit/{$item->type}s/{$item->id}"))));
         // @todo Move album options menu to the album quick edit pane
         // @todo Create resized item quick edit pane menu
         if ($item->type == "album") {
             $options_menu->append(Menu::factory("dialog")->id("add_item")->label(t("Add a photo"))->url(url::site("form/add/albums/{$item->id}?type=photo")))->append(Menu::factory("dialog")->id("add_album")->label(t("Add an album"))->url(url::site("form/add/albums/{$item->id}?type=album")))->append(Menu::factory("dialog")->id("edit_permissions")->label(t("Edit permissions"))->url(url::site("permissions/browse/{$item->id}")));
         }
     }
     if (user::active()->admin) {
         $menu->append($admin_menu = Menu::factory("submenu")->id("admin_menu")->label(t("Admin")));
         self::admin($admin_menu, $theme);
         foreach (module::installed() as $module) {
             if ($module->name == "core") {
                 continue;
             }
             $class = "{$module->name}_menu";
             if (method_exists($class, "admin")) {
                 call_user_func_array(array($class, "admin"), array(&$admin_menu, $this));
             }
         }
     }
 }
示例#2
0
 static function site_menu($menu, $theme)
 {
     $item = $theme->item();
     if ($item && access::can("edit", $item) && $item->is_album()) {
         $menu->get("options_menu")->append(Menu::factory("link")->id("organize")->label(t("Organize Album"))->css_id("gOrganizeLink")->url(url::site("organize/index/{$item->id}")));
     }
 }
 function getETag()
 {
     if (!access::can("view", $this->item)) {
         throw new Sabre_DAV_Exception_Forbidden("Access denied");
     }
     return "'" . md5($this->item->file_path()) . "'";
 }
示例#4
0
 public function albums($id)
 {
     $item = ORM::factory("item", $id);
     if (!access::can("view", $item)) {
         return Kohana::show_404();
     }
     $page = $this->input->get("page", 1);
     if ($page < 1) {
         url::redirect("media_rss/albums/{$item->id}");
     }
     $children = $item->viewable()->descendants(self::$page_size, ($page - 1) * self::$page_size, "photo");
     $max_pages = ceil($item->viewable()->descendants_count("photo") / self::$page_size);
     if ($page > $max_pages) {
         url::redirect("media_rss/albums/{$item->id}?page={$max_pages}");
     }
     $view = new View("feed.mrss");
     $view->title = $item->title;
     $view->link = url::abs_site("albums/{$item->id}");
     $view->description = $item->description;
     $view->feed_link = url::abs_site("media_rss/albums/{$item->id}");
     $view->children = $children;
     if ($page > 1) {
         $previous_page = $page - 1;
         $view->previous_page_link = url::site("media_rss/albums/{$item->id}?page={$previous_page}");
     }
     if ($page < $max_pages) {
         $next_page = $page + 1;
         $view->next_page_link = url::site("media_rss/albums/{$item->id}?page={$next_page}");
     }
     // @todo do we want to add an upload date to the items table?
     $view->pub_date = date("D, d M Y H:i:s T");
     rest::http_content_type(rest::RSS);
     print $view;
 }
 function save($album_id)
 {
     access::verify_csrf();
     $album = ORM::factory("item", $album_id);
     access::required("edit", $album);
     if (Input::instance()->post("save")) {
         $titles = Input::instance()->post("title");
         $descriptions = Input::instance()->post("description");
         $filenames = Input::instance()->post("filename");
         $internetaddresses = Input::instance()->post("internetaddress");
         $tags = Input::instance()->post("tags");
         $enable_tags = module::is_active("tag");
         foreach (array_keys($titles) as $id) {
             $item = ORM::factory("item", $id);
             if ($item->loaded() && access::can("edit", $item)) {
                 $item->title = $titles[$id];
                 $item->description = $descriptions[$id];
                 $item->name = $filenames[$id];
                 $item->slug = $internetaddresses[$id];
                 $item->save();
                 if ($enable_tags) {
                     tag::clear_all($item);
                     foreach (explode(",", $tags[$id]) as $tag_name) {
                         if ($tag_name) {
                             tag::add($item, trim($tag_name));
                         }
                     }
                     tag::compact();
                 }
             }
         }
         message::success(t("Captions saved"));
     }
     url::redirect($album->abs_url());
 }
 static function site_menu($menu, $theme)
 {
     $item = $theme->item();
     if ($item && $item->is_album() && access::can("edit", $item)) {
         $menu->get("options_menu")->append(Menu::factory("link")->id("captionator")->label(t("Caption album"))->css_id("g-menu-captionator-link")->url(url::site("captionator/dialog/{$item->id}")));
     }
 }
示例#7
0
 static function photo($menu, $theme)
 {
     if (access::can("view_full", $theme->item())) {
         $menu->append(Menu::factory("link")->id("fullsize")->label(t("View full size"))->url("#")->css_class("gFullSizeLink"));
     }
     $menu->append(Menu::factory("link")->id("album")->label(t("Return to album"))->url($theme->item()->parent()->url("show={$theme->item->id}"))->css_id("gAlbumLink"));
 }
 static function get($block_id, $theme)
 {
     $block = "";
     // Only display on album pages that the user can edit.
     $item = $theme->item();
     if (!$item || !$item->is_album() || !access::can("edit", $item)) {
         return;
     }
     switch ($block_id) {
         case "batch_tag":
             // Make a new sidebar block.
             $block = new Block();
             $block->css_id = "g-batch-tag";
             $block->title = t("Batch Tag");
             $block->content = new View("batchtag_block.html");
             // Make a new form to place in the sidebar block.
             $form = new Forge("batchtag/tagitems", "", "post", array("id" => "g-batch-tag-form"));
             $label = t("Tag everything in this album:");
             $group = $form->group("add_tag")->label("Add Tag");
             $group->input("name")->label($label)->rules("required|length[1,64]");
             $group->checkbox("tag_subitems")->label(t("Include sub-albums?"))->value(true)->checked(false);
             $group->hidden("item_id")->value($item->id);
             $group->submit("")->value(t("Add Tag"));
             $block->content->batch_tag_form = $form;
             break;
     }
     return $block;
 }
示例#9
0
 static function make_album_cover($item)
 {
     $parent = $item->parent();
     access::required("view", $item);
     access::required("view", $parent);
     access::required("edit", $parent);
     $old_album_cover_id = $parent->album_cover_item_id;
     model_cache::clear();
     $parent->album_cover_item_id = $item->is_album() ? $item->album_cover_item_id : $item->id;
     $parent->save();
     graphics::generate($parent);
     // Walk up the parent hierarchy and set album covers if necessary
     $grand_parent = $parent->parent();
     if ($grand_parent && access::can("edit", $grand_parent) && $grand_parent->album_cover_item_id == null) {
         item::make_album_cover($parent);
     }
     // When albums are album covers themselves, we hotlink directly to the target item.  This
     // means that when we change an album cover, the grandparent may have a deep link to the old
     // album cover.  So find any parent albums that had the old item as their album cover and
     // switch them over to the new item.
     if ($old_album_cover_id) {
         foreach ($item->parents(array(array("album_cover_item_id", "=", $old_album_cover_id))) as $ancestor) {
             if (access::can("edit", $ancestor)) {
                 $ancestor->album_cover_item_id = $parent->album_cover_item_id;
                 $ancestor->save();
                 graphics::generate($ancestor);
             }
         }
     }
 }
 static function site_menu($menu, $theme)
 {
     $item = $theme->item();
     if ($can_add = $item && access::can("add", $item)) {
         $menu->get("add_menu")->append(Menu::factory("dialog")->id("embed_add")->label(t("Embed Video"))->url(url::site("form/add/embedded_videos/{$item->id}")));
     }
 }
 static function sidebar_blocks($theme)
 {
     // Display form for tagging in the album sidebar.
     // Make sure the current page belongs to an item.
     if (!$theme->item()) {
         return;
     }
     $item = $theme->item();
     // Only display the form in albums that the user has edit permission in.
     if ($item->is_album() && access::can("edit", $item)) {
         // Make a new sidebar block.
         $block = new Block();
         $block->css_id = "gBatchTag";
         $block->title = t("Batch Tag");
         $block->content = new View("batchtag_block.html");
         // Make a new form to place in the sidebar block.
         $form = new Forge("batchtag/tagitems", "", "post", array("id" => "gBatchTagForm"));
         $label = t("Tag everything in this album:");
         $group = $form->group("add_tag")->label("Add Tag");
         $group->input("name")->label($label)->rules("required|length[1,64]");
         $group->hidden("item_id")->value($item->id);
         $group->submit("")->value(t("Add Tag"));
         $block->content->form = $form;
         // Display the block.
         return $block;
     }
 }
示例#12
0
 public function tagitems()
 {
     // Tag all non-album items in the current album with the specified tags.
     // Prevent Cross Site Request Forgery
     access::verify_csrf();
     // Generate an array of all non-album items in the current album.
     $children = ORM::factory("item")->where("parent_id", $this->input->post("item_id"))->where("type !=", "album")->find_all();
     // Loop through each item in the album and make sure the user has
     //   access to view and edit it.
     foreach ($children as $child) {
         if (access::can("view", $child) && access::can("edit", $child)) {
             // Assuming the user can view/edit the current item, loop
             //   through each tag that was submitted and apply it to
             //   the current item.
             foreach (split(",", $this->input->post("name")) as $tag_name) {
                 $tag_name = trim($tag_name);
                 if ($tag_name) {
                     tag::add($child, $tag_name);
                 }
             }
         }
     }
     // Redirect back to the album.
     $item = ORM::factory("item", $this->input->post("item_id"));
     url::redirect(url::abs_site("{$item->type}s/{$item->id}"));
 }
 static function album_menu($menu, $theme)
 {
     if (access::can("view_full", $theme->item)) {
         $downloadLink = url::site("downloadalbum/zip/{$theme->item->id}");
         $menu->append(Menu::factory("link")->id("downloadalbum")->label(t("Download Album"))->url($downloadLink)->css_id("g-download-album-link"));
     }
 }
示例#14
0
 public function download($id)
 {
     $item = ORM::factory("item", $id);
     // Make sure we have access to the item
     if (!access::can("view", $item)) {
         throw new Kohana_404_Exception();
     }
     // Make sure we have view_full access to the original
     if (!access::can("view_full", $item)) {
         throw new Kohana_404_Exception();
     }
     // Don't try to load a directory
     if ($item->is_album()) {
         throw new Kohana_404_Exception();
     }
     $file = $item->file_path();
     if (!file_exists($file)) {
         throw new Kohana_404_Exception();
     }
     header("Content-Length: " . filesize($file));
     header("Pragma: public");
     header("Content-Type: application/force-download");
     header("Content-Disposition: attachment; filename=\"{$item->name}\"");
     Kohana::close_buffers(false);
     readfile($file);
 }
示例#15
0
 static function required($perm_name, $item)
 {
     // Original code from the required function in modules/gallery/helpers/access.php.
     if (!access::can($perm_name, $item)) {
         if ($perm_name == "view") {
             // Treat as if the item didn't exist, don't leak any information.
             throw new Kohana_404_Exception();
         } else {
             access::forbidden();
         }
         // Begin rWatcher modifications.
         //   Throw a 404 error when a user attempts to access a protected item,
         //   unless the password has been provided, or the user is the item's owner.
     } elseif (module::get_var("albumpassword", "hideonly") == false) {
         $item_protected = ORM::factory("albumpassword_idcache")->where("item_id", "=", $item->id)->order_by("cache_id")->find_all();
         if (count($item_protected) > 0) {
             $existing_password = ORM::factory("items_albumpassword")->where("id", "=", $item_protected[0]->password_id)->find();
             if ($existing_password->loaded()) {
                 if (cookie::get("g3_albumpassword") != $existing_password->password && identity::active_user()->id != $item->owner_id && !identity::active_user()->admin) {
                     throw new Kohana_404_Exception();
                 }
             }
         }
     }
 }
示例#16
0
 static function site($menu, $theme)
 {
     $item = $theme->item();
     $paths = unserialize(module::get_var("server_add", "authorized_paths"));
     if ($item && access::can("edit", $item) && access::can("server_add", $item) && $item->is_album() && !empty($paths)) {
         $options_menu = $menu->get("options_menu")->append(Menu::factory("dialog")->id("server_add")->label(t("Add from server"))->url(url::site("server_add/index/{$item->id}")));
     }
 }
示例#17
0
 static function resolve($id)
 {
     $comment = ORM::factory("comment", $id);
     if (!access::can("view", $comment->item())) {
         throw new Kohana_404_Exception();
     }
     return $comment;
 }
示例#18
0
 static function resolve($id)
 {
     $item = ORM::factory("item", $id);
     if (!access::can("view", $item)) {
         throw new Kohana_404_Exception();
     }
     return $item;
 }
 static function photo($menu, $theme)
 {
     if (access::can("view_full", $theme->item)) {
         if (module::get_var("downloadfullsize", "fButton")) {
             $downloadLink = url::site("downloadfullsize/send/{$theme->item}");
             $menu->append(Menu::factory("link")->id("downloadfullsize")->label(t("Download Fullsize Image"))->url($downloadLink)->css_id("gDownloadFullsizeLink"));
         }
     }
 }
 /**
  * This adds the buttons for the case of an album.  If you want to disable 
  * either the A4 or LTR part, do so here *and* below for tags.
  */
 static function album_menu($menu, $theme)
 {
     if (access::can("view_full", $theme->item)) {
         $proofsheetA4Link = url::site("proofsheet/makepdf/a4/album/{$theme->item->id}");
         $menu->append(Menu::factory("link")->id("proofsheetA4")->label(t("A4 Proof Sheet"))->url($proofsheetA4Link)->css_id("g-proofsheet-a4-link"));
         $proofsheetLTRLink = url::site("proofsheet/makepdf/ltr/album/{$theme->item->id}");
         $menu->append(Menu::factory("link")->id("proofsheetLTR")->label(t("LTR Proof Sheet"))->url($proofsheetLTRLink)->css_id("g-proofsheet-ltr-link"));
     }
 }
 static function movie_menu($menu, $theme)
 {
     if (access::can("view_full", $theme->item)) {
         if (module::get_var("downloadfullsize", "fButton")) {
             $downloadLink = url::site("downloadfullsize/send/{$theme->item->id}");
             $menu->append(Menu::factory("link")->id("downloadfullsize")->label(t("Download Video"))->url($downloadLink)->css_id("g-download-fullsize-link"));
         }
     }
 }
 static function head($theme)
 {
     if (!$theme->item()) {
         return;
     }
     $item = $theme->item();
     if ($item && access::can("edit", $item)) {
         $theme->css("editcreation.css");
     }
 }
 static function context_menu($menu, $theme, $item, $thumb_css_selector)
 {
     $csrf = access::csrf_token();
     $options_menu = $menu->get("options_menu");
     $can_edit = $item && access::can("edit", $item);
     if ($can_edit && $options_menu != null) {
         $cover_title = t("Browse for an album to cover");
         $options_menu->append(Menu::factory("dialog")->id("browse_album_cover")->label($cover_title)->css_class("ui-icon-folder-open")->url(url::site("browse/browse/{$item->id}?csrf={$csrf}")));
     }
 }
示例#24
0
 static function resolve($tuple)
 {
     list($tag_id, $item_id) = explode(",", $tuple);
     $tag = ORM::factory("tag", $tag_id);
     $item = ORM::factory("item", $item_id);
     if (!$tag->loaded() || !$item->loaded() || !$tag->has($item) || !access::can("view", $item)) {
         throw new Kohana_404_Exception();
     }
     return array($tag, $item);
 }
示例#25
0
 static function get($request)
 {
     $tag = rest::resolve($request->url);
     $tag_items = array();
     foreach ($tag->items() as $item) {
         if (access::can("view", $item)) {
             $tag_items[] = rest::url("tag_item", $tag, $item);
         }
     }
     return array("url" => $request->url, "entity" => $tag->as_array(), "relationships" => array("items" => array("url" => rest::url("tag_items", $tag), "members" => $tag_items)));
 }
示例#26
0
 static function get($request)
 {
     $tag = rest::resolve($request->url);
     $items = array();
     foreach ($tag->items() as $item) {
         if (access::can("view", $item)) {
             $items[] = rest::url("tag_item", $tag, $item);
         }
     }
     return array("url" => $request->url, "members" => $items);
 }
示例#27
0
 static function context_menu($menu, $theme, $item)
 {
     if (access::can("edit", $item)) {
         if ($item->is_album()) {
             $menu->get("options_menu")->append(Menu::factory("dialog")->id("organize")->label(t("Organize album"))->css_class("ui-icon-folder-open g-organize-link")->url(url::site("organize/dialog/{$item->id}")));
         } else {
             $parent = $item->parent();
             $menu->get("options_menu")->append(Menu::factory("dialog")->id("move")->label(t("Move to another album"))->css_class("ui-icon-folder-open g-organize-link")->url(url::site("organize/dialog/{$parent->id}?selected_id={$item->id}")));
         }
     }
 }
示例#28
0
文件: quick.php 项目: krgeek/gallery3
 public function pane($id)
 {
     $item = model_cache::get("item", $id);
     if (!access::can("view", $item) || !access::can("edit", $item)) {
         return "";
     }
     $view = new View("quick_pane.html");
     $view->item = $item;
     $view->page_type = Input::instance()->get("page_type");
     print $view;
 }
示例#29
0
 static function site_menu($menu, $theme)
 {
     if (!user::active()->guest) {
         $item = $theme->item();
         if ($item && $item->is_album() && access::can("view", $item)) {
             $watching = notification::is_watching($item);
             $label = $watching ? t("Remove notifications") : t("Enable notifications");
             $menu->get("options_menu")->append(Menu::factory("link")->id("watch")->label($label)->css_id("gNotifyLink")->url(url::site("notification/watch/{$item->id}?csrf=" . access::csrf_token())));
         }
     }
 }
示例#30
0
 static function head($theme)
 {
     $item = $theme->item();
     if ($item && access::can("edit", $item) && $item->is_album()) {
         // @todo: Defer loading js/css until we're loading the organize dialog as <script> and
         // <link> elements so that we're not forcing them to be downloaded on every page view (which
         // is expensive in terms of browser latency).  When we do that, we'll have to figure out an
         // approach that lets us continue to use the Kohana cascading filesystem.
         $theme->script("organize.js");
         $theme->css("organize.css");
     }
 }