當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CRM_Activity_DAO_Activity::save方法代碼示例

本文整理匯總了PHP中CRM_Activity_DAO_Activity::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Activity_DAO_Activity::save方法的具體用法?PHP CRM_Activity_DAO_Activity::save怎麽用?PHP CRM_Activity_DAO_Activity::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CRM_Activity_DAO_Activity的用法示例。


在下文中一共展示了CRM_Activity_DAO_Activity::save方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testActivityGeneration

 /**
  * Testing Activity Generation through Entity Recursion.
  */
 public function testActivityGeneration()
 {
     //Activity set initial params
     $daoActivity = new CRM_Activity_DAO_Activity();
     $daoActivity->activity_type_id = 1;
     $daoActivity->subject = "Initial Activity";
     $daoActivity->activity_date_time = '20141002103000';
     $daoActivity->save();
     $recursion = new CRM_Core_BAO_RecurringEntity();
     $recursion->entity_id = $daoActivity->id;
     $recursion->entity_table = 'civicrm_activity';
     $recursion->dateColumns = array('activity_date_time');
     $recursion->schedule = array('entity_value' => $daoActivity->id, 'start_action_date' => $daoActivity->activity_date_time, 'entity_status' => 'fourth saturday', 'repetition_frequency_unit' => 'month', 'repetition_frequency_interval' => 3, 'start_action_offset' => 5, 'used_for' => 'activity');
     $generatedEntities = $recursion->generate();
     $this->assertEquals(5, count($generatedEntities['civicrm_activity']), "Cehck if number of iterations are 5");
     $expectedDates = array('20141025103000', '20141227103000', '20150328103000', '20150627103000', '20150926103000');
     foreach ($generatedEntities['civicrm_activity'] as $entityID) {
         $this->assertDBNotNull('CRM_Activity_DAO_Activity', $entityID, 'id', 'id', 'Check DB if repeating activities were created');
     }
     // set mode to ALL, i.e any change to changing activity affects all related recurring activities
     $recursion->mode(3);
     // lets change subject of initial activity that we created in beginning
     $daoActivity->find(TRUE);
     $daoActivity->subject = 'Changed Activity';
     $daoActivity->save();
     // check if other activities were affected
     $actualDates = array();
     foreach ($generatedEntities['civicrm_activity'] as $entityID) {
         $this->assertDBCompareValue('CRM_Activity_DAO_Activity', $entityID, 'subject', 'id', 'Changed Activity', 'Check if subject was updated');
         $actualDates[] = date('YmdHis', strtotime(CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $entityID, 'activity_date_time', 'id')));
     }
     $resultDates = array_diff($actualDates, $expectedDates);
     $this->assertEquals(0, count($resultDates), "Check if all the value in expected array matches actual array");
 }
開發者ID:rajeshrhino,項目名稱:civicrm-core,代碼行數:37,代碼來源:RecurringEntityTest.php

示例2: _convertToCaseActivity

 /**
  * @param array $params
  *
  * @return array
  */
 public static function _convertToCaseActivity($params)
 {
     if (!$params['activityID'] || !$params['caseID']) {
         return array('error_msg' => 'required params missing.');
     }
     $otherActivity = new CRM_Activity_DAO_Activity();
     $otherActivity->id = $params['activityID'];
     if (!$otherActivity->find(TRUE)) {
         return array('error_msg' => 'activity record is missing.');
     }
     $actDateTime = CRM_Utils_Date::isoToMysql($otherActivity->activity_date_time);
     // Create new activity record.
     $mainActivity = new CRM_Activity_DAO_Activity();
     $mainActVals = array();
     CRM_Core_DAO::storeValues($otherActivity, $mainActVals);
     // Get new activity subject.
     if (!empty($params['newSubject'])) {
         $mainActVals['subject'] = $params['newSubject'];
     }
     $mainActivity->copyValues($mainActVals);
     $mainActivity->id = NULL;
     $mainActivity->activity_date_time = $actDateTime;
     // Make sure this is current revision.
     $mainActivity->is_current_revision = TRUE;
     // Drop all relations.
     $mainActivity->parent_id = $mainActivity->original_id = NULL;
     $mainActivity->save();
     $mainActivityId = $mainActivity->id;
     CRM_Activity_BAO_Activity::logActivityAction($mainActivity);
     $mainActivity->free();
     // Mark previous activity as deleted. If it was a non-case activity
     // then just change the subject.
     if (in_array($params['mode'], array('move', 'file'))) {
         $caseActivity = new CRM_Case_DAO_CaseActivity();
         $caseActivity->case_id = $params['caseID'];
         $caseActivity->activity_id = $otherActivity->id;
         if ($params['mode'] == 'move' || $caseActivity->find(TRUE)) {
             $otherActivity->is_deleted = 1;
         } else {
             $otherActivity->subject = ts('(Filed on case %1)', array(1 => $params['caseID'])) . ' ' . $otherActivity->subject;
         }
         $otherActivity->activity_date_time = $actDateTime;
         $otherActivity->save();
         $caseActivity->free();
     }
     $otherActivity->free();
     $targetContacts = array();
     if (!empty($params['targetContactIds'])) {
         $targetContacts = array_unique(explode(',', $params['targetContactIds']));
     }
     $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
     $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
     $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
     $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
     $sourceContactID = CRM_Activity_BAO_Activity::getSourceContactID($params['activityID']);
     $src_params = array('activity_id' => $mainActivityId, 'contact_id' => $sourceContactID, 'record_type_id' => $sourceID);
     CRM_Activity_BAO_ActivityContact::create($src_params);
     foreach ($targetContacts as $key => $value) {
         $targ_params = array('activity_id' => $mainActivityId, 'contact_id' => $value, 'record_type_id' => $targetID);
         CRM_Activity_BAO_ActivityContact::create($targ_params);
     }
     // typically this will be empty, since assignees on another case may be completely different
     $assigneeContacts = array();
     if (!empty($params['assigneeContactIds'])) {
         $assigneeContacts = array_unique(explode(',', $params['assigneeContactIds']));
     }
     foreach ($assigneeContacts as $key => $value) {
         $assigneeParams = array('activity_id' => $mainActivityId, 'contact_id' => $value, 'record_type_id' => $assigneeID);
         CRM_Activity_BAO_ActivityContact::create($assigneeParams);
     }
     // Attach newly created activity to case.
     $caseActivity = new CRM_Case_DAO_CaseActivity();
     $caseActivity->case_id = $params['caseID'];
     $caseActivity->activity_id = $mainActivityId;
     $caseActivity->save();
     $error_msg = $caseActivity->_lastError;
     $caseActivity->free();
     $params['mainActivityId'] = $mainActivityId;
     CRM_Activity_BAO_Activity::copyExtendedActivityData($params);
     return array('error_msg' => $error_msg, 'newId' => $mainActivity->id);
 }
開發者ID:nielosz,項目名稱:civicrm-core,代碼行數:86,代碼來源:AJAX.php

示例3: postProcess


//.........這裏部分代碼省略.........
     }
     if (isset($this->_activityId)) {
         // activity which hasn't been modified by a user yet
         if ($this->_defaults['is_auto'] == 1) {
             $params['is_auto'] = 0;
         }
         // always create a revision of an case activity. CRM-4533
         $newActParams = $params;
         // add target contact values in update mode
         if (empty($params['target_contact_id']) && !empty($this->_defaults['target_contact'])) {
             $newActParams['target_contact_id'] = $this->_defaults['target_contact'];
         }
     }
     if (!isset($newActParams)) {
         // add more attachments if needed for old activity
         CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_activity');
         // call begin post process, before the activity is created/updated.
         $this->beginPostProcess($params);
         foreach ($this->_caseId as $key => $val) {
             $params['case_id'] = $val;
             // activity create/update
             $activity = CRM_Activity_BAO_Activity::create($params);
             $vvalue[] = array('case_id' => $val, 'actId' => $activity->id);
             // call end post process, after the activity has been created/updated.
             $this->endPostProcess($params, $activity);
         }
     } else {
         // since the params we need to set are very few, and we don't want rest of the
         // work done by bao create method , lets use dao object to make the changes
         $params = array('id' => $this->_activityId);
         $params['is_current_revision'] = 0;
         $activity = new CRM_Activity_DAO_Activity();
         $activity->copyValues($params);
         $activity->save();
     }
     // create a new version of activity if activity was found to
     // have been modified/created by user
     if (isset($newActParams)) {
         // set proper original_id
         if (!empty($this->_defaults['original_id'])) {
             $newActParams['original_id'] = $this->_defaults['original_id'];
         } else {
             $newActParams['original_id'] = $activity->id;
         }
         //is_current_revision will be set to 1 by default.
         // add attachments if any
         CRM_Core_BAO_File::formatAttachment($newActParams, $newActParams, 'civicrm_activity');
         // call begin post process, before the activity is created/updated.
         $this->beginPostProcess($newActParams);
         foreach ($this->_caseId as $key => $val) {
             $newActParams['case_id'] = $val;
             $activity = CRM_Activity_BAO_Activity::create($newActParams);
             $vvalue[] = array('case_id' => $val, 'actId' => $activity->id);
             // call end post process, after the activity has been created/updated.
             $this->endPostProcess($newActParams, $activity);
         }
         // copy files attached to old activity if any, to new one,
         // as long as users have not selected the 'delete attachment' option.
         if (empty($newActParams['is_delete_attachment'])) {
             CRM_Core_BAO_File::copyEntityFile('civicrm_activity', $this->_activityId, 'civicrm_activity', $activity->id);
         }
         // copy back params to original var
         $params = $newActParams;
     }
     foreach ($vvalue as $vkey => $vval) {
         if ($vval['actId']) {
開發者ID:rajeshrhino,項目名稱:civicrm-core,代碼行數:67,代碼來源:Activity.php

示例4: endPostProcess

 /**
  * Process the form submission.
  *
  *
  * @param CRM_Core_Form $form
  * @param array $params
  * @param $activity
  */
 public static function endPostProcess(&$form, &$params, $activity)
 {
     if (!empty($params['start_date'])) {
         $params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], $params['start_date_time']);
     }
     $caseType = CRM_Utils_Array::first($form->_caseType);
     $caseId = CRM_Utils_Array::first($form->_caseId);
     if (!$caseType && $caseId) {
         $caseType = CRM_Case_BAO_Case::getCaseType($caseId, 'title');
     }
     if (!$form->_currentlyViewedContactId || !$form->_currentUserId || !$caseId || !$caseType) {
         CRM_Core_Error::fatal('Required parameter missing for ChangeCaseType - end post processing');
     }
     $config = CRM_Core_Config::singleton();
     $params['status_id'] = CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name');
     $activity->status_id = $params['status_id'];
     $params['priority_id'] = CRM_Core_OptionGroup::getValue('priority', 'Normal', 'name');
     $activity->priority_id = $params['priority_id'];
     // 1. save activity subject with new start date
     $currentStartDate = CRM_Utils_Date::customFormat(CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $caseId, 'start_date'), $config->dateformatFull);
     $newStartDate = CRM_Utils_Date::customFormat(CRM_Utils_Date::mysqlToIso($params['start_date']), $config->dateformatFull);
     $subject = 'Change Case Start Date from ' . $currentStartDate . ' to ' . $newStartDate;
     $activity->subject = $subject;
     $activity->save();
     // 2. initiate xml processor
     $xmlProcessor = new CRM_Case_XMLProcessor_Process();
     $xmlProcessorParams = array('clientID' => $form->_currentlyViewedContactId, 'creatorID' => $form->_currentUserId, 'standardTimeline' => 0, 'activity_date_time' => $params['start_date'], 'caseID' => $caseId, 'caseType' => $caseType, 'activityTypeName' => 'Change Case Start Date', 'activitySetName' => 'standard_timeline', 'resetTimeline' => 1);
     $xmlProcessor->run($caseType, $xmlProcessorParams);
     // 2.5 Update open case activity date
     // Multiple steps since revisioned
     if ($form->openCaseActivityId) {
         $abao = new CRM_Activity_BAO_Activity();
         $oldParams = array('id' => $form->openCaseActivityId);
         $oldActivityDefaults = array();
         $oldActivity = $abao->retrieve($oldParams, $oldActivityDefaults);
         // save the old values
         require_once 'api/v3/utils.php';
         $openCaseParams = array();
         //@todo calling api functions directly is not supported
         _civicrm_api3_object_to_array($oldActivity, $openCaseParams);
         // update existing revision
         $oldParams = array('id' => $form->openCaseActivityId, 'is_current_revision' => 0);
         $oldActivity = new CRM_Activity_DAO_Activity();
         $oldActivity->copyValues($oldParams);
         $oldActivity->save();
         // change some params for the new one
         unset($openCaseParams['id']);
         $openCaseParams['activity_date_time'] = $params['start_date'];
         $openCaseParams['target_contact_id'] = $oldActivityDefaults['target_contact'];
         $openCaseParams['assignee_contact_id'] = $oldActivityDefaults['assignee_contact'];
         $session = CRM_Core_Session::singleton();
         $openCaseParams['source_contact_id'] = $session->get('userID');
         // original_id always refers to the first activity, so only update if null (i.e. this is the second revision)
         $openCaseParams['original_id'] = $openCaseParams['original_id'] ? $openCaseParams['original_id'] : $form->openCaseActivityId;
         $newActivity = CRM_Activity_BAO_Activity::create($openCaseParams);
         if (is_a($newActivity, 'CRM_Core_Error')) {
             CRM_Core_Error::fatal('Unable to update Open Case activity');
         } else {
             // Create linkage to case
             $caseActivityParams = array('activity_id' => $newActivity->id, 'case_id' => $caseId);
             CRM_Case_BAO_Case::processCaseActivity($caseActivityParams);
             $caseActivityParams = array('activityID' => $form->openCaseActivityId, 'mainActivityId' => $newActivity->id);
             CRM_Activity_BAO_Activity::copyExtendedActivityData($caseActivityParams);
         }
     }
     // 3.status msg
     $params['statusMsg'] = ts('Case Start Date changed successfully.');
 }
開發者ID:FundingWorks,項目名稱:civicrm-core,代碼行數:76,代碼來源:ChangeCaseStartDate.php

示例5: civicrm_api3_activity_create

/**
 * Creates or updates an Activity.
 *
 * @param array $params
 *   Array per getfields documentation.
 *
 * @throws API_Exception
 * @return array
 *   API result array
 */
function civicrm_api3_activity_create($params)
{
    if (empty($params['id'])) {
        // an update does not require any mandatory parameters
        civicrm_api3_verify_one_mandatory($params, NULL, array('activity_name', 'activity_type_id', 'activity_label'));
    }
    // check for various error and required conditions
    // note that almost all the processing in there should be managed by the wrapper layer
    // & should be removed - needs testing
    $errors = _civicrm_api3_activity_check_params($params);
    // this should not be required as should throw exception rather than return errors -
    //needs testing
    if (!empty($errors)) {
        return $errors;
    }
    // processing for custom data
    $values = $activityArray = array();
    _civicrm_api3_custom_format_params($params, $values, 'Activity');
    if (!empty($values['custom'])) {
        $params['custom'] = $values['custom'];
    }
    // this should be set as a default rather than hard coded
    // needs testing
    $params['skipRecentView'] = TRUE;
    // If this is a case activity, see if there is an existing activity
    // and set it as an old revision. Also retrieve details we'll need.
    // this handling should all be moved to the BAO layer
    $case_id = '';
    $createRevision = FALSE;
    $oldActivityValues = array();
    // Lookup case id if not supplied
    if (!isset($params['case_id']) && !empty($params['id'])) {
        $params['case_id'] = CRM_Core_DAO::singleValueQuery("SELECT case_id FROM civicrm_case_activity WHERE activity_id = " . (int) $params['id']);
    }
    if (!empty($params['case_id'])) {
        $case_id = $params['case_id'];
        if (!empty($params['id'])) {
            $oldActivityParams = array('id' => $params['id']);
            if (!$oldActivityValues) {
                CRM_Activity_BAO_Activity::retrieve($oldActivityParams, $oldActivityValues);
            }
            if (empty($oldActivityValues)) {
                throw new API_Exception(ts("Unable to locate existing activity."));
            } else {
                $activityDAO = new CRM_Activity_DAO_Activity();
                $activityDAO->id = $params['id'];
                $activityDAO->is_current_revision = 0;
                if (!$activityDAO->save()) {
                    if (is_object($activityDAO)) {
                        $activityDAO->free();
                    }
                    throw new API_Exception(ts("Unable to revision existing case activity."));
                }
                $createRevision = TRUE;
            }
        }
    }
    $deleteActivityAssignment = FALSE;
    if (isset($params['assignee_contact_id'])) {
        $deleteActivityAssignment = TRUE;
    }
    $deleteActivityTarget = FALSE;
    if (isset($params['target_contact_id'])) {
        $deleteActivityTarget = TRUE;
    }
    // this should all be handled at the BAO layer
    $params['deleteActivityAssignment'] = CRM_Utils_Array::value('deleteActivityAssignment', $params, $deleteActivityAssignment);
    $params['deleteActivityTarget'] = CRM_Utils_Array::value('deleteActivityTarget', $params, $deleteActivityTarget);
    if ($case_id && $createRevision) {
        // This is very similar to the copy-to-case action.
        if (!CRM_Utils_Array::crmIsEmptyArray($oldActivityValues['target_contact'])) {
            $oldActivityValues['targetContactIds'] = implode(',', array_unique($oldActivityValues['target_contact']));
        }
        if (!CRM_Utils_Array::crmIsEmptyArray($oldActivityValues['assignee_contact'])) {
            $oldActivityValues['assigneeContactIds'] = implode(',', array_unique($oldActivityValues['assignee_contact']));
        }
        $oldActivityValues['mode'] = 'copy';
        $oldActivityValues['caseID'] = $case_id;
        $oldActivityValues['activityID'] = $oldActivityValues['id'];
        $oldActivityValues['contactID'] = $oldActivityValues['source_contact_id'];
        $copyToCase = CRM_Activity_Page_AJAX::_convertToCaseActivity($oldActivityValues);
        if (empty($copyToCase['error_msg'])) {
            // now fix some things that are different from copy-to-case
            // then fall through to the create below to update with the passed in params
            $params['id'] = $copyToCase['newId'];
            $params['is_auto'] = 0;
            $params['original_id'] = empty($oldActivityValues['original_id']) ? $oldActivityValues['id'] : $oldActivityValues['original_id'];
        } else {
            throw new API_Exception(ts("Unable to create new revision of case activity."));
        }
//.........這裏部分代碼省略.........
開發者ID:hyebahi,項目名稱:civicrm-core,代碼行數:101,代碼來源:Activity.php

示例6: callback

 function callback()
 {
     $apiMsgID = $this->retrieve('apiMsgId', 'String');
     $activity = new CRM_Activity_DAO_Activity();
     $activity->result = $apiMsgID;
     if ($activity->find(TRUE)) {
         $actStatusIDs = array_flip(CRM_Core_OptionGroup::values('activity_status'));
         $status = $this->retrieve('status', 'String');
         switch ($status) {
             case "001":
                 $statusID = $actStatusIDs['Cancelled'];
                 $clickStat = $this->_messageStatus[$status] . " - Message Unknown";
                 break;
             case "002":
                 $statusID = $actStatusIDs['Scheduled'];
                 $clickStat = $this->_messageStatus[$status] . " - Message Queued";
                 break;
             case "003":
                 $statusID = $actStatusIDs['Completed'];
                 $clickStat = $this->_messageStatus[$status] . " - Delivered to Gateway";
                 break;
             case "004":
                 $statusID = $actStatusIDs['Completed'];
                 $clickStat = $this->_messageStatus[$status] . " - Received by Recipient";
                 break;
             case "005":
                 $statusID = $actStatusIDs['Cancelled'];
                 $clickStat = $this->_messageStatus[$status] . " - Error with Message";
                 break;
             case "006":
                 $statusID = $actStatusIDs['Cancelled'];
                 $clickStat = $this->_messageStatus[$status] . " - User cancelled message";
                 break;
             case "007":
                 $statusID = $actStatusIDs['Cancelled'];
                 $clickStat = $this->_messageStatus[$status] . " - Error delivering message";
                 break;
             case "008":
                 $statusID = $actStatusIDs['Completed'];
                 $clickStat = $this->_messageStatus[$status] . " - Ok, Message Received by Gateway";
                 break;
             case "009":
                 $statusID = $actStatusIDs['Cancelled'];
                 $clickStat = $this->_messageStatus[$status] . " - Routing Error";
                 break;
             case "010":
                 $statusID = $actStatusIDs['Cancelled'];
                 $clickStat = $this->_messageStatus[$status] . " - Message Expired";
                 break;
             case "011":
                 $statusID = $actStatusIDs['Scheduled'];
                 $clickStat = $this->_messageStatus[$status] . " - Message Queued for Later";
                 break;
             case "012":
                 $statusID = $actStatusIDs['Cancelled'];
                 $clickStat = $this->_messageStatus[$status] . " - Out of Credit";
                 break;
         }
         if ($statusID) {
             // update activity with status + msg in location
             $activity->status_id = $statusID;
             $activity->location = $clickStat;
             $activity->activity_date_time = CRM_Utils_Date::isoToMysql($activity->activity_date_time);
             $activity->save();
             CRM_Core_Error::debug_log_message("SMS Response updated for apiMsgId={$apiMsgID}.");
             return TRUE;
         }
     }
     // if no update is done
     CRM_Core_Error::debug_log_message("Could not update SMS Response for apiMsgId={$apiMsgID}.");
     return FALSE;
 }
開發者ID:peteainsworth,項目名稱:civicrm-4.2.9-drupal,代碼行數:72,代碼來源:Clickatell.php

示例7: 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;
 }
開發者ID:hampelm,項目名稱:Ginsberg-CiviDemo,代碼行數:48,代碼來源:Interview.php

示例8: endPostProcess

 /**
  * Function to process the form
  *
  * @access public
  * @return None
  */
 public function endPostProcess(&$form, &$params, $activity)
 {
     if (CRM_Utils_Array::value('start_date', $params)) {
         $params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], $params['start_date_time']);
     }
     $caseType = $form->_caseType;
     if (!$caseType && $form->_caseId) {
         $query = "\nSELECT  cov_type.label as case_type FROM civicrm_case \nLEFT JOIN  civicrm_option_group cog_type ON cog_type.name = 'case_type'\nLEFT JOIN civicrm_option_value cov_type ON \n( civicrm_case.case_type_id = cov_type.value AND cog_type.id = cov_type.option_group_id ) \nWHERE civicrm_case.id=  %1";
         $queryParams = array(1 => array($form->_caseId, 'Integer'));
         $caseType = CRM_Core_DAO::singleValueQuery($query, $queryParams);
     }
     if (!$form->_currentlyViewedContactId || !$form->_currentUserId || !$form->_caseId || !$caseType) {
         CRM_Core_Error::fatal('Required parameter missing for ChangeCaseType - end post processing');
     }
     $config =& CRM_Core_Config::singleton();
     // 1. save activity subject with new start date
     $currentStartDate = CRM_Utils_Date::customFormat(CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $form->_caseId, 'start_date'), $config->dateformatFull);
     $newStartDate = CRM_Utils_Date::customFormat(CRM_Utils_Date::mysqlToIso($params['start_date']), $config->dateformatFull);
     $subject = 'Change Case Start Date from ' . $currentStartDate . ' to ' . $newStartDate;
     $activity->subject = $subject;
     $activity->save();
     // 2. initiate xml processor
     $xmlProcessor = new CRM_Case_XMLProcessor_Process();
     $xmlProcessorParams = array('clientID' => $form->_currentlyViewedContactId, 'creatorID' => $form->_currentUserId, 'standardTimeline' => 0, 'activity_date_time' => $params['start_date'], 'caseID' => $form->_caseId, 'caseType' => $caseType, 'activityTypeName' => 'Change Case Start Date', 'activitySetName' => 'standard_timeline', 'resetTimeline' => 1);
     $xmlProcessor->run($caseType, $xmlProcessorParams);
     // 2.5 Update open case activity date
     // Multiple steps since revisioned
     if ($form->openCaseActivityId) {
         require_once 'CRM/Activity/BAO/Activity.php';
         $abao = new CRM_Activity_BAO_Activity();
         $oldParams = array('id' => $form->openCaseActivityId);
         $oldActivityDefaults = array();
         $oldActivity = $abao->retrieve($oldParams, $oldActivityDefaults);
         // save the old values
         require_once 'api/v2/utils.php';
         $openCaseParams = array();
         _civicrm_object_to_array($oldActivity, $openCaseParams);
         // update existing revision
         $oldParams = array('id' => $form->openCaseActivityId, 'is_current_revision' => 0);
         require_once 'CRM/Activity/DAO/Activity.php';
         $oldActivity = new CRM_Activity_DAO_Activity();
         $oldActivity->copyValues($oldParams);
         $oldActivity->save();
         // change some params for the new one
         unset($openCaseParams['id']);
         $openCaseParams['activity_date_time'] = $params['start_date'];
         $openCaseParams['target_contact_id'] = $oldActivityDefaults['target_contact'];
         $openCaseParams['assignee_contact_id'] = $oldActivityDefaults['assignee_contact'];
         $session =& CRM_Core_Session::singleton();
         $openCaseParams['source_contact_id'] = $session->get('userID');
         // original_id always refers to the first activity, so only update if null (i.e. this is the second revision)
         $openCaseParams['original_id'] = $openCaseParams['original_id'] ? $openCaseParams['original_id'] : $form->openCaseActivityId;
         $newActivity = CRM_Activity_BAO_Activity::create($openCaseParams);
         if (is_a($newActivity, 'CRM_Core_Error')) {
             CRM_Core_Error::fatal('Unable to update Open Case activity');
         } else {
             // Create linkage to case
             $caseActivityParams = array('activity_id' => $newActivity->id, 'case_id' => $form->_caseId);
             require_once "CRM/Case/BAO/Case.php";
             CRM_Case_BAO_Case::processCaseActivity($caseActivityParams);
         }
     }
     // 3.status msg
     $params['statusMsg'] = ts('Case Start Date changed successfully.');
 }
開發者ID:hampelm,項目名稱:Ginsberg-CiviDemo,代碼行數:71,代碼來源:ChangeCaseStartDate.php

示例9: civicrm_api3_activity_create

/**
 * Creates or updates an Activity. See the example for usage
 *
 * @param array  $params       Associative array of property name/value
 *                             pairs for the activity.
 * {@getfields activity_create}
 *
 * @return array Array containing 'is_error' to denote success or failure and details of the created activity
 *
 * @example ActivityCreate.php Standard create example
 * @example Activity/ContactRefCustomField.php Create example including setting a contact reference custom field
 * {@example ActivityCreate.php 0}
 *
 */
function civicrm_api3_activity_create($params)
{
    if (!CRM_Utils_Array::value('id', $params)) {
        // an update does not require any mandatory parameters
        civicrm_api3_verify_one_mandatory($params, NULL, array('activity_name', 'activity_type_id', 'activity_label'));
    }
    $errors = array();
    // check for various error and required conditions
    $errors = _civicrm_api3_activity_check_params($params);
    if (!empty($errors)) {
        return $errors;
    }
    // processing for custom data
    $values = array();
    _civicrm_api3_custom_format_params($params, $values, 'Activity');
    if (!empty($values['custom'])) {
        $params['custom'] = $values['custom'];
    }
    $params['skipRecentView'] = TRUE;
    // If this is a case activity, see if there is an existing activity
    // and set it as an old revision. Also retrieve details we'll need.
    $case_id = '';
    $createRevision = FALSE;
    $oldActivityValues = array();
    if (CRM_Utils_Array::value('case_id', $params)) {
        $case_id = $params['case_id'];
        if (CRM_Utils_Array::value('id', $params)) {
            $oldActivityParams = array('id' => $params['id']);
            if (!$oldActivityValues) {
                CRM_Activity_BAO_Activity::retrieve($oldActivityParams, $oldActivityValues);
            }
            if (empty($oldActivityValues)) {
                return civicrm_api3_create_error(ts("Unable to locate existing activity."), NULL, CRM_Core_DAO::$_nullObject);
            } else {
                require_once 'CRM/Activity/DAO/Activity.php';
                $activityDAO = new CRM_Activity_DAO_Activity();
                $activityDAO->id = $params['id'];
                $activityDAO->is_current_revision = 0;
                if (!$activityDAO->save()) {
                    return civicrm_api3_create_error(ts("Unable to revision existing case activity."), NULL, $activityDAO);
                }
                $createRevision = TRUE;
            }
        }
    }
    $deleteActivityAssignment = FALSE;
    if (isset($params['assignee_contact_id'])) {
        $deleteActivityAssignment = TRUE;
    }
    $deleteActivityTarget = FALSE;
    if (isset($params['target_contact_id'])) {
        $deleteActivityTarget = TRUE;
    }
    $params['deleteActivityAssignment'] = CRM_Utils_Array::value('deleteActivityAssignment', $params, $deleteActivityAssignment);
    $params['deleteActivityTarget'] = CRM_Utils_Array::value('deleteActivityTarget', $params, $deleteActivityTarget);
    if ($case_id && $createRevision) {
        // This is very similar to the copy-to-case action.
        if (!CRM_Utils_Array::crmIsEmptyArray($oldActivityValues['target_contact'])) {
            $oldActivityValues['targetContactIds'] = implode(',', array_unique($oldActivityValues['target_contact']));
        }
        if (!CRM_Utils_Array::crmIsEmptyArray($oldActivityValues['assignee_contact'])) {
            $oldActivityValues['assigneeContactIds'] = implode(',', array_unique($oldActivityValues['assignee_contact']));
        }
        $oldActivityValues['mode'] = 'copy';
        $oldActivityValues['caseID'] = $case_id;
        $oldActivityValues['activityID'] = $oldActivityValues['id'];
        $oldActivityValues['contactID'] = $oldActivityValues['source_contact_id'];
        require_once 'CRM/Activity/Page/AJAX.php';
        $copyToCase = CRM_Activity_Page_AJAX::_convertToCaseActivity($oldActivityValues);
        if (empty($copyToCase['error_msg'])) {
            // now fix some things that are different from copy-to-case
            // then fall through to the create below to update with the passed in params
            $params['id'] = $copyToCase['newId'];
            $params['is_auto'] = 0;
            $params['original_id'] = empty($oldActivityValues['original_id']) ? $oldActivityValues['id'] : $oldActivityValues['original_id'];
        } else {
            return civicrm_api3_create_error(ts("Unable to create new revision of case activity."), NULL, CRM_Core_DAO::$_nullObject);
        }
    }
    // create activity
    $activityBAO = CRM_Activity_BAO_Activity::create($params);
    if (isset($activityBAO->id)) {
        if ($case_id && !$createRevision) {
            // If this is a brand new case activity we need to add this
            $caseActivityParams = array('activity_id' => $activityBAO->id, 'case_id' => $case_id);
            require_once 'CRM/Case/BAO/Case.php';
//.........這裏部分代碼省略.........
開發者ID:peteainsworth,項目名稱:civicrm-4.2.9-drupal,代碼行數:101,代碼來源:Activity.php

示例10: registerInterview

 /**
  * @param array $params
  *
  * @return mixed
  */
 public 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)) {
         $surveyFields = CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, $surveyTypeId, NULL, FALSE, TRUE);
     }
     static $statusId;
     if (!$statusId) {
         $statusId = array_search('Completed', CRM_Core_PseudoConstant::activityStatus('name'));
     }
     //format custom fields.
     $customParams = CRM_Core_BAO_CustomField::postProcess($params, $activityId, 'Activity');
     CRM_Core_BAO_CustomValueTable::store($customParams, 'civicrm_activity', $activityId);
     //process contact data.
     $contactParams = $fields = array();
     $contactFieldTypes = array_merge(array('Contact'), CRM_Contact_BAO_ContactType::basicTypes());
     $responseFields = CRM_Campaign_BAO_Survey::getSurveyResponseFields($params['survey_id']);
     if (!empty($responseFields)) {
         foreach ($params as $key => $value) {
             if (array_key_exists($key, $responseFields)) {
                 if (in_array($responseFields[$key]['field_type'], $contactFieldTypes)) {
                     $fields[$key] = $responseFields[$key];
                     $contactParams[$key] = $value;
                     if (isset($params["{$key}_id"])) {
                         $contactParams["{$key}_id"] = $params["{$key}_id"];
                     }
                 }
             }
         }
     }
     $contactId = CRM_Utils_Array::value('voter_id', $params);
     if ($contactId && !empty($contactParams)) {
         CRM_Contact_BAO_Contact::createProfileContact($contactParams, $fields, $contactId);
     }
     //update activity record.
     $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 (!empty($params['activity_date_time'])) {
         $activity->activity_date_time = CRM_Utils_Date::processDate($params['activity_date_time'], $params['activity_date_time_time']);
     }
     $subject = '';
     $surveyTitle = CRM_Utils_Array::value('surveyTitle', $params);
     if ($surveyTitle) {
         $subject = $surveyTitle . ' - ';
     }
     $subject .= ts('Respondent Interview');
     $activity->subject = $subject;
     $activityParams = array('details' => 'details', 'result' => 'result', 'engagement_level' => 'activity_engagement_level', 'subject' => 'activity_subject', 'status_id' => 'activity_status_id', 'source_contact_id' => 'source_contact', 'location' => 'activity_location', 'campaign_id' => 'activity_campaign_id', 'duration' => 'activity_duration');
     foreach ($activityParams as $key => $field) {
         if (!empty($params[$field])) {
             $activity->{$key} = $params[$field];
         }
     }
     $activity->save();
     //really this should use Activity BAO& not be here but refactoring will have to be later
     //actually the whole ajax call could be done as an api ajax call & post hook would be sorted
     CRM_Utils_Hook::post('edit', 'Activity', $activity->id, $activity);
     $activity->free();
     return $activityId;
 }
開發者ID:saurabhbatra96,項目名稱:civicrm-core,代碼行數:75,代碼來源:Interview.php

示例11: convertToCaseActivity

 static function convertToCaseActivity()
 {
     $params = array('caseID', 'activityID', 'contactID', 'newSubject', 'targetContactIds', 'mode');
     foreach ($params as $param) {
         ${$param} = CRM_Utils_Array::value($param, $_POST);
     }
     if (!$activityID || !$caseID) {
         echo json_encode(array('error_msg' => 'required params missing.'));
         CRM_Utils_System::civiExit();
     }
     require_once "CRM/Activity/DAO/Activity.php";
     $otherActivity = new CRM_Activity_DAO_Activity();
     $otherActivity->id = $activityID;
     if (!$otherActivity->find(true)) {
         echo json_encode(array('error_msg' => 'activity record is missing.'));
         CRM_Utils_System::civiExit();
     }
     $actDateTime = CRM_Utils_Date::isoToMysql($otherActivity->activity_date_time);
     //create new activity record.
     $mainActivity = new CRM_Activity_DAO_Activity();
     $mainActVals = array();
     CRM_Core_DAO::storeValues($otherActivity, $mainActVals);
     //get new activity subject.
     if (!empty($newSubject)) {
         $mainActVals['subject'] = $newSubject;
     }
     $mainActivity->copyValues($mainActVals);
     $mainActivity->id = null;
     $mainActivity->activity_date_time = $actDateTime;
     //make sure this is current revision.
     $mainActivity->is_current_revision = true;
     //drop all relations.
     $mainActivity->parent_id = $mainActivity->original_id = null;
     $mainActivity->save();
     $mainActivityId = $mainActivity->id;
     require_once 'CRM/Activity/BAO/Activity.php';
     CRM_Activity_BAO_Activity::logActivityAction($mainActivity);
     $mainActivity->free();
     //mark previous activity as deleted.
     if (in_array($mode, array('move', 'file'))) {
         $otherActivity->activity_date_time = $actDateTime;
         $otherActivity->is_deleted = 1;
         $otherActivity->save();
     }
     $otherActivity->free();
     require_once "CRM/Activity/BAO/Activity.php";
     $targetContacts = array();
     if (!empty($targetContactIds)) {
         $targetContacts = array_unique(explode(',', $targetContactIds));
     }
     foreach ($targetContacts as $key => $value) {
         $params = array('activity_id' => $mainActivityId, 'target_contact_id' => $value);
         CRM_Activity_BAO_Activity::createActivityTarget($params);
     }
     //attach newly created activity to case.
     require_once "CRM/Case/DAO/CaseActivity.php";
     $caseActivity = new CRM_Case_DAO_CaseActivity();
     $caseActivity->case_id = $caseID;
     $caseActivity->activity_id = $mainActivityId;
     $caseActivity->save();
     $error_msg = $caseActivity->_lastError;
     $caseActivity->free();
     echo json_encode(array('error_msg' => $error_msg));
     CRM_Utils_System::civiExit();
 }
開發者ID:hampelm,項目名稱:Ginsberg-CiviDemo,代碼行數:65,代碼來源:AJAX.php

示例12: createConference

 static function createConference($adminID, $teacherID, $activityTypeID, $activityDateTime, $subject, $location, $statusID, $duration = 30)
 {
     require_once 'CRM/Activity/DAO/Activity.php';
     $activity = new CRM_Activity_DAO_Activity();
     $activity->source_contact_id = $adminID;
     $activity->activity_type_id = $activityTypeID;
     $activity->activity_date_time = $activityDateTime;
     $activity->status_id = $statusID;
     $activity->subject = $subject;
     $activity->duration = $duration;
     $activity->location = $location;
     $activity->save();
     require_once 'CRM/Activity/DAO/ActivityAssignment.php';
     $assignment = new CRM_Activity_DAO_ActivityAssignment();
     $assignment->activity_id = $activity->id;
     $assignment->assignee_contact_id = $teacherID;
     $assignment->save();
     return $activity->id;
 }
開發者ID:pzingg,項目名稱:sfschool,代碼行數:19,代碼來源:Conference.php

示例13: postProcess


//.........這裏部分代碼省略.........
         $params['assignee_contact_id'] = $assineeContacts = array();
     }
     if (isset($this->_activityId)) {
         // activity which hasn't been modified by a user yet
         if ($this->_defaults['is_auto'] == 1) {
             $params['is_auto'] = 0;
         }
         // always create a revision of an case activity. CRM-4533
         $newActParams = $params;
         // add target contact values in update mode
         if (empty($params['target_contact_id']) && !empty($this->_defaults['target_contact'])) {
             $newActParams['target_contact_id'] = $this->_defaults['target_contact'];
         }
         // record status for status msg
         $recordStatus = 'updated';
     }
     if (!isset($newActParams)) {
         // add more attachments if needed for old activity
         CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_activity');
         // call begin post process, before the activity is created/updated.
         $this->beginPostProcess($params);
         $params['case_id'] = $this->_caseId;
         // activity create/update
         $activity = CRM_Activity_BAO_Activity::create($params);
         // call end post process, after the activity has been created/updated.
         $this->endPostProcess($params, $activity);
     } else {
         // since the params we need to set are very few, and we don't want rest of the
         // work done by bao create method , lets use dao object to make the changes
         $params = array('id' => $this->_activityId);
         $params['is_current_revision'] = 0;
         $activity = new CRM_Activity_DAO_Activity();
         $activity->copyValues($params);
         $activity->save();
     }
     // create a new version of activity if activity was found to
     // have been modified/created by user
     if (isset($newActParams)) {
         // set proper original_id
         if (CRM_Utils_Array::value('original_id', $this->_defaults)) {
             $newActParams['original_id'] = $this->_defaults['original_id'];
         } else {
             $newActParams['original_id'] = $activity->id;
         }
         //is_current_revision will be set to 1 by default.
         // add attachments if any
         CRM_Core_BAO_File::formatAttachment($newActParams, $newActParams, 'civicrm_activity');
         // call begin post process, before the activity is created/updated.
         $this->beginPostProcess($newActParams);
         $newActParams['case_id'] = $this->_caseId;
         $activity = CRM_Activity_BAO_Activity::create($newActParams);
         // call end post process, after the activity has been created/updated.
         $this->endPostProcess($newActParams, $activity);
         // copy files attached to old activity if any, to new one,
         // as long as users have not selected the 'delete attachment' option.
         if (!CRM_Utils_Array::value('is_delete_attachment', $newActParams)) {
             CRM_Core_BAO_File::copyEntityFile('civicrm_activity', $this->_activityId, 'civicrm_activity', $activity->id);
         }
         // copy back params to original var
         $params = $newActParams;
     }
     if ($activity->id) {
         // add tags if exists
         $tagParams = array();
         if (!empty($params['tag'])) {
             foreach ($params['tag'] as $tag) {
開發者ID:hampelm,項目名稱:Ginsberg-CiviDemo,代碼行數:67,代碼來源:Activity.php

示例14: restoreActivity

 /**
  * Restore the activity.
  *
  * @param array $params
  *
  * @return CRM_Activity_DAO_Activity
  */
 public static function restoreActivity(&$params)
 {
     $activity = new CRM_Activity_DAO_Activity();
     $activity->copyValues($params);
     $activity->is_deleted = 0;
     $result = $activity->save();
     return $result;
 }
開發者ID:saurabhbatra96,項目名稱:civicrm-core,代碼行數:15,代碼來源:Activity.php

示例15: deleteActivity

 /**
  * Function to delete the activity
  * @param array  $params  associated array 
  *
  * @return void
  * @access public
  *
  */
 public function deleteActivity(&$params, $moveToTrash = false)
 {
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     if (!$moveToTrash) {
         if (!isset($params['id'])) {
             if (is_array($params['activity_type_id'])) {
                 $activityTypes = implode(',', $params['activity_type_id']);
             } else {
                 $activityTypes = $params['activity_type_id'];
             }
             $query = "DELETE FROM civicrm_activity WHERE source_record_id = {$params['source_record_id']} AND activity_type_id IN ( {$activityTypes} )";
             $dao = CRM_Core_DAO::executeQuery($query);
         } else {
             $activity = new CRM_Activity_DAO_Activity();
             $activity->copyValues($params);
             $result = $activity->delete();
         }
     } else {
         $activity = new CRM_Activity_DAO_Activity();
         $activity->copyValues($params);
         $activity->is_deleted = 1;
         $result = $activity->save();
         //log activty delete.CRM-4525.
         $logMsg = "Case Activity deleted for";
         $msgs = array();
         $sourceContactId = CRM_Core_DAO::getfieldValue('CRM_Activity_DAO_Activity', $activity->id, 'source_contact_id');
         if ($sourceContactId) {
             $msgs[] = " source={$sourceContactId}";
         }
         //get target contacts.
         $targetContactIds = CRM_Activity_BAO_ActivityTarget::getTargetNames($activity->id);
         if (!empty($targetContactIds)) {
             $msgs[] = " target =" . implode(',', array_keys($targetContactIds));
         }
         //get assignee contacts.
         $assigneeContactIds = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($activity->id);
         if (!empty($assigneeContactIds)) {
             $msgs[] = " assignee =" . implode(',', array_keys($assigneeContactIds));
         }
         $logMsg .= implode(', ', $msgs);
         self::logActivityAction($activity, $logMsg);
     }
     // delete the recently created Activity
     require_once 'CRM/Utils/Recent.php';
     if ($result) {
         $activityRecent = array('id' => $activity->id, 'type' => 'Activity');
         CRM_Utils_Recent::del($activityRecent);
     }
     $transaction->commit();
     return $result;
 }
開發者ID:bhirsch,項目名稱:voipdev,代碼行數:60,代碼來源:Activity.php


注:本文中的CRM_Activity_DAO_Activity::save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。