You are here

function workflow_access_get_features_workflow_access_by_sid in Workflow 7

Same name and namespace in other branches
  1. 7.2 workflow_access/workflow_access.features.inc \workflow_access_get_features_workflow_access_by_sid()

Get workflow_access object like below by state id.

array( 'rname' => 'authenticated user', 'grant_view' => 1, 'grant_update' => 0, 'grant_delete' => 0, );

State id and workflow id are not returned because they are implicit for a given sid.

1 call to workflow_access_get_features_workflow_access_by_sid()
workflow_access_features_export_render in workflow_access/workflow_access.features.inc
Implements hook_features_export_render().

File

workflow_access/workflow_access.features.inc, line 181

Code

function workflow_access_get_features_workflow_access_by_sid($sid) {

  // Get all workflow access rules for a sid, where wa.rid is either a valid role or -1,
  // stands for the author
  $sql = <<<SQL
SELECT
  r.name as rname,
  wa.grant_view, wa.grant_update, wa.grant_delete
FROM {workflow_access} wa
  LEFT JOIN {role} r ON wa.rid = r.rid
WHERE
  wa.sid = :sid AND (wa.rid = r.rid OR wa.rid = -1)
SQL;
  $results = db_query($sql, array(
    ':sid' => $sid,
  ));
  $records = $results
    ->fetchAll();
  foreach ($records as $record) {
    if (empty($record->rname)) {
      $record->rname = WORKFLOW_FEATURES_AUTHOR_NAME;
    }
  }
  return $records;
}