| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package VikBooking |
| 4 |
* @subpackage core |
| 5 |
* @author E4J s.r.l. |
| 6 |
* @copyright Copyright (C) 2026 E4J s.r.l. All Rights Reserved. |
| 7 |
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL |
| 8 |
* @link https://vikwp.com |
| 9 |
*/ |
| 10 |
|
| 11 |
// No direct access |
| 12 |
defined('ABSPATH') or die('No script kiddies please!'); |
| 13 |
|
| 14 |
/** |
| 15 |
* This interface can be used to differentiate the behavior depending on |
| 16 |
* the context where a message may be sent. |
| 17 |
* |
| 18 |
* @since 1.8 |
| 19 |
*/ |
| 20 |
interface VBOChatContext |
| 21 |
{ |
| 22 |
/** |
| 23 |
* Returns the foreign key to link a message to an external context. |
| 24 |
* |
| 25 |
* @return int |
| 26 |
*/ |
| 27 |
public function getID(); |
| 28 |
|
| 29 |
/** |
| 30 |
* Returns the alias to identify the context type. |
| 31 |
* |
| 32 |
* @return string |
| 33 |
*/ |
| 34 |
public function getAlias(); |
| 35 |
|
| 36 |
/** |
| 37 |
* Returns a list of recipients that may receive notifications |
| 38 |
* about new messages under this context. |
| 39 |
* |
| 40 |
* @return VBOChatUser[] |
| 41 |
*/ |
| 42 |
public function getRecipients(); |
| 43 |
|
| 44 |
/** |
| 45 |
* Returns a short description to identify the context. |
| 46 |
* |
| 47 |
* @return string |
| 48 |
*/ |
| 49 |
public function getSubject(); |
| 50 |
|
| 51 |
/** |
| 52 |
* Returns the URL that can be used to access the chat interface. |
| 53 |
* |
| 54 |
* @return string |
| 55 |
*/ |
| 56 |
public function getURL(); |
| 57 |
|
| 58 |
/** |
| 59 |
* Returns an associative array of metadata related to this context. |
| 60 |
* |
| 61 |
* @param bool $public When true, skip sensistive metadata. |
| 62 |
* |
| 63 |
* @return array |
| 64 |
*/ |
| 65 |
public function getMetadata(bool $public = false); |
| 66 |
|
| 67 |
/** |
| 68 |
* Sets or updates the specified metadata into the context. |
| 69 |
* |
| 70 |
* @param string $key The metadata key. |
| 71 |
* @param mixed $value The metadata value. |
| 72 |
* |
| 73 |
* @return void |
| 74 |
*/ |
| 75 |
public function setMetadata(string $key, $value); |
| 76 |
|
| 77 |
/** |
| 78 |
* Forces the pre-loading of the resources to make the context scripts work. |
| 79 |
* |
| 80 |
* @param VBOChatUser $user Useful to differentiate the scripts to use |
| 81 |
* depending on the authenticated user. |
| 82 |
* |
| 83 |
* @return void |
| 84 |
*/ |
| 85 |
public function useAssets(VBOChatUser $user); |
| 86 |
|
| 87 |
/** |
| 88 |
* Returns an array of supported actions, which will be added to the |
| 89 |
* contextual menu displayed within the chat interface. |
| 90 |
* |
| 91 |
* @param VBOChatUser $user Useful to differentiate the actions to use |
| 92 |
* depending on the authenticated user. |
| 93 |
* |
| 94 |
* @return array |
| 95 |
*/ |
| 96 |
public function getActions(VBOChatUser $user); |
| 97 |
|
| 98 |
/** |
| 99 |
* Checks whether the provided user is allowed to perform the given action |
| 100 |
* under the current context. |
| 101 |
* |
| 102 |
* NOTE: calling `$user->can()` in this method will result in recursion. |
| 103 |
* |
| 104 |
* @param string $scope The action identifier. |
| 105 |
* @param VBOChatUser $user The involved user. |
| 106 |
* |
| 107 |
* @return bool True if allowed, false otherwise. |
| 108 |
*/ |
| 109 |
public function can(string $scope, VBOChatUser $user); |
| 110 |
} |
| 111 |
|