Exemplo n.º 1
0
 function setDefaultValues()
 {
     // check if the user is registered and we have a contact ID
     $session =& CRM_Core_Session::singleton();
     $contactID = $session->get('userID');
     if ($contactID) {
         $options = array();
         $fields = array();
         foreach ($this->_fields as $name => $dontCare) {
             $fields[$name] = 1;
         }
         $fields['state_province'] = $fields['country'] = $fields['email'] = 1;
         $contact =& CRM_Contact_BAO_Contact::contactDetails($contactID, $options, $fields);
         foreach ($fields as $name => $dontCare) {
             if ($contact->{$name}) {
                 if (substr($name, 0, 7) == 'custom_') {
                     $id = substr($name, 7);
                     $this->_defaults[$name] = CRM_Core_BAO_CustomField::getDefaultValue($contact->{$name}, $id, $options);
                 } else {
                     $this->_defaults[$name] = $contact->{$name};
                 }
             }
         }
     }
     // hack to simplify credit card entry for testing
     /**
             $this->_defaults['credit_card_type']     = 'Visa';
             $this->_defaults['credit_card_number']   = '4807731747657838';
             $this->_defaults['cvv2']                 = '000';
             $this->_defaults['credit_card_exp_date'] = array( 'Y' => '2008', 'M' => '01' );
             **/
     return $this->_defaults;
 }