|
1 | | ---- |
2 | | -title: Access Control & Contexts |
3 | | -sidebar_label: Access Control |
4 | | -sidebar_position: 6 |
5 | | ---- |
6 | | - |
7 | | -# Multi-Context System Documentation |
8 | | - |
9 | | -The **Multi-Context System** allows a single ABCD OPAC installation to serve multiple libraries, institutions, or database collections independently. By using a simple URL parameter (`?ctx=...`), the system switches the physical directory where it looks for databases (`bases`), effectively creating separate environments. |
10 | | - |
11 | | -### 1\. How it Works |
12 | | - |
13 | | -Instead of having a hardcoded path to the databases (e.g., `/var/www/bases/`), the system uses a **Mapping Logic**: |
14 | | - |
15 | | -1. **The User Request:** The user accesses a URL like `http://myserver/opac/?ctx=law`. |
16 | | -2. **The Lookup:** The system checks the `config_opac.php` file for a "map" that links the alias `law` to a specific physical folder on the server (e.g., `C:/abcd/bases-law/`). |
17 | | -3. **The Switch:** If the context is valid, the system sets the internal `$db_path` variable to that specific folder. All subsequent operations (searching, displaying records, loading configuration files) will happen inside that folder. |
18 | | -4. **Session Persistence:** The system remembers the current context in the user's session. This ensures that if the user clicks a link that accidentally omits the `?ctx=` parameter, they remain in the correct library. |
19 | | - |
20 | | -### 2\. How to Enable It |
21 | | - |
22 | | -To enable this feature, you must edit the `config_opac.php` file located in the `opac/` directory (or the central configuration directory, depending on your setup). |
23 | | - |
24 | | -**Step 1: Activate the Feature** |
25 | | -Locate the `$opac_multi_context` variable and set it to `true`. |
26 | | - |
27 | | -```php |
28 | | -$opac_multi_context = true; |
29 | | -``` |
30 | | - |
31 | | -**Step 2: Configure Strict Mode (Optional but Recommended)** |
32 | | -Strict mode prevents users from accessing the OPAC without specifying a context (which would otherwise load the default/root databases). |
33 | | - |
34 | | -```php |
35 | | -$opac_strict_mode = true; // Blocks access if ?ctx= is missing |
36 | | -``` |
37 | | - |
38 | | -**Step 3: Define the Context Map** |
39 | | -This is the most important step. You define an array where the **key** is the URL alias and the **value** is the full physical path to the `bases` folder for that client. |
40 | | - |
41 | | -```php |
42 | | -$opac_context_map = array( |
43 | | - // 'URL_ALIAS' => 'PHYSICAL_PATH_ON_SERVER' |
44 | | - 'demo' => 'C:/xampp/htdocs/ABCD2/www/bases-examples_Windows/', |
45 | | - 'medicine' => 'C:/xampp/htdocs/ABCD2/www/bases-medicina/', |
46 | | - 'law_library' => '/var/www/abcd/bases-law/', |
47 | | -); |
48 | | -``` |
49 | | - |
50 | | ------ |
51 | | - |
52 | | -# ⚙️ Important Points of `config_opac.php` |
53 | | - |
54 | | -The `config_opac.php` file is the brain of the OPAC. It is structured into logical blocks to separate user configuration from system logic. |
55 | | - |
56 | | -### Block 1: Initialization |
57 | | - |
58 | | -This section handles PHP settings and loads the core ABCD configurations. |
59 | | - |
60 | | - * **Session Start:** It ensures a PHP session is active to store the user's current context and language. |
61 | | - * **Central Config:** It includes `central/config.php` to get system-wide defaults. |
62 | | - |
63 | | -### Block 2: User Configuration (Edit Here) |
64 | | - |
65 | | -This is where administrators make changes. |
66 | | - |
67 | | - * **Multi-Context Switches:** As explained above (`$opac_multi_context`, `$opac_strict_mode`). |
68 | | - * **Context Map:** The list of available libraries (`$opac_context_map`). |
69 | | - |
70 | | -### Block 3: Context Resolution Logic |
71 | | - |
72 | | -This section contains the logic that determines which database path (`$db_path`) to use. **You generally do not need to edit this.** |
73 | | - |
74 | | - * **URL Detection:** Checks if `$_REQUEST['ctx']` exists and matches an entry in the map. |
75 | | - * **Session Fallback:** If the URL has no context, it checks `$_SESSION` to see if the user was already browsing a specific library. |
76 | | - * **Security Check:** If `Strict Mode` is on and no context is found, it kills the process with an "Access Denied" message (unless running in the Administrative module). |
77 | | - * **Sanitization:** Ensures paths end with a correct directory separator (`/`). |
78 | | - |
79 | | -### Block 4: Mode Logic (Integrated vs. Single Base) |
80 | | - |
81 | | -Controls the search behavior: |
82 | | - |
83 | | - * **Integrated Mode:** Searches across all databases defined in `bases.dat`. Active by default on the home page. |
84 | | - * **Single Base Mode:** If the URL contains `&base=marc`, this logic automatically disables Integrated Mode so the search is restricted to that specific database. |
85 | | - |
86 | | -### Block 5: Language Detection |
87 | | - |
88 | | -A robust logic to determine the interface language, prioritized as follows: |
89 | | - |
90 | | -1. **Session (Admin):** If an administrator is logged in, their language preference wins. |
91 | | -2. **URL Request:** If the user clicks a flag (`?lang=pt`), that choice takes precedence and is saved. |
92 | | -3. **Session (Visitor):** Remembers the visitor's choice during navigation. |
93 | | -4. **Browser:** Tries to detect the browser's default language. |
94 | | -5. **Default:** Falls back to the system default. |
95 | | - |
96 | | -### Block 6: Visual and Functional Settings |
97 | | - |
98 | | -Loads specific visual settings for the active base. |
99 | | - |
100 | | - * **`opac.def`:** Reads the specific configuration file for the current language/base (colors, texts). |
101 | | - * **`$restricted_opac`:** Defines if the OPAC requires login (`Y` or `N`). |
| 1 | +--- |
| 2 | +title: Access Control & Contexts |
| 3 | +sidebar_label: Access Control |
| 4 | +sidebar_position: 6 |
| 5 | +--- |
| 6 | + |
| 7 | +# Multi-Context System Documentation |
| 8 | + |
| 9 | +The **Multi-Context System** allows a single ABCD OPAC installation to serve multiple libraries, institutions, or database collections independently. By using a simple URL parameter (`?ctx=...`), the system switches the physical directory where it looks for databases (`bases`), effectively creating separate environments. |
| 10 | + |
| 11 | +### 1\. How it Works |
| 12 | + |
| 13 | +Instead of having a hardcoded path to the databases (e.g., `/var/www/bases/`), the system uses a **Mapping Logic**: |
| 14 | + |
| 15 | +1. **The User Request:** The user accesses a URL like `http://myserver/opac/?ctx=law`. |
| 16 | +2. **The Lookup:** The system checks the `config_opac.php` file for a "map" that links the alias `law` to a specific physical folder on the server (e.g., `C:/abcd/bases-law/`). |
| 17 | +3. **The Switch:** If the context is valid, the system sets the internal `$db_path` variable to that specific folder. All subsequent operations (searching, displaying records, loading configuration files) will happen inside that folder. |
| 18 | +4. **Session Persistence:** The system remembers the current context in the user's session. This ensures that if the user clicks a link that accidentally omits the `?ctx=` parameter, they remain in the correct library. |
| 19 | + |
| 20 | +### 2\. How to Enable It |
| 21 | + |
| 22 | +To enable this feature, you must edit the `config_opac.php` file located in the `opac/` directory (or the central configuration directory, depending on your setup). |
| 23 | + |
| 24 | +**Step 1: Activate the Feature** |
| 25 | +Locate the `$opac_multi_context` variable and set it to `true`. |
| 26 | + |
| 27 | +```php |
| 28 | +$opac_multi_context = true; |
| 29 | +``` |
| 30 | + |
| 31 | +**Step 2: Configure Strict Mode (Optional but Recommended)** |
| 32 | +Strict mode prevents users from accessing the OPAC without specifying a context (which would otherwise load the default/root databases). |
| 33 | + |
| 34 | +```php |
| 35 | +$opac_strict_mode = true; // Blocks access if ?ctx= is missing |
| 36 | +``` |
| 37 | + |
| 38 | +**Step 3: Define the Context Map** |
| 39 | +This is the most important step. You define an array where the **key** is the URL alias and the **value** is the full physical path to the `bases` folder for that client. |
| 40 | + |
| 41 | +```php |
| 42 | +$opac_context_map = array( |
| 43 | + // 'URL_ALIAS' => 'PHYSICAL_PATH_ON_SERVER' |
| 44 | + 'demo' => 'C:/xampp/htdocs/ABCD2/www/bases-examples_Windows/', |
| 45 | + 'medicine' => 'C:/xampp/htdocs/ABCD2/www/bases-medicina/', |
| 46 | + 'law_library' => '/var/www/abcd/bases-law/', |
| 47 | +); |
| 48 | +``` |
| 49 | + |
| 50 | +----- |
| 51 | + |
| 52 | +# ⚙️ Important Points of `config_opac.php` |
| 53 | + |
| 54 | +The `config_opac.php` file is the brain of the OPAC. It is structured into logical blocks to separate user configuration from system logic. |
| 55 | + |
| 56 | +### Block 1: Initialization |
| 57 | + |
| 58 | +This section handles PHP settings and loads the core ABCD configurations. |
| 59 | + |
| 60 | + * **Session Start:** It ensures a PHP session is active to store the user's current context and language. |
| 61 | + * **Central Config:** It includes `central/config.php` to get system-wide defaults. |
| 62 | + |
| 63 | +### Block 2: User Configuration (Edit Here) |
| 64 | + |
| 65 | +This is where administrators make changes. |
| 66 | + |
| 67 | + * **Multi-Context Switches:** As explained above (`$opac_multi_context`, `$opac_strict_mode`). |
| 68 | + * **Context Map:** The list of available libraries (`$opac_context_map`). |
| 69 | + |
| 70 | +### Block 3: Context Resolution Logic |
| 71 | + |
| 72 | +This section contains the logic that determines which database path (`$db_path`) to use. **You generally do not need to edit this.** |
| 73 | + |
| 74 | + * **URL Detection:** Checks if `$_REQUEST['ctx']` exists and matches an entry in the map. |
| 75 | + * **Session Fallback:** If the URL has no context, it checks `$_SESSION` to see if the user was already browsing a specific library. |
| 76 | + * **Security Check:** If `Strict Mode` is on and no context is found, it kills the process with an "Access Denied" message (unless running in the Administrative module). |
| 77 | + * **Sanitization:** Ensures paths end with a correct directory separator (`/`). |
| 78 | + |
| 79 | +### Block 4: Mode Logic (Integrated vs. Single Base) |
| 80 | + |
| 81 | +Controls the search behavior: |
| 82 | + |
| 83 | + * **Integrated Mode:** Searches across all databases defined in `bases.dat`. Active by default on the home page. |
| 84 | + * **Single Base Mode:** If the URL contains `&base=marc`, this logic automatically disables Integrated Mode so the search is restricted to that specific database. |
| 85 | + |
| 86 | +### Block 5: Language Detection |
| 87 | + |
| 88 | +A robust logic to determine the interface language, prioritized as follows: |
| 89 | + |
| 90 | +1. **Session (Admin):** If an administrator is logged in, their language preference wins. |
| 91 | +2. **URL Request:** If the user clicks a flag (`?lang=pt`), that choice takes precedence and is saved. |
| 92 | +3. **Session (Visitor):** Remembers the visitor's choice during navigation. |
| 93 | +4. **Browser:** Tries to detect the browser's default language. |
| 94 | +5. **Default:** Falls back to the system default. |
| 95 | + |
| 96 | +### Block 6: Visual and Functional Settings |
| 97 | + |
| 98 | +Loads specific visual settings for the active base. |
| 99 | + |
| 100 | + * **`opac.def`:** Reads the specific configuration file for the current language/base (colors, texts). |
| 101 | + * **`$restricted_opac`:** Defines if the OPAC requires login (`Y` or `N`). |
102 | 102 | * **Global Styles:** Checks for `global_style.def` to apply custom CSS overrides per context. |
0 commit comments