本文整理汇总了PHP中CRM_Core_BAO_Note类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_Note类的具体用法?PHP CRM_Core_BAO_Note怎么用?PHP CRM_Core_BAO_Note使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_BAO_Note类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
$this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->assign('action', $this->_action);
$this->assign('context', $this->_context);
//check permission for action.
if (!CRM_Core_Permission::checkActionPermission('CiviGrant', $this->_action)) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
}
if ($this->_action & CRM_Core_Action::DELETE) {
return;
}
$this->_noteId = null;
if ($this->_id) {
require_once 'CRM/Core/BAO/Note.php';
$noteDAO = new CRM_Core_BAO_Note();
$noteDAO->entity_table = 'civicrm_grant';
$noteDAO->entity_id = $this->_id;
if ($noteDAO->find(true)) {
$this->_noteId = $noteDAO->id;
}
}
//build custom data
CRM_Custom_Form_Customdata::preProcess($this, null, null, 1, 'Grant', $this->_id);
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:33,代码来源:Grant.php
示例2: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
$this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->assign('context', $context);
$values = array();
$params['id'] = $this->_id;
require_once 'CRM/Grant/BAO/Grant.php';
CRM_Grant_BAO_Grant::retrieve($params, $values);
require_once 'CRM/Grant/PseudoConstant.php';
$grantType = CRM_Grant_PseudoConstant::grantType();
$grantStatus = CRM_Grant_PseudoConstant::grantStatus();
$this->assign('grantType', $grantType[$values['grant_type_id']]);
$this->assign('grantStatus', $grantStatus[$values['status_id']]);
$grantTokens = array('amount_total', 'amount_requested', 'amount_granted', 'rationale', 'grant_report_received', 'application_received_date', 'decision_date', 'money_transfer_date', 'grant_due_date');
foreach ($grantTokens as $token) {
$this->assign($token, CRM_Utils_Array::value($token, $values));
}
if (isset($this->_id)) {
require_once 'CRM/Core/BAO/Note.php';
$noteDAO = new CRM_Core_BAO_Note();
$noteDAO->entity_table = 'civicrm_grant';
$noteDAO->entity_id = $this->_id;
if ($noteDAO->find(true)) {
$this->_noteId = $noteDAO->id;
}
}
if (isset($this->_noteId)) {
$this->assign('note', CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Note', $this->_noteId, 'note'));
}
// add Grant to Recent Items
require_once 'CRM/Utils/Recent.php';
require_once 'CRM/Contact/BAO/Contact.php';
require_once 'CRM/Utils/Money.php';
$url = CRM_Utils_System::url('civicrm/contact/view/grant', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
$title = CRM_Contact_BAO_Contact::displayName($values['contact_id']) . ' - ' . ts('Grant') . ': ' . CRM_Utils_Money::format($values['amount_total']) . ' (' . $grantType[$values['grant_type_id']] . ')';
$recentOther = array();
if (CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::UPDATE)) {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/grant', "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
}
if (CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::DELETE)) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/grant', "action=delete&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
}
CRM_Utils_Recent::add($title, $url, $values['id'], 'Grant', $values['contact_id'], null, $recentOther);
require_once 'CRM/Core/BAO/File.php';
$attachment = CRM_Core_BAO_File::attachmentInfo('civicrm_grant', $this->_id);
$this->assign('attachment', $attachment);
$groupTree =& CRM_Core_BAO_CustomGroup::getTree("Grant", $this, $this->_id, 0);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
$this->assign('id', $this->_id);
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:58,代码来源:GrantView.php
示例3: view
/**
* View details of a relationship
*
* @return void
*
* @access public
*/
function view()
{
require_once 'CRM/Core/DAO.php';
$viewRelationship = CRM_Contact_BAO_Relationship::getRelationship($this->_contactId, null, null, null, $this->_id);
//To check whether selected contact is a contact_id_a in
//relationship type 'a_b' in relationship table, if yes then
//revert the permissionship text in template
$relationship =& new CRM_Contact_DAO_Relationship();
$relationship->id = $viewRelationship[$this->_id]['id'];
if ($relationship->find(true)) {
if ($viewRelationship[$this->_id]['rtype'] == 'a_b' && $this->_contactId == $relationship->contact_id_a) {
$this->assign("is_contact_id_a", true);
}
}
$relType = $viewRelationship[$this->_id]['civicrm_relationship_type_id'];
$this->assign('viewRelationship', $viewRelationship);
$viewNote = CRM_Core_BAO_Note::getNote($this->_id);
$this->assign('viewNote', $viewNote);
$groupTree =& CRM_Core_BAO_CustomGroup::getTree('Relationship', $this, $this->_id, 0, $relType);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
// add viewed contribution to recent items list
require_once 'CRM/Utils/Recent.php';
$url = CRM_Utils_System::url('civicrm/contact/view/rel', "action=view&reset=1&id={$viewRelationship[$this->_id]['id']}&cid={$this->_contactId}&context=home");
$title = CRM_Contact_BAO_Contact::displayName($this->_contactId) . ' (' . $viewRelationship[$this->_id]['relation'] . ' ' . CRM_Contact_BAO_Contact::displayName($viewRelationship[$this->_id]['cid']) . ')';
// add the recently viewed Relationship
CRM_Utils_Recent::add($title, $url, $viewRelationship[$this->_id]['id'], 'Relationship', $this->_contactId, null);
}
开发者ID:bhirsch,项目名称:voipdev,代码行数:34,代码来源:Relationship.php
示例4: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
require_once 'CRM/Event/BAO/Participant.php';
$values = $ids = array();
$participantID = CRM_Utils_Request::retrieve('id', 'Positive', $this, true);
$contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, true);
$params = array('id' => $participantID);
CRM_Event_BAO_Participant::getValues($params, $values, $ids);
if (empty($values)) {
require_once 'CRM/Core/Error.php';
CRM_Core_Error::statusBounce(ts('The requested participant record does not exist (possibly the record was deleted).'));
}
CRM_Event_BAO_Participant::resolveDefaults($values[$participantID]);
if (CRM_Utils_Array::value('fee_level', $values[$participantID])) {
CRM_Event_BAO_Participant::fixEventLevel($values[$participantID]['fee_level']);
}
if ($values[$participantID]['is_test']) {
$values[$participantID]['status'] .= ' (test) ';
}
// Get Note
$noteValue = CRM_Core_BAO_Note::getNote($participantID, 'civicrm_participant');
$values[$participantID]['note'] = array_values($noteValue);
require_once 'CRM/Price/BAO/LineItem.php';
// Get Line Items
$lineItem = CRM_Price_BAO_LineItem::getLineItems($participantID);
if (!CRM_Utils_System::isNull($lineItem)) {
$values[$participantID]['lineItem'][] = $lineItem;
}
$values[$participantID]['totalAmount'] = $values[$participantID]['fee_amount'];
// get the option value for custom data type
$roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name');
$eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name');
$eventTypeCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventType', 'name');
$roleGroupTree =& CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, null, $values[$participantID]['role_id'], $roleCustomDataTypeID);
$eventGroupTree =& CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, null, $values[$participantID]['event_id'], $eventNameCustomDataTypeID);
$eventTypeID = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $values[$participantID]['event_id'], 'event_type_id', 'id');
$eventTypeGroupTree =& CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, null, $eventTypeID, $eventTypeCustomDataTypeID);
$groupTree = CRM_Utils_Array::crmArrayMerge($roleGroupTree, $eventGroupTree);
$groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, $eventTypeGroupTree);
$groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID));
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
$this->assign($values[$participantID]);
// add viewed participant to recent items list
require_once 'CRM/Utils/Recent.php';
require_once 'CRM/Contact/BAO/Contact.php';
$url = CRM_Utils_System::url('civicrm/contact/view/participant', "action=view&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
$participantRoles = CRM_Event_PseudoConstant::participantRole();
$eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $values[$participantID]['event_id'], 'title');
$displayName = CRM_Contact_BAO_Contact::displayName($contactID);
$this->assign('displayName', $displayName);
$title = $displayName . ' (' . $participantRoles[$values[$participantID]['role_id']] . ' - ' . $eventTitle . ')';
// add Participant to Recent Items
CRM_Utils_Recent::add($title, $url, $values[$participantID]['id'], 'Participant', $values[$participantID]['contact_id'], null);
}
开发者ID:bhirsch,项目名称:voipdev,代码行数:60,代码来源:ParticipantView.php
示例5: view
/**
* View details of a relationship
*
* @return void
*
* @access public
*/
function view()
{
require_once 'CRM/Core/DAO.php';
$viewRelationship = CRM_Contact_BAO_Relationship::getRelationship($this->_contactId, null, null, null, $this->_id);
//To check whether selected contact is a contact_id_a in
//relationship type 'a_b' in relationship table, if yes then
//revert the permissionship text in template
$relationship = new CRM_Contact_DAO_Relationship();
$relationship->id = $viewRelationship[$this->_id]['id'];
if ($relationship->find(true)) {
if ($viewRelationship[$this->_id]['rtype'] == 'a_b' && $this->_contactId == $relationship->contact_id_a) {
$this->assign("is_contact_id_a", true);
}
}
$relType = $viewRelationship[$this->_id]['civicrm_relationship_type_id'];
$this->assign('viewRelationship', $viewRelationship);
$employerId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'employer_id');
$this->assign('isCurrentEmployer', false);
if ($viewRelationship[$this->_id]['employer_id'] == $this->_contactId) {
$this->assign('isCurrentEmployer', true);
} else {
if ($relType == 4 && $viewRelationship[$this->_id]['cid'] == $employerId) {
// make sure we are viewing employee of relationship
$this->assign('isCurrentEmployer', true);
}
}
$viewNote = CRM_Core_BAO_Note::getNote($this->_id);
$this->assign('viewNote', $viewNote);
$groupTree =& CRM_Core_BAO_CustomGroup::getTree('Relationship', $this, $this->_id, 0, $relType);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
$rType = CRM_Utils_Array::value('rtype', $viewRelationship[$this->_id]);
// add viewed contribution to recent items list
require_once 'CRM/Utils/Recent.php';
$url = CRM_Utils_System::url('civicrm/contact/view/rel', "action=view&reset=1&id={$viewRelationship[$this->_id]['id']}&cid={$this->_contactId}&context=home");
require_once 'CRM/Core/Session.php';
require_once 'CRM/Contact/BAO/Contact/Permission.php';
$session = CRM_Core_Session::singleton();
$recentOther = array();
if ($session->get('userID') == $this->_contactId || CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
$recentOther = array('editUrl' => CRM_Utils_System::url('civicrm/contact/view/rel', "action=update&reset=1&id={$viewRelationship[$this->_id]['id']}&cid={$this->_contactId}&rtype={$rType}&context=home"), 'deleteUrl' => CRM_Utils_System::url('civicrm/contact/view/rel', "action=delete&reset=1&id={$viewRelationship[$this->_id]['id']}&cid={$this->_contactId}&rtype={$rType}&context=home"));
}
$displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
$this->assign('displayName', $displayName);
$title = $displayName . ' (' . $viewRelationship[$this->_id]['relation'] . ' ' . CRM_Contact_BAO_Contact::displayName($viewRelationship[$this->_id]['cid']) . ')';
// add the recently viewed Relationship
CRM_Utils_Recent::add($title, $url, $viewRelationship[$this->_id]['id'], 'Relationship', $this->_contactId, null, $recentOther);
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:54,代码来源:Relationship.php
示例6: view
/**
* View details of a relationship
*
* @return void
*
* @access public
*/
function view()
{
require_once 'CRM/Core/DAO.php';
$viewRelationship = CRM_Contact_BAO_Relationship::getRelationship($this->_contactId, null, null, null, $this->_id);
//To check whether selected contact is a contact_id_a in
//relationship type 'a_b' in relationship table, if yes then
//revert the permissionship text in template
$relationship =& new CRM_Contact_DAO_Relationship();
$relationship->id = $viewRelationship[$this->_id]['id'];
if ($relationship->find(true)) {
if ($viewRelationship[$this->_id]['rtype'] == 'a_b' && $this->_contactId == $relationship->contact_id_a) {
$this->assign("is_contact_id_a", true);
}
}
$relType = $viewRelationship[$this->_id]['civicrm_relationship_type_id'];
$this->assign('viewRelationship', $viewRelationship);
$viewNote = CRM_Core_BAO_Note::getNote($this->_id);
$this->assign('viewNote', $viewNote);
$groupTree =& CRM_Core_BAO_CustomGroup::getTree('Relationship', $this, $this->_id, 0, $relType);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
}
开发者ID:ksecor,项目名称:civicrm,代码行数:28,代码来源:Relationship.php
示例7: CRM_Core_BAO_Note
/**
* takes an associative array and creates a note object
*
* the function extract all the params it needs to initialize the create a
* note object. the params array could contain additional unused name/value
* pairs
*
* @param array $params (reference ) an assoc array of name/value pairs
*
* @return object CRM_Core_BAO_Note object
* @access public
* @static
*/
function &add(&$params)
{
$dataExists = CRM_Core_BAO_Note::dataExists($params);
if (!$dataExists) {
return null;
}
$note =& new CRM_Core_BAO_Note();
$params['modified_date'] = date("Ymd");
$params['entity_id'] = $params['entity_id'];
$params['entity_table'] = $params['entity_table'];
$note->copyValues($params);
$session =& CRM_Core_Session::singleton();
$note->contact_id = $session->get('userID');
if (!$note->contact_id) {
if ($params['entity_table'] == 'civicrm_contact') {
$note->contact_id = $params['entity_id'];
} else {
CRM_Utils_System::statusBounce(ts('We could not find your logged in user ID'));
}
}
$note->save();
return $note;
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:36,代码来源:Note.php
示例8: getCountComponent
/**
* Given the component name and returns the count of participation of contact.
*
* @param string $component
* Input component name.
* @param int $contactId
* Input contact id.
* @param string $tableName
* Optional tableName if component is custom group.
*
* @return int
* total number in database
*/
public static function getCountComponent($component, $contactId, $tableName = NULL)
{
$object = NULL;
switch ($component) {
case 'tag':
return CRM_Core_BAO_EntityTag::getContactTags($contactId, TRUE);
case 'rel':
$result = CRM_Contact_BAO_Relationship::getRelationship($contactId, CRM_Contact_BAO_Relationship::CURRENT, 0, 1);
return $result;
case 'group':
return CRM_Contact_BAO_GroupContact::getContactGroup($contactId, "Added", NULL, TRUE);
case 'log':
if (CRM_Core_BAO_Log::useLoggingReport()) {
return FALSE;
}
return CRM_Core_BAO_Log::getContactLogCount($contactId);
case 'note':
return CRM_Core_BAO_Note::getContactNoteCount($contactId);
case 'contribution':
return CRM_Contribute_BAO_Contribution::contributionCount($contactId);
case 'membership':
return CRM_Member_BAO_Membership::getContactMembershipCount($contactId, TRUE);
case 'participant':
return CRM_Event_BAO_Participant::getContactParticipantCount($contactId);
case 'pledge':
return CRM_Pledge_BAO_Pledge::getContactPledgeCount($contactId);
case 'case':
return CRM_Case_BAO_Case::caseCount($contactId);
case 'grant':
return CRM_Grant_BAO_Grant::getContactGrantCount($contactId);
case 'activity':
$input = array('contact_id' => $contactId, 'admin' => FALSE, 'caseId' => NULL, 'context' => 'activity');
return CRM_Activity_BAO_Activity::getActivitiesCount($input);
case 'mailing':
$params = array('contact_id' => $contactId);
return CRM_Mailing_BAO_Mailing::getContactMailingsCount($params);
default:
$custom = explode('_', $component);
if ($custom['0'] = 'custom') {
if (!$tableName) {
$tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $custom['1'], 'table_name');
}
$queryString = "SELECT count(id) FROM {$tableName} WHERE entity_id = {$contactId}";
return CRM_Core_DAO::singleValueQuery($queryString);
}
}
}
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:60,代码来源:Contact.php
示例9: postProcess
/**
*
* @access public
* @return None
*/
public function postProcess()
{
// store the submitted values in an array
$params = $this->exportValues();
$session =& CRM_Core_Session::singleton();
$params['contact_id'] = $session->get('userID');
$params['entity_table'] = $this->_entityTable;
$params['entity_id'] = $this->_entityId;
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Core_BAO_Note::del($this->_id);
return;
}
if ($this->_action & CRM_Core_Action::UPDATE) {
$params['id'] = $this->_id;
}
$ids = array();
require_once 'CRM/Core/BAO/Note.php';
CRM_Core_BAO_Note::add($params, $ids);
CRM_Core_Session::setStatus(ts('Your Note has been saved.'));
}
开发者ID:ksecor,项目名称:civicrm,代码行数:25,代码来源:Note.php
示例10: preProcess
/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess()
{
$values = $ids = array();
$participantID = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$params = array('id' => $participantID);
CRM_Event_BAO_Participant::getValues($params, $values, $ids);
if (empty($values)) {
CRM_Core_Error::statusBounce(ts('The requested participant record does not exist (possibly the record was deleted).'));
}
CRM_Event_BAO_Participant::resolveDefaults($values[$participantID]);
if (!empty($values[$participantID]['fee_level'])) {
CRM_Event_BAO_Participant::fixEventLevel($values[$participantID]['fee_level']);
}
$this->assign('contactId', $contactID);
$this->assign('participantId', $participantID);
$paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $participantID, 'id', 'participant_id');
$this->assign('hasPayment', $paymentId);
if ($parentParticipantId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $participantID, 'registered_by_id')) {
$parentHasPayment = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $parentParticipantId, 'id', 'participant_id');
$this->assign('parentHasPayment', $parentHasPayment);
}
$statusId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $participantID, 'status_id', 'id');
$status = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantStatusType', $statusId, 'name', 'id');
$status = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantStatusType', $statusId, 'name', 'id');
if ($status == 'Transferred') {
$transferId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $participantID, 'transferred_to_contact_id', 'id');
$pid = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $transferId, 'id', 'contact_id');
$transferName = current(CRM_Contact_BAO_Contact::getContactDetails($transferId));
$this->assign('pid', $pid);
$this->assign('transferId', $transferId);
$this->assign('transferName', $transferName);
}
$participantStatuses = CRM_Event_PseudoConstant::participantStatus();
if ($values[$participantID]['is_test']) {
$values[$participantID]['status'] .= ' (test) ';
}
// Get Note
$noteValue = CRM_Core_BAO_Note::getNote($participantID, 'civicrm_participant');
$values[$participantID]['note'] = array_values($noteValue);
// Get Line Items
$lineItem = CRM_Price_BAO_LineItem::getLineItems($participantID);
if (!CRM_Utils_System::isNull($lineItem)) {
$values[$participantID]['lineItem'][] = $lineItem;
}
$values[$participantID]['totalAmount'] = CRM_Utils_Array::value('fee_amount', $values[$participantID]);
// Get registered_by contact ID and display_name if participant was registered by someone else (CRM-4859)
if (!empty($values[$participantID]['participant_registered_by_id'])) {
$values[$participantID]['registered_by_contact_id'] = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Participant", $values[$participantID]['participant_registered_by_id'], 'contact_id', 'id');
$values[$participantID]['registered_by_display_name'] = CRM_Contact_BAO_Contact::displayName($values[$participantID]['registered_by_contact_id']);
}
// Check if this is a primaryParticipant (registered for others) and retrieve additional participants if true (CRM-4859)
if (CRM_Event_BAO_Participant::isPrimaryParticipant($participantID)) {
$values[$participantID]['additionalParticipants'] = CRM_Event_BAO_Participant::getAdditionalParticipants($participantID);
}
// get the option value for custom data type
$roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name');
$eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name');
$eventTypeCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventType', 'name');
$allRoleIDs = explode(CRM_Core_DAO::VALUE_SEPARATOR, $values[$participantID]['role_id']);
$groupTree = array();
$finalTree = array();
foreach ($allRoleIDs as $k => $v) {
$roleGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, NULL, $v, $roleCustomDataTypeID);
$eventGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, NULL, $values[$participantID]['event_id'], $eventNameCustomDataTypeID);
$eventTypeID = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $values[$participantID]['event_id'], 'event_type_id', 'id');
$eventTypeGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, NULL, $eventTypeID, $eventTypeCustomDataTypeID);
$groupTree = CRM_Utils_Array::crmArrayMerge($roleGroupTree, $eventGroupTree);
$groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, $eventTypeGroupTree);
$groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID));
foreach ($groupTree as $treeId => $trees) {
$finalTree[$treeId] = $trees;
}
}
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $finalTree, FALSE, NULL, NULL, NULL, $participantID);
$eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $values[$participantID]['event_id'], 'title');
//CRM-7150, show event name on participant view even if the event is disabled
if (empty($values[$participantID]['event'])) {
$values[$participantID]['event'] = $eventTitle;
}
//do check for campaigns
if ($campaignId = CRM_Utils_Array::value('campaign_id', $values[$participantID])) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
$values[$participantID]['campaign'] = $campaigns[$campaignId];
}
$this->assign($values[$participantID]);
// add viewed participant to recent items list
$url = CRM_Utils_System::url('civicrm/contact/view/participant', "action=view&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
$recentOther = array();
if (CRM_Core_Permission::check('edit event participants')) {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/participant', "action=update&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
}
if (CRM_Core_Permission::check('delete in CiviEvent')) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/participant', "action=delete&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
}
//.........这里部分代码省略.........
开发者ID:nielosz,项目名称:civicrm-core,代码行数:101,代码来源:ParticipantView.php
示例11: setDefaultValues
/**
* This function sets the default values for the form in edit/view mode
* the default values are retrieved from the database
*
*
* @return void
*/
public function setDefaultValues()
{
if ($this->_showFeeBlock) {
return CRM_Event_Form_EventFees::setDefaultValues($this);
}
$defaults = array();
if ($this->_action & CRM_Core_Action::DELETE) {
return $defaults;
}
if ($this->_id) {
$ids = array();
$params = array('id' => $this->_id);
CRM_Event_BAO_Participant::getValues($params, $defaults, $ids);
$sep = CRM_Core_DAO::VALUE_SEPARATOR;
if ($defaults[$this->_id]['role_id']) {
$roleIDs = explode($sep, $defaults[$this->_id]['role_id']);
}
$this->_contactId = $defaults[$this->_id]['contact_id'];
$this->_statusId = $defaults[$this->_id]['participant_status_id'];
//set defaults for note
$noteDetails = CRM_Core_BAO_Note::getNote($this->_id, 'civicrm_participant');
$defaults[$this->_id]['note'] = array_pop($noteDetails);
// Check if this is a primaryParticipant (registered for others) and retrieve additional participants if true (CRM-4859)
if (CRM_Event_BAO_Participant::isPrimaryParticipant($this->_id)) {
$this->assign('additionalParticipants', CRM_Event_BAO_Participant::getAdditionalParticipants($this->_id));
}
// Get registered_by contact ID and display_name if participant was registered by someone else (CRM-4859)
if (!empty($defaults[$this->_id]['participant_registered_by_id'])) {
$registered_by_contact_id = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $defaults[$this->_id]['participant_registered_by_id'], 'contact_id', 'id');
$this->assign('participant_registered_by_id', $defaults[$this->_id]['participant_registered_by_id']);
$this->assign('registered_by_contact_id', $registered_by_contact_id);
$this->assign('registered_by_display_name', CRM_Contact_BAO_Contact::displayName($registered_by_contact_id));
}
}
if ($this->_action & (CRM_Core_Action::VIEW | CRM_Core_Action::BROWSE)) {
$inactiveNeeded = TRUE;
$viewMode = TRUE;
} else {
$viewMode = FALSE;
$inactiveNeeded = FALSE;
}
//setting default register date
if ($this->_action == CRM_Core_Action::ADD) {
$statuses = array_flip($this->_participantStatuses);
$defaults[$this->_id]['status_id'] = CRM_Utils_Array::value(ts('Registered'), $statuses);
if (!empty($defaults[$this->_id]['event_id'])) {
$contributionTypeId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $defaults[$this->_id]['event_id'], 'financial_type_id');
if ($contributionTypeId) {
$defaults[$this->_id]['financial_type_id'] = $contributionTypeId;
}
}
if ($this->_mode) {
$fields["email-{$this->_bltID}"] = 1;
$fields['email-Primary'] = 1;
if ($this->_contactId) {
CRM_Core_BAO_UFGroup::setProfileDefaults($this->_contactId, $fields, $defaults);
}
if (empty($defaults["email-{$this->_bltID}"]) && !empty($defaults['email-Primary'])) {
$defaults[$this->_id]["email-{$this->_bltID}"] = $defaults['email-Primary'];
}
}
$submittedRole = $this->getElementValue('role_id');
if (!empty($submittedRole[0])) {
$roleID = $submittedRole[0];
}
$submittedEvent = $this->getElementValue('event_id');
if (!empty($submittedEvent[0])) {
$eventID = $submittedEvent[0];
}
} else {
$defaults[$this->_id]['record_contribution'] = 0;
if ($defaults[$this->_id]['participant_is_pay_later']) {
$this->assign('participant_is_pay_later', TRUE);
}
$this->assign('participant_status_id', $defaults[$this->_id]['participant_status_id']);
$eventID = $defaults[$this->_id]['event_id'];
$this->_eventTypeId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventID, 'event_type_id', 'id');
$this->_discountId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'discount_id');
if ($this->_discountId) {
$this->set('discountId', $this->_discountId);
}
}
list($defaults[$this->_id]['register_date'], $defaults[$this->_id]['register_date_time']) = CRM_Utils_Date::setDateDefaults(CRM_Utils_Array::value('register_date', $defaults[$this->_id]), 'activityDateTime');
//assign event and role id, this is needed for Custom data building
$sep = CRM_Core_DAO::VALUE_SEPARATOR;
if (!empty($defaults[$this->_id]['participant_role_id'])) {
$roleIDs = explode($sep, $defaults[$this->_id]['participant_role_id']);
}
if (isset($_POST['event_id'])) {
$eventID = $_POST['event_id'];
}
if ($this->_eID) {
$eventID = $this->_eID;
//.........这里部分代码省略.........
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:101,代码来源:Participant.php
示例12: postProcess
//.........这里部分代码省略.........
$params['end_date'] = CRM_Utils_Date::processDate($params['end_date'], null, true);
//special case to handle if all checkboxes are unchecked
$customFields = CRM_Core_BAO_CustomField::getFields('Relationship', false, false, $relationshipTypeId);
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_relationshipId, 'Relationship');
list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::create($params, $ids);
// if this is called from case view,
//create an activity for case role removal.CRM-4480
if ($this->_caseId) {
require_once "CRM/Case/BAO/Case.php";
CRM_Case_BAO_Case::createCaseRoleActivity($this->_caseId, $relationshipIds, $params['contact_check'], $this->_contactId);
}
$status = '';
if ($valid) {
$status .= ' ' . ts('%count new relationship record created.', array('count' => $valid, 'plural' => '%count new relationship records created.'));
}
if ($invalid) {
$status .= ' ' . ts('%count relationship record not created due to invalid target contact type.', array('count' => $invalid, 'plural' => '%count relationship records not created due to invalid target contact type.'));
}
if ($duplicate) {
$status .= ' ' . ts('%count relationship record not created - duplicate of existing relationship.', array('count' => $duplicate, 'plural' => '%count relationship records not created - duplicate of existing relationship.'));
}
if ($saved) {
$status .= ts('Relationship record has been updated.');
}
$note = new CRM_Core_DAO_Note();
$note->entity_id = $relationshipIds[0];
$note->entity_table = 'civicrm_relationship';
$noteIds = array();
if ($note->find(true)) {
$id = $note->id;
$noteIds["id"] = $id;
}
$noteParams = array('entity_id' => $relationshipIds[0], 'entity_table' => 'civicrm_relationship', 'note' => $params['note'], 'contact_id' => $this->_contactId);
CRM_Core_BAO_Note::add($noteParams, $noteIds);
// Membership for related contacts CRM-1657
if (CRM_Core_Permission::access('CiviMember') && !$duplicate) {
CRM_Contact_BAO_Relationship::relatedMemberships($this->_contactId, $params, $ids, $this->_action);
}
//handle current employee/employer relationship, CRM-3532
if ($this->_allRelationshipNames[$relationshipTypeId]["name_{$this->_rtype}"] == 'Employee of') {
$orgId = null;
if (CRM_Utils_Array::value('employee_of', $params)) {
$orgId = $params['employee_of'];
} else {
if ($this->_action & CRM_Core_Action::UPDATE) {
if (CRM_Utils_Array::value('is_current_employer', $params) && CRM_Utils_Array::value('is_active', $params)) {
if (CRM_Utils_Array::value('contactTarget', $ids) != CRM_Utils_Array::value('current_employer_id', $this->_values)) {
$orgId = CRM_Utils_Array::value('contactTarget', $ids);
}
} else {
if (CRM_Utils_Array::value('contactTarget', $ids) == CRM_Utils_Array::value('current_employer_id', $this->_values)) {
//clear current employer.
require_once 'CRM/Contact/BAO/Contact/Utils.php';
CRM_Contact_BAO_Contact_Utils::clearCurrentEmployer($this->_contactId);
}
}
}
}
//set current employer
if ($orgId) {
$currentEmpParams[$this->_contactId] = $orgId;
require_once 'CRM/Contact/BAO/Contact/Utils.php';
CRM_Contact_BAO_Contact_Utils::setCurrentEmployer($currentEmpParams);
}
} else {
if ($this->_allRelationshipNames[$relationshipTypeId]["name_{$this->_rtype}"] == 'Employer of') {
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:67,代码来源:Relationship.php
示例13: CRM_Core_Transaction
/**
* takes an associative array and creates a participant object
*
* @param array $params (reference ) an assoc array of name/value pairs
* @param array $ids the array that holds all the db ids
*
* @return object CRM_Event_BAO_Participant object
* @access public
* @static
*/
static function &create(&$params)
{
require_once 'CRM/Utils/Date.php';
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
$status = null;
if (CRM_Utils_Array::value('id', $params)) {
$status = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $params['id'], 'status_id');
}
$participant =& self::add($params);
if (is_a($participant, 'CRM_Core_Error')) {
$transaction->rollback();
return $participant;
}
if (!CRM_Utils_Array::value('id', $params) || $params['status_id'] != $status) {
require_once 'CRM/Activity/BAO/Activity.php';
CRM_Activity_BAO_Activity::addActivity($participant);
}
//CRM-5403
//for update mode
if (self::isPrimaryParticipant($participant->id) && $status) {
self::updateParticipantStatus($participant->id, $status, $participant->status_id);
}
$session =& CRM_Core_Session::singleton();
$id = $session->get('userID');
if (!$id) {
$id = $params['contact_id'];
}
// add custom field values
if (CRM_Utils_Array::value('custom', $params) && is_array($params['custom'])) {
require_once 'CRM/Core/BAO/CustomValueTable.php';
CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_participant', $participant->id);
}
if (CRM_Utils_Array::value('note', $params) || CRM_Utils_Array::value('participant_note', $params)) {
if (CRM_Utils_Array::value('note', $params)) {
$note = CRM_Utils_Array::value('note', $params);
} else {
$note = CRM_Utils_Array::value('participant_note', $params);
}
$noteDetails = CRM_Core_BAO_Note::getNote($participant->id, 'civicrm_participant');
$noteIDs = array();
if (!empty($noteDetails)) {
$noteIDs['id'] = array_pop(array_flip($noteDetails));
}
if ($note) {
require_once 'CRM/Core/BAO/Note.php';
$noteParams = array('entity_table' => 'civicrm_participant', 'note' => $note, 'entity_id' => $participant->id, 'contact_id' => $id, 'modified_date' => date('Ymd'));
CRM_Core_BAO_Note::add($noteParams, $noteIDs);
}
}
// Log the information on successful add/edit of Participant data.
require_once 'CRM/Core/BAO/Log.php';
$logParams = array('entity_table' => 'civicrm_participant', 'entity_id' => $participant->id, 'data' => CRM_Event_PseudoConstant::participantStatus($participant->status_id), 'modified_id' => $id, 'modified_date' => date('Ymd'));
CRM_Core_BAO_Log::add($logParams);
$params['participant_id'] = $participant->id;
$transaction->commit();
// do not add to recent items for import, CRM-4399
if (!CRM_Utils_Array::value('skipRecentView', $params)) {
require_once 'CRM/Utils/Recent.php';
require_once 'CRM/Event/PseudoConstant.php';
require_once 'CRM/Contact/BAO/Contact.php';
$url = CRM_Utils_System::url('civicrm/contact/view/participant', "action=view&reset=1&id={$participant->id}&cid={$participant->contact_id}&context=home");
$recentOther = array();
if (CRM_Core_Permission::check('edit event participants')) {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/participant', "action=update&reset=1&id={$participant->id}&cid={$participant->contact_id}&context=home");
}
if (CRM_Core_Permission::check('delete in CiviEvent')) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/participant', "action=delete&reset=1&id={$participant->id}&cid={$participant->contact_id}&context=home");
}
$participantRoles = CRM_Event_PseudoConstant::participantRole();
if ($participant->role_id) {
$role = explode(CRM_Core_DAO::VALUE_SEPARATOR, $participant->role_id);
foreach ($role as $roleKey => $roleValue) {
if (isset($roles)) {
$roles .= ", " . $participantRoles[$roleValue];
} else {
$roles = $participantRoles[$roleValue];
}
}
}
$eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $participant->event_id, 'title');
$title = CRM_Contact_BAO_Contact::displayName($participant->contact_id) . ' (' . $roles . ' - ' . $eventTitle . ')';
// add the recently created Participant
CRM_Utils_Recent::add($title, $url, $participant->id, 'Participant', $participant->contact_id, null, $recentOther);
}
return $participant;
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:97,代码来源:Participant.php
示例14: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
$id = $this->get('id');
$values = $ids = array();
$params = array('id' => $id);
require_once 'CRM/Contribute/BAO/Contribution.php';
CRM_Contribute_BAO_Contribution::getValues($params, $values, $ids);
$softParams = array('contribution_id' => $values['contribution_id']);
if ($softContribution = CRM_Contribute_BAO_Contribution::getSoftContribution($softParams, true)) {
$values = array_merge($values, $softContribution);
}
CRM_Contribute_BAO_Contribution::resolveDefaults($values);
if (CRM_Utils_Array::value('honor_contact_id', $values)) {
$sql = "SELECT display_name FROM civicrm_contact WHERE id = %1";
$params = array(1 => array($values['honor_contact_id'], 'Integer'));
$dao = CRM_Core_DAO::executeQuery($sql, $params);
if ($dao->fetch()) {
$url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$values['honor_contact_id']}");
$values["honor_display"] = "<A href = {$url}>" . $dao->display_name . "</A>";
}
$honor = CRM_Core_PseudoConstant::honor();
$values['honor_type'] = $honor[$values['honor_type_id']];
}
if (CRM_Utils_Array::value('contribution_recur_id', $values)) {
$sql = "SELECT installments, frequency_interval, frequency_unit FROM civicrm_contribution_recur WHERE id = %1";
$params = array(1 => array($values['contribution_recur_id'], 'Integer'));
$dao = CRM_Core_DAO::executeQuery($sql, $params);
if ($dao->fetch()) {
$values["recur_installments"] = $dao->installments;
$values["recur_frequency_unit"] = $dao->frequency_unit;
$values["recur_frequency_interval"] = $dao->frequency_interval;
}
}
$groupTree =& CRM_Core_BAO_CustomGroup::getTree('Contribution', $this, $id, 0, $values['contribution_type_id']);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
$premiumId = null;
if ($id) {
require_once 'CRM/Contribute/DAO/ContributionProduct.php';
$dao =& new CRM_Contribute_DAO_ContributionProduct();
$dao->contribution_id = $id;
if ($dao->find(true)) {
$premiumId = $dao->id;
$productID = $dao->product_id;
}
|
请发表评论