diff --git a/include/class-Mailforwardfrom.php b/include/class-Mailforwardfrom.php index eaa1971..4a5d4d8 100644 --- a/include/class-Mailforwardfrom.php +++ b/include/class-Mailforwardfrom.php @@ -1,94 +1,117 @@ . +/** + * 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 sprintf( '%s@%s', $this->getMailforwardfromUsername(), $this->getDomainName() ); } /** * 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 Domain { +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; } }