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