/**
  * set defaults for the form
  *
  * @return void
  * @access public
  */
 public function setDefaultValues()
 {
     $defaults = array();
     $params = array('id' => $this->_contactId);
     $defaults = array();
     CRM_Contact_BAO_Contact::getValues($params, $defaults);
     return $defaults;
 }
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  *
  * @return void
  * @access public
  *
  */
 function run()
 {
     // get the emails for this contact
     $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $params = array('id' => $contactId);
     $defaults = array();
     CRM_Contact_BAO_Contact::getValues($params, $defaults);
     $defaults['privacy_values'] = CRM_Core_SelectValues::privacy();
     $this->assign('contactId', $contactId);
     $this->assign($defaults);
     // check logged in user permission
     CRM_Contact_Page_View::checkUserPermission($this, $contactId);
     // finally call parent
     parent::run();
 }
Exemplo n.º 3
0
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  */
 public function run()
 {
     // get the emails for this contact
     $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $params = array('id' => $contactId);
     $defaults = array();
     CRM_Contact_BAO_Contact::getValues($params, $defaults);
     if (!empty($defaults['gender_id'])) {
         $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id');
         $defaults['gender_display'] = $gender[CRM_Utils_Array::value('gender_id', $defaults)];
     }
     $this->assign('contactId', $contactId);
     $this->assign($defaults);
     //for birthdate format with respect to birth format set
     $this->assign('birthDateViewFormat', CRM_Utils_Array::value('qfMapping', CRM_Utils_Date::checkBirthDateFormat()));
     // check logged in user permission
     CRM_Contact_Page_View::checkUserPermission($this, $contactId);
     // finally call parent
     parent::run();
 }
Exemplo n.º 4
0
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  *
  * @return void
  */
 public function run()
 {
     // get the emails for this contact
     $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $params = array('id' => $contactId);
     $defaults = array();
     CRM_Contact_BAO_Contact::getValues($params, $defaults);
     //get the current employer name
     if (CRM_Utils_Array::value('contact_type', $defaults) == 'Individual') {
         if (!empty($defaults['employer_id']) && !empty($defaults['organization_name'])) {
             $defaults['current_employer'] = $defaults['organization_name'];
             $defaults['current_employer_id'] = $defaults['employer_id'];
         }
     }
     $this->assign('contactId', $contactId);
     $this->assign($defaults);
     // check logged in user permission
     CRM_Contact_Page_View::checkUserPermission($this, $contactId);
     // finally call parent
     parent::run();
 }
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  *
  * @return void
  */
 public function run()
 {
     // get the emails for this contact
     $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $params = array('id' => $contactId);
     $defaults = array();
     CRM_Contact_BAO_Contact::getValues($params, $defaults);
     $defaults['privacy_values'] = CRM_Core_SelectValues::privacy();
     $communicationStyle = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id');
     if (!empty($communicationStyle)) {
         if (!empty($defaults['communication_style_id'])) {
             $defaults['communication_style_display'] = $communicationStyle[CRM_Utils_Array::value('communication_style_id', $defaults)];
         } else {
             // Make sure the field is displayed as long as it is active, even if it is unset for this contact.
             $defaults['communication_style_display'] = '';
         }
     }
     $this->assign('contactId', $contactId);
     $this->assign($defaults);
     // check logged in user permission
     CRM_Contact_Page_View::checkUserPermission($this, $contactId);
     // finally call parent
     parent::run();
 }
 /**
  * set defaults for the form
  *
  * @return void
  * @access public
  */
 public function setDefaultValues()
 {
     $defaults = array();
     $params = array('id' => $this->_contactId);
     $defaults = array();
     CRM_Contact_BAO_Contact::getValues($params, $defaults);
     $this->_contactType = CRM_Utils_Array::value('contact_type', $defaults);
     if (!empty($defaults['preferred_language'])) {
         $languages = array_flip(CRM_Core_PseudoConstant::languages());
         $defaults['preferred_language'] = $languages[$defaults['preferred_language']];
     }
     // CRM-7119: set preferred_language to default if unset
     if (empty($defaults['preferred_language'])) {
         $config = CRM_Core_Config::singleton();
         $defaults['preferred_language'] = $config->lcMessages;
     }
     foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
         $name = "{$greeting}_display";
         $this->assign($name, CRM_Utils_Array::value($name, $defaults));
     }
     return $defaults;
 }
Exemplo n.º 7
0
/**
 * Get an existing contact.
 *
 * Returns a single existing Contact object which matches ALL property
 * values passed in $params. An error object is returned if there is
 * no match, or more than one match. This API can be used to retrieve
 * the CRM internal identifier (contact_id) based on a unique property
 * (e.g. email address). It can also be used to retrieve any desired
 * contact properties based on a known contact_id. Available
 * properties for each type of Contact are listed in the {@link
 * http://objectledge.org/confluence/display/CRM/Data+Model#DataModel-ContactRef
 * CRM Data Model.} Modules may also invoke crm_get_class_properties()
 * to retrieve all available property names, including extended
 * (i.e. custom) properties.contact of the specific type that matches
 * the input params  
 *
 * <b>Primary Location and Communication Info</b>
 *
 * <ul>
 * <li>Primary location properties (email address, phone, postal address,
 * etc.) are available in the Contact data objects. Primary email and
 * phone number are returned by default. Postal address fields and
 * primary instant messenger identifier are returned when specified in
 * $return_properties. For contacts with multiple locations, use
 * crm_get_locations() to retrieve additional location data.</li> 
 * </ul>
 *
 * @see crm_get_class_properties()
 * @see crm_get_locations()
 *
 * @example api/Contact.php
 *
 * @param array $params           Associative array of property name/value
 *                                pairs to attempt to match on.
 * @param array $returnProperties Which properties should be included in the
 *                                returned Contact object. If NULL, the default
 *                                set of properties will be included.
 *
 * @return CRM_Contact|CRM_Core_Error  Return the Contact Object if found, else
 *                                Error Object
 *
 * @access public
 *
 */
function &crm_get_contact($params, $returnProperties = null)
{
    _crm_initialize();
    // empty parameters ?
    if (empty($params)) {
        return _crm_error('$params is empty');
    }
    // correct parameter format ?
    if (!is_array($params)) {
        return _crm_error('$params is not an array');
    }
    if (!CRM_Utils_Array::value('contact_id', $params)) {
        $returnProperties = array('display_name');
        list($contacts, $options) = crm_contact_search($params, $returnProperties);
        if (count($contacts) != 1) {
            return _crm_error(count($contacts) . " contacts matching input params.");
        }
        $contactIds = array_keys($contacts);
        $params['contact_id'] = $contactIds[0];
    }
    $params['id'] = $params['contact_id'];
    $ids = array();
    $contact =& CRM_Contact_BAO_Contact::getValues($params, $defaults, $ids);
    if ($contact == null || is_a($contact, 'CRM_Core_Error') || !$contact->id) {
        return _crm_error('Did not find contact object for ' . $params['contact_id']);
    }
    unset($params['id']);
    require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_BAO_" . $contact->contact_type) . ".php";
    $contact->contact_type_object = eval('return CRM_Contact_BAO_' . $contact->contact_type . '::getValues( $params, $defaults, $ids );');
    $contact->location =& CRM_Core_BAO_Location::getValues($params, $defaults, $ids, 2);
    //changed the location no
    $contact->custom_values =& CRM_Core_BAO_CustomValue::getContactValues($contact->id);
    return $contact;
}
Exemplo n.º 8
0
 /**
  * Takes a bunch of params that are needed to match certain criteria and
  * retrieves the relevant objects. Typically the valid params are only
  * contact_id. We'll tweak this function to be more full featured over a period
  * of time. This is the inverse function of create. It also stores all the retrieved
  * values in the default array
  *
  * @param array $params   (reference ) an assoc array of name/value pairs
  * @param array $defaults (reference ) an assoc array to hold the name / value pairs
  *                        in a hierarchical manner
  * @param array $ids      (reference) the array that holds all the db ids
  *
  * @return object CRM_Contact_BAO_Contact object
  * @access public
  * @static
  */
 function retrieve(&$params, &$defaults, &$ids)
 {
     $contact = CRM_Contact_BAO_Contact::getValues($params, $defaults, $ids);
     unset($params['id']);
     require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_BAO_" . $contact->contact_type) . ".php";
     eval('$contact->contact_type_object =& CRM_Contact_BAO_' . $contact->contact_type . '::getValues( $params, $defaults, $ids );');
     $locParams = $params + array('entity_id' => $params['contact_id'], 'entity_table' => CRM_Contact_BAO_Contact::getTableName());
     $contact->location =& CRM_Core_BAO_Location::getValues($locParams, $defaults, $ids, 3);
     $contact->notes =& CRM_Core_BAO_Note::getValues($params, $defaults, $ids);
     $contact->relationship =& CRM_Contact_BAO_Relationship::getValues($params, $defaults, $ids);
     $contact->groupContact =& CRM_Contact_BAO_GroupContact::getValues($params, $defaults, $ids);
     $activityParam = array('entity_id' => $params['contact_id']);
     $contact->activity =& CRM_Core_BAO_History::getValues($activityParam, $defaults, 'Activity');
     $activityParam = array('contact_id' => $params['contact_id']);
     $defaults['openActivity'] = array('data' => CRM_Contact_BAO_Contact::getOpenActivities($activityParam, 0, 3), 'totalCount' => CRM_Contact_BAO_Contact::getNumOpenActivity($params['contact_id']));
     return $contact;
 }