|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is ModuleUsersUI, a MikoPBX module that provides user rights management and access control functionality. It allows multi-user access to MikoPBX with role-based permissions and includes LDAP/AD authentication support. |
| 8 | + |
| 9 | +## Development Commands |
| 10 | + |
| 11 | +### Code Quality |
| 12 | +- Use `phpstan` to check code quality after creating or modifying PHP files |
| 13 | +- PHP version requirement: ^7.4 (platform version: 7.4.0) |
| 14 | + |
| 15 | +### JavaScript Build Process |
| 16 | +- Source JS files are in `public/assets/js/src/` |
| 17 | +- Compiled JS files are in `public/assets/js/` |
| 18 | +- Use Babel for JS compilation: `/Users/nb/PhpstormProjects/mikopbx/MikoPBXUtils/node_modules/.bin/babel "$INPUT_FILE" --out-dir "$OUTPUT_DIR" --source-maps inline --presets airbnb` |
| 19 | + |
| 20 | +### Dependencies |
| 21 | +- Run `composer install` to install PHP dependencies |
| 22 | +- Main dependency: `directorytree/ldaprecord` for LDAP functionality |
| 23 | + |
| 24 | +## Architecture Overview |
| 25 | + |
| 26 | +### Core Components |
| 27 | +1. **Module Structure** - Standard MikoPBX module following Phalcon framework patterns |
| 28 | +2. **Access Control System** - Multi-layered ACL implementation with role-based permissions |
| 29 | +3. **Authentication** - Dual authentication: local credentials and LDAP/AD integration |
| 30 | +4. **User Interface** - Tabbed interface using Semantic UI with Volt templating |
| 31 | + |
| 32 | +### Key Directories |
| 33 | +- `App/` - Main application logic (Controllers, Forms, Views, Providers) |
| 34 | +- `Lib/` - Core libraries and ACL system |
| 35 | +- `Models/` - Phalcon ORM models for database entities |
| 36 | +- `Setup/` - Module installation and configuration |
| 37 | +- `Messages/` - Internationalization files |
| 38 | +- `public/assets/` - Frontend assets (CSS, JS, images) |
| 39 | + |
| 40 | +### Database Models |
| 41 | +- `AccessGroups` - User access groups with permissions |
| 42 | +- `AccessGroupsRights` - Granular rights assignment to groups |
| 43 | +- `AccessGroupCDRFilter` - CDR filtering rules per group |
| 44 | +- `UsersCredentials` - User authentication credentials |
| 45 | +- `LdapConfig` - LDAP/AD server configuration |
| 46 | + |
| 47 | +### Controllers Architecture |
| 48 | +- `ModuleUsersUIBaseController` - Base controller with common functionality |
| 49 | +- `ModuleUsersUIController` - Main module interface (groups, users, LDAP tabs) |
| 50 | +- `AccessGroupsController` - Access group management |
| 51 | +- `AccessGroupsRightsController` - Rights assignment |
| 52 | +- `AccessGroupCDRFilterController` - CDR filtering configuration |
| 53 | +- `UsersCredentialsController` - User credential management |
| 54 | +- `LdapConfigController` - LDAP configuration |
| 55 | + |
| 56 | +### ACL System |
| 57 | +The module implements a sophisticated ACL system: |
| 58 | +- `UsersUIACL` - Main ACL modifier that integrates with MikoPBX core ACL |
| 59 | +- `CoreACL` and various `Module*ACL` classes - Define permissions for different MikoPBX modules |
| 60 | +- Role-based access with prefix: `Constants::MODULE_ROLE_PREFIX` |
| 61 | +- Dynamic permission assignment based on access group configuration |
| 62 | + |
| 63 | +### Authentication Flow |
| 64 | +1. `UsersUIAuthenticator` - Handles login authentication |
| 65 | +2. Supports both local password and LDAP authentication |
| 66 | +3. `UsersUILdapAuth` - LDAP authentication implementation |
| 67 | +4. Session management integrated with MikoPBX core |
| 68 | + |
| 69 | +### Frontend Architecture |
| 70 | +- Uses Semantic UI framework for styling |
| 71 | +- JavaScript modules for each tab functionality: |
| 72 | + - `module-users-ui-index.js` - Main module initialization |
| 73 | + - `module-users-ui-index-users.js` - Users tab functionality |
| 74 | + - `module-users-ui-index-ldap.js` - LDAP configuration tab |
| 75 | + - `module-users-ui-modify-ag.js` - Access group modification |
| 76 | + - `module-users-ui-extensions-modify.js` - Extension modifications |
| 77 | +- Volt templating engine for server-side rendering |
| 78 | + |
| 79 | +### Configuration |
| 80 | +- `module.json` - Module metadata and release settings |
| 81 | +- `composer.json` - PHP dependencies and autoloading (PSR-4) |
| 82 | +- License: GPL-3.0-or-later |
| 83 | + |
| 84 | +## Development Patterns |
| 85 | +- Follow MikoPBX module development standards |
| 86 | +- Use Phalcon ORM for database operations |
| 87 | +- Implement proper ACL checks in all controllers |
| 88 | +- Maintain separation between frontend source and compiled assets |
| 89 | +- Use dependency injection container for service registration |
| 90 | +- Follow PSR-4 autoloading standards with namespace `Modules\ModuleUsersUI\` |
| 91 | + |
| 92 | +## Key Files to Understand |
| 93 | +- `App/Module.php` - Main module definition and service registration |
| 94 | +- `Setup/PbxExtensionSetup.php` - Module installation and sidebar integration |
| 95 | +- `Lib/UsersUIACL.php` - Core ACL modification logic |
| 96 | +- `Lib/UsersUIAuthenticator.php` - Authentication handler |
| 97 | +- `App/Controllers/ModuleUsersUIController.php` - Main controller |
0 commit comments