示例#1
0
 /**
  * @param string|integer $user the user ID.
  * @param Item $item the role or permission that this rule is associated with
  * @param array $params parameters passed to ManagerInterface::checkAccess().
  * @return boolean a value indicating whether the rule permits the role or permission it is associated with.
  */
 public function execute($user, $item, $params)
 {
     $areaPersonal = AreaPersonal::findOne($params['id_area'], $user);
     if ($areaPersonal != NULL) {
         return true;
     }
     return false;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = AreaPersonal::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['area_id' => $this->area_id, 'user_id' => $this->user_id, 'permission' => $this->permission]);
     return $dataProvider;
 }
示例#3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = AreaPersonal::find();
     $query->joinWith('area');
     $query->joinWith('user');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['area_Name'] = ['asc' => ['areas.name' => SORT_ASC], 'desc' => ['areas.name' => SORT_DESC]];
     $dataProvider->sort->attributes['user_Name'] = ['asc' => ['users.first_name' => SORT_ASC], 'desc' => ['users.first_name' => SORT_DESC]];
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['name' => $this->area_id, 'first_name' => $this->user_id, 'permission' => $this->permission])->andFilterWhere(['like', 'areas.name', $this->area_Name])->andFilterWhere(['like', 'user.first_name', $this->user_Name]);
     return $dataProvider;
 }
示例#4
0
 /**
  * Finds the AreaPersonal model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $area_id
  * @param string $user_id
  * @return AreaPersonal the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($area_id, $user_id)
 {
     if (($model = AreaPersonal::findOne(['area_id' => $area_id, 'user_id' => $user_id])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#5
0
    ?>
                    </td>
                    <td class="skip-export kv-align-center kv-align-middle">
                        <?php 
    $user = User::findOne($pers["user_id"]);
    echo $user->first_name;
    ?>
                    </td>
                    <td class="skip-export kv-align-center kv-align-middle">
                        <?php 
    echo $user->lastname;
    ?>
                    </td>
                    <td class="skip-export kv-align-center kv-align-middle">
                        <?php 
    $relationship = AreaPersonal::find()->where(['user_id' => $pers['user_id'], 'area_id' => $area->id])->one();
    echo $relationship->permission;
    ?>
                    </td>
                    <td class="skip-export kv-align-center kv-align-middle">
                        <a data-toggle="modal" data-target="#permissionsModal"
                           data-user-id="<?php 
    echo $user->id;
    ?>
" data-area-id="<?php 
    echo $area->id;
    ?>
">
                            <span data-toggle="tooltip" title="Modify permission"
                                  class="glyphicon glyphicon-pencil"></span>
                        </a>
示例#6
0
文件: Areas.php 项目: Hyuchiha/SAU
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAreaPersonals()
 {
     return $this->hasMany(AreaPersonal::className(), ['area_id' => 'id']);
 }
 public function actionRemove($a_id, $u_id)
 {
     $model = AreaPersonal::find()->where(['user_id' => $u_id, 'area_id' => $a_id])->one();
     $model->delete();
     return $this->redirect('modify?id=' . $a_id);
 }