This is the documentation for concrete5 version 5.6 and earlier. View Current Documentation

concrete 5.4 introduces the concept of task-based permissions. These permissions are highly specific to a certain task, as opposed to general content-based permissions (which are based around specific instances and types of content.) These task permissions can be accessed from the dashboard. Developers can also install their own task permissions, and install them through a package.

Example of Task-Based Permissions

  • Specifying who can edit page defaults
  • Specifying who can sign in as a user account.
  • Specifying who can uninstall packages

Checking a Task-Based Permission against the Logged-In User

	$tp = TaskPermission::getByHandle('page_defaults'); 	if ($tp->can()) { 		print 'yes'; 	}

Using the Magic Method

Grab the handle of the task-based permission, camelcase it, and add it to "canAccess"

	$tp = new TaskPermission(); 	if ($tp->canAcessPageDefaults()) { 		print 'yes'; 	}

Checking a task-based permission against another user or group

Simply pass the Group or UserInfo object to the can() method

	$ui = UserInfo::getByUserName('johndoe'); 	$tp = TaskPermission::getByHandle('page_defaults'); 	if ($tp->can($ui)) { 		print 'johndoe can access'; 	}

Methods

$tp = TaskPermission::getByID($tpID)

Returns a TaskPermission object based on $tpID.

$tp = TaskPermission::getByHandle($tpHandle)

Returns a TaskPermission object based on its handle.

$tp->getTaskPermissionID()

Gets the ID of the current task permission object.

$tp->getTaskPermissionID()

Gets the ID of the current task permission object.

$tp->getTaskPermissionName()

Gets the name of the current task permission object.

$tp->getTaskPermissionHandle()

Gets the handle of the current task permission object.

$tp->getTaskPermissionDescription()

Gets the description of the current task permission object.

$tp->getPackageID()

Returns the package ID for the current task permission object.

$tp->getPackageHandle()

Returns the package handle for the current task permission object.

$tp->delete()

Delete the current task permission.

$tp->clearPermissions()

Clear all permissions associated with the task. $tp->addAccess($obj) Pass either a UserInfo or Group object. Adds access for the passed object.

$tp->removeAccess($obj)

Pass either a UserInfo or Group object. Removes access for the passed object.

$tp->can($obj = false)

Checks whether the current task can be accessed. If $obj is false, the currently logged-in user is checked.

Loading Conversation