+ public function setPerms($perms)
+ {
+ $this->perms = $perms;
+ $this->perm_flags = null;
+ }
+
+ /** Retrieve the 'general' read visibility.
+ * This is the maximum level of fields that may be viewed by the current user on other profiles.
+ *
+ * Rules are:
+ * - Everyone can view 'public'
+ * - directory_ax gives access to 'AX' level
+ * - directory_private gives access to 'private' level
+ * - admin gives access to 'hidden' level
+ */
+ public function readVisibility()
+ {
+ $level = Visibility::VIEW_NONE;
+ if ($this->is_admin) {
+ $level = Visibility::VIEW_ADMIN;
+ } elseif ($this->checkPerms('directory_private')) {
+ $level = Visibility::VIEW_PRIVATE;
+ } elseif ($this->checkPerms('directory_ax')) {
+ $level = Visibility::VIEW_AX;
+ } else {
+ $level = Visibility::VIEW_PUBLIC;
+ }
+ return Visibility::get($level);
+ }
+
+ /** Retrieve the 'general' edit visibility.
+ * This is the maximum level of fields that may be edited by the current user on other profiles.
+ *
+ * Rules are:
+ * - Only admins can edit the 'hidden' fields
+ * - If someone has 'directory_edit' (which is actually directory_ax_edit): AX level
+ * - Otherwise, nothing.
+ */
+ public function editVisibility()
+ {
+ $level = Visibility::VIEW_NONE;
+ if ($this->is_admin) {
+ $level = Visibility::VIEW_ADMIN;
+ } elseif ($this->checkPerms('directory_edit')) {
+ $level = Visibility::VIEW_AX;
+ }
+ return Visibility::get($level);
+ }
+