Blame view

app/mihaildev/elfinder/UserPath.php 707 Bytes
bf807468   Alex Savenko   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  <?php
  /**
   * Date: 22.01.14
   * Time: 14:13
   */
  
  namespace app\mihaildev\elfinder;
  
  use Yii;
  
  class UserPath extends LocalPath{
  
      public function isAvailable(){
          if(Yii::$app->user->isGuest)
              return false;
  
          return parent::isAvailable();
      }
  
      public function getUrl(){
          $path = strtr($this->path, ['{id}'=>Yii::$app->user->id]);
          return Yii::getAlias($this->baseUrl.'/'.trim($path,'/'));
      }
  
      public function getRealPath(){
          $path = strtr($this->path, ['{id}'=>Yii::$app->user->id]);
          $path = Yii::getAlias($this->basePath.'/'.trim($path,'/'));
          if(!is_dir($path))
              mkdir($path, 0777, true);
  
          return $path;
      }
  }