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


PHP access::recalculate_album_permissions方法代码示例

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


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

示例1: fix


//.........这里部分代码省略.........
                 break;
             case self::FIX_STATE_RUN_DUPE_NAMES:
                 $stack = explode(" ", $task->get("stack"));
                 list($parent_id, $name) = explode(":", array_pop($stack));
                 $fixed = 0;
                 // We want to leave the first one alone and update all conflicts to be random values.
                 $conflicts = ORM::factory("item")->where("parent_id", "=", $parent_id)->where("name", "=", $name)->find_all(1, 1);
                 if ($conflicts->count() && ($conflict = $conflicts->current())) {
                     $task->log("Fixing conflicting name for item id {$conflict->id}");
                     db::build()->update("items")->set("name", $name . "-" . (string) rand(1000, 9999))->where("id", "=", $conflict->id)->execute();
                     // We fixed one conflict, but there might be more so put this parent back on the stack
                     // and try again.  We won't consider it completed when we don't fix a conflict.  This
                     // guarantees that we won't spend too long fixing one set of conflicts, and that we
                     // won't stop before all are fixed.
                     $stack[] = "{$parent_id}:{$name}";
                     break;
                 }
                 $task->set("stack", implode(" ", $stack));
                 $completed++;
                 if (empty($stack)) {
                     $state = self::FIX_STATE_START_ALBUMS;
                 }
                 break;
             case self::FIX_STATE_START_ALBUMS:
                 $stack = array();
                 foreach (db::build()->select("id")->from("items")->where("type", "=", "album")->execute() as $row) {
                     $stack[] = $row->id;
                 }
                 $task->set("stack", implode(" ", $stack));
                 $state = self::FIX_STATE_RUN_ALBUMS;
                 break;
             case self::FIX_STATE_RUN_ALBUMS:
                 $stack = explode(" ", $task->get("stack"));
                 $id = array_pop($stack);
                 $item = ORM::factory("item", $id);
                 if ($item->album_cover_item_id) {
                     $album_cover_item = ORM::factory("item", $item->album_cover_item_id);
                     if (!$album_cover_item->loaded()) {
                         $item->album_cover_item_id = null;
                         $item->save();
                     }
                 }
                 $everybody = identity::everybody();
                 $view_col = "view_{$everybody->id}";
                 $view_full_col = "view_full_{$everybody->id}";
                 $intent = ORM::factory("access_intent")->where("item_id", "=", $id)->find();
                 if ($intent->{$view_col} === access::DENY) {
                     access::update_htaccess_files($item, $everybody, "view", access::DENY);
                 }
                 if ($intent->{$view_full_col} === access::DENY) {
                     access::update_htaccess_files($item, $everybody, "view_full", access::DENY);
                 }
                 $task->set("stack", implode(" ", $stack));
                 $completed++;
                 if (empty($stack)) {
                     $state = self::FIX_STATE_START_MISSING_ACCESS_CACHES;
                 }
                 break;
             case self::FIX_STATE_START_MISSING_ACCESS_CACHES:
                 $stack = array();
                 foreach (self::find_missing_access_caches() as $row) {
                     $stack[] = $row->id;
                 }
                 if ($stack) {
                     $task->set("stack", implode(" ", $stack));
                     $state = self::FIX_STATE_RUN_MISSING_ACCESS_CACHES;
                 } else {
                     $state = self::FIX_STATE_DONE;
                 }
                 break;
             case self::FIX_STATE_RUN_MISSING_ACCESS_CACHES:
                 $stack = explode(" ", $task->get("stack"));
                 $id = array_pop($stack);
                 $access_cache = ORM::factory("access_cache");
                 $access_cache->item_id = $id;
                 $access_cache->save();
                 $task->set("stack", implode(" ", $stack));
                 $completed++;
                 if (empty($stack)) {
                     // The new cache rows are there, but they're incorrectly populated so we have to fix
                     // them.  If this turns out to be too slow, we'll have to refactor
                     // access::recalculate_permissions to allow us to do it in slices.
                     access::recalculate_album_permissions(item::root());
                     $state = self::FIX_STATE_DONE;
                 }
                 break;
         }
     }
     $task->set("state", $state);
     $task->set("completed", $completed);
     if ($state == self::FIX_STATE_DONE) {
         $task->done = true;
         $task->state = "success";
         $task->percent_complete = 100;
         module::set_var("gallery", "maintenance_mode", 0);
     } else {
         $task->percent_complete = round(100 * $completed / $total);
     }
     $task->status = t2("One operation complete", "%count / %total operations complete", $completed, array("total" => $total));
 }
开发者ID:JasonWiki,项目名称:docs,代码行数:101,代码来源:gallery_task.php

示例2: item_moved

 static function item_moved($item, $old_parent)
 {
     if ($item->is_album()) {
         access::recalculate_album_permissions($item->parent());
     } else {
         access::recalculate_photo_permissions($item);
     }
     // If the new parent doesn't have an album cover, make this it.
     if (!$item->parent()->album_cover_item_id) {
         item::make_album_cover($item);
     }
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:12,代码来源:gallery_event.php

示例3: fix


//.........这里部分代码省略.........
                 if ($item->album_cover_item_id) {
                     $album_cover_item = ORM::factory("item", $item->album_cover_item_id);
                     if (!$album_cover_item->loaded()) {
                         $item->album_cover_item_id = null;
                         $item->save();
                     }
                 }
                 $everybody = identity::everybody();
                 $view_col = "view_{$everybody->id}";
                 $view_full_col = "view_full_{$everybody->id}";
                 $intent = ORM::factory("access_intent")->where("item_id", "=", $id)->find();
                 if ($intent->{$view_col} === access::DENY) {
                     access::update_htaccess_files($item, $everybody, "view", access::DENY);
                 }
                 if ($intent->{$view_full_col} === access::DENY) {
                     access::update_htaccess_files($item, $everybody, "view_full", access::DENY);
                 }
                 $task->set("stack", implode(" ", $stack));
                 $completed++;
                 if (empty($stack)) {
                     $state = self::FIX_STATE_START_REBUILD_ITEM_CACHES;
                 }
                 break;
             case self::FIX_STATE_START_REBUILD_ITEM_CACHES:
                 $stack = array();
                 foreach (self::find_empty_item_caches(500) as $row) {
                     $stack[] = $row->id;
                 }
                 $task->set("stack", implode(" ", $stack));
                 $state = self::FIX_STATE_RUN_REBUILD_ITEM_CACHES;
                 break;
             case self::FIX_STATE_RUN_REBUILD_ITEM_CACHES:
                 $stack = explode(" ", $task->get("stack"));
                 if (!empty($stack)) {
                     $id = array_pop($stack);
                     $item = ORM::factory("item", $id);
                     $item->relative_path();
                     // this rebuilds the cache and saves the item as a side-effect
                     $task->set("stack", implode(" ", $stack));
                     $completed++;
                 }
                 if (empty($stack)) {
                     // Try refilling the stack
                     foreach (self::find_empty_item_caches(500) as $row) {
                         $stack[] = $row->id;
                     }
                     $task->set("stack", implode(" ", $stack));
                     if (empty($stack)) {
                         $state = self::FIX_STATE_START_MISSING_ACCESS_CACHES;
                     }
                 }
                 break;
             case self::FIX_STATE_START_MISSING_ACCESS_CACHES:
                 $stack = array();
                 foreach (self::find_missing_access_caches_limited(500) as $row) {
                     $stack[] = $row->id;
                 }
                 $task->set("stack", implode(" ", $stack));
                 $state = self::FIX_STATE_RUN_MISSING_ACCESS_CACHES;
                 break;
             case self::FIX_STATE_RUN_MISSING_ACCESS_CACHES:
                 $stack = array_filter(explode(" ", $task->get("stack")));
                 // filter removes empty/zero ids
                 if (!empty($stack)) {
                     $id = array_pop($stack);
                     $access_cache = ORM::factory("access_cache");
                     $access_cache->item_id = $id;
                     $access_cache->save();
                     $task->set("stack", implode(" ", $stack));
                     $completed++;
                 }
                 if (empty($stack)) {
                     // Try refilling the stack
                     foreach (self::find_missing_access_caches_limited(500) as $row) {
                         $stack[] = $row->id;
                     }
                     $task->set("stack", implode(" ", $stack));
                     if (empty($stack)) {
                         // The new cache rows are there, but they're incorrectly populated so we have to fix
                         // them.  If this turns out to be too slow, we'll have to refactor
                         // access::recalculate_permissions to allow us to do it in slices.
                         access::recalculate_album_permissions(item::root());
                         $state = self::FIX_STATE_DONE;
                     }
                 }
                 break;
         }
     }
     $task->set("state", $state);
     $task->set("completed", $completed);
     if ($state == self::FIX_STATE_DONE) {
         $task->done = true;
         $task->state = "success";
         $task->percent_complete = 100;
         module::set_var("gallery", "maintenance_mode", 0);
     } else {
         $task->percent_complete = round(100 * $completed / $total);
     }
     $task->status = t2("One operation complete", "%count / %total operations complete", $completed, array("total" => $total));
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:101,代码来源:gallery_task.php


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