• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP CRM_Core_DAO_Note类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: browse

 /**
  * called when action is browse.
  */
 public function browse()
 {
     $note = new CRM_Core_DAO_Note();
     $note->entity_table = 'civicrm_contact';
     $note->entity_id = $this->_contactId;
     $note->orderBy('modified_date desc');
     //CRM-4418, handling edit and delete separately.
     $permissions = array($this->_permission);
     if ($this->_permission == CRM_Core_Permission::EDIT) {
         //previously delete was subset of edit
         //so for consistency lets grant delete also.
         $permissions[] = CRM_Core_Permission::DELETE;
     }
     $mask = CRM_Core_Action::mask($permissions);
     $values = array();
     $links = self::links();
     $action = array_sum(array_keys($links)) & $mask;
     $note->find();
     while ($note->fetch()) {
         if (!CRM_Core_BAO_Note::getNotePrivacyHidden($note)) {
             CRM_Core_DAO::storeValues($note, $values[$note->id]);
             $values[$note->id]['action'] = CRM_Core_Action::formLink($links, $action, array('id' => $note->id, 'cid' => $this->_contactId), ts('more'), FALSE, 'note.selector.row', 'Note', $note->id);
             $contact = new CRM_Contact_DAO_Contact();
             $contact->id = $note->contact_id;
             $contact->find();
             $contact->fetch();
             $values[$note->id]['createdBy'] = $contact->display_name;
             $values[$note->id]['comment_count'] = CRM_Core_BAO_Note::getChildCount($note->id);
             // paper icon view for attachments part
             $paperIconAttachmentInfo = CRM_Core_BAO_File::paperIconAttachment('civicrm_note', $note->id);
             $values[$note->id]['attachment'] = $paperIconAttachmentInfo;
         }
     }
     $this->assign('notes', $values);
     $commentLinks = self::commentLinks();
     $action = array_sum(array_keys($commentLinks)) & $mask;
     $commentAction = CRM_Core_Action::formLink($commentLinks, $action, array('id' => $note->id, 'pid' => $note->entity_id, 'cid' => $note->entity_id), ts('more'), FALSE, 'note.comment.action', 'Note', $note->id);
     $this->assign('commentAction', $commentAction);
     $this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent('note', $this->_contactId);
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:43,代码来源:Note.php


示例2: array

 /**
  * combine all the importable fields from the lower levels object
  *
  * The ordering is important, since currently we do not have a weight
  * scheme. Adding weight is super important and should be done in the
  * next week or so, before this can be called complete.
  *
  * @return array array of importable Fields
  * @access public
  */
 function &importableFields($contacType = 'Individual', $status = true)
 {
     if (!self::$_importableFields) {
         if (!self::$_importableFields) {
             self::$_importableFields = array();
         }
         if (!$status) {
             $fields = array('' => array('title' => ts('- do not import -')));
         } else {
             $fields = array('' => array('title' => ts('- Contribution Fields -')));
         }
         require_once 'CRM/Core/DAO/Note.php';
         $note = CRM_Core_DAO_Note::import();
         $tmpFields = CRM_Contribute_DAO_Contribution::import();
         unset($tmpFields['option_value']);
         require_once 'CRM/Core/OptionValue.php';
         $optionFields = CRM_Core_OptionValue::getFields($mode = 'contribute');
         require_once 'CRM/Contact/BAO/Contact.php';
         $contactFields = CRM_Contact_BAO_Contact::importableFields($contacType, null);
         // Using new Dedupe rule.
         $ruleParams = array('contact_type' => $contacType, 'level' => 'Strict');
         require_once 'CRM/Dedupe/BAO/Rule.php';
         $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
         $tmpConatctField = array();
         if (is_array($fieldsArray)) {
             foreach ($fieldsArray as $value) {
                 //skip if there is no dupe rule
                 if ($value == 'none') {
                     continue;
                 }
                 $tmpConatctField[trim($value)] = $contactFields[trim($value)];
                 if (!$status) {
                     $title = $tmpConatctField[trim($value)]['title'] . " (match to contact)";
                 } else {
                     $title = $tmpConatctField[trim($value)]['title'];
                 }
                 $tmpConatctField[trim($value)]['title'] = $title;
             }
         }
         $tmpConatctField['external_identifier'] = $contactFields['external_identifier'];
         $tmpConatctField['external_identifier']['title'] = $contactFields['external_identifier']['title'] . " (match to contact)";
         $tmpFields['contribution_contact_id']['title'] = $tmpFields['contribution_contact_id']['title'] . " (match to contact)";
         $fields = array_merge($fields, $tmpConatctField);
         $fields = array_merge($fields, $tmpFields);
         $fields = array_merge($fields, $note);
         $fields = array_merge($fields, $optionFields);
         require_once 'CRM/Contribute/DAO/ContributionType.php';
         $fields = array_merge($fields, CRM_Contribute_DAO_ContributionType::export());
         $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Contribution'));
         self::$_importableFields = $fields;
     }
     return self::$_importableFields;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:63,代码来源:Contribution.php


示例3: array

 /**
  * Combine all the importable fields from the lower levels object.
  *
  * The ordering is important, since currently we do not have a weight
  * scheme. Adding weight is super important and should be done in the
  * next week or so, before this can be called complete.
  *
  * @param string $contactType
  * @param bool $status
  *
  * @return array
  *   array of importable Fields
  */
 public static function &importableFields($contactType = 'Individual', $status = TRUE)
 {
     if (!self::$_importableFields) {
         if (!self::$_importableFields) {
             self::$_importableFields = array();
         }
         if (!$status) {
             $fields = array('' => array('title' => ts('- do not import -')));
         } else {
             $fields = array('' => array('title' => ts('- Contribution Fields -')));
         }
         $note = CRM_Core_DAO_Note::import();
         $tmpFields = CRM_Contribute_DAO_Contribution::import();
         unset($tmpFields['option_value']);
         $optionFields = CRM_Core_OptionValue::getFields($mode = 'contribute');
         $contactFields = CRM_Contact_BAO_Contact::importableFields($contactType, NULL);
         // Using new Dedupe rule.
         $ruleParams = array('contact_type' => $contactType, 'used' => 'Unsupervised');
         $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
         $tmpContactField = array();
         if (is_array($fieldsArray)) {
             foreach ($fieldsArray as $value) {
                 //skip if there is no dupe rule
                 if ($value == 'none') {
                     continue;
                 }
                 $customFieldId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $value, 'id', 'column_name');
                 $value = $customFieldId ? 'custom_' . $customFieldId : $value;
                 $tmpContactField[trim($value)] = $contactFields[trim($value)];
                 if (!$status) {
                     $title = $tmpContactField[trim($value)]['title'] . ' ' . ts('(match to contact)');
                 } else {
                     $title = $tmpContactField[trim($value)]['title'];
                 }
                 $tmpContactField[trim($value)]['title'] = $title;
             }
         }
         $tmpContactField['external_identifier'] = $contactFields['external_identifier'];
         $tmpContactField['external_identifier']['title'] = $contactFields['external_identifier']['title'] . ' ' . ts('(match to contact)');
         $tmpFields['contribution_contact_id']['title'] = $tmpFields['contribution_contact_id']['title'] . ' ' . ts('(match to contact)');
         $fields = array_merge($fields, $tmpContactField);
         $fields = array_merge($fields, $tmpFields);
         $fields = array_merge($fields, $note);
         $fields = array_merge($fields, $optionFields);
         $fields = array_merge($fields, CRM_Financial_DAO_FinancialType::export());
         $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Contribution'));
         self::$_importableFields = $fields;
     }
     return self::$_importableFields;
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:63,代码来源:Contribution.php


示例4: postProcess


//.........这里部分代码省略.........
             $params['employee_of'] = $params['rel_contact_id'];
         } elseif ($params['add_current_employer'] && $this->_allRelationshipNames[$relationshipTypeId]["name_b_a"] == 'Employer of') {
             $params['employer_of'] = array($params['rel_contact_id'] => 1);
         }
         if (!$this->_rtype) {
             $this->_rtype = str_replace($relationshipTypeId . '_', '', $params['relationship_type_id']);
         }
     }
     $params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], null, true);
     $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);
                     }
                 }
             }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:67,代码来源:Relationship.php


示例5: importableFields

 /**
  * Combine all the importable fields from the lower levels object.
  *
  * The ordering is important, since currently we do not have a weight
  * scheme. Adding weight is super important
  *
  * @param int|string $contactType contact Type
  * @param bool $status
  *   Status is used to manipulate first title.
  * @param bool $showAll
  *   If true returns all fields (includes disabled fields).
  * @param bool $isProfile
  *   If its profile mode.
  * @param bool $checkPermission
  *   If false, do not include permissioning clause (for custom data).
  *
  * @param bool $withMultiCustomFields
  *
  * @return array
  *   array of importable Fields
  */
 public static function importableFields($contactType = 'Individual', $status = FALSE, $showAll = FALSE, $isProfile = FALSE, $checkPermission = TRUE, $withMultiCustomFields = FALSE)
 {
     if (empty($contactType)) {
         $contactType = 'All';
     }
     $cacheKeyString = "importableFields {$contactType}";
     $cacheKeyString .= $status ? '_1' : '_0';
     $cacheKeyString .= $showAll ? '_1' : '_0';
     $cacheKeyString .= $isProfile ? '_1' : '_0';
     $cacheKeyString .= $checkPermission ? '_1' : '_0';
     $fields = CRM_Utils_Array::value($cacheKeyString, self::$_importableFields);
     if (!$fields) {
         // check if we can retrieve from database cache
         $fields = CRM_Core_BAO_Cache::getItem('contact fields', $cacheKeyString);
     }
     if (!$fields) {
         $fields = CRM_Contact_DAO_Contact::import();
         // get the fields thar are meant for contact types
         if (in_array($contactType, array('Individual', 'Household', 'Organization', 'All'))) {
             $fields = array_merge($fields, CRM_Core_OptionValue::getFields('', $contactType));
         }
         $locationFields = array_merge(CRM_Core_DAO_Address::import(), CRM_Core_DAO_Phone::import(), CRM_Core_DAO_Email::import(), CRM_Core_DAO_IM::import(TRUE), CRM_Core_DAO_OpenID::import());
         $locationFields = array_merge($locationFields, CRM_Core_BAO_CustomField::getFieldsForImport('Address', FALSE, FALSE, FALSE, FALSE));
         foreach ($locationFields as $key => $field) {
             $locationFields[$key]['hasLocationType'] = TRUE;
         }
         $fields = array_merge($fields, $locationFields);
         $fields = array_merge($fields, CRM_Contact_DAO_Contact::import());
         $fields = array_merge($fields, CRM_Core_DAO_Note::import());
         //website fields
         $fields = array_merge($fields, CRM_Core_DAO_Website::import());
         $fields['url']['hasWebsiteType'] = TRUE;
         if ($contactType != 'All') {
             $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($contactType, $showAll, TRUE, FALSE, FALSE, $withMultiCustomFields));
             //unset the fields, which are not related to their
             //contact type.
             $commonValues = array('Individual' => array('household_name', 'legal_name', 'sic_code', 'organization_name'), 'Household' => array('first_name', 'middle_name', 'last_name', 'formal_title', 'job_title', 'gender_id', 'prefix_id', 'suffix_id', 'birth_date', 'organization_name', 'legal_name', 'legal_identifier', 'sic_code', 'home_URL', 'is_deceased', 'deceased_date'), 'Organization' => array('first_name', 'middle_name', 'last_name', 'formal_title', 'job_title', 'gender_id', 'prefix_id', 'suffix_id', 'birth_date', 'household_name', 'is_deceased', 'deceased_date'));
             foreach ($commonValues[$contactType] as $value) {
                 unset($fields[$value]);
             }
         } else {
             foreach (array('Individual', 'Household', 'Organization') as $type) {
                 $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($type, $showAll, FALSE, FALSE, FALSE, $withMultiCustomFields));
             }
         }
         if ($isProfile) {
             $fields = array_merge($fields, array('group' => array('title' => ts('Group(s)'), 'name' => 'group'), 'tag' => array('title' => ts('Tag(s)'), 'name' => 'tag'), 'note' => array('title' => ts('Note(s)'), 'name' => 'note'), 'communication_style_id' => array('title' => ts('Communication Style'), 'name' => 'communication_style_id')));
         }
         //Sorting fields in alphabetical order(CRM-1507)
         $fields = CRM_Utils_Array::crmArraySortByField($fields, 'title');
         CRM_Core_BAO_Cache::setItem($fields, 'contact fields', $cacheKeyString);
     }
     self::$_importableFields[$cacheKeyString] = $fields;
     if (!$isProfile) {
         if (!$status) {
             $fields = array_merge(array('do_not_import' => array('title' => ts('- do not import -'))), self::$_importableFields[$cacheKeyString]);
         } else {
             $fields = array_merge(array('' => array('title' => ts('- Contact Fields -'))), self::$_importableFields[$cacheKeyString]);
         }
     }
     return $fields;
 }
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:83,代码来源:Contact.php


示例6: getDescendentIds

 /**
  * Given a note id, get a list of the ids of all notes that are descendents of that note
  *
  * @param int $parentId
  *   Id of the given note.
  * @param array $ids
  *   (reference) one-dimensional array to store found descendent ids.
  *
  * @return array
  *   One-dimensional array containing ids of all desendent notes
  */
 public static function getDescendentIds($parentId, &$ids = array())
 {
     // get direct children of given parentId note
     $note = new CRM_Core_DAO_Note();
     $note->entity_table = 'civicrm_note';
     $note->entity_id = $parentId;
     $note->find();
     while ($note->fetch()) {
         // foreach child, add to ids list, and recurse
         $ids[] = $note->id;
         self::getDescendentIds($note->id, $ids);
     }
     return $ids;
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:25,代码来源:Note.php


示例7: _civicrm_api3_deprecated_add_formatted_param


//.........这里部分代码省略.........
        } else {
            $params['email_greeting'] = $values['email_greeting'];
        }
        return TRUE;
    }
    if (isset($values['postal_greeting'])) {
        if (!empty($params['postal_greeting_id'])) {
            $postalGreetingFilter = array('contact_type' => CRM_Utils_Array::value('contact_type', $params), 'greeting_type' => 'postal_greeting');
            $postalGreetings = CRM_Core_PseudoConstant::greeting($postalGreetingFilter);
            $params['postal_greeting'] = $postalGreetings[$params['postal_greeting_id']];
        } else {
            $params['postal_greeting'] = $values['postal_greeting'];
        }
        return TRUE;
    }
    if (isset($values['addressee'])) {
        if (!empty($params['addressee_id'])) {
            $addresseeFilter = array('contact_type' => CRM_Utils_Array::value('contact_type', $params), 'greeting_type' => 'addressee');
            $addressee = CRM_Core_PseudoConstant::addressee($addresseeFilter);
            $params['addressee'] = $addressee[$params['addressee_id']];
        } else {
            $params['addressee'] = $values['addressee'];
        }
        return TRUE;
    }
    if (isset($values['gender'])) {
        if (!empty($params['gender_id'])) {
            $genders = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id');
            $params['gender'] = $genders[$params['gender_id']];
        } else {
            $params['gender'] = $values['gender'];
        }
        return TRUE;
    }
    if (!empty($values['preferred_communication_method'])) {
        $comm = array();
        $pcm = array_change_key_case(array_flip(CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method')), CASE_LOWER);
        $preffComm = explode(',', $values['preferred_communication_method']);
        foreach ($preffComm as $v) {
            $v = strtolower(trim($v));
            if (array_key_exists($v, $pcm)) {
                $comm[$pcm[$v]] = 1;
            }
        }
        $params['preferred_communication_method'] = $comm;
        return TRUE;
    }
    // format the website params.
    if (!empty($values['url'])) {
        static $websiteFields;
        if (!is_array($websiteFields)) {
            require_once 'CRM/Core/DAO/Website.php';
            $websiteFields = CRM_Core_DAO_Website::fields();
        }
        if (!array_key_exists('website', $params) || !is_array($params['website'])) {
            $params['website'] = array();
        }
        $websiteCount = count($params['website']);
        _civicrm_api3_store_values($websiteFields, $values, $params['website'][++$websiteCount]);
        return TRUE;
    }
    // get the formatted location blocks into params - w/ 3.0 format, CRM-4605
    if (!empty($values['location_type_id'])) {
        _civicrm_api3_deprecated_add_formatted_location_blocks($values, $params);
        return TRUE;
    }
    if (isset($values['note'])) {
        // add a note field
        if (!isset($params['note'])) {
            $params['note'] = array();
        }
        $noteBlock = count($params['note']) + 1;
        $params['note'][$noteBlock] = array();
        if (!isset($fields['Note'])) {
            $fields['Note'] = CRM_Core_DAO_Note::fields();
        }
        // get the current logged in civicrm user
        $session = CRM_Core_Session::singleton();
        $userID = $session->get('userID');
        if ($userID) {
            $values['contact_id'] = $userID;
        }
        _civicrm_api3_store_values($fields['Note'], $values, $params['note'][$noteBlock]);
        return TRUE;
    }
    // Check for custom field values
    if (empty($fields['custom'])) {
        $fields['custom'] =& CRM_Core_BAO_CustomField::getFields(CRM_Utils_Array::value('contact_type', $values), FALSE, FALSE, NULL, NULL, FALSE, FALSE, FALSE);
    }
    foreach ($values as $key => $value) {
        if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
            // check if it's a valid custom field id
            if (!array_key_exists($customFieldID, $fields['custom'])) {
                return civicrm_api3_create_error('Invalid custom field ID');
            } else {
                $params[$key] = $value;
            }
        }
    }
}
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:101,代码来源:DeprecatedUtils.php


示例8: postProcess


//.........这里部分代码省略.........
         }
         if (!$this->_rtype) {
             $this->_rtype = str_replace($relationshipTypeId . '_', '', $params['relationship_type_id']);
         }
     }
     if (!$params['note']) {
         $params['note'] = 'null';
     }
     $params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], NULL, TRUE);
     $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) {
         CRM_Case_BAO_Case::createCaseRoleActivity($this->_caseId, $relationshipIds, $params['contact_check'], $this->_contactId);
     }
     $status = '';
     if ($valid) {
         CRM_Core_Session::setStatus(ts('New relationship created.', array('count' => $valid, 'plural' => '%count new relationships created.')), ts('Saved'), 'success');
     }
     if ($invalid) {
         CRM_Core_Session::setStatus(ts('%count relationship record was not created due to an invalid target contact type.', array('count' => $invalid, 'plural' => '%count relationship records were not created due to invalid target contact types.')), ts('%count invalid relationship record', array('count' => $invalid, 'plural' => '%count invalid relationship records')));
     }
     if ($duplicate) {
         CRM_Core_Session::setStatus(ts('One relationship was not created because it already exists.', array('count' => $duplicate, 'plural' => '%count relationships were not created because they already exist.')), ts('%count duplicate relationship', array('count' => $duplicate, 'plural' => '%count duplicate relationships')));
     }
     if ($saved) {
         CRM_Core_Session::setStatus(ts('Relationship record has been updated.'), ts('Saved'), 'success');
     }
     if (!empty($relationshipIds)) {
         $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);
         $params['relationship_ids'] = $relationshipIds;
     }
     // Membership for related contacts CRM-1657
     if (CRM_Core_Permission::access('CiviMember') && !$duplicate) {
         if ($this->_action & CRM_Core_Action::ADD) {
             CRM_Contact_BAO_Relationship::relatedMemberships($this->_contactId, $params, $ids, $this->_action);
         } elseif ($this->_action & CRM_Core_Action::UPDATE) {
             //fixes for CRM-7985
             //only if the relationship has been toggled to enable /disable
             if (CRM_Utils_Array::value('is_active', $params) != $this->_enabled) {
                 $active = CRM_Utils_Array::value('is_active', $params) ? CRM_Core_Action::ENABLE : CRM_Core_Action::DISABLE;
                 CRM_Contact_BAO_Relationship::disableEnableRelationship($this->_relationshipId, $active);
             }
         }
     }
     //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'];
         } elseif ($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)) {
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:67,代码来源:Relationship.php


示例9: _civicrm_add_formatted_param


//.........这里部分代码省略.........
        return true;
    }
    //CRM-4575
    if (isset($values['email_greeting'])) {
        if ($params['email_greeting_id']) {
            $emailGreetings = array();
            $emailGreetingFilter = array('contact_type' => CRM_Utils_Array::value('contact_type', $params), 'greeting_type' => 'email_greeting');
            $emailGreetings = CRM_Core_PseudoConstant::greeting($emailGreetingFilter);
            $params['email_greeting'] = $emailGreetings[$params['email_greeting_id']];
        } else {
            $params['email_greeting'] = $values['email_greeting'];
        }
        return true;
    }
    if (isset($values['postal_greeting'])) {
        if ($params['postal_greeting_id']) {
            $postalGreetings = array();
            $postalGreetingFilter = array('contact_type' => CRM_Utils_Array::value('contact_type', $params), 'greeting_type' => 'postal_greeting');
            $postalGreetings = CRM_Core_PseudoConstant::greeting($postalGreetingFilter);
            $params['postal_greeting'] = $postalGreetings[$params['postal_greeting_id']];
        } else {
            $params['postal_greeting'] = $values['postal_greeting'];
        }
        return true;
    }
    if (isset($values['addressee'])) {
        if ($params['addressee_id']) {
            $addressee = array();
            $addresseeFilter = array('contact_type' => CRM_Utils_Array::value('contact_type', $params), 'greeting_type' => 'addressee');
            $addressee = CRM_Core_PseudoConstant::addressee($addresseeFilter);
            $params['addressee'] = $addressee[$params['addressee_id']];
        } else {
            $params['addressee'] = $values['addressee'];
        }
        return true;
    }
    if (isset($values['gender'])) {
        if ($params['gender_id']) {
            $genders = array();
            $genders = CRM_Core_PseudoConstant::gender();
            $params['gender'] = $genders[$params['gender_id']];
        } else {
            $params['gender'] = $values['gender'];
        }
        return true;
    }
    if (isset($values['preferred_communication_method'])) {
        $comm = array();
        $preffComm = array();
        $pcm = array();
        $pcm = array_change_key_case(array_flip(CRM_Core_PseudoConstant::pcm()), CASE_LOWER);
        $preffComm = explode(',', $values['preferred_communication_method']);
        foreach ($preffComm as $v) {
            $v = strtolower(trim($v));
            if (array_key_exists($v, $pcm)) {
                $comm[$pcm[$v]] = 1;
            }
        }
        $params['preferred_communication_method'] = $comm;
        return true;
    }
    // get the formatted location blocks into params - w/ 3.0 format, CRM-4605
    if (CRM_Utils_Array::value('location_type_id', $values)) {
        _civicrm_add_formatted_location_blocks($values, $params);
        return true;
    }
    if (isset($values['note'])) {
        /* add a note field */
        if (!isset($params['note'])) {
            $params['note'] = array();
        }
        $noteBlock = count($params['note']) + 1;
        $params['note'][$noteBlock] = array();
        if (!isset($fields['Note'])) {
            $fields['Note'] = CRM_Core_DAO_Note::fields();
        }
        // get the current logged in civicrm user
        $session =& CRM_Core_Session::singleton();
        $userID = $session->get('userID');
        if ($userID) {
            $values['contact_id'] = $userID;
        }
        _civicrm_store_values($fields['Note'], $values, $params['note'][$noteBlock]);
        return true;
    }
    /* Check for custom field values */
    if ($fields['custom'] == null) {
        $fields['custom'] =& CRM_Core_BAO_CustomField::getFields($values['contact_type']);
    }
    foreach ($values as $key => $value) {
        if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
            /* check if it's a valid custom field id */
            if (!array_key_exists($customFieldID, $fields['custom'])) {
                return civicrm_create_error('Invalid custom field ID');
            } else {
                $params[$key] = $value;
            }
        }
    }
}
开发者ID:ksecor,项目名称:civicrm,代码行数:101,代码来源:utils.php


示例10: _crm_add_formatted_param


//.........这里部分代码省略.........
            _crm_store_values($fields['Email'], $values, $params['location'][$locBlock]['email'][$emailBlock]);
            if ($emailBlock == 1) {
                $params['location'][$locBlock]['email'][$emailBlock]['is_primary'] = true;
            }
            return true;
        }
        /* if this is an IM value, create a new block */
        if (isset($values['im'])) {
            if (!isset($params['location'][$locBlock]['im'])) {
                $params['location'][$locBlock]['im'] = array();
            }
            /* add a new IM block */
            $imBlock = count($params['location'][$locBlock]['im']) + 1;
            $params['location'][$locBlock]['im'][$imBlock] = array();
            if (!isset($fields['IM'])) {
                $fields['IM'] = CRM_Core_DAO_IM::fields();
            }
            _crm_store_values($fields['IM'], $values, $params['location'][$locBlock]['im'][$imBlock]);
            if ($imBlock == 1) {
                $params['location'][$locBlock]['im'][$imBlock]['is_primary'] = true;
            }
            return true;
        }
        /* Otherwise we must be an address */
        if (!isset($params['location'][$locBlock]['address'])) {
            $params['location'][$locBlock]['address'] = array();
        }
        if (!isset($fields['Address'])) {
            $fields['Address'] = CRM_Core_DAO_Address::fields();
        }
        _crm_store_values($fields['Address'], $values, $params['location'][$locBlock]['address']);
        $ids = array('county', 'country', 'state_province', 'supplemental_address_1', 'supplemental_address_2', 'StateProvince.name');
        foreach ($ids as $id) {
            if (array_key_exists($id, $values)) {
                $params['location'][$locBlock]['address'][$id] = $values[$id];
            }
        }
        return true;
    }
    if (isset($values['note'])) {
        /* add a note field */
        if (!isset($params['note'])) {
            $params['note'] = array();
        }
        $noteBlock = count($params['note']) + 1;
        $params['note'][$noteBlock] = array();
        if (!isset($fields['Note'])) {
            $fields['Note'] = CRM_Core_DAO_Note::fields();
        }
        _crm_store_values($fields['Note'], $values, $params['note'][$noteBlock]);
        return true;
    }
    /* Check for custom field values */
    if ($fields['custom'] == null) {
        $fields['custom'] =& CRM_Core_BAO_CustomField::getFields($values['contact_type']);
    }
    foreach ($values as $key => $value) {
        if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
            /* check if it's a valid custom field id */
            if (!array_key_exists($customFieldID, $fields['custom'])) {
                return _crm_error('Invalid custom field ID');
            }
            if (!isset($params['custom'])) {
                $params['custom'] = array();
            }
            // fixed for Import
            $newMulValues = array();
            if ($fields['custom'][$customFieldID][3] == 'CheckBox' || $fields['custom'][$customFieldID][3] == 'Multi-Select') {
                $value = str_replace("|", ",", $value);
                $mulValues = explode(',', $value);
                $custuomOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, true);
                foreach ($mulValues as $v1) {
                    foreach ($custuomOption as $v2) {
                        if (strtolower($v2['label']) == strtolower(trim($v1))) {
                            $newMulValues[] = $v2['value'];
                        }
                    }
                }
                $value = implode(CRM_CORE_BAO_CUSTOMOPTION_VALUE_SEPERATOR, $newMulValues);
            } else {
                if ($fields['custom'][$customFieldID][3] == 'Select' || $fields['custom'][$customFieldID][3] == 'Radio') {
                    $custuomOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, true);
                    foreach ($custuomOption as $v2) {
                        if (strtolower($v2['label']) == strtolower(trim($value))) {
                            $value = $v2['value'];
                            break;
                        }
                    }
                }
            }
            $customBlock = count($params['custom']) + 1;
            $params['custom'][$customBlock] = array('custom_field_id' => $customFieldID, 'value' => $value, 'type' => $fields['custom'][$customFieldID][2], 'name' => $fields['custom'][$customFieldID][0]);
        }
    }
    /* Finally, check for contact fields */
    if (!isset($fields['Contact'])) {
        $fields['Contact'] =& CRM_Contact_DAO_Contact::fields();
    }
    _crm_store_values($fields['Contact'], $values, $params);
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:101,代码来源:utils.php


示例11: array

 /**
  * combine all the importable fields from the lower levels object
  *
  * The ordering is important, since currently we do not have a weight
  * scheme. Adding weight is super important and should be done in the
  * next week or so, before this can be called complete.
  *
  * @param int     $contactType contact Type
  * @param boolean $status  status is used to manipulate first title
  * @param boolean $showAll if true returns all fields (includes disabled fields)
  * @param boolean $isProfile if its profile mode
  *
  * @return array array of importable Fields
  * @access public
  */
 function &importableFields($contactType = 'Individual', $status = false, $showAll = false, $isProfile = false)
 {
     if (empty($contactType)) {
         $contactType = 'All';
     }
     $cacheKeyString = "importableFields {$contactType}";
     $cacheKeyString .= $status ? "_1" : "_0";
     $cacheKeyString .= $showAll ? "_1" : "_0";
     $cacheKeyString .= $isProfile ? "_1" : "_0";
     if (!self::$_importableFields || !CRM_Utils_Array::value($cacheKeyString, self::$_importableFields)) {
         if (!self::$_importableFields) {
             self::$_importableFields = array();
         }
         // check if we can retrieve from database cache
         require_once 'CRM/Core/BAO/Cache.php';
         $fields =& CRM_Core_BAO_Cache::getItem('contact fields', $cacheKeyString);
         if (!$fields) {
             $fields = CRM_Contact_DAO_Contact::import();
             require_once "CRM/Core/OptionValue.php";
             // get the fields thar are meant for contact types
             if (in_array($contactType, array('Individual', 'Household', 'Organization', 'All'))) {
                 $fields = array_merge($fields, CRM_Core_OptionValue::getFields('', $contactType));
             }
             $locationFields = array_merge(CRM_Core_DAO_Address::import(), CRM_Core_DAO_Phone::import(), CRM_Core_DAO_Email::import(), CRM_Core_DAO_IM::import(true), CRM_Core_DAO_OpenID::import());
             foreach ($locationFields as $key => $field) {
                 $locationFields[$key]['hasLocationType'] = true;
             }
             $fields = array_merge($fields, $locationFields);
             $fields = array_merge($fields, CRM_Contact_DAO_Contact::import());
             $fields = array_merge($fields, CRM_Core_DAO_Note::import());
             if ($contactType != 'All') {
                 $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($contactType, $showAll, true));
                 //unset the fields, which are not related to their
                 //contact type.
                 $commonValues = array('Individual' => array('household_name', 'legal_name', 'sic_code', 'organization_name'), 'Household' => array('first_name', 'middle_name', 'last_name', 'job_title', 'gender_id', 'birth_date', 'organization_name', 'legal_name', 'legal_identifier', 'sic_code', 'home_URL', 'is_deceased', 'deceased_date'), 'Organization' => array('first_name', 'middle_name', 'last_name', 'job_title', 'gender_id', 'birth_date', 'household_name', 'email_greeting', 'email_greeting_custom', 'postal_greeting', 'postal_greeting_custom', 'is_deceased', 'deceased_date'));
                 foreach ($commonValues[$contactType] as $value) {
                     unset($fields[$value]);
                 }
             } else {
                 foreach (array('Individual', 'Household', 'Organization') as $type) {
                     $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport($type, $showAll));
                 }
             }
             if ($isProfile) {
                 $fields = array_merge($fields, array('group' => array('title' => ts('Group(s)')), 'tag' => array('title' => ts('Tag(s)')), 'note' => array('title' => ts('Note(s)'))));
             }
             //Sorting fields in alphabetical order(CRM-1507)
             foreach ($fields as $k => $v) {
                 $sortArray[$k] = $v['title'];
             }
             asort($sortArray);
             $fields = array_merge($sortArray, $fields);
             CRM_Core_BAO_Cache::setItem($fields, 'contact fields', $cacheKeyString);
         }
         self::$_importableFields[$cacheKeyString] = $fields;
     }
     if (!$isProfile) {
         if (!$status) {
             $fields = array_merge(array('do_not_import' => array('title' => ts('- do not import -'))), self::$_importableFields[$cacheKeyString]);
         } else {
             $fields = array_merge(array('' => array('title' => ts('- Contact Fields -'))), self::$_importableFields[$cacheKeyString]);
         }
     }
     return $fields;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:80,代码来源:Contact.php


示例12: rebook

 /**
  * Will rebook all given contributions to the given target contact
  *
  * @param $contribution_ids  an array of contribution IDs
  * @param $contact_id        the target contact ID
  */
 static function rebook($contribution_ids, $contact_id, $redirect_url = NULL)
 {
     $contact_id = (int) $contact_id;
     $excludeList = array('id', 'contribution_id', 'trxn_id', 'invoice_id', 'cancel_date', 'cancel_reason', 'address_id', 'contribution_contact_id', 'contribution_status_id');
     $cancelledStatus = CRM_Core_OptionGroup::getValue('contribution_status', 'Cancelled', 'name');
     $completedStatus = CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name');
     $contribution_fieldKeys = CRM_Contribute_DAO_Contribution::fieldKeys();
     $sepa_ooff_payment_id = CRM_Core_OptionGroup::getValue('payment_instrument', 'OOFF', 'name');
     $contribution_count = count($contribution_ids);
     $session = CRM_Core_Session::singleton();
     $rebooked = 0;
     foreach ($contribution_ids as $contributionId) {
         $params = array('version' => 3, 'sequential' => 1, 'id' => $contributionId);
         $contribution = civicrm_api('Contribution', 'getsingle', $params);
         if (empty($contribution['is_error'])) {
             // contribution exists
             // cancel contribution
             $params = array('version' => 3, 'contribution_status_id' => $cancelledStatus, 'cancel_reason' => ts('Rebooked to CiviCRM ID %1', array(1 => $contact_id, 'domain' => 'de.systopia.donrec')), 'cancel_date' => date('YmdHis'), 'currency' => $contribution['currency'], 'id' => $contribution['id']);
             $cancelledContribution = civicrm_api('Contribution', 'create', $params);
             if (!empty($cancelledContribution['is_error']) && !empty($cancelledContribution['error_message'])) {
                 CRM_Core_Session::setStatus($cancelledContribution['error_message'], ts("Error", array('domain' => 'de.systopia.donrec')), "error");
             }
             // Now compile $attributes, taking the exclusionList into account
             $attributes = array('version' => 3, 'contribution_contact_id' => $contact_id, 'contribution_status_id' => $completedStatus, 'payment_instrument_id' => CRM_Core_OptionGroup::getValue('payment_instrument', $contribution['instrument_id'], 'id'));
             foreach ($contribution as $key => $value) {
                 if (!in_array($key, $excludeList) && in_array($key, $contribution_fieldKeys)) {
                     // to be sure that this keys really exists
                     $attributes[$key] = $value;
                 }
                 if (strstr($key, 'custom')) {
                     // get custom fields
                     // load custom field spec for exception handling
                     $custom_field_id = substr($key, 7);
                     $custom_field = civicrm_api('CustomField', 'getsingle', array('id' => $custom_field_id, 'version' => 3));
                     // Exception 1: dates are not properly formatted
                     if ($custom_field['data_type'] == 'Date') {
                         if (!empty($value)) {
                             $value = date('YmdHis', strtotime($value));
                         }
                     }
                     $attributes[$key] = $value;
                 }
             }
             // create new contribution
             $newContribution = civicrm_api('Contribution', 'create', $attributes);
             if (!empty($newContribution['is_error']) && !empty($newContribution['error_message'])) {
                 CRM_Core_Session::setStatus($newContribution['error_message'], ts("Error", array('domain' => 'de.systopia.donrec')), "error");
             }
             // Exception handling for SEPA OOFF payments (org.project60.sepa extension)
             if (!empty($sepa_ooff_payment_id) && $attributes['payment_instrument_id'] == $sepa_ooff_payment_id) {
                 CRM_Donrec_Form_Task_Rebook::fixOOFFMandate($contribution, $newContribution['id']);
             }
             // create rebook note
             $params = array('version' => 3, 'sequential' => 1, 'note' => ts('Rebooked from CiviCRM ID %1', array(1 => $contribution['contact_id'], 'domain' => 'de.systopia.donrec')), 'entity_table' => 'civicrm_contribution', 'entity_id' => $newContribution['id']);
             $result = civicrm_api('Note', 'create', $params);
             // move all notes from the old contribution
             $notes = civicrm_api('Note', 'get', array('entity_id' => $contributionId, 'entity_table' => 'civicrm_contribution', 'version' => 3));
             if (!empty($notes['is_error'])) {
                 CRM_Core_Error::debug_log_message("de.systopia.donrec: Error while reading notes: " . $notes['error_message']);
             } else {
                 foreach ($notes['values'] as $note) {
                     $dao = new CRM_Core_DAO_Note();
                     $dao->id = $note['id'];
                     $dao->entity_id = $newContribution['id'];
                     $dao->save();
                 }
             }
             $rebooked += 1;
         }
     }
     if ($rebooked == $contribution_count) {
         CRM_Core_Session::setStatus(ts('%1 contribution(s) successfully rebooked!', array(1 => $contribution_count, 'domain' => 'de.systopia.donrec')), ts('Successfully rebooked!'), 'success');
     } else {
         CRM_Core_Error::debug_log_message("de.systopia.donrec: Only {$rebooked} of {$contribution_count} contributions rebooked.", array('domain' => 'de.systopia.donrec'));
         CRM_Core_Session::setStatus(ts('Please check your data and try again', array(1 => $contribution_count)), ts('Nothing rebooked!'), 'warning');
         CRM_Utils_System::redirect($redirect_url);
     }
 }
开发者ID:systopia,项目名称:de.systopia.donrec,代码行数:84,

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP CRM_Core_DAO_OptionGroup类代码示例发布时间:2022-05-20
下一篇:
PHP CRM_Core_DAO_Mapping类代码示例发布时间:2022-05-20
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap