本文整理匯總了PHP中CRM_Activity_DAO_Activity::free方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Activity_DAO_Activity::free方法的具體用法?PHP CRM_Activity_DAO_Activity::free怎麽用?PHP CRM_Activity_DAO_Activity::free使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CRM_Activity_DAO_Activity
的用法示例。
在下文中一共展示了CRM_Activity_DAO_Activity::free方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: cleanupActivity
/**
* This function delete activity record related to contact record,
* when there are no target and assignee record w/ other contact.
*
* @param int $contactId contactId
*
* @return true/null
* @access public
*/
public function cleanupActivity($contactId)
{
$result = null;
if (!$contactId) {
return $result;
}
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
// delete activity if there are no record in
// civicrm_activity_assignment or civicrm_activity_target
// pointing to any other contact record.
require_once 'CRM/Activity/DAO/ActivityTarget.php';
require_once 'CRM/Activity/DAO/ActivityAssignment.php';
$activity = new CRM_Activity_DAO_Activity();
$activity->source_contact_id = $contactId;
$activity->find();
while ($activity->fetch()) {
$noTarget = $noAssignee = true;
// check for target activity record.
$target = new CRM_Activity_DAO_ActivityTarget();
$target->activity_id = $activity->id;
$target->find();
while ($target->fetch()) {
if ($target->target_contact_id != $contactId) {
$noTarget = false;
break;
}
}
$target->free();
// check for assignee activity record.
$assignee = new CRM_Activity_DAO_ActivityAssignment();
$assignee->activity_id = $activity->id;
$assignee->find();
while ($assignee->fetch()) {
if ($assignee->assignee_contact_id != $contactId) {
$noAssignee = false;
break;
}
}
$assignee->free();
// finally delete activity.
if ($noTarget && $noAssignee) {
$activityParams = array('id' => $activity->id);
$result = self::deleteActivity($activityParams);
}
}
$activity->free();
$transaction->commit();
return $result;
}
示例2: registerInterview
static function registerInterview($params)
{
$activityId = CRM_Utils_Array::value('activity_id', $params);
$surveyTypeId = CRM_Utils_Array::value('activity_type_id', $params);
if (!is_array($params) || !$surveyTypeId || !$activityId) {
return false;
}
static $surveyFields;
if (!is_array($surveyFields)) {
require_once 'CRM/Core/BAO/CustomField.php';
$surveyFields = CRM_Core_BAO_CustomField::getFields('Activity', false, false, $surveyTypeId, null, false, true);
}
static $statusId;
if (!$statusId) {
require_once 'CRM/Core/PseudoConstant.php';
$statusId = array_search('Completed', CRM_Core_PseudoConstant::activityStatus('name'));
}
//format custom fields.
$customParams = CRM_Core_BAO_CustomField::postProcess($params, $surveyFields, $activityId, 'Activity');
require_once 'CRM/Core/BAO/CustomValueTable.php';
CRM_Core_BAO_CustomValueTable::store($customParams, 'civicrm_activity', $activityId);
//update activity record.
require_once 'CRM/Activity/DAO/Activity.php';
$activity = new CRM_Activity_DAO_Activity();
$activity->id = $activityId;
$activity->selectAdd();
$activity->selectAdd('activity_date_time, status_id, result, subject');
$activity->find(true);
$activity->activity_date_time = date('Ymdhis');
$activity->status_id = $statusId;
if (CRM_Utils_Array::value('details', $params)) {
$activity->details = $params['details'];
}
if ($result = CRM_Utils_Array::value('result', $params)) {
$activity->result = $result;
}
$subject = '';
$surveyTitle = CRM_Utils_Array::value('surveyTitle', $params);
if ($surveyTitle) {
$subject = ts('%1', array(1 => $surveyTitle));
$subject .= ' - ';
}
$subject .= ts('Respondent Interview');
$activity->subject = $subject;
$activity->save();
$activity->free();
return $activityId;
}