本文整理汇总了PHP中CRM_Utils_File::formatFile方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_File::formatFile方法的具体用法?PHP CRM_Utils_File::formatFile怎么用?PHP CRM_Utils_File::formatFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_File
的用法示例。
在下文中一共展示了CRM_Utils_File::formatFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
/**
* Process the form submission.
*/
public function postProcess()
{
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Core_BAO_MessageTemplate::del($this->_id);
} elseif ($this->_action & CRM_Core_Action::VIEW) {
// currently, the above action is used solely for previewing default workflow templates
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/messageTemplates', 'selectedChild=workflow&reset=1'));
} else {
$params = array();
// store the submitted values in an array
$params = $this->controller->exportValues($this->_name);
if ($this->_action & CRM_Core_Action::UPDATE) {
$params['id'] = $this->_id;
}
if (!empty($params['file_type'])) {
unset($params['msg_html']);
unset($params['msg_text']);
CRM_Utils_File::formatFile($params, 'file_id');
} elseif (!empty($this->_id)) {
$entityFileDAO = new CRM_Core_DAO_EntityFile();
$entityFileDAO->entity_id = $this->_id;
$entityFileDAO->entity_table = 'civicrm_msg_template';
if ($entityFileDAO->find(TRUE)) {
$fileDAO = new CRM_Core_DAO_File();
$fileDAO->id = $entityFileDAO->file_id;
$fileDAO->find(TRUE);
$entityFileDAO->delete();
$fileDAO->delete();
}
}
if ($this->_workflow_id) {
$params['workflow_id'] = $this->_workflow_id;
$params['is_active'] = TRUE;
}
$messageTemplate = CRM_Core_BAO_MessageTemplate::add($params);
CRM_Core_Session::setStatus(ts('The Message Template \'%1\' has been saved.', array(1 => $messageTemplate->msg_title)), ts('Saved'), 'success');
if ($this->_workflow_id) {
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/messageTemplates', 'selectedChild=workflow&reset=1'));
} else {
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/messageTemplates', 'selectedChild=user&reset=1'));
}
}
}
示例2: formatAttachment
/**
* @param $formValues
* @param array $params
* @param $entityTable
* @param int $entityID
*/
public static function formatAttachment(&$formValues, &$params, $entityTable, $entityID = NULL)
{
// delete current attachments if applicable
if ($entityID && !empty($formValues['is_delete_attachment'])) {
CRM_Core_BAO_File::deleteEntityFile($entityTable, $entityID);
}
$numAttachments = Civi::settings()->get('max_attachments');
// setup all attachments
for ($i = 1; $i <= $numAttachments; $i++) {
$attachName = "attachFile_{$i}";
$attachDesc = "attachDesc_{$i}";
$attachTags = "tag_{$i}";
$attachFreeTags = "file_taglist_{$i}";
if (isset($formValues[$attachName]) && !empty($formValues[$attachName])) {
// add static tags if selects
$tagParams = array();
if (!empty($formValues[$attachTags])) {
foreach ($formValues[$attachTags] as $tag) {
$tagParams[$tag] = 1;
}
}
// we dont care if the file is empty or not
// CRM-7448
$extraParams = array('description' => $formValues[$attachDesc], 'tag' => $tagParams, 'attachment_taglist' => CRM_Utils_Array::value($attachFreeTags, $formValues, array()));
CRM_Utils_File::formatFile($formValues, $attachName, $extraParams);
// set the formatted attachment attributes to $params, later used by
// CRM_Activity_BAO_Activity::sendEmail(...) to send mail with desired attachments
if (!empty($formValues[$attachName])) {
$params[$attachName] = $formValues[$attachName];
}
}
}
}