-- --------------------------------------------------------------------------------
-- _130_moderationQueue Group Routines
-- --------------------------------------------------------------------------------
DELIMITER $$$

create function moderationQueue_Create(node_id int unsigned, comment_ varchar(255)) returns int unsigned
not deterministic modifies sql data
begin
    declare queue_id int unsigned;
    
    insert moderationQueueT(
        nodeId, 
        comment1,
        resolved,
        addedUserId,
        addedUserName,
        addedIp,
        changedUserId,
        changedUserName,
        changedIp)
    values (
        node_id,
        coalesce(comment_, ''),
        'n',
        user_CurrentId(),
        user_CurrentName(),
        user_CurrentIp(),
        user_CurrentId(),
        user_CurrentName(),
        user_CurrentIp());
        
    set queue_id = last_insert_id();
    return queue_id;
end$$$


create function moderationQueue_Resolve(queue_id int unsigned, comment_ varchar(255)) returns int unsigned
not deterministic modifies sql data
begin
    update moderationQueueT set
        resolved = 'y',
        comment2 = coalesce(comment_, '')
    where id = queue_id;

    return 1;
end$$$
