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


PHP CRM_Core_BAO_File::copyEntityFile方法代码示例

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


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

示例1: create

 /**
  * Create a new HRJobDetails based on array-data
  *
  * @param array $params key-value pairs
  * @return CRM_HRJob_DAO_HRJobDetails|NULL
  *
  */
 public static function create($params)
 {
     $hook = empty($params['id']) ? 'create' : 'edit';
     $previousDetailsRevisionId = null;
     if ($hook == 'create') {
         $previousRevisionResult = civicrm_api3('HRJobContractRevision', 'getcurrentrevision', array('sequential' => 1, 'jobcontract_id' => $params['jobcontract_id']));
         if (!empty($previousRevisionResult['values']['details_revision_id'])) {
             $previousDetailsRevisionId = $previousRevisionResult['values']['details_revision_id'];
         }
     }
     $instance = parent::create($params);
     // setting 'effective_date' if it's not set:
     $revision = civicrm_api3('HRJobContractRevision', 'get', array('sequential' => 1, 'jobcontract_id' => $params['jobcontract_id'], 'id' => $instance->jobcontract_revision_id));
     if (!empty($revision['values'][0])) {
         $revisionData = array_shift($revision['values']);
         if (!$revisionData['effective_date']) {
             civicrm_api3('HRJobContractRevision', 'create', array('id' => $revisionData['id'], 'effective_date' => $instance->period_start_date));
         }
     }
     $revisionResult = civicrm_api3('HRJobContractRevision', 'get', array('sequential' => 1, 'id' => $instance->jobcontract_revision_id));
     $revision = CRM_Utils_Array::first($revisionResult['values']);
     $duplicate = CRM_Utils_Array::value('action', $params, $hook);
     if ($hook == 'create' && empty($revision['role_revision_id']) && $duplicate != 'duplicate' && empty($params['import'])) {
         //civicrm_api3('HRJobRole', 'create', array('jobcontract_id' => $revision['jobcontract_id'],'title' => $instance->title, 'location'=> $instance->location, 'percent_pay_role' => 100, 'jobcontract_revision_id' => $instance->jobcontract_revision_id));
         CRM_Hrjobcontract_BAO_HRJobRole::create(array('jobcontract_id' => $revision['jobcontract_id'], 'title' => $instance->title, 'location' => $instance->location, 'percent_pay_role' => 100, 'jobcontract_revision_id' => $instance->jobcontract_revision_id));
     }
     if ($previousDetailsRevisionId) {
         CRM_Core_BAO_File::copyEntityFile('civicrm_hrjobcontract_details', $previousDetailsRevisionId, 'civicrm_hrjobcontract_details', $revision['details_revision_id']);
     }
     $contract = new CRM_Hrjobcontract_DAO_HRJobContract();
     $contract->id = $revision['jobcontract_id'];
     $contract->find(true);
     CRM_Hrjobcontract_JobContractDates::setDates($contract->contact_id, $revision['jobcontract_id'], $instance->period_start_date, $instance->period_end_date);
     return $instance;
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:42,代码来源:HRJobDetails.php

示例2: create

 /**
  * Create a new HRJobPension based on array-data
  *
  * @param array $params key-value pairs
  * @return CRM_HRJob_DAO_HRJobPension|NULL
  * 
  */
 public static function create($params)
 {
     $hook = empty($params['id']) ? 'create' : 'edit';
     $previousPensionRevisionId = null;
     if ($hook == 'create') {
         $previousRevisionResult = civicrm_api3('HRJobContractRevision', 'getcurrentrevision', array('sequential' => 1, 'jobcontract_id' => $params['jobcontract_id']));
         if (!empty($previousRevisionResult['values']['pension_revision_id'])) {
             $previousPensionRevisionId = $previousRevisionResult['values']['pension_revision_id'];
         }
     }
     $instance = parent::create($params);
     $revisionResult = civicrm_api3('HRJobContractRevision', 'get', array('sequential' => 1, 'id' => $instance->jobcontract_revision_id));
     $revision = CRM_Utils_Array::first($revisionResult['values']);
     if ($previousPensionRevisionId) {
         CRM_Core_BAO_File::copyEntityFile('civicrm_hrjobcontract_pension', $previousPensionRevisionId, 'civicrm_hrjobcontract_pension', $revision['pension_revision_id']);
     }
     return $instance;
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:25,代码来源:HRJobPension.php

示例3: copyExtendedActivityData

 /**
  * Copy custom fields and attachments from an existing activity to another.
  *
  * @see CRM_Case_Page_AJAX::_convertToCaseActivity()
  *
  * @param array $params
  */
 public static function copyExtendedActivityData($params)
 {
     // attach custom data to the new activity
     $customParams = $htmlType = array();
     $customValues = CRM_Core_BAO_CustomValueTable::getEntityValues($params['activityID'], 'Activity');
     if (!empty($customValues)) {
         $fieldIds = implode(', ', array_keys($customValues));
         $sql = "SELECT id FROM civicrm_custom_field WHERE html_type = 'File' AND id IN ( {$fieldIds} )";
         $result = CRM_Core_DAO::executeQuery($sql);
         while ($result->fetch()) {
             $htmlType[] = $result->id;
         }
         foreach ($customValues as $key => $value) {
             if ($value !== NULL) {
                 // CRM-10542
                 if (in_array($key, $htmlType)) {
                     $fileValues = CRM_Core_BAO_File::path($value, $params['activityID']);
                     $customParams["custom_{$key}_-1"] = array('name' => $fileValues[0], 'path' => $fileValues[1]);
                 } else {
                     $customParams["custom_{$key}_-1"] = $value;
                 }
             }
         }
         CRM_Core_BAO_CustomValueTable::postProcess($customParams, 'civicrm_activity', $params['mainActivityId'], 'Activity');
     }
     // copy activity attachments ( if any )
     CRM_Core_BAO_File::copyEntityFile('civicrm_activity', $params['activityID'], 'civicrm_activity', $params['mainActivityId']);
 }
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:35,代码来源:Activity.php

示例4: postProcess


//.........这里部分代码省略.........
     } 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']) {
             // add tags if exists
             $tagParams = array();
             if (!empty($params['tag'])) {
                 foreach ($params['tag'] as $tag) {
                     $tagParams[$tag] = 1;
                 }
             }
             //save static tags
             CRM_Core_BAO_EntityTag::create($tagParams, 'civicrm_activity', $vval['actId']);
             //save free tags
             if (isset($params['taglist']) && !empty($params['taglist'])) {
                 CRM_Core_Form_Tag::postProcess($params['taglist'], $vval['actId'], 'civicrm_activity', $this);
             }
         }
         // update existing case record if needed
         $caseParams = $params;
         $caseParams['id'] = $vval['case_id'];
         if (!empty($caseParams['case_status_id'])) {
             $caseParams['status_id'] = $caseParams['case_status_id'];
         }
         // unset params intended for activities only
         unset($caseParams['subject'], $caseParams['details'], $caseParams['status_id'], $caseParams['custom']);
         $case = CRM_Case_BAO_Case::create($caseParams);
         // create case activity record
         $caseParams = array('activity_id' => $vval['actId'], 'case_id' => $vval['case_id']);
         CRM_Case_BAO_Case::processCaseActivity($caseParams);
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:67,代码来源:Activity.php

示例5: postProcess


//.........这里部分代码省略.........
         $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) {
                 $tagParams[$tag] = 1;
             }
         }
         //save static tags
         require_once 'CRM/Core/BAO/EntityTag.php';
         CRM_Core_BAO_EntityTag::create($tagParams, 'civicrm_activity', $activity->id);
         //save free tags
         if (isset($params['taglist']) && !empty($params['taglist'])) {
             require_once 'CRM/Core/Form/Tag.php';
             CRM_Core_Form_Tag::postProcess($params['taglist'], $activity->id, 'civicrm_activity', $this);
         }
     }
     $params['assignee_contact_id'] = $assineeContacts;
     // update existing case record if needed
     $caseParams = $params;
     $caseParams['id'] = $this->_caseId;
     if (CRM_Utils_Array::value('case_type_id', $caseParams)) {
         $caseParams['case_type_id'] = CRM_Case_BAO_Case::VALUE_SEPERATOR . $caseParams['case_type_id'] . CRM_Case_BAO_Case::VALUE_SEPERATOR;
     }
     if (CRM_Utils_Array::value('case_status_id', $caseParams)) {
         $caseParams['status_id'] = $caseParams['case_status_id'];
     }
     // unset params intended for activities only
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:67,代码来源:Activity.php


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