<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Admin Pages</title><meta name="generator" content="DocBook XSL Stylesheets V1.64.1"><link rel="home" href="index.html" title="OpenACS Core Documentation"><link rel="up" href="tutorial-advanced.html" title="Chapter�10.�Advanced Topics"><link rel="previous" href="tutorial-comments.html" title="Adding Comments"><link rel="next" href="tutorial-categories.html" title="Categories"><link rel="stylesheet" href="openacs.css" type="text/css"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><a href="http://openacs.org"><img src="/doc/images/alex.jpg" border="0" alt="Alex logo"></a><table width="100%" summary="Navigation header" border="0"><tr><td width="20%" align="left"><a accesskey="p" href="tutorial-comments.html">Prev</a> </td><th width="60%" align="center">Chapter�10.�Advanced Topics</th><td width="20%" align="right"> <a accesskey="n" href="tutorial-categories.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="tutorial-admin-pages"></a>Admin Pages</h2></div></div><div></div></div><p> There are at least two flavors of admin user interface: </p><div class="itemizedlist"><ul type="disc"><li><p>Admins use same pages as all other users, except that they are offered admin links and buttons where appropriate. For example, if admins have privilege to bulk-delete items you could provide checkboxes next to every item seen on a list and the Delete Selected button on the bottom of the list. </p></li><li><p>Dedicated admin pages. If you want admins to have access to data that users aren't interested in or aren't allowed to see you will need dedicated admin pages. The conventional place to put those dedicated admin pages is in the <tt class="computeroutput">/var/lib/aolserver/<span class="replaceable"><span class="replaceable">service0</span></span>/packages/myfirstpackage/www/admin</tt> directory. </p><pre class="screen">[service0 www]$ <b class="userinput"><tt>mkdir admin</tt></b></pre><pre class="screen">[service0 www]$ <b class="userinput"><tt>cd admin</tt></b></pre><p> Even if your application doesn't need any admin pages of its own you will usually need at least one simple page with a bunch of links to existing administration UI such as Category Management or standard Parameters UI. Adding the link to Category Management is described in the section on categories. The listing below adds a link to the Parameters UI of our package. </p><pre class="screen">[service0 admin]$ <b class="userinput"><tt>vi index.adp</tt></b></pre><pre class="programlisting"> <master> <property name="title">@title;noquote@</property> <property name="context">@context;noquote@</property> <ul class="action-links"> <li><a href="@parameters_url@" title="Set parameters" class="action_link">Set parameters</a></li> </ul> </pre><pre class="screen">[service0 admin]$ <b class="userinput"><tt>vi index.tcl</tt></b></pre><pre class="programlisting"> ad_page_contract {} { } -properties { context_bar } set package_id [ad_conn package_id] permission::require_permission \ -object_id $package_id \ -privilege admin] set context [list] set title "Administration" set parameters_url [export_vars -base "/shared/parameters" { package_id { return_url [ad_return_url] } }] </pre><p> Now that you have the first admin page it would be nice to have a link to it somewhere in the system so that admins don't have to type in the <tt class="computeroutput">/admin</tt> every time they need to reach it. You could put a static link to the toplevel <tt class="computeroutput">index.adp</tt> but that might be distracting for people who are not admins. Besides, some people consider it impolite to first offer a link and then display a nasty "You don't have permission to access this page" message. </p><p> In order to display the link to the admin page only to users that have admin privileges add the following code near the top of <tt class="computeroutput">/var/lib/aolserver/<span class="replaceable"><span class="replaceable">service0</span></span>/packages/myfirstpackage/www/admin/index.tcl</tt>: </p><pre class="programlisting"> set package_id [ad_conn package_id] set admin_p [permission::permission_p -object_id $package_id \ -privilege admin -party_id [ad_conn untrusted_user_id]] if { $admin_p } { set admin_url "admin" set admin_title Administration } </pre><p> In <tt class="computeroutput">/var/lib/aolserver/<span class="replaceable"><span class="replaceable">service0</span></span>/packages/myfirstpackage/www/admin/index.adp</tt> put: </p><pre class="programlisting"> <if @admin_p@ ne nil> <a href="@admin_url@">@admin_title@</a> </if> </pre></li></ul></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="tutorial-comments.html">Prev</a> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right"> <a accesskey="n" href="tutorial-categories.html">Next</a></td></tr><tr><td width="40%" align="left">Adding Comments </td><td width="20%" align="center"><a accesskey="u" href="tutorial-advanced.html">Up</a></td><td width="40%" align="right"> Categories</td></tr></table><hr><address><a href="mailto:docs@openacs.org">docs@openacs.org</a></address></div><a name="comments"></a><center><a href="http://openacs.org/doc/tutorial-admin-pages.html#comments">View comments on this page at openacs.org</a></center></body></html>