Exemplo n.º 1
0
 public function run()
 {
     $var = [];
     $items = AuthItem::getAuthItems();
     $service = [];
     foreach ($items as $item) {
         if ($item->type == 2) {
             continue;
         }
         $child = [];
         foreach ($items as $c) {
             if ($c->type == 1) {
                 continue;
             }
             if (preg_match('/^' . $item->name . '/', $c->name)) {
                 $child[] = $c;
             }
         }
         $item->setAttribute("child", $child);
         $service[] = $item;
     }
     $userId = Yii::$app->user->getId();
     $assign = AuthAssignment::getAssignById($userId);
     foreach ($assign as $assignment) {
         $var["assignments"][] = $assignment->getAttributes();
     }
     $var['services'] = $service;
     $var['group'] = AuthGroup::getGroups();
     return $this->render('navigation', ['var' => $var]);
 }
Exemplo n.º 2
0
 public function init()
 {
     parent::init();
     $this->baseUrl = TextUtils::getBaseUrl();
     $this->timeZone = 'Asia/Ho_Chi_Minh';
     Yii::$app->language = 'vi-VN';
     $assignments = Yii::$app->session->get("assignments");
     if (empty($assignments)) {
         $assignments = AuthAssignment::findAll(['user_id' => Yii::$app->user->getId()]);
         Yii::$app->session->set('assignments', $assignments);
     }
     $this->var['assignments'] = $assignments;
 }
Exemplo n.º 3
0
 /**
  * @return ActiveQuery
  */
 public function getAuthAssignments()
 {
     return $this->hasMany(AuthAssignment::className(), ['item_name' => 'name']);
 }
Exemplo n.º 4
0
 /**
  * Xóa toàn bộ quyền hiện tại
  * @param type $userId
  * @return type
  */
 public static function removeAssignmentByUserId($userId)
 {
     return AuthAssignment::deleteAll(["user_id" => $userId]);
 }