Exemplo n.º 1
-1
 /**
  * Modifies the group input to let the user choose all existing groups.
  *
  * @param $cells
  * @return array
  */
 private function modifyGroupInput($cells)
 {
     foreach ($cells as $cell) {
         if (is_numeric(strpos($cell, '[group]'))) {
             $searchModel = new PasswordSearch();
             $acc_groups = Password::find()->select(['id', 'group'])->where(['is not', 'group', null])->asArray()->all();
             // Filter unique group items from all account credentials.
             $acc_groups = self::getUniqueArrItems($acc_groups, 'group');
             // Groups for which the user has access.
             $allowed_acc_groups = array();
             if (is_object(\Yii::$app->user->identity) && intval(\Yii::$app->user->identity->is_admin) !== 1) {
                 foreach ($acc_groups as $a_group) {
                     // Iterate all groups and check if user is allowed.
                     if (PasswordController::checkAccessByAccId($a_group['id'])) {
                         $allowed_acc_groups[] = $a_group;
                     }
                 }
             } else {
                 // Admin can access everything.
                 $allowed_acc_groups = $acc_groups;
             }
             $arr_dropdown = ArrayHelper::map($allowed_acc_groups, 'group', 'group');
             $cell = Html::activeDropDownList($searchModel, 'group', $arr_dropdown, ['class' => 'form-control', 'prompt' => 'Select Group']);
             $cell = $this->render('@app/modules/yiipass/views/elements/dropdown', array('group_input' => $cell));
         }
         // Remove "lastaccess" input. Working sorting is enough here. Input for date works not good.
         if (is_numeric(strpos($cell, '[lastaccess]'))) {
             $cell = '';
         }
         $new_cells[] = $cell;
     }
     return $new_cells;
 }