PageRenderTime 20ms CodeModel.GetById 16ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/priv/sites/zotonic_status/zotonic_status.erl

http://github.com/zotonic/zotonic
Erlang | 47 lines | 18 code | 9 blank | 20 comment | 1 complexity | 57a2f38fcffbf4de1b377915225cdf7d MD5 | raw file
 1%% @author Marc Worrell <marc@worrell.nl>
 2%% @copyright 2011 Marc Worrell <marc@worrell.nl>
 3%% Date: 2011-12-23
 4
 5%% @doc Default Zotonic site, used when no other site can handle the supplied Host.
 6
 7%% Copyright 2011 Marc Worrell
 8%%
 9%% Licensed under the Apache License, Version 2.0 (the "License");
10%% you may not use this file except in compliance with the License.
11%% You may obtain a copy of the License at
12%% 
13%%     http://www.apache.org/licenses/LICENSE-2.0
14%% 
15%% Unless required by applicable law or agreed to in writing, software
16%% distributed under the License is distributed on an "AS IS" BASIS,
17%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18%% See the License for the specific language governing permissions and
19%% limitations under the License.
20
21-module(zotonic_status).
22-author("Marc Worrell <marc@worrell.nl>").
23
24-mod_title("Zotonic Status").
25-mod_descr("Default Zotonic site, used when no other site can handle the supplied Host.").
26-mod_prio(10).
27-mod_depends([base, bootstrap]).
28
29-export([
30    observe_user_is_enabled/2,
31    observe_acl_logon/2,
32    observe_acl_logoff/2
33]).
34
35-include_lib("zotonic.hrl").
36
37%% @doc Check if an user is enabled.
38observe_user_is_enabled(#user_is_enabled{id=UserId}, _Context) ->
39    UserId == 1.
40
41%% @doc Let the user log on, this is the moment to start caching information.
42observe_acl_logon(#acl_logon{id=UserId}, Context) ->
43    Context#context{user_id=UserId}.
44
45%% @doc Let the user log off, clean up any cached information.
46observe_acl_logoff(#acl_logoff{}, Context) ->
47    Context#context{acl=undefined, user_id=undefined}.