1<?php 2namespace go\modules\community\imapauthenticator\model; 3 4use go\core\orm\Query; 5use go\core\jmap\Entity; 6 7class Server extends Entity { 8 9 public $id; 10 public $imapHostname; 11 public $imapPort; 12 public $imapEncryption; 13 14 public $imapValidateCertificate = true; 15 16 public $removeDomainFromUsername = false; 17 18 public $smtpHostname; 19 public $smtpPort; 20 public $smtpUsername; 21 22 /** 23 * SMTP Password 24 * 25 * @var string 26 */ 27 protected $smtpPassword = null; 28 29 30 public function getSmtpPassword() { 31 return isset($this->smtpPassword) ? \go\core\util\Crypt::decrypt($this->smtpPassword) : null; 32 } 33 34 public function setSmtpPassword($value) { 35 $this->smtpPassword = !empty($value) ? \go\core\util\Crypt::encrypt($value) : null; 36 } 37 38 public $smtpUseUserCredentials= false; 39 public $smtpValidateCertificate = true; 40 public $smtpEncryption; 41 42 /** 43 * Users must login with their full e-mail address. The domain part will be used 44 * to lookup this server profile. 45 * 46 * @var Domain[] 47 */ 48 public $domains; 49 50 /** 51 * New users will be added to these user groups 52 * 53 * @var Group[] 54 */ 55 public $groups; 56 57 protected static function defineMapping() { 58 return parent::defineMapping() 59 ->addTable('imapauth_server', 's') 60 ->addArray("domains", Domain::class, ['id' => "serverId"]) 61 ->addArray("groups", Group::class, ['id' => "serverId"]); 62 } 63 64 public static function getClientName() { 65 return "ImapAuthServer"; 66 } 67 68 protected function internalSave() { 69 if($this->isModified("domains")) { 70 go()->getCache()->delete("authentication-domains"); 71 } 72 73 return parent::internalSave(); 74 } 75 76 protected static function internalDelete(Query $query) { 77 go()->getCache()->delete("authentication-domains"); 78 return parent::internalDelete($query); 79 } 80} 81