public function save() { model_cache::clear(); $result = parent::save(); $this->original = $this->object; return $result; }
static function remove_album_cover($album) { access::required("edit", $album); @unlink($album->thumb_path()); model_cache::clear("item", $album->album_cover_item_id); $album->album_cover_item_id = null; $album->thumb_width = 0; $album->thumb_height = 0; $album->thumb_dirty = 1; $album->save(); graphics::generate($album); }
public function save($source_id) { access::verify_csrf(); $source = ORM::factory("item", $source_id); $target = ORM::factory("item", Input::instance()->post("target_id")); access::required("view", $source); access::required("view", $target); access::required("edit", $target); model_cache::clear(); $target->album_cover_item_id = $source->is_album() ? $source->album_cover_item_id : $source->id; $target->thumb_dirty = 1; $target->save(); graphics::generate($target); $grand_parent = $target->parent(); if ($grand_parent && access::can("edit", $grand_parent) && $grand_parent->album_cover_item_id == null) { item::make_album_cover($target); } $msg = t("Made <b>%title</b> album's cover for <b>%album</b>", array("title" => html::purify($source->title), "album" => html::purify($target->title))); message::success($msg); json::reply(array("result" => "success")); }
/** * Move this item to the specified target. * @chainable * @param Item_Model $target Target item (must be an album) * @return ORM_MPTT */ function move_to($target) { if (!$target->is_album()) { throw new Exception("@todo INVALID_MOVE_TYPE {$target->type}"); } if ($this->id == 1) { throw new Exception("@todo INVALID_SOURCE root album"); } $original_path = $this->file_path(); $original_resize_path = $this->resize_path(); $original_thumb_path = $this->thumb_path(); $original_parent = $this->parent(); parent::move_to($target, true); model_cache::clear(); $this->relative_path_cache = null; rename($original_path, $this->file_path()); if ($this->is_album()) { @rename(dirname($original_resize_path), dirname($this->resize_path())); @rename(dirname($original_thumb_path), dirname($this->thumb_path())); Database::instance()->update("items", array("relative_path_cache" => null), array("left_ptr >" => $this->left_ptr, "right_ptr <" => $this->right_ptr)); } else { @rename($original_resize_path, $this->resize_path()); @rename($original_thumb_path, $this->thumb_path()); } module::event("item_moved", $this, $original_parent); return $this; }
/** * Internal method to add Permission/Group columns * * @param Group_Model $group * @param string $perm_name * @return void */ private static function _add_columns($perm_name, $group) { $db = Database::instance(); $field = "{$perm_name}_{$group->id}"; $cache_table = $perm_name == "view" ? "items" : "access_caches"; $db->query("ALTER TABLE {{$cache_table}} ADD `{$field}` SMALLINT NOT NULL DEFAULT 0"); $db->query("ALTER TABLE {access_intents} ADD `{$field}` BOOLEAN DEFAULT NULL"); $db->update("access_intents", array($field => 0), array("item_id" => 1)); model_cache::clear(); ORM::factory("access_intent")->clear_cache(); }
/** * Internal method to add Permission/Group columns * * @param Group_Model $group * @param string $perm_name * @return void */ private static function _add_columns($perm_name, $group) { $db = Database::instance(); $field = "{$perm_name}_{$group->id}"; $cache_table = $perm_name == "view" ? "items" : "access_caches"; $not_null = $cache_table == "items" ? "" : "NOT NULL"; $db->query("ALTER TABLE {{$cache_table}} ADD `{$field}` BINARY {$not_null} DEFAULT FALSE"); $db->query("ALTER TABLE {access_intents} ADD `{$field}` BINARY DEFAULT NULL"); $db->update("access_intents", array($field => self::DENY), array("item_id" => 1)); model_cache::clear(); ORM::factory("access_intent")->clear_cache(); }
static function remove_album_cover($album) { access::required("view", $album); access::required("edit", $album); model_cache::clear(); $album->album_cover_item_id = null; $album->save(); graphics::generate($album); }
/** * Internal method to add Permission/Group columns * * @param Group_Model $group * @param string $perm_name * @return void */ private static function _add_columns($perm_name, $group) { $field = "{$perm_name}_{$group->id}"; $cache_table = $perm_name == "view" ? "items" : "access_caches"; $not_null = $cache_table == "items" ? "" : "NOT NULL"; Database::instance()->query("ALTER TABLE {{$cache_table}} ADD `{$field}` BINARY {$not_null} DEFAULT FALSE"); Database::instance()->query("ALTER TABLE {access_intents} ADD `{$field}` BINARY DEFAULT NULL"); db::build()->update("access_intents")->set($field, access::DENY)->where("item_id", "=", 1)->execute(); model_cache::clear(); ORM::factory("access_intent")->clear_cache(); }
public function save() { model_cache::clear(); return parent::save(); }
public function save() { model_cache::clear($this->object_name, $this->{$this->primary_key}, $this->primary_key); return parent::save(); }
/** * Move this item to the specified target. * @chainable * @param Item_Model $target Target item (must be an album) * @return ORM_MPTT */ function move_to($target) { if (!$target->is_album()) { throw new Exception("@todo INVALID_MOVE_TYPE {$target->type}"); } if (file_exists($target_file = "{$target->file_path()}/{$this->name}")) { throw new Exception("@todo INVALID_MOVE_TARGET_EXISTS: {$target_file}"); } if ($this->id == 1) { throw new Exception("@todo INVALID_SOURCE root album"); } $original_path = $this->file_path(); $original_resize_path = $this->resize_path(); $original_thumb_path = $this->thumb_path(); $original_parent = $this->parent(); parent::move_to($target, true); model_cache::clear(); $this->relative_path_cache = null; rename($original_path, $this->file_path()); if ($this->is_album()) { @rename(dirname($original_resize_path), dirname($this->resize_path())); @rename(dirname($original_thumb_path), dirname($this->thumb_path())); db::build()->update("items")->set("relative_path_cache", null)->set("relative_url_cache", null)->where("left_ptr", ">", $this->left_ptr)->where("right_ptr", "<", $this->right_ptr)->execute(); } else { @rename($original_resize_path, $this->resize_path()); @rename($original_thumb_path, $this->thumb_path()); } module::event("item_moved", $this, $original_parent); return $this; }