/modules/mod_admin_modules/resources/resource_admin_module_manager.erl

http://github.com/zotonic/zotonic · Erlang · 47 lines · 24 code · 7 blank · 16 comment · 2 complexity · 34a7049b4b8a382fe959db32e6d9efcd MD5 · raw file

  1. %% @author Marc Worrell <marc@worrell.nl>
  2. %% @copyright 2009 Marc Worrell
  3. %% @doc Overview of modules, allows activating/deactivating the modules.
  4. %% Copyright 2009 Marc Worrell
  5. %%
  6. %% Licensed under the Apache License, Version 2.0 (the "License");
  7. %% you may not use this file except in compliance with the License.
  8. %% You may obtain a copy of the License at
  9. %%
  10. %% http://www.apache.org/licenses/LICENSE-2.0
  11. %%
  12. %% Unless required by applicable law or agreed to in writing, software
  13. %% distributed under the License is distributed on an "AS IS" BASIS,
  14. %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. %% See the License for the specific language governing permissions and
  16. %% limitations under the License.
  17. -module(resource_admin_module_manager).
  18. -author("Marc Worrell <marc@worrell.nl>").
  19. -export([
  20. is_authorized/2
  21. ]).
  22. -include_lib("resource_html.hrl").
  23. is_authorized(ReqData, Context) ->
  24. z_acl:wm_is_authorized(use, mod_admin_modules, ReqData, Context).
  25. html(Context) ->
  26. Status = z_module_manager:get_modules_status(Context),
  27. Selected = z_context:get(selected, Context, "modules"),
  28. Status1 = lists:flatten(
  29. [
  30. [ {Module, atom_to_list(State)} || {Module, _, _Pid, _Date} <- Specs ]
  31. || {State, Specs} <- Status
  32. ]),
  33. Vars = [
  34. {selected, Selected},
  35. {modules, mod_admin_modules:all(Context)},
  36. {status, Status1}
  37. ],
  38. Template = z_context:get(template, Context, "admin_modules.tpl"),
  39. Html = z_template:render(Template, Vars, Context),
  40. z_context:output(Html, Context).