{init_users}

Tag {init_users} returns a list of users. Since version 4.5.0.

Parameters

  • name - variable name where the returned data is saved. Default value is "users".
  • parent - group ID where to get the users.

Attributes

  • id, user_id - ID number of the user
  • firstname - user first name
  • lastname - user last name
  • username - username
  • email - e-mail address

General tags

  • <name>_count - the number of returned objects.

Example

Displays list of user ID values and names

{init_users name="users"}
{foreach from=$users item="user"}
    {$user->id} : {$user->firstname} {$user->lastname}<br />
{/foreach}

 

User permissions

CMS sets the following variables to check user permissions:

  • {$user} - boolean, if true (1) then user has logged in.
  • {$in_editor} - boolean, if true (1) then user is logged in and is located in the editor-area and this user has also (C)reate, (U)pdate or (D)delete permissions for the current section.

In addition, every object has their permissions in the "permission" array, these permissions are calculated for the current logged in user:

  • {$obj->permission.C} - boolean, if true (1) then the user has C(reate) permission for this object.
  • {$obj->permission.R} - boolean, if true (1) then the user has R(ead) permission for this object.
  • {$obj->permission.U} - boolean, if true (1) then the user has U(pdate) permission for this object.
  • {$obj->permission.P} - boolean, if true (1) then the user has P(ublish) permission for this object.
  • {$obj->permission.D} - boolean, if true (1) then the user has D(elete) permission for this object.
  • {$obj->permission.only_read} - boolean, if true (1) then the user has only R(ead) permission for this object.
  • {$obj->permission.is_visible} - boolean, if true (1) then the object is visible to the user.
  • {$obj->permission.mask} - the CRUPD permissions mask in 5 digit format eg "01110".

Example

Display custom action link in the editor area for editors having Create or Update permission for this content object

{if $in_editor && ($obj->permission.C || $obj->permission.U) }
# .. display action link ..
{/if}

{$userdata}

{$userdata} gives you an access to logged in user object with following attributes:

  • {$userdata->id}{$userdata->user_id} - user ID.
  • {$userdata->group_id} - group ID to where user belongs.
  • {$userdata->name} - user's fullname.
  • {$userdata->username} - user's username.
  • {$userdata->profile_id} - user's profile ID.
  • {$userdata->auth_type} - authenication type that user used when loggin in, possible values are: "CMS", "AD" (Active Directory), "ID card" (Estonian ID card).
  • {$userdata->is_superuser} - boolean, if true (1) then the user has superuser privileges.
  • {$userdata->all.pass_expired} - boolean, if true (1) then the user's password has expired.
  • {$userdata->roles} - array of user's role ID values.
  • {$userdata->all} - array of all user data values from "users" table, array key is the column name of the table eg {$userdata->all.idcode} is the ID code of the user.

Example

display all of $userdata->all values:

{foreach from=$userdata->all key="column" item="value"}
{$column}: {$value}<br>
{/foreach}

Check if user has been assigned a role with ID 19

{if in_array(19, $userdata->roles)}
user has role with ID 19
{else}
user hasn't got role with ID 19
{/if}