예제 #1
0
 /**
  * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  */
 public static function filetype($path)
 {
     return \OC\Files\Filesystem::filetype($path);
 }
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  * @SSOCORS
  */
 public function unshare($id, $type)
 {
     $shareWith = null;
     $path = \OC\Files\Filesystem::getPath($id);
     $response = array('id' => $id);
     if ($path === null) {
         if ($type == 'file') {
             $error_msg = self::msg_idNotExist;
         } else {
             $replacement = '${1}folder${3}';
             $error_msg = preg_replace($this->fileTypePattern, $replacement, self::msg_idNotExist);
         }
         return new DataResponse(array('data' => $response, 'status' => 'error', 'message' => $error_msg));
     }
     if (\OC\Files\Filesystem::filetype($path) !== $type) {
         $replacement = '${1}\'' . $type . '\'${3}' . 'id: ' . $id;
         $error_msg = preg_replace($this->errorTypePattern, $replacement, self::msg_errorType);
         return new DataResponse(array('data' => $response, 'status' => 'error', 'message' => $error_msg));
     }
     if ($type == 'dir') {
         $type = 'folder';
     }
     $unshare = \OCP\Share::unshare((string) $type, (string) $id, (int) $this->shareType, $shareWith);
     if ($unshare) {
         return new DataResponse(array('data' => $response, 'status' => 'success'));
     } else {
         $replacement = '${1}folder${3}';
         $error_msg = preg_replace($this->fileTypePattern, $replacement, self::msg_noRequireUnshareBeforeShare);
         return new DataResponse(array('data' => $response, 'status' => 'error', 'message' => $error_msg));
     }
 }