3 namespace Drupal\permissions_by_term;
5 use \Drupal\Core\Form\FormState;
8 * Defines an interface for access storage classes.
10 interface AccessStorageInterface {
13 * Checks if the submitted users are existing.
15 * If an user isn't existing, set an error message.
17 * @param \Drupal\Core\Form\FormState $form_state
19 public function checkIfUsersExists(FormState $form_state);
22 * Gets user term permissions by tid.
27 * Existing term permissions.
29 public function getExistingUserTermPermissionsByTid($term_id);
32 * Gets role term permissions by tid.
37 * Existing role term permissions.
39 public function getExistingRoleTermPermissionsByTid($term_id);
42 * Gets single user id by user name.
44 * @param string $sUsername
50 public function getUserIdByName($sUsername);
53 * Gets multiple user ids by user names.
55 * @param array $aUserNames
56 * An array with user names.
61 public function getUserIdsByNames($aUserNames);
64 * Gets the user names from users.
66 * Users which have granted access for a taxonomy term.
71 * Gets user ids, which are allowed to access.
73 public function getAllowedUserIds($term_id);
76 * Deletes term permissions by user id.
78 * @param array $aUserIdsAccessRemove
79 * An array with user ids, which access will be removed.
81 * The term id to remove.
83 public function deleteTermPermissionsByUserIds($aUserIdsAccessRemove, $term_id);
86 * Deletes term permissions by role ids.
88 * @param array $aRoleIdsAccessRemove
89 * An array with role ids, that will be removed.
93 public function deleteTermPermissionsByRoleIds($aRoleIdsAccessRemove, $term_id);
96 * Adds term permissions by user ids.
98 * @param array $aUserIdsGrantedAccess
99 * The user ids which will get granted access.
100 * @param int $term_id
104 public function addTermPermissionsByUserIds($aUserIdsGrantedAccess, $term_id);
107 * Adds term permissions by role ids.
109 * @param array $aRoleIdsGrantedAccess
110 * The role ids which will gain access.
111 * @param int $term_id
115 public function addTermPermissionsByRoleIds($aRoleIdsGrantedAccess, $term_id);
118 * Gets the term id by term name.
120 * @param string $sTermName
126 public function getTermIdByName($sTermName);
129 * Gets the taxonomy name by id.
131 * @param int $term_id
132 * The taxonomy term id.
135 * Gets a term name by an id.
137 public function getTermNameById($term_id);
140 * Saves term permissions by users.
142 * Opposite to save term permission by roles.
144 * @param \Drupal\Core\Form\FormState $form_state
145 * @param int $term_id
148 * Data for database queries.
150 public function saveTermPermissions(FormState $form_state, $term_id);
153 * Prepares the data which has to be applied to the database.
155 * @param array $aExistingUserPermissions
156 * The permissions for existing user.
157 * @param array $aSubmittedUserIdsGrantedAccess
158 * The user ids which get access.
159 * @param array $aExistingRoleIdsGrantedAccess
160 * The existing role ids.
161 * @param array $aSubmittedRolesGrantedAccess
162 * The user roles which get access.
165 * User ID and role data.
167 public function getPreparedDataForDatabaseQueries($aExistingUserPermissions,
168 $aSubmittedUserIdsGrantedAccess,
169 $aExistingRoleIdsGrantedAccess,
170 $aSubmittedRolesGrantedAccess);
173 * The form value for allowed users as string to be shown to the user.
175 * @param \Drupal\user\Entity\User[] $aAllowedUsers
176 * An array with the allowed users.
178 * @return null|string
179 * Either null or the user name.
181 public function getUserFormValue($aAllowedUsers);