Protect install.xml with is_file and try-catch against abrupt uninstall
This commit is contained in:
parent
41b4fbaa35
commit
d6a56769a2
100
install.xml
100
install.xml
|
|
@ -11,42 +11,47 @@
|
|||
<operation error="skip">
|
||||
<search><![CDATA[if ($this->user->hasPermission('access', 'catalog/product')) {]]></search>
|
||||
<add position="before"><![CDATA[
|
||||
$this->load->model('setting/setting');
|
||||
$nat_status = $this->config->get('module_poll_widget_nat_status');
|
||||
if ($nat_status === null || $nat_status) {
|
||||
$nat_pos = $this->config->get('module_poll_widget_nat_menu_position');
|
||||
if (empty($nat_pos)) { $nat_pos = 'both'; }
|
||||
if ($nat_pos == 'sidebar' || $nat_pos == 'both') {
|
||||
if ($this->user->hasPermission('access', 'module/poll_widget_nat')) {
|
||||
$nat_item = array(
|
||||
'name' => 'Poll Widget',
|
||||
'href' => $this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], true),
|
||||
'children' => array()
|
||||
);
|
||||
|
||||
$nat_menu_index = -1;
|
||||
if (isset($data['menus'])) {
|
||||
foreach ($data['menus'] as $k => $menu) {
|
||||
if (isset($menu['id']) && $menu['id'] == 'menu-nat') {
|
||||
$nat_menu_index = $k;
|
||||
break;
|
||||
try {
|
||||
if (is_file(DIR_APPLICATION . 'controller/module/poll_widget_nat.php')) {
|
||||
$this->load->model('setting/setting');
|
||||
$nat_status = $this->config->get('module_poll_widget_nat_status');
|
||||
if ($nat_status === null || $nat_status) {
|
||||
$nat_pos = $this->config->get('module_poll_widget_nat_menu_position');
|
||||
if (empty($nat_pos)) { $nat_pos = 'both'; }
|
||||
if ($nat_pos == 'sidebar' || $nat_pos == 'both') {
|
||||
if ($this->user->hasPermission('access', 'module/poll_widget_nat')) {
|
||||
$nat_item = array(
|
||||
'name' => 'Poll Widget',
|
||||
'href' => $this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], true),
|
||||
'children' => array()
|
||||
);
|
||||
|
||||
$nat_menu_index = -1;
|
||||
if (isset($data['menus'])) {
|
||||
foreach ($data['menus'] as $k => $menu) {
|
||||
if (isset($menu['id']) && $menu['id'] == 'menu-nat') {
|
||||
$nat_menu_index = $k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($nat_menu_index > -1) {
|
||||
$data['menus'][$nat_menu_index]['children'][] = $nat_item;
|
||||
} else {
|
||||
$data['menus'][] = array(
|
||||
'id' => 'menu-nat',
|
||||
'icon' => 'fa-rocket fw',
|
||||
'name' => '[NAT] Modules',
|
||||
'href' => '',
|
||||
'children' => array($nat_item)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($nat_menu_index > -1) {
|
||||
$data['menus'][$nat_menu_index]['children'][] = $nat_item;
|
||||
} else {
|
||||
$data['menus'][] = array(
|
||||
'id' => 'menu-nat',
|
||||
'icon' => 'fa-rocket fw',
|
||||
'name' => '[NAT] Modules',
|
||||
'href' => '',
|
||||
'children' => array($nat_item)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
}
|
||||
]]></add>
|
||||
</operation>
|
||||
|
|
@ -56,22 +61,27 @@
|
|||
<operation error="skip">
|
||||
<search><![CDATA[$data['logout'] = $this->url->link('common/logout']]></search>
|
||||
<add position="before"><![CDATA[
|
||||
if (!isset($data['nat_menus'])) {
|
||||
$data['nat_menus'] = array();
|
||||
}
|
||||
$this->load->model('setting/setting');
|
||||
$nat_status = $this->config->get('module_poll_widget_nat_status');
|
||||
if ($nat_status === null || $nat_status) {
|
||||
$nat_pos = $this->config->get('module_poll_widget_nat_menu_position');
|
||||
if (empty($nat_pos)) { $nat_pos = 'both'; }
|
||||
if ($nat_pos == 'header' || $nat_pos == 'both') {
|
||||
if ($this->user->hasPermission('access', 'module/poll_widget_nat')) {
|
||||
$data['nat_menus'][] = array(
|
||||
'name' => 'Poll Widget',
|
||||
'href' => $this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], true)
|
||||
);
|
||||
try {
|
||||
if (!isset($data['nat_menus'])) {
|
||||
$data['nat_menus'] = array();
|
||||
}
|
||||
if (is_file(DIR_APPLICATION . 'controller/module/poll_widget_nat.php')) {
|
||||
$this->load->model('setting/setting');
|
||||
$nat_status = $this->config->get('module_poll_widget_nat_status');
|
||||
if ($nat_status === null || $nat_status) {
|
||||
$nat_pos = $this->config->get('module_poll_widget_nat_menu_position');
|
||||
if (empty($nat_pos)) { $nat_pos = 'both'; }
|
||||
if ($nat_pos == 'header' || $nat_pos == 'both') {
|
||||
if ($this->user->hasPermission('access', 'module/poll_widget_nat')) {
|
||||
$data['nat_menus'][] = array(
|
||||
'name' => 'Poll Widget',
|
||||
'href' => $this->url->link('module/poll_widget_nat', 'token=' . $this->session->data['token'], true)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
}
|
||||
]]></add>
|
||||
</operation>
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in New Issue