Difference between revisions of "S2 Cookbook: Users"

From Dreamwidth Notes
Jump to: navigation, search
(Created page with 'Classes that represent users are [http://www.dreamwidth.org/customize/advanced/layerbrowse?id=core2#class.UserLite UserLite] and [http://www.dreamwidth.org/customize/advanced/lay…')
 
(add in basic viewer helper functions)
 
Line 6: Line 6:
  
 
== Viewer information ==
 
== Viewer information ==
 +
 +
All of the below functions return True or False.
  
 
=== Is the viewer logged in ===
 
=== Is the viewer logged in ===
 +
 +
Returns true if the user viewing the page is logged in. It's recommended that your page links to the site login page if the user isn't logged in.
 +
 +
viewer_logged_in()
  
 
=== Does the viewer subscribe ===
 
=== Does the viewer subscribe ===
 +
 +
Returns true if the user viewing the page is logged in and can search that journal.
 +
 +
viewer_is_subscribed()
  
 
=== Does the viewer have access ===
 
=== Does the viewer have access ===
 +
 +
Returns true if the user viewing the page is logged in and has access to the journal being viewed. In communities, returns true if the viewer is a member of the community.
 +
 +
viewer_has_access()
  
 
=== Can the viewer search the journal ===
 
=== Can the viewer search the journal ===
 +
 +
Returns true if the user viewing the page is logged in and can search that journal.
 +
 +
viewer_can_search()
  
 
=== Does the viewer see the control strip ===
 
=== Does the viewer see the control strip ===
 +
 +
Returns true if reader will see the built in control strip.
 +
 +
viewer_sees_control_strip()
  
 
=== Is the viewer a member of the community ===
 
=== Is the viewer a member of the community ===
  
=== Is the viewer a moderator of the community ===
+
Returns true if the user viewing the page is both logged in, and is a member of the community being viewed. Always returns false for personal journals, since they cannot have members.
 +
 
 +
viewer_is_member()
 +
 
 +
=== Is the viewer a maintainer of the community ===
 +
 
 +
Returns true if the user viewing a community is logged in and a maintainer of the community.
 +
 
 +
viewer_is_moderator()
  
 
=== Is the viewer an administrator of the community ===
 
=== Is the viewer an administrator of the community ===
 +
 +
Returns true if the user viewing a community is logged in and is an admin of the community.
 +
 +
viewer_is_admin()
 +
 +
=== Does the viewer own the content being viewed ===
 +
 +
Returns true if the user viewing the page is both logged in, and is the owner of the content in question. Useful for returning links to manage information, or edit entries.
 +
 +
viewer_is_owner()
 +
 +
=== Can the viewer manage tags ===
 +
 +
Returns true if the user viewing the page can add, edit, and delete tags on the journal being viewed.
 +
 +
viewer_can_manage_tags()
  
 
[[Category: S2 Cookbook]]
 
[[Category: S2 Cookbook]]

Latest revision as of 07:45, 2 March 2013

Classes that represent users are UserLite and User.

Creating a UserLite object from a username

Get the User object of the journal being viewed

Viewer information

All of the below functions return True or False.

Is the viewer logged in

Returns true if the user viewing the page is logged in. It's recommended that your page links to the site login page if the user isn't logged in.

viewer_logged_in()

Does the viewer subscribe

Returns true if the user viewing the page is logged in and can search that journal.

viewer_is_subscribed()

Does the viewer have access

Returns true if the user viewing the page is logged in and has access to the journal being viewed. In communities, returns true if the viewer is a member of the community.

viewer_has_access()

Can the viewer search the journal

Returns true if the user viewing the page is logged in and can search that journal.

viewer_can_search() 

Does the viewer see the control strip

Returns true if reader will see the built in control strip.

viewer_sees_control_strip()

Is the viewer a member of the community

Returns true if the user viewing the page is both logged in, and is a member of the community being viewed. Always returns false for personal journals, since they cannot have members.

viewer_is_member()

Is the viewer a maintainer of the community

Returns true if the user viewing a community is logged in and a maintainer of the community.

viewer_is_moderator()

Is the viewer an administrator of the community

Returns true if the user viewing a community is logged in and is an admin of the community.

viewer_is_admin() 

Does the viewer own the content being viewed

Returns true if the user viewing the page is both logged in, and is the owner of the content in question. Useful for returning links to manage information, or edit entries.

viewer_is_owner()

Can the viewer manage tags

Returns true if the user viewing the page can add, edit, and delete tags on the journal being viewed.

viewer_can_manage_tags()