function initMail($mail_template_dir, $name, $master = '') { $cm = DB_DataObject::factory('core_email'); if ($cm->get('name', $name)) { return; } // $basedir = $this->bootLoader->rootDir . $mail_template_dir; $opts = array(); $opts['file'] = $mail_template_dir . $name . '.html'; if (!empty($master)) { $opts['master'] = $mail_template_dir . $master . '.html'; } print_r($opts); require_once 'Pman/Core/Import/Core_email.php'; $x = new Pman_Core_Import_Core_email(); $x->get('', $opts); }
function initEmails($templateDir, $emails) { $pg = HTML_FlexyFramework::get()->page; foreach ($emails as $name => $data) { $cm = DB_DataObject::factory('core_email'); $update = $cm->get('name', $name); $old = clone $cm; if (empty($cm->bcc_group)) { if (empty($data['bcc_group'])) { $this->jerr("missing bcc_group for template {$name}"); } $g = DB_DataObject::Factory('core_group')->lookup('name', $data['bcc_group']); if (empty($g->id)) { $this->jerr("bcc_group {$data['bcc_group']} does not exist when importing template {$name}"); } if (!$g->members('email')) { $this->jerr("bcc_group {$data['bcc_group']} does not have any members"); } $cm->bcc_group = $g->id; } if (empty($cm->test_class)) { if (empty($data['test_class'])) { $this->jerr("missing test_class for template {$name}"); } $cm->test_class = $data['test_class']; } require_once $cm->test_class . '.php'; $clsname = str_replace('/', '_', $cm->test_class); try { $method = new ReflectionMethod($clsname, 'test_' . $name); $got_it = $method->isStatic(); } catch (Exception $e) { $got_it = false; } if (!$got_it) { $this->jerr("template {$name} does not have a test method {$clsname}::test_{$name}"); } if ($update) { $cm->update($old); echo "email: {$name} - checked\n"; continue; /// we do not import the body content of templates that exist... } else { //$cm->insert(); } // $basedir = $this->bootLoader->rootDir . $mail_template_dir; $opts = array('update' => 1, 'file' => $templateDir . $name . '.html'); if (!empty($data['master'])) { $opts['master'] = $templateDir . $master . '.html'; } require_once 'Pman/Core/Import/Core_email.php'; $x = new Pman_Core_Import_Core_email(); $x->updateOrCreateEmail('', $opts, $cm); echo "email: {$name} - CREATED\n"; } }