/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. %% Copyright 2011 Arjan Scherpenisse
  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_mailing_status).
  18. -author("Arjan Scherpenisse <arjan@scherpenisse.net>").
  19. -export([
  20. resource_exists/2,
  21. is_authorized/2
  22. ]).
  23. -include_lib("resource_html.hrl").
  24. %% @todo Change this into "visible" and add a view instead of edit template.
  25. is_authorized(ReqData, Context) ->
  26. {Context2, Id} = resource_admin_edit:ensure_id(?WM_REQ(ReqData, Context)),
  27. z_acl:wm_is_authorized([{use, mod_mailinglist}, {view, Id}], Context2).
  28. resource_exists(ReqData, Context) ->
  29. {Context2, Id} = resource_admin_edit:ensure_id(?WM_REQ(ReqData, Context)),
  30. case Id of
  31. undefined -> ?WM_REPLY(false, Context2);
  32. _N -> ?WM_REPLY(m_rsc:exists(Id, Context2), Context2)
  33. end.
  34. html(Context) ->
  35. Vars = [
  36. {id, z_context:get(id, Context)}
  37. ],
  38. Html = z_template:render({cat, "admin_mailing_status.tpl"}, Vars, Context),
  39. z_context:output(Html, Context).