dom::xpathFunc::irc::logger::user_link (public)

 dom::xpathFunc::irc::logger::user_link ctxNode pos nodeListType \
    nodeList [ args... ]

Defined in packages/irc-logger/tcl/irc-logger-procs.tcl

Create a link to the user account on this site where the IRC nick matches the user's screen name.

Rolf (rolf@pointsman.de) from the tDOM team on tDOM extension functions:

If an XPath expr (both for the selectNodes method and in XSLT stylesheets) uses a not standard XPath function name (you cannot 'overwrite' the C coded standard built-in functions), the engine looks, if there is a tcl proc with the given function name in the ::dom::xpathFunc:: namespace. In other words: all extension functions procs must reside in the namespace ::dom::xpathFunc or in a child namespace of that namespace. If the XPath extension function has a prefix, the prefix is expanded to the namespace URI and that namespace URI must be the name of the child namespace of the ::dom::xpathFunc namespace.

If there is such a proc, this proc is called with the following arguments: ctxNode pos nodeListType nodeList args. The 'args' are, as type/value pairs, the arguments, that are given to the extension functions. (E.g. if you have myExtensionFunction('foo'), you will get two args, the first "string" the second "foo").

The tcl proc, which implements the extension function must return a list of two elements: {<type> <value>}. The possible types at the moment are: "bool", "number", "string", "nodes".

But don't get confused by my probably (too) vague explanations. Just look at the examples in the xpath.test and tdom.tcl files. For almost all 'real life' needs, you should get it very fast, what to do from that usage examples.

Parameters:
ctxNode - See tDOM documentation.
pos - See tDOM documentation.
nodeListType - See tDOM documentation.
nodeList - See tDOM documentation.
Returns:
A single (type, value) pair with a link to the user account on the site. Or just the nick if no user account was found.
Error:
The empty string.
Author:
Bart Teeuwisse <bart.teeuwisse@thecodemill.biz>
Created:
2003-01-31

Partial Call Graph (max 5 caller/called nodes):
%3 ad_acs_kernel_id ad_acs_kernel_id (public) db_0or1row db_0or1row (public) export_vars export_vars (public) parameter::get parameter::get (public) dom::xpathFunc::irc::logger::user_link dom::xpathFunc::irc::logger::user_link dom::xpathFunc::irc::logger::user_link->ad_acs_kernel_id dom::xpathFunc::irc::logger::user_link->db_0or1row dom::xpathFunc::irc::logger::user_link->export_vars dom::xpathFunc::irc::logger::user_link->parameter::get

Testcases:
No testcase defined.
Source code:

    # Default return value

    set link ""

    # Limited parameter checking. The tDOM related parameters don't
    # matter.

    if {[llength $args] == 2} {

        # Get argument type and value.

        foreach {type value} $args {
            break
        }
        
        # Check that the parameter an attribute node is and extract
        # the value of the attribute.

        if {[string equal $type "attrnodes"]} {
            set nick [lindex [lindex $value end] end]

            # Locate the first user with a screen name of 'nick' on this
            # site. DB caching reduces the number of hits on the DB
            # itself.
        
        # community_member_url was changed to require a conn
        # it always returned / for the subsite since we run from a 
        # scheduled proc. This needs to be smarter.

        set community_member_url "[parameter::get -package_id [ad_acs_kernel_id] -parameter CommunityMemberURL]?[export_vars {user_id}]"

            if {[db_0or1row get_user {}]} {
                set link "<a href=\"$community_member_url\" title=\"$name\">$nick</a>"
            } else {
                set link $nick
            }
        } else {
            ns_log warning "dom::xpathFunc::irc::logger::user_link wrong parameter type '$type($value)'; type should have been attrnodes"
        }
    } else {
        ns_log warning "dom::xpathFunc::irc::logger::user_link accepts only 1 parameter, received [llength $args] parameters"
    }

    return [list string $link]
XQL Not present:
Oracle
Generic XQL file:
packages/irc-logger/tcl/irc-logger-procs.xql

PostgreSQL XQL file:
<fullquery name="dom::xpathFunc::irc::logger::user_link.get_user">
    <querytext>
      select u.user_id, p.first_names || ' ' || p.last_name as name 
      from users u, persons p 
      where u.screen_name = :nick
      and p.person_id = u.user_id
      limit 1
    </querytext>
</fullquery>
packages/irc-logger/tcl/irc-logger-procs-postgresql.xql

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