Index: openacs-4/packages/acs-core-docs/www/xml/developers-guide/i18n.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/xml/developers-guide/i18n.xml,v diff -u -N -r1.8 -r1.9 --- openacs-4/packages/acs-core-docs/www/xml/developers-guide/i18n.xml 26 Jan 2004 15:39:44 -0000 1.8 +++ openacs-4/packages/acs-core-docs/www/xml/developers-guide/i18n.xml 2 Feb 2004 08:32:36 -0000 1.9 @@ -305,7 +305,7 @@ - + Checking the Consistency of Catalog Files Index: openacs-4/packages/acs-core-docs/www/xml/developers-guide/tutorial-advanced.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/xml/developers-guide/tutorial-advanced.xml,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/acs-core-docs/www/xml/developers-guide/tutorial-advanced.xml 26 Jan 2004 15:39:44 -0000 1.6 +++ openacs-4/packages/acs-core-docs/www/xml/developers-guide/tutorial-advanced.xml 2 Feb 2004 08:32:36 -0000 1.7 @@ -50,7 +50,7 @@ from scratch, start by copying the documentation template from /var/lib/aolserver/openacs-dev/packages/acs-core-docs/xml/docs/xml/package-documentation-template.xml to - yourpackage/www/docs/xml/index.xml. + myfirstpackage/www/docs/xml/index.xml. You then edit that file with emacs to write the requirements and design sections, generate the html, and start coding. Store any supporting files, like page maps or schema @@ -251,7 +251,7 @@ form generated by the ad_form command with the matching name. Test it by adding the new files in the APM and then deleting a few samplenotes. - General_comments + General comments You can track comments for any ACS Object. Here we'll track comments for notes. On the notes.tcl/adp pair, which is used to display individual notes, we want to put a link to add comments at @@ -283,7 +283,233 @@ <a href="@comment_add_url@">Add a comment</a> @comments_html@ + + Admin Pages + + There are at least two flavors of admin user interface: + + + 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. + + 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 +/var/lib/aolserver/service0/packages/myfirstpackage/www/admin +directory. + +[service0@yourserver www]$ mkdir admin +[service0@yourserver www]$ cd admin + + 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. + +[service0@yourserver admin]$ vi index.adp + +<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> + +[service0@yourserver admin]$ vi index.tcl + +ad_page_contract {} { +} -properties { + context_bar +} + +set package_id [ad_conn package_id] + +set admin_p [ad_require_permission $package_id admin] + +set context [list] + +set title "Administration" + +set parameters_url [export_vars -base "/shared/parameters" { + package_id { return_url [ad_return_url] } +}] + + + + +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 +/admin every time they need to reach it. You +could put a static link to the toplevel +index.adp 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. + + +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 +/var/lib/aolserver/service0/packages/myfirstpackage/www/admin/index.tcl: + + + +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 +} + + +In +/var/lib/aolserver/service0/packages/myfirstpackage/www/admin/index.adp put: + + +<if @admin_p@ ne nil> + <a href="@admin_url@">@admin_title@</a> +</if> + + + + + + + + + Categories + + You can associate any ACS Object with one or more categories. + In this tutorial we'll show how to equip your application with user + interface to take advantage of the Categories service. + + + We'll start by installing the Categories service. Go to + /acs/admin and install it. This step + won't be necessary for the users of your applications because you'll create + a dependency with the Package Manager which will take care that the + Categories service always gets installed when your application gets + installed. + + + Now that we have installed the Categories service we can proceed to + modifying our application so that it can take advantage of it. We'll do it + in three steps: + + + + The Categories service provides a mechanism to associate one or + more category trees that are relevant to + your application. One example of such tree is a tree of + geographical locations. Continents are on the top of such tree, + each continent containing countries etc. Another tree might + contain market segments etc. Before users of your application + can take advantage of the Categories service there needs to be a + way for administrators of your application to choose which + category trees are applicable for the application. + + + + The way to achieve this is is to provide a link + to the Category Management pages. Add the following snippet to your + /var/lib/aolserver/service0/packages/myfirstpackage/www/admin/index.tcl + file: + + +set category_map_url [export_vars -base \ + "[site_node::get_package_url -package_key categories]cadmin/one-object" \ + { { object_id $package_id } }] + + + and the following snippet to your + /var/lib/aolserver/service0/packages/myfirstpackage/www/admin/index.adp + file: + + +<li><a href="@category_map_url@" + class="action_link">Site-Wide Categories</a> + + The link created by the above code will take the admin to the generic + admin UI where he can pick category trees that make sense for this + application. The same UI also includes facilities to build and edit + category trees. Notice that the only parameter in this example is + package_id so that category trees + will be associated with the object identified by this + package_id. The categorization + service is actually more general than that: instead of + package_id you could use an ID of + some other object that serves as a "container" in your application. + For example, if your discussion forums application supports multiple + forums you would use forum_id to + associate category trees with just that one forum rather than the + entire application instance. + + + Once the category trees have been selected users need a way + to categorize items. The easiest way to do this is by adding the + category widget type of the + form builder to note-edit.tcl. + To achieve this we'll need to use the -extend + switch to the ad_form command. Here's the "meat" of the + note-edit.tcl page: + +ad_form -name note -form { + {item_id:key} + {title:text {label Title}} +} + +set package_id [ad_conn package_id] + +set category_trees [category_tree::get_mapped_trees $package_id] + +foreach tree $category_trees { + foreach { tree_id name subtree_id } $tree {} + ad_form -extend -name note -form \ + [list [list category_id_${tree_id}:integer(category),optional \ + {label $name} \ + {html {single single}} \ + {category_tree_id $tree_id} \ + {category_subtree_id $subtree_id} \ + {category_object_id {[value_if_exists entry_id]}}]] +} + +ad_form -extend \ + -name note \ + -new_request { + permission::require_permission -object_id [ad_conn package_id] -privilege create + set page_title "Add a Note" + set context [list $page_title] +} -edit_request { + permission::require_write_permission -object_id $item_id + mfp::note::get \ + -item_id $item_id \ + -array note_array + + set title $note_array(title) + + set page_title "Edit a Note" + set context [list $page_title] +} -new_data { + mfp::note::add \ + -title $title +} -after_submit { + ad_returnredirect "." + ad_script_abort +} + + + + + Prepare the package for distribution. Browse to the package manager. Click on Index: openacs-4/packages/acs-core-docs/www/xml/developers-guide/tutorial-debug.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/xml/developers-guide/tutorial-debug.xml,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/acs-core-docs/www/xml/developers-guide/tutorial-debug.xml 11 Dec 2003 21:39:48 -0000 1.5 +++ openacs-4/packages/acs-core-docs/www/xml/developers-guide/tutorial-debug.xml 2 Feb 2004 08:32:36 -0000 1.6 @@ -43,7 +43,7 @@ log output To set up real-time monitoring of the AOLserver error - log, type less /usr/local/aolserver/log/openacs-dev-error.log + log, type less /var/lib/aolserver/service0/log/openacs-dev-error.log F to show new log entries in real time (like tail -f) C-c to stop and F to start it up again. G goes to the end. Index: openacs-4/packages/acs-core-docs/www/xml/developers-guide/tutorial-pages.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/xml/developers-guide/tutorial-pages.xml,v diff -u -N -r1.7 -r1.8 --- openacs-4/packages/acs-core-docs/www/xml/developers-guide/tutorial-pages.xml 26 Jan 2004 15:39:44 -0000 1.7 +++ openacs-4/packages/acs-core-docs/www/xml/developers-guide/tutorial-pages.xml 2 Feb 2004 08:32:36 -0000 1.8 @@ -156,10 +156,11 @@ } permission::require_write_permission -object_id $item_id - +set title [item::get_title $item_id] mfp::note::delete -item_id $item_id +ad_returnredirect -message "Item $title deleted." "." -ad_returnredirect "." +