예제 #1
0
 /**
  * 如果是在根目录下,则获取用户的共享目录
  */
 public function handlerGetShared($user_id, $include_deleted = false, $root = 'miniyun', $contents = array())
 {
     $search = '/' . $user_id . '/';
     $file_metas = FileMeta::model()->findAll("meta_key=:type1 and file_path like :type2", array(':type1' => 'shared_folders', ':type2' => $search . "%"));
     //
     // 组装conents
     //
     foreach ($file_metas as $meta) {
         $file_path = $meta['file_path'];
         $meta_value = unserialize($meta['meta_value']);
         $this->master = $meta_value['master'];
         $index = strlen("/{$user_id}");
         $path = substr_replace($file_path, "", 0, $index);
         $attr = array('file_path' => '/' . $this->master . $path);
         if (!$include_deleted) {
             $attr['is_deleted'] = 0;
         }
         $file = UserFile::model()->findByAttributes($attr);
         if (!$file || $file['file_type'] == 0) {
             continue;
         }
         $content = array();
         $content["size"] = '0 bytes';
         $content["bytes"] = 0;
         $content["path"] = $path;
         $content["modified"] = CUtils::formatIntTime($file["file_update_time"]);
         $content["revision"] = intval($file["version_id"]);
         $content["rev"] = strval($file["version_id"]);
         $content["root"] = $root;
         $content["hash"] = "";
         $content["event"] = $file["event_uuid"];
         $content["is_deleted"] = $file['is_deleted'];
         $content["is_dir"] = true;
         array_push($contents, $content);
     }
     return $contents;
 }