/** * build all the data structures needed to build the form * * @return void * @access public */ static function preProcess(&$form) { $messageText = array(); $messageSubject = array(); $dao = new CRM_Core_BAO_MessageTemplate(); $dao->is_active = 1; $dao->find(); while ($dao->fetch()) { $messageText[$dao->id] = $dao->msg_text; $messageSubject[$dao->id] = $dao->msg_subject; } $form->assign('message', $messageText); $form->assign('messageSubject', $messageSubject); }
/** * Returns an array of all templates that can be used * to create donation receipts * @return array of template objects */ public static function findAllTemplates() { $messageTemplate = new CRM_Core_BAO_MessageTemplate(); $messageTemplate->orderBy('msg_title' . ' asc'); $messageTemplate->find(); $results = array(); $workflowId = CRM_Donrec_DataStructure::getFirstUsedOptionValueId(); while ($messageTemplate->fetch()) { if ($messageTemplate->workflow_id == $workflowId) { CRM_Core_DAO::storeValues($messageTemplate, $results[$messageTemplate->id]); } } return empty($results) ? NULL : $results; }
/** * Build all the data structures needed to build the form. * * @param CRM_Core_Form $form * * @return void */ public static function preProcess(&$form) { $messageText = array(); $messageSubject = array(); $dao = new CRM_Core_BAO_MessageTemplate(); $dao->is_active = 1; $dao->find(); while ($dao->fetch()) { $messageText[$dao->id] = $dao->msg_text; $messageSubject[$dao->id] = $dao->msg_subject; } $form->assign('message', $messageText); $form->assign('messageSubject', $messageSubject); CRM_Utils_System::setTitle('Create Printable Letters (PDF)'); }
/** * browse all entities. * * @internal param int $action * * @return void * @access public */ function browse() { $action = func_num_args() ? func_get_arg(0) : NULL; if ($this->_action & CRM_Core_Action::ADD) { return; } $links = $this->links(); if ($action == NULL) { if (!empty($links)) { $action = array_sum(array_keys($links)); } } if ($action & CRM_Core_Action::DISABLE) { $action -= CRM_Core_Action::DISABLE; } if ($action & CRM_Core_Action::ENABLE) { $action -= CRM_Core_Action::ENABLE; } $messageTemplate = new CRM_Core_BAO_MessageTemplate(); $messageTemplate->orderBy('msg_title' . ' asc'); $userTemplates = array(); $workflowTemplates = array(); // find all objects $messageTemplate->find(); while ($messageTemplate->fetch()) { $values[$messageTemplate->id] = array(); CRM_Core_DAO::storeValues($messageTemplate, $values[$messageTemplate->id]); // populate action links $this->action($messageTemplate, $action, $values[$messageTemplate->id], $links, CRM_Core_Permission::EDIT); if (!$messageTemplate->workflow_id) { $userTemplates[$messageTemplate->id] = $values[$messageTemplate->id]; } elseif (!$messageTemplate->is_reserved) { $workflowTemplates[$messageTemplate->id] = $values[$messageTemplate->id]; } } $rows = array('userTemplates' => $userTemplates, 'workflowTemplates' => $workflowTemplates); $this->assign('rows', $rows); }
/** * Revert a message template to its default subject+text+HTML state. * * @param int $id id of the template */ public static function revert($id) { $diverted = new CRM_Core_BAO_MessageTemplate(); $diverted->id = (int) $id; $diverted->find(1); if ($diverted->N != 1) { CRM_Core_Error::fatal(ts('Did not find a message template with id of %1.', array(1 => $id))); } $orig = new CRM_Core_BAO_MessageTemplate(); $orig->workflow_id = $diverted->workflow_id; $orig->is_reserved = 1; $orig->find(1); if ($orig->N != 1) { CRM_Core_Error::fatal(ts('Message template with id of %1 does not have a default to revert to.', array(1 => $id))); } $diverted->msg_subject = $orig->msg_subject; $diverted->msg_text = $orig->msg_text; $diverted->msg_html = $orig->msg_html; $diverted->pdf_format_id = is_null($orig->pdf_format_id) ? 'null' : $orig->pdf_format_id; $diverted->save(); }