1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Modules\Modules;
13
14 use ICanBoogie\I18n;
15
16 class Module extends \Icybee\Module
17 {
18 const OPERATION_ACTIVATE = 'activate';
19 const OPERATION_DEACTIVATE = 'deactivate';
20
21 protected function block_install($module_id)
22 {
23 global $core;
24
25 if (!$core->user->has_permission(self::PERMISSION_ADMINISTER, $this))
26 {
27 return '<div class="alert alert-error">' . I18n\t('You don\'t have enought privileges to install packages.') . '</div>';
28 }
29
30 if (empty($core->modules[$module_id]))
31 {
32 return '<div class="alert alert-error">' . I18n\t('The module %module_id does not exists.', array('%module_id' => $module_id)) . '</div>';
33 }
34
35 $errors = new \ICanBoogie\Errors;
36 $module = $core->modules[$module_id];
37
38 $is_installed = $module->is_installed($errors);
39
40 if ($is_installed && !count($errors))
41 {
42 return '<div class="alert alert-error">' . I18n\t('The module %module is already installed', array('%module' => $module_id)) . '</div>';
43 }
44
45 $errors->clear();
46 $is_installed = $module->install($errors);
47
48 if (!$is_installed || count($errors))
49 {
50 return '<div class="alert alert-error">' . I18n\t('Unable to install the module %module', array('%module' => $module_id)) . '</div>';
51 }
52
53 return '<div class="alert alert-success">' . I18n\t('The module %module has been installed. <a href="' . $core->site->path . '/admin/' . $this . '">Retourner à la liste.</a>', array('%module' => $module_id)) . '</div>';
54 }
55 }