diff --git a/include/class-Mailforwardfrom.php b/include/class-Mailforwardfrom.php index f4339dd..89b597b 100644 --- a/include/class-Mailforwardfrom.php +++ b/include/class-Mailforwardfrom.php @@ -1,127 +1,153 @@ . /** * Methods for a Mailforwardfrom class */ trait MailforwardfromTrait { /** * Get the mailforward from ID * * @return int */ public function getMailforwardfromID() { return $this->get( 'mailforwardfrom_ID' ); } /** * Get the mailforward from address * * @return string E-mail */ public function getMailforwardfromAddress() { return Mailbox::address( $this->getDomainName(), $this->getMailforwardfromUsername() ); } + /** + * Get the Mailforwardfrom printable firm + * + * @return self + */ + public function getMailforwardfromFirm() { + return Mailforwardfrom::firm( + $this->getDomainName(), + $this->getMailforwardfromUsername() + ); + } + /** * Get the mailforward from username * * @return string */ public function getMailforwardfromUsername() { return $this->get( 'mailforwardfrom_username' ); } /** * Get the mailforward permalink * * @param $absolute boolean * @return string */ public function getMailforwardfromPermalink( $absolute = false ) { return Mailforwardfrom::permalink( $this->getDomainName(), $this->getMailforwardfromUsername(), $absolute ); } /** * Normalize a Mailforwardfrom object after being retrieved from database */ protected function normalizeMailforwardfrom() { $this->integers( 'mailforwardfrom_ID' ); } } /** * An e-mail forwarding */ class Mailforwardfrom extends Queried { use MailforwardfromTrait; use DomainTrait; /** * Constructor */ public function __constructor() { $this->normalizeMailforwardfrom(); $this->normalizeDomain(); } /** * Database table name */ const T = 'mailforwardfrom'; /** * Update the related database row */ public function update( $columns ) { query_update( self::T, $columns, sprintf( "mailforwardfrom_ID = %d", $this->getMailforwardfromID() ) ); } /** * Get the mailforward permalink * * @return string */ public static function permalink( $domain, $mailforward = false, $absolute = false ) { $part = site_page( 'mailforward.php', $absolute ) . _ . $domain; if( $mailforward ) { $part .= _ . $mailforward; } return $part; } + /** + * Get a printable Mailbox firm + * + * @param string $domain_name Domain name + * @param string $mailforward_username Mailforward username without domain name + * @return string + */ + public static function firm( $domain_name, $mailforward_username ) { + return HTML::a( + self::permalink( $domain_name, $mailforward_username ), + esc_html( Mailbox::address( $domain_name, $mailforward_username ) ) + ); + } + /** * Force to get a Mailforwardfrom ID, whatever is passed * * @param mixed $mailforward Mailforwardfrom object or its ID * @return int */ public static function getID( $mailforward ) { return is_object( $mailforward ) ? $mailforward->getMailforwardfromID() : (int)$mailforward; } } diff --git a/template/mailforwards.php b/template/mailforwards.php index 7114ebc..859d3ba 100644 --- a/template/mailforwards.php +++ b/template/mailforwards.php @@ -1,73 +1,70 @@ . /* * This is the template for the mailboxes list * * Called from: * template/domain.php * * Available variables: * $domain object */ // unuseful when load directly defined( 'BOZ_PHP' ) or die; // domain mail forwardings $mailforwardfroms = $domain->factoryMailforwardfrom() ->select( [ 'mailforwardfrom.mailforwardfrom_ID', 'mailforwardfrom_username', 'domain_name', ] ) ->queryGenerator(); ?>

valid() ): ?>

getPlanName(), $plan->getPlanMailForwardings(), __( "Forwarding" ) ) ) ?>

getDomainName() ), __( "Create" ) ) ?>