* @param Object|Array $obj Object (or array) to send @see Pman_Core_Mailer
* + subject
* + rcpts || person << if person is set - then it goes to them...
- * + rcpts_group << for admin emails..
+ * + rcpts_group (string) << name of group - normally to send admin emails.. (if set, then bcc_group is ignored.)
* + replace_links
* + template
* + mailer_opts
function toMailer($obj,$force=false)
{
-
+ $p = new PEAR();
$contents = (array)$obj;
$this->get('name', $contents['template']);
}
+ if(empty($this->active)){
+ return $p->raiseError("template [{$contents['template']}] is Disabled");
+ }
+
if(empty($this->id)){
- $p = new PEAR();
return $p->raiseError("template [{$contents['template']}] has not been set");
}
// fill in BCC
if (!empty($this->bcc_group) && empty($contents['rcpts_group'])) {
+ $admin = DB_DAtaObject::Factory('core_group')->lookupMembersByGroupId($this->bcc_group,'email');
- $group = DB_DataObject::factory('groups');
- $group->get($this->bcc_group);
- $ar = $group->members('email');
- if (empty($ar)) {
- return $p->raiseError("template [{$contents['template']}] has not been set - bcc group is empty");
-
+ if (empty($admin)) {
+ return $p->raiseError("template [{$contents['template']}] - bcc group is empty");
}
- $contents->bcc = $ar;
+
+ $contents['bcc'] = $admin ;
}
if (!empty($contents['rcpts_group'])) {
+ $admin = DB_DAtaObject::Factory('core_group')->lookupMembers($contents['rcpts_group'],'email');
+
if (empty($admin)) {
- $admin = DB_DAtaObject::Factory('groups')->lookupMembers('bcc-email','email');
+ return $p->raiseError("Trying to send to {$contents['rcpts_group']} - group is empty");
}
-
+ $contents['rcpts'] = $admin;
}
-
-
-
-
if(empty($contents['subject'])){
$contents['subject'] = $this->subject;
}