public function actionIndex() { if (!self::can("domainTopology/read") && !self::can("domain/read")) { return $this->goHome(); } return $this->render('index', ['domains' => Domain::find()->select(['id', 'name'])->asArray()->all()]); }
public function actionIndex() { if (self::can("user/read")) { $allowedDomains = Domain::find()->orderBy(['name' => SORT_ASC])->all(); $searchModel = new UserSearch(); $data = $searchModel->searchByDomains(Yii::$app->request->get(), $allowedDomains, true); } else { if (self::can("role/read")) { $allowedDomains = self::whichDomainsCan('role/read'); $searchModel = new UserSearch(); $data = $searchModel->searchByDomains(Yii::$app->request->get(), $allowedDomains, false); } else { return $this->goHome(); } } return $this->render('index', array('searchModel' => $searchModel, 'users' => $data, 'domains' => $allowedDomains)); }
public function actionGetByName($name, $cols = null) { $query = Domain::find()->where(['name' => $name])->asArray(); $cols ? $data = $query->select(json_decode($cols))->one() : ($data = $query->one()); $temp = Json::encode($data); Yii::trace($temp); return $temp; }
echo $form->field($model, 'name')->textInput(['size' => 50]); ?> <?php echo $form->field($model, 'nsa')->textInput(['size' => 50]); ?> <?php echo $form->field($model, 'type')->dropDownList(ArrayHelper::map(Provider::getTypes(), 'id', 'name')); ?> <?php echo $form->field($model, 'latitude')->textInput(['size' => 20]); ?> <?php echo $form->field($model, 'longitude')->textInput(['size' => 20]); ?> <?php echo $form->field($model, 'domain_id')->dropDownList(ArrayHelper::map(Domain::find()->select(['id', 'name'])->asArray()->all(), 'id', 'name')); ?> </div> <div class="box-footer"> <div class="form-group"> <div class="col-sm-offset-3 col-sm-6"> <button type="submit" class="btn btn-primary"><?php echo Yii::t("topology", 'Save'); ?> </button> </div> </div> </div> </div> <?php
public function actionGetAllColor($cols = null) { $query = Device::find()->orderBy(['name' => 'SORT ASC'])->asArray(); $cols ? $data = $query->select(array_merge(json_decode($cols), ['domain_id']))->all() : ($data = $query->all()); foreach ($data as &$dev) { $dev['color'] = Domain::find()->where(['id' => $dev['domain_id']])->select(['color'])->asArray()->one()['color']; } $temp = Json::encode($data); Yii::trace($temp); return $temp; }
<div class="box box-default"> <div class="box-header with-border"> <h3 class="box-title"><?php echo Yii::t("aaa", "Federation sign-in"); ?> </h3></h3> </div> <div class="box-body"> <?php echo $form->field($model, 'status')->dropDownList(ArrayHelper::map([['id' => 'true', 'name' => Yii::t("aaa", "Enabled")], ['id' => 'false', 'name' => Yii::t("aaa", "Disabled")]], 'id', 'name')); ?> <?php echo $form->field($model, 'group')->dropDownList(ArrayHelper::map(UserDomainRole::getDomainGroups(), 'role_name', 'name')); ?> <?php echo $form->field($model, 'domain')->dropDownList(array_merge([null => Yii::t("aaa", "any")], ArrayHelper::map(Domain::find()->orderBy(['name' => SORT_ASC])->asArray()->all(), 'name', 'name'))); ?> </div> <div class="box-footer"> <div class="form-group"> <div class="col-sm-offset-3 col-sm-6"> <button type="submit" class="btn btn-primary"><?php echo Yii::t("aaa", 'Save'); ?> </button> </div> </div> </div> </div> <?php
static function whichDomainsCan($permissions = null, $asArray = false) { $domains = Domain::find()->orderBy(['name' => SORT_ASC]); if ($asArray) { $domains = $domains->asArray()->all(); $canDomains = []; foreach ($domains as $domain) { if (self::can($permissions, $domain['name'])) { $canDomains[] = $domain; } } return $canDomains; } else { $domains = $domains->all(); $canDomains = []; foreach ($domains as $domain) { if (self::can($permissions, $domain->name)) { $canDomains[] = $domain; } } return $canDomains; } }
public function actionGetUserDomains() { $domains = Domain::find()->orderBy(['name' => SORT_ASC])->all(); $domainsClean = []; foreach ($domains as $domain) { if (self::can('workflow/create', $domain->name)) { $domainsClean[$domain->name] = $domain->name; } } echo json_encode($domainsClean); }
public function actionIndex($mode = "read") { $data = new ActiveDataProvider(['query' => Test::find()->where(['type' => Reservation::TYPE_TEST]), 'pagination' => ['pageSize' => 15], 'sort' => false]); return $this->render('status', array('data' => $data, 'mode' => $mode, 'domains' => json_encode(Domain::find()->orderBy(['name' => "SORT ASC"])->asArray()->select(['id', 'name'])->all()))); }
static function getDomains($allowed_domains) { $domains_name = []; foreach ($allowed_domains as $domain) { $domains_name[] = $domain->name; } return Domain::find()->where(['in', 'name', $domains_name])->orderBy(['name' => "SORT ASC"])->asArray()->all(); }
public function actionUpdateRoleDomain($id) { $udr = UserDomainRole::findOne($id); if (!$udr) { if (!self::can("user/read") && !self::can("role/read", $udr->domain)) { return $this->goHome(); } else { Yii::$app->getSession()->addFlash('warning', Yii::t('topology', 'Role not found')); return $this->redirect(array('/aaa/user/view', 'id' => $udr->user_id)); } } if (!self::can("role/update", $udr->domain) && !self::can("user/update")) { if (!self::can("user/read") && !self::can("role/read")) { return $this->goHome(); } else { Yii::$app->getSession()->addFlash('warning', Yii::t('aaa', 'You are not allowed to update roles')); return $this->redirect(array('/aaa/user/view', 'id' => $udr->user_id)); } } $udr->getGroup(); $group = $udr->getGroup(); $domain = $udr->getDomain(); if (isset($_POST["UserDomainRole"])) { $form = $_POST["UserDomainRole"]; $udr->_groupRoleName = $form["_groupRoleName"]; $roleDomain = $form['domain']; if ($roleDomain == "") { $udr->domain = null; } else { $udr->domain = $roleDomain; } $alreadyHas = false; $roles = UserDomainRole::find()->where(['domain' => $udr->domain, 'user_id' => $udr->user_id])->all(); foreach ($roles as $role) { if ($role->getGroup()->role_name == $udr->_groupRoleName) { $alreadyHas = true; break; } } if ($alreadyHas) { Yii::$app->getSession()->setFlash("warning", Yii::t("aaa", 'The user already has this profile')); return $this->redirect(array('/aaa/user/view', 'id' => $udr->user_id)); } else { if ($udr->save()) { AaaNotification::createRole($udr); AaaNotification::deleteRole($udr, $group, $domain); Yii::$app->getSession()->setFlash("success", Yii::t("aaa", 'Role updated successfully')); return $this->redirect(array('/aaa/user/view', 'id' => $udr->user_id)); } else { foreach ($udr->getErrors() as $attribute => $error) { Yii::$app->getSession()->setFlash("error", $error[0]); } } } } if (self::can("user/create")) { $anyDomain = [null => Yii::t("aaa", "any")]; $domains = Domain::find()->orderBy(['name' => SORT_ASC])->asArray()->all(); } else { $domains = self::whichDomainsCan("role/create"); $anyDomain = []; } $groups = []; if ($udr->domain != null) { foreach (UserDomainRole::getDomainGroupsByDomainNoArray($udr->domain) as $group) { $groups[$group->role_name] = $group->name . " (" . $udr->domain . ")"; } } foreach (UserDomainRole::getGlobalDomainGroupsNoArray() as $group) { $groups[$group->role_name] = $group->name; } return $this->renderPartial('_edit-role-domain', array('udr' => $udr, 'groups' => $groups, 'domains' => $domains, 'anyDomain' => $anyDomain)); }
public function actionCreate() { return $this->render('create/create2', ['domains' => Domain::find()->asArray()->all(), 'reserveForm' => new ReservationForm()]); }
static function findOneByName($name) { return Domain::find()->where(['name' => $name])->one(); }