示例#1
0
 /**
  * Set default values for the form.
  *
  * Note that in edit/view mode the default values are retrieved from the database
  */
 public function setDefaultValues()
 {
     $defaults = $this->_values;
     if ($this->_action & CRM_Core_Action::ADD) {
         if (array_key_exists('TagsAndGroups', $this->_editOptions)) {
             // set group and tag defaults if any
             if ($this->_gid) {
                 $defaults['group'][] = $this->_gid;
             }
             if ($this->_tid) {
                 $defaults['tag'][$this->_tid] = 1;
             }
         }
         if ($this->_contactSubType) {
             $defaults['contact_sub_type'] = $this->_contactSubType;
         }
     } else {
         foreach ($defaults['email'] as $dontCare => &$val) {
             if (isset($val['signature_text'])) {
                 $val['signature_text_hidden'] = $val['signature_text'];
             }
             if (isset($val['signature_html'])) {
                 $val['signature_html_hidden'] = $val['signature_html'];
             }
         }
         if (!empty($defaults['contact_sub_type'])) {
             $defaults['contact_sub_type'] = $this->_oldSubtypes;
         }
     }
     // set defaults for blocks ( custom data, address, communication preference, notes, tags and groups )
     foreach ($this->_editOptions as $name => $label) {
         if (!in_array($name, array('Address', 'Notes'))) {
             $className = 'CRM_Contact_Form_Edit_' . $name;
             $className::setDefaultValues($this, $defaults);
         }
     }
     //set address block defaults
     CRM_Contact_Form_Edit_Address::setDefaultValues($defaults, $this);
     if (!empty($defaults['image_URL'])) {
         list($imageWidth, $imageHeight) = getimagesize(CRM_Utils_String::unstupifyUrl($defaults['image_URL']));
         list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
         $this->assign('imageWidth', $imageWidth);
         $this->assign('imageHeight', $imageHeight);
         $this->assign('imageThumbWidth', $imageThumbWidth);
         $this->assign('imageThumbHeight', $imageThumbHeight);
         $this->assign('imageURL', $defaults['image_URL']);
     }
     //set location type and country to default for each block
     $this->blockSetDefaults($defaults);
     $this->_preEditValues = $defaults;
     return $defaults;
 }
 /**
  * set defaults for the form
  *
  * @return void
  * @access public
  */
 public function setDefaultValues()
 {
     $defaults = $this->_values;
     $config = CRM_Core_Config::singleton();
     //set address block defaults
     if (CRM_Utils_Array::value('address', $defaults)) {
         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;
     }
     $values = $defaults['address'][$this->_locBlockNo];
     CRM_Contact_Form_Edit_Address::fixStateSelect($this, "address[{$this->_locBlockNo}][country_id]", "address[{$this->_locBlockNo}][state_province_id]", "address[{$this->_locBlockNo}][county_id]", CRM_Utils_Array::value('country_id', $values, $config->defaultContactCountry), CRM_Utils_Array::value('state_province_id', $values));
     return $defaults;
 }
示例#3
0
 /**
  * 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;
 }
 /**
  * This function sets the default values for the form. Note that in edit/view mode
  * the default values are retrieved from the database
  *
  * @access public
  *
  * @return None
  */
 function setDefaultValues()
 {
     $defaults = $this->_values;
     $params = array();
     if ($this->_action & CRM_Core_Action::ADD) {
         if (array_key_exists('TagsAndGroups', $this->_editOptions)) {
             // set group and tag defaults if any
             if ($this->_gid) {
                 $defaults['group'][$this->_gid] = 1;
             }
             if ($this->_tid) {
                 $defaults['tag'][$this->_tid] = 1;
             }
         }
         if ($this->_contactSubType) {
             $defaults['contact_sub_type'] = $this->_contactSubType;
         }
     } else {
         $currentEmployer = CRM_Contact_BAO_Relationship::getCurrentEmployer(array($this->_contactId));
         $defaults['current_employer_id'] = CRM_Utils_Array::value('org_id', $currentEmployer[$this->_contactId]);
         foreach ($defaults['email'] as $dontCare => &$val) {
             if (isset($val['signature_text'])) {
                 $val['signature_text_hidden'] = $val['signature_text'];
             }
             if (isset($val['signature_html'])) {
                 $val['signature_html_hidden'] = $val['signature_html'];
             }
         }
         if (CRM_Utils_Array::value('contact_sub_type', $defaults)) {
             $defaults['contact_sub_type'] = $this->_oldSubtypes;
         }
     }
     $this->assign('currentEmployer', CRM_Utils_Array::value('current_employer_id', $defaults));
     // set defaults for blocks ( custom data, address, communication preference, notes, tags and groups )
     foreach ($this->_editOptions as $name => $label) {
         if (!in_array($name, array('Address', 'Notes'))) {
             eval('CRM_Contact_Form_Edit_' . $name . '::setDefaultValues( $this, $defaults );');
         }
     }
     //set address block defaults
     CRM_Contact_Form_Edit_Address::setDefaultValues($defaults, $this);
     if (CRM_Utils_Array::value('image_URL', $defaults)) {
         list($imageWidth, $imageHeight) = getimagesize($defaults['image_URL']);
         list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
         $this->assign('imageWidth', $imageWidth);
         $this->assign('imageHeight', $imageHeight);
         $this->assign('imageThumbWidth', $imageThumbWidth);
         $this->assign('imageThumbHeight', $imageThumbHeight);
         $this->assign('imageURL', $defaults['image_URL']);
     }
     //set location type and country to default for each block
     $this->blockSetDefaults($defaults);
     $this->_preEditValues = $defaults;
     return $defaults;
 }