本文整理汇总了PHP中access::update_htaccess_files方法的典型用法代码示例。如果您正苦于以下问题:PHP access::update_htaccess_files方法的具体用法?PHP access::update_htaccess_files怎么用?PHP access::update_htaccess_files使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类access
的用法示例。
在下文中一共展示了access::update_htaccess_files方法的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));
}
示例2: _set
/**
* Internal method to set a permission
*
* @param Group_Model $group
* @param string $perm_name
* @param Item_Model $item
* @param boolean $value
*/
private static function _set(Group_Definition $group, $perm_name, $album, $value)
{
if (!$group instanceof Group_Definition) {
throw new Exception("@todo PERMISSIONS_ONLY_WORK_ON_GROUPS");
}
if (!$album->loaded()) {
throw new Exception("@todo INVALID_ALBUM {$album->id}");
}
if (!$album->is_album()) {
throw new Exception("@todo INVALID_ALBUM_TYPE not an album");
}
$access = model_cache::get("access_intent", $album->id, "item_id");
$access->__set("{$perm_name}_{$group->id}", $value);
$access->save();
if ($perm_name == "view") {
self::_update_access_view_cache($group, $album);
} else {
self::_update_access_non_view_cache($group, $perm_name, $album);
}
access::update_htaccess_files($album, $group, $perm_name, $value);
model_cache::clear();
}
示例3: fix
//.........这里部分代码省略.........
$stack[] = "{$parent_id}:{$base_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_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;