- Publicity: Public Only All
views-procs.tcl
Tcl library for recoding views
- Location:
- packages/views/tcl/views-procs.tcl
- Created:
- 2004-05-20
- Author:
- Jeff Davis
- CVS Identification:
$Id: views-procs.tcl,v 1.11 2018/07/26 15:12:22 hectorr Exp $
Procedures in this file
- views::get (public)
- views::record_view (public)
- views::viewed_p (public)
Detailed information
views::get (public)
views::get [ -object_id object_id ]
Return an array (which you have to set with "array set your_array [views::get -object_id $object_id]") with the elements:
- views_count
- unique_views
- last_viewed
- Switches:
- -object_id (optional)
- ID of the object for which you want to return the views
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- view_api_test_without_type, view_api_test_with_type
views::record_view (public)
views::record_view [ -object_id object_id ] [ -viewer_id viewer_id ] \ [ -type type ]
Record an object view by viewer_id
- Switches:
- -object_id (optional)
- -viewer_id (optional)
- -type (optional)
- Returns:
- the total view count for the user
- Author:
- Jeff Davis davis@xarg.net
- Created:
- 2004-01-30
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- view_api_test_without_type, view_api_test_with_type
views::viewed_p (public)
views::viewed_p [ -object_id object_id ] [ -user_id user_id ] \ [ -type type ]
Returns whether an object was viewed by specified user.
- Switches:
- -object_id (optional)
- viewed object id
- -user_id (optional, defaults to
"0"
)- viewing user id
- -type (optional)
- filter results by type
- Returns:
- boolean value
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- view_api_test_without_type, view_api_test_with_type
Content File Source
ad_library { Tcl library for recoding views @author Jeff Davis <davis@xarg.net> @creation-date 2004-05-20 @cvs-id $Id: views-procs.tcl,v 1.11 2018/07/26 15:12:22 hectorr Exp $ } namespace eval views {} d_proc -public views::record_view { -object_id -viewer_id {-type ""} } { Record an object view by viewer_id @param object_id @param viewer_id @return the total view count for the user @author Jeff Davis davis@xarg.net @creation-date 2004-01-30 } { if { $type ne "" } { if { $type in {views_count unique_views last_viewed} } { # if the type is on of the list it will conflict on the views::get procedure error "views::record_view type cannot be views_count, unique_views or last_viewed" } #TYPE is PL/SQL reserver word in ORACLE #set view_type $type set views_by_type [db_exec_plsql record_view_by_type {}] } if {[catch {set views [db_exec_plsql record_view {}]} views]} { set views 0 } return $views } d_proc -public views::get { -object_id } { Return an array (which you have to set with "array set your_array [views::get -object_id $object_id]") with the elements: <ul> <li>views_count <li>unique_views <li>last_viewed </ul> @param object_id ID of the object for which you want to return the views } { if {[db_0or1row views { } -column_array ret] } { db_foreach select_views_by_type { } { set ret($view_type) $views_count } return [array get ret] } return {views_count {} unique_views {} last_viewed {}} } d_proc -public views::viewed_p { -object_id {-user_id 0} {-type ""} } { Returns whether an object was viewed by specified user. @param object_id viewed object id @param user_id viewing user id @param type filter results by type @return boolean value } { if {!$user_id} { set user_id [ad_conn user_id] } if { $type ne "" } { return [db_string get_viewed_by_type_p {} -default 0] } else { return [db_string get_viewed_p {} -default 0] } } # Local variables: # mode: tcl # tcl-indent-level: 4 # indent-tabs-mode: nil # End: