public function __construct($reservation, $connection_id, $domain)
 {
     $this->reservation_id = $reservation->id;
     $this->reservation_name = $reservation->name;
     $path = ConnectionPath::findOne(['conn_id' => $connection_id, 'path_order' => 0]);
     if ($path) {
         $this->source_domain = $path->domain;
     } else {
         $this->source_domain = Yii::t('circuits', 'deleted');
     }
     $path = ConnectionPath::find()->where(['conn_id' => $connection_id])->orderBy("path_order DESC")->one();
     if ($path) {
         $this->destination_domain = $path->domain;
     } else {
         $this->destination_domain = Yii::t('circuits', 'deleted');
     }
     $user = User::findOne(['id' => $reservation->request_user_id]);
     if ($user) {
         $this->requester = $user->name;
     }
     $this->bandwidth = $reservation->bandwidth . " Mbps";
     $paths_domain = ConnectionPath::find()->where(['conn_id' => $connection_id, 'domain' => $domain])->orderBy("path_order ASC")->all();
     $this->port_in = $paths_domain[0]->port_urn;
     $this->port_out = $paths_domain[count($paths_domain) - 1]->port_urn;
 }
Example #2
0
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = User::findByUsername($this->login);
     }
     return $this->_user;
 }
Example #3
0
 public function searchByDomains($params, $allowed_domains, $root)
 {
     $this->load($params);
     Yii::trace($this->domain);
     $domains_name = [];
     foreach ($allowed_domains as $domain) {
         $domains_name[] = $domain->name;
     }
     if (!$root) {
         if ($this->domain) {
             $users = UserDomainRole::find()->where(['in', 'domain', $this->domain])->all();
         } else {
             $users = UserDomainRole::find()->where(['in', 'domain', $domains_name])->all();
         }
         $users_id = [];
         foreach ($users as $user) {
             $users_id[] = $user->user_id;
         }
     } else {
         if ($this->domain) {
             $users = UserDomainRole::find()->where(['in', 'domain', $this->domain])->all();
             $users_id = [];
             foreach ($users as $user) {
                 $users_id[] = $user->user_id;
             }
         } else {
             $users = User::find()->all();
             $users_id = [];
             foreach ($users as $user) {
                 $users_id[] = $user->id;
             }
         }
     }
     $users = User::find()->where(['in', 'id', $users_id])->all();
     $userForm = [];
     foreach ($users as $user) {
         $aux = new UserSearchForm();
         if ($this->domain) {
             $count = UserDomainRole::find()->where(['user_id' => $user->id, 'domain' => $this->domain])->count();
         } else {
             if (!$root) {
                 $count = UserDomainRole::find()->where(['user_id' => $user->id])->andWhere(['in', 'domain', $domains_name])->select('DISTINCT `domain`')->count();
             } else {
                 $count = UserDomainRole::find()->where(['user_id' => $user->id])->select('DISTINCT `domain`')->count();
             }
         }
         $aux->setData($user, $count);
         $userForm[$aux->id] = $aux;
     }
     $data = new ArrayDataProvider(['allModels' => $userForm, 'sort' => false, 'pagination' => ['pageSize' => 15]]);
     return $data;
 }
Example #4
0
 public function validatePass($attr, $params)
 {
     if ($this->isChangedPass) {
         if ($this->currentPass == '' && $this->scenario == self::SCENARIO_USER || $this->newPass == '' || $this->newPassConfirm == '') {
             $this->addError('', 'All password fields are required');
         } else {
             $user = User::findOne(Yii::$app->user->id);
             if ($user->isValidPassword($this->currentPass)) {
                 return true;
             } else {
                 $this->addError('currentPass', Yii::t('aaa', 'Current password does not match'));
             }
         }
     }
     return false;
 }
 public function sendEmail()
 {
     $user;
     if ($this->login != "") {
         $user = User::findByUsername($this->login);
     } else {
         $user = User::findOne(['email' => $this->email]);
     }
     $newPassword = $this->generateRandomString();
     $body = "Hello. Your new password for Meican is: \n\n";
     $body .= $newPassword;
     $body .= "\n\nThis is an automated message, please do not respond.";
     Yii::trace($body);
     $mail = Yii::$app->mailer->compose()->setFrom('*****@*****.**')->setTo($user->email)->setSubject('Meican new Password')->setTextBody($body);
     if ($mail->send()) {
         Yii::trace("Email send to: " . $user->email);
         $user->password = Yii::$app->getSecurity()->generatePasswordHash($newPassword);
         $user->save();
         return true;
     } else {
         $this->addError($this->login, Yii::t('home', 'An error occured, please try again'));
         return false;
     }
 }
Example #6
0
use meican\circuits\models\ConnectionAuth;
use meican\aaa\models\User;
$this->params['header'] = [Yii::t('circuits', 'Pending Authorization'), ['Home', Yii::t('circuits', 'Circuits')]];
?>

<div class="box box-default">
    <div class="box-body">      
	<?php 
echo Grid::widget(['options' => ['class' => 'list'], 'dataProvider' => $data, 'id' => 'gridInfo', 'filterModel' => $searchModel, 'layout' => "{items}{summary}{pager}", 'columns' => array(['label' => Yii::t('circuits', 'Reply request as '), 'value' => 'domain', 'filter' => Html::activeDropDownList($searchModel, 'domain', ArrayHelper::map(ConnectionAuth::find()->select(["domain"])->distinct(true)->orderBy(['domain' => SORT_ASC])->asArray()->all(), 'domain', 'domain'), ['class' => 'form-control', 'prompt' => Yii::t("circuits", 'any')]), 'contentOptions' => ['style' => 'font-weight: bold;'], 'headerOptions' => ['style' => 'width: 23%;']], ['label' => Yii::t('circuits', 'Source Domain'), 'value' => function ($aut) {
    if ($aut->source) {
        return $aut->source;
    } else {
        return Yii::t('circuits', 'deleted');
    }
}, 'filter' => Html::activeDropDownList($searchModel, 'src_domain', ArrayHelper::map(ConnectionPath::find()->select(["domain"])->distinct(true)->orderBy(['domain' => SORT_ASC])->asArray()->all(), 'domain', 'domain'), ['class' => 'form-control', 'prompt' => Yii::t("circuits", 'any')]), 'headerOptions' => ['style' => 'width: 21%;']], ['label' => Yii::t('circuits', 'Destination Domain'), 'value' => function ($aut) {
    if ($aut->destination) {
        return $aut->destination;
    } else {
        return Yii::t('circuits', 'deleted');
    }
}, 'filter' => Html::activeDropDownList($searchModel, 'dst_domain', ArrayHelper::map(ConnectionPath::find()->select(["domain"])->distinct(true)->orderBy(['domain' => SORT_ASC])->asArray()->all(), 'domain', 'domain'), ['class' => 'form-control', 'prompt' => Yii::t("circuits", 'any')]), 'headerOptions' => ['style' => 'width: 21%;']], ['label' => Yii::t('circuits', 'Requester'), 'value' => function ($aut) {
    $user_id = $aut->request_user_id;
    return User::findOne(['id' => $user_id])->name;
}, 'headerOptions' => ['style' => 'width: 12%;']], ['label' => Yii::t('circuits', 'Bandwidth'), 'value' => function ($aut) {
    return $aut->bandwidth . " Mbps";
}, 'headerOptions' => ['style' => 'width: 12%;']], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{answer}', 'buttons' => ['answer' => function ($url, $model) {
    return Html::a(Html::button(Yii::t('circuits', 'Answer'), ['class' => 'btn btn-sm btn-primary']), ['answer', 'id' => $model->id, 'domain' => $model->domain]);
}], 'headerOptions' => ['style' => 'width: 11%;']])]);
?>
	</div>
</div>
 public function searchByDomains($params)
 {
     $this->load($params);
     $userId = Yii::$app->user->getId();
     $now = DateUtils::now();
     $authorizations = [];
     //Armazena os pedidos
     $reservationsVisited = [];
     //Armazena as reservas ja incluidas nos pedidos e o dominio ao qual o pedido foi feito.
     //Pega todas requisições feitas para o usuário
     if ($this->domain) {
         $userRequests = ConnectionAuth::find()->where(['domain' => $this->domain, 'manager_user_id' => $userId, 'status' => Connection::AUTH_STATUS_PENDING])->all();
     } else {
         $userRequests = ConnectionAuth::find()->where(['manager_user_id' => $userId, 'status' => Connection::AUTH_STATUS_PENDING])->all();
     }
     foreach ($userRequests as $request) {
         //Limpa mantendo apenas 1 por reserva
         $uniq = true;
         $conn = Connection::find()->where(['id' => $request->connection_id])->andWhere(['<=', 'start', DateUtils::now()])->one();
         if (isset($conn)) {
             $request->changeStatusToExpired();
             $conn->auth_status = Connection::AUTH_STATUS_EXPIRED;
             $conn->save();
             ReservationNotification::create($conn->id);
         } else {
             $conn = Connection::find()->where(['id' => $request->connection_id])->andWhere(['>', 'start', DateUtils::now()])->one();
             foreach ($reservationsVisited as $res) {
                 if ($conn->reservation_id == $res[0] && $request->domain == $res[1]) {
                     $uniq = false;
                 }
             }
             if ($uniq) {
                 $aux = [];
                 $aux[0] = $conn->reservation_id;
                 $aux[1] = $request->domain;
                 $reservationsVisited[] = $aux;
                 $source = $conn->getFirstPath()->one();
                 $destination = $conn->getLastPath()->one();
                 if (!$this->src_domain || $this->src_domain == $source->domain) {
                     if (!$this->dst_domain || $this->dst_domain == $destination->domain) {
                         $form = new AuthorizationForm();
                         $form->setValues(Reservation::findOne(['id' => $conn->reservation_id]), $request->domain, $source->domain, $destination->domain);
                         $authorizations[] = $form;
                     }
                 }
             }
         }
     }
     //Pega todos os papeis do usuário
     $domainRoles = User::findOne(['id' => $userId])->getRoles()->all();
     foreach ($domainRoles as $role) {
         //Passa por todos papeis
         if ($this->domain) {
             $groupRequests = ConnectionAuth::find()->where(['domain' => $this->domain, 'manager_group_id' => $role->getGroup()->id, 'status' => Connection::AUTH_STATUS_PENDING])->all();
         } else {
             $groupRequests = ConnectionAuth::find()->where(['manager_group_id' => $role->getGroup()->id, 'status' => Connection::AUTH_STATUS_PENDING])->all();
         }
         foreach ($groupRequests as $request) {
             //Passa por todas requisições para testar se o dominio corresponde
             $domain = Domain::findOne(['name' => $request->domain]);
             if ($domain) {
                 if ($role->domain == NULL || $role->domain == $domain->name) {
                     $uniq = true;
                     $conn = Connection::find()->where(['id' => $request->connection_id])->andWhere(['<=', 'start', DateUtils::now()])->one();
                     if (isset($conn)) {
                         $request->changeStatusToExpired();
                         $conn->auth_status = Connection::AUTH_STATUS_EXPIRED;
                         $conn->save();
                         ReservationNotification::create($conn->id);
                     } else {
                         $conn = Connection::find()->where(['id' => $request->connection_id])->andWhere(['>', 'start', DateUtils::now()])->one();
                         foreach ($reservationsVisited as $res) {
                             if ($conn->reservation_id == $res[0] && $domain->name == $res[1]) {
                                 $uniq = false;
                             }
                         }
                         if ($uniq) {
                             $aux = [];
                             $aux[0] = $conn->reservation_id;
                             $aux[1] = $request->domain;
                             $reservationsVisited[] = $aux;
                             $source = $conn->getFirstPath()->one();
                             $destination = $conn->getLastPath()->one();
                             if (!$this->src_domain || $this->src_domain == $source->domain) {
                                 if (!$this->dst_domain || $this->dst_domain == $destination->domain) {
                                     $form = new AuthorizationForm();
                                     $form->setValues(Reservation::findOne(['id' => $conn->reservation_id]), $request->domain, $source->domain, $destination->domain);
                                     $authorizations[] = $form;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $dataProvider = new ArrayDataProvider(['allModels' => $authorizations, 'sort' => false, 'pagination' => ['pageSize' => 15]]);
     return $dataProvider;
 }
Example #8
0
use meican\aaa\models\User;
use meican\circuits\models\Reservation;
use meican\circuits\models\Connection;
use meican\circuits\models\ConnectionPath;
use meican\base\grid\Grid;
echo Grid::widget(['id' => $gridId, 'dataProvider' => $data, 'filterModel' => $searchModel, 'layout' => "{items}{summary}{pager}", 'columns' => array(['class' => 'yii\\grid\\ActionColumn', 'template' => '{view}', 'buttons' => ['view' => function ($url, $model) {
    return Html::a('<span class="fa fa-eye"></span>', $url);
}], 'headerOptions' => ['style' => 'width: 2%;']], ['label' => Yii::t('circuits', 'Name'), 'value' => 'name', 'headerOptions' => ['style' => 'width: 11%;']], ['attribute' => 'date', 'format' => 'datetime', 'headerOptions' => ['style' => 'width: 10%;']], ['label' => Yii::t('circuits', 'Source Domain'), 'value' => function ($model) {
    return $model->getSourceDomain();
}, 'filter' => Html::activeDropDownList($searchModel, 'src_domain', ArrayHelper::map($allowedDomains, 'name', 'name'), ['class' => 'form-control', 'prompt' => Yii::t("circuits", 'any')]), 'headerOptions' => ['style' => 'width: 14%;']], ['label' => Yii::t('circuits', 'Destination Domain'), 'value' => function ($model) {
    return $model->getDestinationDomain();
}, 'filter' => Html::activeDropDownList($searchModel, 'dst_domain', ArrayHelper::map($allowedDomains, 'name', 'name'), ['class' => 'form-control', 'prompt' => Yii::t("circuits", 'any')]), 'headerOptions' => ['style' => 'width: 14%;']], ['label' => Yii::t('circuits', 'Bandwidth'), 'value' => function ($res) {
    return $res->bandwidth . " Mbps";
}, 'headerOptions' => ['style' => 'width: 9%;']], ['label' => Yii::t('circuits', 'Requester'), 'value' => function ($res) {
    $user_id = $res->request_user_id;
    $user = User::findOne(['id' => $user_id]);
    if ($user) {
        return $user->name;
    }
    return null;
}, 'headerOptions' => ['style' => 'width: 12%;']], ['label' => Yii::t('circuits', "Status"), 'format' => 'html', 'value' => function ($model) {
    $conns = $model->getConnections()->select(['status', 'auth_status', 'dataplane_status'])->all();
    if (!$conns) {
        return 'Error';
    }
    //Se for somente uma conexão, mostra os status
    if (count($conns) < 2) {
        return $conns[0]->getStatus() . ", " . $conns[0]->getAuthStatus() . ", " . $conns[0]->getDataStatus();
    }
    //Se forem varias, mostra um resumo
    $provisioned = 0;
Example #9
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUser()
 {
     return $this->hasOne(User::className(), ['id' => 'id']);
 }
Example #10
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getManagerUser()
 {
     return $this->hasOne(User::className(), ['id' => 'manager_user_id']);
 }
Example #11
0
 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'));
     }
 }
Example #12
0
 public function getAuthor()
 {
     switch ($this->type) {
         case self::TYPE_NSI_MESSAGE_TIMEOUT:
         case self::TYPE_NSI_PROVISION_CONFIRMED:
         case self::TYPE_NSI_DATAPLANE_CHANGE:
         case self::TYPE_NSI_SUMMARY_CONFIRMED:
         case self::TYPE_NSI_RESERVE_FAILED:
         case self::TYPE_NSI_RESERVE_CONFIRMED:
         case self::TYPE_NSI_RESERVE_RESPONSE:
         case self::TYPE_NSI_COMMIT_CONFIRMED:
         case self::TYPE_NSI_COMMIT_FAILED:
         case self::TYPE_NSI_RELEASE_CONFIRMED:
         case self::TYPE_NSI_TERMINATE_CONFIRMED:
             return 'Provider';
         case self::TYPE_NSI_SUMMARY:
         case self::TYPE_NSI_TERMINATE:
         case self::TYPE_NSI_PROVISION:
         case self::TYPE_NSI_COMMIT:
         case self::TYPE_NSI_RESERVE:
         case self::TYPE_NSI_RELEASE:
             return 'MEICAN';
         case self::TYPE_USER_CANCEL:
         case self::TYPE_USER_UPDATE:
         case self::TYPE_USER_CREATE:
             return $this->hasOne(User::className(), ['id' => 'author_id'])->select(['name'])->asArray()->one()['name'];
         default:
             return 'Error';
             break;
     }
 }
Example #13
0
 static function deleteNotificationsGroup($user_id, $group, $domain)
 {
     $user = User::findOne($user_id);
     if ($user && $group) {
         Yii::trace("Remover notificações do grupo " . $group->name . " para usuário " . $user->name);
         //Busca todas autorizações do grupo
         //Se tem domínio, procura só as relacionadas ao domínio do papel
         if ($domain) {
             $auths = ConnectionAuth::find()->where(['domain' => $domain, 'type' => ConnectionAuth::TYPE_GROUP, 'manager_group_id' => $group->id])->all();
         } else {
             $auths = ConnectionAuth::find()->where(['type' => ConnectionAuth::TYPE_GROUP, 'manager_group_id' => $group->id])->all();
         }
         //Passa por todas deletando uma notificação
         foreach ($auths as $auth) {
             $notification = Notification::findOne(['user_id' => $user_id, 'type' => Notification::TYPE_AUTHORIZATION, 'info' => $auth->id]);
             if ($notification) {
                 $notification->delete();
             }
         }
     }
 }
Example #14
0
 /**
  * CREATE TOPOLOGY NOTIFICAION
  * @param string $msg (A tag no caso)
  * @param string $date
  * Cria notificação de mudança na topologia. VERSÃO BETA
  */
 public static function createTopologyNotification($msg, $date = null)
 {
     $users = User::find()->all();
     foreach ($users as $user) {
         $not = Notification::findOne(['user_id' => $user->id, 'type' => self::TYPE_TOPOLOGY, 'info' => $msg]);
         if ($not) {
             //Pode receber uma data por parametro, neste caso, utiliza essa data como a data da criação da notificação
             if ($date) {
                 $not->date = $date;
             } else {
                 $not->date = DateUtils::now();
             }
             $not->viewed = 0;
             $not->save();
         } else {
             $not = new Notification();
             $not->user_id = $user->id;
             //Pode receber uma data por parametro, neste caso, utiliza essa data como a data da criação da notificação
             if ($date) {
                 $not->date = $date;
             } else {
                 $not->date = DateUtils::now();
             }
             $not->type = self::TYPE_TOPOLOGY;
             $not->viewed = 0;
             $not->info = $msg;
             $not->save();
         }
     }
 }
Example #15
0
 public function actionAccount()
 {
     $user = User::findOne(Yii::$app->user->id);
     $rolesProvider = new ActiveDataProvider(['query' => $user->getRoles(), 'pagination' => ['pageSize' => 10], 'sort' => false]);
     return $this->render('account', array('model' => $user, 'rolesProvider' => $rolesProvider));
 }
Example #16
0
 public function actionCafe()
 {
     $cafeUser = new CafeUserForm();
     if ($cafeUser->load($_POST) && $cafeUser->validate()) {
         $user = new User();
         $data = Yii::$app->session["data_from_cafe"];
         $data = json_decode($data);
         $user->setFromData($cafeUser->login, $cafeUser->password, $data->name, $data->email, Preference::findOneValue(AaaPreference::AAA_FEDERATION_GROUP), Preference::findOneValue(AaaPreference::AAA_FEDERATION_DOMAIN));
         if ($user->save()) {
             $loginForm = new LoginForm();
             $loginForm->createSession($user);
             return $this->goHome();
         } else {
             foreach ($user->getErrors() as $attribute => $error) {
                 $cafeUser->addError('', $error[0]);
             }
             return $this->render('createCafeUser', array('model' => $cafeUser));
         }
     }
     $data = Yii::$app->session["data_from_cafe"];
     if ($data) {
         $data = json_decode($data);
         $user = User::findOneByEmail($data->email);
         if ($user) {
             $loginForm = new LoginForm();
             $loginForm->createSession($user);
             return $this->goHome();
         } else {
             return $this->render('createCafeUser', array('model' => $cafeUser));
         }
     }
     return $this->goHome();
 }
 /**
  * ACTION REJECT ALL
  * @param string $id
  * @param string $domainTop
  * @param string $message
  */
 public function actionRejectAll($id = null, $domainTop = null, $message = null)
 {
     Yii::trace("Reject ALL");
     Yii::trace("Reservation ID: " . $id);
     Yii::trace("Msg: " . $message);
     if ($id && $domainTop) {
         $userId = Yii::$app->user->getId();
         $reservation = Reservation::findOne(['id' => $id]);
         $allRequest = null;
         $connections = Connection::find()->where(['reservation_id' => $id])->all();
         foreach ($connections as $conn) {
             if ($allRequest == null) {
                 $allRequest = ConnectionAuth::find()->where(['connection_id' => $conn->id, 'domain' => $domainTop]);
             } else {
                 $allRequest->union(ConnectionAuth::find()->where(['connection_id' => $conn->id, 'domain' => $domainTop]));
             }
         }
         $allRequest = $allRequest->all();
         $domainRoles = User::findOne(['id' => $userId])->getRoles()->all();
         $requests = [];
         foreach ($allRequest as $request) {
             if ($request->manager_user_id == $userId) {
                 $requests[$request->id] = $request;
             } else {
                 foreach ($domainRoles as $domainRule) {
                     $groupId = $domainRule->getGroup()->id;
                     if ($request->manager_group_id == $groupId) {
                         $requests[$request->id] = $request;
                     }
                 }
             }
         }
         foreach ($requests as $req) {
             if ($req->status == Connection::AUTH_STATUS_PENDING) {
                 if ($req->type == ConnectionAuth::TYPE_GROUP) {
                     $req->manager_user_id = Yii::$app->user->getId();
                 }
                 if ($message) {
                     $req->manager_message = $message;
                 }
                 $req->status = Connection::AUTH_STATUS_REJECTED;
                 $req->save();
                 $flow = new BpmFlow();
                 $flow->response($req->connection_id, $req->domain, BpmFlow::STATUS_NO);
             }
         }
     }
 }
Example #18
0
 public function checkGroup($flow, $reservation)
 {
     Yii::trace("Testando Grupo");
     $user = User::findOne($reservation->request_user_id);
     $roles = $user->getRoles()->all();
     foreach ($roles as $role) {
         $group = $role->getGroup();
         if ($role->domain == null || $role->domain == $flow->domain) {
             if ($flow->value == $group->id) {
                 $flow->status = self::STATUS_YES;
                 return;
             }
         }
     }
     Yii::trace("Não passou em GROUP");
     $flow->status = self::STATUS_NO;
 }