/**
  * 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');
 }
Exemple #2
0
 /**
  * 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)));
 }
 /**
  * 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)));
     }
 }