当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Activity_BAO_Activity::retrieve方法代码示例

本文整理汇总了PHP中CRM_Activity_BAO_Activity::retrieve方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Activity_BAO_Activity::retrieve方法的具体用法?PHP CRM_Activity_BAO_Activity::retrieve怎么用?PHP CRM_Activity_BAO_Activity::retrieve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Activity_BAO_Activity的用法示例。


在下文中一共展示了CRM_Activity_BAO_Activity::retrieve方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postProcess

 /**
  * Process the form after the input has been submitted and validated.
  */
 public function postProcess()
 {
     $formparams = $this->exportValues();
     $caseId = $formparams['unclosed_case_id'];
     $filedActivities = 0;
     foreach ($this->_activityHolderIds as $key => $id) {
         $targetContactValues = $defaults = array();
         $params = array('id' => $id);
         CRM_Activity_BAO_Activity::retrieve($params, $defaults);
         if (CRM_Case_BAO_Case::checkPermission($id, 'File On Case', $defaults['activity_type_id'])) {
             if (!CRM_Utils_Array::crmIsEmptyArray($defaults['target_contact'])) {
                 $targetContactValues = array_combine(array_unique($defaults['target_contact']), explode(';', trim($defaults['target_contact_value'])));
                 $targetContactValues = implode(',', array_keys($targetContactValues));
             }
             $params = array('caseID' => $caseId, 'activityID' => $id, 'newSubject' => empty($defaults['subject']) ? '' : $defaults['subject'], 'targetContactIds' => $targetContactValues, 'mode' => 'file');
             $error_msg = CRM_Activity_Page_AJAX::_convertToCaseActivity($params);
             if (empty($error_msg['error_msg'])) {
                 $filedActivities++;
             } else {
                 CRM_Core_Session::setStatus($error_msg['error_msg'], ts("Error"), "error");
             }
         } else {
             CRM_Core_Session::setStatus(ts('Not permitted to file activity %1 %2.', array(1 => empty($defaults['subject']) ? '' : $defaults['subject'], 2 => $defaults['activity_date_time'])), ts("Error"), "error");
         }
     }
     CRM_Core_Session::setStatus($filedActivities, ts("Filed Activities"), "success");
     CRM_Core_Session::setStatus("", ts('Total Selected Activities: %1', array(1 => count($this->_activityHolderIds))), "info");
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:31,代码来源:FileOnCase.php

示例2: setDefaultValues

 function setDefaultValues()
 {
     if (isset($this->_activityId)) {
         $params = array('id' => $this->_activityId);
         CRM_Activity_BAO_Activity::retrieve($params, $defaults);
         $defaults['html_message'] = $defaults['details'];
         return $defaults;
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:9,代码来源:PDF.php

示例3: setDefaultValues

 /**
  * Set default values for the form.
  */
 public function setDefaultValues()
 {
     $defaults = array();
     if (isset($this->_activityId)) {
         $params = array('id' => $this->_activityId);
         CRM_Activity_BAO_Activity::retrieve($params, $defaults);
         $defaults['html_message'] = CRM_Utils_Array::value('details', $defaults);
     }
     $defaults = $defaults + CRM_Contact_Form_Task_PDFLetterCommon::setDefaultValues();
     return $defaults;
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:14,代码来源:PDF.php

示例4: setDefaultValues

 /**
  * This function sets the default values for the form. For edit/view mode
  * the default values are retrieved from the database
  *
  * @access public
  *
  * @return None
  */
 function setDefaultValues()
 {
     $targetContactValues = $defaults = array();
     $params = array('id' => $this->_activityId);
     CRM_Activity_BAO_Activity::retrieve($params, $defaults);
     $defaults['case_activity_subject'] = $defaults['subject'];
     if (!CRM_Utils_Array::crmIsEmptyArray($defaults['target_contact'])) {
         $targetContactValues = array_combine(array_unique($defaults['target_contact']), explode(';', trim($defaults['target_contact_value'])));
     }
     $this->assign('targetContactValues', empty($targetContactValues) ? FALSE : $targetContactValues);
     return $defaults;
 }
开发者ID:hguru,项目名称:224Civi,代码行数:20,代码来源:ActivityToCase.php

示例5: setDefaultValues

 function setDefaultValues()
 {
     $defaults = array();
     if (isset($this->_activityId)) {
         $params = array('id' => $this->_activityId);
         CRM_Activity_BAO_Activity::retrieve($params, $defaults);
         $defaults['html_message'] = $defaults['details'];
     } else {
         $defaults['thankyou_update'] = 1;
     }
     $defaults = $defaults + CRM_Contact_Form_Task_PDFLetterCommon::setDefaultValues();
     return $defaults;
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:13,代码来源:PDFLetter.php

示例6: preProcess

 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     //get the activity values
     $activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     //check for required permissions, CRM-6264
     if ($activityId && !CRM_Activity_BAO_Activity::checkPermission($activityId, CRM_Core_Action::VIEW)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     $session = CRM_Core_Session::singleton();
     if (!in_array($context, array('home', 'dashlet', 'dashletFullscreen'))) {
         $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity");
     } else {
         $url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
     }
     $session->pushUserContext($url);
     $defaults = array();
     $params = array('id' => $activityId);
     CRM_Activity_BAO_Activity::retrieve($params, $defaults);
     //set activity type name and description to template
     list($activityTypeName, $activityTypeDescription) = CRM_Core_BAO_OptionValue::getActivityTypeDetails($defaults['activity_type_id']);
     $this->assign('activityTypeName', $activityTypeName);
     $this->assign('activityTypeDescription', $activityTypeDescription);
     if (CRM_Utils_Array::value('mailingId', $defaults)) {
         $this->_mailing_id = CRM_Utils_Array::value('source_record_id', $defaults);
         $mailingReport = CRM_Mailing_BAO_Mailing::report($this->_mailing_id, TRUE);
         CRM_Mailing_BAO_Mailing::getMailingContent($mailingReport, $this);
         $this->assign('mailingReport', $mailingReport);
         $full_open_report = CRM_Mailing_Event_BAO_Opened::getRows($this->_mailing_id, NULL, FALSE, NULL, NULL, NULL, $cid);
         $this->assign('openreport', $full_open_report);
         $click_thru_report = CRM_Mailing_Event_BAO_TrackableURLOpen::getRows($this->_mailing_id, NULL, FALSE, NULL, NULL, NULL, NULL, $cid);
         $this->assign('clickreport', $click_thru_report);
     }
     foreach ($defaults as $key => $value) {
         if (substr($key, -3) != '_id') {
             $values[$key] = $value;
         }
     }
     //get the campaign
     if ($campaignId = CRM_Utils_Array::value('campaign_id', $defaults)) {
         $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
         $values['campaign'] = $campaigns[$campaignId];
     }
     if ($engagementLevel = CRM_Utils_Array::value('engagement_level', $defaults)) {
         $engagementLevels = CRM_Campaign_PseudoConstant::engagementLevel();
         $values['engagement_level'] = CRM_Utils_Array::value($engagementLevel, $engagementLevels, $engagementLevel);
     }
     $values['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_activity', $activityId);
     $this->assign('values', $values);
 }
开发者ID:hguru,项目名称:224Civi,代码行数:57,代码来源:ActivityView.php

示例7: setDefaultValues

 function setDefaultValues()
 {
     $defaults = array();
     if ($this->_id) {
         $params = array('id' => $this->_id);
         CRM_Activity_BAO_Activity::retrieve($params, $defaults);
         if (!CRM_Utils_Array::value('activity_date_time', $defaults)) {
             list($defaults['activity_date_time'], $defaults['activity_date_time_time']) = CRM_Utils_Date::setDateDefaults(NULL, 'activityDateTime');
         }
         list($defaults['activity_date_time'], $defaults['activity_date_time_time']) = CRM_Utils_Date::setDateDefaults($defaults['activity_date_time'], 'activityDateTime');
         $status = CRM_Core_PseudoConstant::activityStatus();
         $defaults['status_id'] = $defaults['status_id'] == array_search('Scheduled', $status) ? 1 : 0;
     } else {
         $defaults['status_id'] = 1;
     }
     return $defaults;
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:17,代码来源:PublicHolidays.php

示例8: setDefaultValues

 /**
  * Set default values for the form. For edit/view mode
  * the default values are retrieved from the database
  *
  *
  * @return array
  */
 public function setDefaultValues()
 {
     $defaults = array();
     $params = array('id' => $this->_activityId);
     CRM_Activity_BAO_Activity::retrieve($params, $defaults);
     $defaults['file_on_case_activity_subject'] = $defaults['subject'];
     $defaults['file_on_case_target_contact_id'] = $defaults['target_contact'];
     // If this contact has an open case, supply it as a default
     $cid = CRM_Utils_Request::retrieve('cid', 'Integer');
     if ($cid) {
         $cases = civicrm_api3('CaseContact', 'get', array('contact_id' => $cid, 'case_id' => array('!=' => $this->_currentCaseId), 'case_id.status_id' => array('!=' => "Closed"), 'case_id.is_deleted' => 0, 'case_id.end_date' => array('IS NULL' => 1), 'options' => array('limit' => 1), 'return' => 'case_id'));
         foreach ($cases['values'] as $record) {
             $defaults['file_on_case_unclosed_case_id'] = $record['case_id'];
             break;
         }
     }
     return $defaults;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:25,代码来源:ActivityToCase.php

示例9: testRetrieve

 /**
  * Test case for retrieve() method.
  *
  * Retrieve($params, $defaults) method return activity detail for given params
  *                              and set defaults.
  */
 public function testRetrieve()
 {
     $contactId = Contact::createIndividual();
     $params = array('first_name' => 'liz', 'last_name' => 'hurleey');
     $targetContactId = Contact::createIndividual($params);
     $params = array('source_contact_id' => $contactId, 'subject' => 'Scheduling Meeting', 'activity_type_id' => 2, 'target_contact_id' => array($targetContactId), 'activity_date_time' => date('Ymd'));
     CRM_Activity_BAO_Activity::create($params);
     $activityId = $this->assertDBNotNull('CRM_Activity_DAO_Activity', 'Scheduling Meeting', 'id', 'subject', 'Database check for created activity.');
     $activityTargetId = $this->assertDBNotNull('CRM_Activity_DAO_ActivityContact', $targetContactId, 'id', 'contact_id', 'Database check for created activity target.');
     $defaults = array();
     $activity = CRM_Activity_BAO_Activity::retrieve($params, $defaults);
     $this->assertEquals($activity->subject, 'Scheduling Meeting', 'Verify activity subject is correct.');
     $this->assertEquals($activity->activity_type_id, 2, 'Verify activity type id is correct.');
     $this->assertEquals($defaults['source_contact_id'], $contactId, 'Verify source contact id is correct.');
     $this->assertEquals($defaults['subject'], 'Scheduling Meeting', 'Verify activity subject is correct.');
     $this->assertEquals($defaults['activity_type_id'], 2, 'Verify activity type id is correct.');
     $this->assertEquals($defaults['target_contact'][0], $targetContactId, 'Verify target contact id is correct.');
     Contact::delete($contactId);
     Contact::delete($targetContactId);
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:26,代码来源:ActivityTest.php

示例10: setDefaultValues

 /**
  * Set default values for the form. For edit/view mode
  * the default values are retrieved from the database
  *
  *
  * @return array
  */
 public function setDefaultValues()
 {
     $defaults = array();
     $params = array('id' => $this->_activityId);
     CRM_Activity_BAO_Activity::retrieve($params, $defaults);
     $defaults['file_on_case_activity_subject'] = $defaults['subject'];
     $defaults['file_on_case_target_contact_id'] = $defaults['target_contact'];
     // If this contact has an open case, supply it as a default
     $cid = CRM_Utils_Request::retrieve('cid', 'Integer');
     if ($cid) {
         $cases = CRM_Case_BAO_Case::getUnclosedCases(array('contact_id' => $cid), $this->_currentCaseId);
         foreach ($cases as $id => $details) {
             $defaults['file_on_case_unclosed_case_id'] = $id;
             $value = array('label' => $details['sort_name'] . ' - ' . $details['case_type'], 'extra' => array('contact_id' => $cid));
             $this->updateElementAttr('file_on_case_unclosed_case_id', array('data-value' => json_encode($value)));
             break;
         }
     }
     return $defaults;
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:27,代码来源:ActivityToCase.php

示例11: preProcess

 /**  
  * Function to set variables up before form is built  
  *                                                            
  * @return void  
  * @access public  
  */
 public function preProcess()
 {
     //get the activity values
     $activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     //check for required permissions, CRM-6264
     if ($activityId && !CRM_Activity_BAO_Activity::checkPermission($activityId, CRM_Core_Action::VIEW)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     $session = CRM_Core_Session::singleton();
     if ($context != 'home') {
         $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity");
     } else {
         $url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
     }
     $session->pushUserContext($url);
     $params = array('id' => $activityId);
     CRM_Activity_BAO_Activity::retrieve($params, $defaults);
     //set activity type name and description to template
     require_once 'CRM/Core/BAO/OptionValue.php';
     list($activityTypeName, $activityTypeDescription) = CRM_Core_BAO_OptionValue::getActivityTypeDetails($defaults['activity_type_id']);
     $this->assign('activityTypeName', $activityTypeName);
     $this->assign('activityTypeDescription', $activityTypeDescription);
     if (CRM_Utils_Array::value('mailingId', $defaults)) {
         $this->_mailing_id = CRM_Utils_Array::value('source_record_id', $defaults);
         require_once 'CRM/Mailing/BAO/Mailing.php';
         $mailingReport =& CRM_Mailing_BAO_Mailing::report($this->_mailing_id, true);
         CRM_Mailing_BAO_Mailing::getMailingContent($mailingReport, $this);
         $this->assign('mailingReport', $mailingReport);
     }
     foreach ($defaults as $key => $value) {
         if (substr($key, -3) != '_id') {
             $values[$key] = $value;
         }
     }
     require_once 'CRM/Core/BAO/File.php';
     $values['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_activity', $activityId);
     $this->assign('values', $values);
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:46,代码来源:ActivityView.php

示例12: 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

示例13: testActivityCreate

 /**
  * Test activity amount updation.
  */
 public function testActivityCreate()
 {
     $contactId = $this->individualCreate();
     $defaults = array();
     $params = array('contact_id' => $contactId, 'currency' => 'USD', 'financial_type_id' => 1, 'contribution_status_id' => 1, 'payment_instrument_id' => 1, 'source' => 'STUDENT', 'receive_date' => '20080522000000', 'receipt_date' => '20080522000000', 'non_deductible_amount' => 0.0, 'total_amount' => 100.0, 'trxn_id' => '22ereerwww444444', 'invoice_id' => '86ed39c9e9ee6ef6031621ce0eafe7eb81', 'thankyou_date' => '20160519');
     $contribution = CRM_Contribute_BAO_Contribution::create($params);
     $this->assertEquals($params['total_amount'], $contribution->total_amount, 'Check for total amount in contribution.');
     $this->assertEquals($contactId, $contribution->contact_id, 'Check for contact id  creation.');
     // Check amount in activity.
     $activityParams = array('source_record_id' => $contribution->id, 'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type', 'Contribution', 'name'));
     $activity = CRM_Activity_BAO_Activity::retrieve($activityParams, $defaults);
     $this->assertEquals($contribution->id, $activity->source_record_id, 'Check for activity associated with contribution.');
     $this->assertEquals("\$ 100.00 - STUDENT", $activity->subject, 'Check for total amount in activity.');
     // Update contribution amount.
     $ids = array('contribution' => $contribution->id);
     $params['total_amount'] = 200;
     $contribution = CRM_Contribute_BAO_Contribution::create($params, $ids);
     $this->assertEquals($params['total_amount'], $contribution->total_amount, 'Check for total amount in contribution.');
     $this->assertEquals($contactId, $contribution->contact_id, 'Check for contact id  creation.');
     // Retrieve activity again.
     $activity = CRM_Activity_BAO_Activity::retrieve($activityParams, $defaults);
     $this->assertEquals($contribution->id, $activity->source_record_id, 'Check for activity associated with contribution.');
     $this->assertEquals("\$ 200.00 - STUDENT", $activity->subject, 'Check for total amount in activity.');
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:27,代码来源:ContributionTest.php

示例14: preProcess

 /**
  * Build the form object.
  */
 public function preProcess()
 {
     CRM_Core_Form_RecurringEntity::preProcess('civicrm_activity');
     $this->_atypefile = CRM_Utils_Array::value('atypefile', $_GET);
     $this->assign('atypefile', FALSE);
     if ($this->_atypefile) {
         $this->assign('atypefile', TRUE);
     }
     $session = CRM_Core_Session::singleton();
     $this->_currentUserId = $session->get('userID');
     $this->_currentlyViewedContactId = $this->get('contactId');
     if (!$this->_currentlyViewedContactId) {
         $this->_currentlyViewedContactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     }
     $this->assign('contactId', $this->_currentlyViewedContactId);
     // Give the context.
     if (!isset($this->_context)) {
         $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
         if (CRM_Contact_Form_Search::isSearchContext($this->_context)) {
             $this->_context = 'search';
         } elseif (!in_array($this->_context, array('dashlet', 'dashletFullscreen')) && $this->_currentlyViewedContactId) {
             $this->_context = 'activity';
         }
         $this->_compContext = CRM_Utils_Request::retrieve('compContext', 'String', $this);
     }
     $this->assign('context', $this->_context);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
     if ($this->_action & CRM_Core_Action::DELETE) {
         if (!CRM_Core_Permission::check('delete activities')) {
             CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
         }
     }
     // CRM-6957
     // When we come from contact search, activity id never comes.
     // So don't try to get from object, it might gives you wrong one.
     // if we're not adding new one, there must be an id to
     // an activity we're trying to work on.
     if ($this->_action != CRM_Core_Action::ADD && get_class($this->controller) != 'CRM_Contact_Controller_Search') {
         $this->_activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     }
     $this->_activityTypeId = CRM_Utils_Request::retrieve('atype', 'Positive', $this);
     $this->assign('atype', $this->_activityTypeId);
     $this->assign('activityId', $this->_activityId);
     // Check for required permissions, CRM-6264.
     if ($this->_activityId && in_array($this->_action, array(CRM_Core_Action::UPDATE, CRM_Core_Action::VIEW)) && !CRM_Activity_BAO_Activity::checkPermission($this->_activityId, $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     if ($this->_action & CRM_Core_Action::VIEW && CRM_Activity_BAO_Activity::checkPermission($this->_activityId, CRM_Core_Action::UPDATE)) {
         $this->assign('permission', 'edit');
     }
     if (!$this->_activityTypeId && $this->_activityId) {
         $this->_activityTypeId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'activity_type_id');
     }
     // Assigning Activity type name.
     if ($this->_activityTypeId) {
         $activityTName = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, 'AND v.value = ' . $this->_activityTypeId, 'label');
         if ($activityTName[$this->_activityTypeId]) {
             $this->_activityTypeName = $activityTName[$this->_activityTypeId];
             $this->assign('activityTName', $activityTName[$this->_activityTypeId]);
         }
     }
     // Set title.
     if (isset($activityTName)) {
         $activityName = CRM_Utils_Array::value($this->_activityTypeId, $activityTName);
         $this->assign('pageTitle', ts('%1 Activity', array(1 => $activityName)));
         if ($this->_currentlyViewedContactId) {
             $displayName = CRM_Contact_BAO_Contact::displayName($this->_currentlyViewedContactId);
             // Check if this is default domain contact CRM-10482.
             if (CRM_Contact_BAO_Contact::checkDomainContact($this->_currentlyViewedContactId)) {
                 $displayName .= ' (' . ts('default organization') . ')';
             }
             CRM_Utils_System::setTitle($displayName . ' - ' . $activityName);
         } else {
             CRM_Utils_System::setTitle(ts('%1 Activity', array(1 => $activityName)));
         }
     }
     // Check the mode when this form is called either single or as
     // search task action.
     if ($this->_activityTypeId || $this->_context == 'standalone' || $this->_currentlyViewedContactId) {
         $this->_single = TRUE;
         $this->assign('urlPath', 'civicrm/activity');
     } else {
         // Set the appropriate action.
         $url = CRM_Utils_System::currentPath();
         $urlArray = explode('/', $url);
         $searchPath = array_pop($urlArray);
         $searchType = 'basic';
         $this->_action = CRM_Core_Action::BASIC;
         switch ($searchPath) {
             case 'basic':
                 $searchType = $searchPath;
                 $this->_action = CRM_Core_Action::BASIC;
                 break;
             case 'advanced':
                 $searchType = $searchPath;
                 $this->_action = CRM_Core_Action::ADVANCED;
                 break;
//.........这里部分代码省略.........
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:101,代码来源:Activity.php

示例15: 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


注:本文中的CRM_Activity_BAO_Activity::retrieve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。