Skip to content

Commit

Permalink
Add option for logo url
Browse files Browse the repository at this point in the history
  • Loading branch information
David Durieux committed Mar 7, 2019
1 parent e68a2a1 commit e949c4e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
7 changes: 7 additions & 0 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ function plugin_notifications_install() {
['options' => $options],
['WHERE' => ['id' => $data['id']]]);
}
if (!strstr($data['options'], 'logo')) {
$options = str_replace("}", ',"opt_logo":"default"}', $data['options']);
$DB->update(
'glpi_plugin_notifications_notifications',
['options' => $options],
['WHERE' => ['id' => $data['id']]]);
}
}
return true;
}
Expand Down
27 changes: 24 additions & 3 deletions inc/notification.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,24 @@ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBT


function getOptions() {
global $CFG_GLPI;

return [
'subject' => [
'name' => __('Subject'),
'type' => 'string'
],
'logo' => [
'name' => __('Logo', 'notifications'),
'type' => 'select',
'allowed' => [
'default' => __('Default display'),
'glpi_instance' => __('Your GLPI logo (pics/fd_logo.png)', 'notifications')
],
'default' => 'default'
],
'left_image' => [
'name' => __('image Helpdesk à gauche'),
'name' => __('Helpdesk picture at left', 'notifications'),
'type' => 'select',
'allowed' => ['None' => 'none', 'M' => 'M', 'XL' => 'XL'],
'default' => 'M'
Expand Down Expand Up @@ -369,12 +380,12 @@ function notification_blue($type, $options) {
global $CFG_GLPI;

$blocks = [];

$logo = $this->getLogoURL($options['logo']);
$blocks[] = '<div style="font-family: Helvetica;">
<table style="border-collapse: collapse;width: 950px; border-top-left-radius: 6px;border-top-right-radius: 6px;background-color: #1B2F62;color: #ffffff;height: 80px;">
<tr style="height: 25px">
<td style="width:160px" rowspan="2">
<img alt="GLPi" title="Glpi" width="100" height="55" src="'.$CFG_GLPI["url_base"].'/pics/fd_logo.png" />
<img alt="GLPi" title="Glpi" width="100" height="55" src="'.$logo.'" />
</td>
<td style="width:350px;height: 30px;font-size: 24px;color: #ffffff;" rowspan="2">';

Expand Down Expand Up @@ -1087,4 +1098,14 @@ static function getMenuContent() {
}
return $menu;
}

function getLogoURL($type) {
global $CFG_GLPI;

if ($type == 'glpi_instance') {
return $CFG_GLPI["url_base"].'/pics/fd_logo.png';
}
// default
return 'https://raw.githubusercontent.com/glpi-project/glpi/master/pics/fd_logo.png';
}
}

0 comments on commit e949c4e

Please sign in to comment.