public function actionIndex() { if (!self::can("group/read")) { //Se ele não tiver permissão return $this->goHome(); } $dataProvider = new ActiveDataProvider(['query' => Group::find()]); return $this->render('index', array('groups' => $dataProvider)); }
public function actionEditorUpdate($id = null) { $this->layout = 'wireit'; if ($id) { $workflow = BpmWorkflow::findOne(['id' => $id]); if ($workflow) { $domain = Domain::findOne(['name' => $workflow->domain]); if ($domain) { if (!self::can('workflow/update', $domain->name)) { if (!self::can("workflow/read")) { return $this->goHome(); } else { Yii::$app->getSession()->setFlash('warning', Yii::t("bpm", 'You are not allowed to edit in domain {domain}', ['domain' => $domain->name])); return $this->redirect(array('/bpm/workflow/index')); } } $ownerDomain = []; $ownerDomain[$domain->name] = $domain->name; $domains = Domain::find()->orderBy(['name' => SORT_ASC])->all(); $allDomains = []; foreach ($domains as $dom) { $allDomains[$dom->name] = $dom->name; } $roles = $domain->getUserDomainsRoles()->all(); $adminsNames = []; foreach ($roles as $role) { $adminsNames[$role->getUser()->id] = $role->getUser()->name; } foreach (User::find()->all() as $user) { $usersNames[$user->id] = $user->name; } $groupsNames = []; foreach (Group::find()->where(['type' => Group::TYPE_DOMAIN, 'domain' => $domain->name])->orWhere(['type' => Group::TYPE_DOMAIN, 'domain' => null])->all() as $group) { $groupsNames[$group->id] = $group->name; } $devicesNames = []; foreach (Device::find()->where(['domain_id' => $domain->id])->all() as $device) { $devicesNames[$device->id] = $device->name; } Yii::trace($roles); Yii::trace($usersNames); Yii::trace($groupsNames); Yii::trace($devicesNames); return $this->render('editor', array('owner_domain' => $ownerDomain, 'domains' => $allDomains, 'groups' => $groupsNames, 'users' => $usersNames, 'admins' => $adminsNames, 'devices' => $devicesNames, 'id' => $_GET['id'])); } } } if (!self::can("workflow/read")) { return $this->goHome(); } else { return $this->redirect(array('/bpm/workflow/index')); } }
static function getGlobalDomainGroupsNoArray() { return Group::find()->where(['type' => Group::TYPE_DOMAIN, 'domain' => null])->orderBy(['name' => SORT_ASC])->all(); }