m_rsc_gone (zotonic_core v1.0.0-rc.17)

This model tracks deleted resources (see m_rsc). Its primary goal is to be able to determine if a resource never existed, has been deleted or has been replaced by another resource.

Information kept

Only very basic information of the deleted resource is kept in the rsc_gone table. It is enough for referring to a new location, giving correct errors or to determine who deleted a resource.

It is not enough to undelete a resource. The module mod_backup retains enough information about past versions to be able to undelete a resource. Currently there is no support for an undelete.

Properties

Whenever a m_rsc record is deleted some information from that resource is copied to the rsc_gone table.

The following properties are saved:

PropertyDescriptionExample value
idId of the resource, an integer.42
new_idIf the resource is replaced by another resource then this is the id of that other resource.341
new_uriIf the resource is moved to another place on the web then this is the uri of the new location.<<"<http://example.com/hello>">>
nameThe name (if any) of the deleted resource.<<"page_hello">>
uriThe uri of the authoritative source for the resource.<<"<http://foo.bar/hello>">>
page_pathThe page path (if any) of the deleted resource.<<"/hello">>
is_authoritativeWhether the resource originated on this site or was imported and maintained on another site. Return a boolean.true
creator_idThe id of the creator of the deleted resource.1
createdThe date the deleted resource was created.{{2008,12,10},{15,30,00}}
modifier_idThe id of the user that deleted the resource.2718
modifiedThe date the resource was deleted.{{2012,12,5},{23,59,59}}

Available Model API Paths

MethodPath patternDescription
get/+id/new_location/...Return category data for +id. Uses get_new_location.
get/+id/is_gone/...Return whether gone (is_gone).

/+name marks a variable path segment. A trailing /... means extra path segments are accepted for further lookups.

See also

The Zotonic data model, m_rsc

Summary

Functions

delete(Id, Context)

-spec delete(Id, Context) -> ok | {error, enoent} when Id :: m_rsc:resource_id(), Context :: z:context().

get/2

get_new_location/2

get_uri/2

-spec get_uri(binary() | string(), z:context()) -> proplists:proplist() | undefined.

gone(Id, Context)

-spec gone(m_rsc:resource_id(), z:context()) -> {ok, integer()} | {error, term()}.

gone(Id, NewId, Context)

install(Context)

-spec install(z:context()) -> ok.

is_gone/2

-spec is_gone(m_rsc:resource_id() | undefined, z:context()) -> boolean().

is_gone_uri/2

-spec is_gone_uri(string() | binary() | undefined, z:context()) -> boolean().

m_get/3