/**
  * 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 flattened values
  *
  * @return object CRM_Core_BAO_LocaationType object on success, null otherwise
  * @access public
  * @static
  */
 static function retrieve(&$params, &$defaults)
 {
     $locationType = new CRM_Core_DAO_LocationType();
     $locationType->copyValues($params);
     if ($locationType->find(true)) {
         CRM_Core_DAO::storeValues($locationType, $defaults);
         return $locationType;
     }
     return null;
 }
 /**
  * Add a Location Type.
  *
  * @param array $params
  * @return CRM_Core_DAO_LocationType
  *   location id of created location
  */
 public function locationTypeCreate($params = NULL)
 {
     if ($params === NULL) {
         $params = array('name' => 'New Location Type', 'vcard_name' => 'New Location Type', 'description' => 'Location Type for Delete', 'is_active' => 1);
     }
     $locationType = new CRM_Core_DAO_LocationType();
     $locationType->copyValues($params);
     $locationType->save();
     // clear getfields cache
     CRM_Core_PseudoConstant::flush();
     $this->callAPISuccess('phone', 'getfields', array('version' => 3, 'cache_clear' => 1));
     return $locationType;
 }
Example #3
0
 /**
  * Add a Location Type.
  *
  * @param array $params
  *   Reference array contains the values submitted by the form.
  *
  *
  * @return object
  */
 public static function create(&$params)
 {
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
     $params['is_default'] = CRM_Utils_Array::value('is_default', $params, FALSE);
     $params['is_reserved'] = CRM_Utils_Array::value('is_reserved', $params, FALSE);
     // action is taken depending upon the mode
     $locationType = new CRM_Core_DAO_LocationType();
     $locationType->copyValues($params);
     if ($params['is_default']) {
         $query = "UPDATE civicrm_location_type SET is_default = 0";
         CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
     }
     $locationType->save();
     return $locationType;
 }
Example #4
0
 /**
  * Add a Location Type.
  *
  * @param array $params
  *   Reference array contains the values submitted by the form.
  *
  *
  * @return object
  */
 public static function create(&$params)
 {
     if (empty($params['id'])) {
         $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
         $params['is_default'] = CRM_Utils_Array::value('is_default', $params, FALSE);
         $params['is_reserved'] = CRM_Utils_Array::value('is_reserved', $params, FALSE);
     }
     $locationType = new CRM_Core_DAO_LocationType();
     $locationType->copyValues($params);
     if (!empty($params['is_default'])) {
         $query = "UPDATE civicrm_location_type SET is_default = 0";
         CRM_Core_DAO::executeQuery($query);
     }
     $locationType->save();
     return $locationType;
 }