_server/annotationfiles.php
/**
 * @param $hypervideoID
 * @param $annotationfileID
 * @return mixed
 *
Returning Code:
0		=	Success. File has been written
1		=	failed. Not logged in. Or User not active
3		=	failed. Could not find the annotations folder
4		=	failed. Annotationfile is Main-file and cant be deleted.
5		=	failed. Annotation with id=$annotationfileID has not been found.
7		=	Permission denied. Permission denied. You are not the annotations owner and no administrator!
 */
@param $hypervideoID
@param $annotationfileID
@return mixed

Returning Code:
0               =       Success. File has been written
1               =       failed. Not logged in. Or User not active
3               =       failed. Could not find the annotations folder
4               =       failed. Annotationfile is Main-file and cant be deleted.
5               =       failed. Annotation with id=$annotationfileID has not been found.
7               =       Permission denied. Permission denied. You are not the annotations owner and no administrator!
@param $hypervideoID @param $annotationfileID @return mixed Returning Code : 0 = Success . File has been written 1 = failed . Not logged in . Or User not active 3 = failed . Could not find the annotations folder 4 = failed . Annotationfile is Main - file and cant be deleted . 5 = failed . Annotation with id = $annotationfileID has not been found . 7 = Permission denied . Permission denied . You are not the annotations owner and no administrator!
function annotationfileDelete($hypervideoID,$annotationfileID) {
	global $conf;
	$login = userCheckLogin();
	if ($login["code"] != 1) {
		$return["status"] = "fail";
		$return["code"] = 1;
		$return["string"] = $login["string"];
		return $return;
	} else {
		$file = new sharedFile($conf["dir"]["data"]."/users.json");
		$json = $file->read();
		$file->close();
		$u = json_decode($json,true);
		$_SESSION["ohv"]["user"] = array_replace_recursive($_SESSION["ohv"]["user"], $u["user"][$_SESSION["ohv"]["user"]["id"]]);
	}
    $annotationfileID = $_SESSION["ohv"]["user"];
	if (!is_dir($conf["dir"]["data"]."/hypervideos/".$hypervideoID."/annotations")) {
		$return["status"] = "fail";
		$return["code"] = 3;
		$return["string"] = "Could not find the annotations folder";
		return $return;
	}
	$file = new sharedFile($conf["dir"]["data"]."/hypervideos/".$hypervideoID."/annotations/_index.json");
	$hvannotationsIndexJson = $file->read();
	$hvannotationsIndex = json_decode($hvannotationsIndexJson,true);
	if ($hvannotationsIndex["mainAnnotation"] == $annotationfileID) {
		$return["status"] = "fail";
		$return["code"] = 4;
		$return["string"] = "Annotationfile is Main-file and cant be deleted.";
		$file->close();
		return $return;
	}
	if ((!is_array($hvannotationsIndex["annotationfiles"][$annotationfileID])) || (!file_exists($conf["dir"]["data"]."/hypervideos/".$hypervideoID."/annotations/".$annotationfileID.".json"))) {
		$return["status"] = "fail";
		$return["code"] = 5;
		$return["string"] = "Annotation with id=".$annotationfileID." has not been found.";
		$file->close();
		return $return;
	}
	$currAnnotation = $hvannotationsIndex["annotationfiles"][$annotationfileID];
	unlink($conf["dir"]["data"]."/hypervideos/".$hypervideoID."/annotations/".$annotationfileID.".json");
	unset($hvannotationsIndex["annotationfiles"][$annotationfileID]);
	$file->writeClose(json_encode($hvannotationsIndex, $conf["settings"]["json_flags"]));
	$return["status"] = "success";
	$return["code"] = 0;
	$return["string"] = "Annotations deleted.";
	return $return;
}
function annotationfileDelete ( $ hypervideoID , $ annotationfileID ) { global $ conf ; $ login = userCheckLogin ( ) ; if ( $ login [ " code " ] != 1 ) { $ return [ " status " ] = " fail " ; $ return [ " code " ] = 1 ; $ return [ " string " ] = $ login [ " string " ] ; return $ return ; } else { $ file = new sharedFile ( $ conf [ " dir " ] [ " data " ] . " /users.json " ) ; $ json = $ file -> read ( ) ; $ file -> close ( ) ; $ u = json_decode ( $ json , true ) ; $ _SESSION [ " ohv " ] [ " user " ] = array_replace_recursive ( $ _SESSION [ " ohv " ] [ " user " ] , $ u [ " user " ] [ $ _SESSION [ " ohv " ] [ " user " ] [ " id " ] ] ) ; } $ annotationfileID = $ _SESSION [ " ohv " ] [ " user " ] ; if ( ! is_dir ( $ conf [ " dir " ] [ " data " ] . " /hypervideos/ " . $ hypervideoID . " /annotations " ) ) { $ return [ " status " ] = " fail " ; $ return [ " code " ] = 3 ; $ return [ " string " ] = " Could not find the annotations folder " ; return $ return ; } $ file = new sharedFile ( $ conf [ " dir " ] [ " data " ] . " /hypervideos/ " . $ hypervideoID . " /annotations/_index.json " ) ; $ hvannotationsIndexJson = $ file -> read ( ) ; $ hvannotationsIndex = json_decode ( $ hvannotationsIndexJson , true ) ; if ( $ hvannotationsIndex [ " mainAnnotation " ] == $ annotationfileID ) { $ return [ " status " ] = " fail " ; $ return [ " code " ] = 4 ; $ return [ " string " ] = " Annotationfile is Main-file and cant be deleted. " ; $ file -> close ( ) ; return $ return ; } if ( ( ! is_array ( $ hvannotationsIndex [ " annotationfiles " ] [ $ annotationfileID ] ) ) || ( ! file_exists ( $ conf [ " dir " ] [ " data " ] . " /hypervideos/ " . $ hypervideoID . " /annotations/ " . $ annotationfileID . " .json " ) ) ) { $ return [ " status " ] = " fail " ; $ return [ " code " ] = 5 ; $ return [ " string " ] = " Annotation with id= " . $ annotationfileID . "  has not been found. " ; $ file -> close ( ) ; return $ return ; } $ currAnnotation = $ hvannotationsIndex [ " annotationfiles " ] [ $ annotationfileID ] ; unlink ( $ conf [ " dir " ] [ " data " ] . " /hypervideos/ " . $ hypervideoID . " /annotations/ " . $ annotationfileID . " .json " ) ; unset ( $ hvannotationsIndex [ " annotationfiles " ] [ $ annotationfileID ] ) ; $ file -> writeClose ( json_encode ( $ hvannotationsIndex , $ conf [ " settings " ] [ " json_flags " ] ) ) ; $ return [ " status " ] = " success " ; $ return [ " code " ] = 0 ; $ return [ " string " ] = " Annotations deleted. " ; return $ return ; }
@param $hypervideoID
 @param $annotationfileID
 @return mixed
@param $hypervideoID @param $annotationfileID @return mixed
// if (($_SESSION["ohv"]["user"]["id"] != $currAnnotation["ownerId"]) && ($_SESSION["ohv"]["user"]["role"] != "admin")) { // 	$return["status"] = "fail"; // 	$return["code"] = 6; // 	$return["string"] = "Permission denied. You are not the annotations owner and no administrator!"; // 	$file->close(); // 	return $return; // }