本文整理汇总了PHP中CRM_Core_BAO_File类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_File类的具体用法?PHP CRM_Core_BAO_File怎么用?PHP CRM_Core_BAO_File使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_BAO_File类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Create a new HRJobDetails based on array-data
*
* @param array $params key-value pairs
* @return CRM_HRJob_DAO_HRJobDetails|NULL
*
*/
public static function create($params)
{
$hook = empty($params['id']) ? 'create' : 'edit';
$previousDetailsRevisionId = null;
if ($hook == 'create') {
$previousRevisionResult = civicrm_api3('HRJobContractRevision', 'getcurrentrevision', array('sequential' => 1, 'jobcontract_id' => $params['jobcontract_id']));
if (!empty($previousRevisionResult['values']['details_revision_id'])) {
$previousDetailsRevisionId = $previousRevisionResult['values']['details_revision_id'];
}
}
$instance = parent::create($params);
// setting 'effective_date' if it's not set:
$revision = civicrm_api3('HRJobContractRevision', 'get', array('sequential' => 1, 'jobcontract_id' => $params['jobcontract_id'], 'id' => $instance->jobcontract_revision_id));
if (!empty($revision['values'][0])) {
$revisionData = array_shift($revision['values']);
if (!$revisionData['effective_date']) {
civicrm_api3('HRJobContractRevision', 'create', array('id' => $revisionData['id'], 'effective_date' => $instance->period_start_date));
}
}
$revisionResult = civicrm_api3('HRJobContractRevision', 'get', array('sequential' => 1, 'id' => $instance->jobcontract_revision_id));
$revision = CRM_Utils_Array::first($revisionResult['values']);
$duplicate = CRM_Utils_Array::value('action', $params, $hook);
if ($hook == 'create' && empty($revision['role_revision_id']) && $duplicate != 'duplicate' && empty($params['import'])) {
//civicrm_api3('HRJobRole', 'create', array('jobcontract_id' => $revision['jobcontract_id'],'title' => $instance->title, 'location'=> $instance->location, 'percent_pay_role' => 100, 'jobcontract_revision_id' => $instance->jobcontract_revision_id));
CRM_Hrjobcontract_BAO_HRJobRole::create(array('jobcontract_id' => $revision['jobcontract_id'], 'title' => $instance->title, 'location' => $instance->location, 'percent_pay_role' => 100, 'jobcontract_revision_id' => $instance->jobcontract_revision_id));
}
if ($previousDetailsRevisionId) {
CRM_Core_BAO_File::copyEntityFile('civicrm_hrjobcontract_details', $previousDetailsRevisionId, 'civicrm_hrjobcontract_details', $revision['details_revision_id']);
}
$contract = new CRM_Hrjobcontract_DAO_HRJobContract();
$contract->id = $revision['jobcontract_id'];
$contract->find(true);
CRM_Hrjobcontract_JobContractDates::setDates($contract->contact_id, $revision['jobcontract_id'], $instance->period_start_date, $instance->period_end_date);
return $instance;
}
示例2: run
public function run()
{
$entityID = CRM_Utils_Request::retrieve('entityID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE);
$fileID = CRM_Utils_Request::retrieve('fileID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE);
$file = false;
if (is_numeric($fileID)) {
$file = civicrm_api3('File', 'getsingle', array('id' => $fileID));
}
try {
CRM_Core_BAO_File::deleteAttachment();
} catch (Exception $e) {
return null;
}
//Do the backend-service delete
if ($file && !empty($file['description'])) {
$details = json_decode($file['description']);
if ($details && property_exists($details, "source") && $details->source == "securefiles") {
//Check extension level permissions
CRM_Securefiles_Permission::checkFilePerms(CRM_Core_Action::DELETE, $fileID, $entityID);
$backendService = CRM_Securefiles_Backend::getBackendService();
if ($backendService) {
//Check backend service permissions
if ($backendService->checkPermissions(CRM_Core_Action::DELETE, $fileID, $entityID) !== false) {
$backendService->deleteFile($file['uri'], $entityID);
}
}
}
}
}
示例3: run
function run()
{
require_once 'CRM/Utils/Request.php';
require_once 'CRM/Core/DAO.php';
$eid = CRM_Utils_Request::retrieve('eid', 'Positive', $this, true);
$fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, false);
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this, true);
$quest = CRM_Utils_Request::retrieve('quest', 'String', $this);
$action = CRM_Utils_Request::retrieve('action', 'String', $this);
require_once 'CRM/Core/BAO/File.php';
list($path, $mimeType) = CRM_Core_BAO_File::path($id, $eid, null, $quest);
if (!$path) {
CRM_Core_Error::statusBounce('Could not retrieve the file');
}
$buffer = file_get_contents($path);
if (!$buffer) {
CRM_Core_Error::statusBounce('The file is either empty or you do not have permission to retrieve the file');
}
if ($action & CRM_Core_Action::DELETE) {
if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject)) {
CRM_Core_BAO_File::delete($id, $eid, $fid);
CRM_Core_Session::setStatus(ts('The attached file has been deleted.'));
$session = CRM_Core_Session::singleton();
$toUrl = $session->popUserContext();
CRM_Utils_System::redirect($toUrl);
} else {
$wrapper = new CRM_Utils_Wrapper();
return $wrapper->run('CRM_Custom_Form_DeleteFile', ts('Domain Information Page'), null);
}
} else {
require_once 'CRM/Utils/File.php';
CRM_Utils_System::download(CRM_Utils_File::cleanFileName(basename($path)), $mimeType, $buffer);
}
}
示例4: __construct
/**
* Constructor.
*
* @param null $path
* The class Path of the form being implemented
* @param bool $title
* @param string $mode
* @param bool $imageUpload
* @param bool $addSequence
* Should we add a unique sequence number to the end of the key.
* @param bool $ignoreKey
* Should we not set a qfKey for this controller (for standalone forms).
* @param bool $attachUpload
*
* @return \CRM_Core_Controller_Simple
*/
public function __construct($path, $title, $mode = NULL, $imageUpload = FALSE, $addSequence = FALSE, $ignoreKey = FALSE, $attachUpload = FALSE)
{
// by definition a single page is modal :). We use the form name as the scope for this controller
parent::__construct($title, TRUE, $mode, $path, $addSequence, $ignoreKey);
$this->_stateMachine = new CRM_Core_StateMachine($this);
$params = array($path => NULL);
$savedAction = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, NULL);
if (!empty($savedAction) && $savedAction != $mode) {
$mode = $savedAction;
}
$this->_stateMachine->addSequentialPages($params, $mode);
$this->addPages($this->_stateMachine, $mode);
//changes for custom data type File
$uploadNames = $this->get('uploadNames');
$config = CRM_Core_Config::singleton();
if (is_array($uploadNames) && !empty($uploadNames)) {
$uploadArray = $uploadNames;
$this->addActions($config->customFileUploadDir, $uploadArray);
$this->set('uploadNames', NULL);
} else {
// always allow a single upload file with same name
if ($attachUpload) {
$this->addActions($config->uploadDir, CRM_Core_BAO_File::uploadNames());
} elseif ($imageUpload) {
$this->addActions($config->imageUploadDir, array('uploadFile'));
} else {
$this->addActions();
}
}
}
示例5: __construct
/**
* constructor
*
* @param string path the class Path of the form being implemented
* @param string title the descriptive name for the page
* @param int mode the mode that the form will operate on
* @param boolean addSequence should we add a unique sequence number to the end of the key
* @param boolean ignoreKey should we not set a qfKey for this controller (for standalone forms)
*
* @return object
* @access public
*/
function __construct($path, $title, $mode = null, $imageUpload = false, $addSequence = false, $ignoreKey = false, $attachUpload = false)
{
// by definition a single page is modal :). We use the form name as the scope for this controller
parent::__construct($title, true, $mode, $path, $addSequence, $ignoreKey);
$this->_stateMachine =& new CRM_Core_StateMachine($this);
$params = array($path => null);
$this->_stateMachine->addSequentialPages($params, $mode);
$this->addPages($this->_stateMachine, $mode);
//changes for custom data type File
$uploadNames = $this->get('uploadNames');
$config =& CRM_Core_Config::singleton();
if (is_array($uploadNames) && !empty($uploadNames)) {
$uploadArray = $uploadNames;
$this->addActions($config->customFileUploadDir, $uploadArray);
$this->set('uploadNames', null);
} else {
// always allow a single upload file with same name
if ($attachUpload) {
require_once 'CRM/Core/BAO/File.php';
$this->addActions($config->uploadDir, CRM_Core_BAO_File::uploadNames());
} else {
if ($imageUpload) {
$this->addActions($config->imageUploadDir, array('uploadFile'));
} else {
$this->addActions();
}
}
}
}
示例6: buildQuickForm
public function buildQuickForm()
{
$session =& CRM_Core_Session::singleton();
$this->add('text', 'test_email', ts('Send to This Address'));
$defaults['test_email'] = $session->get('ufUniqID');
$qfKey = $this->get('qfKey');
$this->add('select', 'test_group', ts('Send to This Group'), array('' => ts('- none -')) + CRM_Core_PseudoConstant::group('Mailing'));
$this->setDefaults($defaults);
$this->add('submit', 'sendtest', ts('Send a Test Mailing'));
//FIXME : currently we are hiding save an continue later when
//search base mailing, we should handle it when we fix CRM-3876
$buttons = array(array('type' => 'back', 'name' => '<< Previous'), array('type' => 'next', 'name' => ts('Next >>'), 'spacing' => ' ', 'isDefault' => true), array('type' => 'submit', 'name' => ts('Save & Continue Later')), array('type' => 'cancel', 'name' => ts('Cancel')));
if ($this->get('context') == 'search' && $this->get('ssID')) {
$buttons = array(array('type' => 'back', 'name' => '<< Previous'), array('type' => 'next', 'name' => ts('Next >>'), 'spacing' => ' ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')));
}
$this->addButtons($buttons);
$mailingID = $this->get('mailing_id');
$textFile = $this->get('textFile');
$htmlFile = $this->get('htmlFile');
$subject = $this->get('subject');
$this->assign('subject', $subject);
$this->addFormRule(array('CRM_Mailing_Form_Test', 'testMail'), $this);
$preview = array();
if ($textFile) {
$preview['text_link'] = CRM_Utils_System::url('civicrm/mailing/preview', "type=text&qfKey={$qfKey}");
}
if ($htmlFile) {
$preview['html_link'] = CRM_Utils_System::url('civicrm/mailing/preview', "type=html&qfKey={$qfKey}");
}
require_once 'CRM/Core/BAO/File.php';
$preview['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_mailing', $mailingID);
$this->assign('preview', $preview);
}
示例7: run
public function run()
{
$eid = CRM_Utils_Request::retrieve('eid', 'Positive', $this, TRUE);
$fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, FALSE);
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$quest = CRM_Utils_Request::retrieve('quest', 'String', $this);
$action = CRM_Utils_Request::retrieve('action', 'String', $this);
list($path, $mimeType) = CRM_Core_BAO_File::path($id, $eid, NULL, $quest);
if (!$path) {
CRM_Core_Error::statusBounce('Could not retrieve the file');
}
$buffer = file_get_contents($path);
if (!$buffer) {
CRM_Core_Error::statusBounce('The file is either empty or you do not have permission to retrieve the file');
}
if ($action & CRM_Core_Action::DELETE) {
if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject)) {
CRM_Core_BAO_File::deleteFileReferences($id, $eid, $fid);
CRM_Core_Session::setStatus(ts('The attached file has been deleted.'), ts('Complete'), 'success');
$session = CRM_Core_Session::singleton();
$toUrl = $session->popUserContext();
CRM_Utils_System::redirect($toUrl);
}
} else {
CRM_Utils_System::download(CRM_Utils_File::cleanFileName(basename($path)), $mimeType, $buffer);
}
}
示例8: postProcess
/**
* Process the form when submitted
*
* @return void
* @access public
*/
public function postProcess()
{
CRM_Core_BAO_File::delete($this->_id, $this->_eid);
CRM_Core_Session::setStatus(ts('The attached file has been deleted.'));
$session = CRM_Core_Session::singleton();
$toUrl = $session->popUserContext();
CRM_Utils_System::redirect($toUrl);
}
示例9: fileDelete
function fileDelete()
{
// delete file
$postParams = $_POST;
$fileId = $postParams['fileID'];
CRM_Core_BAO_File::deleteEntityFile($postParams['entityTable'], $postParams['entityID'], $fileTypeID = NULL, $fileId);
CRM_Utils_System::civiExit();
}
示例10: template
/**
* Fetch the template text/html messages
*/
public static function template()
{
$templateId = CRM_Utils_Type::escape($_POST['tid'], 'Integer');
$messageTemplate = new CRM_Core_DAO_MessageTemplate();
$messageTemplate->id = $templateId;
$messageTemplate->selectAdd();
$messageTemplate->selectAdd('msg_text, msg_html, msg_subject, pdf_format_id');
$messageTemplate->find(TRUE);
$messages = array('subject' => $messageTemplate->msg_subject, 'msg_text' => $messageTemplate->msg_text, 'msg_html' => $messageTemplate->msg_html, 'pdf_format_id' => $messageTemplate->pdf_format_id);
$documentInfo = CRM_Core_BAO_File::getEntityFile('civicrm_msg_template', $templateId);
foreach ((array) $documentInfo as $info) {
list($messages['document_body']) = CRM_Utils_PDF_Document::docReader($info['fullPath'], $info['mime_type']);
}
CRM_Utils_JSON::output($messages);
}
示例11: run
/**
* run this page (figure out the action needed and perform it).
*
* @return void
*/
function run()
{
require_once 'CRM/Mailing/BAO/Mailing.php';
$session =& CRM_Core_Session::singleton();
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', CRM_Core_DAO::$_nullObject, false, 'text');
$type = CRM_Utils_Request::retrieve('type', 'String', CRM_Core_DAO::$_nullObject, false, 'text');
$options = array();
$session->getVars($options, "CRM_Mailing_Controller_Send_{$qfKey}");
//get the options if control come from search context, CRM-3711
if (empty($options)) {
$session->getVars($options, "CRM_Contact_Controller_Search_{$qfKey}");
}
// FIXME: the below and CRM_Mailing_Form_Test::testMail()
// should be refactored
$fromEmail = null;
$mailing =& new CRM_Mailing_BAO_Mailing();
if (!empty($options)) {
$mailing->id = $options['mailing_id'];
$fromEmail = $options['from_email'];
}
$mailing->find(true);
CRM_Mailing_BAO_Mailing::tokenReplace($mailing);
if (defined('CIVICRM_MAIL_SMARTY')) {
require_once 'CRM/Core/Smarty/resources/String.php';
civicrm_smarty_register_string_resource();
}
// get and format attachments
require_once 'CRM/Core/BAO/File.php';
$attachments =& CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $mailing->id);
//get details of contact with token value including Custom Field Token Values.CRM-3734
$returnProperties = $mailing->getReturnProperties();
$params = array('contact_id' => $session->get('userID'));
$details = $mailing->getDetails($params, $returnProperties);
$mime =& $mailing->compose(null, null, null, $session->get('userID'), $fromEmail, $fromEmail, true, $details[0][$session->get('userID')], $attachments);
// there doesn't seem to be a way to get to Mail_Mime's text and HTML
// parts, so we steal a peek at Mail_Mime's private properties, render
// them and exit
// note that preview does not display any attachments
$mime->get();
if ($type == 'html') {
header('Content-Type: text/html; charset=utf-8');
print $mime->_htmlbody;
} else {
header('Content-Type: text/plain; charset=utf-8');
print $mime->_txtbody;
}
exit;
}
示例12: preProcess
/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess()
{
$this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->assign('context', $context);
$values = array();
$params['id'] = $this->_id;
CRM_Grant_BAO_Grant::retrieve($params, $values);
$grantType = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id');
$grantStatus = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id');
$this->assign('grantType', $grantType[$values['grant_type_id']]);
$this->assign('grantStatus', $grantStatus[$values['status_id']]);
$grantTokens = array('amount_total', 'amount_requested', 'amount_granted', 'rationale', 'grant_report_received', 'application_received_date', 'decision_date', 'money_transfer_date', 'grant_due_date');
foreach ($grantTokens as $token) {
$this->assign($token, CRM_Utils_Array::value($token, $values));
}
if (isset($this->_id)) {
$noteDAO = new CRM_Core_BAO_Note();
$noteDAO->entity_table = 'civicrm_grant';
$noteDAO->entity_id = $this->_id;
if ($noteDAO->find(TRUE)) {
$this->_noteId = $noteDAO->id;
}
}
if (isset($this->_noteId)) {
$this->assign('note', CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Note', $this->_noteId, 'note'));
}
// add Grant to Recent Items
$url = CRM_Utils_System::url('civicrm/contact/view/grant', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
$title = CRM_Contact_BAO_Contact::displayName($values['contact_id']) . ' - ' . ts('Grant') . ': ' . CRM_Utils_Money::format($values['amount_total']) . ' (' . $grantType[$values['grant_type_id']] . ')';
$recentOther = array();
if (CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::UPDATE)) {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/grant', "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
}
if (CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::DELETE)) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/grant', "action=delete&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
}
CRM_Utils_Recent::add($title, $url, $values['id'], 'Grant', $values['contact_id'], NULL, $recentOther);
$attachment = CRM_Core_BAO_File::attachmentInfo('civicrm_grant', $this->_id);
$this->assign('attachment', $attachment);
$grantType = CRM_Core_DAO::getFieldValue("CRM_Grant_DAO_Grant", $this->_id, "grant_type_id");
$groupTree =& CRM_Core_BAO_CustomGroup::getTree("Grant", $this, $this->_id, 0, $grantType);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $this->_id);
$this->assign('id', $this->_id);
$this->setPageTitle(ts('Grant'));
}
示例13: __construct
/**
* Class constructor.
*
* @param string $title
* @param bool|int $action
* @param bool $modal
*/
public function __construct($title = NULL, $action = CRM_Core_Action::NONE, $modal = TRUE)
{
parent::__construct($title, $modal, NULL, FALSE, TRUE);
$mailingID = CRM_Utils_Request::retrieve('mid', 'String', $this, FALSE, NULL);
// also get the text and html file
$txtFile = CRM_Utils_Request::retrieve('txtFile', 'String', CRM_Core_DAO::$_nullObject, FALSE, NULL);
$config = CRM_Core_Config::singleton();
if ($txtFile && file_exists($config->uploadDir . $txtFile)) {
$this->set('textFilePath', $config->uploadDir . $txtFile);
}
$this->_stateMachine = new CRM_SMS_StateMachine_Send($this, $action, $mailingID);
// create and instantiate the pages
$this->addPages($this->_stateMachine, $action);
// add all the actions
$uploadNames = array_merge(array('textFile'), CRM_Core_BAO_File::uploadNames());
$this->addActions(CRM_Core_Config::singleton()->uploadDir, $uploadNames);
}
示例14: create
/**
* Create a new HRJobPension based on array-data
*
* @param array $params key-value pairs
* @return CRM_HRJob_DAO_HRJobPension|NULL
*
*/
public static function create($params)
{
$hook = empty($params['id']) ? 'create' : 'edit';
$previousPensionRevisionId = null;
if ($hook == 'create') {
$previousRevisionResult = civicrm_api3('HRJobContractRevision', 'getcurrentrevision', array('sequential' => 1, 'jobcontract_id' => $params['jobcontract_id']));
if (!empty($previousRevisionResult['values']['pension_revision_id'])) {
$previousPensionRevisionId = $previousRevisionResult['values']['pension_revision_id'];
}
}
$instance = parent::create($params);
$revisionResult = civicrm_api3('HRJobContractRevision', 'get', array('sequential' => 1, 'id' => $instance->jobcontract_revision_id));
$revision = CRM_Utils_Array::first($revisionResult['values']);
if ($previousPensionRevisionId) {
CRM_Core_BAO_File::copyEntityFile('civicrm_hrjobcontract_pension', $previousPensionRevisionId, 'civicrm_hrjobcontract_pension', $revision['pension_revision_id']);
}
return $instance;
}
示例15: view
/**
* View details of a note
*
* @return void
* @access public
*/
function view()
{
$note = new CRM_Core_DAO_Note();
$note->id = $this->_id;
if ($note->find(TRUE)) {
$values = array();
CRM_Core_DAO::storeValues($note, $values);
$values['privacy'] = CRM_Core_OptionGroup::optionLabel('note_privacy', $values['privacy']);
$this->assign('note', $values);
}
$comments = CRM_Core_BAO_Note::getNoteTree($values['id'], 1);
if (!empty($comments)) {
$this->assign('comments', $comments);
}
// add attachments part
$currentAttachmentInfo = CRM_Core_BAO_File::getEntityFile('civicrm_note', $this->_id);
$this->assign('currentAttachmentInfo', $currentAttachmentInfo);
}