<?php

class cancelshare_sxExe extends xIExecutor {

	public function main() {
		if(isset($_POST['checkbox']['folder'])) {
			foreach($_POST['checkbox']['folder'] as $folderID) {
				$folder = new xFolder((int)$folderID);
				if($folder->isValid() && $folder->isOwner(xUser::$cur)) {
					xShare::cancel($folder, xUser::$cur, new xUser(0));
				}
			}
		}
		if(isset($_POST['checkbox']['file'])) {
			foreach($_POST['checkbox']['file'] as $fileID) {
				$file = new xFile((int)$fileID);
				if($file->isValid() && $file->isOwner(xUser::$cur)) {
					xShare::cancel($file, xUser::$cur, new xUser(0));
				}
			}
		}
		echo json_encode(array(
			'result' => '1'
		));
	}

	public function onError($result) {

	}
}

