lang::message::edit (private)

 lang::message::edit [ -update_sync ] package_key message_key locale \
    edit_array_list

Defined in packages/acs-lang/tcl/lang-message-procs.tcl

Edit properties (meta data) of a language catalog message, but not the message text itself. To update or add message catalog text, use the lang::message::register proc. Implementation note: some of the dynamic sql edit code of this proc was copied from the auth::authority::edit proc and should probably be broken out into a general API.

Switches:
-update_sync
(boolean) (optional)
If this switch is provided the sync_time of the message will be updated to current time. If not provided no update to sync_time will be made. If sync_time is contained in the edit_array_list then that value will override the update_sync flag.
Parameters:
package_key - The package_key of the message to update
message_key - The message_key of the message to update
locale - The locale of the message to update
edit_array_list - An array list holding names of columns and the values to set them to. Valid keys in this array list are any column names in the lang_messages table.
Author:
Peter Marklund

Partial Call Graph (max 5 caller/called nodes):
%3 test_upgrade upgrade (test acs-lang) lang::message::edit lang::message::edit test_upgrade->lang::message::edit db_boolean db_boolean (public) lang::message::edit->db_boolean db_dml db_dml (public) lang::message::edit->db_dml db_list db_list (public) lang::message::edit->db_list lang::audit::changed_message lang::audit::changed_message (public) lang::message::edit->lang::audit::changed_message lang::message::get lang::message::get (public) lang::message::edit->lang::message::get lang::catalog::import_messages lang::catalog::import_messages (private) lang::catalog::import_messages->lang::message::edit lang::message::delete lang::message::delete (public) lang::message::delete->lang::message::edit lang::message::undelete lang::message::undelete (private) lang::message::undelete->lang::message::edit lang::test::execute_upgrade lang::test::execute_upgrade (private) lang::test::execute_upgrade->lang::message::edit packages/acs-lang/www/admin/message-conflict-resolve.tcl packages/acs-lang/ www/admin/message-conflict-resolve.tcl packages/acs-lang/www/admin/message-conflict-resolve.tcl->lang::message::edit

Testcases:
upgrade
Source code:
    array set edit_array $edit_array_list

    if { [info exists edit_array(message)] } {
        error "The proc lang::message::edit was invoked with the message attribute in the edit array. To edit the message text of a message use the lang::message::register proc instead"
    }
    #
    # Deleting/undeleting?
    #
    if { [info exists edit_array(deleted_p)] } {
        set edit_array(deleted_p) [db_boolean [string is true -strict $edit_array(deleted_p)]]
        if { [string is true -strict $edit_array(deleted_p)] } {
            set delete_p t
            set delete_comment "deleted"
        } else {
            set delete_p f
            set delete_comment "undeleted"
        }
        #
        # If we are deleting/undeleting we need to preserve the old message in the audit log
        #
        # Peter TODO: should these attributes be cached?
        #
        lang::message::get  -package_key $package_key  -message_key $message_key  -locale $locale  -array old_message_array

        lang::audit::changed_message  $old_message_array(message)  $package_key  $message_key  $locale  $delete_comment  $old_message_array(deleted_p)  $old_message_array(sync_time)  $old_message_array(conflict_p)  $old_message_array(upgrade_status)

        #
        # If we are deleting an en_US message we need to mark the message as deleted in all locales
        #
        if {$delete_p && $locale eq "en_US"} {
            set message_locales [db_list all_message_locales {
                select locale
                from lang_messages
                where package_key = :package_key
                  and message_key = :message_key
                  and locale <> 'en_US'
            }]
            foreach message_locale $message_locales {
                lang::message::delete  -package_key $package_key  -message_key $message_key  -locale $message_locale
            }
        }
    }

    set set_clauses [list]
    foreach name [array names edit_array] {
        lappend set_clauses "$name = :$name"
        set $name $edit_array($name)
    }
    if { $update_sync_p && ![info exists edit_array(sync_time)] } {
        lappend set_clauses {sync_time = current_timestamp}
    }

    if { [llength $set_clauses] > 0 } {

        set sql "
            update lang_messages
            set    [join $set_clauses ""]
            where  package_key = :package_key
            and    message_key = :message_key
            and    locale = :locale
        "
        db_dml edit_message $sql
    }
Generic XQL file:
packages/acs-lang/tcl/lang-message-procs.xql

PostgreSQL XQL file:
packages/acs-lang/tcl/lang-message-procs-postgresql.xql

Oracle XQL file:
packages/acs-lang/tcl/lang-message-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: