예제 #1
0
 public static function lockFile($params)
 {
     $result['status'] = 'KO';
     $result['error'] = -1;
     $username = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser()->getName();
     $IpServer = $_SERVER['SERVER_ADDR'];
     $timeLimit = TIME_LIMIT_BLOCK;
     $dt_now = new DateTime('NOW');
     $resourceUrl = self::getResourceUrl();
     if (isset($params['id']) && isset($params['cloud'])) {
         $id = $params['id'];
         $cloud = $params['cloud'];
         if (isset($_SESSION['access_token_' . $cloud . '_v2'])) {
             $token = $_SESSION['access_token_' . $cloud . '_v2'];
             $apiManager = new ApiManager();
             $result = $apiManager->unLockedFile($cloud, $token, $id, $username, $IpServer, $timeLimit, $dt_now, $resourceUrl);
             if (isset($params['block']) && $result['status'] == 'OK') {
                 $result = $apiManager->lockFile($cloud, $token, $id, $username, $IpServer, $timeLimit, bin2hex($dt_now->format("Y-m-d H:i:s")), $resourceUrl);
             }
         }
     }
     return $result;
 }