Header Icon Alt Text: @header_alt_text@
This is what the header will look like:
-@header_text@
+ @header_text@
Index: openacs-4/packages/dotlrn/www/community-edit-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/community-edit-2.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/dotlrn/www/community-edit-2.tcl 5 Jun 2002 18:22:41 -0000 1.3
+++ openacs-4/packages/dotlrn/www/community-edit-2.tcl 13 Jun 2002 04:33:31 -0000 1.4
@@ -24,81 +24,92 @@
{header_font_color ""}
{header_font_size "Normal"}
{header_img ""}
- {header_img.tmpfile:tmpfile ""}
{header_alt_text ""}
}
+#
+# Some general stuff
+#
+
set user_id [ad_conn user_id]
+set creation_ip [ad_conn peeraddr]
set community_id [dotlrn_community::get_community_id]
-
dotlrn::require_user_admin_community -user_id $user_id $community_id
-
set page_title Preview
+set header_text [dotlrn_community::get_community_header_name $community_id]
#
-# # check the img if given
-# set n_bytes [file size ${header_img.tmpfile}]
-# set max_bytes [ad_parameter "MaximumFileSize"]
-# if { $n_bytes > $max_bytes } {
-# ad_complain "Your file is larger than the maximum file size allowed on this system ([util_commify_number $max_bytes] bytes)"
-# }
+# Image stuff
#
-# # get the public folder for this comm
-# set fs_package_id [dotlrn_community::get_applet_package_id $community_id [dotlrn_fs::applet_key]]
-# set comm_root_folder_id [fs::get_root_folder -package_id $fs_package_id]
-# set folder_id [dotlrn_fs::get_public_folder_id -parent_id $comm_root_folder_id]
-# set title group_icon_3
-# set mime_type [fs_maybe_create_new_mime_type $header_img]
-# set creation_ip [ad_conn peeraddr]
-# set filename $header_img
-# ad_require_permission $folder_id write
-# if ![regexp {[^//\\]+$} $header_img filename] {
-# set filename $header_img
-# }
+set tmp_filename [ns_queryget header_img.tmpfile]
+set mime_type [ns_guesstype $header_img]
+
+if {[empty_string_p $tmp_filename]} {
+ set tmp_size 0
+ set revision_id 0
+} else {
+ set tmp_size [file size $tmp_filename]
+}
+set title "$header_img-[db_nextval acs_object_id_seq]"
+
+# strip off the C:\directories... crud and just get the file name
+if ![regexp {([^/\\]+)$} $header_img match client_filename] {
+ set client_filename $header_img
+}
+
+if { ![empty_string_p [ad_parameter MaximumFileSize]]
+ && $tmp_size > 0
+ && $tmp_size > [ad_parameter MaximumFileSize] } {
+
+ ad_return_complaint 1 "
Your icon is too large. The publisher of [ad_system_name] has chosen to limit attachments to [util_commify_number [ad_parameter MaximumFileSize]] bytes.\n"
+ ad_script_abort
+}
+
+if { $tmp_size > 0 } {
+ # import the content now, so that we can spit it out in the preview
+ db_transaction {
+ set parent_id 0
+
+ # the last param "object name" is unused
+ set revision_id [cr_import_content \
+ -title $title \
+ -description "group's icon" \
+ -image_only \
+ $parent_id \
+ $tmp_filename \
+ $tmp_size \
+ $mime_type \
+ "$client_filename-$title"
+ ]
+
+ ns_log notice "aks1: new revision_id $revision_id"
+
+ } on_error {
+ # most likely a duplicate name, double click, etc.
+ ad_return_complaint 1 "
+ There was an error trying to add your content.
+ Most likely causes you've
+
Tried to upload a non-image file.
+
Double-clicking the \"Add\" button on the previous page.
+
Here is the actual error message:
$errmsg
"
+
+ ad_script_abort
+ }
+} else {
+ # if there was no img uploaded, use the old value of the attribute
+ # which is either "" for no img ever uploaded or the current revision_id
+ set revision_id [dotlrn_community::get_attribute \
+ -community_id $community_id \
+ -attribute_name header_logo_item_id
+ ]
+
+ ns_log notice "aks2: old revision_id $revision_id"
+}
+
#
-# # ungraciously shove this file into the public folder
-# # copied from file-storage/www/file-add-2.tcl
-# db_transaction {
-# set file_id [db_exec_plsql new_lob_file "
-# begin
-# :1 := file_storage.new_file (
-# title => :title,
-# folder_id => :folder_id,
-# creation_user => :user_id,
-# creation_ip => :creation_ip,
-# indb_p => 't'
-# );
+# Font stuff
#
-# end;"]
-#
-# set version_id [db_exec_plsql new_version "
-# begin
-# :1 := file_storage.new_version (
-# filename => :filename,
-# description => 'the group header image',
-# mime_type => :mime_type,
-# item_id => :file_id,
-# creation_user => :user_id,
-# creation_ip => :creation_ip
-# );
-# end;"]
-#
-# db_dml lob_content "
-# update cr_revisions
-# set content = empty_lob()
-# where revision_id = :version_id
-# returning content into :1" -blob_files [list ${header_img.tmpfile}]
-#
-# db_dml lob_size "
-# update cr_revisions
-# set content_length = dbms_lob.getlength(content)
-# where revision_id = :version_id"
-# }
-# # end copied stuff
-#
-set header_text [dotlrn_community::get_community_header_name $community_id]
-
if {[empty_string_p $header_font]} {
set header_font_text "sans-serif (None chosen)"
set header_font_fragment ""
@@ -135,6 +146,18 @@
-datatype text \
-widget submit
+element create header_form header_logo_item_id \
+ -label header_logo_item_id \
+ -datatype text \
+ -widget hidden \
+ -value $revision_id
+
+element create header_form header_logo_alt_text \
+ -label header_logo_alt_text \
+ -datatype text \
+ -widget hidden \
+ -value $header_alt_text
+
element create header_form header_font \
-label header_font \
-datatype text \
@@ -157,15 +180,20 @@
yes_button \
header_font \
header_font_size \
- header_font_color
+ header_font_color \
+ header_logo_item_id \
+ header_logo_alt_text
if {[string equal $yes_button $yes_label]} {
+
dotlrn_community::set_attributes \
-community_id $community_id \
-pairs [list \
[list header_font $header_font] \
[list header_font_size $header_font_size] \
[list header_font_color $header_font_color] \
+ [list header_logo_item_id $header_logo_item_id] \
+ [list header_logo_alt_text $header_logo_alt_text] \
]
ad_returnredirect "one-community-admin"
Index: openacs-4/packages/dotlrn/www/community-edit.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/community-edit.adp,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/dotlrn/www/community-edit.adp 3 Jun 2002 21:16:28 -0000 1.4
+++ openacs-4/packages/dotlrn/www/community-edit.adp 13 Jun 2002 04:33:31 -0000 1.5
@@ -58,6 +58,17 @@
+