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

/modules/mod_mailinglist/resources/resource_admin_mailing_status.erl

https://code.google.com/p/zotonic/
Erlang | 48 lines | 22 code | 9 blank | 17 comment | 0 complexity | c36e0e736d08a57f7ff20efb596fb402 MD5 | raw file
 1%% @author Arjan Scherpenisse <arjan@scherpenisse.net>
 2%% @copyright 2011 Arjan Scherpenisse
 3%% @doc Mailing status/control page
 4
 5%% Copyright 2011 Arjan Scherpenisse
 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_mailing_status).
20-author("Arjan Scherpenisse <arjan@scherpenisse.net>").
21
22-export([
23    resource_exists/2,
24    is_authorized/2
25]).
26
27-include_lib("resource_html.hrl").
28
29%% @todo Change this into "visible" and add a view instead of edit template.
30is_authorized(ReqData, Context) ->
31    {Context2, Id} = resource_admin_edit:ensure_id(?WM_REQ(ReqData, Context)),
32    z_acl:wm_is_authorized([{use, mod_mailinglist}, {view, Id}], Context2).
33
34
35resource_exists(ReqData, Context) ->
36    {Context2, Id} = resource_admin_edit:ensure_id(?WM_REQ(ReqData, Context)),
37    case Id of
38        undefined -> ?WM_REPLY(false, Context2);
39        _N -> ?WM_REPLY(m_rsc:exists(Id, Context2), Context2)
40    end.
41        
42
43html(Context) ->
44    Vars = [
45        {id, z_context:get(id, Context)}
46    ],
47    Html = z_template:render({cat, "admin_mailing_status.tpl"}, Vars, Context),
48	z_context:output(Html, Context).