frontend/modules/download/controllers/FolderController.php
/**
     * Renders the index view for the module
     * @return string
     */
Renders the index view for the module
@return string
Renders the index view for the module @return string
public function actionIndex()
    {
        $model = new DynamicModel(['share_group_hash', 'file_id']);
        $model->addRule(['share_group_hash'], 'required');
        $model->addRule(['share_group_hash'], 'string', ['length' => 32]);
        $model->addRule(['file_id'], 'integer', ['min' => 0]);
        $data[$model->formName()] = Yii::$app->request->get();
        if ($model->load($data) && $model->validate()) {
            if (!$model->file_id) {
                $where = ['share_hash' => $model->share_group_hash];
            } else {
                $where = ['share_group_hash' => $model->share_group_hash, 'file_id' => $model->file_id];
            }
            $shareParent = UserFiles::find()
                ->where($where)
                ->andWhere("(share_lifetime > :share_lifetime) OR (share_lifetime IS NULL)", ['share_lifetime'  => date(SQL_DATE_FORMAT)])
                ->andWhere("last_event_type <> :last_event_type", ['last_event_type' => UserFileEvents::TYPE_DELETE])
                ->one();
            if ($shareParent) {
                $shareChildren = UserFiles::find()
                    ->asArray()
                    ->select([
                        'file_id',
                        'share_hash',
                        'share_group_hash',
                        'file_name',
                        'file_size',
                        'file_parent_id',
                        'is_folder',
                    ])
                    ->where([
                        'share_group_hash' => $shareParent->share_group_hash,
                        'file_parent_id' => $shareParent->file_id,
                    ])
                    ->andWhere("(share_lifetime > :share_lifetime) OR (share_lifetime IS NULL)", ['share_lifetime'  => date(SQL_DATE_FORMAT)])
                    ->andWhere("last_event_type <> :last_event_type", ['last_event_type' => UserFileEvents::TYPE_DELETE])
                    ->orderBy(['is_folder' => SORT_DESC, 'file_name' => SORT_ASC])
                    ->all();
                    if (!$shareChildren) {
                        $shareChildren = [];
                    }
                    if ($shareParent->file_parent_id) {
                        $parentShareParent = UserFiles::findOne([
                            'file_id'          => $shareParent->file_parent_id,
                            'share_group_hash' => $model->share_group_hash,
                        ]);
                        if ($parentShareParent) {
                            $share_top = ['file_id' => null, 'share_hash' => '', 'share_group_hash' => $model->share_group_hash, 'file_name' => '.', 'is_folder' => UserFiles::TYPE_TOP_FOLDER, 'file_size' => 0, 'file_parent_id' => UserFiles::ROOT_PARENT_ID];
                            $share_up = ['file_id' => null, 'share_hash' => '', 'share_group_hash' => $model->share_group_hash, 'file_name' => '..', 'is_folder' => UserFiles::TYPE_UP_FOLDER, 'file_size' => 0, 'file_parent_id' => $shareParent->file_id];
                            array_unshift($shareChildren, $share_top, $share_up);
                             exit;
                        }
                    }
                    $dataProvider = new ArrayDataProvider([
                        'allModels'  => $shareChildren,
                        'pagination' => false,
                    ]);
                    return $this->render('index', [
                        'share_group_hash' => $model->share_group_hash,
                        'shareParent'      => $shareParent,
                        'dataProvider'     => $dataProvider,
                    ]);
            }
        }
        return "404 Share Not Found";
    }
public function actionIndex ( ) { $ model = new DynamicModel ( [ 'share_group_hash' , 'file_id' ] ) ; $ model -> addRule ( [ 'share_group_hash' ] , 'required' ) ; $ model -> addRule ( [ 'share_group_hash' ] , 'string' , [ 'length' => 32 ] ) ; $ model -> addRule ( [ 'file_id' ] , 'integer' , [ 'min' => 0 ] ) ; $ data [ $ model -> formName ( ) ] = Yii :: $ app -> request -> get ( ) ; if ( $ model -> load ( $ data ) && $ model -> validate ( ) ) { if ( ! $ model -> file_id ) { $ where = [ 'share_hash' => $ model -> share_group_hash ] ; } else { $ where = [ 'share_group_hash' => $ model -> share_group_hash , 'file_id' => $ model -> file_id ] ; } $ shareParent = UserFiles :: find ( ) -> where ( $ where ) -> andWhere ( " (share_lifetime > :share_lifetime) OR (share_lifetime IS NULL) " , [ 'share_lifetime' => date ( SQL_DATE_FORMAT ) ] ) -> andWhere ( " last_event_type <> :last_event_type " , [ 'last_event_type' => UserFileEvents :: TYPE_DELETE ] ) -> one ( ) ; if ( $ shareParent ) { $ shareChildren = UserFiles :: find ( ) -> asArray ( ) -> select ( [ 'file_id' , 'share_hash' , 'share_group_hash' , 'file_name' , 'file_size' , 'file_parent_id' , 'is_folder' , ] ) -> where ( [ 'share_group_hash' => $ shareParent -> share_group_hash , 'file_parent_id' => $ shareParent -> file_id , ] ) -> andWhere ( " (share_lifetime > :share_lifetime) OR (share_lifetime IS NULL) " , [ 'share_lifetime' => date ( SQL_DATE_FORMAT ) ] ) -> andWhere ( " last_event_type <> :last_event_type " , [ 'last_event_type' => UserFileEvents :: TYPE_DELETE ] ) -> orderBy ( [ 'is_folder' => SORT_DESC , 'file_name' => SORT_ASC ] ) -> all ( ) ; if ( ! $ shareChildren ) { $ shareChildren = [ ] ; } if ( $ shareParent -> file_parent_id ) { $ parentShareParent = UserFiles :: findOne ( [ 'file_id' => $ shareParent -> file_parent_id , 'share_group_hash' => $ model -> share_group_hash , ] ) ; if ( $ parentShareParent ) { $ share_top = [ 'file_id' => null , 'share_hash' => '' , 'share_group_hash' => $ model -> share_group_hash , 'file_name' => '.' , 'is_folder' => UserFiles :: TYPE_TOP_FOLDER , 'file_size' => 0 , 'file_parent_id' => UserFiles :: ROOT_PARENT_ID ] ; $ share_up = [ 'file_id' => null , 'share_hash' => '' , 'share_group_hash' => $ model -> share_group_hash , 'file_name' => '..' , 'is_folder' => UserFiles :: TYPE_UP_FOLDER , 'file_size' => 0 , 'file_parent_id' => $ shareParent -> file_id ] ; array_unshift ( $ shareChildren , $ share_top , $ share_up ) ; } } $ dataProvider = new ArrayDataProvider ( [ 'allModels' => $ shareChildren , 'pagination' => false , ] ) ; return $ this -> render ( 'index' , [ 'share_group_hash' => $ model -> share_group_hash , 'shareParent' => $ shareParent , 'dataProvider' => $ dataProvider , ] ) ; } } return " 404 Share Not Found " ; }
Renders the index view for the module
 @return string
Renders the index view for the module @return string
/** @var array $share */ //var_dump($_GET); exit; //$model->addRule(['file_id'], 'default', ['value' => 0]); /** @var \common\models\UserFiles $shareParent */ //var_dump($shareParent); exit; /*
                    ->andWhere("(share_lifetime > :share_lifetime) OR ((share_lifetime IS NULL) AND (share_ttl_info != :TTL_IMMEDIATELY_DOWNLOADED))", [
                        'share_lifetime'             => date(SQL_DATE_FORMAT),
                        'TTL_IMMEDIATELY_DOWNLOADED' => UserFiles::TTL_IMMEDIATELY_DOWNLOADED,
                    ])
                    */ //var_dump($shareChildren);exit; //var_dump($shareChildren); //if (sizeof($shareChildren) > 0 || $model->file_id) { //var_dump($shareParent->share_group_hash); //var_dump($model->share_group_hash); //exit; //var_dump($shareChildren); exit; //} //var_dump($model->getErrors());