PluginProbe
VikBooking Hotel Booking Engine & PMS / trunk
VikBooking Hotel Booking Engine & PMS vtrunk
1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.7.3 All 36 releases
vikbooking / admin / helpers / src / chat / context.php

context.php in VikBooking Hotel Booking Engine & PMS trunk, at admin/helpers/src/chat/context.php

111 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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