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


PHP CRM_Contact_DAO_Contact类代码示例

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


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

示例1: preProcess

 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     // reset action from the session
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'update');
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     $rcid = CRM_Utils_Request::retrieve('rcid', 'Positive', $this);
     $rcid = $rcid ? "&id={$rcid}" : '';
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/user', "reset=1{$rcid}"));
     if ($this->_contactId) {
         $contact = new CRM_Contact_DAO_Contact();
         $contact->id = $this->_contactId;
         if (!$contact->find(TRUE)) {
             CRM_Core_Error::statusBounce(ts('contact does not exist: %1', array(1 => $this->_contactId)));
         }
         $this->_contactType = $contact->contact_type;
         // check for permissions
         if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
             CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to edit this contact.'));
         }
         list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($this->_contactId);
         CRM_Utils_System::setTitle($displayName, $contactImage . ' ' . $displayName);
     } else {
         CRM_Core_Error::statusBounce(ts('Could not get a contact_id and/or contact_type'));
     }
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:32,代码来源:RelatedContact.php

示例2: validateData

 function validateData(&$input, &$ids, &$objects, $required = true)
 {
     // make sure contact exists and is valid
     require_once 'CRM/Contact/DAO/Contact.php';
     $contact = new CRM_Contact_DAO_Contact();
     $contact->id = $ids['contact'];
     if (!$contact->find(true)) {
         CRM_Core_Error::debug_log_message("Could not find contact record: {$ids['contact']}");
         echo "Failure: Could not find contact record: {$ids['contact']}<p>";
         return false;
     }
     // make sure contribution exists and is valid
     require_once 'CRM/Contribute/DAO/Contribution.php';
     $contribution = new CRM_Contribute_DAO_Contribution();
     $contribution->id = $ids['contribution'];
     if (!$contribution->find(true)) {
         CRM_Core_Error::debug_log_message("Could not find contribution record: {$contributionID}");
         echo "Failure: Could not find contribution record for {$contributionID}<p>";
         return false;
     }
     $contribution->receive_date = CRM_Utils_Date::isoToMysql($contribution->receive_date);
     $objects['contact'] =& $contact;
     $objects['contribution'] =& $contribution;
     if (!$this->loadObjects($input, $ids, $objects, $required)) {
         return false;
     }
     return true;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:28,代码来源:BaseIPN.php

示例3: validateData

 function validateData(&$input, &$ids, &$objects, $required = TRUE, $paymentProcessorID = NULL)
 {
     // make sure contact exists and is valid
     $contact = new CRM_Contact_DAO_Contact();
     $contact->id = $ids['contact'];
     if (!$contact->find(TRUE)) {
         CRM_Core_Error::debug_log_message("Could not find contact record: {$ids['contact']}");
         echo "Failure: Could not find contact record: {$ids['contact']}<p>";
         return FALSE;
     }
     // make sure contribution exists and is valid
     $contribution = new CRM_Contribute_DAO_Contribution();
     $contribution->id = $ids['contribution'];
     if (!$contribution->find(TRUE)) {
         CRM_Core_Error::debug_log_message("Could not find contribution record: " . $contribution->id);
         echo "Failure: Could not find contribution record for {$contribution->id}<p>";
         return FALSE;
     }
     $contribution->receive_date = CRM_Utils_Date::isoToMysql($contribution->receive_date);
     $objects['contact'] =& $contact;
     $objects['contribution'] =& $contribution;
     if (!$this->loadObjects($input, $ids, $objects, $required, $paymentProcessorID)) {
         return FALSE;
     }
     return TRUE;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:26,代码来源:BaseIPN.php

示例4: tearDownAfterClass

 /**
  * Both testDummy1 and testDummy2 have been created at some point (as part of the test runs),
  * but all the data was rolled-back
  *
  * @throws \Exception
  */
 public static function tearDownAfterClass()
 {
     if (!is_numeric(self::$contactIds['testDummy1'])) {
         throw new \Exception("Uh oh! The static \$contactIds does not include testDummy1! Did the test fail to execute?");
     }
     if (!is_numeric(self::$contactIds['testDummy2'])) {
         throw new \Exception("Uh oh! The static \$contactIds does not include testDummy2! Did the test fail to execute?");
     }
     $dao = new \CRM_Contact_DAO_Contact();
     $dao->id = self::$contactIds['testDummy1'];
     if ($dao->find()) {
         throw new \Exception("Uh oh! testDummy1 still exists!");
     }
     $dao = new \CRM_Contact_DAO_Contact();
     $dao->id = self::$contactIds['testDummy2'];
     if ($dao->find()) {
         throw new \Exception("Uh oh! testDummy2 still exists!");
     }
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:25,代码来源:ExampleTransactionalTest.php

示例5: retrieve

 /**
  * Get a list of Commendations matching the params, where each param key is:
  *  1. the key of a field in civicrm_activity, except for activity_type_id
  *  2. the key of a custom field on the activity (volunteer_project_id)
  *  3. the key of a field in civicrm_contact
  *
  * @param array $params
  * @return array of CRM_Volunteer_BAO_Project objects
  */
 public static function retrieve(array $params)
 {
     $activity_fields = CRM_Activity_DAO_Activity::fields();
     $contact_fields = CRM_Contact_DAO_Contact::fields();
     $custom_fields = self::getCustomFields();
     // This is the "real" id
     $activity_fields['id'] = $activity_fields['activity_id'];
     unset($activity_fields['activity_id']);
     // enforce restrictions on parameters
     $allowed_params = array_flip(array_merge(array_keys($activity_fields), array_keys($contact_fields), array_keys($custom_fields)));
     unset($allowed_params['activity_type_id']);
     $filtered_params = array_intersect_key($params, $allowed_params);
     $custom_group = self::getCustomGroup();
     $customTableName = $custom_group['table_name'];
     foreach ($custom_fields as $name => $field) {
         $selectClause[] = "{$customTableName}.{$field['column_name']} AS {$name}";
     }
     $customSelect = implode(', ', $selectClause);
     $activityContactTypes = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
     $targetID = CRM_Utils_Array::key('Activity Targets', $activityContactTypes);
     $placeholders = array(1 => array($targetID, 'Integer'), 2 => array(self::getActivityTypeId(), 'Integer'));
     $i = count($placeholders) + 1;
     $where = array();
     $whereClause = NULL;
     foreach ($filtered_params as $key => $value) {
         if (CRM_Utils_Array::value($key, $activity_fields)) {
             $dataType = CRM_Utils_Type::typeToString($activity_fields[$key]['type']);
             $fieldName = $activity_fields[$key]['name'];
             $tableName = CRM_Activity_DAO_Activity::$_tableName;
         } elseif (CRM_Utils_Array::value($key, $contact_fields)) {
             $dataType = CRM_Utils_Type::typeToString($contact_fields[$key]['type']);
             $fieldName = $contact_fields[$key]['name'];
             $tableName = CRM_Contact_DAO_Contact::$_tableName;
         } elseif (CRM_Utils_Array::value($key, $custom_fields)) {
             $dataType = $custom_fields[$key]['data_type'];
             $fieldName = $custom_fields[$key]['column_name'];
             $tableName = $customTableName;
         }
         $where[] = "{$tableName}.{$fieldName} = %{$i}";
         $placeholders[$i] = array($value, $dataType);
         $i++;
     }
     if (count($where)) {
         $whereClause = 'AND ' . implode("\nAND ", $where);
     }
     $query = "\n      SELECT\n        civicrm_activity.*,\n        {$customSelect},\n        activityContact.contact_id AS volunteer_contact_id,\n        volunteer_contact.sort_name AS volunteer_sort_name,\n        volunteer_contact.display_name AS volunteer_display_name\n      FROM civicrm_activity\n      INNER JOIN civicrm_activity_contact activityContact\n        ON (\n          activityContact.activity_id = civicrm_activity.id\n          AND activityContact.record_type_id = %1\n        )\n      INNER JOIN civicrm_contact volunteer_contact\n        ON activityContact.contact_id = volunteer_contact.id\n      INNER JOIN {$customTableName}\n        ON ({$customTableName}.entity_id = civicrm_activity.id)\n      WHERE civicrm_activity.activity_type_id = %2\n      {$whereClause}\n    ";
     $dao = CRM_Core_DAO::executeQuery($query, $placeholders);
     $rows = array();
     while ($dao->fetch()) {
         $rows[$dao->id] = $dao->toArray();
     }
     return $rows;
 }
开发者ID:adam-edison,项目名称:org.civicrm.volunteer,代码行数:62,代码来源:Commendation.php

示例6: browse

 /**
  * This function is called when action is browse
  *
  * return null
  * @access public
  */
 function browse()
 {
     $note =& new CRM_Core_DAO_Note();
     $note->entity_table = 'civicrm_contact';
     $note->entity_id = $this->_contactId;
     $note->orderBy('modified_date desc');
     $values = array();
     $links =& CRM_Contact_Page_View_Note::links();
     $action = array_sum(array_keys($links)) & CRM_Core_Action::mask($this->_permission);
     $note->find();
     while ($note->fetch()) {
         $values[$note->id] = array();
         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));
         $contact = new CRM_Contact_DAO_Contact();
         $contact->id = $note->contact_id;
         $contact->find();
         $contact->fetch();
         $values[$note->id]['createdBy'] = $contact->display_name;
     }
     $this->assign('notes', $values);
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:28,代码来源:Note.php

示例7: preProcess

 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 function preProcess()
 {
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('cdType', FALSE);
     if ($this->_cdType) {
         $this->assign('cdType', TRUE);
         return CRM_Custom_Form_CustomData::preProcess($this);
     }
     $this->_caseId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_currentlyViewedContactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     if ($this->_action & CRM_Core_Action::ADD && !$this->_currentlyViewedContactId) {
         // check for add contacts permissions
         if (!CRM_Core_Permission::check('add contacts')) {
             CRM_Utils_System::permissionDenied();
             return;
         }
     }
     //CRM-4418
     if (!CRM_Core_Permission::checkActionPermission('CiviCase', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     if ($this->_action & CRM_Core_Action::DELETE || $this->_action & CRM_Core_Action::RENEW) {
         return TRUE;
     }
     if (!$this->_caseId) {
         $caseAttributes = array('case_type' => CRM_Case_PseudoConstant::caseType(), 'case_status' => CRM_Case_PseudoConstant::caseStatus(), 'encounter_medium' => CRM_Case_PseudoConstant::encounterMedium());
         foreach ($caseAttributes as $key => $values) {
             if (empty($values)) {
                 CRM_Core_Error::fatal(ts('You do not have any active %1', array(1 => str_replace('_', ' ', $key))));
                 break;
             }
         }
     }
     if ($this->_action & CRM_Core_Action::ADD) {
         $this->_activityTypeId = CRM_Core_OptionGroup::getValue('activity_type', 'Open Case', 'name');
         if (!$this->_activityTypeId) {
             CRM_Core_Error::fatal(ts('The Open Case activity type is missing or disabled. Please have your site administrator check Administer > Option Lists > Activity Types for the CiviCase component.'));
         }
     }
     //check for case permissions.
     if (!CRM_Case_BAO_Case::accessCiviCase()) {
         CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
     }
     if ($this->_action & CRM_Core_Action::ADD && (!CRM_Core_Permission::check('access all cases and activities') && !CRM_Core_Permission::check('add cases'))) {
         CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
     }
     if ($this->_activityTypeFile = CRM_Activity_BAO_Activity::getFileForActivityTypeId($this->_activityTypeId, 'Case')) {
         $this->assign('activityTypeFile', $this->_activityTypeFile);
     }
     $details = CRM_Case_PseudoConstant::caseActivityType(FALSE);
     CRM_Utils_System::setTitle($details[$this->_activityTypeId]['label']);
     $this->assign('activityType', $details[$this->_activityTypeId]['label']);
     $this->assign('activityTypeDescription', $details[$this->_activityTypeId]['description']);
     if (isset($this->_currentlyViewedContactId)) {
         $contact = new CRM_Contact_DAO_Contact();
         $contact->id = $this->_currentlyViewedContactId;
         if (!$contact->find(TRUE)) {
             CRM_Core_Error::statusBounce(ts('Client contact does not exist: %1', array(1 => $this->_currentlyViewedContactId)));
         }
         $this->assign('clientName', $contact->display_name);
     }
     $session = CRM_Core_Session::singleton();
     $this->_currentUserId = $session->get('userID');
     //when custom data is included in this page
     CRM_Custom_Form_CustomData::preProcess($this, NULL, $this->_activityTypeId, 1, 'Activity');
     eval("CRM_Case_Form_Activity_{$this->_activityTypeFile}::preProcess( \$this );");
     $activityGroupTree = $this->_groupTree;
     // for case custom fields to populate with defaults
     if (CRM_Utils_Array::value('hidden_custom', $_POST)) {
         CRM_Custom_Form_CustomData::preProcess($this);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
     }
     // so that grouptree is not populated with case fields, since the grouptree is used
     // for populating activity custom fields.
     $this->_groupTree = $activityGroupTree;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:82,代码来源:Case.php

示例8: import

 /**
  * handle the values in import mode
  *
  * @param int $onDuplicate the code for what action to take on duplicates
  * @param array $values the array of values belonging to this line
  *
  * @return boolean      the result of this processing
  * @access public
  */
 function import($onDuplicate, &$values, $doGeocodeAddress = false)
 {
     $config =& CRM_Core_Config::singleton();
     $this->_unparsedStreetAddressContacts = array();
     if (!$doGeocodeAddress) {
         // CRM-5854, reset the geocode method to null to prevent geocoding
         $config->geocodeMethod = null;
     }
     // first make sure this is a valid line
     //$this->_updateWithId = false;
     $response = $this->summary($values);
     $statusFieldName = $this->_statusFieldName;
     if ($response != CRM_Import_Parser::VALID) {
         $importRecordParams = array($statusFieldName => 'INVALID', "{$statusFieldName}Msg" => "Invalid (Error Code: {$response})");
         $this->updateImportRecord($values[count($values) - 1], $importRecordParams);
         return $response;
     }
     $params =& $this->getActiveFieldParams();
     $formatted = array('contact_type' => $this->_contactType);
     static $contactFields = null;
     if ($contactFields == null) {
         require_once "CRM/Contact/DAO/Contact.php";
         $contactFields =& CRM_Contact_DAO_Contact::import();
     }
     //check if external identifier exists in database
     if (CRM_Utils_Array::value('external_identifier', $params) && (CRM_Utils_Array::value('id', $params) || in_array($onDuplicate, array(CRM_Import_Parser::DUPLICATE_SKIP, CRM_Import_Parser::DUPLICATE_NOCHECK)))) {
         require_once "CRM/Contact/BAO/Contact.php";
         if ($internalCid = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params['external_identifier'], 'id', 'external_identifier')) {
             if ($internalCid != CRM_Utils_Array::value('id', $params)) {
                 $errorMessage = ts('External Identifier already exists in database.');
                 array_unshift($values, $errorMessage);
                 $importRecordParams = array($statusFieldName => 'ERROR', "{$statusFieldName}Msg" => $errorMessage);
                 $this->updateImportRecord($values[count($values) - 1], $importRecordParams);
                 return CRM_Import_Parser::ERROR;
             }
         }
     }
     if (!empty($this->_contactSubType)) {
         $params['contact_sub_type'] = $this->_contactSubType;
     }
     if ($subType = CRM_Utils_Array::value('contact_sub_type', $params)) {
         if (CRM_Contact_BAO_ContactType::isExtendsContactType($subType, $this->_contactType, false, 'label')) {
             $subTypes = CRM_Contact_BAO_ContactType::subTypePairs($this->_contactType, false, null);
             $params['contact_sub_type'] = array_search($subType, $subTypes);
         } elseif (!CRM_Contact_BAO_ContactType::isExtendsContactType($subType, $this->_contactType)) {
             $message = "Mismatched or Invalid Contact SubType.";
             array_unshift($values, $message);
             return CRM_Import_Parser::NO_MATCH;
         }
     }
     //get contact id to format common data in update/fill mode,
     //if external identifier is present, CRM-4423
     if ($this->_updateWithId && !CRM_Utils_Array::value('id', $params) && CRM_Utils_Array::value('external_identifier', $params)) {
         if ($cid = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params['external_identifier'], 'id', 'external_identifier')) {
             $formatted['id'] = $cid;
         }
     }
     //format common data, CRM-4062
     $this->formatCommonData($params, $formatted, $contactFields);
     $relationship = false;
     $createNewContact = true;
     // Support Match and Update Via Contact ID
     if ($this->_updateWithId) {
         $createNewContact = false;
         if (!CRM_Utils_Array::value('id', $params) && CRM_Utils_Array::value('external_identifier', $params)) {
             if ($cid) {
                 $params['id'] = $cid;
             } else {
                 //update contact if dedupe found contact id, CRM-4148
                 $dedupeParams = $formatted;
                 //special case to check dedupe if external id present.
                 //if we send external id dedupe will stop.
                 unset($dedupeParams['external_identifier']);
                 $checkDedupe = _civicrm_duplicate_formatted_contact($dedupeParams);
                 if (civicrm_duplicate($checkDedupe)) {
                     $matchingContactIds = explode(',', $checkDedupe['error_message']['params'][0]);
                     if (count($matchingContactIds) == 1) {
                         $params['id'] = array_pop($matchingContactIds);
                     } else {
                         $message = "More than one matching contact found for given criteria.";
                         array_unshift($values, $message);
                         $this->_retCode = CRM_Import_Parser::NO_MATCH;
                     }
                 } else {
                     $createNewContact = true;
                 }
             }
         }
         $error = _civicrm_duplicate_formatted_contact($formatted);
         if (civicrm_duplicate($error)) {
             $matchedIDs = explode(',', $error['error_message']['params'][0]);
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:voipdev,代码行数:101,代码来源:Contact.php

示例9: clearCurrentEmployer

 /**
  * Delete current employer relationship.
  *
  * @param int $id
  * @param int $action
  *
  * @return CRM_Contact_DAO_Relationship
  */
 public static function clearCurrentEmployer($id, $action)
 {
     $relationship = new CRM_Contact_DAO_Relationship();
     $relationship->id = $id;
     $relationship->find(TRUE);
     //to delete relationship between household and individual                                                                                          \
     //or between individual and organization
     if ($action & CRM_Core_Action::DISABLE || $action & CRM_Core_Action::DELETE) {
         $relTypes = CRM_Utils_Array::index(array('name_a_b'), CRM_Core_PseudoConstant::relationshipType('name'));
         if (isset($relTypes['Employee of']) && $relationship->relationship_type_id == $relTypes['Employee of']['id'] || isset($relTypes['Household Member of']) && $relationship->relationship_type_id == $relTypes['Household Member of']['id']) {
             $sharedContact = new CRM_Contact_DAO_Contact();
             $sharedContact->id = $relationship->contact_id_a;
             $sharedContact->find(TRUE);
             // CRM-15881 UPDATES
             // changed FROM "...relationship->relationship_type_id == 4..." TO "...relationship->relationship_type_id == 5..."
             // As the system should be looking for type "employer of" (id 5) and not "sibling of" (id 4)
             // As suggested by @davecivicrm, the employee relationship type id is fetched using the CRM_Core_DAO::getFieldValue() class and method, since these ids differ from system to system.
             $employerRelTypeId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', 'Employee of', 'id', 'name_a_b');
             if ($relationship->relationship_type_id == $employerRelTypeId && $relationship->contact_id_b == $sharedContact->employer_id) {
                 CRM_Contact_BAO_Contact_Utils::clearCurrentEmployer($relationship->contact_id_a);
             }
         }
     }
     return $relationship;
 }
开发者ID:scardinius,项目名称:civicrm-core,代码行数:33,代码来源:Relationship.php

示例10: permissionClause

 /**
  * Construct a WHERE clause to handle permissions to $object_*
  *
  * @param array ref $tables -   Any tables that may be needed in the FROM
  * @param string $operation -   The operation being attempted
  * @param string $object_table -    The table of the object in question
  * @param int $object_id    -   The ID of the object in question
  * @param int $acl_id   -       If it's a grant/revoke operation, the ACL ID
  * @param boolean $acl_role -  For grant operations, this flag determines if we're granting a single acl (false) or an entire group.
  *
  * @return string           -   The WHERE clause, or 0 on failure
  * @access public
  * @static
  */
 public static function permissionClause(&$tables, $operation, $object_table = NULL, $object_id = NULL, $acl_id = NULL, $acl_role = FALSE)
 {
     $dao = new CRM_ACL_DAO_ACL();
     $t = array('ACL' => self::getTableName(), 'ACLRole' => 'civicrm_acl_role', 'ACLEntityRole' => CRM_ACL_DAO_EntityRole::getTableName(), 'Contact' => CRM_Contact_DAO_Contact::getTableName(), 'Group' => CRM_Contact_DAO_Group::getTableName(), 'GroupContact' => CRM_Contact_DAO_GroupContact::getTableName());
     $session = CRM_Core_Session::singleton();
     $contact_id = $session->get('userID');
     $where = " {$t['ACL']}.operation = '" . CRM_Utils_Type::escape($operation, 'String') . "'";
     /* Include clause if we're looking for a specific table/id permission */
     if (!empty($object_table)) {
         $where .= " AND ( {$t['ACL']}.object_table IS null\n                         OR ({$t['ACL']}.object_table   = '" . CRM_Utils_Type::escape($object_table, 'String') . "'";
         if (!empty($object_id)) {
             $where .= " AND ({$t['ACL']}.object_id IS null\n                            OR {$t['ACL']}.object_id = " . CRM_Utils_Type::escape($object_id, 'Integer') . ')';
         }
         $where .= '))';
     }
     /* Include clause if we're granting an ACL or ACL Role */
     if (!empty($acl_id)) {
         $where .= " AND ({$t['ACL']}.acl_id IS null\n                        OR {$t['ACL']}.acl_id   = " . CRM_Utils_Type::escape($acl_id, 'Integer') . ')';
         if ($acl_role) {
             $where .= " AND {$t['ACL']}.acl_table = '{$t['ACLRole']}'";
         } else {
             $where .= " AND {$t['ACL']}.acl_table = '{$t['ACL']}'";
         }
     }
     $query = array();
     /* Query for permissions granted to all contacts in the domain */
     $query[] = "SELECT      {$t['ACL']}.*, 0 as override\n                    FROM        {$t['ACL']}\n\n                    WHERE       {$t['ACL']}.entity_table    = '{$t['Domain']}'\n                            AND ({$where})";
     /* Query for permissions granted to all contacts through an ACL group */
     $query[] = "SELECT      {$t['ACL']}.*, 0 as override\n                    FROM        {$t['ACL']}\n\n                    INNER JOIN  {$t['ACLEntityRole']}\n                            ON  ({$t['ACL']}.entity_table = '{$t['ACLRole']}'\n                            AND     {$t['ACL']}.entity_id =\n                                    {$t['ACLEntityRole']}.acl_role_id)\n\n                    INNER JOIN  {$t['ACLRole']}\n                            ON      {$t['ACL']}.entity_id =\n                                    {$t['ACLRole']}.id\n\n                    WHERE       {$t['ACLEntityRole']}.entity_table =\n                                    '{$t['Domain']}'\n                            AND {$t['ACLRole']}.is_active      = 1\n                            AND ({$where})";
     /* Query for permissions granted directly to the contact */
     $query[] = "SELECT      {$t['ACL']}.*, 1 as override\n                    FROM        {$t['ACL']}\n\n                    INNER JOIN  {$t['Contact']}\n                            ON  ({$t['ACL']}.entity_table = '{$t['Contact']}'\n                            AND     {$t['ACL']}.entity_id = {$t['Contact']}.id)\n\n                    WHERE       {$t['Contact']}.id          = {$contact_id}\n                            AND ({$where})";
     /* Query for permissions granted to the contact through an ACL group */
     $query[] = "SELECT      {$t['ACL']}.*, 1 as override\n                    FROM        {$t['ACL']}\n\n                    INNER JOIN  {$t['ACLEntityRole']}\n                            ON  ({$t['ACL']}.entity_table = '{$t['ACLRole']}'\n                            AND     {$t['ACL']}.entity_id =\n                                    {$t['ACLEntityRole']}.acl_role_id)\n\n                    INNER JOIN  {$t['ACLRole']}\n                            ON  {$t['ACL']}.entity_id = {$t['ACLRole']}.id\n\n                    WHERE       {$t['ACLEntityRole']}.entity_table =\n                                    '{$t['Contact']}'\n                        AND     {$t['ACLRole']}.is_active      = 1\n                        AND     {$t['ACLEntityRole']}.entity_id  = {$contact_id}\n                        AND     ({$where})";
     /* Query for permissions granted to the contact through a group */
     $query[] = "SELECT      {$t['ACL']}.*, 0 as override\n                    FROM        {$t['ACL']}\n\n                    INNER JOIN  {$t['GroupContact']}\n                            ON  ({$t['ACL']}.entity_table = '{$t['Group']}'\n                            AND     {$t['ACL']}.entity_id =\n                                    {$t['GroupContact']}.group_id)\n\n                    WHERE       ({$where})\n                        AND     {$t['GroupContact']}.contact_id = {$contact_id}\n                        AND     {$t['GroupContact']}.status     = 'Added')";
     /* Query for permissions granted through an ACL group to a Contact
      * group */
     $query[] = "SELECT      {$t['ACL']}.*, 0 as override\n                    FROM        {$t['ACL']}\n\n                    INNER JOIN  {$t['ACLEntityRole']}\n                            ON  ({$t['ACL']}.entity_table = '{$t['ACLRole']}'\n                            AND     {$t['ACL']}.entity_id =\n                                    {$t['ACLEntityRole']}.acl_role_id)\n\n                    INNER JOIN  {$t['ACLRole']}\n                            ON  {$t['ACL']}.entity_id = {$t['ACLRole']}.id\n\n                    INNER JOIN  {$t['GroupContact']}\n                            ON  ({$t['ACLEntityRole']}.entity_table =\n                                    '{$t['Group']}'\n                            AND     {$t['ACLEntityRole']}.entity_id =\n                                    {$t['GroupContact']}.group_id)\n\n                    WHERE       ({$where})\n                        AND     {$t['ACLRole']}.is_active      = 1\n                        AND     {$t['GroupContact']}.contact_id = {$contact_id}\n                        AND     {$t['GroupContact']}.status     = 'Added'";
     $union = '(' . implode(') UNION DISTINCT (', $query) . ')';
     $dao->query($union);
     $allow = array(0);
     $deny = array(0);
     $override = array();
     while ($dao->fetch()) {
         /* Instant bypass for the following cases:
          * 1) the rule governs all tables
          * 2) the rule governs all objects in the table in question
          * 3) the rule governs the specific object we want
          */
         if (empty($dao->object_table) || $dao->object_table == $object_table && (empty($dao->object_id) || $dao->object_id == $object_id)) {
             $clause = 1;
         } else {
             /* Otherwise try to generate a clause for this rule */
             $clause = self::getClause($dao->object_table, $dao->object_id, $tables);
             /* If the clause returned is null, then the rule is a blanket
              * (id is null) on a table other than the one we're interested
              * in.  So skip it. */
             if (empty($clause)) {
                 continue;
             }
         }
         /* Now we figure out if this is an allow or deny rule, and possibly
          * a contact-level override */
         if ($dao->deny) {
             $deny[] = $clause;
         } else {
             $allow[] = $clause;
             if ($dao->override) {
                 $override[] = $clause;
             }
         }
     }
     $allows = '(' . implode(' OR ', $allow) . ')';
     $denies = '(' . implode(' OR ', $deny) . ')';
     if (!empty($override)) {
         $denies = '(NOT (' . implode(' OR ', $override) . ") AND {$denies})";
     }
     return "({$allows} AND NOT {$denies})";
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:93,代码来源:ACL.php

示例11: setDefaultValues

 /**
  * This function sets the default values for the form. Relationship that in edit/view mode
  * the default values are retrieved from the database
  * 
  * @access public
  * @return None
  */
 function setDefaultValues()
 {
     if ($this->_cdType) {
         return CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     $defaults = array();
     if ($this->_action & CRM_Core_Action::UPDATE) {
         if (!empty($this->_values)) {
             $defaults['relationship_type_id'] = $this->_rtypeId;
             if (CRM_Utils_Array::value('start_date', $this->_values)) {
                 list($defaults['start_date']) = CRM_Utils_Date::setDateDefaults($this->_values['start_date']);
             }
             if (CRM_Utils_Array::value('end_date', $this->_values)) {
                 list($defaults['end_date']) = CRM_Utils_Date::setDateDefaults($this->_values['end_date']);
             }
             $defaults['description'] = CRM_Utils_Array::value('description', $this->_values);
             $defaults['is_active'] = CRM_Utils_Array::value('is_active', $this->_values);
             $defaults['is_permission_a_b'] = CRM_Utils_Array::value('is_permission_a_b', $this->_values);
             $defaults['is_permission_b_a'] = CRM_Utils_Array::value('is_permission_b_a', $this->_values);
             $contact = new CRM_Contact_DAO_Contact();
             if ($this->_rtype == 'a_b' && $this->_values['contact_id_a'] == $this->_contactId) {
                 $contact->id = $this->_values['contact_id_b'];
             } else {
                 $contact->id = $this->_values['contact_id_a'];
             }
             if ($contact->find(true)) {
                 $this->_display_name_b = $contact->display_name;
                 $this->assign('sort_name_b', $this->_display_name_b);
                 //is current employee/employer.
                 if ($this->_allRelationshipNames[$this->_relationshipTypeId]["name_{$this->_rtype}"] == 'Employee of' && $contact->id == CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'employer_id')) {
                     $defaults['is_current_employer'] = 1;
                     $this->_values['current_employee_id'] = $this->_contactId;
                     $this->_values['current_employer_id'] = $contact->id;
                 } else {
                     if ($this->_allRelationshipNames[$this->_relationshipTypeId]["name_{$this->_rtype}"] == 'Employer of' && $this->_contactId == $contact->employer_id) {
                         $defaults['is_current_employer'] = 1;
                         $this->_values['current_employee_id'] = $contact->id;
                         $this->_values['current_employer_id'] = $this->_contactId;
                     }
                 }
             }
             $relationshipID = $this->_values['id'];
             $query = "SELECT id, note FROM civicrm_note where entity_table = 'civicrm_relationship' and entity_id = {$relationshipID}  order by modified_date desc";
             $dao = new CRM_Core_DAO();
             $dao->query($query);
             if ($dao->fetch($query)) {
                 $defaults['note'] = $dao->note;
             }
         }
     } else {
         $defaults['is_active'] = 1;
         $defaults['relationship_type_id'] = $this->_rtypeId;
     }
     return $defaults;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:62,代码来源:Relationship.php

示例12: randomContact

 /**
  * Generate a random contact of type $cType.
  *
  * @param  string  Contact Type, default as 'Individual'
  * @return int     Contact ID of created contact
  */
 private function randomContact($cType = 'Individual')
 {
     $contact = new CRM_Contact_DAO_Contact();
     //TODO : in future if we need cType as 'Organization'
     //Generate contact of type individual randomly
     $contact->contact_type = $cType;
     if ($cType == 'Individual') {
         list($gender_id, $gender) = $this->randomKeyValue($this->gender);
         $contact->gender_id = $gender_id;
         $contact->first_name = $this->randomItem($gender . '_name');
         $contact->middle_name = $this->probability(0.5) ? '' : ucfirst($this->randomChar());
         $contact->last_name = $this->randomItem('last_name');
         $contact->sort_name = $contact->last_name . ', ' . $contact->first_name;
         $contact->display_name = $contact->first_name . ' ' . $contact->last_name;
     }
     $contact->save();
     $email = $this->_individualEmail($contact);
     $this->_addEmail($contact->id, $email, self::WORK);
     return $contact->id;
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:26,代码来源:GenerateHRData.php

示例13: addMembership

 function addMembership()
 {
     $contact = new CRM_Contact_DAO_Contact();
     $contact->query("SELECT id FROM civicrm_contact where contact_type = 'Individual'");
     while ($contact->fetch()) {
         $contacts[] = $contact->id;
     }
     shuffle($contacts);
     $randomContacts = array_slice($contacts, 0, 350);
     $sources = array('Payment', 'Donation', 'Check');
     $membershipTypes = array(2, 1);
     $membershipTypeNames = array('Student', 'General');
     $statuses = array(3, 4);
     $membership = "\n INSERT INTO civicrm_membership\n        (contact_id, membership_type_id, join_date, start_date, end_date, source, status_id)\nVALUES\n ";
     $activity = "\nINSERT INTO civicrm_activity\n        (source_contact_id, source_record_id, activity_type_id, subject, activity_date_time, duration, location, phone_id, phone_number, details, priority_id,parent_id, is_test, status_id)\nVALUES\n";
     foreach ($randomContacts as $count => $dontCare) {
         $source = self::_getRandomElement($sources);
         $acititySourceId = $count + 1;
         if (($count + 1) % 11 == 0) {
             // lifetime membership, status can be anything
             $startDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') - $count, date('Y')));
             $membership .= "( {$randomContacts[$count]}, 3, '{$startDate}', '{$startDate}', null, '{$source}', 1)";
             $activity .= "( {$randomContacts[$count]}, {$acititySourceId}, 7, 'Lifetime', '{$startDate} 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 )";
         } elseif (($count + 1) % 5 == 0) {
             // Grace or expired, memberhsip type is random of 1 & 2
             $randId = array_rand($membershipTypes);
             $membershipType = self::_getRandomElement($membershipTypes);
             $startDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') - $count * ($randId + 1) * ($randId + 1) * ($randId + 1), date('Y') - ($randId + 1)));
             $partOfDate = explode('-', $startDate);
             $endDate = date('Y-m-d', mktime(0, 0, 0, $partOfDate[1], $partOfDate[2] - 1, $partOfDate[0] + ($randId + 1)));
             $membership .= "( {$randomContacts[$count]}, {$membershipType}, '{$startDate}', '{$startDate}', '{$endDate}', '{$source}', {$statuses[$randId]})";
             $activity .= "( {$randomContacts[$count]}, {$acititySourceId}, 7, '{$membershipTypeNames[$randId]}', '{$startDate} 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 )";
         } elseif (($count + 1) % 2 == 0) {
             // membership type 2
             $startDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') - $count, date('Y')));
             $endDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') - $count, date('Y') + 1));
             $membership .= "( {$randomContacts[$count]}, 2, '{$startDate}', '{$startDate}', '{$endDate}', '{$source}', 1)";
             $activity .= "( {$randomContacts[$count]}, {$acititySourceId}, 7, 'Student', '{$startDate} 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 )";
         } else {
             // membership type 1
             $startDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') - $count, date('Y')));
             $endDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') - $count, date('Y') + 2));
             $membership .= "( {$randomContacts[$count]}, 1, '{$startDate}', '{$startDate}', '{$endDate}', '{$source}', 1)";
             $activity .= "( {$randomContacts[$count]}, {$acititySourceId}, 7, 'General', '{$startDate} 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2 )";
         }
         if ($count != 349) {
             $membership .= ",";
             $activity .= ",";
         }
     }
     CRM_Core_DAO::executeQuery($membership, CRM_Core_DAO::$_nullArray);
     CRM_Core_DAO::executeQuery($activity, CRM_Core_DAO::$_nullArray);
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:53,代码来源:GenerateReportData.php

示例14: createNavigation

 /**
  * Function to create navigation for CiviCRM Admin Menu
  *
  * @param int $contactID contact id
  *
  * @return string $navigation returns navigation html
  * @static
  */
 static function createNavigation($contactID)
 {
     $config = CRM_Core_Config::singleton();
     // if on frontend, do not create navigation menu items, CRM-5349
     if ($config->userFrameworkFrontend) {
         return "<!-- {$config->lcMessages} -->";
     }
     $navParams = array('contact_id' => $contactID);
     $navigation = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::PERSONAL_PREFERENCES_NAME, 'navigation', NULL, NULL, $contactID);
     // FIXME: hack for CRM-5027: we need to prepend the navigation string with
     // (HTML-commented-out) locale info so that we rebuild menu on locale changes
     if (!$navigation || substr($navigation, 0, 14) != "<!-- {$config->lcMessages} -->") {
         //retrieve navigation if it's not cached.
         $navigation = self::buildNavigation();
         //add additional navigation items
         $logoutURL = CRM_Utils_System::url('civicrm/logout', 'reset=1');
         $appendSring = "<li id=\"menu-logout\" class=\"menumain\"><a href=\"{$logoutURL}\">" . ts('Logout') . "</a></li>";
         // get home menu from db
         $homeParams = array('name' => 'Home');
         $homeNav = array();
         self::retrieve($homeParams, $homeNav);
         if ($homeNav) {
             list($path, $q) = explode('&', $homeNav['url']);
             $homeURL = CRM_Utils_System::url($path, $q);
             $homeLabel = $homeNav['label'];
             // CRM-6804 (we need to special-case this as we don’t ts()-tag variables)
             if ($homeLabel == 'Home') {
                 $homeLabel = ts('Home');
             }
         } else {
             $homeURL = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
             $homeLabel = ts('Home');
         }
         if ($config->userSystem->is_drupal && (module_exists('toolbar') && user_access('access toolbar') || module_exists('admin_menu') && user_access('access administration menu'))) {
             $prepandString = "<li class=\"menumain crm-link-home\">" . $homeLabel . "<ul id=\"civicrm-home\"><li><a href=\"{$homeURL}\">" . $homeLabel . "</a></li><li><a href=\"#\" onclick=\"cj.Menu.closeAll( );cj('#civicrm-menu').toggle( );\">" . ts('Drupal Menu') . "</a></li></ul>";
         } elseif ($config->userSystem->is_wordpress) {
             $prepandString = "<li class=\"menumain crm-link-home\">" . $homeLabel . "<ul id=\"civicrm-home\"><li><a href=\"{$homeURL}\">" . $homeLabel . "</a></li><li><a href=\"#\" onclick=\"cj.Menu.closeAll( );cj('#civicrm-menu').toggle( );\">" . ts('WordPress Menu') . "</a></li></ul>";
         } else {
             $prepandString = "<li class=\"menumain crm-link-home\"><a href=\"{$homeURL}\" title=\"" . $homeLabel . "\">" . $homeLabel . "</a>";
         }
         // prepend the navigation with locale info for CRM-5027
         $navigation = "<!-- {$config->lcMessages} -->" . $prepandString . $navigation . $appendSring;
         // before inserting check if contact id exists in db
         // this is to handle wierd case when contact id is in session but not in db
         $contact = new CRM_Contact_DAO_Contact();
         $contact->id = $contactID;
         if ($contact->find(TRUE)) {
             CRM_Core_BAO_Setting::setItem($navigation, CRM_Core_BAO_Setting::PERSONAL_PREFERENCES_NAME, 'navigation', NULL, $contactID, $contactID);
         }
     }
     return $navigation;
 }
开发者ID:hguru,项目名称:224Civi,代码行数:60,代码来源:Navigation.php

示例15: getContactFields

 /**
  * @return array
  *   Array of field names which will be compared, so everything except ID.
  */
 public static function getContactFields()
 {
     $contactFields = CRM_Contact_DAO_Contact::fields();
     $invalidFields = array('api_key', 'contact_is_deleted', 'created_date', 'display_name', 'hash', 'id', 'modified_date', 'primary_contact_id', 'sort_name', 'user_unique_id');
     foreach ($contactFields as $field => $value) {
         if (in_array($field, $invalidFields)) {
             unset($contactFields[$field]);
         }
     }
     return array_keys($contactFields);
 }
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:15,代码来源:Merger.php


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