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

PHP CRM_Core_BAO_LocationType类代码示例

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

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



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

示例1: postProcess

 /**
  * Process the form submission.
  */
 public function postProcess()
 {
     CRM_Utils_System::flushCache('CRM_Core_DAO_LocationType');
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Core_BAO_LocationType::del($this->_id);
         CRM_Core_Session::setStatus(ts('Selected Location type has been deleted.'), ts('Record Deleted'), 'success');
         return;
     }
     // store the submitted values in an array
     $params = $this->exportValues();
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
     $params['is_default'] = CRM_Utils_Array::value('is_default', $params, FALSE);
     // action is taken depending upon the mode
     $locationType = new CRM_Core_DAO_LocationType();
     $locationType->name = $params['name'];
     $locationType->display_name = $params['display_name'];
     $locationType->vcard_name = $params['vcard_name'];
     $locationType->description = $params['description'];
     $locationType->is_active = $params['is_active'];
     $locationType->is_default = $params['is_default'];
     if ($params['is_default']) {
         $query = "UPDATE civicrm_location_type SET is_default = 0";
         CRM_Core_DAO::executeQuery($query);
     }
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $locationType->id = $this->_id;
     }
     $locationType->save();
     CRM_Core_Session::setStatus(ts("The location type '%1' has been saved.", array(1 => $locationType->name)), ts('Saved'), 'success');
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:33,代码来源:LocationType.php


示例2: postProcess

 /**
  * Function to process the form
  *
  * @access public
  * @return None
  */
 function postProcess()
 {
     if ($this->_action & CRM_CORE_ACTION_DELETE) {
         CRM_Core_BAO_LocationType::del($this->_id);
         CRM_Core_Session::setStatus(ts('Selected Location type has been deleted.'));
     } else {
         // store the submitted values in an array
         $params = $this->exportValues();
         $params['is_active'] = CRM_Utils_Array::value('is_active', $params, false);
         $params['is_default'] = CRM_Utils_Array::value('is_default', $params, false);
         // action is taken depending upon the mode
         $locationType =& new CRM_Core_DAO_LocationType();
         $locationType->domain_id = CRM_Core_Config::domainID();
         $locationType->name = $params['name'];
         $locationType->vcard_name = $params['vcard_name'];
         $locationType->description = $params['description'];
         $locationType->is_active = $params['is_active'];
         $locationType->is_default = $params['is_default'];
         if ($params['is_default']) {
             $unsetDefault =& new CRM_Core_DAO();
             $query = 'UPDATE civicrm_location_type SET is_default = 0';
             $unsetDefault->query($query);
         }
         if ($this->_action & CRM_CORE_ACTION_UPDATE) {
             $locationType->id = $this->_id;
         }
         $locationType->save();
         CRM_Core_Session::setStatus(ts('The location type "%1" has been saved.', array(1 => $locationType->name)));
     }
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:36,代码来源:LocationType.php


示例3: setDefaultValues

 /**
  * This function sets the default values for the form. For edit/view mode
  * the default values are retrieved from the database
  * 
  * @access public
  * @return None
  */
 function setDefaultValues(&$form)
 {
     $defaults = array();
     if ($form->_context == 'caseActivity') {
         return $defaults;
     }
     require_once 'CRM/Utils/Date.php';
     list($defaults['start_date']) = CRM_Utils_Date::setDateDefaults();
     // set case status to 'ongoing'
     $defaults['status_id'] = 1;
     // set default encounter medium, location type and phone type defaults are set in DB
     require_once "CRM/Core/OptionGroup.php";
     $medium = CRM_Core_OptionGroup::values('encounter_medium', false, false, false, 'AND is_default = 1');
     if (count($medium) == 1) {
         $defaults['medium_id'] = key($medium);
     }
     require_once 'CRM/Core/BAO/LocationType.php';
     $defaultLocationType =& CRM_Core_BAO_LocationType::getDefault();
     if ($defaultLocationType->id) {
         $defaults['location[1][location_type_id]'] = $defaultLocationType->id;
     }
     $phoneType = CRM_Core_OptionGroup::values('phone_type', false, false, false, 'AND is_default = 1');
     if (count($phoneType) == 1) {
         $defaults['location[1][phone][1][phone_type_id]'] = key($phoneType);
     }
     return $defaults;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:34,代码来源:OpenCase.php


示例4: postProcess

 /**
  * Function to process the form
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Core_BAO_LocationType::del($this->_id);
         CRM_Core_Session::setStatus(ts('Selected Location type has been deleted.'));
         return;
     }
     // store the submitted values in an array
     $params = $this->exportValues();
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, false);
     $params['is_default'] = CRM_Utils_Array::value('is_default', $params, false);
     // action is taken depending upon the mode
     $locationType =& new CRM_Core_DAO_LocationType();
     $locationType->name = $params['name'];
     $locationType->vcard_name = $params['vcard_name'];
     $locationType->description = $params['description'];
     $locationType->is_active = $params['is_active'];
     $locationType->is_default = $params['is_default'];
     if ($params['is_default']) {
         $query = "UPDATE civicrm_location_type SET is_default = 0";
         CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
     }
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $locationType->id = $this->_id;
     }
     $locationType->save();
     CRM_Core_Session::setStatus(ts('The location type \'%1\' has been saved.', array(1 => $locationType->name)));
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:34,代码来源:LocationType.php


示例5: civicrm_api3_contact_create

/**
 * Create or update a contact (note you should always call this via civicrm_api() & never directly)
 *
 * @param  array   $params   input parameters
 *
 * Allowed @params array keys are:
 * {@getfields contact_create}
 *
 *
 * @example ContactCreate.php Example of Create Call
 *
 * @return array  API Result Array
 *
 * @static void
 * @access public
 */
function civicrm_api3_contact_create($params)
{
    $contactID = CRM_Utils_Array::value('contact_id', $params, CRM_Utils_Array::value('id', $params));
    $dupeCheck = CRM_Utils_Array::value('dupe_check', $params, FALSE);
    $values = _civicrm_api3_contact_check_params($params, $dupeCheck);
    if ($values) {
        return $values;
    }
    if (empty($contactID)) {
        // If we get here, we're ready to create a new contact
        if (($email = CRM_Utils_Array::value('email', $params)) && !is_array($params['email'])) {
            require_once 'CRM/Core/BAO/LocationType.php';
            $defLocType = CRM_Core_BAO_LocationType::getDefault();
            $params['email'] = array(1 => array('email' => $email, 'is_primary' => 1, 'location_type_id' => $defLocType->id ? $defLocType->id : 1));
        }
    }
    if (CRM_Utils_Array::value('home_url', $params)) {
        require_once 'CRM/Core/PseudoConstant.php';
        $websiteTypes = CRM_Core_PseudoConstant::websiteType();
        $params['website'] = array(1 => array('website_type_id' => key($websiteTypes), 'url' => $params['home_url']));
    }
    if (isset($params['suffix_id']) && !is_numeric($params['suffix_id'])) {
        $params['suffix_id'] = array_search($params['suffix_id'], CRM_Core_PseudoConstant::individualSuffix());
    }
    if (isset($params['prefix_id']) && !is_numeric($params['prefix_id'])) {
        $params['prefix_id'] = array_search($params['prefix_id'], CRM_Core_PseudoConstant::individualPrefix());
    }
    if (isset($params['gender_id']) && !is_numeric($params['gender_id'])) {
        $params['gender_id'] = array_search($params['gender_id'], CRM_Core_PseudoConstant::gender());
    }
    $error = _civicrm_api3_greeting_format_params($params);
    if (civicrm_error($error)) {
        return $error;
    }
    $values = array();
    $entityId = $contactID;
    if (!CRM_Utils_Array::value('contact_type', $params) && $entityId) {
        $params['contact_type'] = CRM_Contact_BAO_Contact::getContactType($entityId);
    }
    if (!isset($params['contact_sub_type']) && $entityId) {
        require_once 'CRM/Contact/BAO/Contact.php';
        $params['contact_sub_type'] = CRM_Contact_BAO_Contact::getContactSubType($entityId);
    }
    _civicrm_api3_custom_format_params($params, $values, $params['contact_type'], $entityId);
    $params = array_merge($params, $values);
    $contact = _civicrm_api3_contact_update($params, $contactID);
    if (is_a($contact, 'CRM_Core_Error')) {
        return civicrm_api3_create_error($contact->_errors[0]['message']);
    } else {
        $values = array();
        _civicrm_api3_object_to_array_unique_fields($contact, $values[$contact->id]);
    }
    return civicrm_api3_create_success($values, $params, 'Contact', 'create');
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:70,代码来源:Contact.php


示例6: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  *
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->useTransaction(TRUE);
     // taken from form code - couldn't find good method to use
     $params['entity_id'] = 1;
     $params['entity_table'] = CRM_Core_BAO_Domain::getTableName();
     $defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
     $domContact = $this->callAPISuccess('contact', 'create', array('contact_type' => 'Organization', 'organization_name' => 'new org', 'api.phone.create' => array('location_type_id' => $defaultLocationType->id, 'phone_type_id' => 1, 'phone' => '456-456'), 'api.address.create' => array('location_type_id' => $defaultLocationType->id, 'street_address' => '45 Penny Lane'), 'api.email.create' => array('location_type_id' => $defaultLocationType->id, 'email' => '[email protected]')));
     $this->callAPISuccess('domain', 'create', array('id' => 1, 'contact_id' => $domContact['id']));
     $this->params = array('name' => 'A-team domain', 'description' => 'domain of chaos', 'domain_version' => '4.2', 'contact_id' => $domContact['id']);
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:17,代码来源:DomainTest.php


示例7: civicrm_api3_contact_create

/**
 * Create or update a Contact.
 *
 * @param array $params
 *   Input parameters.
 *
 * @throws API_Exception
 *
 * @return array
 *   API Result Array
 */
function civicrm_api3_contact_create($params)
{
    $contactID = CRM_Utils_Array::value('contact_id', $params, CRM_Utils_Array::value('id', $params));
    if ($contactID && !empty($params['check_permissions']) && !CRM_Contact_BAO_Contact_Permission::allow($contactID, CRM_Core_Permission::EDIT)) {
        throw new \Civi\API\Exception\UnauthorizedException('Permission denied to modify contact record');
    }
    $dupeCheck = CRM_Utils_Array::value('dupe_check', $params, FALSE);
    $values = _civicrm_api3_contact_check_params($params, $dupeCheck);
    if ($values) {
        return $values;
    }
    if (array_key_exists('api_key', $params) && !empty($params['check_permissions'])) {
        if (CRM_Core_Permission::check('edit api keys') || CRM_Core_Permission::check('administer CiviCRM')) {
            // OK
        } elseif ($contactID && CRM_Core_Permission::check('edit own api keys') && CRM_Core_Session::singleton()->get('userID') == $contactID) {
            // OK
        } else {
            throw new \Civi\API\Exception\UnauthorizedException('Permission denied to modify api key');
        }
    }
    if (!$contactID) {
        // If we get here, we're ready to create a new contact
        if (($email = CRM_Utils_Array::value('email', $params)) && !is_array($params['email'])) {
            $defLocType = CRM_Core_BAO_LocationType::getDefault();
            $params['email'] = array(1 => array('email' => $email, 'is_primary' => 1, 'location_type_id' => $defLocType->id ? $defLocType->id : 1));
        }
    }
    if (!empty($params['home_url'])) {
        $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id');
        $params['website'] = array(1 => array('website_type_id' => key($websiteTypes), 'url' => $params['home_url']));
    }
    _civicrm_api3_greeting_format_params($params);
    $values = array();
    if (empty($params['contact_type']) && $contactID) {
        $params['contact_type'] = CRM_Contact_BAO_Contact::getContactType($contactID);
    }
    if (!isset($params['contact_sub_type']) && $contactID) {
        $params['contact_sub_type'] = CRM_Contact_BAO_Contact::getContactSubType($contactID);
    }
    _civicrm_api3_custom_format_params($params, $values, $params['contact_type'], $contactID);
    $params = array_merge($params, $values);
    //@todo we should just call basic_create here - but need to make contact:create accept 'id' on the bao
    $contact = _civicrm_api3_contact_update($params, $contactID);
    if (is_a($contact, 'CRM_Core_Error')) {
        throw new API_Exception($contact->_errors[0]['message']);
    } else {
        $values = array();
        _civicrm_api3_object_to_array_unique_fields($contact, $values[$contact->id]);
    }
    return civicrm_api3_create_success($values, $params, 'Contact', 'create');
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:62,代码来源:Contact.php


示例8: getBillingAddressFields

 /**
  * Get billing fields required for this processor.
  *
  * We apply the existing default of returning fields only for payment processor type 1. Processors can override to
  * alter.
  *
  * @param int $billingLocationID
  *
  * @return array
  */
 public function getBillingAddressFields($billingLocationID = NULL)
 {
     if (!$billingLocationID) {
         // Note that although the billing id is passed around the forms the idea that it would be anything other than
         // the result of the function below doesn't seem to have eventuated.
         // So taking this as a param is possibly something to be removed in favour of the standard default.
         $billingLocationID = CRM_Core_BAO_LocationType::getBilling();
     }
     // Only handle pseudo-profile billing for now.
     if ($this->billingProfile == 'billing') {
         // @todo - use profile api to retrieve this - either as pseudo-profile or (better) set up billing
         // as a reserved profile in the DB and (even better) allow the profile to be selected
         // on the form instead of just 'billing for pay=later bool'
         return array('first_name' => 'billing_first_name', 'middle_name' => 'billing_middle_name', 'last_name' => 'billing_last_name', 'street_address' => "billing_street_address-{$billingLocationID}", 'city' => "billing_city-{$billingLocationID}", 'country' => "billing_country_id-{$billingLocationID}", 'state_province' => "billing_state_province_id-{$billingLocationID}", 'postal_code' => "billing_postal_code-{$billingLocationID}");
     } else {
         return array();
     }
 }
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:28,代码来源:Manual.php


示例9: array

 /**
  * Register a subscription event.  Create a new contact if one does not
  * already exist.
  *
  * @param int $domain_id        The domain id of the new subscription
  * @param int $group_id         The group id to subscribe to
  * @param string $email         The email address of the (new) contact
  * @return int|null $se_id      The id of the subscription event, null on failure
  * @access public
  * @static
  */
 function &subscribe($domain_id, $group_id, $email)
 {
     /* First, find out if the contact already exists */
     $params = array('email' => $email, 'domain_id' => $domain_id);
     require_once 'CRM/Core/BAO/UFGroup.php';
     $contact_id = CRM_Core_BAO_UFGroup::findContact($params);
     CRM_Core_DAO::transaction('BEGIN');
     if (is_a($contact_id, CRM_Core_Error)) {
         require_once 'CRM/Core/BAO/LocationType.php';
         /* If the contact does not exist, create one. */
         $formatted = array('contact_type' => 'Individual');
         $value = array('email' => $email, 'location_type' => CRM_Core_BAO_LocationType::getDefaultID());
         _crm_add_formatted_param($value, $formatted);
         $contact =& crm_create_contact_formatted($formatted, CRM_IMPORT_PARSER_DUPLICATE_SKIP);
         if (is_a($contact, CRM_Core_Error)) {
             return null;
         }
         $contact_id = $contact->id;
     }
     require_once 'CRM/Core/BAO/Email.php';
     require_once 'CRM/Core/BAO/Location.php';
     require_once 'CRM/Contact/BAO/Contact.php';
     /* Get the primary email id from the contact to use as a hash input */
     $dao =& new CRM_Core_DAO();
     $emailTable = CRM_Core_BAO_Email::getTableName();
     $locTable = CRM_Core_BAO_Location::getTableName();
     $contactTable = CRM_Contact_BAO_Contact::getTableName();
     $dao->query("SELECT {$emailTable}.id as email_id\n                    FROM {$emailTable}\n                    INNER JOIN {$locTable}\n                        ON  {$emailTable}.location_id = {$locTable}.id\n                    WHERE   {$emailTable}.is_primary = 1\n                    AND     {$locTable}.is_primary = 1\n                    AND     {$locTable}.entity_table = '{$contactTable}'\n                    AND     {$locTable}.entity_id = " . CRM_Utils_Type::escape($contact_id, 'Integer'));
     $dao->fetch();
     $se =& new CRM_Mailing_Event_BAO_Subscribe();
     $se->group_id = $group_id;
     $se->contact_id = $contact_id;
     $se->time_stamp = date('YmdHis');
     $se->hash = sha1("{$group_id}:{$contact_id}:{$dao->email_id}");
     $se->save();
     $contacts = array($contact_id);
     require_once 'CRM/Contact/BAO/GroupContact.php';
     CRM_Contact_BAO_GroupContact::addContactsToGroup($contacts, $group_id, 'Email', 'Pending', $se->id);
     CRM_Core_DAO::transaction('COMMIT');
     return $se;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:52,代码来源:Subscribe.php


示例10: civicrm_api3_contact_create

/**
 * Create or update a Contact.
 *
 * @param array $params
 *   Input parameters.
 *
 * @throws API_Exception
 *
 * @return array
 *   API Result Array
 */
function civicrm_api3_contact_create($params)
{
    $contactID = CRM_Utils_Array::value('contact_id', $params, CRM_Utils_Array::value('id', $params));
    $dupeCheck = CRM_Utils_Array::value('dupe_check', $params, FALSE);
    $values = _civicrm_api3_contact_check_params($params, $dupeCheck);
    if ($values) {
        return $values;
    }
    if (!$contactID) {
        // If we get here, we're ready to create a new contact
        if (($email = CRM_Utils_Array::value('email', $params)) && !is_array($params['email'])) {
            $defLocType = CRM_Core_BAO_LocationType::getDefault();
            $params['email'] = array(1 => array('email' => $email, 'is_primary' => 1, 'location_type_id' => $defLocType->id ? $defLocType->id : 1));
        }
    }
    if (!empty($params['home_url'])) {
        $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id');
        $params['website'] = array(1 => array('website_type_id' => key($websiteTypes), 'url' => $params['home_url']));
    }
    _civicrm_api3_greeting_format_params($params);
    $values = array();
    if (empty($params['contact_type']) && $contactID) {
        $params['contact_type'] = CRM_Contact_BAO_Contact::getContactType($contactID);
    }
    if (!isset($params['contact_sub_type']) && $contactID) {
        $params['contact_sub_type'] = CRM_Contact_BAO_Contact::getContactSubType($contactID);
    }
    _civicrm_api3_custom_format_params($params, $values, $params['contact_type'], $contactID);
    $params = array_merge($params, $values);
    //@todo we should just call basic_create here - but need to make contact:create accept 'id' on the bao
    $contact = _civicrm_api3_contact_update($params, $contactID);
    if (is_a($contact, 'CRM_Core_Error')) {
        throw new API_Exception($contact->_errors[0]['message']);
    } else {
        $values = array();
        _civicrm_api3_object_to_array_unique_fields($contact, $values[$contact->id]);
    }
    return civicrm_api3_create_success($values, $params, 'Contact', 'create');
}
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:50,代码来源:Contact.php


示例11: testCreateContactFromMailchimpRequest

 function testCreateContactFromMailchimpRequest()
 {
     $request_data = CRM_CiviMailchimp_Page_WebhookTest::sampleRequestSubscribeOrProfileUpdate();
     $contact = CRM_CiviMailchimp_Utils::createContactFromMailchimpRequest($request_data);
     $location_type = CRM_Core_BAO_LocationType::getDefault();
     $this->assertEquals('Individual', $contact->contact_type);
     $this->assertEquals($request_data['merges']['FNAME'], $contact->first_name);
     $this->assertEquals($request_data['merges']['LNAME'], $contact->last_name);
     $this->assertEquals($request_data['email'], $contact->email[0]->email);
     $this->assertEquals(1, $contact->email[0]->is_primary);
     $this->assertEquals($location_type->id, $contact->email[0]->location_type_id);
 }
开发者ID:jaapjansma,项目名称:com.giantrabbit.civimailchimp,代码行数:12,代码来源:UtilsTest.php


示例12: buildQuickForm

 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     $this->add('hidden', 'gid', $this->_gid);
     switch ($this->_mode) {
         case self::MODE_CREATE:
         case self::MODE_EDIT:
         case self::MODE_REGISTER:
             CRM_Utils_Hook::buildProfile($this->_ufGroup['name']);
             break;
         case self::MODE_SEARCH:
             CRM_Utils_Hook::searchProfile($this->_ufGroup['name']);
             break;
         default:
     }
     //lets have single status message, CRM-4363
     $return = FALSE;
     $statusMessage = NULL;
     if ($this->_multiRecord & CRM_Core_Action::ADD && $this->_maxRecordLimit) {
         return;
     }
     if ($this->_multiRecord & CRM_Core_Action::DELETE) {
         if (!$this->_recordExists) {
             CRM_Core_Session::setStatus(ts('The record %1 doesnot exists', array(1 => $this->_recordId)), ts('Record doesnot exists'), 'alert');
         } else {
             $this->assign('deleteRecord', TRUE);
         }
         return;
     }
     CRM_Core_BAO_Address::checkContactSharedAddressFields($this->_fields, $this->_id);
     // we should not allow component and mix profiles in search mode
     if ($this->_mode != self::MODE_REGISTER) {
         //check for mix profile fields (eg:  individual + other contact type)
         if (CRM_Core_BAO_UFField::checkProfileType($this->_gid)) {
             if ($this->_mode & self::MODE_EDIT && $this->_isContactActivityProfile) {
                 $errors = self::validateContactActivityProfile($this->_activityId, $this->_id, $this->_gid);
                 if (!empty($errors)) {
                     $statusMessage = array_pop($errors);
                     $return = TRUE;
                 }
             } else {
                 $statusMessage = ts('Profile search, view and edit are not supported for Profiles which include fields for more than one record type.');
                 $return = TRUE;
             }
         }
         $profileType = CRM_Core_BAO_UFField::getProfileType($this->_gid);
         if ($this->_id) {
             $contactTypes = CRM_Contact_BAO_Contact::getContactTypes($this->_id);
             $contactType = $contactTypes[0];
             array_shift($contactTypes);
             $contactSubtypes = $contactTypes;
             $profileSubType = FALSE;
             if (CRM_Contact_BAO_ContactType::isaSubType($profileType)) {
                 $profileSubType = $profileType;
                 $profileType = CRM_Contact_BAO_ContactType::getBasicType($profileType);
             }
             if ($profileType != 'Contact' && !$this->_isContactActivityProfile && ($profileSubType && !empty($contactSubtypes) && !in_array($profileSubType, $contactSubtypes) || $profileType != $contactType)) {
                 $return = TRUE;
                 if (!$statusMessage) {
                     $statusMessage = ts("This profile is configured for contact type '%1'. It cannot be used to edit contacts of other types.", array(1 => $profileSubType ? $profileSubType : $profileType));
                 }
             }
         }
         if (in_array($profileType, array("Membership", "Participant", "Contribution"))) {
             $return = TRUE;
             if (!$statusMessage) {
                 $statusMessage = ts('Profile is not configured for the selected action.');
             }
         }
     }
     //lets have single status message,
     $this->assign('statusMessage', $statusMessage);
     if ($return) {
         return FALSE;
     }
     $this->assign('id', $this->_id);
     $this->assign('mode', $this->_mode);
     $this->assign('action', $this->_action);
     $this->assign('fields', $this->_fields);
     $this->assign('fieldset', isset($this->_fieldset) ? $this->_fieldset : "");
     // should we restrict what we display
     $admin = TRUE;
     if ($this->_mode == self::MODE_EDIT) {
         $admin = FALSE;
         // show all fields that are visibile:
         // if we are a admin OR the same user OR acl-user with access to the profile
         // or we have checksum access to this contact (i.e. the user without a login) - CRM-5909
         if (CRM_Core_Permission::check('administer users') || $this->_id == $this->_currentUserID || $this->_isPermissionedChecksum || in_array($this->_gid, CRM_ACL_API::group(CRM_Core_Permission::EDIT, NULL, 'civicrm_uf_group', CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id')))) {
             $admin = TRUE;
         }
     }
     // if false, user is not logged-in.
     $anonUser = FALSE;
     if (!$this->_currentUserID) {
         $defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
         $primaryLocationType = $defaultLocationType->id;
//.........这里部分代码省略.........
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:101,代码来源:Form.php


示例13: blockSetDefaults

 function blockSetDefaults(&$defaults)
 {
     $locationTypeKeys = array_filter(array_keys(CRM_Core_PseudoConstant::locationType()), 'is_int');
     sort($locationTypeKeys);
     // get the default location type
     require_once 'CRM/Core/BAO/LocationType.php';
     $locationType = CRM_Core_BAO_LocationType::getDefault();
     // unset primary location type
     $primaryLocationTypeIdKey = CRM_Utils_Array::key($locationType->id, $locationTypeKeys);
     unset($locationTypeKeys[$primaryLocationTypeIdKey]);
     // reset the array sequence
     $locationTypeKeys = array_values($locationTypeKeys);
     // get default phone and im provider id.
     require_once 'CRM/Core/OptionGroup.php';
     $defPhoneTypeId = key(CRM_Core_OptionGroup::values('phone_type', false, false, false, ' AND is_default = 1'));
     $defIMProviderId = key(CRM_Core_OptionGroup::values('instant_messenger_service', false, false, false, ' AND is_default = 1'));
     $allBlocks = $this->_blocks;
     if (array_key_exists('Address', $this->_editOptions)) {
         $allBlocks['Address'] = $this->_editOptions['Address'];
     }
     $config =& CRM_Core_Config::singleton();
     foreach ($allBlocks as $blockName => $label) {
         $name = strtolower($blockName);
         if (array_key_exists($name, $defaults) && !CRM_Utils_System::isNull($defaults[$name])) {
             continue;
         }
         for ($instance = 1; $instance <= $this->get($blockName . "_Block_Count"); $instance++) {
             //set location to primary for first one.
             if ($instance == 1) {
                 $defaults[$name][$instance]['is_primary'] = true;
                 $defaults[$name][$instance]['location_type_id'] = $locationType->id;
             } else {
                 $locTypeId = isset($locationTypeKeys[$instance - 1]) ? $locationTypeKeys[$instance - 1] : $locationType->id;
                 $defaults[$name][$instance]['location_type_id'] = $locTypeId;
             }
             //set default country
             if ($name == 'address' && $config->defaultContactCountry) {
                 $defaults[$name][$instance]['country_id'] = $config->defaultContactCountry;
             }
             //set default phone type.
             if ($name == 'phone' && $defPhoneTypeId) {
                 $defaults[$name][$instance]['phone_type_id'] = $defPhoneTypeId;
             }
             //set default im provider.
             if ($name == 'im' && $defIMProviderId) {
                 $defaults[$name][$instance]['provider_id'] = $defIMProviderId;
             }
         }
     }
     // set defaults for country-state widget
     if (CRM_Utils_Array::value('address', $defaults) && is_array($defaults['address'])) {
         require_once 'CRM/Contact/Form/Edit/Address.php';
         foreach ($defaults['address'] as $blockId => $values) {
             CRM_Contact_Form_Edit_Address::fixStateSelect($this, "address[{$blockId}][country_id]", "address[{$blockId}][state_province_id]", CRM_Utils_Array::value('country_id', $values, $config->defaultContactCountry));
         }
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:57,代码来源:Contact.php


示例14: setDefaultValues

 /**
  * Set defaults for the form.
  *
  * @return array
  */
 public function setDefaultValues()
 {
     $defaults = $this->_values;
     $config = CRM_Core_Config::singleton();
     //set address block defaults
     if (!empty($defaults['address'])) {
         CRM_Contact_Form_Edit_Address::setDefaultValues($defaults, $this);
     } else {
         // get the default location type
         $locationType = CRM_Core_BAO_LocationType::getDefault();
         if ($this->_locBlockNo == 1) {
             $address['is_primary'] = TRUE;
             $address['location_type_id'] = $locationType->id;
         }
         $address['country_id'] = $config->defaultContactCountry;
         $defaults['address'][$this->_locBlockNo] = $address;
     }
     return $defaults;
 }
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:24,代码来源:Address.php


示例15: buildQuickForm

 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     //to save the current mappings
     if (!$this->get('savedMapping')) {
         $saveDetailsName = ts('Save this field mapping');
         $this->applyFilter('saveMappingName', 'trim');
         $this->add('text', 'saveMappingName', ts('Name'));
         $this->add('text', 'saveMappingDesc', ts('Description'));
     } else {
         $savedMapping = $this->get('savedMapping');
         list($mappingName, $mappingContactType, $mappingLocation, $mappingPhoneType, $mappingImProvider, $mappingRelation, $mappingOperator, $mappingValue, $mappingWebsiteType) = CRM_Core_BAO_Mapping::getMappingFields($savedMapping);
         //get loaded Mapping Fields
         $mappingName = CRM_Utils_Array::value(1, $mappingName);
         $mappingContactType = CRM_Utils_Array::value(1, $mappingContactType);
         $mappingLocation = CRM_Utils_Array::value(1, $mappingLocation);
         $mappingPhoneType = CRM_Utils_Array::value(1, $mappingPhoneType);
         $mappingImProvider = CRM_Utils_Array::value(1, $mappingImProvider);
         $mappingRelation = CRM_Utils_Array::value(1, $mappingRelation);
         $mappingWebsiteType = CRM_Utils_Array::value(1, $mappingWebsiteType);
         $this->assign('loadedMapping', $savedMapping);
         $this->set('loadedMapping', $savedMapping);
         $params = array('id' => $savedMapping);
         $temp = array();
         $mappingDetails = CRM_Core_BAO_Mapping::retrieve($params, $temp);
         $this->assign('savedName', $mappingDetails->name);
         $this->add('hidden', 'mappingId', $savedMapping);
         $this->addElement('checkbox', 'updateMapping', ts('Update this field mapping'), NULL);
         $saveDetailsName = ts('Save as a new field mapping');
         $this->add('text', 'saveMappingName', ts('Name'));
         $this->add('text', 'saveMappingDesc', ts('Description'));
     }
     $this->addElement('checkbox', 'saveMapping', $saveDetailsName, NULL, array('onclick' => "showSaveDetails(this)"));
     $this->addFormRule(array('CRM_Contact_Import_Form_MapField', 'formRule'));
     //-------- end of saved mapping stuff ---------
     $defaults = array();
     $mapperKeys = array_keys($this->_mapperFields);
     $hasColumnNames = !empty($this->_columnNames);
     $columnPatterns = $this->get('columnPatterns');
     $dataPatterns = $this->get('dataPatterns');
     $hasLocationTypes = $this->get('fieldTypes');
     $this->_location_types = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
     $defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
     // Pass default location to js
     if ($defaultLocationType) {
         $this->assign('defaultLocationType', $defaultLocationType->id);
         $this->assign('defaultLocationTypeLabel', $this->_location_types[$defaultLocationType->id]);
     }
     /* Initialize all field usages to false */
     foreach ($mapperKeys as $key) {
         $this->_fieldUsed[$key] = FALSE;
     }
     $sel1 = $this->_mapperFields;
     $sel2[''] = NULL;
     $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
     $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
     $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id');
     foreach ($this->_location_types as $key => $value) {
         $sel3['phone'][$key] =& $phoneTypes;
         //build array for IM service provider type for contact
         $sel3['im'][$key] =& $imProviders;
     }
     $sel4 = NULL;
     // store and cache all relationship types
     $contactRelation = new CRM_Contact_DAO_RelationshipType();
     $contactRelation->find();
     while ($contactRelation->fetch()) {
         $contactRelationCache[$contactRelation->id] = array();
         $contactRelationCache[$contactRelation->id]['contact_type_a'] = $contactRelation->contact_type_a;
         $contactRelationCache[$contactRelation->id]['contact_sub_type_a'] = $contactRelation->contact_sub_type_a;
         $contactRelationCache[$contactRelation->id]['contact_type_b'] = $contactRelation->contact_type_b;
         $contactRelationCache[$contactRelation->id]['contact_sub_type_b'] = $contactRelation->contact_sub_type_b;
     }
     $highlightedFields = $highlightedRelFields = array();
     $highlightedFields['email'] = 'All';
     $highlightedFields['external_identifier'] = 'All';
     $highlightedFields['first_name'] = 'Individual';
     $highlightedFields['last_name'] = 'Individual';
     $highlightedFields['household_name'] = 'Household';
     $highlightedFields['organization_name'] = 'Organization';
     foreach ($mapperKeys as $key) {
         // check if there is a _a_b or _b_a in the key
         if (strpos($key, '_a_b') || strpos($key, '_b_a')) {
             list($id, $first, $second) = explode('_', $key);
         } else {
             $id = $first = $second = NULL;
         }
         if ($first == 'a' && $second == 'b' || $first == 'b' && $second == 'a') {
             $cType = $contactRelationCache[$id]["contact_type_{$second}"];
             //CRM-5125 for contact subtype specific relationshiptypes
             $cSubType = NULL;
             if (!empty($contactRelationCache[$id]["contact_sub_type_{$second}"])) {
                 $cSubType = $contactRelationCache[$id]["contact_sub_type_{$second}"];
             }
             if (!$cType) {
                 $cType = 'All';
             }
             $relatedFields = array();
//.........这里部分代码省略.........
开发者ID:nganivet,项目名称:civicrm-core,代码行数:101,代码来源:MapField.php


示例16: CRM_Core_Dao

 /**
  * Create a new forward event, create a new contact if necessary
  */
 static function &forward($job_id, $queue_id, $hash, $forward_email, $fromEmail = null, $comment = null)
 {
     $q =& CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
     $successfulForward = false;
     if (!$q) {
         return $successfulForward;
     }
     /* Find the email address/contact, if it exists */
     $contact = CRM_Contact_BAO_Contact::getTableName();
     $location = CRM_Core_BAO_Location::getTableName();
     $email = CRM_Core_BAO_Email::getTableName();
     $queueTable = CRM_Mailing_Event_BAO_Queue::getTableName();
     $job = CRM_Mailing_BAO_Job::getTableName();
     $mailing = CRM_Mailing_BAO_Mailing::getTableName();
     $forward = self::getTableName();
     $domain =& CRM_Core_BAO_Domain::getDomain();
     $dao =& new CRM_Core_Dao();
     $dao->query("\n                SELECT      {$contact}.id as contact_id,\n                            {$email}.id as email_id,\n                            {$contact}.do_not_email as do_not_email,\n                            {$queueTable}.id as queue_id\n                FROM        ({$email}, {$job} as temp_job)\n                INNER JOIN  {$contact}\n                        ON  {$email}.contact_id = {$contact}.id\n                LEFT JOIN   {$queueTable}\n                        ON  {$email}.id = {$queueTable}.email_id\n                LEFT JOIN   {$job}\n                        ON  {$queueTable}.job_id = {$job}.id\n                        AND temp_job.mailing_id = {$job}.mailing_id\n                WHERE       {$queueTable}.job_id = {$job_id}\n                    AND     {$email}.email = '" . CRM_Utils_Type::escape($forward_email, 'String') . "'");
     $dao->fetch();
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     if (isset($dao->queue_id) || $dao->do_not_email == 1) {
         /* We already sent this mailing to $forward_email, or we should
          * never email this contact.  Give up. */
         return $successfulForward;
     }
     require_once 'api/v2/Contact.php';
     $contact_params = array('email' => $forward_email);
     $count = civicrm_contact_search_count($contact_params);
     if ($count == 0) {
         require_once 'CRM/Core/BAO/LocationType.php';
         /* If the contact does not exist, create one. */
         $formatted = array('contact_type' => 'Individual');
         $locationType = CRM_Core_BAO_LocationType::getDefault();
         $value = array('email' => $forward_email, 'location_type_id' => $locationType->id);
         _civicrm_add_formatted_param($value, $formatted);
         require_once 'CRM/Import/Parser.php';
         $formatted['onDuplicate'] = CRM_Import_Parser::DUPLICATE_SKIP;
         $formatted['fixAddress'] = true;
         $contact =& civicrm_contact_format_create($formatted);
         if (civicrm_error($contact, CRM_Core_Error)) {
             return $successfulForward;
         }
         $contact_id = $contact['id'];
     }
     $email =& new CRM_Core_DAO_Email();
     $email->email = $forward_email;
     $email->find(true);
     $email_id = $email->id;
     if (!$contact_id) {
         $contact_id = $email->contact_id;
     }
     /* Create a new queue event */
     $queue_params = array('email_id' => $email_id, 'contact_id' => $contact_id, 'job_id' => $job_id);
     $queue =& CRM_Mailing_Event_BAO_Queue::create($queue_params);
     $forward =& new CRM_Mailing_Event_BAO_Forward();
     $forward->time_stamp = date('YmdHis');
     $forward->event_queue_id = $queue_id;
     $forward->dest_queue_id = $queue->id;
     $forward->save();
     $dao->reset();
     $dao->query("   SELECT  {$job}.mailing_id as mailing_id \n                        FROM    {$job}\n                        WHERE   {$job}.id = " . CRM_Utils_Type::escape($job_id, 'Integer'));
     $dao->fetch();
     $mailing_obj =& new CRM_Mailing_BAO_Mailing();
     $mailing_obj->id = $dao->mailing_id;
     $mailing_obj->find(true);
     $config =& CRM_Core_Config::singleton();
     $mailer =& $config->getMailer();
     $recipient = null;
     $attachments = null;
     $message =& $mailing_obj->compose($job_id, $queue->id, $queue->hash, $queue->contact_id, $forward_email, $recipient, false, null, $attachments, true, $fromEmail);
     //append comment if added while forwarding.
     if (count($comment)) {
         $message->_txtbody = $comment['body_text'] . $message->_txtbody;
         if (CRM_Utils_Array::value('body_html', $comment)) {
             $message->_htmlbody = $comment['body_html'] . '<br />---------------Original message---------------------<br />' . $message->_htmlbody;
         }
     }
     $body = $message->get();
     $headers = $message->headers();
     PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array('CRM_Core_Error', 'nullHandler'));
     $result = null;
     if (is_object($mailer)) {
         $result = $mailer->send($recipient, $headers, $body);
         CRM_Core_Error::setCallback();
     }
     $params = array('event_queue_id' => $queue->id, 'job_id' => $job_id, 'hash' => $queue->hash);
     if (is_a($result, PEAR_Error)) {
         /* Register the bounce event */
         $params = array_merge($params, CRM_Mailing_BAO_BouncePattern::match($result->getMessage()));
         CRM_Mailing_Event_BAO_Bounce::create($params);
     } else {
         $successfulForward = true;
         /* Register the delivery event */
         CRM_Mailing_Event_BAO_Delivered::create($params);
     }
     $transaction->commit();
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:voipdev,代码行数:101,代码来源:Forward.php


示例17: formatProfileContactParams

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP CRM_Core_BAO_Log类代码示例发布时间:2022-05-20
下一篇:
PHP CRM_Core_BAO_Location类代码示例发布时间: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