PageRenderTime 14ms CodeModel.GetById 10ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 5%% Copyright 2009 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
19-module(resource_admin_module_manager).
20-author("Marc Worrell <marc@worrell.nl>").
21
22-export([
23    is_authorized/2
24]).
25
26-include_lib("resource_html.hrl").
27
28is_authorized(ReqData, Context) ->
29    z_acl:wm_is_authorized(use, mod_admin_modules, ReqData, Context).
30
31
32html(Context) ->
33    Status = z_module_manager:get_modules_status(Context),
34    Selected = z_context:get(selected, Context, "modules"),
35    Status1 = lists:flatten(
36                    [ 
37                        [ {Module, atom_to_list(State)} || {Module, _, _Pid, _Date} <- Specs ] 
38                        || {State, Specs} <- Status 
39                    ]),
40    Vars = [
41        {selected, Selected},
42        {modules, mod_admin_modules:all(Context)},
43        {status, Status1}
44    ],
45    Template = z_context:get(template, Context, "admin_modules.tpl"),
46	Html = z_template:render(Template, Vars, Context),
47	z_context:output(Html, Context).