1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
<?php
namespace MatthiasWeb\RealMediaLibrary\attachment;
use MatthiasWeb\RealMediaLibrary\general;
use MatthiasWeb\RealMediaLibrary\folder;
use MatthiasWeb\RealMediaLibrary\base;
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
class Permissions extends base\Base {
private static $me = null;
public static function insert($errors, $id, $folder) {
if (is_rml_folder($folder) && $folder->isRestrictFor("ins")) {
$errors[] = __("You are not allowed to insert files here.", RML_TD);
return $errors;
}
$otherFolder = wp_attachment_folder($id);
if ($otherFolder !== "") {
$otherFolder = wp_rml_get_by_id($otherFolder, null, true);
if (is_rml_folder($otherFolder) && $otherFolder->isRestrictFor("mov")) {
$errors[] = __("You are not allowed to move the file.", RML_TD);
}
}
return $errors;
}
public static function create($errors, $name, $parent, $type) {
$folder = wp_rml_get_by_id($parent, null, true);
if (is_rml_folder($folder) && $folder->isRestrictFor("cre")) {
$errors[] = __("You are not allowed to create a subfolder here.", RML_TD);
}
return $errors;
}
public static function deleteFolder($errors, $id, $folder) {
if (is_rml_folder($folder) && $folder->isRestrictFor("del")) {
$errors[] = __("You are not allowed to delete this folder.", RML_TD);
}
return $errors;
}
public static function setName($errors, $name, $folder) {
if (is_rml_folder($folder) && $folder->isRestrictFor("ren")) {
$errors[] = __("You are not allowed to rename this folder.", RML_TD);
}
return $errors;
}
public static function getInstance() {
if (self::$me == null) {
self::$me = new Permissions();
}
return self::$me;
}
}
?>