Debug mailer finished and debug messages removed:
[shipsimu.git] / inc / classes / main / mailer / class_BaseMailer.php
index 3685bf7cf353af51b68f1865b355d2f1b5e743ce..2dcbd9315b386132448bba430f46cacc7c251573 100644 (file)
@@ -53,7 +53,7 @@ class BaseMailer extends BaseFrameworkSystem {
         * @param       $templateName   Name of the template we shall load
         * @return      void
         */
-       public function loadTemplate ($templateName) {
+       protected final function loadTemplate ($templateName) {
                // Set template name
                $this->setTemplateName($templateName);
 
@@ -77,11 +77,66 @@ class BaseMailer extends BaseFrameworkSystem {
                // Is the list initialized?
                if (!isset($this->recipientList[$templateName]['recipients'])) {
                        // Then initialize it here
-                       $this->recipientList[$templateName]['recipients'] = new FrameworkArrayObject("FakedRecipientList");
+                       $this->recipientList[$templateName]['recipients'] = array();
                } // END - if
 
                // Add it as a recipient
-               $this->recipientList[$templateName]['recipients']->append($userInstance);
+               $this->recipientList[$templateName]['recipients'][] = $userInstance;
+       }
+
+       /**
+        * Adds a template variable (just the name) to the recipient list in given section of current template
+        *
+        * @param       $section                Section can be "config" or "value" currently
+        * @param       $variableName   Template variable name to add
+        * @return      void
+        */
+       private final function addTemplateVariable ($section, $variableName) {
+               // Get template name
+               $templateName = $this->getTemplateName();
+
+               // Generate full section name
+               $sectionName = $section . '_vars';
+
+               // Is the list initialized?
+               if (!isset($this->recipientList[$templateName][$sectionName])) {
+                       // Then initialize it here
+                       $this->recipientList[$templateName][$sectionName] = array();
+               } // END - if
+
+               // Add the variable to the list
+               $this->recipientList[$templateName][$sectionName][$variableName] = 'OK';
+       }
+
+       /**
+        * Adds a config template variable to the recipient list of current template
+        *
+        * @param       $variableName   Template variable name to add
+        * @return      void
+        */
+       public final function addConfigTemplateVariable ($variableName) {
+               $this->addTemplateVariable("config", $variableName);
+       }
+
+       /**
+        * Adds a "value" template variable to the recipient list of current template
+        *
+        * @param       $variableName   Template variable name to add
+        * @return      void
+        */
+       public final function addValueTemplateVariable ($variableName) {
+               $this->addTemplateVariable("value", $variableName);
+       }
+
+       /**
+        * Adds a value instance for a given variable name. It should be set!
+        *
+        * @param       $variableName   Template variable we want to assign a value instance
+        * @param       $valueInstance  An object instance which can provide "field values"
+        * @return      void
+        */
+       public final function addValueInstance ($variableName, FrameworkInterface $valueInstance) {
+               $this->recipientList[$this->getTemplateName()]['values'][$variableName] = $valueInstance;
        }
 
        /**
@@ -90,7 +145,7 @@ class BaseMailer extends BaseFrameworkSystem {
         * @param       $templateName   Name of email template
         * @return      void
         */
-       protected final function setTemplateName ($templateName) {
+       public final function setTemplateName ($templateName) {
                $this->templateName = (string) $templateName;
        }
 
@@ -144,6 +199,15 @@ class BaseMailer extends BaseFrameworkSystem {
                // Set the subject line
                $this->setSubjectLine("{?subject?}");
        }
+
+       /**
+        * Getter for recipient list array
+        *
+        * @return      $recipientList  Array with reciepients
+        */
+       public final function getRecipientList () {
+               return $this->recipientList;
+       }
 }
 
 // [EOF]