Пример #1
0
 /**
  * 获取当前文件版本列表
  * @param $path
  * @return mixed
  */
 public function getList($path)
 {
     $item = explode("/", $path);
     $permissionArr = UserPermissionBiz::getInstance()->getPermission($path, $this->user['id']);
     if ($item[1] !== $this->user['id'] && count($permissionArr) == 0) {
         throw new MFilesException(Yii::t('api', MConst::PARAMS_ERROR), MConst::HTTP_CODE_400);
     }
     $file = MiniFile::getInstance()->getByPath($path);
     $version_id = $file['version_id'];
     $fileMeta = MiniFileMeta::getInstance()->getFileMeta($path, "version");
     $fileVersion = MiniVersion::getInstance()->getVersion($version_id);
     $currentSignature = $fileVersion['file_signature'];
     $historyArr = array_reverse(unserialize($fileMeta['meta_value']));
     // 去掉delete事件版本
     $histories = array();
     foreach ($historyArr as $item) {
         $history = array();
         if ($item['type'] == CConst::DELETE) {
             continue;
         }
         $history['type'] = $item['type'];
         $history['file_size'] = $item['file_size'];
         $history['user_nick'] = $item['user_nick'];
         $history['device_name'] = $item['device_name'];
         $history['datetime'] = MiniUtil::formatTime(strtotime($item['datetime']));
         $fileVersion = MiniVersion::getInstance()->getVersion($item['version_id']);
         $history['signature'] = $fileVersion['file_signature'];
         array_push($histories, $history);
     }
     $data['histories'] = $histories;
     $data['current_signature'] = $currentSignature;
     return $data;
 }
Пример #2
0
 /**
  *   获取events数据
  */
 public function getList($path, $time, $deviceUuid, $pageSize, $currentPage)
 {
     $user = $this->user;
     $userId = $user['id'];
     $time = $this->getTime($time);
     if ($path != "") {
         $path = MiniUtil::joinPath($path);
     }
     $total = MiniEvent::getInstance()->getTotal($path, $time, $userId, $deviceUuid);
     $totalPage = ceil($total / $pageSize);
     $events = MiniEvent::getInstance()->getByCondition($path, $userId, $time, $deviceUuid, $pageSize, ($currentPage - 1) * $pageSize);
     $itemList = array();
     $data = array();
     foreach ($events as $event) {
         $item = array();
         $device = MiniUserDevice::getInstance()->getUserDevice($event['user_device_id']);
         $item['create_user_id'] = $device['user_id'];
         $item['file_path'] = MiniUtil::getRelativePath($event['file_path']);
         $item['action'] = $event['action'];
         $item['user_name'] = $user['user_name'];
         $item['user_device_type'] = $device['user_device_type'];
         if ($device['user_id'] == $userId) {
             $item['user_self'] = true;
         } else {
             $item['user_self'] = false;
             $user = MiniUser::getInstance()->getById($device['user_id']);
             $userMetas = MiniUserMeta::getInstance()->getUserMetas($device['user_id']);
             if (isset($userMetas['nick'])) {
                 $item['user_name'] = $userMetas['nick'];
             } else {
                 $item['user_name'] = $user['user_name'];
             }
         }
         $item['created_at'] = MiniUtil::formatTime(strtotime($event['created_at']));
         $item['user_device_name'] = $device['user_device_name'];
         $item['context'] = MiniUtil::getRelativePath($event['context']);
         $item['device_uuid'] = $device['user_device_uuid'];
         if ($event['action'] == 2) {
             //判断是否是重命名还是创建
             $fromParent = CUtils::pathinfo_utf($event['file_path']);
             $toParent = CUtils::pathinfo_utf($event['context']);
             if ($fromParent['dirname'] == $toParent['dirname']) {
                 $item['action'] = MConst::RENAME;
             }
         }
         $itemList[] = $item;
     }
     $data['events'] = $itemList;
     $data['totalPage'] = $totalPage;
     return $data;
 }
Пример #3
0
 /**
  * 登陆信息
  *
  */
 public function getLogs($currentPage, $pageSize)
 {
     $data = array();
     $logs = array();
     $item = array();
     $userId = $this->user['user_id'];
     $list = MiniLog::getInstance()->getByType($userId, ProfileBiz::TYPE, $pageSize, ($currentPage - 1) * $pageSize);
     $count = MiniLog::getInstance()->getCountByType($userId, ProfileBiz::TYPE);
     foreach ($list as $log) {
         $context = unserialize($log['context']);
         $item['action'] = $context['action'];
         $device = MiniUserDevice::getInstance()->getById($context['device_id']);
         $item['device_name'] = $device['user_device_name'];
         $item['device_type'] = $context['device_type'];
         $item['created_at'] = MiniUtil::formatTime(strtotime($log['created_at']));
         $item['message'] = $log['message'];
         $logs[] = $item;
     }
     $data['logs'] = $logs;
     $data['logCount'] = ceil($count / $pageSize);
     return $data;
 }