3 * Dependency injection configuration
7 * Copyright © 2003-2018 The Galette Team
9 * This file is part of Galette (http://galette.tuxfamily.org).
11 * Galette is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
16 * Galette is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
27 * @author Frédéric Jaqcuot <unknown@unknow.com>
28 * @author Georges Khaznadar (password encryption, images) <unknown@unknow.com>
29 * @author Johan Cwiklinski <johan@x-tnd.be>
30 * @copyright 2003-2018 The Galette Team
31 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
32 * @link http://galette.tuxfamily.org
35 use Galette\Entity\PdfModel
;
37 $container = $app->getContainer();
39 // -----------------------------------------------------------------------------
41 // -----------------------------------------------------------------------------
43 $container['errorHandler'] = function ($c) {
44 return new Galette\Handlers\
Error($c['view'], true);
47 $container['phpErrorHandler'] = function ($c) {
48 return new Galette\Handlers\
PhpError($c['view'], true);
51 $container['notFoundHandler'] = function ($c) {
52 return new Galette\Handlers\
NotFound($c['view']);
55 // -----------------------------------------------------------------------------
57 // -----------------------------------------------------------------------------
59 // Register Smarty View helper
60 $container['view'] = function ($c) {
61 $view = new \Slim\Views\
Smarty(
62 rtrim(GALETTE_ROOT
. GALETTE_TPL_SUBDIR
, DIRECTORY_SEPARATOR
),
64 'cacheDir' => rtrim(GALETTE_CACHE_DIR
, DIRECTORY_SEPARATOR
),
65 'compileDir' => rtrim(GALETTE_COMPILE_DIR
, DIRECTORY_SEPARATOR
),
67 GALETTE_ROOT
. 'includes/smarty_plugins'
72 // Add Slim specific plugins
73 $basepath = str_replace(
76 $c['request']->getUri()->getBasePath()
78 $view->addSlimPlugins($c['router'], $basepath);
80 $smarty = $view->getSmarty();
81 $smarty->inheritance_merge_compiled_includes
= false;
83 $smarty->assign('flash', $c->get('flash'));
85 $smarty->assign('login', $c->login
);
86 $smarty->assign('logo', $c->logo
);
87 $smarty->assign('tpl', $smarty);
88 $smarty->assign('headers', $c->plugins
->getTplHeaders());
89 $smarty->assign('plugin_actions', $c->plugins
->getTplAdhActions());
91 'plugin_batch_actions',
92 $c->plugins
->getTplAdhBatchActions()
95 'plugin_detailled_actions',
96 $c->plugins
->getTplAdhDetailledActions()
98 $smarty->assign('scripts_dir', 'js/');
99 $smarty->assign('jquery_dir', 'js/jquery/');
100 $smarty->assign('jquery_version', JQUERY_VERSION
);
101 $smarty->assign('jquery_migrate_version', JQUERY_MIGRATE_VERSION
);
102 $smarty->assign('jquery_ui_version', JQUERY_UI_VERSION
);
103 $smarty->assign('jquery_markitup_version', JQUERY_MARKITUP_VERSION
);
104 $smarty->assign('jquery_jqplot_version', JQUERY_JQPLOT_VERSION
);
105 $smarty->assign('PAGENAME', basename($_SERVER['SCRIPT_NAME']));
106 $smarty->assign('galette_base_path', './');
107 $smarty->assign('GALETTE_VERSION', GALETTE_VERSION
);
108 $smarty->assign('GALETTE_MODE', GALETTE_MODE
);
109 $smarty->assign('GALETTE_DISPLAY_ERRORS', GALETTE_DISPLAY_ERRORS
);
110 $smarty->assign('_CURRENT_THEME_PATH', _CURRENT_THEME_PATH
);
112 /*if ($this->parserConfigDir) {
113 $instance->setConfigDir($this->parserConfigDir);
116 $smarty->assign('template_subdir', GALETTE_THEME
);
117 foreach ($c->plugins
->getTplAssignments() as $k => $v) {
118 $smarty->assign($k, $v);
120 /** galette_lang should be removed and languages used instead */
121 $smarty->assign('galette_lang', $c->i18n
->getAbbrev());
122 $smarty->assign('galette_lang_name', $c->i18n
->getName());
123 $smarty->assign('languages', $c->i18n
->getList());
124 $smarty->assign('plugins', $c->plugins
);
125 $smarty->assign('preferences', $c->preferences
);
126 $smarty->assign('pref_slogan', $c->preferences
->pref_slogan
);
127 $smarty->assign('pref_theme', $c->preferences
->pref_theme
);
128 $smarty->assign('pref_statut', $c->preferences
->pref_statut
);
130 'pref_editor_enabled',
131 $c->preferences
->pref_editor_enabled
133 $smarty->assign('pref_mail_method', $c->preferences
->pref_mail_method
);
134 $smarty->assign('existing_mailing', $c->get('session')->mailing
!== null);
135 $smarty->assign('require_tabs', null);
136 $smarty->assign('contentcls', null);
137 $smarty->assign('require_cookie', false);
138 $smarty->assign('additionnal_html_class', null);
139 $smarty->assign('require_calendar', null);
140 $smarty->assign('head_redirect', null);
141 $smarty->assign('error_detected', null);
142 $smarty->assign('warning_detected', null);
143 $smarty->assign('success_detected', null);
144 $smarty->assign('color_picker', null);
145 $smarty->assign('require_sorter', null);
146 $smarty->assign('require_dialog', null);
147 $smarty->assign('require_tree', null);
148 $smarty->assign('html_editor', null);
149 $smarty->assign('require_charts', null);
150 $smarty->assign('require_mass', null);
151 if ($c->login
->isAdmin() && $c->preferences
->pref_telemetry_date
) {
152 $now = new \
DateTime();
153 $sent = new \
DateTime($c->preferences
->pref_telemetry_date
);
154 $sent->add(new \
DateInterval('P1Y'));// ask to resend telemetry after one year
155 if ($now > $sent && !$_COOKIE['renew_telemetry']) {
156 $smarty->assign('renew_telemetry', true);
160 foreach ($c->get('plugins')->getModules() as $module_id => $module) {
161 $smarty->addTemplateDir(
162 $module['root'] . '/templates/' . $c->get('preferences')->pref_theme
,
170 $container['flash'] = function ($c) {
171 return new \Slim\Flash\Messages
;
174 $container['plugins'] = function ($c) use ($app) {
175 $plugins = new Galette\Core\
Plugins();
176 $i18n = $c->get('i18n');
177 $plugins->loadModules($c->preferences
, GALETTE_PLUGINS_PATH
, $i18n->getLongID());
181 $container['i18n'] = function ($c) {
182 $i18n = $c->get('session')->i18n
;
183 if (!$i18n ||
!$i18n->getId()) {
184 $i18n = new Galette\Core\
I18n();
185 $c->get('session')->i18n
= $i18n;
190 $container['zdb'] = function ($c) {
191 $zdb = new Galette\Core\
Db();
195 $container['preferences'] = function ($c) {
196 return new Galette\Core\
Preferences($c->zdb
);
199 $container['login'] = function ($c) {
200 $login = $c->get('session')->login
;
202 $login = new Galette\Core\
Login(
211 $container['session'] = function ($c) {
212 $session = new \RKA\
Session();
216 $container['logo'] = function ($c) {
217 return new Galette\Core\
Logo();
220 $container['print_logo'] = function ($c) {
221 return new Galette\Core\
PrintLogo();
225 $container['history'] = function ($c) {
226 return new Galette\Core\
History($c->get('zdb'), $c->get('login'));
229 $container['acls'] = function ($c) {
231 'preferences' => 'admin',
232 'store-preferences' => 'admin',
233 'testEmail' => 'admin',
234 'dashboard' => 'member',
235 'sysinfos' => 'staff',
237 'plugins' => 'admin',
238 'pluginInitDb' => 'admin',
239 'pluginsActivation' => 'admin',
240 'history' => 'staff',
241 'history_filter' => 'staff',
242 'flushHistory' => 'staff',
243 'doFlushHistory' => 'staff',
244 'members' => 'groupmanager',
245 'filter-memberslist'=> 'groupmanager',
246 'advanced-search' => 'groupmanager',
247 'batch-memberslist' => 'groupmanager',
248 'mailing' => 'staff',
249 'doMailing' => 'staff',
250 'mailingPreview' => 'staff',
251 'previewAttachment' => 'staff',
252 'mailingRecipients' => 'staff',
253 'csv-memberslist' => 'staff',
254 'groups' => 'groupmanager',
256 'member' => 'member',
257 'pdf-members-cards' => 'member',
258 'pdf-members-labels'=> 'groupmanager',
259 'mailings' => 'staff',
260 'mailings_filter' => 'staff',
261 'removeMailing' => 'staff',
262 'doRemoveMailing' => 'staff',
263 'contributions' => 'member',
264 'transactions' => 'staff',
265 'payments_filter' => 'member',
266 'editmember' => 'member',
267 'impersonate' => 'superadmin',
268 'unimpersonate' => 'member',
269 'reminders' => 'staff',
270 'doReminders' => 'staff',
271 'reminders-filter' => 'staff',
273 'doExport' => 'staff',
274 'removeCsv' => 'staff',
275 'doRemoveCsv' => 'staff',
278 'doImport' => 'staff',
279 'importModel' => 'staff',
280 'getImportModel' => 'staff',
281 'storeImportModel' => 'staff',
282 'uploadImportFile' => 'staff',
283 'pdfModels' => 'staff',
285 'removeTitle' => 'staff',
286 'doRemoveTitle' => 'staff',
287 'editTitle' => 'staff',
289 'changeText' => 'staff',
290 'transaction' => 'staff',
291 'doEditTransaction' => 'staff',
292 'contribution' => 'staff',
293 'contributionDates' => 'staff',
294 'contributionMembers' => 'staff',
295 'attendance_sheet_details' => 'groupmanager',
296 'attendance_sheet' => 'groupmanager',
297 'entitleds' => 'staff',
298 'editEntitled' => 'staff',
299 'removeEntitled' => 'staff',
300 'doRemoveEntitled' => 'staff',
301 'dynamicTranslations' => 'staff',
302 'editDynamicTranslation' => 'staff',
303 'printContribution' => 'staff',
304 'attach_contribution' => 'staff',
305 'detach_contribution' => 'staff',
306 'removeContribution' => 'staff',
307 'removeContributions' => 'staff',
308 'pdf_groups' => 'groupmanager',
309 'ajax_group' => 'groupmanager',
310 'ajax_groups' => 'groupmanager',
311 'ajax_groupname_unique' => 'groupmanager',
312 'ajax_groups_reorder' => 'admin',
313 'add_group' => 'staff',
314 'removeGroup' => 'staff',
315 'doRemoveGroup' => 'staff',
316 'doEditGroup' => 'groupmanager',
317 'adhesionForm' => 'member',
318 'removeMember' => 'staff',
319 'removeMembers' => 'staff',
320 'doRemoveMember' => 'staff',
321 'doRemoveContribution' => 'staff',
322 'configureCoreFields' => 'admin',
323 'configureDynamicFields' => 'admin',
324 'storeCoreFieldsConfig' => 'admin',
325 'editDynamicField' => 'admin',
326 'doEditDynamicField' => 'admin',
327 'moveDynamicField' => 'admin',
328 'removeDynamicField' => 'admin',
329 'doRemoveDynamicField' => 'admin',
330 'photoDnd' => 'staff',
331 'ajaxMembers' => 'groupmanager',
332 'ajaxGroupMembers' => 'staff',
333 'getDynamicFile' => 'member',
334 'fakeData' => 'superadmin',
335 'doFakeData' => 'superadmin',
336 'adminTools' => 'superadmin',
337 'doAdminTools' => 'superadmin',
338 'telemetryInfos' => 'admin',
339 'telemetrySend' => 'admin',
340 'setRegistered' => 'admin',
341 'masschangeMembers' => 'groupmanager',
342 'massstoremembers' => 'groupmanager',
343 'masschangeMembersReview' => 'groupmanager',
344 'duplicateMember' => 'staff',
345 'paymentTypes' => 'staff',
346 'removePaymentType' => 'staff',
347 'doRemovePaymentType' => 'staff',
348 'editPaymentType' => 'staff',
349 'searches' => 'member',
350 'removeSearch' => 'member',
351 'removeSearches' => 'member',
352 'doRemoveSearch' => 'member',
353 'loadSearch' => 'member'
356 foreach ($c['plugins']->getModules() as $plugin) {
357 $acls[$plugin['route'] . 'Info'] = 'member';
360 //load user defined ACLs
361 if (file_exists(GALETTE_CONFIG_PATH
. 'local_acls.inc.php')) {
362 $acls = array_merge($acls, $local_acls);
368 $container['texts_fields'] = function ($c) {
369 include_once GALETTE_ROOT
. 'includes/fields_defs/texts_fields.php';
370 return $texts_fields;
373 $container['members_fields'] = function ($c) {
374 include_once GALETTE_ROOT
. 'includes/fields_defs/members_fields.php';
375 return $members_fields;
378 $container['members_fields_cats'] = function ($c) {
379 include_once GALETTE_ROOT
. 'includes/fields_defs/members_fields_cats.php';
380 return $members_fields_cats;
383 $container['pdfmodels_fields'] = function ($c) {
384 //include_once GALETTE_ROOT . 'includes/fields_defs/pdfmodels_fields.php';
385 $pdfmodels_fields = array(
387 'model_id' => PdfModel
::MAIN_MODEL
,
388 'model_name' => '_T("Main")',
389 'model_title' => null,
390 'model_type' => PdfModel
::MAIN_MODEL
,
391 'model_header' => '<table>
393 <td id="pdf_assoname"><strong id="asso_name">{ASSO_NAME}</strong><br/>{ASSO_SLOGAN}</td>
394 <td id="pdf_logo">{ASSO_LOGO}</td>
397 'model_footer' => '<div id="pdf_footer">
398 _T("Association") {ASSO_NAME} - {ASSO_ADDRESS}<br/>
401 'model_body' => null,
402 'model_styles' => 'div#pdf_title {
430 'model_parent' => null
433 'model_id' => PdfModel
::INVOICE_MODEL
,
434 'model_name' => '_T("Invoice")',
435 'model_title' => '_T("Invoice") {CONTRIBUTION_YEAR}-{CONTRIBUTION_ID}',
436 'model_type' => PdfModel
::INVOICE_MODEL
,
437 'model_header' => null,
438 'model_footer' => null,
439 'model_body' => '<table>
441 <td width="300"></td>
442 <td><strong>{NAME_ADH}</strong><br/>
444 <strong>{ZIP_ADH} {TOWN_ADH}</strong>
448 <td height="100"></td>
456 <th>_T("Amount")</th>
462 {CONTRIBUTION_LABEL} (_T("on") {CONTRIBUTION_DATE})<br/>
463 _T("from") {CONTRIBUTION_BEGIN_DATE} _T("to") {CONTRIBUTION_END_DATE}<br/>
464 {CONTRIBUTION_PAYMENT_TYPE}<br/>
465 {CONTRIBUTION_COMMENT}
467 <td>{CONTRIBUTION_AMOUNT}</td>
474 'model_styles' => null,
475 'model_parent' => PdfModel
::MAIN_MODEL
478 'model_id' => PdfModel
::RECEIPT_MODEL
,
479 'model_name' => '_T("Receipt")',
480 'model_title' => '_T("Receipt") {CONTRIBUTION_YEAR}-{CONTRIBUTION_ID}',
481 'model_type' => PdfModel
::RECEIPT_MODEL
,
482 'model_header' => null,
483 'model_footer' => null,
484 'model_body' => '<table>
486 <td width="300"></td>
487 <td><strong>{NAME_ADH}</strong><br/>
489 <strong>{ZIP_ADH} {TOWN_ADH}</strong>
493 <td height="100"></td>
501 <th>_T("Amount")</th>
507 {CONTRIBUTION_LABEL} (_T("on") {CONTRIBUTION_DATE})<br/>
508 _T("from") {CONTRIBUTION_BEGIN_DATE} _T("to") {CONTRIBUTION_END_DATE}<br/>
509 {CONTRIBUTION_PAYMENT_TYPE}<br/>
510 {CONTRIBUTION_COMMENT}
512 <td>{CONTRIBUTION_AMOUNT}</td>
519 'model_styles' => null,
520 'model_parent' => PdfModel
::MAIN_MODEL
523 'model_id' => PdfModel
::ADHESION_FORM_MODEL
,
524 'model_name' => '_T("Adhesion form")',
525 'model_title' => '_T("Adhesion form")',
526 'model_type' => PdfModel
::ADHESION_FORM_MODEL
,
527 'model_header' => null,
528 'model_footer' => null,
529 'model_body' => '<hr/>
530 <div class="infos">_T("Complete the following form and send it with your funds, in order to complete your subscription.")</div>
533 <td width="50%"></td>
534 <td width="50%">{ASSO_ADDRESS_MULTI}</td>
540 <td height="30"></td>
543 <td>_T("Required membership:")
545 <input type="radio" class="box" name="cotisation" value="none1">_T("Active member")
546 <input type="radio" class="box" name="cotisation" value="none2">_T("Benefactor member")
547 <input type="radio" class="box" name="cotisation" value="none3">_T("Donation")
548 <div class="infos">_T("The minimum contribution for each type of membership are defined on the website of the association. The amount of donations are free to be decided by the generous donor.") </div>
553 <td height="30"></td>
556 <table class="member">
558 <td class="label">_T("Politeness")</td>
559 <td class="input">{TITLE_ADH}</td>
562 <td class="label">_T("Name")</td>
563 <td class="input">{LAST_NAME_ADH}</td>
566 <td class="label">_T("First name")</td>
567 <td class="input">{FIRST_NAME_ADH}</td>
570 <td class="label">_T("Company name") *</td>
571 <td class="input">{COMPANY_ADH}</td>
574 <td class="label">_T("Address")</td>
575 <td class="input">{ADDRESS_ADH}</td>
578 <td class="label"></td>
579 <td class="input"></td>
582 <td class="label"></td>
583 <td class="input"></td>
586 <td class="label">_T("Zip Code")</td>
587 <td class="cpinput">{ZIP_ADH}</td>
588 <td class="label">_T("City")</td>
589 <td class="towninput">{TOWN_ADH}</td>
592 <td class="label">_T("Country")</td>
593 <td class="input">{COUNTRY_ADH}</td>
596 <td class="label">_T("Email address")</td>
597 <td class="input">{EMAIL_ADH}</td>
600 <td class="label">_T("Username") **</td>
601 <td class="input">{LOGIN_ADH}</td>
604 <td colspan="2" height="10"></td>
607 <td class="label">_T("Amount")</td>
608 <td class="input"></td>
611 <p>str_replace(\'%s\', \'{ASSO_NAME}\', \'_T("Hereby, I agree to comply to %s association statutes and its rules.")\')</p><p>_T("At ................................................")</p><p>_T("On .......... / .......... / .......... ")</p><p>_T("Signature")</p>
612 <p class="notes">_T("* Only for compagnies")<br/>_T("** Galette identifier, if applicable")</p>',
613 'model_styles' => 'td.label {
619 border-bottom: 1px dotted black;
624 border-bottom: 1px dotted black;
629 border-bottom: 1px dotted black;
645 'model_parent' => PdfModel
::MAIN_MODEL
648 return $pdfmodels_fields;
651 // -----------------------------------------------------------------------------
653 // -----------------------------------------------------------------------------
656 $container['logger'] = function ($c) {
657 $settings = $c->get('settings');
658 $logger = new \Monolog\
Logger($settings['logger']['name']);
659 $logger->pushProcessor(new \Monolog\Processor\
UidProcessor());
660 $logger->pushHandler(new \Monolog\Handler\
StreamHandler($settings['logger']['path'], $setting['logger']['level']));
664 $container['fields_config'] = function ($c) {
665 $fc = new Galette\Entity\
FieldsConfig(
667 Galette\Entity\Adherent
::TABLE
,
668 $c->get('members_fields'),
669 $c->get('members_fields_cats')
674 $container['cache'] = function ($c) {
676 if (function_exists('wincache_ucache_add')) {
677 //since APCu is not known to work on windows
678 $adapter = 'wincache';
679 } elseif (function_exists('apcu_fetch')) {
682 if ($adapter !== null) {
683 $uuid = $c->get('mode') !== 'INSTALL' ?
$c->get('preferences')->pref_instance_uuid
: '_install';
684 $cache = Zend\Cache\StorageFactory
::factory([
685 'adapter' => $adapter,
687 'namespace' => str_replace(
688 ['%version', '%uuid'],
689 [GALETTE_VERSION
, $uuid],
690 'galette_%version_%uuid'
699 $container['translator'] = function ($c) {
700 $translator = new Galette\Core\
Translator();
702 $domains = ['galette'];
703 foreach ($domains as $domain) {
704 //load translation file for domain
705 $translator->addTranslationFilePattern(
707 GALETTE_ROOT
. '/lang/',
708 '/%s/LC_MESSAGES/' . $domain . '.mo',
712 //check if a local lang file exists and load it
713 $translator->addTranslationFilePattern(
715 GALETTE_ROOT
. '/lang/',
716 $domain . '_%s_local_lang.php',
721 $translator->setLocale($c->get('i18n')->getLongID());
722 if (!isset($container['mode']) ||
$c->get('mode') !== 'INSTALL' && $c->get('mode') !== 'NEED_UPDATE') {
723 $translator->setCache($c->get('cache'));
728 //For bad existing globals can be used...
729 if (!isset($container['mode']) ||
$container['mode'] !== 'INSTALL' && $container['mode'] !== 'NEED_UPDATE') {
730 $hist = $container['history'];
731 $login = $container['login'];
732 $zdb = $container['zdb'];
734 $i18n = $container['i18n'];
735 $translator = $container['translator'];
737 require_once GALETTE_ROOT
. 'includes/i18n.inc.php';