Primary

API

Groups_File_Access

The Groups_File_Access class provides class methods that can be used to obtain information about files and user access on files.

Groups_File_Access::can_access( $user_id, $file_id )

Returns true if a user can access a file handled by the Groups File Access plugin.

Parameters:

  • int $user_id the user id
  • int $file_id the file id

Returns:

boolean true if the user can access the file, otherwise false

Groups_File_Access:get_count( $user_id, $file_id )

Return the number of times the user has accessed the file.

Parameters:

  • int $user_id the user id
  • int $file_id the file id

Returns:

int number of times

Groups_File_Access:get_max_count( $file_id )

Returns the maximum number of accesses allowed per user for the given file.

Parameters:

  • int $file_id the file id

Returns:

int number of accesses allowed, 0 for unlimited, null on error

Groups_File_Access::get_remaining( $user_id, $file_id )

Returns the number of remaining accesses on the file for the given user.

Parameters:

  • int $user_id the user id
  • int $file_id the file id

Returns:

int remaining number of times the user can access the file or INF if unlimited

GFA_Shortcodes

The GFA_Shortcodes class provides class methods that can be used to render links and information about files handled by the Groups File Access plugin.

GFA_Shortcodes::groups_file_url( $atts, $content = null )

Renders a file URL.

Attributes are passed through $atts:

  • file_id : id of the file
  • visibility : This option determines whether the file URL will be returned for the current user or not. can_access will only return the file URL if the current user is allowed to access the file; always will return the file URL disregarding whether the user is allowed to access the file.

Parameters

  • array $atts attributes
  • string $content – not used

Returns:

string rendered URL

GFA_Shortcodes::groups_file_link( $atts, $content = null )

Renders a link to a file based on settings passed through $atts.

Required attributes are either file_id or group.

Basic attributes:

  • file_id : id of the file
  • visibility : can_access or always see GFA_Shortcodes::groups_file_url()
  • group : group name or ID – will list files for the given group sorted by name
  • description : defaults to noyes shows description for each entry (only group)
  • order : ASC or DESC sort order (only for group)
  • list_prefix : defaults to <ul>
  • list_suffix : defaults to </ul>
  • item_prefix : defaults to <li>
  • item_suffix : defaults to </li>

Note that the prefixes and suffixes are very limited due to filters applied.

Allowed link attributes that are applied to the rendered a tag: accesskeyaltcharsetcoordsclassdirhreflangidlangnamerelrevshapestyletabindextarget

Parameters:

  • array $atts attributes
  • string $content not used

Returns:

string rendered link

GFA_Shortcodes::groups_can_access_file( $atts, $content = null )

Returns $content if the current user can access the file.

Parameters:

  • array $atts attributes – must provide the file_id
  • string $content content to render

Returns:

string $content or empty string

GFA_Shortcodes::groups_can_not_access_file( $atts, $content = null )

Returns $content if the current user can not access the file.

Parameters:

  • array $atts attributes – must provide the file_id
  • string $content content to render

Returns:

string $content or empty string

GFA_Shortcodes::groups_file_info( $atts, $content = null )

Renders file information.

The visibility parameter determines whether the $content will be returned for the current user or not:

can_access will only return $content if the current user is allowed to access the file; alwayswill return $content disregarding whether the user is allowed to access the file

Attributes:

  • file_id : id of the file
  • visibility : can_access (default) or always
  • show : namedescriptioncountmax_countremainingfile_id

Parameters:

  • array $atts attributes – must provide the file_id
  • string $content content to render

Returns:

string $content or empty string

GFA_Shortcodes::groups_visibility( $atts, $content = null )

Allows to switch the default visibility setting for shortcodes handled by GFA_Shortcodes.

Parameters:

  • array $atts attributes must specify the visibility with allowed values alwayscan_access
  • string $content not used