private function _get_admin_form() { $form = new Forge("admin/hide/save", "", "post", array("id" => "g-hide-admin-form")); $form->dropdown("access_permissions")->label(t("Who can see hidden items?"))->options(hide::get_groups_as_dropdown_options())->selected(module::get_var("hide", "access_permissions")); $form->submit("save")->value(t("Save")); return $form; }
function children($limit = null, $offset = null, $where = array(), $order_by = null) { if (!hide::can_view_hidden_items($this)) { $this->join("hidden_items", "items.id", "hidden_items.item_id", "LEFT OUTER"); $this->where("hidden_items.item_id", "IS", NULL); return parent::children($limit, $offset, $where, $order_by); } }
/** * Checks whether the given object can be hidden by the active user. * * @param Item_Model $item the item */ private function _check_hide_permissions(Item_Model $item) { access::verify_csrf(); access::required("view", $item); access::required("edit", $item); if (!hide::can_hide()) { access::forbidden(); } }
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; }
/** * Returns some data used to create a hide link. * * @param Item_Model $item the related item * @return array */ private static function _get_hide_link_data(Item_Model $item) { if (hide::is_hidden($item)) { $action = "show"; $action_label = "Show"; } else { $action = "hide"; $action_label = "Hide"; } switch ($item->type) { case "movie": $item_type_label = "movie"; break; default: $item_type_label = "photo"; break; } $label = t("{$action_label} this {$item_type_label}"); return array("text" => $label, "action" => $action); }