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


PHP Surfer::may_handle方法代码示例

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


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

示例1: is_assigned

 /**
  * check that the surfer is an editor of an anchor
  *
  * This function is used to control the authority delegation from the anchor.
  * For example, if some editor is assigned to a complete section of the
  * web site, he/she should be able to edit all articles in this section.
  * you can use following code to check that:
  * [php]
  * $anchor = Anchors::get($article['anchor']);
  * if($anchor->is_assigned() {
  *	 ...
  * }
  * [/php]
  *
  * A logged member is always considered as an editor if he has created the target item.
  *
  * An anonymous surfer is considered as an editor if he has provided the secret handle.
  *
  * To be overloaded into derived class if field has a different name
  *
  * @param int optional reference to some user profile
  * @param boolean TRUE to climb the list of containers up to the top
  * @return TRUE or FALSE
  */
 function is_assigned($user_id = NULL, $cascade = TRUE)
 {
     global $context;
     // we need some data to proceed
     if (!isset($this->item['id'])) {
         return FALSE;
     }
     // id of requesting user
     if (!$user_id) {
         $user_id = Surfer::get_id();
     }
     // anonymous is allowed
     if (!$user_id) {
         $user_id = 0;
     }
     // create the cache
     if (!isset($this->is_assigned_cache)) {
         $this->is_assigned_cache = array();
     }
     // cache the answer
     if (isset($this->is_assigned_cache[$user_id])) {
         return $this->is_assigned_cache[$user_id];
     }
     // surfer has provided the secret handle
     if (isset($this->item['handle']) && Surfer::may_handle($this->item['handle'])) {
         return $this->is_assigned_cache[$user_id] = TRUE;
     }
     // surfer owns this item
     if ($user_id && isset($this->item['owner_id']) && $user_id == $this->item['owner_id']) {
         return $this->is_assigned_cache[$user_id] = TRUE;
     }
     // anchor has been assigned to this surfer
     if ($user_id && Members::check('user:' . $user_id, $this->get_reference())) {
         return $this->is_assigned_cache[$user_id] = TRUE;
     }
     // anonymous edition is allowed
     if ($this->item['active'] == 'Y' && $this->has_option('anonymous_edit')) {
         return $this->is_assigned_cache[$user_id] = TRUE;
     }
     // members edition is allowed
     if ($this->item['active'] == 'Y' && Surfer::is_empowered('M') && $this->has_option('members_edit')) {
         return $this->is_assigned_cache[$user_id] = TRUE;
     }
     // check parent container
     if ($cascade && isset($this->item['anchor'])) {
         // save requests
         if (!isset($this->anchor) || !$this->anchor) {
             $this->anchor = Anchors::get($this->item['anchor']);
         }
         // check for ownership
         if (is_object($this->anchor)) {
             return $this->is_assigned_cache[$user_id] = $this->anchor->is_assigned($user_id);
         }
     }
     // sorry
     return $this->is_assigned_cache[$user_id] = FALSE;
 }
开发者ID:rair,项目名称:yacs,代码行数:81,代码来源:anchor.php

示例2: allow_modification

 /**
  * check if a section can be modified
  *
  * This function returns TRUE if the section can be modified,
  * and FALSE otherwise.
  *
  * @param array a set of item attributes, aka, the target section
  * @param object an instance of the Anchor interface
  * @return TRUE or FALSE
  */
 public static function allow_modification($item, $anchor = NULL)
 {
     global $context;
     // sanity check
     if (!isset($item['id']) && !$anchor) {
         return FALSE;
     }
     // surfer is an associate
     if (Surfer::is_associate()) {
         return TRUE;
     }
     // submissions have been disallowed
     if (isset($context['users_without_submission']) && $context['users_without_submission'] == 'Y') {
         return FALSE;
     }
     // surfer owns the container or the section
     if (Sections::is_owned($item, $anchor, TRUE)) {
         return TRUE;
     }
     // allow editor of parent section, if not subscriber, to manage content, except on private sections
     if (Surfer::is_member() && is_object($anchor) && !$anchor->is_hidden() && $anchor->is_assigned()) {
         return TRUE;
     }
     // section has been locked
     if (isset($item['locked']) && $item['locked'] == 'Y') {
         return FALSE;
     }
     // maybe this anonymous surfer is allowed to handle this item
     if (isset($item['handle']) && Surfer::may_handle($item['handle'])) {
         return TRUE;
     }
     // community wiki
     if (Surfer::is_logged() && Sections::has_option('members_edit', $anchor, $item)) {
         return TRUE;
     }
     // public wiki
     if (Sections::has_option('anonymous_edit', $anchor, $item)) {
         return TRUE;
     }
     // default case
     return FALSE;
 }
开发者ID:rair,项目名称:yacs,代码行数:52,代码来源:sections.php

示例3: allow_modification

 /**
  * check if an article can be modified
  *
  * This function returns TRUE if the page can be modified,
  * and FALSE otherwise.
  *
  * @param array a set of item attributes, aka, the target article
  * @param object an instance of the Anchor interface
  * @return TRUE or FALSE
  */
 public static function allow_modification($item, $anchor)
 {
     global $context;
     // sanity check
     if (!isset($item['id']) && !$anchor) {
         return FALSE;
     }
     // surfer is an associate
     if (Surfer::is_associate()) {
         return TRUE;
     }
     // ensure access rights
     if (!Articles::allow_access($item, $anchor)) {
         return FALSE;
     }
     // submissions have been disallowed
     if (isset($context['users_without_submission']) && $context['users_without_submission'] == 'Y') {
         return FALSE;
     }
     // surfer owns the container or the article
     if (Articles::is_owned($item, $anchor)) {
         return TRUE;
     }
     // allow section editors to manage content, except on private sections
     if (Surfer::is_member() && is_object($anchor) && !$anchor->is_hidden() && $anchor->is_assigned()) {
         return TRUE;
     }
     // allow page editors to manage content, except on private page
     if (Surfer::is_member() && $item['active'] != 'N' && Articles::is_assigned($item['id'])) {
         return TRUE;
     }
     // article has been locked
     if (isset($item['locked']) && $item['locked'] == 'Y') {
         return FALSE;
     }
     // maybe this anonymous surfer is allowed to handle this item
     if (isset($item['handle']) && Surfer::may_handle($item['handle'])) {
         return TRUE;
     }
     // community wiki
     if (Surfer::is_logged() && Articles::has_option('members_edit', $anchor, $item)) {
         return TRUE;
     }
     // public wiki
     if (Articles::has_option('anonymous_edit', $anchor, $item)) {
         return TRUE;
     }
     // default case
     return FALSE;
 }
开发者ID:rair,项目名称:yacs,代码行数:60,代码来源:articles.php

示例4: allow_access

 /**
  * check if a file can be accessed
  *
  * This function returns TRUE if the item can be transferred to surfer,
  * and FALSE otherwise.
  *
  * @param array a set of item attributes, aka, the target file
  * @param object an instance of the Anchor interface, if any
  * @return boolean TRUE or FALSE
  */
 public static function allow_access($item, $anchor)
 {
     global $context;
     // surfer is an associate
     if (Surfer::is_associate()) {
         return TRUE;
     }
     // surfer has uploaded this file
     if (isset($item['create_id']) && Surfer::is($item['create_id'])) {
         return TRUE;
     }
     // the file is anchored to the profile of this member
     if (Surfer::is_member() && !strcmp($item['anchor'], 'user:' . Surfer::get_id())) {
         return TRUE;
     }
     // the anchor or overlay-in-anchor allows for file download --see overlays/bbb_meeting.php for example
     if (is_object($anchor) && is_callable(array($anchor, 'allows')) && $anchor->allows('fetch', 'file')) {
         return TRUE;
     }
     // anonymous surfer has provided the secret handle
     if (isset($item['handle']) && Surfer::may_handle($item['handle'])) {
         return TRUE;
     }
     // surfer is an editor
     if (is_object($anchor) && $anchor->is_assigned()) {
         return TRUE;
     }
     // surfer is a trusted host
     if (Surfer::is_trusted()) {
         return TRUE;
     }
     // container is hidden
     if (isset($item['active']) && $item['active'] == 'N') {
         return FALSE;
     }
     if (is_object($anchor) && $anchor->is_hidden()) {
         return FALSE;
     }
     // surfer is logged
     if (Surfer::is_logged()) {
         return TRUE;
     }
     // container is restricted
     if (isset($item['active']) && $item['active'] == 'R') {
         return FALSE;
     }
     if (is_object($anchor) && !$anchor->is_public()) {
         return FALSE;
     }
     // public page
     return TRUE;
 }
开发者ID:rair,项目名称:yacs,代码行数:62,代码来源:files.php

示例5: elseif

    $anchor = Anchors::get($item['anchor']);
}
// editors can do what they want on items anchored here
if (Surfer::is_member() && is_object($anchor) && $anchor->is_assigned()) {
    Surfer::empower();
} elseif (isset($item['id']) && Articles::is_assigned($item['id']) && Surfer::is_member()) {
    Surfer::empower();
} elseif (Surfer::is_logged() && is_object($anchor) && $anchor->is_assigned()) {
    Surfer::empower('S');
} elseif (isset($item['id']) && Articles::is_assigned($item['id']) && Surfer::is_logged()) {
    Surfer::empower('S');
} elseif (isset($item['options']) && $item['options'] && preg_match('/\\banonymous_edit\\b/i', $item['options'])) {
    Surfer::empower();
} elseif (Surfer::is_member() && isset($item['options']) && $item['options'] && preg_match('/\\bmembers_edit\\b/i', $item['options'])) {
    Surfer::empower();
} elseif (isset($item['handle']) && Surfer::may_handle($item['handle'])) {
    Surfer::empower();
}
//
// is this surfer allowed to browse the page?
//
// associates, editors and readers can read this page
if (Surfer::is_empowered('S')) {
    $permitted = TRUE;
} elseif (isset($item['create_id']) && Surfer::is($item['create_id'])) {
    $permitted = TRUE;
} elseif (is_object($anchor) && !$anchor->is_viewable()) {
    $permitted = FALSE;
} elseif (isset($item['active']) && $item['active'] == 'R' && Surfer::is_logged()) {
    $permitted = TRUE;
} elseif (isset($item['active']) && $item['active'] == 'Y') {
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:fetch_as_csv.php


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