本文整理汇总了PHP中CRM_Core_BAO_File::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_File::delete方法的具体用法?PHP CRM_Core_BAO_File::delete怎么用?PHP CRM_Core_BAO_File::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_File
的用法示例。
在下文中一共展示了CRM_Core_BAO_File::delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
示例2: 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);
}
示例3: postProcess
public function postProcess()
{
$formValues = $this->exportValues();
// user can't choose to move cases without activities (CRM-3778)
if ($formValues['move_rel_table_cases'] == '1' && array_key_exists('move_rel_table_activities', $formValues)) {
$formValues['move_rel_table_activities'] = '1';
}
// reset all selected contact ids from session
// when we came from search context, CRM-3526
$session =& CRM_Core_Session::singleton();
if ($session->get('selectedSearchContactIds')) {
$session->resetScope('selectedSearchContactIds');
}
$relTables =& CRM_Dedupe_Merger::relTables();
$moveTables = $locBlocks = array();
foreach ($formValues as $key => $value) {
if ($value == $this->_qfZeroBug) {
$value = '0';
}
if ((in_array(substr($key, 5), CRM_Dedupe_Merger::$validFields) or substr($key, 0, 12) == 'move_custom_') and $value != null) {
$submitted[substr($key, 5)] = $value;
} elseif (substr($key, 0, 14) == 'move_location_' and $value != null) {
$locField = explode('_', $key);
$fieldName = $locField[2];
$fieldCount = $locField[3];
$operation = CRM_Utils_Array::value('operation', $formValues['location'][$fieldName][$fieldCount]);
// default operation is overwrite.
if (!$operation) {
$operation = 2;
}
$locBlocks[$fieldName][$fieldCount]['operation'] = $operation;
$locBlocks[$fieldName][$fieldCount]['locTypeId'] = CRM_Utils_Array::value('locTypeId', $formValues['location'][$fieldName][$fieldCount]);
} elseif (substr($key, 0, 15) == 'move_rel_table_' and $value == '1') {
$moveTables = array_merge($moveTables, $relTables[substr($key, 5)]['tables']);
}
}
// process location blocks.
if (!empty($locBlocks)) {
$locComponent = array('email' => 'Email', 'phone' => 'Phone', 'im' => 'IM', 'openid' => 'OpenID', 'address' => 'Address');
require_once 'CRM/Contact/BAO/Contact.php';
$primaryBlockIds = CRM_Contact_BAO_Contact::getLocBlockIds($this->_cid, array('is_primary' => 1));
$billingBlockIds = CRM_Contact_BAO_Contact::getLocBlockIds($this->_cid, array('is_billing' => 1));
foreach ($locBlocks as $name => $block) {
if (!is_array($block) || CRM_Utils_System::isNull($block)) {
continue;
}
$daoName = $locComponent[$name];
$primaryDAOId = array_key_exists($name, $primaryBlockIds) ? array_pop($primaryBlockIds[$name]) : null;
$billingDAOId = array_key_exists($name, $billingBlockIds) ? array_pop($billingBlockIds[$name]) : null;
foreach ($block as $blkCount => $values) {
$locTypeId = CRM_Utils_Array::value('locTypeId', $values, 1);
$operation = CRM_Utils_Array::value('operation', $values, 2);
$updateBlockId = CRM_Utils_Array::value($blkCount, $this->_locBlockIds['other'][$name]);
// keep 1-1 mapping for address - loc type.
$idKey = $blkCount;
if ($name == 'address') {
$idKey = $locTypeId;
}
$deleteBlockId = CRM_Utils_Array::value($idKey, $this->_locBlockIds['main'][$name]);
if (!$updateBlockId) {
continue;
}
require_once "CRM/Core/DAO/{$daoName}.php";
eval("\$updateDAO =& new CRM_Core_DAO_{$daoName}();");
$updateDAO->id = $updateBlockId;
$updateDAO->contact_id = $this->_cid;
$updateDAO->location_type_id = $locTypeId;
// contact having primary block.
if ($primaryDAOId) {
$updateDAO->is_primary = 0;
}
if ($billingDAOId) {
$updateDAO->is_billing = 0;
}
// overwrite - need to delete block from main contact.
if ($deleteBlockId && $operation == 2) {
eval("\$deleteDAO =& new CRM_Core_DAO_{$daoName}();");
$deleteDAO->id = $deleteBlockId;
$deleteDAO->find(true);
// since we overwrite primary block.
if ($primaryDAOId && $primaryDAOId == $deleteDAO->id) {
$updateDAO->is_primary = 1;
}
if ($billingDAOId && $billingDAOId == $deleteDAO->id) {
$updateDAO->is_billing = 1;
}
$deleteDAO->delete();
$deleteDAO->free();
}
$updateDAO->update();
$updateDAO->free();
}
}
}
// FIXME: fix gender, prefix and postfix, so they're edible by createProfileContact()
$names['gender'] = array('newName' => 'gender_id', 'groupName' => 'gender');
$names['individual_prefix'] = array('newName' => 'prefix_id', 'groupName' => 'individual_prefix');
$names['individual_suffix'] = array('newName' => 'suffix_id', 'groupName' => 'individual_suffix');
$names['addressee'] = array('newName' => 'addressee_id', 'groupName' => 'addressee');
$names['email_greeting'] = array('newName' => 'email_greeting_id', 'groupName' => 'email_greeting');
//.........这里部分代码省略.........
示例4: moveAllBelongings
/**
* Based on the provided two contact_ids and a set of tables, move the belongings of the
* other contact to the main one - be it Location / CustomFields or Contact .. related info.
* A superset of moveContactBelongings() function.
*
* @param int $mainId main contact with whom merge has to happen
* @param int $otherId duplicate contact which would be deleted after merge operation
*
* @static void
* @access public
*/
function moveAllBelongings($mainId, $otherId, $migrationInfo)
{
if (empty($migrationInfo)) {
return FALSE;
}
$qfZeroBug = 'e8cddb72-a257-11dc-b9cc-0016d3330ee9';
$relTables = CRM_Dedupe_Merger::relTables();
$moveTables = $locBlocks = $tableOperations = array();
foreach ($migrationInfo as $key => $value) {
if ($value == $qfZeroBug) {
$value = '0';
}
if ((in_array(substr($key, 5), CRM_Dedupe_Merger::$validFields) or substr($key, 0, 12) == 'move_custom_') and $value != NULL) {
$submitted[substr($key, 5)] = $value;
} elseif (substr($key, 0, 14) == 'move_location_' and $value != NULL) {
$locField = explode('_', $key);
$fieldName = $locField[2];
$fieldCount = $locField[3];
$operation = CRM_Utils_Array::value('operation', $migrationInfo['location'][$fieldName][$fieldCount]);
// default operation is overwrite.
if (!$operation) {
$operation = 2;
}
$locBlocks[$fieldName][$fieldCount]['operation'] = $operation;
$locBlocks[$fieldName][$fieldCount]['locTypeId'] = CRM_Utils_Array::value('locTypeId', $migrationInfo['location'][$fieldName][$fieldCount]);
} elseif (substr($key, 0, 15) == 'move_rel_table_' and $value == '1') {
$moveTables = array_merge($moveTables, $relTables[substr($key, 5)]['tables']);
if (array_key_exists('operation', $migrationInfo)) {
foreach ($relTables[substr($key, 5)]['tables'] as $table) {
if (array_key_exists($key, $migrationInfo['operation'])) {
$tableOperations[$table] = $migrationInfo['operation'][$key];
}
}
}
}
}
// **** Do location related migration:
if (!empty($locBlocks)) {
$locComponent = array('email' => 'Email', 'phone' => 'Phone', 'im' => 'IM', 'openid' => 'OpenID', 'address' => 'Address');
$primaryBlockIds = CRM_Contact_BAO_Contact::getLocBlockIds($mainId, array('is_primary' => 1));
$billingBlockIds = CRM_Contact_BAO_Contact::getLocBlockIds($mainId, array('is_billing' => 1));
foreach ($locBlocks as $name => $block) {
if (!is_array($block) || CRM_Utils_System::isNull($block)) {
continue;
}
$daoName = $locComponent[$name];
$primaryDAOId = array_key_exists($name, $primaryBlockIds) ? array_pop($primaryBlockIds[$name]) : NULL;
$billingDAOId = array_key_exists($name, $billingBlockIds) ? array_pop($billingBlockIds[$name]) : NULL;
foreach ($block as $blkCount => $values) {
$locTypeId = CRM_Utils_Array::value('locTypeId', $values, 1);
$operation = CRM_Utils_Array::value('operation', $values, 2);
$otherBlockId = CRM_Utils_Array::value($blkCount, $migrationInfo['other_details']['loc_block_ids'][$name]);
// keep 1-1 mapping for address - loc type.
$idKey = $blkCount;
if (array_key_exists($name, $locComponent)) {
$idKey = $locTypeId;
}
if (isset($migrationInfo['main_details']['loc_block_ids'][$name])) {
$mainBlockId = CRM_Utils_Array::value($idKey, $migrationInfo['main_details']['loc_block_ids'][$name]);
}
if (!$otherBlockId) {
continue;
}
// for the block which belongs to other-contact, link the contact to main-contact
eval("\$otherBlockDAO = new CRM_Core_DAO_{$daoName}();");
$otherBlockDAO->id = $otherBlockId;
$otherBlockDAO->contact_id = $mainId;
$otherBlockDAO->location_type_id = $locTypeId;
// if main contact already has primary & billing, set the falgs to 0.
if ($primaryDAOId) {
$otherBlockDAO->is_primary = 0;
}
if ($billingDAOId) {
$otherBlockDAO->is_billing = 0;
}
// overwrite - need to delete block which belongs to main-contact.
if ($mainBlockId && $operation == 2) {
eval("\$deleteDAO = new CRM_Core_DAO_{$daoName}();");
$deleteDAO->id = $mainBlockId;
$deleteDAO->find(TRUE);
// if we about to delete a primary / billing block, set the flags for new block
// that we going to assign to main-contact
if ($primaryDAOId && $primaryDAOId == $deleteDAO->id) {
$otherBlockDAO->is_primary = 1;
}
if ($billingDAOId && $billingDAOId == $deleteDAO->id) {
$otherBlockDAO->is_billing = 1;
}
$deleteDAO->delete();
//.........这里部分代码省略.........