• Publicity: Public Only All

object-procs.tcl

Object support for ACS.

Location:
packages/acs-tcl/tcl/object-procs.tcl
Created:
11 Aug 2000
Author:
Jon Salz <jsalz@arsdigita.com>
CVS Identification:
$Id: object-procs.tcl,v 1.14.2.11 2022/08/08 11:01:07 antoniop Exp $

Procedures in this file

Detailed information

acs_magic_object (public)

 acs_magic_object name

Returns the object ID of a magic object.

Parameters:
name - the name of the magic object (as listed in the acs_magic_objects table).
Returns:
the object ID.
Error:
if no object exists with that magic name.

Partial Call Graph (max 5 caller/called nodes):
%3 test_magic_objects magic_objects (test acs-tcl) acs_magic_object acs_magic_object test_magic_objects->acs_magic_object acs_lookup_magic_object_no_cache acs_lookup_magic_object_no_cache (private) acs_magic_object->acs_lookup_magic_object_no_cache acs::test::user::create acs::test::user::create (public) acs::test::user::create->acs_magic_object acs_user::get_user_info_not_cached acs_user::get_user_info_not_cached (private) acs_user::get_user_info_not_cached->acs_magic_object acs_user::site_wide_admin_p acs_user::site_wide_admin_p (public) acs_user::site_wide_admin_p->acs_magic_object apm_mount_core_packages apm_mount_core_packages (private) apm_mount_core_packages->acs_magic_object auth::test::get_admin_user_id auth::test::get_admin_user_id (private) auth::test::get_admin_user_id->acs_magic_object

Testcases:
magic_objects

acs_object::get (public)

 acs_object::get -object_id object_id [ -array array ] \
    [ -element element ]

Gets information about an acs_object. If called without "-element", it returns a dict containing object_id, package_id, object_type, context_id, security_inherit_p, creation_user, creation_date_ansi, creation_ip, last_modified_ansi, modifying_user, modifying_ip, tree_sortkey, object_name. If called with "-element" it returns the denoted element (similar to e.g. "party::get").

Switches:
-object_id
(required)
for which the information should be retrieved
-array
(optional)
An array in the caller's namespace into which the info should be delivered (upvared)
-element
(optional)
to be returned
Error:
when object_id does not exist

Partial Call Graph (max 5 caller/called nodes):
%3 test_acs_object_procs_test acs_object_procs_test (test acs-tcl) acs_object::get acs_object::get test_acs_object_procs_test->acs_object::get db_1row db_1row (public) acs_object::get->db_1row acs_object::get_element acs_object::get_element (public) acs_object::get_element->acs_object::get chat_room_get_not_cached chat_room_get_not_cached (private, deprecated) chat_room_get_not_cached->acs_object::get packages/acs-subsite/www/admin/parties/one.tcl packages/acs-subsite/ www/admin/parties/one.tcl packages/acs-subsite/www/admin/parties/one.tcl->acs_object::get packages/acs-subsite/www/permissions/one.tcl packages/acs-subsite/ www/permissions/one.tcl packages/acs-subsite/www/permissions/one.tcl->acs_object::get packages/acs-subsite/www/permissions/perm-include.tcl packages/acs-subsite/ www/permissions/perm-include.tcl packages/acs-subsite/www/permissions/perm-include.tcl->acs_object::get

Testcases:
acs_object_procs_test

acs_object::get_element (public)

 acs_object::get_element -object_id object_id -element element

Gets a specific element from the info returned by acs_object::get.

Switches:
-object_id
(required)
the object to get data for
-element
(required)
the field to return
Returns:
the value of the specified element
See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 test_acs_object_procs_test acs_object_procs_test (test acs-tcl) acs_object::get_element acs_object::get_element test_acs_object_procs_test->acs_object::get_element test_attachments_name_api attachments_name_api (test attachments) test_attachments_name_api->acs_object::get_element acs_object::get acs_object::get (public) acs_object::get_element->acs_object::get attachments::get_title attachments::get_title (public) attachments::get_title->acs_object::get_element content::item::get_context content::item::get_context (public, deprecated) content::item::get_context->acs_object::get_element fs::do_notifications fs::do_notifications (public) fs::do_notifications->acs_object::get_element permission::write_permission_p permission::write_permission_p (public) permission::write_permission_p->acs_object::get_element

Testcases:
acs_object_procs_test, attachments_name_api

acs_object::object_p (public)

 acs_object::object_p -id id
Switches:
-id
(required)
ID of the potential acs-object
Returns:
true if object whose id is $id exists
Authors:
Jim Lynch <jim@jam.sessionsnet.org>
Malte Sussdorff
Created:
2007-01-26

Partial Call Graph (max 5 caller/called nodes):
%3 test_object_p object_p (test acs-tcl) acs_object::object_p acs_object::object_p test_object_p->acs_object::object_p db_string db_string (public) acs_object::object_p->db_string acs_mail_lite::inbound_queue_pull acs_mail_lite::inbound_queue_pull (private) acs_mail_lite::inbound_queue_pull->acs_object::object_p acs_mail_lite::load_mails acs_mail_lite::load_mails (public, deprecated) acs_mail_lite::load_mails->acs_object::object_p

Testcases:
object_p

acs_object::package_id (public)

 acs_object::package_id -object_id object_id

Gets the package_id of the object

Switches:
-object_id
(required)
the object to get the package_id for
Returns:
package_id of the object. Empty string if the package_id is not stored
Author:
Malte Sussdorff <malte.sussdorff@cognovis.de>
Created:
2006-08-10

Partial Call Graph (max 5 caller/called nodes):
%3 test_acs_object__package_id acs_object__package_id (test acs-tcl) acs_object::package_id acs_object::package_id test_acs_object__package_id->acs_object::package_id acs_object::package_id_not_cached acs_object::package_id_not_cached (private) acs_object::package_id->acs_object::package_id_not_cached util_memoize util_memoize (public) acs_object::package_id->util_memoize fs::new_folder fs::new_folder (public) fs::new_folder->acs_object::package_id

Testcases:
acs_object__package_id

acs_object::set_context_id (public)

 acs_object::set_context_id -object_id object_id -context_id context_id

Sets the context_id of the specified object.

Switches:
-object_id
(required)
-context_id
(required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_acs_object_procs_test acs_object_procs_test (test acs-tcl) acs_object::set_context_id acs_object::set_context_id test_acs_object_procs_test->acs_object::set_context_id db_dml db_dml (public) acs_object::set_context_id->db_dml

Testcases:
acs_object_procs_test

acs_object_name (public)

 acs_object_name object_id

Returns the name of an object.

Parameters:
object_id

Partial Call Graph (max 5 caller/called nodes):
%3 test_object_name object_name (test acs-tcl) acs_object_name acs_object_name test_object_name->acs_object_name db_string db_string (public) acs_object_name->db_string application_group::group_id_from_package_id application_group::group_id_from_package_id (public) application_group::group_id_from_package_id->acs_object_name category::get_object_context category::get_object_context (public) category::get_object_context->acs_object_name ds_require_permission ds_require_permission (private) ds_require_permission->acs_object_name general_comments_create_link general_comments_create_link (public) general_comments_create_link->acs_object_name packages/acs-subsite/www/admin/parties/new.tcl packages/acs-subsite/ www/admin/parties/new.tcl packages/acs-subsite/www/admin/parties/new.tcl->acs_object_name

Testcases:
object_name

acs_object_type (public)

 acs_object_type object_id

Returns the type of an object.

Parameters:
object_id

Partial Call Graph (max 5 caller/called nodes):
%3 test_attachments_name_api attachments_name_api (test attachments) acs_object_type acs_object_type test_attachments_name_api->acs_object_type test_data_links_with_tag data_links_with_tag (test acs-tcl) test_data_links_with_tag->acs_object_type db_string db_string (public) acs_object_type->db_string acs_object::is_type_p acs_object::is_type_p (private) acs_object::is_type_p->acs_object_type ad_call_method ad_call_method (public, deprecated) ad_call_method->acs_object_type attachments::get_title attachments::get_title (public) attachments::get_title->acs_object_type auth::validate_account_info auth::validate_account_info (private) auth::validate_account_info->acs_object_type etp::revision_datasource etp::revision_datasource (public) etp::revision_datasource->acs_object_type

Testcases:
data_links_with_tag, attachments_name_api
[ hide source ] | [ make this the default ]

Content File Source

ad_library {

    Object support for ACS.

    @author Jon Salz (jsalz@arsdigita.com)
    @creation-date 11 Aug 2000
    @cvs-id $Id: object-procs.tcl,v 1.14.2.11 2022/08/08 11:01:07 antoniop Exp $

}

namespace eval acs_object {}

ad_proc -private acs_lookup_magic_object_no_cache { name } {
    Non memoized version of acs_magic_object.

    @return the magic object's object ID

    @see acs_magic_object
} {
    return [db_string magic_object_select {} ]
}

ad_proc -private -deprecated acs_lookup_magic_object { name } {
    Non memoized version of acs_magic_object.

    @return the magic object's object ID

    @see acs_magic_object
} {
    return [util_memoize [list acs_lookup_magic_object_no_cache $name]]
}

ad_proc -public acs_magic_object { name } {
    Returns the object ID of a magic object.

    @param name the name of the magic object (as listed in the
        <code>acs_magic_objects</code> table).
    @return the object ID.

    @error if no object exists with that magic name.
} {
    return [acs::per_thread_cache eval -key acs-tcl.acs_magic_object($name) {
        acs_lookup_magic_object_no_cache $name
    }]
}

ad_proc -public acs_object_name { object_id } {

    Returns the name of an object.

} {
    return [db_string object_name_get {
        select acs_object.name(:object_id) from dual
    }]
}

ad_proc -public acs_object_type { object_id } {

    Returns the type of an object.

} {
    return [db_string object_type_select {
        select object_type
        from acs_objects
        where object_id = :object_id
    } -default ""]
}

d_proc -public acs_object::get {
    {-object_id:required}
    {-array}
    {-element}
} {
    Gets information about an acs_object.

    If called without "-element", it returns a dict containing
    object_id, package_id, object_type, context_id,
    security_inherit_p, creation_user, creation_date_ansi,
    creation_ip, last_modified_ansi, modifying_user, modifying_ip,
    tree_sortkey, object_name.

    If called with "-element" it returns the denoted element (similar
    to e.g. "party::get").

    @param array An array in the caller's namespace into which the info should be delivered (upvared)
    @param element to be returned
    @param object_id for which the information should be retrieved
    @error when object_id does not exist
} {
    if {[info exists array]} {
        upvar 1 $array row
    }
    db_1row select_object {
        select o.object_id,
               o.title,
               o.package_id,
               o.object_type,
               o.context_id,
               o.security_inherit_p,
               o.creation_user,
               to_char(o.creation_date, 'YYYY-MM-DD HH24:MI:SS') as creation_date_ansi,
               o.creation_ip,
               to_char(o.last_modified, 'YYYY-MM-DD HH24:MI:SS') as last_modified_ansi,
               o.modifying_user,
               o.modifying_ip,
               acs_object.name(o.object_id) as object_name
        from   acs_objects o
        where  o.object_id = :object_id
    } -column_array row

    if {[info exists element]} {
        return [dict get [array get row] $element]
    } else {
        return [array get row]
    }
}

d_proc -public acs_object::package_id {
    {-object_id:required}
} {
    Gets the package_id of the object

    @author Malte Sussdorff (malte.sussdorff@cognovis.de)
    @creation-date 2006-08-10

    @param object_id the object to get the package_id for

    @return package_id of the object. Empty string if the package_id is not stored
} {
    return [util_memoize [list acs_object::package_id_not_cached -object_id $object_id]]
}

d_proc -private acs_object::package_id_not_cached {
    {-object_id:required}
} {
    Gets the package_id of the object

    @author Malte Sussdorff (malte.sussdorff@cognovis.de)
    @creation-date 2006-08-10

    @param object_id the object to get the package_id for

    @return package_id of the object. Empty string if the package_id is not stored
} {
    return [db_string get_package_id {} -default ""]
}


d_proc -public acs_object::get_element {
    {-object_id:required}
    {-element:required}
} {
    Gets a specific element from the info returned by acs_object::get.

    @param object_id the object to get data for
    @param element the field to return

    @return the value of the specified element

    @see acs_object::get
} {
    return [acs_object::get -object_id $object_id -element $element]
}

d_proc -public acs_object::object_p {
    -id:required
} {

    @author Jim Lynch (jim@jam.sessionsnet.org)
    @author Malte Sussdorff

    @creation-date 2007-01-26

    @param id ID of the potential acs-object

    @return true if object whose id is $id exists

} {
    return [db_string object_exists {} -default 0]
}

d_proc -private acs_object::is_type_p {
    -object_id:required
    -object_types:required
    -no_hierarchy:boolean
} {
    Returns whether an object is of a given object type.

    @return boolean
} {
    if { ![string is integer -strict $object_id] } {
        return 0
    }

    set object [acs::per_request_cache eval \
                    -key acs-tcl.acs_object.is_type_p($object_id,$object_types,$no_hierarchy_p) {

                        set object_type [acs_object_type $object_id]

                        if {$object_type eq ""} {
                            # Object was not found
                            return 0
                        } elseif {$object_type in $object_types} {
                            # Object is one of the types we look for
                            return 1
                        } elseif {$no_hierarchy_p} {
                            # Object is not one of the types we look
                            # for and we were told to not look into
                            # the hierarchy
                            return 0
                        } else {
                            # We expand the object type hierarchy and
                            # see if one of our supertypes is a type
                            # we look for
                            foreach supertype [acs_object_type::supertypes -subtype $object_type] {
                                if {$supertype in $object_types} {
                                    return 1
                                }
                            }

                            return 0
                        }
                    }]
}

d_proc -public acs_object::set_context_id {
    {-object_id:required}
    {-context_id:required}
} {
    Sets the context_id of the specified object.
} {
    db_dml update_context_id {}
}

# Local variables:
#    mode: tcl
#    tcl-indent-level: 4
#    indent-tabs-mode: nil
# End: