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


PHP access::required方法代码示例

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


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

示例1: 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

示例2: get

 static function get($request)
 {
     $item = rest::resolve($request->url);
     access::required("view", $item);
     $checksums = array(rest::url("itemchecksum_md5", $item), rest::url("itemchecksum_sha1", $item));
     return array("url" => $request->url, "members" => $checksums);
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:7,代码来源:item_itemchecksums_rest.php

示例3: _form_add

 public function _form_add($item_id)
 {
     $item = ORM::factory("item", $item_id);
     access::required("view", $item);
     access::required("edit", $item);
     return tag::get_add_form($item);
 }
开发者ID:krgeek,项目名称:gallery3,代码行数:7,代码来源:tags.php

示例4: change

 function change($command, $group_id, $perm_id, $item_id)
 {
     access::verify_csrf();
     $group = identity::lookup_group($group_id);
     $perm = ORM::factory("permission", $perm_id);
     $item = ORM::factory("item", $item_id);
     access::required("view", $item);
     access::required("edit", $item);
     if (!empty($group) && $perm->loaded() && $item->loaded()) {
         switch ($command) {
             case "allow":
                 access::allow($group, $perm->name, $item);
                 break;
             case "deny":
                 access::deny($group, $perm->name, $item);
                 break;
             case "reset":
                 access::reset($group, $perm->name, $item);
                 break;
         }
         // If the active user just took away their own edit permissions, give it back.
         if ($perm->name == "edit") {
             if (!access::user_can(identity::active_user(), "edit", $item)) {
                 access::allow($group, $perm->name, $item);
             }
         }
     }
 }
开发者ID:JasonWiki,项目名称:docs,代码行数:28,代码来源:permissions.php

示例5: get

 /**
  * The tree is rooted in a single item and can have modifiers which adjust what data is shown
  * for items inside the given tree, up to the depth that you want.  The entity for this resource
  * is a series of items.
  *
  *  depth=<number>
  *    Only traverse this far down into the tree.  If there are more albums
  *    below this depth, provide RESTful urls to other tree resources in
  *    the members section.  Default is infinite.
  *
  *  type=<album|photo|movie>
  *    Restrict the items displayed to the given type.  Default is all types.
  *
  *  fields=<comma separated list of field names>
  *    In the entity section only return these fields for each item.
  *    Default is all fields.
  */
 static function get($request)
 {
     $item = rest::resolve($request->url);
     access::required("view", $item);
     $query_params = array();
     $p = $request->params;
     $where = array();
     if (isset($p->type)) {
         $where[] = array("type", "=", $p->type);
         $query_params[] = "type={$p->type}";
     }
     if (isset($p->depth)) {
         $lowest_depth = $item->level + $p->depth;
         $where[] = array("level", "<=", $lowest_depth);
         $query_params[] = "depth={$p->depth}";
     }
     $fields = array();
     if (isset($p->fields)) {
         $fields = explode(",", $p->fields);
         $query_params[] = "fields={$p->fields}";
     }
     $entity = array(array("url" => rest::url("item", $item), "entity" => $item->as_restful_array($fields)));
     $members = array();
     foreach ($item->viewable()->descendants(null, null, $where) as $child) {
         $entity[] = array("url" => rest::url("item", $child), "entity" => $child->as_restful_array($fields));
         if (isset($lowest_depth) && $child->level == $lowest_depth) {
             $members[] = url::merge_querystring(rest::url("tree", $child), $query_params);
         }
     }
     $result = array("url" => $request->url, "entity" => $entity, "members" => $members, "relationships" => rest::relationships("tree", $item));
     return $result;
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:49,代码来源:tree_rest.php

示例6: delete

 static function delete($request)
 {
     $item = rest::resolve($request->url);
     access::required("edit", $item);
     // Deleting this collection means removing all tags associated with the item.
     tag::clear_all($item);
 }
开发者ID:assad2012,项目名称:gallery3-appfog,代码行数:7,代码来源:item_tags_rest.php

示例7: feed

 static function feed($feed_id, $offset, $limit, $id)
 {
     $feed = new stdClass();
     switch ($feed_id) {
         case "latest":
             $feed->items = ORM::factory("item")->viewable()->where("type", "<>", "album")->order_by("created", "DESC")->find_all($limit, $offset);
             $all_items = ORM::factory("item")->viewable()->where("type", "<>", "album")->order_by("created", "DESC");
             $feed->max_pages = ceil($all_items->find_all()->count() / $limit);
             $feed->title = t("%site_title - Recent updates", array("site_title" => item::root()->title));
             $feed->description = t("Recent updates");
             return $feed;
         case "album":
             $item = ORM::factory("item", $id);
             access::required("view", $item);
             $feed->items = $item->viewable()->descendants($limit, $offset, array(array("type", "=", "photo")));
             $feed->max_pages = ceil($item->viewable()->descendants_count(array(array("type", "=", "photo"))) / $limit);
             if ($item->id == item::root()->id) {
                 $feed->title = html::purify($item->title);
             } else {
                 $feed->title = t("%site_title - %item_title", array("site_title" => item::root()->title, "item_title" => $item->title));
             }
             $feed->description = nl2br(html::purify($item->description));
             return $feed;
     }
 }
开发者ID:Joe7,项目名称:gallery3,代码行数:25,代码来源:gallery_rss.php

示例8: add_photo

 public function add_photo($id)
 {
     $album = ORM::factory("item", $id);
     access::required("view", $album);
     access::required("add", $album);
     access::verify_csrf();
     $file_validation = new Validation($_FILES);
     $file_validation->add_rules("Filedata", "upload::valid", "upload::type[gif,jpg,png,flv,mp4]");
     if ($file_validation->validate()) {
         // SimpleUploader.swf does not yet call /start directly, so simulate it here for now.
         if (!batch::in_progress()) {
             batch::start();
         }
         $temp_filename = upload::save("Filedata");
         try {
             $name = substr(basename($temp_filename), 10);
             // Skip unique identifier Kohana adds
             $title = item::convert_filename_to_title($name);
             $path_info = pathinfo($temp_filename);
             if (array_key_exists("extension", $path_info) && in_array(strtolower($path_info["extension"]), array("flv", "mp4"))) {
                 $movie = movie::create($album, $temp_filename, $name, $title);
                 log::success("content", t("Added a movie"), html::anchor("movies/{$movie->id}", t("view movie")));
             } else {
                 $photo = photo::create($album, $temp_filename, $name, $title);
                 log::success("content", t("Added a photo"), html::anchor("photos/{$photo->id}", t("view photo")));
             }
         } catch (Exception $e) {
             unlink($temp_filename);
             throw $e;
         }
         unlink($temp_filename);
     }
     print "File Received";
 }
开发者ID:krgeek,项目名称:gallery3,代码行数:34,代码来源:simple_uploader.php

示例9: delete

 static function delete($request)
 {
     list($tag, $item) = rest::resolve($request->url);
     access::required("edit", $item);
     $tag->remove($item);
     $tag->save();
 }
开发者ID:JasonWiki,项目名称:docs,代码行数:7,代码来源:tag_items_rest.php

示例10: add_photo

 public function add_photo($id)
 {
     $album = ORM::factory("item", $id);
     access::required("view", $album);
     access::required("add", $album);
     access::verify_csrf();
     // The Flash uploader not call /start directly, so simulate it here for now.
     if (!batch::in_progress()) {
         batch::start();
     }
     $form = $this->_get_add_form($album);
     if ($form->validate()) {
         // Uploadify puts the result in $_FILES["Filedata"] - process it.
         try {
             list($tmp_name, $name) = $this->_process_upload("Filedata");
         } catch (Exception $e) {
             header("HTTP/1.1 400 Bad Request");
             print "ERROR: " . $e->getMessage();
             return;
         }
         // We have a valid upload file (of unknown type) - build an item from it.
         try {
             $item = $this->_add_item($id, $tmp_name, $name);
             module::event("add_photos_form_completed", $item, $form);
             print "FILEID: {$item->id}";
         } catch (Exception $e) {
             header("HTTP/1.1 500 Internal Server Error");
             print "ERROR: " . $e->getMessage();
         }
     } else {
         header("HTTP/1.1 400 Bad Request");
         print "ERROR: " . t("Invalid upload");
     }
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:34,代码来源:uploader.php

示例11: form_edit

 public function form_edit($movie_id)
 {
     $movie = ORM::factory("item", $movie_id);
     access::required("view", $movie);
     access::required("edit", $movie);
     print movie::get_edit_form($movie);
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:7,代码来源:movies.php

示例12: form_edit

 public function form_edit($photo_id)
 {
     $photo = ORM::factory("item", $photo_id);
     access::required("view", $photo);
     access::required("edit", $photo);
     print photo::get_edit_form($photo);
 }
开发者ID:JasonWiki,项目名称:docs,代码行数:7,代码来源:photos.php

示例13: albums

 public function albums($id)
 {
     $item = ORM::factory("item", $id);
     access::required("view", $item);
     $page = $this->input->get("page", 1);
     if ($page < 1) {
         url::redirect("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 ($max_pages && $page > $max_pages) {
         url::redirect("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("rss/albums/{$item->id}");
     $view->children = $children;
     if ($page > 1) {
         $previous_page = $page - 1;
         $view->previous_page_link = url::site("rss/albums/{$item->id}?page={$previous_page}");
     }
     if ($page < $max_pages) {
         $next_page = $page + 1;
         $view->next_page_link = url::site("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:xafr,项目名称:gallery3,代码行数:32,代码来源:rss.php

示例14: random

 public function random($item_id)
 {
     $item = ORM::factory("item", $item_id);
     access::required("view", $item);
     item::set_display_context_callback("Albums_Controller::get_display_context");
     url::redirect($item->abs_url());
 }
开发者ID:JasonWiki,项目名称:docs,代码行数:7,代码来源:image_block.php

示例15: map

 /**
  * Redirect Gallery 2 urls to their appropriate matching Gallery 3 url.
  *
  * We use mod_rewrite to create this path, so Gallery2 urls like this:
  *   /gallery2/v/Family/Wedding.jpg.html
  *   /gallery2/main.php?g2_view=core.ShowItem&g2_itemId=1234
  *
  * Show up here like this:
  *   /g2/map?path=v/Family/Wedding.jpg.html
  *   /g2/map?g2_view=core.ShowItem&g2_itemId=1931
  */
 public function map()
 {
     $input = Input::instance();
     $path = $input->get("path");
     $id = $input->get("g2_itemId");
     if ($path && $path != 'index.php' && $path != 'main.php' || $id) {
         if ($id) {
             // Requests by id are either core.DownloadItem or core.ShowItem requests. Later versions of
             // Gallery 2 don't specify g2_view if it's the default (core.ShowItem). And in some cases
             // (bbcode, embedding) people are using the id style URLs although URL rewriting is enabled.
             $where = array(array("g2_id", "=", $id));
             $view = $input->get("g2_view");
             if ($view == "core.DownloadItem") {
                 $where[] = array("resource_type", "IN", array("file", "resize", "thumbnail", "full"));
             } else {
                 if ($view) {
                     $where[] = array("g2_url", "like", "%g2_view={$view}%");
                 }
             }
             // else: Assuming that the first search hit is sufficiently good.
         } else {
             if ($path) {
                 $where = array(array("g2_url", "IN", array($path, str_replace(" ", "+", $path))));
             } else {
                 throw new Kohana_404_Exception();
             }
         }
         $g2_map = ORM::factory("g2_map")->merge_where($where)->find();
         if (!$g2_map->loaded()) {
             throw new Kohana_404_Exception();
         }
         $item = ORM::factory("item", $g2_map->g3_id);
         if (!$item->loaded()) {
             throw new Kohana_404_Exception();
         }
         $resource_type = $g2_map->resource_type;
     } else {
         $item = item::root();
         $resource_type = "album";
     }
     access::required("view", $item);
     // Redirect the user to the new url
     switch ($resource_type) {
         case "thumbnail":
             url::redirect($item->thumb_url(true));
         case "resize":
             url::redirect($item->resize_url(true));
         case "file":
         case "full":
             url::redirect($item->file_url(true));
         case "item":
         case "album":
             url::redirect($item->abs_url());
         case "group":
         case "user":
         default:
             throw new Kohana_404_Exception();
     }
 }
开发者ID:JasonWiki,项目名称:docs,代码行数:70,代码来源:g2.php


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