示例#1
0
 /**
  * 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 void
  */
 function setDefaultValues()
 {
     $defaults = array();
     $showHide = new CRM_Core_ShowHideBlocks();
     if ($this->_action == CRM_Core_Action::ADD) {
         $defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_UFJoin');
     }
     //id fetched for Dojo Pane
     $pId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     if (isset($pId)) {
         $this->_id = $pId;
     }
     if (isset($this->_id)) {
         $defaults['weight'] = CRM_Core_BAO_UFGroup::getWeight($this->_id);
         $params = array('id' => $this->_id);
         CRM_Core_BAO_UFGroup::retrieve($params, $defaults);
         $defaults['group'] = CRM_Utils_Array::value('limit_listings_group_id', $defaults);
         $defaults['add_contact_to_group'] = CRM_Utils_Array::value('add_to_group_id', $defaults);
         //get the uf join records for current uf group
         $ufJoinRecords = CRM_Core_BAO_UFGroup::getUFJoinRecord($this->_id);
         foreach ($ufJoinRecords as $key => $value) {
             $checked[$value] = 1;
         }
         $defaults['uf_group_type'] = isset($checked) ? $checked : "";
         //get the uf join records for current uf group other than default modules
         $otherModules = array();
         $otherModules = CRM_Core_BAO_UFGroup::getUFJoinRecord($this->_id, TRUE, TRUE);
         if (!empty($otherModules)) {
             $otherModuleString = NULL;
             foreach ($otherModules as $key) {
                 $otherModuleString .= " [ x ] <label>" . $key . "</label>";
             }
             $this->assign('otherModuleString', $otherModuleString);
         }
         $showAdvanced = 0;
         $advFields = array('group', 'post_URL', 'cancel_URL', 'add_captcha', 'is_map', 'is_uf_link', 'is_edit_link', 'is_update_dupe', 'is_cms_user', 'is_proximity_search');
         foreach ($advFields as $key) {
             if (!empty($defaults[$key])) {
                 $showAdvanced = 1;
                 $this->_allPanes['Advanced Settings']['open'] = 'true';
                 break;
             }
         }
     } else {
         $defaults['is_active'] = 1;
         $defaults['is_map'] = 0;
         $defaults['is_update_dupe'] = 0;
         $defaults['is_proximity_search'] = 0;
     }
     // Don't assign showHide elements to template in DELETE mode (fields to be shown and hidden don't exist)
     if (!($this->_action & CRM_Core_Action::DELETE) && !($this->_action & CRM_Core_Action::DISABLE)) {
         $showHide->addToTemplate();
     }
     $this->assign('allPanes', $this->_allPanes);
     return $defaults;
 }
示例#2
0
 /**
  * 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 void
  */
 function setDefaultValues()
 {
     $defaults = array();
     if ($this->_action == CRM_CORE_ACTION_ADD) {
         $defaults['weight'] = CRM_Core_BAO_UFGroup::getWeight();
         $UFGroupType = CRM_Core_SelectValues::ufGroupTypes();
         foreach ($UFGroupType as $key => $value) {
             $checked[$key] = 1;
         }
         $defaults['uf_group_type'] = $checked;
     }
     if (isset($this->_id)) {
         $defaults['weight'] = CRM_Core_BAO_UFGroup::getWeight($this->_id);
         $params = array('id' => $this->_id);
         CRM_Core_BAO_UFGroup::retrieve($params, $defaults);
         $defaults['group'] = $defaults['limit_listings_group_id'];
         //get the uf join records for current uf group
         $ufJoinRecords = CRM_Core_BAO_UFGroup::getUFJoinRecord($this->_id);
         foreach ($ufJoinRecords as $key => $value) {
             $checked[$value] = 1;
         }
         $defaults['uf_group_type'] = $checked;
         //get the uf join records for current uf group other than default modules
         $otherModules = array();
         $otherModules = CRM_Core_BAO_UFGroup::getUFJoinRecord($this->_id, true, true);
         if (!empty($otherModules)) {
             foreach ($otherModules as $key) {
                 $otherModuleString .= " [ x ] " . $key;
             }
             $this->assign('otherModuleString', $otherModuleString);
         }
     } else {
         $defaults['is_active'] = 1;
     }
     return $defaults;
 }