static function remove_album_cover($album) { parent::remove_album_cover($album); if ($album->id > 1) { aws_s3::remove_album_cover($album); } }
static function viewable($model) { $model = parent::viewable($model); if (star::show_only_starred_items($model)) { // only fetches items that are starred $model->join("starred_items", "items.id", "starred_items.item_id", "LEFT OUTER")->and_where("starred_items.item_id", "IS", TRUE); } return $model; }
static function viewable($model) { $model = parent::viewable($model); if (!hide::can_view_hidden_items($model)) { // only fetches items that are not hidden $model->join("hidden_items", "items.id", "hidden_items.item_id", "LEFT OUTER")->and_where("hidden_items.item_id", "IS", NULL); } return $model; }
static function viewable($model) { // Hide password protected albums until the correct password is entered, // unless the current user is an admin, or the albums owner. $model = item_Core::viewable($model); // If the user is an admin, don't hide anything anything. // If not, hide whatever is restricted by an album password // that the current user is not the owner of. if (!identity::active_user()->admin) { $model->and_open()->join("items_albumpasswords", "items.id", "items_albumpasswords.album_id", "LEFT OUTER")->and_where("items_albumpasswords.album_id", "IS", NULL)->or_where("items_albumpasswords.password", "=", cookie::get("g3_albumpassword"))->or_where("items.owner_id", "=", identity::active_user()->id)->close(); } return $model; }
static function viewable($model) { // Hide password protected albums until the correct password is entered, // unless the current user is an admin, or the albums owner. $model = item_Core::viewable($model); // If the user is an admin, don't hide anything anything. // If not, hide whatever is restricted by an album password // that the current user is not the owner of. if (!identity::active_user()->admin) { // Display items that are not in idcaches. $model->and_open()->join("albumpassword_idcaches", "items.id", "albumpassword_idcaches.item_id", "LEFT OUTER")->and_where("albumpassword_idcaches.item_id", "IS", NULL); // If in hide only mode, check and see if the current item is protected. // If it is, log the user in with the password to view it. if (module::get_var("albumpassword", "hideonly") == true) { $existing_cacheditem = ORM::factory("albumpassword_idcache")->where("item_id", "=", $model->id)->order_by("cache_id")->find_all(); if (count($existing_cacheditem) > 0) { $existing_cacheditem_password = ORM::factory("items_albumpassword")->where("id", "=", $existing_cacheditem[0]->password_id)->find_all(); if (cookie::get("g3_albumpassword") != $existing_cacheditem_password[0]->password) { cookie::set("g3_albumpassword", $existing_cacheditem_password[0]->password); cookie::set("g3_albumpassword_id", $existing_cacheditem_password[0]->id); $model->or_where("albumpassword_idcaches.password_id", "=", $existing_cacheditem_password[0]->id); } } } // ... Unless their password id corresponds with a valid password. $existing_password = ORM::factory("items_albumpassword")->where("password", "=", cookie::get("g3_albumpassword"))->find_all(); if (count($existing_password) > 0) { foreach ($existing_password as $one_password) { if (cookie::get("g3_albumpassword_id") != "") { if (cookie::get("g3_albumpassword_id") == $one_password->id) { $model->or_where("albumpassword_idcaches.password_id", "=", $one_password->id); } } else { $model->or_where("albumpassword_idcaches.password_id", "=", $one_password->id); } } } // Or the current user is the owner of the item. $model->or_where("items.owner_id", "=", identity::active_user()->id)->close(); } return $model; }
static function root() { return user_chroot::album() ? user_chroot::album() : parent::root(); }