diff --git a/datamodels/2.x/itop-remote-authent-oauth/model.itop-remote-authent-oauth.php b/datamodels/2.x/itop-remote-authent-oauth/model.itop-remote-authent-oauth.php index c29097be3f..28da5d3e54 100644 --- a/datamodels/2.x/itop-remote-authent-oauth/model.itop-remote-authent-oauth.php +++ b/datamodels/2.x/itop-remote-authent-oauth/model.itop-remote-authent-oauth.php @@ -1,137 +1,5 @@ 'cloud,searchable', - 'key_type' => 'autoincrement', - 'name_attcode' => array('provider', 'name'), - 'state_attcode' => '', - 'reconc_keys' => array('provider', 'name'), - 'db_table' => 'priv_remote_authent_oauth', - 'db_key_field' => 'id', - 'db_finalclass_field' => '', - 'uniqueness_rules' => array ( - 'Username' => - array ( - 'attributes' => - array ( - 0 => 'name', - ), - 'filter' => NULL, - 'disabled' => false, - 'is_blocking' => true, - ), - 'OAuth Server' => - array ( - 'attributes' => - array ( - 0 => 'provider', - 1 => 'scope', - 2 => 'client_id', - 3 => 'client_secret', - ), - 'filter' => NULL, - 'disabled' => false, - 'is_blocking' => true, - ), -),); - MetaModel::Init_Params($aParams); - MetaModel::Init_InheritAttributes(); - MetaModel::Init_AddAttribute(new AttributeString("provider", array("allowed_values"=>null, "sql"=>'provider', "default_value"=>'', "is_null_allowed"=>false, "depends_on"=>array(), "always_load_in_tables"=>false))); - MetaModel::Init_AddAttribute(new AttributeString("name", array("allowed_values"=>null, "sql"=>'name', "default_value"=>'', "is_null_allowed"=>false, "depends_on"=>array(), "always_load_in_tables"=>false))); - MetaModel::Init_AddAttribute(new AttributeString("scope", array("allowed_values"=>null, "sql"=>'scope', "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array(), "always_load_in_tables"=>false))); - MetaModel::Init_AddAttribute(new AttributeText("description", array("allowed_values"=>null, "sql"=>'description', "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array(), "always_load_in_tables"=>false))); - MetaModel::Init_AddAttribute(new AttributeText("client_id", array("allowed_values"=>null, "sql"=>'client_id', "default_value"=>'', "is_null_allowed"=>false, "depends_on"=>array(), "always_load_in_tables"=>false))); - MetaModel::Init_AddAttribute(new AttributeText("client_secret", array("allowed_values"=>null, "sql"=>'client_secret', "default_value"=>'', "is_null_allowed"=>false, "depends_on"=>array(), "always_load_in_tables"=>false))); - MetaModel::Init_AddAttribute(new AttributeText("refresh_token", array("allowed_values"=>null, "sql"=>'refresh_token', "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array(), "always_load_in_tables"=>false, "tracking_level"=>ATTRIBUTE_TRACKING_NONE))); - MetaModel::Init_AddAttribute(new AttributeDateTime("refresh_token_expiration", array("allowed_values"=>null, "sql"=>'refresh_token_expiration', "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array(), "always_load_in_tables"=>false, "tracking_level"=>ATTRIBUTE_TRACKING_NONE))); - MetaModel::Init_AddAttribute(new AttributeText("token", array("allowed_values"=>null, "sql"=>'token', "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array(), "always_load_in_tables"=>false, "tracking_level"=>ATTRIBUTE_TRACKING_NONE))); - MetaModel::Init_AddAttribute(new AttributeDateTime("token_expiration", array("allowed_values"=>null, "sql"=>'token_expiration', "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array(), "always_load_in_tables"=>false, "tracking_level"=>ATTRIBUTE_TRACKING_NONE))); - MetaModel::Init_AddAttribute(new AttributeURL("redirect_url", array("target"=>'_blank', "allowed_values"=>null, "sql"=>'redirect_url', "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array(), "always_load_in_tables"=>false))); - MetaModel::Init_AddAttribute(new AttributeLinkedSet("mailbox_list", array("linked_class"=>'MailInboxOAuth', "ext_key_to_me"=>'remote_authent_oauth_id', "count_min"=>0, "count_max"=>0, "allowed_values"=>null, "depends_on"=>array(), "always_load_in_tables"=>false))); - - - - MetaModel::Init_SetZListItems('details', array ( - 0 => 'name', - 1 => 'description', - 2 => 'provider', - 3 => 'scope', - 4 => 'redirect_url', - 5 => 'client_id', - 6 => 'client_secret', - 7 => 'mailbox_list', -)); - MetaModel::Init_SetZListItems('standard_search', array ( - 0 => 'name', - 1 => 'provider', -)); - MetaModel::Init_SetZListItems('default_search', array ( - 0 => 'name', - 1 => 'provider', -)); -; - } - - - - - public function DisplayBareHeader(WebPage $oPage, $bEditMode = false) - { - parent::DisplayBareHeader($oPage, $bEditMode); - if (!$bEditMode) { - $oConfig = utils::GetConfig(); - if ($oConfig->Get('email_transport_smtp.username') == $this->Get('name')) { - $sLabel = Dict::S('itop-remote-authent-oauth:UsedForSMTP'); - $sTestLabel = Dict::S('itop-remote-authent-oauth:TestSMTP'); - $sTestURL = utils::GetAbsoluteUrlAppRoot().'setup/email.test.php'; - $oPage->p("$sLabel $sTestLabel"); - } - } - } - - - - - public function GetDefaultMailServer() - { - return 'imap.'.$this->Get('provider').'.com'; - } - - - - - public function GetDefaultMailServerPort() - { - return 993; - } - - -} -// -// Menus -// -class MenuCreation_itop_remote_authent_oauth extends ModuleHandlerAPI -{ - public static function OnMenuCreation() - { - global $__comp_menus__; // ensure that the global variable is indeed global ! - $__comp_menus__['ConfigurationTools'] = new MenuGroup('ConfigurationTools', 90 , null, UR_ACTION_MODIFY, UR_ALLOWED_YES, null); - $__comp_menus__['RemoteOAuth'] = new SearchMenuNode('RemoteOAuth', 'RemoteAuthentOAuth', $__comp_menus__['ConfigurationTools']->GetIndex(), 100, null , null, UR_ACTION_MODIFY, UR_ALLOWED_YES, null); - } -} // class MenuCreation_itop_remote_authent_oauth diff --git a/datamodels/2.x/itop-remote-authent-oauth/src/Model/RemoteAuthentOAuthAzure.php b/datamodels/2.x/itop-remote-authent-oauth/src/Model/RemoteAuthentOAuthAzure.php index 0ded7dc462..877c930edd 100644 --- a/datamodels/2.x/itop-remote-authent-oauth/src/Model/RemoteAuthentOAuthAzure.php +++ b/datamodels/2.x/itop-remote-authent-oauth/src/Model/RemoteAuthentOAuthAzure.php @@ -14,12 +14,12 @@ class RemoteAuthentOAuthAzure extends RemoteAuthentOAuth ( 'category' => 'cloud', 'key_type' => 'autoincrement', - 'name_attcode' => ['provider','name'], + 'name_attcode' => ['provider', 'name'], 'state_attcode' => '', - 'reconc_keys' => ['provider','name'], + 'reconc_keys' => ['provider', 'name'], 'db_table' => 'priv_remote_authent_oauth_azure', 'db_key_field' => 'id', - 'icon' => utils::GetAbsoluteUrlModulesRoot().'itop-remote-authent-oauth/assets/img/icons8-azure.svg', + 'icon' => utils::GetAbsoluteUrlModulesRoot().'itop-remote-authent-oauth/assets/img/icons8-azure.svg', 'db_finalclass_field' => '', ); MetaModel::Init_Params($aParams); @@ -56,4 +56,13 @@ class RemoteAuthentOAuthAzure extends RemoteAuthentOAuth { return 'imap.office365.com'; } + + public function GetAttributeFlags($sAttCode, &$aReasons = array(), $sTargetState = '') + { + if ($sAttCode == 'provider' || $sAttCode == 'redirect_url') { + return OPT_ATT_READONLY; + } + + return parent::GetAttributeFlags($sAttCode, $aReasons, $sTargetState); + } } \ No newline at end of file diff --git a/datamodels/2.x/itop-remote-authent-oauth/src/Model/RemoteAuthentOAuthGoogle.php b/datamodels/2.x/itop-remote-authent-oauth/src/Model/RemoteAuthentOAuthGoogle.php index d137ca59d6..6849c9694a 100644 --- a/datamodels/2.x/itop-remote-authent-oauth/src/Model/RemoteAuthentOAuthGoogle.php +++ b/datamodels/2.x/itop-remote-authent-oauth/src/Model/RemoteAuthentOAuthGoogle.php @@ -57,4 +57,12 @@ class RemoteAuthentOAuthGoogle extends RemoteAuthentOAuth return 'imap.gmail.com'; } + public function GetAttributeFlags($sAttCode, &$aReasons = array(), $sTargetState = '') + { + if ($sAttCode == 'provider' || $sAttCode == 'scope' || $sAttCode == 'redirect_url') { + return OPT_ATT_READONLY; + } + + return parent::GetAttributeFlags($sAttCode, $aReasons, $sTargetState); + } } \ No newline at end of file