1 /** 2 * Copyright © DiamondMVC 2019 3 * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE) 4 * Author: Jacob Jensen (bausshf) 5 */ 6 module diamond.http.privacy; 7 8 /// Wrapper around a privacy collection. 9 final class PrivacyCollection 10 { 11 private: 12 /// Collection of privacy configurations. 13 PrivacyConfiguration[string] _configurations; 14 15 final: 16 /// Creates a new privacy collection. 17 package(diamond) this() { } 18 19 public: 20 /** 21 * Operator overload for accessing privacy configurations. 22 * Params: 23 * key = The key of the privacy configuration. 24 * Returns: 25 * The privacy configurations tied to the key. 26 */ 27 PrivacyConfiguration opIndex(string key) 28 { 29 auto config = _configurations.get(key, null); 30 31 if (!config) 32 { 33 config = new PrivacyConfiguration; 34 35 _configurations[key] = config; 36 } 37 38 return config; 39 } 40 } 41 42 /// Wrapper around privacy configurations. 43 public final class PrivacyConfiguration 44 { 45 private: 46 /// Creates a new privacy configuration. 47 this() { } 48 49 public: 50 /// Boolean determining whether the data is visible to the public. 51 bool publicVisible; 52 /// Boolean determining whether the data is visible to associates. 53 bool associateVisible; 54 /// Boolean determining whether the data is visible to contacts. 55 bool contactVisible; 56 /// Boolean determining whether the data is visible to staff. 57 bool staffVisible; 58 /// Boolean determining whehter the data is visible to admins. 59 bool adminVisible; 60 }