Removing the BSVariableRegistry and instead making public static vars in BSApp for...
[isso.git] / Mail.php
index d2849856e7aa0fa8021647cbe8db27d3637d3fc7..ce4392e2fd432aa5024155dd72860ce7a37dcd09 100644 (file)
--- a/Mail.php
+++ b/Mail.php
@@ -89,6 +89,17 @@ class BSMail
        * @access       public
        */
        private $charset = 'utf-8'; // should we be using iso-8859-1 ?
+       
+       /**
+        * Constructor
+        */
+       public function __construct()
+       {
+               if (!BSApp::$input instanceof BSInput)
+               {
+                       throw new Exception('BSApp::$input is not an instance of BSInput');
+               }
+       }
                
        // ###################################################################
        /**
@@ -185,14 +196,6 @@ class BSMail
                        throw new Exception('You need to specify an email address');
                }
                
-               // load the input sanitizer
-               $input = BSApp::registry()->getType('Input');
-               if ($input == null)
-               {
-                       BSApp::debug(ISSO . '/Input not loaded, so manually doing so');
-                       $input = BSApp::load_module('Input');
-               }
-               
                // make sure we have a mailer
                // TODO - add support for SMTP
                if (!@ini_get('sendmail_path'))
@@ -203,14 +206,14 @@ class BSMail
                
                // sort out the to addresses
                $address = $this->_fetchFirstLine($address);
-               $address = trim($input->unsanitize($address));
+               $address = trim(BSApp::$input->unsanitize($address));
                $name = $this->_fetchFirstLine($name);
-               $name = trim($input->unsanitize($name));
+               $name = trim(BSApp::$input->unsanitize($name));
                $tostring = ($name == null ?  $address : "\"$name\" <$address>");
                
                // sanitize the from field
                $from = $this->_fetchFirstLine($this->from);
-               $from = trim($input->unsanitize($from));
+               $from = trim(BSApp::$input->unsanitize($from));
                if (empty($from))
                {
                        throw new Exception('You need to specify a from email address');
@@ -218,12 +221,12 @@ class BSMail
                
                // sanitize the from name
                $fromName = $this->_fetchFirstLine($this->fromName);
-               $fromName = ($fromName == '' ? $from : trim($input->unsanitize($fromName)));
+               $fromName = ($fromName == '' ? $from : trim(BSApp::$input->unsanitize($fromName)));
                $fromName = $this->_encodeHeaderValue($this->fromName);
                
                // sanitize the subject
                $subject = $this->_fetchFirstLine($this->subject);
-               $subject = trim($input->unsanitize($subject));
+               $subject = trim(BSApp::$input->unsanitize($subject));
                if (empty($subject))
                {
                        throw new Exception('You need to specify a subject for the message');
@@ -231,7 +234,7 @@ class BSMail
                
                // sanitize the body
                $bodyText = BSFunctions::convert_line_breaks($this->bodyText, $this->delim);
-               $bodyText = trim($input->unsanitize($bodyText, true));
+               $bodyText = trim(BSApp::$input->unsanitize($bodyText, true));
                if (empty($bodyText))
                {
                        throw new Exception('You need to specify body text before sending the message');