예제 #1
0
 /**
  * Process the form when submitted.
  *
  * @return void
  */
 public function postProcess()
 {
     $field = new CRM_Core_DAO_CustomField();
     $field->id = $this->_id;
     $field->find(TRUE);
     CRM_Core_BAO_CustomField::deleteField($field);
     // also delete any profiles associted with this custom field
     CRM_Core_Session::setStatus(ts('The custom field \'%1\' has been deleted.', array(1 => $field->label)), '', 'success');
 }
예제 #2
0
 function testDeleteCustomfield()
 {
     $customGroup = Custom::createGroup(array(), 'Individual');
     $fields = array('groupId' => $customGroup->id, 'dataType' => 'Memo', 'htmlType' => 'TextArea');
     $customField = Custom::createField(array(), $fields);
     CRM_Core_BAO_CustomField::deleteField($customField);
     $this->assertDBNull('CRM_Core_DAO_CustomField', $customGroup->id, 'id', 'custom_group_id', 'Database check for deleted Custom Field.');
     Custom::deleteGroup($customGroup);
 }
예제 #3
0
 public function testDeleteCustomField()
 {
     $customGroup = $this->customGroupCreate(array('extends' => 'Individual'));
     $fields = array('custom_group_id' => $customGroup['id'], 'label' => 'Throwaway Field', 'dataType' => 'Memo', 'htmlType' => 'TextArea');
     $customField = $this->customFieldCreate($fields);
     $fieldObject = new CRM_Core_BAO_CustomField();
     $fieldObject->id = $customField['id'];
     $fieldObject->find(TRUE);
     CRM_Core_BAO_CustomField::deleteField($fieldObject);
     $this->assertDBNull('CRM_Core_DAO_CustomField', $customGroup['id'], 'id', 'custom_group_id', 'Database check for deleted Custom Field.');
     $this->customGroupDelete($customGroup['id']);
 }
예제 #4
0
/**
 * Use this API to delete an existing custom group field.
 *
 * @param $params     Array id of the field to be deleted
 *
 * @return array
 * @example CustomFieldDelete.php
 *
 * {@example CustomFieldDelete.php 0}
 * {@getfields CustomField_delete}
 * @access public
 **/
function civicrm_api3_custom_field_delete($params)
{
    $field = new CRM_Core_BAO_CustomField();
    $field->id = $params['id'];
    $field->find(TRUE);
    $customFieldDelete = CRM_Core_BAO_CustomField::deleteField($field);
    civicrm_api('custom_field', 'getfields', array('version' => 3, 'cache_clear' => 1));
    return $customFieldDelete ? civicrm_api3_create_error('Error while deleting custom field') : civicrm_api3_create_success();
}
예제 #5
0
 /**
  * Delete the Custom Group.
  *
  * @param CRM_Core_BAO_CustomGroup $group
  *   Custom group object.
  * @param bool $force
  *   whether to force the deletion, even if there are custom fields.
  *
  * @return bool
  *   False if field exists for this group, true if group gets deleted.
  */
 public static function deleteGroup($group, $force = FALSE)
 {
     //check whether this contain any custom fields
     $customField = new CRM_Core_DAO_CustomField();
     $customField->custom_group_id = $group->id;
     $customField->find();
     // return early if there are custom fields and we're not
     // forcing the delete, otherwise delete the fields one by one
     while ($customField->fetch()) {
         if (!$force) {
             return FALSE;
         }
         CRM_Core_BAO_CustomField::deleteField($customField);
     }
     // drop the table associated with this custom group
     CRM_Core_BAO_SchemaHandler::dropTable($group->table_name);
     //delete  custom group
     $group->delete();
     CRM_Utils_Hook::post('delete', 'CustomGroup', $group->id, $group);
     return TRUE;
 }
예제 #6
0
 /**
  * Process the form when submitted
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     // step 1: copy and create dstField and column
     require_once 'CRM/Core/BAO/CustomField.php';
     $field = new CRM_Core_DAO_CustomField();
     $field->id = $this->_srcFID;
     if (!$field->find(true)) {
         CRM_Core_Error::fatal();
     }
     // now change the field group ID and save it, also unset the id
     unset($field->id);
     // step 2: copy data from srcColumn to dstColumn
     $query = "\nINSERT INTO {$dstTable} ( {$entityID}, {$dstColumn} )\nSELECT {$entityID}, {$srcColumn}\nFROM   {$srcTable}\nON DUPLICATE KEY UPDATE {$dstColumn} = {$srcColumn}";
     CRM_Core_DAO::query($query, CRM_Core_DAO::$_nullArray);
     // step 3: remove srcField (which should also delete the srcColumn
     require_once 'CRM/Core/BAO/CustomField.php';
     $field = new CRM_Core_DAO_CustomField();
     $field->id = $this->_srcFID;
     CRM_Core_BAO_CustomField::deleteField($field);
 }
예제 #7
0
 /**
  * Helper function to delete custom field
  * @deprecated use function on parent class
  * @param  object of Custom Field to delete
  */
 static function deleteField($params)
 {
     require_once 'CRM/Core/BAO/CustomField.php';
     CRM_Core_BAO_CustomField::deleteField($params);
 }
예제 #8
0
 /**
  * Process the form when submitted
  *
  * @param null
  * 
  * @return void
  * @access public
  */
 public function postProcess()
 {
     $field =& new CRM_Core_DAO_CustomField();
     $field->id = $this->_id;
     $field->find(true);
     CRM_Core_BAO_CustomField::deleteField($field);
     // also delete any profiles associted with this custom field
     require_once "CRM/Core/BAO/UFField.php";
     CRM_Core_BAO_UFField::delUFField($this->_id);
     CRM_Core_Session::setStatus(ts('The custom field \'%1\' has been deleted.', array(1 => $field->label)));
     CRM_Utils_Weight::correctDuplicateWeights('CRM_Core_DAO_CustomField');
 }
예제 #9
0
/**
 * Use this API to delete an existing custom group field.
 *
 * @param $params     Array id of the field to be deleted
 *
 *       
 * @access public
 **/
function civicrm_custom_field_delete($params)
{
    _civicrm_initialize();
    if (!is_array($params)) {
        return civicrm_create_error('Params is not an array');
    }
    if (!CRM_Utils_Array::value('customFieldId', $params['result'])) {
        return civicrm_create_error('Invalid or no value for Custom Field ID');
    }
    require_once 'CRM/Core/DAO/CustomField.php';
    $field = new CRM_Core_DAO_CustomField();
    $field->id = $params['result']['customFieldId'];
    $field->find(true);
    require_once 'CRM/Core/BAO/CustomField.php';
    $customFieldDelete = CRM_Core_BAO_CustomField::deleteField($field);
    return $customFieldDelete ? civicrm_create_error('Error while deleting custom field') : civicrm_create_success();
}
예제 #10
0
 /**
  * Helper function to delete custom field.
  *
  * @deprecated use function on parent class
  *
  * @param $params
  */
 public static function deleteField($params)
 {
     CRM_Core_BAO_CustomField::deleteField($params);
 }