lib/controllers/ObjectController.php
public function actionAccess()
    {
        $subform = null;
        $p = $this->_parseParams();
        $this->_checkParams($p, ['object', 'type']);
        $this->params = &$p;

        $primaryModel = $p['type']->primaryModel;
        $this->params['errors'] = [];
        Yii::$app->response->view = 'access';
        $taskOptions = ['title' => 'Access for ' . $p['type']->title->getSingular(true)];
        $lookAtPost = false;
        if ($p['object']->can('manageAccess')) {
            $lookAtPost = true;
            $taskOptions['title'] = 'Manage ' . $taskOptions['title'];
            $taskOptions['isForm'] = false;
        }
        $this->params['access'] = $access = $p['object']->objectAccess;
        $this->params['disableFields'] = !$lookAtPost;
        $taskOptions['isForm'] = $lookAtPost;
        $objectRoles = $access->roleObjects;
        Yii::$app->response->task = 'dialog';
        Yii::$app->response->taskOptions = $taskOptions;
        if ($lookAtPost && !empty($_POST['roles'])) {
            $result = $access->save($_POST['roles']);
            if (!empty($result['errors'])) {
                if (is_array($result['errors'])) {
                    $this->params['errors'] = $result['errors'];
                    Yii::$app->response->error = 'An error occurred while saving the object\'s sharing settings.';
                } else {
                    Yii::$app->response->error = $result['errors'];
                }
                foreach ($result['data'] as $requestorId => $roleId) {
                    $objectRole = $access->getRoleObject($requestorId, $roleId);
                    if (!isset($objectRoles[$requestorId])
                            || (isset($objectRoles[$requestorId]['role'])
                                    && $objectRoles[$requestorId]['role']->object->primaryKey !== $roleId)
                    ) {
                        $objectRoles[$requestorId] = $objectRole;
                    }
                }
            } else {
                Yii::$app->response->task = 'status';
                Yii::$app->response->success = 'Access has been updated.';
                if (empty($p['relatedObject'])) {
                    Yii::$app->response->refresh = true;
                } else {
                    $primaryModel = $p['type']->primaryModel;
                    Yii::$app->response->trigger = [
                        ['refresh', '.model-' . $primaryModel::baseClassName()],
                    ];
                }
            }
        }
        $this->params['objectRoles'] = $objectRoles;
    }
public function actionAccess()
    {
        $subform = null;
        $p = $this->_parseParams();
        $this->_checkParams($p, ['object', 'type']);
        $this->params = &$p;

        $primaryModel = $p['type']->primaryModel;
        $this->params['errors'] = [];
        Yii::$app->response->view = 'access';
        $taskOptions = ['title' => 'Access for ' . $p['type']->title->getSingular(true)];
        $lookAtPost = false;
        if ($p['object']->can('manageAccess')) {
            $lookAtPost = true;
            $taskOptions['title'] = 'Manage ' . $taskOptions['title'];
            $taskOptions['isForm'] = false;
        }
        $this->params['access'] = $access = $p['object']->objectAccess;
        $this->params['disableFields'] = !$lookAtPost;
        $taskOptions['isForm'] = $lookAtPost;
        $objectRoles = $access->roleObjects;
        Yii::$app->response->task = 'dialog';
        Yii::$app->response->taskOptions = $taskOptions;
        if ($lookAtPost && !empty($_POST['roles'])) {
            $result = $access->save($_POST['roles']);
            if (!empty($result['errors'])) {
                if (is_array($result['errors'])) {
                    $this->params['errors'] = $result['errors'];
                    Yii::$app->response->error = 'An error occurred while saving the object\'s sharing settings.';
                } else {
                    Yii::$app->response->error = $result['errors'];
                }
                foreach ($result['data'] as $requestorId => $roleId) {
                    $objectRole = $access->getRoleObject($requestorId, $roleId);
                    if (!isset($objectRoles[$requestorId])
                            || (isset($objectRoles[$requestorId]['role'])
                                    && $objectRoles[$requestorId]['role']->object->primaryKey !== $roleId)
                    ) {
                        $objectRoles[$requestorId] = $objectRole;
                    }
                }
            } else {
                Yii::$app->response->task = 'status';
                Yii::$app->response->success = 'Access has been updated.';
                if (empty($p['relatedObject'])) {
                    Yii::$app->response->refresh = true;
                } else {
                    $primaryModel = $p['type']->primaryModel;
                    Yii::$app->response->trigger = [
                        ['refresh', '.model-' . $primaryModel::baseClassName()],
                    ];
                }
            }
        }
        $this->params['objectRoles'] = $objectRoles;
    }
[[@doctodo method_description:actionAccess]].