general_comments_new (public)

 general_comments_new -object_id object_id -comment_id comment_id \
    -title title -comment_mime_type comment_mime_type \
    -context_id context_id [ -user_id user_id ] \
    [ -creation_ip creation_ip ] -is_live is_live -category category \
    -content content

Defined in packages/general-comments/tcl/general-comments-procs.tcl

Creates a comment and attaches it to a given object ID

Switches:
-object_id
(required)
-comment_id
(required)
-title
(required)
-comment_mime_type
(required)
-context_id
(required)
-user_id
(optional)
-creation_ip
(optional)
-is_live
(required)
-category
(required)
-content
(required)
Returns:
Error:

Partial Call Graph (max 5 caller/called nodes):
%3 test_general_comments_create_retrieve general_comments_create_retrieve (test general-comments) general_comments_new general_comments_new test_general_comments_create_retrieve->general_comments_new acs_object_type acs_object_type (public) general_comments_new->acs_object_type ad_html_text_convert ad_html_text_convert (public) general_comments_new->ad_html_text_convert callback callback (public) general_comments_new->callback content::item::get_latest_revision content::item::get_latest_revision (public) general_comments_new->content::item::get_latest_revision db_dml db_dml (public) general_comments_new->db_dml packages/general-comments/www/comment-add-3.tcl packages/general-comments/ www/comment-add-3.tcl packages/general-comments/www/comment-add-3.tcl->general_comments_new

Testcases:
general_comments_create_retrieve
Source code:

    # Generate a unique id for the message
    set rfc822_id [ns_uuid]

    db_transaction {

        db_exec_plsql insert_comment {}
        db_dml add_entry {}
        set revision_id [content::item::get_latest_revision  -item_id $comment_id]
        db_dml set_content {} -blobs [list $content]

        # Grant the user sufficient permissions to
        # created comment. This is done here to ensure that
        # a fail on permissions granting will not leave
        # the comment with incorrect permissions.
        if {$user_id ne ""} {
            permission::grant -object_id $comment_id  -party_id $user_id  -privilege "read"

            permission::grant -object_id $comment_id  -party_id $user_id  -privilege "write"

        }
    }

    # Convert the comment to HTML
    if {$comment_mime_type ne "text/html"} {
        set content [ad_html_text_convert $content]
    }

    # Start notifications
    callback general_comments::notify_objects  -object_id $object_id  -comment $content  -title $title  -object_type [acs_object_type $object_id]

    return $revision_id
Generic XQL file:
<fullquery name="general_comments_new.add_entry">
    <querytext>
      
        insert into general_comments
            (comment_id,
             object_id,
             category)
        values
            (:comment_id,
             :object_id,
             :category)
    
    </querytext>
</fullquery>
packages/general-comments/tcl/general-comments-procs.xql

PostgreSQL XQL file:
<fullquery name="general_comments_new.insert_comment">
    <querytext>
	     select acs_message__new (
		:comment_id,		-- 1  p_message_id
		NULL, 			-- 2  p_reply_to
		current_timestamp,	-- 3  p_sent_date
		NULL, 			-- 4  p_sender
		:rfc822_id,	        -- 5  p_rfc822_id
		:title,			-- 6  p_title
		NULL,			-- 7  p_description
		:comment_mime_type,	-- 8  p_mime_type
		NULL,			-- 9  p_text
		NULL, -- empty_blob(),		-- 10 p_data
		-4,			-- 11 p_parent_id
		:context_id,		-- 12 p_context_id
		:user_id,		-- 13 p_creation_user
		:creation_ip,		-- 14 p_creation_ip
		'acs_message',		-- 15 p_object_type
		:is_live		-- 16 p_is_live
	    )
      </querytext>
</fullquery>

<fullquery name="general_comments_new.set_content">
    <querytext>
    
        update cr_revisions
           set content = :content
         where revision_id = :revision_id
       
      </querytext>
</fullquery>
packages/general-comments/tcl/general-comments-procs-postgresql.xql

Oracle XQL file:
<fullquery name="general_comments_new.insert_comment">
    <querytext>
      
        begin
            :1 := acs_message.new (
                message_id    => :comment_id,
                title         => :title,
                mime_type     => :comment_mime_type,
                data          => empty_blob(),
                context_id    => :context_id,
                creation_user => :user_id, 
                creation_ip   => :creation_ip,
                is_live       => :is_live,
		rfc822_id     => :rfc822_id
            );
        end;
    
      </querytext>
</fullquery>

<fullquery name="general_comments_new.set_content">
    <querytext>
      
        update cr_revisions
           set content = empty_blob()
         where revision_id = :revision_id
     returning content into :1
    
      </querytext>
</fullquery>
packages/general-comments/tcl/general-comments-procs-oracle.xql

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