mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-19 00:28:47 +02:00
N°5102 - Allow to send emails (eg. notifications) using GSuite SMTP and OAuth
* migration to iTop 3.0
This commit is contained in:
@@ -2862,10 +2862,10 @@ HTML;
|
||||
*
|
||||
* @param string|null $sString
|
||||
*
|
||||
* @return boolean if string null or empty
|
||||
* @return bool if string null or empty
|
||||
* @since 3.0.2 N°5302
|
||||
*/
|
||||
public static function IsNullOrEmptyString(?string $sString): boolean
|
||||
public static function IsNullOrEmptyString(?string $sString): bool
|
||||
{
|
||||
return $sString == null || strlen($sString) == 0;
|
||||
}
|
||||
@@ -2877,10 +2877,10 @@ HTML;
|
||||
*
|
||||
* @param string|null $sString
|
||||
*
|
||||
* @return boolean if string is not null and not empty
|
||||
* @return bool if string is not null and not empty
|
||||
* @since 3.0.2 N°5302
|
||||
*/
|
||||
public static function IsNotNullOrEmptyString(?string $sString): boolean
|
||||
public static function IsNotNullOrEmptyString(?string $sString): bool
|
||||
{
|
||||
return !static::IsNullOrEmptyString($sString);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0">
|
||||
<constants/>
|
||||
<classes>
|
||||
<class id="OAuthClient" _delta="define">
|
||||
<parent>cmdbAbstractObject</parent>
|
||||
@@ -17,14 +16,15 @@
|
||||
<attribute id="name"/>
|
||||
</attributes>
|
||||
</naming>
|
||||
<display_template/>
|
||||
<icon/>
|
||||
<reconciliation>
|
||||
<attributes>
|
||||
<attribute id="provider"/>
|
||||
<attribute id="name"/>
|
||||
</attributes>
|
||||
</reconciliation>
|
||||
<style>
|
||||
<icon/>
|
||||
</style>
|
||||
</properties>
|
||||
<fields>
|
||||
<field id="provider" xsi:type="AttributeString">
|
||||
@@ -121,18 +121,32 @@
|
||||
<code><![CDATA[
|
||||
public function DisplayBareHeader(WebPage $oPage, $bEditMode = false)
|
||||
{
|
||||
parent::DisplayBareHeader($oPage, $bEditMode);
|
||||
$aHeaderBlocks = parent::DisplayBareHeader($oPage, $bEditMode);
|
||||
$aTags = [];
|
||||
if (!$bEditMode) {
|
||||
$oConfig = utils::GetConfig();
|
||||
if ($this->Get('status') == 'inactive') {
|
||||
$oPage->p('<b>'.Dict::S('itop-oauth-client:Message:MissingToken').'</b>');
|
||||
$sLabel = Dict::S('itop-oauth-client:Message:MissingToken');
|
||||
$sTitle = '';
|
||||
$aTags['oauth-message'] = ['title' => $sTitle, 'css_classes' => 'ibo-object-details--tag--oauth-message', 'decoration_classes' => 'fas fa-exclamation-triangle', 'label' => $sLabel];
|
||||
} elseif ($this->Get('used_for_smtp') == 'yes' && $oConfig->Get('email_transport_smtp.username') == $this->Get('name')) {
|
||||
$sLabel = Dict::S('itop-oauth-client:UsedForSMTP');
|
||||
$sTestLabel = Dict::S('itop-oauth-client:TestSMTP');
|
||||
$sTestURL = utils::GetAbsoluteUrlAppRoot().'setup/email.test.php';
|
||||
$oPage->p("<b>$sLabel</b> <a href='$sTestURL' target='_blank'>$sTestLabel</a>");
|
||||
$sLabel = Dict::S('itop-oauth-client:UsedForSMTP')." <a href='$sTestURL' target='_blank'>$sTestLabel</a>";
|
||||
$sTitle = '';
|
||||
$aTags['oauth-message'] = ['title' => $sTitle, 'css_classes' => 'ibo-object-details--tag--oauth-message', 'decoration_classes' => 'far fa-envelope', 'label' => $sLabel];
|
||||
}
|
||||
}
|
||||
foreach ($aTags as $sIconId => $aIconData) {
|
||||
$sTagTooltipContent = utils::EscapeHtml($aIconData['title']);
|
||||
$aHeaderBlocks['subtitle'][static::HEADER_BLOCKS_SUBTITLE_TAG_PREFIX.$sIconId] = new Combodo\iTop\Application\UI\Base\Component\Html\Html(<<<HTML
|
||||
<span id="{$sIconId}" class="ibo-object-details--tag {$aIconData['css_classes']}" data-tooltip-content="{$sTagTooltipContent}" data-tooltip-html-enabled="true"><span class="ibo-object-details--tag-icon"><span class="{$aIconData['decoration_classes']}"></span></span>{$aIconData['label']}</span>
|
||||
HTML
|
||||
);
|
||||
}
|
||||
|
||||
return $aHeaderBlocks;
|
||||
}
|
||||
]]></code>
|
||||
</method>
|
||||
@@ -294,8 +308,6 @@
|
||||
<attribute id="name"/>
|
||||
</attributes>
|
||||
</naming>
|
||||
<display_template/>
|
||||
<icon/>
|
||||
<reconciliation>
|
||||
<attributes>
|
||||
<attribute id="provider"/>
|
||||
@@ -312,13 +324,20 @@
|
||||
<is_blocking>true</is_blocking>
|
||||
</rule>
|
||||
</uniqueness_rules>
|
||||
<style>
|
||||
<icon/>
|
||||
</style>
|
||||
</properties>
|
||||
<fields>
|
||||
<field id="scope" xsi:type="AttributeEnumSet">
|
||||
<always_load_in_tables>true</always_load_in_tables>
|
||||
<values>
|
||||
<value id="SMTP">SMTP</value>
|
||||
<value id="IMAP">IMAP</value>
|
||||
<value id="SMTP">
|
||||
<code>SMTP</code>
|
||||
</value>
|
||||
<value id="IMAP">
|
||||
<code>IMAP</code>
|
||||
</value>
|
||||
</values>
|
||||
<sql>scope</sql>
|
||||
<default_value>SMTP,IMAP</default_value>
|
||||
@@ -332,8 +351,12 @@
|
||||
<field id="used_scope" xsi:type="AttributeEnum">
|
||||
<always_load_in_tables>true</always_load_in_tables>
|
||||
<values>
|
||||
<value id="simple">simple</value>
|
||||
<value id="advanced">advanced</value>
|
||||
<value id="simple">
|
||||
<code>simple</code>
|
||||
</value>
|
||||
<value id="advanced">
|
||||
<code>advanced</code>
|
||||
</value>
|
||||
</values>
|
||||
<sql>used_scope</sql>
|
||||
<default_value>simple</default_value>
|
||||
@@ -346,8 +369,12 @@
|
||||
<field id="used_for_smtp" xsi:type="AttributeEnum">
|
||||
<always_load_in_tables>true</always_load_in_tables>
|
||||
<values>
|
||||
<value id="yes">yes</value>
|
||||
<value id="no">no</value>
|
||||
<value id="yes">
|
||||
<code>yes</code>
|
||||
</value>
|
||||
<value id="no">
|
||||
<code>no</code>
|
||||
</value>
|
||||
</values>
|
||||
<sql>used_for_smtp</sql>
|
||||
<default_value>no</default_value>
|
||||
@@ -594,8 +621,6 @@
|
||||
<attribute id="name"/>
|
||||
</attributes>
|
||||
</naming>
|
||||
<display_template/>
|
||||
<icon/>
|
||||
<reconciliation>
|
||||
<attributes>
|
||||
<attribute id="provider"/>
|
||||
@@ -612,13 +637,20 @@
|
||||
<is_blocking>true</is_blocking>
|
||||
</rule>
|
||||
</uniqueness_rules>
|
||||
<style>
|
||||
<icon/>
|
||||
</style>
|
||||
</properties>
|
||||
<fields>
|
||||
<field id="scope" xsi:type="AttributeEnumSet">
|
||||
<always_load_in_tables>true</always_load_in_tables>
|
||||
<values>
|
||||
<value id="SMTP">SMTP</value>
|
||||
<value id="IMAP">IMAP</value>
|
||||
<value id="SMTP">
|
||||
<code>SMTP</code>
|
||||
</value>
|
||||
<value id="IMAP">
|
||||
<code>IMAP</code>
|
||||
</value>
|
||||
</values>
|
||||
<sql>scope</sql>
|
||||
<default_value>SMTP,IMAP</default_value>
|
||||
@@ -632,8 +664,12 @@
|
||||
<field id="used_scope" xsi:type="AttributeEnum">
|
||||
<always_load_in_tables>true</always_load_in_tables>
|
||||
<values>
|
||||
<value id="simple">simple</value>
|
||||
<value id="advanced">advanced</value>
|
||||
<value id="simple">
|
||||
<code>simple</code>
|
||||
</value>
|
||||
<value id="advanced">
|
||||
<code>advanced</code>
|
||||
</value>
|
||||
</values>
|
||||
<sql>used_scope</sql>
|
||||
<default_value>simple</default_value>
|
||||
@@ -646,8 +682,12 @@
|
||||
<field id="used_for_smtp" xsi:type="AttributeEnum">
|
||||
<always_load_in_tables>true</always_load_in_tables>
|
||||
<values>
|
||||
<value id="yes">yes</value>
|
||||
<value id="no">no</value>
|
||||
<value id="yes">
|
||||
<code>yes</code>
|
||||
</value>
|
||||
<value id="no">
|
||||
<code>no</code>
|
||||
</value>
|
||||
</values>
|
||||
<sql>used_for_smtp</sql>
|
||||
<default_value>no</default_value>
|
||||
@@ -899,7 +939,5 @@
|
||||
</classes>
|
||||
</group>
|
||||
</groups>
|
||||
<profiles>
|
||||
</profiles>
|
||||
</user_rights>
|
||||
</itop_design>
|
||||
|
||||
@@ -41,7 +41,7 @@ class PopupMenuExtension implements \iPopupMenuExtension
|
||||
$sId = $oObj->GetKey();
|
||||
$sAjaxUri = utils::GetAbsoluteUrlModulePage(static::MODULE_CODE, 'ajax.php');
|
||||
// Add a new menu item that triggers a custom JS function defined in our own javascript file: js/sample.js
|
||||
$sJSFileUrl = utils::GetAbsoluteUrlModulesRoot().static::MODULE_CODE.'/assets/js/oauth_connect.js';
|
||||
$sJSFileUrl = 'env-'.utils::GetCurrentEnvironment().'/'.static::MODULE_CODE.'/assets/js/oauth_connect.js';
|
||||
$sRedirectUri = OAuthClientProviderFactory::GetRedirectUri();
|
||||
$aResult[] = new JSPopupMenuItem(
|
||||
$sMenu.' from '.$sObjClass,
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{# @copyright Copyright (C) 2010-2022 Combodo SARL #}
|
||||
{# @license http://opensource.org/licenses/AGPL-3.0 #}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
{# @copyright Copyright (C) 2010-2022 Combodo SARL #}
|
||||
{# @license http://opensource.org/licenses/AGPL-3.0 #}
|
||||
|
||||
window.location.href = '{{ sURL|raw }}'
|
||||
Reference in New Issue
Block a user