当前位置: 首页>>代码示例>>PHP>>正文


PHP access::can方法代码示例

本文整理汇总了PHP中access::can方法的典型用法代码示例。如果您正苦于以下问题:PHP access::can方法的具体用法?PHP access::can怎么用?PHP access::can使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在access的用法示例。


在下文中一共展示了access::can方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: site

 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));
             }
         }
     }
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:29,代码来源:core_menu.php

示例2: site_menu

 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}")));
     }
 }
开发者ID:eo04837,项目名称:gallery3,代码行数:7,代码来源:organize_event.php

示例3: getETag

 function getETag()
 {
     if (!access::can("view", $this->item)) {
         throw new Sabre_DAV_Exception_Forbidden("Access denied");
     }
     return "'" . md5($this->item->file_path()) . "'";
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:7,代码来源:Gallery3_DAV_File.php

示例4: albums

 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;
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:34,代码来源:media_rss.php

示例5: save

 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());
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:35,代码来源:captionator.php

示例6: site_menu

 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}")));
     }
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:7,代码来源:captionator_event.php

示例7: photo

 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"));
 }
开发者ID:xafr,项目名称:gallery3,代码行数:7,代码来源:gallery_menu.php

示例8: get

 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;
 }
开发者ID:Glooper,项目名称:gallery3-contrib,代码行数:28,代码来源:batchtag_block.php

示例9: make_album_cover

 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);
             }
         }
     }
 }
开发者ID:sandadze,项目名称:gallery3,代码行数:30,代码来源:item.php

示例10: site_menu

 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}")));
     }
 }
开发者ID:Glooper,项目名称:gallery3-contrib,代码行数:7,代码来源:embed_videos_event.php

示例11: sidebar_blocks

 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;
     }
 }
开发者ID:kuranoglu,项目名称:gallery3-contrib,代码行数:27,代码来源:batchtag_theme.php

示例12: tagitems

 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}"));
 }
开发者ID:kuranoglu,项目名称:gallery3-contrib,代码行数:26,代码来源:batchtag.php

示例13: album_menu

 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"));
     }
 }
开发者ID:Glooper,项目名称:gallery3-contrib,代码行数:7,代码来源:downloadalbum_event.php

示例14: download

 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);
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:26,代码来源:pear.php

示例15: required

 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();
                 }
             }
         }
     }
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:25,代码来源:MY_access.php


注:本文中的access::can方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。